mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-24 05:58:08 +00:00
Added possebility to call settings for just one application.
This commit is contained in:
parent
14a412b54f
commit
cf46a9aae1
@ -69,11 +69,15 @@ void listSettings(SettingsType type, const QString &application)
|
||||
}
|
||||
}
|
||||
|
||||
int showWindow(const QString &appName)
|
||||
{
|
||||
SettingsWindow *window = new SettingsWindow(appName);
|
||||
window->show();
|
||||
return qApp->exec();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
SettingsWindow *window;
|
||||
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName(QLatin1String("SnoreSettings"));
|
||||
app.setOrganizationName(QLatin1String("SnoreNotify"));
|
||||
@ -113,10 +117,9 @@ int main(int argc, char *argv[])
|
||||
listApps();
|
||||
} else if (parser.isSet(listSettingsCommand)) {
|
||||
listSettings(type, appName);
|
||||
} else if (parser.optionNames().empty() && parser.positionalArguments().empty()) {
|
||||
window = new SettingsWindow();
|
||||
window->show();
|
||||
return app.exec();
|
||||
} else if ((parser.optionNames().empty() || (parser.optionNames().size() == 1 && parser.isSet(appNameCommand)))
|
||||
&& parser.positionalArguments().empty()) {
|
||||
return showWindow(appName);
|
||||
} else {
|
||||
QStringList posArgs = parser.positionalArguments();
|
||||
if (posArgs.size() != 2) {
|
||||
|
@ -26,18 +26,34 @@
|
||||
#include <QApplication>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
SettingsWindow::SettingsWindow(QWidget *parent) :
|
||||
SettingsWindow::SettingsWindow(const QString &appName, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::SettingsWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->widget->show();
|
||||
|
||||
if (appName.isEmpty()) {
|
||||
QStringList list = knownApps();
|
||||
list.removeAll(qApp->applicationName());
|
||||
ui->comboBox->addItems(list);
|
||||
} else {
|
||||
if (!knownApps().contains(appName)) {
|
||||
|
||||
std::wcerr << "Error: " << appName.toUtf8().constData() << " is not known to Snorenotify" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
ui->comboBox->deleteLater();
|
||||
ui->label->deleteLater();
|
||||
SnoreCorePrivate::instance()->setLocalSttingsPrefix(appName);
|
||||
setWindowTitle(appName + tr(" Settings"));
|
||||
ui->widget->initTabs();
|
||||
ui->widget->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
SettingsWindow::~SettingsWindow()
|
||||
|
@ -33,7 +33,7 @@ class SettingsWindow : public QMainWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsWindow(QWidget *parent = 0);
|
||||
explicit SettingsWindow(const QString &appName, QWidget *parent = 0);
|
||||
~SettingsWindow();
|
||||
|
||||
static QStringList knownApps();
|
||||
|
Loading…
x
Reference in New Issue
Block a user