rewrite ui part (except for privateslots)

This commit is contained in:
arcan1s 2015-02-28 04:05:34 +03:00
parent e70ebe318d
commit 1333967535
19 changed files with 181 additions and 262 deletions

View File

@ -30,7 +30,7 @@ QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QList<netctlProfileInfo> profileInfo; QList<netctlProfileInfo> profileInfo;
if (raw.size() == 0) return profileInfo; if (raw.count() == 0) return profileInfo;
QStringList list = raw[0].toStringList(); QStringList list = raw[0].toStringList();
for (int i=0; i<list.count(); i++) { for (int i=0; i<list.count(); i++) {
QStringList info = list[i].split(QChar('|')); QStringList info = list[i].split(QChar('|'));
@ -53,7 +53,7 @@ QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QList<netctlWifiInfo> wifiInfo; QList<netctlWifiInfo> wifiInfo;
if (raw.size() == 0) return wifiInfo; if (raw.count() == 0) return wifiInfo;
QStringList list = raw[0].toStringList(); QStringList list = raw[0].toStringList();
for (int i=0; i<list.count(); i++) { for (int i=0; i<list.count(); i++) {
QStringList info = list[i].split(QChar('|')); QStringList info = list[i].split(QChar('|'));
@ -84,23 +84,14 @@ QList<QVariant> sendDBusRequest(const QString service, const QString path,
if (debug) qDebug() << PDEBUG << ":" << "args" << args; if (debug) qDebug() << PDEBUG << ":" << "args" << args;
if (debug) qDebug() << PDEBUG << ":" << "is system bus" << system; if (debug) qDebug() << PDEBUG << ":" << "is system bus" << system;
QList<QVariant> 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(); QDBusConnection bus = QDBusConnection::sessionBus();
if (system)
bus = QDBusConnection::systemBus();
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd); QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
if (!args.isEmpty()) if (!args.isEmpty()) request.setArguments(args);
request.setArguments(args); QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
response = bus.call(request, QDBus::BlockWithGui); QList<QVariant> arguments = response.arguments();
} if (arguments.count() == 0)
arguments = response.arguments();
if (arguments.size() == 0)
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage(); if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
return arguments; return arguments;

View File

@ -108,7 +108,7 @@ void IpWidget::createActions()
connect(ui->lineEdit_ipAddress, SIGNAL(returnPressed()), this, SLOT(addIp())); connect(ui->lineEdit_ipAddress, SIGNAL(returnPressed()), this, SLOT(addIp()));
connect(ui->pushButton_ipRoutes, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes())); connect(ui->pushButton_ipRoutes, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes()));
connect(ui->pushButton_ipAddress6, SIGNAL(clicked(bool)), this, SLOT(addIp6())); 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_ipRoutes6, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes6()));
connect(ui->pushButton_custom, SIGNAL(clicked(bool)), this, SLOT(addCustom())); connect(ui->pushButton_custom, SIGNAL(clicked(bool)), this, SLOT(addCustom()));
connect(ui->lineEdit_custom, SIGNAL(returnPressed()), this, SLOT(addCustom())); connect(ui->lineEdit_custom, SIGNAL(returnPressed()), this, SLOT(addCustom()));

View File

@ -137,11 +137,11 @@ int main(int argc, char *argv[])
(args[QString("error")].toBool())) (args[QString("error")].toBool()))
args[QString("detached")] = false; args[QString("detached")] = false;
if (args[QString("essid")].toString() != QString("ESSID")) if (args[QString("essid")].toString() != QString("ESSID"))
args[QString("tab")] = (int) 3; args[QString("tab")] = static_cast<int>(3);
if (args[QString("open")].toString() != QString("PROFILE")) if (args[QString("open")].toString() != QString("PROFILE"))
args[QString("tab")] = (int) 2; args[QString("tab")] = static_cast<int>(2);
if (args[QString("select")].toString() != QString("PROFILE")) if (args[QString("select")].toString() != QString("PROFILE"))
args[QString("tab")] = (int) 1; args[QString("tab")] = static_cast<int>(1);
// detach from console // detach from console
if (args[QString("detached")].toBool()) if (args[QString("detached")].toBool())
@ -162,7 +162,7 @@ int main(int argc, char *argv[])
if (args[QString("error")].toBool()) { if (args[QString("error")].toBool()) {
cout << errorMessage().toUtf8().data() << endl; cout << errorMessage().toUtf8().data() << endl;
cout << helpMessage().toUtf8().data(); cout << helpMessage().toUtf8().data();
return 127; return 1;
} else if (args[QString("help")].toBool()) { } else if (args[QString("help")].toBool()) {
cout << helpMessage().toUtf8().data(); cout << helpMessage().toUtf8().data();
return 0; return 0;

View File

@ -353,15 +353,15 @@ void MainWindow::mainTabContextualMenu(const QPoint &pos)
// create menu // create menu
QMenu menu(this); QMenu menu(this);
QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh")); QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh"));
refreshTable->setIcon(QIcon::fromTheme("stock-refresh")); refreshTable->setIcon(QIcon::fromTheme("view-refresh"));
menu.addSeparator(); menu.addSeparator();
QAction *startProfile = menu.addAction(QApplication::translate("MainWindow", "Start profile")); QAction *startProfile = menu.addAction(QApplication::translate("MainWindow", "Start profile"));
QAction *restartProfile = menu.addAction(QApplication::translate("MainWindow", "Restart 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")); QAction *enableProfile = menu.addAction(QApplication::translate("MainWindow", "Enable profile"));
menu.addSeparator(); menu.addSeparator();
QAction *editProfile = menu.addAction(QApplication::translate("MainWindow", "Edit profile")); 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")); QAction *removeProfile = menu.addAction(QApplication::translate("MainWindow", "Remove profile"));
removeProfile->setIcon(QIcon::fromTheme("edit-delete")); removeProfile->setIcon(QIcon::fromTheme("edit-delete"));
@ -899,7 +899,7 @@ void MainWindow::wifiTabContextualMenu(const QPoint &pos)
// create menu // create menu
QMenu menu(this); QMenu menu(this);
QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh")); QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh"));
refreshTable->setIcon(QIcon::fromTheme("stock-refresh")); refreshTable->setIcon(QIcon::fromTheme("view-refresh"));
menu.addSeparator(); menu.addSeparator();
QAction *startWifi = menu.addAction(QApplication::translate("MainWindow", "Start WiFi")); QAction *startWifi = menu.addAction(QApplication::translate("MainWindow", "Start WiFi"));

