diff --git a/sources/gui/src/dbusoperation.cpp b/sources/gui/src/dbusoperation.cpp index 4c72c20..a7ef689 100644 --- a/sources/gui/src/dbusoperation.cpp +++ b/sources/gui/src/dbusoperation.cpp @@ -30,7 +30,7 @@ QList parseOutputNetctl(const QList raw, if (debug) qDebug() << PDEBUG; QList profileInfo; - if (raw.size() == 0) return profileInfo; + if (raw.count() == 0) return profileInfo; QStringList list = raw[0].toStringList(); for (int i=0; i parseOutputWifi(const QList raw, if (debug) qDebug() << PDEBUG; QList wifiInfo; - if (raw.size() == 0) return wifiInfo; + if (raw.count() == 0) return wifiInfo; QStringList list = raw[0].toStringList(); for (int i=0; i sendDBusRequest(const QString service, const QString path, if (debug) qDebug() << PDEBUG << ":" << "args" << args; if (debug) qDebug() << PDEBUG << ":" << "is system bus" << system; - QList arguments; - QDBusMessage response; - if (system) { - QDBusConnection bus = QDBusConnection::systemBus(); - QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd); - if (!args.isEmpty()) - request.setArguments(args); - response = bus.call(request, QDBus::BlockWithGui); - } else { - QDBusConnection bus = QDBusConnection::sessionBus(); - QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd); - if (!args.isEmpty()) - request.setArguments(args); - response = bus.call(request, QDBus::BlockWithGui); - } - arguments = response.arguments(); - if (arguments.size() == 0) + QDBusConnection bus = QDBusConnection::sessionBus(); + if (system) + bus = QDBusConnection::systemBus(); + QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd); + if (!args.isEmpty()) request.setArguments(args); + QDBusMessage response = bus.call(request, QDBus::BlockWithGui); + QList arguments = response.arguments(); + if (arguments.count() == 0) if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage(); return arguments; diff --git a/sources/gui/src/ipwidget.cpp b/sources/gui/src/ipwidget.cpp index 52c9fee..ac3a0e8 100644 --- a/sources/gui/src/ipwidget.cpp +++ b/sources/gui/src/ipwidget.cpp @@ -108,7 +108,7 @@ void IpWidget::createActions() connect(ui->lineEdit_ipAddress, SIGNAL(returnPressed()), this, SLOT(addIp())); connect(ui->pushButton_ipRoutes, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes())); connect(ui->pushButton_ipAddress6, SIGNAL(clicked(bool)), this, SLOT(addIp6())); - connect(ui->lineEdit_ipAddress6, SIGNAL(returnPressed(bool)), this, SLOT(addIp6())); + connect(ui->lineEdit_ipAddress6, SIGNAL(returnPressed()), this, SLOT(addIp6())); connect(ui->pushButton_ipRoutes6, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes6())); connect(ui->pushButton_custom, SIGNAL(clicked(bool)), this, SLOT(addCustom())); connect(ui->lineEdit_custom, SIGNAL(returnPressed()), this, SLOT(addCustom())); diff --git a/sources/gui/src/main.cpp b/sources/gui/src/main.cpp index 923032b..8cebece 100644 --- a/sources/gui/src/main.cpp +++ b/sources/gui/src/main.cpp @@ -137,11 +137,11 @@ int main(int argc, char *argv[]) (args[QString("error")].toBool())) args[QString("detached")] = false; if (args[QString("essid")].toString() != QString("ESSID")) - args[QString("tab")] = (int) 3; + args[QString("tab")] = static_cast(3); if (args[QString("open")].toString() != QString("PROFILE")) - args[QString("tab")] = (int) 2; + args[QString("tab")] = static_cast(2); if (args[QString("select")].toString() != QString("PROFILE")) - args[QString("tab")] = (int) 1; + args[QString("tab")] = static_cast(1); // detach from console if (args[QString("detached")].toBool()) @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) if (args[QString("error")].toBool()) { cout << errorMessage().toUtf8().data() << endl; cout << helpMessage().toUtf8().data(); - return 127; + return 1; } else if (args[QString("help")].toBool()) { cout << helpMessage().toUtf8().data(); return 0; diff --git a/sources/gui/src/mainprivateslots.cpp b/sources/gui/src/mainprivateslots.cpp index a7aefce..f706980 100644 --- a/sources/gui/src/mainprivateslots.cpp +++ b/sources/gui/src/mainprivateslots.cpp @@ -353,15 +353,15 @@ void MainWindow::mainTabContextualMenu(const QPoint &pos) // create menu QMenu menu(this); QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh")); - refreshTable->setIcon(QIcon::fromTheme("stock-refresh")); + refreshTable->setIcon(QIcon::fromTheme("view-refresh")); menu.addSeparator(); QAction *startProfile = menu.addAction(QApplication::translate("MainWindow", "Start profile")); QAction *restartProfile = menu.addAction(QApplication::translate("MainWindow", "Restart profile")); - restartProfile->setIcon(QIcon::fromTheme("stock-refresh")); + restartProfile->setIcon(QIcon::fromTheme("view-refresh")); QAction *enableProfile = menu.addAction(QApplication::translate("MainWindow", "Enable profile")); menu.addSeparator(); QAction *editProfile = menu.addAction(QApplication::translate("MainWindow", "Edit profile")); - editProfile->setIcon(QIcon::fromTheme("edit")); + editProfile->setIcon(QIcon::fromTheme("document-edit")); QAction *removeProfile = menu.addAction(QApplication::translate("MainWindow", "Remove profile")); removeProfile->setIcon(QIcon::fromTheme("edit-delete")); @@ -899,7 +899,7 @@ void MainWindow::wifiTabContextualMenu(const QPoint &pos) // create menu QMenu menu(this); QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh")); - refreshTable->setIcon(QIcon::fromTheme("stock-refresh")); + refreshTable->setIcon(QIcon::fromTheme("view-refresh")); menu.addSeparator(); QAction *startWifi = menu.addAction(QApplication::translate("MainWindow", "Start WiFi")); diff --git a/sources/gui/src/mainpublicslots.cpp b/sources/gui/src/mainpublicslots.cpp index cfcd6bd..689f850 100644 --- a/sources/gui/src/mainpublicslots.cpp +++ b/sources/gui/src/mainpublicslots.cpp @@ -94,9 +94,13 @@ bool MainWindow::enableProfileSlot(const QString profile) sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, DBUS_HELPER_INTERFACE, QString("Enable"), args, true, debug); - current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, - DBUS_HELPER_INTERFACE, QString("isProfileEnabled"), - args, true, debug)[0].toBool(); + QList responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("isProfileEnabled"), + args, true, debug); + if (responce.isEmpty()) + current = netctlCommand->isProfileEnabled(profile); + else + current = responce[0].toBool(); } else { netctlCommand->enableProfile(profile); current = netctlCommand->isProfileEnabled(profile); @@ -118,9 +122,13 @@ bool MainWindow::restartProfileSlot(const QString profile) sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, DBUS_HELPER_INTERFACE, QString("Restart"), args, true, debug)[0].toBool(); - current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, - DBUS_HELPER_INTERFACE, QString("isProfileActive"), - args, true, debug)[0].toBool(); + QList responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("isProfileActive"), + args, true, debug); + if (responce.isEmpty()) + current = netctlCommand->isProfileActive(profile); + else + current = responce[0].toBool(); } else { netctlCommand->restartProfile(profile); current = netctlCommand->isProfileActive(profile); @@ -139,10 +147,11 @@ bool MainWindow::startProfileSlot(const QString profile) if (useHelper) { QList args; args.append(profile); - QStringList currentProfile = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, - DBUS_HELPER_INTERFACE, QString("ActiveProfile"), - QList(), true, debug)[0] - .toString().split(QChar('|')); + QList responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("ActiveProfile"), + QList(), true, debug); + QStringList currentProfile; + if (!responce.isEmpty()) currentProfile = responce[0].toString().split(QChar('|')); if ((currentProfile.isEmpty()) || (currentProfile.contains(profile))) sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, DBUS_HELPER_INTERFACE, QString("Start"), @@ -151,9 +160,13 @@ bool MainWindow::startProfileSlot(const QString profile) sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, DBUS_HELPER_INTERFACE, QString("SwitchTo"), args, true, debug); - current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, - DBUS_HELPER_INTERFACE, QString("isProfileActive"), - args, true, debug)[0].toBool(); + responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("isProfileActive"), + args, true, debug); + if (responce.isEmpty()) + current = netctlCommand->isProfileActive(profile); + else + current = responce[0].toBool(); } else { QStringList currentProfile = netctlCommand->getActiveProfile(); if ((currentProfile.isEmpty()) || (currentProfile.contains(profile))) @@ -188,11 +201,12 @@ bool MainWindow::switchToProfileSlot(const QString profile) if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile; bool netctlAutoStatus = false; - if (useHelper) - netctlAutoStatus = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, - DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"), - QList(), true, debug)[0].toBool(); - else + if (useHelper) { + QList responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"), + QList(), true, debug); + if (!responce.isEmpty()) netctlAutoStatus = responce[0].toBool(); + } else netctlAutoStatus = netctlCommand->isNetctlAutoRunning(); bool current; @@ -203,9 +217,13 @@ bool MainWindow::switchToProfileSlot(const QString profile) sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, DBUS_HELPER_INTERFACE, QString("autoStart"), args, true, debug); - current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, - DBUS_HELPER_INTERFACE, QString("autoIsProfileActive"), - args, true, debug)[0].toBool(); + QList responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("autoIsProfileActive"), + args, true, debug); + if (responce.isEmpty()) + current = netctlCommand->autoIsProfileActive(profile); + else + current = responce[0].toBool(); } else { netctlCommand->autoStartProfile(profile); current = netctlCommand->autoIsProfileActive(profile); @@ -217,9 +235,13 @@ bool MainWindow::switchToProfileSlot(const QString profile) sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, DBUS_HELPER_INTERFACE, QString("SwitchTo"), args, true, debug); - current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, - DBUS_HELPER_INTERFACE, QString("isProfileActive"), - args, true, debug)[0].toBool(); + QList responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("isProfileActive"), + args, true, debug); + if (responce.isEmpty()) + current = netctlCommand->isProfileActive(profile); + else + current = responce[0].toBool(); } else { netctlCommand->switchToProfile(profile); current = netctlCommand->isProfileActive(profile); @@ -272,17 +294,14 @@ bool MainWindow::forceStartHelper() return false; } - QString cmd = configuration[QString("HELPER_PATH")] + QString(" -c ") + configPath; + QString cmd = QString("%1 -c %2").arg(configuration[QString("HELPER_PATH")]).arg(configPath); if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd; TaskResult process = runTask(cmd, false); if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode; if (process.exitCode != 0) if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error; - if (process.exitCode == 0) - return true; - else - return false; + return (process.exitCode == 0); } @@ -314,15 +333,7 @@ void MainWindow::setTab(int tab) if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab; - switch (tab) { - case 0: - case 1: - case 2: - break; - default: - tab = 0; - break; - } + if (tab > 2) tab = 0; ui->tabWidget->setCurrentIndex(tab); updateTabs(tab); @@ -353,9 +364,8 @@ void MainWindow::updateConfiguration(const QMap args) // update translation qApp->removeTranslator(translator); - QString language = Language::defineLanguage(configPath, - args[QString("options")].toString()); - qtTranslator->load(QString("qt_") + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + QString language = Language::defineLanguage(configPath, args[QString("options")].toString()); + qtTranslator->load(QString("qt_%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); qApp->installTranslator(qtTranslator); translator->load(QString(":/translations/") + language); qApp->installTranslator(translator); @@ -366,7 +376,7 @@ void MainWindow::updateConfiguration(const QMap args) // tray if ((QSystemTrayIcon::isSystemTrayAvailable()) && - (configuration[QString("SYSTRAY")] == QString("true"))) + (configuration[QString("SYSTRAY")] == QString("true"))) trayIcon->setVisible(true); else trayIcon->setVisible(false); @@ -423,14 +433,17 @@ void MainWindow::connectToUnknownEssid(const QString passwd) { if (debug) qDebug() << PDEBUG; - if (passwdWid != 0) - delete passwdWid; + if (passwdWid != nullptr) delete passwdWid; QStringList interfaces; - if (useHelper) - interfaces = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, - DBUS_HELPER_INTERFACE, QString("WirelessInterfaces"), - QList(), true, debug)[0].toStringList(); - else + if (useHelper) { + QList responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("WirelessInterfaces"), + QList(), true, debug); + if (responce.isEmpty()) + interfaces = netctlCommand->getWirelessInterfaceList(); + else + interfaces = responce[0].toStringList(); + } else interfaces = netctlCommand->getWirelessInterfaceList(); if (interfaces.isEmpty()) return; @@ -445,11 +458,9 @@ void MainWindow::connectToUnknownEssid(const QString passwd) settings[QString("Security")] = QString("wep"); else settings[QString("Security")] = QString("none"); - settings[QString("ESSID")] = QString("'") + - ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() + - QString("'"); + settings[QString("ESSID")] = QString("'%1'").arg(ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text()); if (!passwd.isEmpty()) - settings[QString("Key")] = QString("'") + passwd + QString("'"); + settings[QString("Key")] = QString("'%1'").arg(passwd); settings[QString("IP")] = QString("dhcp"); if (hiddenNetwork) settings[QString("Hidden")] = QString("yes"); @@ -460,7 +471,7 @@ void MainWindow::connectToUnknownEssid(const QString passwd) if (useHelper) { QStringList settingsList; for (int i=0; i args; args.append(profile); args.append(settingsList); @@ -472,9 +483,13 @@ void MainWindow::connectToUnknownEssid(const QString passwd) sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, DBUS_HELPER_INTERFACE, QString("Start"), args, true, debug); - status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, - DBUS_HELPER_INTERFACE, QString("isProfileActive"), - args, true, debug)[0].toBool(); + QList responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, + DBUS_HELPER_INTERFACE, QString("isProfileActive"), + args, true, debug); + if (responce.isEmpty()) + status = netctlCommand->isProfileActive(profile); + else + status = responce[0].toBool(); } else { QString profileTempName = netctlProfile->createProfile(profile, settings); netctlProfile->copyProfile(profileTempName); @@ -503,7 +518,7 @@ void MainWindow::connectToUnknownEssid(const QString passwd) args.append(profile); sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, DBUS_HELPER_INTERFACE, QString("Remove"), - args, true, debug)[0].toBool(); + args, true, debug); } else netctlProfile->removeProfile(profile); break; diff --git a/sources/gui/src/mainwindow.cpp b/sources/gui/src/mainwindow.cpp index 78b4312..d753503 100644 --- a/sources/gui/src/mainwindow.cpp +++ b/sources/gui/src/mainwindow.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -79,7 +80,7 @@ MainWindow::MainWindow(QWidget *parent, for (int i=0; itableWidget_wifi->rowCount(); i++) if (ui->tableWidget_wifi->item(i, 0)->text() == args[QString("essid")].toString()) ui->tableWidget_wifi->setCurrentCell(i, 0); - if (ui->tableWidget_wifi->currentItem() == 0) + if (ui->tableWidget_wifi->currentItem() == nullptr) ErrorWindow::showWindow(18, QString(PDEBUG), debug); } else if (args[QString("open")].toString() != QString("PROFILE")) { ui->comboBox_profile->addItem(args[QString("open")].toString()); @@ -88,7 +89,7 @@ MainWindow::MainWindow(QWidget *parent, for (int i=0; itableWidget_main->rowCount(); i++) if (ui->tableWidget_main->item(i, 0)->text() == args[QString("select")].toString()) ui->tableWidget_main->setCurrentCell(i, 0); - if (ui->tableWidget_main->currentItem() == 0) + if (ui->tableWidget_main->currentItem() == nullptr) ErrorWindow::showWindow(17, QString(PDEBUG), debug); } @@ -118,30 +119,28 @@ QStringList MainWindow::printInformation() { if (debug) qDebug() << PDEBUG; - QString profile; - QString status; + QStringList output; + output.append(QString("none")); + output.append(QString("(none)")); if (useHelper) { QStringList request = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, DBUS_HELPER_INTERFACE, QString("Information"), QList(), true, debug)[0].toStringList(); - profile = request[0]; - status = request[1]; + if (request.count() != 2) return output; + output = request; } else { if (netctlCommand->isNetctlAutoRunning()) { - profile = netctlCommand->autoGetActiveProfile(); - status = QString("netctl-auto"); + output[0] = netctlCommand->autoGetActiveProfile(); + output[1] = QString("netctl-auto"); } else { QStringList currentProfiles = netctlCommand->getActiveProfile(); - profile = currentProfiles.join(QChar('|')); + output[0] = currentProfiles.join(QChar('|')); QStringList statusList; for (int i=0; igetProfileStatus(currentProfiles[i])); - status = statusList.join(QChar('|')); + output[1] = statusList.join(QChar('|')); } } - QStringList output; - output.append(profile); - output.append(status); return output; } @@ -153,8 +152,7 @@ QStringList MainWindow::printSettings() QStringList settingsList; for (int i=0; iignore(); } else @@ -305,10 +299,7 @@ bool MainWindow::checkExternalApps(const QString apps = QString("all")) if (process.exitCode != 0) if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error; - if (process.exitCode != 0) - return false; - else - return true; + return (process.exitCode == 0); } @@ -334,14 +325,12 @@ QString MainWindow::checkStatus(const bool statusBool, const bool nullFalse) { if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool; - if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse; + if (debug) qDebug() << PDEBUG << ":" << "Return null on false" << nullFalse; - if (statusBool) - return QApplication::translate("MainWindow", "yes"); - if (nullFalse) - return QString(""); - else - return QApplication::translate("MainWindow", "no"); + if (statusBool) return QApplication::translate("MainWindow", "yes"); + if (!nullFalse) return QApplication::translate("MainWindow", "no"); + + return QString(""); } @@ -372,6 +361,7 @@ void MainWindow::createActions() // profile tab events connect(ui->comboBox_profile, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabLoadProfile())); connect(ui->comboBox_profile, SIGNAL(editTextChanged(QString)), this, SLOT(updateMenuProfile())); + connect(ui->comboBox_profile->lineEdit(), SIGNAL(returnPressed()), this, SLOT(profileTabLoadProfile())); connect(generalWid->connectionType, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabChangeState(QString))); // wifi tab events @@ -406,11 +396,10 @@ void MainWindow::createObjects() // backend createDBusSession(); - if (useHelper) - if (!forceStartHelper()) { - ErrorWindow::showWindow(19, QString(PDEBUG), debug); - useHelper = false; - } + if ((useHelper) && (!forceStartHelper())) { + ErrorWindow::showWindow(19, QString(PDEBUG), debug); + useHelper = false; + } checkHelperStatus(); netctlCommand = new Netctl(debug, configuration); @@ -462,13 +451,13 @@ void MainWindow::createToolBars() actionToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle); toolBarActions[QString("netctlAuto")] = actionToolBar->addAction(QApplication::translate("MainWindow", "netctl-auto"), this, SLOT(showNetctlAutoWindow())); - toolBarActions[QString("mainRefresh")] = actionToolBar->addAction(QIcon::fromTheme(QString("stock-refresh")), + toolBarActions[QString("mainRefresh")] = actionToolBar->addAction(QIcon::fromTheme(QString("view-refresh")), QApplication::translate("MainWindow", "Refresh"), this, SLOT(updateMainTab())); toolBarActions[QString("profileClear")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-clear")), QApplication::translate("MainWindow", "Clear"), this, SLOT(profileTabClear())); - toolBarActions[QString("wifiRefresh")] = actionToolBar->addAction(QIcon::fromTheme(QString("stock-refresh")), + toolBarActions[QString("wifiRefresh")] = actionToolBar->addAction(QIcon::fromTheme(QString("view-refresh")), QApplication::translate("MainWindow", "Refresh"), this, SLOT(updateWifiTab())); @@ -482,7 +471,7 @@ void MainWindow::createToolBars() toolBarActions[QString("mainSwitch")] = menu->addAction(QIcon::fromTheme(QString("system-run")), QApplication::translate("MainWindow", "Switch"), this, SLOT(mainTabSwitchToProfile())); - toolBarActions[QString("mainRestart")] = menu->addAction(QIcon::fromTheme(QString("stock-refresh")), + toolBarActions[QString("mainRestart")] = menu->addAction(QIcon::fromTheme(QString("view-refresh")), QApplication::translate("MainWindow", "Restart"), this, SLOT(mainTabRestartProfile())); toolBarActions[QString("mainEnable")] = menu->addAction(QIcon::fromTheme(QString("edit-add")), @@ -503,7 +492,7 @@ void MainWindow::createToolBars() actionMenu->setMenu(menu); actionToolBar->addWidget(actionMenu); - toolBarActions[QString("mainEdit")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit")), + toolBarActions[QString("mainEdit")] = actionToolBar->addAction(QIcon::fromTheme(QString("document-edit")), QApplication::translate("MainWindow", "Edit"), this, SLOT(mainTabEditProfile())); toolBarActions[QString("mainRemove")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-delete")), @@ -554,16 +543,6 @@ void MainWindow::deleteObjects() } -void MainWindow::keyPressEvent(QKeyEvent *pressedKey) -{ - if (debug) qDebug() << PDEBUG; - - if (pressedKey->key() == Qt::Key_Return) - if (ui->comboBox_profile->hasFocus()) - profileTabLoadProfile(); -} - - QMap MainWindow::parseOptions(const QString options) { if (debug) qDebug() << PDEBUG; diff --git a/sources/gui/src/mainwindow.h b/sources/gui/src/mainwindow.h index 58627b3..58709ca 100644 --- a/sources/gui/src/mainwindow.h +++ b/sources/gui/src/mainwindow.h @@ -167,7 +167,6 @@ private: void createObjects(); void createToolBars(); void deleteObjects(); - void keyPressEvent(QKeyEvent *pressedKey); QString configPath; bool debug = false; bool hiddenNetwork; diff --git a/sources/gui/src/messages.cpp b/sources/gui/src/messages.cpp index b7d70f0..0d7dff9 100644 --- a/sources/gui/src/messages.cpp +++ b/sources/gui/src/messages.cpp @@ -34,7 +34,7 @@ QMap getArgs() QMap args; // windows args[QString("detached")] = false; - args[QString("minimized")] = (int) 0; + args[QString("minimized")] = static_cast(0); args[QString("about")] = false; args[QString("auto")] = false; args[QString("settings")] = false; @@ -43,11 +43,11 @@ QMap getArgs() args[QString("open")] = QString("PROFILE"); args[QString("select")] = QString("PROFILE"); // additional functions - args[QString("config")] = QString(QDir::homePath() + QString("/.config/netctl-gui.conf")); + args[QString("config")] = QString("%1/.config/netctl-gui.conf").arg(QDir::homePath()); args[QString("debug")] = false; args[QString("defaults")] = false; args[QString("options")] = QString("OPTIONS"); - args[QString("tab")] = (int) 1; + args[QString("tab")] = static_cast(1); // messages args[QString("error")] = false; args[QString("help")] = false; @@ -66,46 +66,29 @@ QString helpMessage() helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Options:")); // windows helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Open window:")); - helpMessage += QString(" --detached - %1\n") - .arg(QApplication::translate("MainWindow", "start detached from console")); - helpMessage += QString(" --maximized - %1\n") - .arg(QApplication::translate("MainWindow", "start maximized")); - helpMessage += QString(" --minimized - %1\n") - .arg(QApplication::translate("MainWindow", "start minimized to tray")); - helpMessage += QString(" --about - %1\n") - .arg(QApplication::translate("MainWindow", "show about window")); - helpMessage += QString(" --netctl-auto - %1\n") - .arg(QApplication::translate("MainWindow", "show netctl-auto window")); - helpMessage += QString(" --settings - %1\n") - .arg(QApplication::translate("MainWindow", "show settings window")); + helpMessage += QString(" --detached - %1\n").arg(QApplication::translate("MainWindow", "start detached from console")); + helpMessage += QString(" --maximized - %1\n").arg(QApplication::translate("MainWindow", "start maximized")); + helpMessage += QString(" --minimized - %1\n").arg(QApplication::translate("MainWindow", "start minimized to tray")); + helpMessage += QString(" --about - %1\n").arg(QApplication::translate("MainWindow", "show about window")); + helpMessage += QString(" --netctl-auto - %1\n").arg(QApplication::translate("MainWindow", "show netctl-auto window")); + helpMessage += QString(" --settings - %1\n").arg(QApplication::translate("MainWindow", "show settings window")); // main functions helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Functions:")); - helpMessage += QString(" -e, --essid - %1\n") - .arg(QApplication::translate("MainWindow", "select this ESSID")); - helpMessage += QString(" -o, --open - %1\n") - .arg(QApplication::translate("MainWindow", "open this profile")); - helpMessage += QString(" -s, --select - %1\n") - .arg(QApplication::translate("MainWindow", "select this profile")); + helpMessage += QString(" -e, --essid - %1\n").arg(QApplication::translate("MainWindow", "select this ESSID")); + helpMessage += QString(" -o, --open - %1\n").arg(QApplication::translate("MainWindow", "open this profile")); + helpMessage += QString(" -s, --select - %1\n").arg(QApplication::translate("MainWindow", "select this profile")); // additional functions helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Additional flags:")); - helpMessage += QString(" -c, --config - %1\n") - .arg(QApplication::translate("MainWindow", "read configuration from this file")); - helpMessage += QString(" -d, --debug - %1\n") - .arg(QApplication::translate("MainWindow", "print debug information")); - helpMessage += QString(" --default - %1\n") - .arg(QApplication::translate("MainWindow", "start with default settings")); - helpMessage += QString(" --set-opts - %1\n") - .arg(QApplication::translate("MainWindow", "set options for this run, comma separated")); - helpMessage += QString(" -t, --tab - %1\n") - .arg(QApplication::translate("MainWindow", "open a tab with this number")); + helpMessage += QString(" -c, --config - %1\n").arg(QApplication::translate("MainWindow", "read configuration from this file")); + helpMessage += QString(" -d, --debug - %1\n").arg(QApplication::translate("MainWindow", "print debug information")); + helpMessage += QString(" --default - %1\n").arg(QApplication::translate("MainWindow", "start with default settings")); + helpMessage += QString(" --set-opts - %1\n").arg(QApplication::translate("MainWindow", "set options for this run, comma separated")); + helpMessage += QString(" -t, --tab - %1\n").arg(QApplication::translate("MainWindow", "open a tab with this number")); // messages helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Show messages:")); - helpMessage += QString(" -v, --version - %1\n") - .arg(QApplication::translate("MainWindow", "show version and exit")); - helpMessage += QString(" -i, --info - %1\n") - .arg(QApplication::translate("MainWindow", "show build information and exit")); - helpMessage += QString(" -h, --help - %1\n") - .arg(QApplication::translate("MainWindow", "show this help and exit")); + helpMessage += QString(" -v, --version - %1\n").arg(QApplication::translate("MainWindow", "show version and exit")); + helpMessage += QString(" -i, --info - %1\n").arg(QApplication::translate("MainWindow", "show build information and exit")); + helpMessage += QString(" -h, --help - %1\n").arg(QApplication::translate("MainWindow", "show this help and exit")); return helpMessage; } @@ -115,8 +98,7 @@ QString infoMessage() { QString infoMessage = QString(""); // build information - infoMessage += QApplication::translate("MainWindow", "Build date: %1"). - arg(QString(BUILD_DATE)); + infoMessage += QApplication::translate("MainWindow", "Build date: %1").arg(QString(BUILD_DATE)); // cmake infoMessage += QString("\n%1:\n").arg(QApplication::translate("MainWindow", "cmake flags")); // cmake properties @@ -162,15 +144,9 @@ QString versionMessage() { QString versionMessage = QString(""); versionMessage += QString("%1\n").arg(QString(NAME)); - versionMessage += QString("%1 : %2\n") - .arg(QApplication::translate("MainWindow", "Version")) - .arg(QString(VERSION)); - versionMessage += QString("%1 : %2\n") - .arg(QApplication::translate("MainWindow", "Author")) - .arg(QString(AUTHOR)); - versionMessage += QString("%1 : %2\n") - .arg(QApplication::translate("MainWindow", "License")) - .arg(QString(LICENSE)); + versionMessage += QString("%1 : %2\n").arg(QApplication::translate("MainWindow", "Version")).arg(QString(VERSION)); + versionMessage += QString("%1 : %2\n").arg(QApplication::translate("MainWindow", "Author")).arg(QString(AUTHOR)); + versionMessage += QString("%1 : %2\n").arg(QApplication::translate("MainWindow", "License")).arg(QString(LICENSE)); return versionMessage; } diff --git a/sources/gui/src/netctlautowindow.ui b/sources/gui/src/netctlautowindow.ui index b577ae5..6c5fc35 100644 --- a/sources/gui/src/netctlautowindow.ui +++ b/sources/gui/src/netctlautowindow.ui @@ -70,7 +70,7 @@ Refresh - + @@ -223,7 +223,7 @@ - + diff --git a/sources/gui/src/netctlguiadaptor.cpp b/sources/gui/src/netctlguiadaptor.cpp index 7ad88c9..2d9e612 100644 --- a/sources/gui/src/netctlguiadaptor.cpp +++ b/sources/gui/src/netctlguiadaptor.cpp @@ -70,8 +70,7 @@ QString NetctlGuiAdaptor::Pony() { QString pony; QFile ponyFile(QString(":pinkiepie")); - if (!ponyFile.open(QIODevice::ReadOnly)) - return pony; + if (!ponyFile.open(QIODevice::ReadOnly)) return pony; pony = QTextCodec::codecForMib(106)->toUnicode(ponyFile.readAll()); ponyFile.close(); diff --git a/sources/gui/src/settingswindow.cpp b/sources/gui/src/settingswindow.cpp index 53ff66d..de4d12f 100644 --- a/sources/gui/src/settingswindow.cpp +++ b/sources/gui/src/settingswindow.cpp @@ -177,13 +177,8 @@ void SettingsWindow::setTray() { if (debug) qDebug() << PDEBUG; - if (ui->checkBox_enableTray->checkState() == 0) { - ui->checkBox_closeToTray->setDisabled(true); - ui->checkBox_startToTray->setDisabled(true); - } else if (ui->checkBox_enableTray->checkState() == 2) { - ui->checkBox_closeToTray->setEnabled(true); - ui->checkBox_startToTray->setEnabled(true); - } + ui->checkBox_closeToTray->setDisabled(ui->checkBox_enableTray->checkState() == 0); + ui->checkBox_startToTray->setDisabled(ui->checkBox_enableTray->checkState() == 0); } @@ -328,8 +323,7 @@ QMap SettingsWindow::readSettings() config[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text(); for (int i=0; i config) ui->lineEdit_helperPath->setText(config[QString("HELPER_PATH")]); ui->lineEdit_helperService->setText(config[QString("HELPER_SERVICE")]); ui->lineEdit_interfacesDir->setText(config[QString("IFACE_DIR")]); - ui->comboBox_language->setCurrentIndex(0); - for (int i=0; icomboBox_language->count(); i++) - if (ui->comboBox_language->itemText(i) == config[QString("LANGUAGE")]) { - ui->comboBox_language->setCurrentIndex(i); - break; - } + int index = ui->comboBox_language->findText(config[QString("LANGUAGE")]); + ui->comboBox_language->setCurrentIndex(index); ui->lineEdit_netctlPath->setText(config[QString("NETCTL_PATH")]); ui->lineEdit_netctlAutoPath->setText(config[QString("NETCTLAUTO_PATH")]); ui->lineEdit_netctlAutoService->setText(config[QString("NETCTLAUTO_SERVICE")]); @@ -392,8 +382,7 @@ void SettingsWindow::setSettings(const QMap config) ui->lineEdit_wpaSupDrivers->setText(config[QString("WPA_DRIVERS")]); for (int i=0; i SettingsWindow::getSettings(QString fileName) settings.endGroup(); for (int i=0; iaddAction(contextMenu[QString("switch")]); - contextMenu[QString("restart")] = new QAction(QIcon::fromTheme("stock-refresh"), QApplication::translate("TrayIcon", "Restart profile"), this); + contextMenu[QString("restart")] = new QAction(QIcon::fromTheme("view-refresh"), QApplication::translate("TrayIcon", "Restart profile"), this); connect(contextMenu[QString("restart")], SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot())); menuActions->addAction(contextMenu[QString("restart")]); diff --git a/sources/gui/src/wirelesswidget.cpp b/sources/gui/src/wirelesswidget.cpp index 054e293..615618b 100644 --- a/sources/gui/src/wirelesswidget.cpp +++ b/sources/gui/src/wirelesswidget.cpp @@ -68,9 +68,7 @@ void WirelessWidget::clear() if (rfkillDirectory->exists()) { QStringList rfkillDevices = rfkillDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot); for (int i=0; iabsolutePath()) - .arg(QDir::separator()) - .arg(rfkillDevices[i])); + QFile device(QString("%1/%2/name").arg(rfkillDirectory->absolutePath()).arg(rfkillDevices[i])); if (!device.open(QIODevice::ReadOnly)) continue; ui->comboBox_rfkill->addItem(QString(device.readLine()).trimmed()); device.close(); diff --git a/sources/helper/src/main.cpp b/sources/helper/src/main.cpp index a0ec8d4..c48588f 100644 --- a/sources/helper/src/main.cpp +++ b/sources/helper/src/main.cpp @@ -120,7 +120,7 @@ int main(int argc, char *argv[]) if (args[QString("error")].toBool()) { cout << errorMessage().toUtf8().data() << endl; cout << helpMessage().toUtf8().data(); - return 127; + return 11; } else if (args[QString("help")].toBool()) { cout << helpMessage().toUtf8().data(); return 0; diff --git a/sources/helper/src/messages.cpp b/sources/helper/src/messages.cpp index 6440bcc..da87319 100644 --- a/sources/helper/src/messages.cpp +++ b/sources/helper/src/messages.cpp @@ -54,27 +54,17 @@ QString helpMessage() helpMessage += QString("netctlgui-helper [ options ]\n"); helpMessage += QString("%1\n").arg(QCoreApplication::translate("NetctlHelper", "Options:")); // windows - helpMessage += QString(" -c, --config - %1\n") - .arg(QCoreApplication::translate("NetctlHelper", "read configuration from this file")); - helpMessage += QString(" -d, --debug - %1\n") - .arg(QCoreApplication::translate("NetctlHelper", "print debug information")); - helpMessage += QString(" --nodaemon - %1\n") - .arg(QCoreApplication::translate("NetctlHelper", "do not start as daemon")); - helpMessage += QString(" --replace - %1\n") - .arg(QCoreApplication::translate("NetctlHelper", "force replace the existing session")); - helpMessage += QString(" --restore - %1\n") - .arg(QCoreApplication::translate("NetctlHelper", "force restore the existing session")); - helpMessage += QString(" --session - %1\n") - .arg(QCoreApplication::translate("NetctlHelper", "force create user DBus session")); - helpMessage += QString(" --system - %1\n") - .arg(QCoreApplication::translate("NetctlHelper", "do not read user configuration, system-wide only")); + helpMessage += QString(" -c, --config - %1\n").arg(QCoreApplication::translate("NetctlHelper", "read configuration from this file")); + helpMessage += QString(" -d, --debug - %1\n").arg(QCoreApplication::translate("NetctlHelper", "print debug information")); + helpMessage += QString(" --nodaemon - %1\n").arg(QCoreApplication::translate("NetctlHelper", "do not start as daemon")); + helpMessage += QString(" --replace - %1\n").arg(QCoreApplication::translate("NetctlHelper", "force replace the existing session")); + helpMessage += QString(" --restore - %1\n").arg(QCoreApplication::translate("NetctlHelper", "force restore the existing session")); + helpMessage += QString(" --session - %1\n").arg(QCoreApplication::translate("NetctlHelper", "force create user DBus session")); + helpMessage += QString(" --system - %1\n").arg(QCoreApplication::translate("NetctlHelper", "do not read user configuration, system-wide only")); helpMessage += QString(" %1\n").arg(QCoreApplication::translate("NetctlHelper", "Show messages:")); - helpMessage += QString(" -v, --version - %1\n") - .arg(QCoreApplication::translate("NetctlHelper", "show version and exit")); - helpMessage += QString(" -i, --info - %1\n") - .arg(QCoreApplication::translate("NetctlHelper", "show build information and exit")); - helpMessage += QString(" -h, --help - %1\n") - .arg(QCoreApplication::translate("NetctlHelper", "show this help and exit")); + helpMessage += QString(" -v, --version - %1\n").arg(QCoreApplication::translate("NetctlHelper", "show version and exit")); + helpMessage += QString(" -i, --info - %1\n").arg(QCoreApplication::translate("NetctlHelper", "show build information and exit")); + helpMessage += QString(" -h, --help - %1\n").arg(QCoreApplication::translate("NetctlHelper", "show this help and exit")); return helpMessage; } @@ -131,15 +121,9 @@ QString versionMessage() { QString versionMessage = QString(""); versionMessage += QString("%1\n").arg(QString(NAME)); - versionMessage += QString("%1 : %2\n") - .arg(QCoreApplication::translate("NetctlHelper", "Version")) - .arg(QString(VERSION)); - versionMessage += QString("%1 : %2\n") - .arg(QCoreApplication::translate("NetctlHelper", "Author")) - .arg(QString(AUTHOR)); - versionMessage += QString("%1 : %2\n") - .arg(QCoreApplication::translate("NetctlHelper", "License")) - .arg(QString(LICENSE)); + versionMessage += QString("%1 : %2\n").arg(QCoreApplication::translate("NetctlHelper", "Version")).arg(QString(VERSION)); + versionMessage += QString("%1 : %2\n").arg(QCoreApplication::translate("NetctlHelper", "Author")).arg(QString(AUTHOR)); + versionMessage += QString("%1 : %2\n").arg(QCoreApplication::translate("NetctlHelper", "License")).arg(QString(LICENSE)); return versionMessage; } diff --git a/sources/netctlgui/src/netctlinteract.cpp b/sources/netctlgui/src/netctlinteract.cpp index 123ae90..3311ed7 100644 --- a/sources/netctlgui/src/netctlinteract.cpp +++ b/sources/netctlgui/src/netctlinteract.cpp @@ -494,9 +494,7 @@ QStringList Netctl::getWirelessInterfaceList() interfaces.append(mainInterface); QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot); for (int i=0; ipath()) - .arg(QDir::separator()) - .arg(allInterfaces[i]); + QString dir = QString("%1/%2/wireless").arg(ifaceDirectory->path()).arg(allInterfaces[i]); if (debug) qDebug() << PDEBUG << ":" << "Check directory" << dir; if (QDir(dir).exists()) interfaces.append(allInterfaces[i]); diff --git a/sources/netctlgui/src/netctlprofile.cpp b/sources/netctlgui/src/netctlprofile.cpp index 79827bc..48692f6 100644 --- a/sources/netctlgui/src/netctlprofile.cpp +++ b/sources/netctlgui/src/netctlprofile.cpp @@ -80,9 +80,7 @@ bool NetctlProfile::copyProfile(const QString oldPath) return false; } - QString newPath = QString("%1%2%3").arg(profileDirectory->absolutePath()) - .arg(QDir::separator()) - .arg(QFileInfo(oldPath).fileName()); + QString newPath = QString("%1/%2").arg(profileDirectory->absolutePath()).arg(QFileInfo(oldPath).fileName()); QString cmd = QString("%1 /usr/bin/mv \"%2\" \"%3\"").arg(sudoCommand) .arg(oldPath) .arg(newPath); @@ -104,9 +102,7 @@ QString NetctlProfile::createProfile(const QString profile, const QMap NetctlProfile::getSettingsFromProfile(const QString profi systemVariables.append(output[i].split(QChar('='))[0]); // profile variables QMap settings; - QString profileUrl = QString("%1%2%3").arg(profileDirectory->absolutePath()) - .arg(QDir::separator()) - .arg(QFileInfo(profile).fileName()); + QString profileUrl = QString("%1/%2").arg(profileDirectory->absolutePath()).arg(QFileInfo(profile).fileName()); cmd = QString("env -i bash -c \"source '%1'; set\"").arg(profileUrl); if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd; process = runTask(cmd, false); @@ -269,9 +263,7 @@ bool NetctlProfile::removeProfile(const QString profile) return false; } - QString profilePath = QString("%1%2%3").arg(profileDirectory->absolutePath()) - .arg(QDir::separator()) - .arg(QFileInfo(profile).fileName()); + QString profilePath = QString("%1/%2").arg(profileDirectory->absolutePath()).arg(QFileInfo(profile).fileName()); QString cmd = QString("%1 /usr/bin/rm \"%2\"").arg(sudoCommand).arg(profilePath); if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd; TaskResult process = runTask(cmd, useSuid); diff --git a/sources/plasmoid-kde4/netctl.cpp b/sources/plasmoid-kde4/netctl.cpp index 0cbfd61..fddbce1 100644 --- a/sources/plasmoid-kde4/netctl.cpp +++ b/sources/plasmoid-kde4/netctl.cpp @@ -477,7 +477,7 @@ void Netctl::createActions() menuActions.append(contextMenu[QString("switch")]); contextMenu[QString("restart")] = new QAction(i18n("Restart profile"), this); - contextMenu[QString("restart")]->setIcon(QIcon::fromTheme("stock-refresh")); + contextMenu[QString("restart")]->setIcon(QIcon::fromTheme("view-refresh")); connect(contextMenu[QString("restart")], SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot())); menuActions.append(contextMenu[QString("restart")]); diff --git a/sources/plasmoid-kf5/package/contents/ui/main.qml b/sources/plasmoid-kf5/package/contents/ui/main.qml index 58ad5d3..8a26bf0 100644 --- a/sources/plasmoid-kf5/package/contents/ui/main.qml +++ b/sources/plasmoid-kf5/package/contents/ui/main.qml @@ -105,7 +105,7 @@ Item { plasmoid.setAction("stopProfile", i18n("Stop profile"), "dialog-close") plasmoid.setAction("stopAllProfiles", i18n("Stop all profiles"), "dialog-close") plasmoid.setAction("switchToProfile", i18n("Switch to profile")) - plasmoid.setAction("restartProfile", i18n("Restart profile"), "stock-refresh") + plasmoid.setAction("restartProfile", i18n("Restart profile"), "view-refresh") plasmoid.setAction("enableProfile", i18n("Enable profile")) plasmoid.setAction("startWifi", i18n("Show WiFi menu"), "netctl-gui-wifi") // helper