commit a1da4d9454994611b7782915ab3d1e1d1663eef4 Author: Carl Klemm Date: Sat Jun 13 12:32:49 2020 +0200 Inital commit diff --git a/debian/.debhelper/generated/sigstoped/installed-by-dh_installdocs b/debian/.debhelper/generated/sigstoped/installed-by-dh_installdocs new file mode 100644 index 0000000..e69de29 diff --git a/debian/.debhelper/sigstoped/dbgsym-build-ids b/debian/.debhelper/sigstoped/dbgsym-build-ids new file mode 100644 index 0000000..3b7a36e --- /dev/null +++ b/debian/.debhelper/sigstoped/dbgsym-build-ids @@ -0,0 +1 @@ +8d2a153010b3e35a0500b1969e6f855421d6aee4 \ No newline at end of file diff --git a/debian/.debhelper/sigstoped/dbgsym-root/DEBIAN/control b/debian/.debhelper/sigstoped/dbgsym-root/DEBIAN/control new file mode 100644 index 0000000..5bac24e --- /dev/null +++ b/debian/.debhelper/sigstoped/dbgsym-root/DEBIAN/control @@ -0,0 +1,13 @@ +Package: sigstoped-dbgsym +Source: sigstoped +Version: 1:0.73-1 +Auto-Built-Package: debug-symbols +Architecture: amd64 +Maintainer: Uvos +Installed-Size: 349 +Depends: sigstoped (= 1:0.73-1) +Section: debug +Priority: optional +Multi-Arch: same +Description: debug symbols for sigstoped +Build-Ids: 8d2a153010b3e35a0500b1969e6f855421d6aee4 diff --git a/debian/.debhelper/sigstoped/dbgsym-root/DEBIAN/md5sums b/debian/.debhelper/sigstoped/dbgsym-root/DEBIAN/md5sums new file mode 100644 index 0000000..b1c7cfd --- /dev/null +++ b/debian/.debhelper/sigstoped/dbgsym-root/DEBIAN/md5sums @@ -0,0 +1 @@ +fda7b3cbcccd3e15500982d40bd692e5 usr/lib/debug/.build-id/8d/2a153010b3e35a0500b1969e6f855421d6aee4.debug diff --git a/debian/.debhelper/sigstoped/dbgsym-root/usr/lib/debug/.build-id/8d/2a153010b3e35a0500b1969e6f855421d6aee4.debug b/debian/.debhelper/sigstoped/dbgsym-root/usr/lib/debug/.build-id/8d/2a153010b3e35a0500b1969e6f855421d6aee4.debug new file mode 100644 index 0000000..7104782 Binary files /dev/null and b/debian/.debhelper/sigstoped/dbgsym-root/usr/lib/debug/.build-id/8d/2a153010b3e35a0500b1969e6f855421d6aee4.debug differ diff --git a/debian/.debhelper/sigstoped/dbgsym-root/usr/share/doc/sigstoped-dbgsym b/debian/.debhelper/sigstoped/dbgsym-root/usr/share/doc/sigstoped-dbgsym new file mode 120000 index 0000000..c82963e --- /dev/null +++ b/debian/.debhelper/sigstoped/dbgsym-root/usr/share/doc/sigstoped-dbgsym @@ -0,0 +1 @@ +sigstoped \ No newline at end of file diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..fc6cccb --- /dev/null +++ b/debian/changelog @@ -0,0 +1,3 @@ +qsigstoped (1:1.0-1) unstable; urgency=medium + Inital version + -- Uvos Mon, 10 Jun 2020 15:00:00 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +10 diff --git a/debian/control b/debian/control new file mode 100755 index 0000000..22bfdfe --- /dev/null +++ b/debian/control @@ -0,0 +1,18 @@ +Source: qsigstoped +Section: base +Priority: optional +Maintainer: Uvos +Build-Depends: + debhelper, + qt5-qmake, + qt5-default, +Standards-Version: 1.0 + +Package: qsigstoped +Architecture: any +Multi-arch: same +Depends: + libqt5gui5, + libqt5core5a, +Description: An application to configure the qsigstoped deamon + diff --git a/debian/copywrite b/debian/copywrite new file mode 100644 index 0000000..61721d5 --- /dev/null +++ b/debian/copywrite @@ -0,0 +1,2 @@ +Unless stated otherwise, all files are: +Copyright 2020 Carl Klemm and are licensed under the GPLv3 diff --git a/debian/gbp.conf b/debian/gbp.conf new file mode 100644 index 0000000..bbb5a2e --- /dev/null +++ b/debian/gbp.conf @@ -0,0 +1,2 @@ +[DEFAULT] +upstream-tag=%(version)s diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..4f2c774 --- /dev/null +++ b/debian/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f +%: + dh $@ + diff --git a/desktopfile.cpp b/desktopfile.cpp new file mode 100644 index 0000000..4761845 --- /dev/null +++ b/desktopfile.cpp @@ -0,0 +1,63 @@ +#include "desktopfile.h" + +#include +#include +#include +#include +#include + +DesktopFile::DesktopFile(const QString& fileName) +{ + open(fileName); +} + +bool DesktopFile::operator==(const DesktopFile& in) +{ + return execName == in.execName; +} + +bool DesktopFile::open(const QString& fileName) +{ + if(QFile::exists(fileName)) + { + QSettings desktopFile(fileName, QSettings::IniFormat); + desktopFile.beginGroup("Desktop Entry"); + name = desktopFile.value("Name").toString(); + command = desktopFile.value("Exec").toString(); + execName = QFileInfo(command).fileName().split(' ').at(0); + return true; + } + else + { + qDebug()< DesktopFile::getDesktopFiles(const QList& desktopFileDirs) +{ + + QList desktopFiles; + + for(int i = 0; i < desktopFileDirs.size(); ++i) + { + QDir directory(desktopFileDirs[i] + "/applications"); + if(directory.exists()) + { + QStringList desktopFileNames = directory.entryList(QStringList() << "*.desktop",QDir::Files); + for(int j = 0; j < desktopFileNames.size(); ++j) + { + DesktopFile desktopFile(directory.path() + "/" + desktopFileNames[j]); + bool found = desktopFile.execName == ""; + for(int k = 0; k < desktopFiles.size(); ++k)if( desktopFile == desktopFiles[k] ) + { + found = true; + break; + } + + if(!found)desktopFiles.push_back(desktopFile); + } + } + } + return desktopFiles; +} diff --git a/desktopfile.h b/desktopfile.h new file mode 100644 index 0000000..9645e8f --- /dev/null +++ b/desktopfile.h @@ -0,0 +1,26 @@ +#ifndef DESKTOPFILE_H +#define DESKTOPFILE_H + +#include + +class DesktopFile +{ +public: + + QString name; + QString command; + QString execName; + QString iconPath; + + bool stop = false; + +public: + DesktopFile(const QString& fileName); + DesktopFile(){} + bool open(const QString& fileName); + bool operator==(const DesktopFile& in); + + static QList getDesktopFiles(const QList& desktopFileDirs); +}; + +#endif // DESKTOPFILE_H diff --git a/desktopfilewidget.cpp b/desktopfilewidget.cpp new file mode 100644 index 0000000..94814ff --- /dev/null +++ b/desktopfilewidget.cpp @@ -0,0 +1,31 @@ +#include "desktopfilewidget.h" +#include "ui_desktopfilewidget.h" +#include + +DesktopFileWidget::DesktopFileWidget(const DesktopFile& desktopfile, QWidget *parent) : + QWidget(parent), + ui(new Ui::DesktopFileWidget) +{ + ui->setupUi(this); + ui->label->setText(desktopfile.name); + ui->checkBox->setChecked(desktopfile.stop); + ui->checkBox->setStyleSheet("QCheckBox::indicator { width: 32px; height: 32px; } "); + + ui->checkBox->setTristate(false); + +} + +DesktopFileWidget::~DesktopFileWidget() +{ + delete ui; +} + +bool DesktopFileWidget::isChecked() +{ + return ui->checkBox->isChecked(); +} + +void DesktopFileWidget::mousePressEvent(QMouseEvent *event) +{ + ui->checkBox->setCheckState(ui->checkBox->checkState() == Qt::Checked ? Qt::Unchecked : Qt::Checked); +} diff --git a/desktopfilewidget.h b/desktopfilewidget.h new file mode 100644 index 0000000..d1da014 --- /dev/null +++ b/desktopfilewidget.h @@ -0,0 +1,30 @@ +#ifndef DESKTOPFILEWIDGET_H +#define DESKTOPFILEWIDGET_H + +#include +#include +#include "desktopfile.h" + +namespace Ui { +class DesktopFileWidget; +} + +class DesktopFileWidget : public QWidget +{ + Q_OBJECT + +public: + explicit DesktopFileWidget(const DesktopFile& desktopfile, QWidget *parent = nullptr); + ~DesktopFileWidget(); + + bool isChecked(); + +protected: + + virtual void mousePressEvent(QMouseEvent* event); + +private: + Ui::DesktopFileWidget *ui; +}; + +#endif // DESKTOPFILEWIDGET_H diff --git a/desktopfilewidget.ui b/desktopfilewidget.ui new file mode 100644 index 0000000..812a09f --- /dev/null +++ b/desktopfilewidget.ui @@ -0,0 +1,68 @@ + + + DesktopFileWidget + + + + 0 + 0 + 400 + 61 + + + + Form + + + + :/icons/qsigstoped.svg:/icons/qsigstoped.svg + + + + + + + 0 + 0 + + + + TextLabel + + + + + + + + 0 + 0 + + + + true + + + Qt::RightToLeft + + + false + + + + + + + 32 + 32 + + + + + + + + + + + diff --git a/icons/qsigstoped.png b/icons/qsigstoped.png new file mode 100644 index 0000000..3692238 Binary files /dev/null and b/icons/qsigstoped.png differ diff --git a/icons/qsigstoped.svg b/icons/qsigstoped.svg new file mode 100644 index 0000000..b41c1cb --- /dev/null +++ b/icons/qsigstoped.svg @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..3f68f14 --- /dev/null +++ b/main.cpp @@ -0,0 +1,92 @@ +#include "maindialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "desktopfile.h" + +void generateBlacklistFile(QString fileName, QVector widgets, const QList& desktopFiles, pid_t sigstopedPid) +{ + QFile blacklist(fileName); + blacklist.open(QIODevice::WriteOnly | QIODevice::Truncate); + if(!blacklist.isOpen()) + { + QMessageBox::critical(nullptr, "Error", "Can not open: " + fileName ); + } + else + { + for(int i = 0; i < widgets.size() && i < desktopFiles.size(); ++i) + { + if(widgets[i]->isChecked()) + { + blacklist.write(desktopFiles[i].execName.toUtf8()+'\n'); + qDebug()< desktopFileDirs = qgetenv("XDG_DATA_DIRS").split(':'); + qDebug()<<"Looking for .desktop files in:"; + for(int i = 0; i < desktopFileDirs.size(); ++i) qDebug()< desktopFiles = DesktopFile::getDesktopFiles(desktopFileDirs); + if(blacklist.isOpen()) + { + QList blacklistedApplicationNames = blacklist.readAll().split('\n'); + if(blacklistedApplicationNames.size() > 0 && blacklistedApplicationNames.back() == "") blacklistedApplicationNames.pop_back(); + for(int i = 0; i < blacklistedApplicationNames.size(); ++i) + { + qDebug()< +#include +#include + +MainDialog::MainDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::MainDialog) +{ + ui->setupUi(this); + connect(ui->buttonBox->button(ui->buttonBox->Apply), &QPushButton::clicked, this, &MainDialog::accepted); + QScroller::grabGesture(ui->scrollArea, QScroller::TouchGesture); + QScroller::grabGesture(ui->scrollArea, QScroller::LeftMouseButtonGesture); + + + ui->scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); +} + +MainDialog::~MainDialog() +{ + delete ui; + for(int i = 0; i& desktopFiles) +{ + for(int i = 0; iscollItemLayout->insertWidget(-1, widgets_[i]); +} + +QVector MainDialog::getWidgets() +{ + return widgets_; +} + diff --git a/maindialog.h b/maindialog.h new file mode 100644 index 0000000..7a34a8a --- /dev/null +++ b/maindialog.h @@ -0,0 +1,30 @@ +#ifndef MAINDIALOG_H +#define MAINDIALOG_H + +#include +#include +#include "desktopfilewidget.h" + +namespace Ui { +class MainDialog; +} + +class MainDialog : public QDialog +{ + Q_OBJECT + + QVector widgets_; + +public: + explicit MainDialog(QWidget *parent = nullptr); + ~MainDialog(); + + void setDesktopFiles(const QList& desktopFiles); + + QVector getWidgets(); + +private: + Ui::MainDialog *ui; +}; + +#endif // MAINDIALOG_H diff --git a/maindialog.ui b/maindialog.ui new file mode 100644 index 0000000..3fe4d82 --- /dev/null +++ b/maindialog.ui @@ -0,0 +1,116 @@ + + + MainDialog + + + + 0 + 0 + 400 + 300 + + + + + 400 + 200 + + + + QSigstoped + + + + :/icons/qsigstoped.png + + + + + + + Select Applications to stop in background: + + + + + + + QFrame::Plain + + + true + + + + + 0 + 0 + 384 + 216 + + + + + + + + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + true + + + + + + + + + buttonBox + accepted() + MainDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + MainDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..41a26bd --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,15 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + diff --git a/qsigstoped.desktop b/qsigstoped.desktop new file mode 100644 index 0000000..48d7387 --- /dev/null +++ b/qsigstoped.desktop @@ -0,0 +1,24 @@ + +[Desktop Entry] + +# The type as listed above +Type=Application + +# The version of the desktop entry specification to which this file complies +Version=1.0 + +# The name of the application +Name=QSigstoped + +# A comment which can/will be used as a tooltip +Comment=Tool to configure sigstoped + +# The executable of the application, possibly with arguments. +Exec=qsigstoped + +# The name of the icon that will be used to display this entry +Icon=qsigstoped + +# Describes whether this application needs to be run in a terminal or not +Terminal=false + diff --git a/qsigstoped.pro b/qsigstoped.pro new file mode 100644 index 0000000..eb2453f --- /dev/null +++ b/qsigstoped.pro @@ -0,0 +1,43 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++11 + +# The following define makes your compiler emit warnings if you use +# any Qt feature that has been marked deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + desktopfile.cpp \ + desktopfilewidget.cpp \ + main.cpp \ + maindialog.cpp + +HEADERS += \ + desktopfile.h \ + desktopfilewidget.h \ + maindialog.h + +FORMS += \ + desktopfilewidget.ui \ + maindialog.ui + + +unix:target.path = /usr/bin +unix:icons.path = /usr/share/icons +unix:icons.files = icons/* +unix:desktopfile.path = /usr/share/applications +unix:desktopfile.files = qsigstoped.desktop + +INSTALLS += target icons desktopfile + +RESOURCES += \ + resources.qrc diff --git a/resources.qrc b/resources.qrc new file mode 100644 index 0000000..bbb0e23 --- /dev/null +++ b/resources.qrc @@ -0,0 +1,5 @@ + + + icons/qsigstoped.png + +