View File

@ -94,9 +94,13 @@ bool MainWindow::enableProfileSlot(const QString profile)
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Enable"), DBUS_HELPER_INTERFACE, QString("Enable"),
args, true, debug); args, true, debug);
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileEnabled"), DBUS_HELPER_INTERFACE, QString("isProfileEnabled"),
args, true, debug)[0].toBool(); args, true, debug);
if (responce.isEmpty())
current = netctlCommand->isProfileEnabled(profile);
else
current = responce[0].toBool();
} else { } else {
netctlCommand->enableProfile(profile); netctlCommand->enableProfile(profile);
current = netctlCommand->isProfileEnabled(profile); current = netctlCommand->isProfileEnabled(profile);
@ -118,9 +122,13 @@ bool MainWindow::restartProfileSlot(const QString profile)
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Restart"), DBUS_HELPER_INTERFACE, QString("Restart"),
args, true, debug)[0].toBool(); args, true, debug)[0].toBool();
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"), DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true, debug)[0].toBool(); args, true, debug);
if (responce.isEmpty())
current = netctlCommand->isProfileActive(profile);
else
current = responce[0].toBool();
} else { } else {
netctlCommand->restartProfile(profile); netctlCommand->restartProfile(profile);
current = netctlCommand->isProfileActive(profile); current = netctlCommand->isProfileActive(profile);
@ -139,10 +147,11 @@ bool MainWindow::startProfileSlot(const QString profile)
if (useHelper) { if (useHelper) {
QList<QVariant> args; QList<QVariant> args;
args.append(profile); args.append(profile);
QStringList currentProfile = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ActiveProfile"), DBUS_HELPER_INTERFACE, QString("ActiveProfile"),
QList<QVariant>(), true, debug)[0] QList<QVariant>(), true, debug);
.toString().split(QChar('|')); QStringList currentProfile;
if (!responce.isEmpty()) currentProfile = responce[0].toString().split(QChar('|'));
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile))) if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Start"), DBUS_HELPER_INTERFACE, QString("Start"),
@ -151,9 +160,13 @@ bool MainWindow::startProfileSlot(const QString profile)
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("SwitchTo"), DBUS_HELPER_INTERFACE, QString("SwitchTo"),
args, true, debug); args, true, debug);
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"), DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true, debug)[0].toBool(); args, true, debug);
if (responce.isEmpty())
current = netctlCommand->isProfileActive(profile);
else
current = responce[0].toBool();
} else { } else {
QStringList currentProfile = netctlCommand->getActiveProfile(); QStringList currentProfile = netctlCommand->getActiveProfile();
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile))) if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
@ -188,11 +201,12 @@ bool MainWindow::switchToProfileSlot(const QString profile)
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile; if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
bool netctlAutoStatus = false; bool netctlAutoStatus = false;
if (useHelper) if (useHelper) {
netctlAutoStatus = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"), DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
QList<QVariant>(), true, debug)[0].toBool(); QList<QVariant>(), true, debug);
else if (!responce.isEmpty()) netctlAutoStatus = responce[0].toBool();
} else
netctlAutoStatus = netctlCommand->isNetctlAutoRunning(); netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
bool current; bool current;
@ -203,9 +217,13 @@ bool MainWindow::switchToProfileSlot(const QString profile)
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoStart"), DBUS_HELPER_INTERFACE, QString("autoStart"),
args, true, debug); args, true, debug);
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("autoIsProfileActive"), DBUS_HELPER_INTERFACE, QString("autoIsProfileActive"),
args, true, debug)[0].toBool(); args, true, debug);
if (responce.isEmpty())
current = netctlCommand->autoIsProfileActive(profile);
else
current = responce[0].toBool();
} else { } else {
netctlCommand->autoStartProfile(profile); netctlCommand->autoStartProfile(profile);
current = netctlCommand->autoIsProfileActive(profile); current = netctlCommand->autoIsProfileActive(profile);
@ -217,9 +235,13 @@ bool MainWindow::switchToProfileSlot(const QString profile)
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("SwitchTo"), DBUS_HELPER_INTERFACE, QString("SwitchTo"),
args, true, debug); args, true, debug);
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"), DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true, debug)[0].toBool(); args, true, debug);
if (responce.isEmpty())
current = netctlCommand->isProfileActive(profile);
else
current = responce[0].toBool();
} else { } else {
netctlCommand->switchToProfile(profile); netctlCommand->switchToProfile(profile);
current = netctlCommand->isProfileActive(profile); current = netctlCommand->isProfileActive(profile);
@ -272,17 +294,14 @@ bool MainWindow::forceStartHelper()
return false; 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; if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
TaskResult process = runTask(cmd, false); TaskResult process = runTask(cmd, false);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode; if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0) if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error; if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
if (process.exitCode == 0) return (process.exitCode == 0);
return true;
else
return false;
} }
@ -314,15 +333,7 @@ void MainWindow::setTab(int tab)
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab; if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
switch (tab) { if (tab > 2) tab = 0;
case 0:
case 1:
case 2:
break;
default:
tab = 0;
break;
}
ui->tabWidget->setCurrentIndex(tab); ui->tabWidget->setCurrentIndex(tab);
updateTabs(tab); updateTabs(tab);
@ -353,9 +364,8 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
// update translation // update translation
qApp->removeTranslator(translator); qApp->removeTranslator(translator);
QString language = Language::defineLanguage(configPath, QString language = Language::defineLanguage(configPath, args[QString("options")].toString());
args[QString("options")].toString()); qtTranslator->load(QString("qt_%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
qtTranslator->load(QString("qt_") + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
qApp->installTranslator(qtTranslator); qApp->installTranslator(qtTranslator);
translator->load(QString(":/translations/") + language); translator->load(QString(":/translations/") + language);
qApp->installTranslator(translator); qApp->installTranslator(translator);
@ -423,14 +433,17 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (passwdWid != 0) if (passwdWid != nullptr) delete passwdWid;
delete passwdWid;
QStringList interfaces; QStringList interfaces;
if (useHelper) if (useHelper) {
interfaces = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("WirelessInterfaces"), DBUS_HELPER_INTERFACE, QString("WirelessInterfaces"),
QList<QVariant>(), true, debug)[0].toStringList(); QList<QVariant>(), true, debug);
if (responce.isEmpty())
interfaces = netctlCommand->getWirelessInterfaceList();
else else
interfaces = responce[0].toStringList();
} else
interfaces = netctlCommand->getWirelessInterfaceList(); interfaces = netctlCommand->getWirelessInterfaceList();
if (interfaces.isEmpty()) return; if (interfaces.isEmpty()) return;
@ -445,11 +458,9 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
settings[QString("Security")] = QString("wep"); settings[QString("Security")] = QString("wep");
else else
settings[QString("Security")] = QString("none"); settings[QString("Security")] = QString("none");
settings[QString("ESSID")] = QString("'") + settings[QString("ESSID")] = QString("'%1'").arg(ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text());
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() +
QString("'");
if (!passwd.isEmpty()) if (!passwd.isEmpty())
settings[QString("Key")] = QString("'") + passwd + QString("'"); settings[QString("Key")] = QString("'%1'").arg(passwd);
settings[QString("IP")] = QString("dhcp"); settings[QString("IP")] = QString("dhcp");
if (hiddenNetwork) if (hiddenNetwork)
settings[QString("Hidden")] = QString("yes"); settings[QString("Hidden")] = QString("yes");
@ -460,7 +471,7 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
if (useHelper) { if (useHelper) {
QStringList settingsList; QStringList settingsList;
for (int i=0; i<settings.keys().count(); i++) for (int i=0; i<settings.keys().count(); i++)
settingsList.append(settings.keys()[i] + QString("==") + settings[settings.keys()[i]]); settingsList.append(QString("%1==%2").arg(settings.keys()[i]).arg(settings[settings.keys()[i]]));
QList<QVariant> args; QList<QVariant> args;
args.append(profile); args.append(profile);
args.append(settingsList); args.append(settingsList);
@ -472,9 +483,13 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Start"), DBUS_HELPER_INTERFACE, QString("Start"),
args, true, debug); args, true, debug);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"), DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true, debug)[0].toBool(); args, true, debug);
if (responce.isEmpty())
status = netctlCommand->isProfileActive(profile);
else
status = responce[0].toBool();
} else { } else {
QString profileTempName = netctlProfile->createProfile(profile, settings); QString profileTempName = netctlProfile->createProfile(profile, settings);
netctlProfile->copyProfile(profileTempName); netctlProfile->copyProfile(profileTempName);
@ -503,7 +518,7 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
args.append(profile); args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Remove"), DBUS_HELPER_INTERFACE, QString("Remove"),
args, true, debug)[0].toBool(); args, true, debug);
} else } else
netctlProfile->removeProfile(profile); netctlProfile->removeProfile(profile);
break; break;

View File

@ -21,6 +21,7 @@
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusMessage> #include <QDBusMessage>
#include <QDebug> #include <QDebug>
#include <QLineEdit>
#include <QMenu> #include <QMenu>
#include <pdebug/pdebug.h> #include <pdebug/pdebug.h>
@ -79,7 +80,7 @@ MainWindow::MainWindow(QWidget *parent,
for (int i=0; i<ui->tableWidget_wifi->rowCount(); i++) for (int i=0; i<ui->tableWidget_wifi->rowCount(); i++)
if (ui->tableWidget_wifi->item(i, 0)->text() == args[QString("essid")].toString()) if (ui->tableWidget_wifi->item(i, 0)->text() == args[QString("essid")].toString())
ui->tableWidget_wifi->setCurrentCell(i, 0); ui->tableWidget_wifi->setCurrentCell(i, 0);
if (ui->tableWidget_wifi->currentItem() == 0) if (ui->tableWidget_wifi->currentItem() == nullptr)
ErrorWindow::showWindow(18, QString(PDEBUG), debug); ErrorWindow::showWindow(18, QString(PDEBUG), debug);
} else if (args[QString("open")].toString() != QString("PROFILE")) { } else if (args[QString("open")].toString() != QString("PROFILE")) {
ui->comboBox_profile->addItem(args[QString("open")].toString()); ui->comboBox_profile->addItem(args[QString("open")].toString());
@ -88,7 +89,7 @@ MainWindow::MainWindow(QWidget *parent,
for (int i=0; i<ui->tableWidget_main->rowCount(); i++) for (int i=0; i<ui->tableWidget_main->rowCount(); i++)
if (ui->tableWidget_main->item(i, 0)->text() == args[QString("select")].toString()) if (ui->tableWidget_main->item(i, 0)->text() == args[QString("select")].toString())
ui->tableWidget_main->setCurrentCell(i, 0); ui->tableWidget_main->setCurrentCell(i, 0);
if (ui->tableWidget_main->currentItem() == 0) if (ui->tableWidget_main->currentItem() == nullptr)
ErrorWindow::showWindow(17, QString(PDEBUG), debug); ErrorWindow::showWindow(17, QString(PDEBUG), debug);
} }
@ -118,30 +119,28 @@ QStringList MainWindow::printInformation()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QString profile; QStringList output;
QString status; output.append(QString("none"));
output.append(QString("(none)"));
if (useHelper) { if (useHelper) {
QStringList request = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, QStringList request = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("Information"), DBUS_HELPER_INTERFACE, QString("Information"),
QList<QVariant>(), true, debug)[0].toStringList(); QList<QVariant>(), true, debug)[0].toStringList();
profile = request[0]; if (request.count() != 2) return output;
status = request[1]; output = request;
} else { } else {
if (netctlCommand->isNetctlAutoRunning()) { if (netctlCommand->isNetctlAutoRunning()) {
profile = netctlCommand->autoGetActiveProfile(); output[0] = netctlCommand->autoGetActiveProfile();
status = QString("netctl-auto"); output[1] = QString("netctl-auto");
} else { } else {
QStringList currentProfiles = netctlCommand->getActiveProfile(); QStringList currentProfiles = netctlCommand->getActiveProfile();
profile = currentProfiles.join(QChar('|')); output[0] = currentProfiles.join(QChar('|'));
QStringList statusList; QStringList statusList;
for (int i=0; i<currentProfiles.count(); i++) for (int i=0; i<currentProfiles.count(); i++)
statusList.append(netctlCommand->getProfileStatus(currentProfiles[i])); statusList.append(netctlCommand->getProfileStatus(currentProfiles[i]));
status = statusList.join(QChar('|')); output[1] = statusList.join(QChar('|'));
} }
} }
QStringList output;
output.append(profile);
output.append(status);
return output; return output;
} }
@ -153,8 +152,7 @@ QStringList MainWindow::printSettings()
QStringList settingsList; QStringList settingsList;
for (int i=0; i<configuration.keys().count(); i++) for (int i=0; i<configuration.keys().count(); i++)
settingsList.append(configuration.keys()[i] + QString("==") + settingsList.append(QString("%1==%2").arg(configuration.keys()[i]).arg(configuration[configuration.keys()[i]]));
configuration[configuration.keys()[i]]);
return settingsList; return settingsList;
} }
@ -243,18 +241,15 @@ bool MainWindow::isHelperServiceActive()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QString cmd = configuration[QString("SYSTEMCTL_PATH")] + QString(" is-active ") + QString cmd = QString("%1 is-active %2").arg(configuration[QString("SYSTEMCTL_PATH")])
configuration[QString("HELPER_SERVICE")]; .arg(configuration[QString("HELPER_SERVICE")]);
if (debug) qDebug() << PDEBUG << "Run cmd" << cmd; if (debug) qDebug() << PDEBUG << "Run cmd" << cmd;
TaskResult process = runTask(cmd, false); TaskResult process = runTask(cmd, false);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode; if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0) if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error; if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
if (process.exitCode != 0) return (process.exitCode == 0);
return false;
else
return true;
} }
@ -262,8 +257,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if ((QSystemTrayIcon::isSystemTrayAvailable()) && if ((QSystemTrayIcon::isSystemTrayAvailable()) && (configuration[QString("SYSTRAY")] == QString("true"))) {
(configuration[QString("SYSTRAY")] == QString("true"))) {
hide(); hide();
event->ignore(); event->ignore();
} else } else
@ -305,10 +299,7 @@ bool MainWindow::checkExternalApps(const QString apps = QString("all"))
if (process.exitCode != 0) if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error; if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
if (process.exitCode != 0) return (process.exitCode == 0);
return false;
else
return true;
} }
@ -334,14 +325,12 @@ QString MainWindow::checkStatus(const bool statusBool, const bool nullFalse)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool; 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 QApplication::translate("MainWindow", "no");
if (statusBool)
return QApplication::translate("MainWindow", "yes");
if (nullFalse)
return QString(""); return QString("");
else
return QApplication::translate("MainWindow", "no");
} }
@ -372,6 +361,7 @@ void MainWindow::createActions()
// profile tab events // profile tab events
connect(ui->comboBox_profile, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabLoadProfile())); connect(ui->comboBox_profile, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabLoadProfile()));
connect(ui->comboBox_profile, SIGNAL(editTextChanged(QString)), this, SLOT(updateMenuProfile())); 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))); connect(generalWid->connectionType, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabChangeState(QString)));
// wifi tab events // wifi tab events
@ -406,8 +396,7 @@ void MainWindow::createObjects()
// backend // backend
createDBusSession(); createDBusSession();
if (useHelper) if ((useHelper) && (!forceStartHelper())) {
if (!forceStartHelper()) {
ErrorWindow::showWindow(19, QString(PDEBUG), debug); ErrorWindow::showWindow(19, QString(PDEBUG), debug);
useHelper = false; useHelper = false;
} }
@ -462,13 +451,13 @@ void MainWindow::createToolBars()
actionToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle); actionToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
toolBarActions[QString("netctlAuto")] = actionToolBar->addAction(QApplication::translate("MainWindow", "netctl-auto"), toolBarActions[QString("netctlAuto")] = actionToolBar->addAction(QApplication::translate("MainWindow", "netctl-auto"),
this, SLOT(showNetctlAutoWindow())); 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"), QApplication::translate("MainWindow", "Refresh"),
this, SLOT(updateMainTab())); this, SLOT(updateMainTab()));
toolBarActions[QString("profileClear")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-clear")), toolBarActions[QString("profileClear")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-clear")),
QApplication::translate("MainWindow", "Clear"), QApplication::translate("MainWindow", "Clear"),
this, SLOT(profileTabClear())); 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"), QApplication::translate("MainWindow", "Refresh"),
this, SLOT(updateWifiTab())); this, SLOT(updateWifiTab()));
@ -482,7 +471,7 @@ void MainWindow::createToolBars()
toolBarActions[QString("mainSwitch")] = menu->addAction(QIcon::fromTheme(QString("system-run")), toolBarActions[QString("mainSwitch")] = menu->addAction(QIcon::fromTheme(QString("system-run")),
QApplication::translate("MainWindow", "Switch"), QApplication::translate("MainWindow", "Switch"),
this, SLOT(mainTabSwitchToProfile())); 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"), QApplication::translate("MainWindow", "Restart"),
this, SLOT(mainTabRestartProfile())); this, SLOT(mainTabRestartProfile()));
toolBarActions[QString("mainEnable")] = menu->addAction(QIcon::fromTheme(QString("edit-add")), toolBarActions[QString("mainEnable")] = menu->addAction(QIcon::fromTheme(QString("edit-add")),
@ -503,7 +492,7 @@ void MainWindow::createToolBars()
actionMenu->setMenu(menu); actionMenu->setMenu(menu);
actionToolBar->addWidget(actionMenu); 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"), QApplication::translate("MainWindow", "Edit"),
this, SLOT(mainTabEditProfile())); this, SLOT(mainTabEditProfile()));
toolBarActions[QString("mainRemove")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-delete")), 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<QString, QString> MainWindow::parseOptions(const QString options) QMap<QString, QString> MainWindow::parseOptions(const QString options)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;

View File

@ -167,7 +167,6 @@ private:
void createObjects(); void createObjects();
void createToolBars(); void createToolBars();
void deleteObjects(); void deleteObjects();
void keyPressEvent(QKeyEvent *pressedKey);
QString configPath; QString configPath;
bool debug = false; bool debug = false;
bool hiddenNetwork; bool hiddenNetwork;

View File

@ -34,7 +34,7 @@ QMap<QString, QVariant> getArgs()
QMap<QString, QVariant> args; QMap<QString, QVariant> args;
// windows // windows
args[QString("detached")] = false; args[QString("detached")] = false;
args[QString("minimized")] = (int) 0; args[QString("minimized")] = static_cast<int>(0);
args[QString("about")] = false; args[QString("about")] = false;
args[QString("auto")] = false; args[QString("auto")] = false;
args[QString("settings")] = false; args[QString("settings")] = false;
@ -43,11 +43,11 @@ QMap<QString, QVariant> getArgs()
args[QString("open")] = QString("PROFILE"); args[QString("open")] = QString("PROFILE");
args[QString("select")] = QString("PROFILE"); args[QString("select")] = QString("PROFILE");
// additional functions // 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("debug")] = false;
args[QString("defaults")] = false; args[QString("defaults")] = false;
args[QString("options")] = QString("OPTIONS"); args[QString("options")] = QString("OPTIONS");
args[QString("tab")] = (int) 1; args[QString("tab")] = static_cast<int>(1);
// messages // messages
args[QString("error")] = false; args[QString("error")] = false;
args[QString("help")] = false; args[QString("help")] = false;
@ -66,46 +66,29 @@ QString helpMessage()
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Options:")); helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Options:"));
// windows // windows
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Open window:")); helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Open window:"));
helpMessage += QString(" --detached - %1\n") helpMessage += QString(" --detached - %1\n").arg(QApplication::translate("MainWindow", "start detached from console"));
.arg(QApplication::translate("MainWindow", "start detached from console")); helpMessage += QString(" --maximized - %1\n").arg(QApplication::translate("MainWindow", "start maximized"));
helpMessage += QString(" --maximized - %1\n") helpMessage += QString(" --minimized - %1\n").arg(QApplication::translate("MainWindow", "start minimized to tray"));
.arg(QApplication::translate("MainWindow", "start maximized")); helpMessage += QString(" --about - %1\n").arg(QApplication::translate("MainWindow", "show about window"));
helpMessage += QString(" --minimized - %1\n") helpMessage += QString(" --netctl-auto - %1\n").arg(QApplication::translate("MainWindow", "show netctl-auto window"));
.arg(QApplication::translate("MainWindow", "start minimized to tray")); helpMessage += QString(" --settings - %1\n").arg(QApplication::translate("MainWindow", "show settings window"));
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 // main functions
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Functions:")); helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Functions:"));
helpMessage += QString(" -e, --essid <arg> - %1\n") helpMessage += QString(" -e, --essid <arg> - %1\n").arg(QApplication::translate("MainWindow", "select this ESSID"));
.arg(QApplication::translate("MainWindow", "select this ESSID")); helpMessage += QString(" -o, --open <arg> - %1\n").arg(QApplication::translate("MainWindow", "open this profile"));
helpMessage += QString(" -o, --open <arg> - %1\n") helpMessage += QString(" -s, --select <arg> - %1\n").arg(QApplication::translate("MainWindow", "select this profile"));
.arg(QApplication::translate("MainWindow", "open this profile"));
helpMessage += QString(" -s, --select <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "select this profile"));
// additional functions // additional functions
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Additional flags:")); helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Additional flags:"));
helpMessage += QString(" -c, --config <arg> - %1\n") helpMessage += QString(" -c, --config <arg> - %1\n").arg(QApplication::translate("MainWindow", "read configuration from this file"));
.arg(QApplication::translate("MainWindow", "read configuration from this file")); helpMessage += QString(" -d, --debug - %1\n").arg(QApplication::translate("MainWindow", "print debug information"));
helpMessage += QString(" -d, --debug - %1\n") helpMessage += QString(" --default - %1\n").arg(QApplication::translate("MainWindow", "start with default settings"));
.arg(QApplication::translate("MainWindow", "print debug information")); helpMessage += QString(" --set-opts <arg> - %1\n").arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
helpMessage += QString(" --default - %1\n") helpMessage += QString(" -t, --tab <arg> - %1\n").arg(QApplication::translate("MainWindow", "open a tab with this number"));
.arg(QApplication::translate("MainWindow", "start with default settings"));
helpMessage += QString(" --set-opts <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
helpMessage += QString(" -t, --tab <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "open a tab with this number"));
// messages // messages
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Show messages:")); helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Show messages:"));
helpMessage += QString(" -v, --version - %1\n") helpMessage += QString(" -v, --version - %1\n").arg(QApplication::translate("MainWindow", "show version and exit"));
.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(" -i, --info - %1\n") helpMessage += QString(" -h, --help - %1\n").arg(QApplication::translate("MainWindow", "show this help and exit"));
.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; return helpMessage;
} }
@ -115,8 +98,7 @@ QString infoMessage()
{ {
QString infoMessage = QString(""); QString infoMessage = QString("");
// build information // build information
infoMessage += QApplication::translate("MainWindow", "Build date: %1"). infoMessage += QApplication::translate("MainWindow", "Build date: %1").arg(QString(BUILD_DATE));
arg(QString(BUILD_DATE));
// cmake // cmake
infoMessage += QString("\n%1:\n").arg(QApplication::translate("MainWindow", "cmake flags")); infoMessage += QString("\n%1:\n").arg(QApplication::translate("MainWindow", "cmake flags"));
// cmake properties // cmake properties
@ -162,15 +144,9 @@ QString versionMessage()
{ {
QString versionMessage = QString(""); QString versionMessage = QString("");
versionMessage += QString("%1\n").arg(QString(NAME)); versionMessage += QString("%1\n").arg(QString(NAME));
versionMessage += QString("%1 : %2\n") versionMessage += QString("%1 : %2\n").arg(QApplication::translate("MainWindow", "Version")).arg(QString(VERSION));
.arg(QApplication::translate("MainWindow", "Version")) versionMessage += QString("%1 : %2\n").arg(QApplication::translate("MainWindow", "Author")).arg(QString(AUTHOR));
.arg(QString(VERSION)); versionMessage += QString("%1 : %2\n").arg(QApplication::translate("MainWindow", "License")).arg(QString(LICENSE));
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; return versionMessage;
} }

View File

@ -70,7 +70,7 @@
<string>Refresh</string> <string>Refresh</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="stock-refresh"> <iconset theme="view-refresh">
<normaloff/> <normaloff/>
</iconset> </iconset>
</property> </property>
@ -223,7 +223,7 @@
</action> </action>
<action name="actionRefresh"> <action name="actionRefresh">
<property name="icon"> <property name="icon">
<iconset theme="stock-refresh"> <iconset theme="view-refresh">
<normaloff/> <normaloff/>
</iconset> </iconset>
</property> </property>

View File

@ -70,8 +70,7 @@ QString NetctlGuiAdaptor::Pony()
{ {
QString pony; QString pony;
QFile ponyFile(QString(":pinkiepie")); QFile ponyFile(QString(":pinkiepie"));
if (!ponyFile.open(QIODevice::ReadOnly)) if (!ponyFile.open(QIODevice::ReadOnly)) return pony;
return pony;
pony = QTextCodec::codecForMib(106)->toUnicode(ponyFile.readAll()); pony = QTextCodec::codecForMib(106)->toUnicode(ponyFile.readAll());
ponyFile.close(); ponyFile.close();

View File

@ -177,13 +177,8 @@ void SettingsWindow::setTray()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (ui->checkBox_enableTray->checkState() == 0) { ui->checkBox_closeToTray->setDisabled(ui->checkBox_enableTray->checkState() == 0);
ui->checkBox_closeToTray->setDisabled(true); ui->checkBox_startToTray->setDisabled(ui->checkBox_enableTray->checkState() == 0);
ui->checkBox_startToTray->setDisabled(true);
} else if (ui->checkBox_enableTray->checkState() == 2) {
ui->checkBox_closeToTray->setEnabled(true);
ui->checkBox_startToTray->setEnabled(true);
}
} }
@ -328,8 +323,7 @@ QMap<QString, QString> SettingsWindow::readSettings()
config[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text(); config[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
for (int i=0; i<config.keys().count(); i++) for (int i=0; i<config.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << config.keys()[i] + QString("=") + if (debug) qDebug() << PDEBUG << ":" << QString("%1=%2").arg(config.keys()[i]).arg(config[config.keys()[i]]);
config[config.keys()[i]];
return config; return config;
} }
@ -356,12 +350,8 @@ void SettingsWindow::setSettings(const QMap<QString, QString> config)
ui->lineEdit_helperPath->setText(config[QString("HELPER_PATH")]); ui->lineEdit_helperPath->setText(config[QString("HELPER_PATH")]);
ui->lineEdit_helperService->setText(config[QString("HELPER_SERVICE")]); ui->lineEdit_helperService->setText(config[QString("HELPER_SERVICE")]);
ui->lineEdit_interfacesDir->setText(config[QString("IFACE_DIR")]); ui->lineEdit_interfacesDir->setText(config[QString("IFACE_DIR")]);
ui->comboBox_language->setCurrentIndex(0); int index = ui->comboBox_language->findText(config[QString("LANGUAGE")]);
for (int i=0; i<ui->comboBox_language->count(); i++) ui->comboBox_language->setCurrentIndex(index);
if (ui->comboBox_language->itemText(i) == config[QString("LANGUAGE")]) {
ui->comboBox_language->setCurrentIndex(i);
break;
}
ui->lineEdit_netctlPath->setText(config[QString("NETCTL_PATH")]); ui->lineEdit_netctlPath->setText(config[QString("NETCTL_PATH")]);
ui->lineEdit_netctlAutoPath->setText(config[QString("NETCTLAUTO_PATH")]); ui->lineEdit_netctlAutoPath->setText(config[QString("NETCTLAUTO_PATH")]);
ui->lineEdit_netctlAutoService->setText(config[QString("NETCTLAUTO_SERVICE")]); ui->lineEdit_netctlAutoService->setText(config[QString("NETCTLAUTO_SERVICE")]);
@ -392,8 +382,7 @@ void SettingsWindow::setSettings(const QMap<QString, QString> config)
ui->lineEdit_wpaSupDrivers->setText(config[QString("WPA_DRIVERS")]); ui->lineEdit_wpaSupDrivers->setText(config[QString("WPA_DRIVERS")]);
for (int i=0; i<config.keys().count(); i++) for (int i=0; i<config.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << config.keys()[i] + QString("=") + if (debug) qDebug() << PDEBUG << ":" << QString("%1=%2").arg(config.keys()[i]).arg(config[config.keys()[i]]);
config[config.keys()[i]];
} }
@ -458,8 +447,7 @@ QMap<QString, QString> SettingsWindow::getSettings(QString fileName)
settings.endGroup(); settings.endGroup();
for (int i=0; i<config.keys().count(); i++) for (int i=0; i<config.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << config.keys()[i] + QString("=") + if (debug) qDebug() << PDEBUG << ":" << QString("%1=%2").arg(config.keys()[i]).arg(config[config.keys()[i]]);
config[config.keys()[i]];
return config; return config;
} }

View File

@ -202,7 +202,7 @@ void TrayIcon::createActions()
connect(switchToProfileMenu, SIGNAL(triggered(QAction *)), this, SLOT(switchToProfileSlot(QAction *))); connect(switchToProfileMenu, SIGNAL(triggered(QAction *)), this, SLOT(switchToProfileSlot(QAction *)));
menuActions->addAction(contextMenu[QString("switch")]); menuActions->addAction(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())); connect(contextMenu[QString("restart")], SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot()));
menuActions->addAction(contextMenu[QString("restart")]); menuActions->addAction(contextMenu[QString("restart")]);

View File

@ -68,9 +68,7 @@ void WirelessWidget::clear()
if (rfkillDirectory->exists()) { if (rfkillDirectory->exists()) {
QStringList rfkillDevices = rfkillDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot); QStringList rfkillDevices = rfkillDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i=0; i<rfkillDevices.count(); i++) { for (int i=0; i<rfkillDevices.count(); i++) {
QFile device(QString("%1%2%3%2name").arg(rfkillDirectory->absolutePath()) QFile device(QString("%1/%2/name").arg(rfkillDirectory->absolutePath()).arg(rfkillDevices[i]));
.arg(QDir::separator())
.arg(rfkillDevices[i]));
if (!device.open(QIODevice::ReadOnly)) continue; if (!device.open(QIODevice::ReadOnly)) continue;
ui->comboBox_rfkill->addItem(QString(device.readLine()).trimmed()); ui->comboBox_rfkill->addItem(QString(device.readLine()).trimmed());
device.close(); device.close();

View File

@ -120,7 +120,7 @@ int main(int argc, char *argv[])
if (args[QString("error")].toBool()) { if (args[QString("error")].toBool()) {
cout << errorMessage().toUtf8().data() << endl; cout << errorMessage().toUtf8().data() << endl;
cout << helpMessage().toUtf8().data(); cout << helpMessage().toUtf8().data();
return 127; return 11;
} else if (args[QString("help")].toBool()) { } else if (args[QString("help")].toBool()) {
cout << helpMessage().toUtf8().data(); cout << helpMessage().toUtf8().data();
return 0; return 0;

View File

@ -54,27 +54,17 @@ QString helpMessage()
helpMessage += QString("netctlgui-helper [ options ]\n"); helpMessage += QString("netctlgui-helper [ options ]\n");
helpMessage += QString("%1\n").arg(QCoreApplication::translate("NetctlHelper", "Options:")); helpMessage += QString("%1\n").arg(QCoreApplication::translate("NetctlHelper", "Options:"));
// windows // windows
helpMessage += QString(" -c, --config <arg> - %1\n") helpMessage += QString(" -c, --config <arg> - %1\n").arg(QCoreApplication::translate("NetctlHelper", "read configuration from this file"));
.arg(QCoreApplication::translate("NetctlHelper", "read configuration from this file")); helpMessage += QString(" -d, --debug - %1\n").arg(QCoreApplication::translate("NetctlHelper", "print debug information"));
helpMessage += QString(" -d, --debug - %1\n") helpMessage += QString(" --nodaemon - %1\n").arg(QCoreApplication::translate("NetctlHelper", "do not start as daemon"));
.arg(QCoreApplication::translate("NetctlHelper", "print debug information")); helpMessage += QString(" --replace - %1\n").arg(QCoreApplication::translate("NetctlHelper", "force replace the existing session"));
helpMessage += QString(" --nodaemon - %1\n") helpMessage += QString(" --restore - %1\n").arg(QCoreApplication::translate("NetctlHelper", "force restore the existing session"));
.arg(QCoreApplication::translate("NetctlHelper", "do not start as daemon")); helpMessage += QString(" --session - %1\n").arg(QCoreApplication::translate("NetctlHelper", "force create user DBus session"));
helpMessage += QString(" --replace - %1\n") helpMessage += QString(" --system - %1\n").arg(QCoreApplication::translate("NetctlHelper", "do not read user configuration, system-wide only"));
.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(" %1\n").arg(QCoreApplication::translate("NetctlHelper", "Show messages:"));
helpMessage += QString(" -v, --version - %1\n") helpMessage += QString(" -v, --version - %1\n").arg(QCoreApplication::translate("NetctlHelper", "show version and exit"));
.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(" -i, --info - %1\n") helpMessage += QString(" -h, --help - %1\n").arg(QCoreApplication::translate("NetctlHelper", "show this help and exit"));
.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; return helpMessage;
} }
@ -131,15 +121,9 @@ QString versionMessage()
{ {
QString versionMessage = QString(""); QString versionMessage = QString("");
versionMessage += QString("%1\n").arg(QString(NAME)); versionMessage += QString("%1\n").arg(QString(NAME));
versionMessage += QString("%1 : %2\n") versionMessage += QString("%1 : %2\n").arg(QCoreApplication::translate("NetctlHelper", "Version")).arg(QString(VERSION));
.arg(QCoreApplication::translate("NetctlHelper", "Version")) versionMessage += QString("%1 : %2\n").arg(QCoreApplication::translate("NetctlHelper", "Author")).arg(QString(AUTHOR));
.arg(QString(VERSION)); versionMessage += QString("%1 : %2\n").arg(QCoreApplication::translate("NetctlHelper", "License")).arg(QString(LICENSE));
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; return versionMessage;
} }

View File

@ -494,9 +494,7 @@ QStringList Netctl::getWirelessInterfaceList()
interfaces.append(mainInterface); interfaces.append(mainInterface);
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot); QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i=0; i<allInterfaces.count(); i++) { for (int i=0; i<allInterfaces.count(); i++) {
QString dir = QString("%1%2%3%2wireless").arg(ifaceDirectory->path()) QString dir = QString("%1/%2/wireless").arg(ifaceDirectory->path()).arg(allInterfaces[i]);
.arg(QDir::separator())
.arg(allInterfaces[i]);
if (debug) qDebug() << PDEBUG << ":" << "Check directory" << dir; if (debug) qDebug() << PDEBUG << ":" << "Check directory" << dir;
if (QDir(dir).exists()) if (QDir(dir).exists())
interfaces.append(allInterfaces[i]); interfaces.append(allInterfaces[i]);

View File

@ -80,9 +80,7 @@ bool NetctlProfile::copyProfile(const QString oldPath)
return false; return false;
} }
QString newPath = QString("%1%2%3").arg(profileDirectory->absolutePath()) QString newPath = QString("%1/%2").arg(profileDirectory->absolutePath()).arg(QFileInfo(oldPath).fileName());
.arg(QDir::separator())
.arg(QFileInfo(oldPath).fileName());
QString cmd = QString("%1 /usr/bin/mv \"%2\" \"%3\"").arg(sudoCommand) QString cmd = QString("%1 /usr/bin/mv \"%2\" \"%3\"").arg(sudoCommand)
.arg(oldPath) .arg(oldPath)
.arg(newPath); .arg(newPath);
@ -104,9 +102,7 @@ QString NetctlProfile::createProfile(const QString profile, const QMap<QString,
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile; if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
QString profileTempName = QString("%1%2%3").arg(QDir::tempPath()) QString profileTempName = QString("%1/%2").arg(QDir::tempPath()).arg(QFileInfo(profile).fileName());
.arg(QDir::separator())
.arg(QFileInfo(profile).fileName());
QFile profileFile(profileTempName); QFile profileFile(profileTempName);
if (debug) qDebug() << PDEBUG << ":" << "Save to" << profileTempName; if (debug) qDebug() << PDEBUG << ":" << "Save to" << profileTempName;
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text)) if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
@ -215,9 +211,7 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
systemVariables.append(output[i].split(QChar('='))[0]); systemVariables.append(output[i].split(QChar('='))[0]);
// profile variables // profile variables
QMap<QString, QString> settings; QMap<QString, QString> settings;
QString profileUrl = QString("%1%2%3").arg(profileDirectory->absolutePath()) QString profileUrl = QString("%1/%2").arg(profileDirectory->absolutePath()).arg(QFileInfo(profile).fileName());
.arg(QDir::separator())
.arg(QFileInfo(profile).fileName());
cmd = QString("env -i bash -c \"source '%1'; set\"").arg(profileUrl); cmd = QString("env -i bash -c \"source '%1'; set\"").arg(profileUrl);
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd; if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
process = runTask(cmd, false); process = runTask(cmd, false);
@ -269,9 +263,7 @@ bool NetctlProfile::removeProfile(const QString profile)
return false; return false;
} }
QString profilePath = QString("%1%2%3").arg(profileDirectory->absolutePath()) QString profilePath = QString("%1/%2").arg(profileDirectory->absolutePath()).arg(QFileInfo(profile).fileName());
.arg(QDir::separator())
.arg(QFileInfo(profile).fileName());
QString cmd = QString("%1 /usr/bin/rm \"%2\"").arg(sudoCommand).arg(profilePath); QString cmd = QString("%1 /usr/bin/rm \"%2\"").arg(sudoCommand).arg(profilePath);
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd; if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
TaskResult process = runTask(cmd, useSuid); TaskResult process = runTask(cmd, useSuid);

View File

@ -477,7 +477,7 @@ void Netctl::createActions()
menuActions.append(contextMenu[QString("switch")]); menuActions.append(contextMenu[QString("switch")]);
contextMenu[QString("restart")] = new QAction(i18n("Restart profile"), this); 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())); connect(contextMenu[QString("restart")], SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot()));
menuActions.append(contextMenu[QString("restart")]); menuActions.append(contextMenu[QString("restart")]);

View File

@ -105,7 +105,7 @@ Item {
plasmoid.setAction("stopProfile", i18n("Stop profile"), "dialog-close") plasmoid.setAction("stopProfile", i18n("Stop profile"), "dialog-close")
plasmoid.setAction("stopAllProfiles", i18n("Stop all profiles"), "dialog-close") plasmoid.setAction("stopAllProfiles", i18n("Stop all profiles"), "dialog-close")
plasmoid.setAction("switchToProfile", i18n("Switch to profile")) 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("enableProfile", i18n("Enable profile"))
plasmoid.setAction("startWifi", i18n("Show WiFi menu"), "netctl-gui-wifi") plasmoid.setAction("startWifi", i18n("Show WiFi menu"), "netctl-gui-wifi")
// helper // helper