mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
add dynamic settings load
fix setTray() function
This commit is contained in:
parent
4e027ec19f
commit
516c4b5a22
@ -10,6 +10,7 @@ Ver.1.3.0
|
||||
+ add 3rd party license information
|
||||
+ add system tray icon
|
||||
+ add dbus interface org.netctlgui.netctlgui
|
||||
+ add dynamic settings load
|
||||
* update to library changes
|
||||
* rewrite tables to use toolTip
|
||||
* library:
|
||||
|
@ -164,7 +164,7 @@ int main(int argc, char *argv[])
|
||||
if (args[QString("select")].toString() != QString("PROFILE"))
|
||||
args[QString("tab")] = (int) 1;
|
||||
|
||||
// reread translations
|
||||
// reread translations according to flags
|
||||
a.removeTranslator(&translator);
|
||||
language = Language::defineLanguage(args[QString("config")].toString(),
|
||||
args[QString("options")].toString());
|
||||
@ -190,6 +190,6 @@ int main(int argc, char *argv[])
|
||||
cout << versionMessage().toUtf8().data();
|
||||
return 0;
|
||||
}
|
||||
MainWindow w(0, args);
|
||||
MainWindow w(0, args, &translator);
|
||||
return a.exec();
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
#include <QTranslator>
|
||||
#include <QUrl>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
@ -35,6 +36,7 @@
|
||||
#include "ethernetwidget.h"
|
||||
#include "generalwidget.h"
|
||||
#include "ipwidget.h"
|
||||
#include "language.h"
|
||||
#include "macvlanwidget.h"
|
||||
#include "mobilewidget.h"
|
||||
#include "netctladaptor.h"
|
||||
@ -52,83 +54,30 @@
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent,
|
||||
const QMap<QString, QVariant> args)
|
||||
const QMap<QString, QVariant> args,
|
||||
QTranslator *appTranslator)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
debug(args[QString("debug")].toBool())
|
||||
configPath(args[QString("config")].toString()),
|
||||
debug(args[QString("debug")].toBool()),
|
||||
translator(appTranslator)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "startMinimized" << args[QString("minimized")].toInt();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showAbout" << args[QString("about")].toBool();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showNetctlAuto" << args[QString("auto")].toBool();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showSettings" << args[QString("settings")].toBool();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "selectEssid" << args[QString("essid")].toString();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "openProfile" << args[QString("open")].toString();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "selectProfile" << args[QString("select")].toString();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "configPath" << args[QString("config")].toString();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "debug" << args[QString("debug")].toBool();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "defaultSettings" << args[QString("defaults")].toBool();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "about" << args[QString("about")].toBool();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "auto" << args[QString("auto")].toBool();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "config" << configPath;
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "debug" << debug;
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "defaults" << args[QString("defaults")].toBool();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "essid" << args[QString("essid")].toString();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "minimized" << args[QString("minimized")].toInt();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "open" << args[QString("open")].toString();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "options" << args[QString("options")].toString();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "tabNum" << args[QString("tab")].toInt();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "select" << args[QString("select")].toString();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "settings" << args[QString("settings")].toBool();
|
||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "tab" << args[QString("tab")].toInt();
|
||||
|
||||
// reading configuration
|
||||
settingsWin = new SettingsWindow(this, debug, args[QString("config")].toString());
|
||||
if (args[QString("defaults")].toBool())
|
||||
settingsWin->setDefault();
|
||||
configuration = settingsWin->getSettings();
|
||||
QMap<QString, QString> optionsDict = parseOptions(args[QString("options")].toString());
|
||||
for (int i=0; i<optionsDict.keys().count(); i++)
|
||||
configuration[optionsDict.keys()[i]] = optionsDict[optionsDict.keys()[i]];
|
||||
|
||||
// backend
|
||||
createDBusSession();
|
||||
netctlCommand = new Netctl(debug, configuration);
|
||||
netctlProfile = new NetctlProfile(debug, configuration);
|
||||
wpaCommand = new WpaSup(debug, configuration);
|
||||
// frontend
|
||||
// windows
|
||||
ui->setupUi(this);
|
||||
ui->tableWidget_main->setColumnHidden(2, true);
|
||||
ui->tableWidget_main->setColumnHidden(3, true);
|
||||
ui->tableWidget_wifi->setColumnHidden(3, true);
|
||||
ui->tableWidget_wifi->setColumnHidden(4, true);
|
||||
aboutWin = new AboutWindow(this, debug);
|
||||
errorWin = new ErrorWindow(this, debug);
|
||||
netctlAutoWin = new NetctlAutoWindow(this, debug, configuration);
|
||||
// profile widgets
|
||||
generalWid = new GeneralWidget(this, configuration);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(generalWid);
|
||||
ipWid = new IpWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(ipWid);
|
||||
bridgeWid = new BridgeWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid);
|
||||
ethernetWid = new EthernetWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid);
|
||||
macvlanWid = new MacvlanWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(macvlanWid);
|
||||
mobileWid = new MobileWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
|
||||
pppoeWid = new PppoeWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);
|
||||
tunnelWid = new TunnelWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(tunnelWid);
|
||||
tuntapWid = new TuntapWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(tuntapWid);
|
||||
vlanWid = new VlanWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
|
||||
wirelessWid = new WirelessWidget(this, configuration);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
|
||||
|
||||
setTab(args[QString("tab")].toInt()-1);
|
||||
createActions();
|
||||
setIconsToTabs();
|
||||
|
||||
if (args[QString("about")].toBool())
|
||||
showAboutWindow();
|
||||
if (args[QString("auto")].toBool())
|
||||
showNetctlAutoWindow();
|
||||
if (args[QString("settings")].toBool())
|
||||
showSettingsWindow();
|
||||
updateConfiguration(args);
|
||||
|
||||
// main actions
|
||||
if (args[QString("essid")].toString() != QString("ESSID")) {
|
||||
for (int i=0; i<ui->tableWidget_wifi->rowCount(); i++)
|
||||
if (ui->tableWidget_wifi->item(i, 0)->text() == args[QString("essid")].toString())
|
||||
@ -148,29 +97,15 @@ MainWindow::MainWindow(QWidget *parent,
|
||||
errorWin->showWindow(17, QString("[MainWindow] : [MainWindow]"));
|
||||
}
|
||||
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready"));
|
||||
// show windows
|
||||
if (args[QString("about")].toBool())
|
||||
showAboutWindow();
|
||||
if (args[QString("auto")].toBool())
|
||||
showNetctlAutoWindow();
|
||||
if (args[QString("settings")].toBool())
|
||||
showSettingsWindow();
|
||||
|
||||
// tray
|
||||
trayIcon = new TrayIcon(this, debug);
|
||||
if (args[QString("minimized")].toInt() == 1)
|
||||
return;
|
||||
if ((QSystemTrayIcon::isSystemTrayAvailable()) &&
|
||||
(configuration[QString("SYSTRAY")] == QString("true")))
|
||||
trayIcon->setVisible(true);
|
||||
else
|
||||
trayIcon->setVisible(false);
|
||||
if (trayIcon->isVisible()) {
|
||||
if (configuration[QString("STARTTOTRAY")] == QString("true"))
|
||||
hide();
|
||||
else
|
||||
show();
|
||||
if (args[QString("minimized")].toInt() == 2)
|
||||
show();
|
||||
else if (args[QString("minimized")].toInt() == 3)
|
||||
hide();
|
||||
}
|
||||
else
|
||||
show();
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready"));
|
||||
}
|
||||
|
||||
|
||||
@ -179,28 +114,7 @@ MainWindow::~MainWindow()
|
||||
if (debug) qDebug() << "[MainWindow]" << "[~MainWindow]";
|
||||
|
||||
QDBusConnection::sessionBus().unregisterService(QString(DBUS_SERVICE));
|
||||
delete netctlCommand;
|
||||
delete netctlProfile;
|
||||
delete wpaCommand;
|
||||
|
||||
delete bridgeWid;
|
||||
delete ethernetWid;
|
||||
delete generalWid;
|
||||
delete ipWid;
|
||||
delete macvlanWid;
|
||||
delete mobileWid;
|
||||
delete pppoeWid;
|
||||
delete tunnelWid;
|
||||
delete tuntapWid;
|
||||
delete vlanWid;
|
||||
delete wirelessWid;
|
||||
|
||||
delete aboutWin;
|
||||
delete errorWin;
|
||||
delete netctlAutoWin;
|
||||
delete settingsWin;
|
||||
delete trayIcon;
|
||||
delete ui;
|
||||
deleteObjects();
|
||||
}
|
||||
|
||||
|
||||
@ -242,11 +156,13 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[closeEvent]";
|
||||
|
||||
if (configuration[QString("CLOSETOTRAY")] == QString("true"))
|
||||
if (trayIcon->isVisible()) {
|
||||
if ((configuration[QString("CLOSETOTRAY")] == QString("true")) &&
|
||||
(trayIcon->isVisible())) {
|
||||
hide();
|
||||
event->ignore();
|
||||
}
|
||||
else
|
||||
closeMainWindow();
|
||||
}
|
||||
|
||||
|
||||
@ -369,6 +285,81 @@ void MainWindow::createDBusSession()
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::createObjects()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[createObjects]";
|
||||
|
||||
// backend
|
||||
netctlCommand = new Netctl(debug, configuration);
|
||||
netctlProfile = new NetctlProfile(debug, configuration);
|
||||
wpaCommand = new WpaSup(debug, configuration);
|
||||
// frontend
|
||||
trayIcon = new TrayIcon(this, debug);
|
||||
// windows
|
||||
ui = new Ui::MainWindow;
|
||||
ui->setupUi(this);
|
||||
ui->tableWidget_main->setColumnHidden(2, true);
|
||||
ui->tableWidget_main->setColumnHidden(3, true);
|
||||
ui->tableWidget_wifi->setColumnHidden(3, true);
|
||||
ui->tableWidget_wifi->setColumnHidden(4, true);
|
||||
aboutWin = new AboutWindow(this, debug);
|
||||
errorWin = new ErrorWindow(this, debug);
|
||||
netctlAutoWin = new NetctlAutoWindow(this, debug, configuration);
|
||||
// profile widgets
|
||||
generalWid = new GeneralWidget(this, configuration);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(generalWid);
|
||||
ipWid = new IpWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(ipWid);
|
||||
bridgeWid = new BridgeWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid);
|
||||
ethernetWid = new EthernetWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid);
|
||||
macvlanWid = new MacvlanWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(macvlanWid);
|
||||
mobileWid = new MobileWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
|
||||
pppoeWid = new PppoeWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);
|
||||
tunnelWid = new TunnelWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(tunnelWid);
|
||||
tuntapWid = new TuntapWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(tuntapWid);
|
||||
vlanWid = new VlanWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
|
||||
wirelessWid = new WirelessWidget(this, configuration);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::deleteObjects()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[deleteObjects]";
|
||||
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
if (wpaCommand != nullptr) delete wpaCommand;
|
||||
|
||||
if (bridgeWid != nullptr) delete bridgeWid;
|
||||
if (ethernetWid != nullptr) delete ethernetWid;
|
||||
if (generalWid != nullptr) delete generalWid;
|
||||
if (ipWid != nullptr) delete ipWid;
|
||||
if (macvlanWid != nullptr) delete macvlanWid;
|
||||
if (mobileWid != nullptr) delete mobileWid;
|
||||
if (pppoeWid != nullptr) delete pppoeWid;
|
||||
if (tunnelWid != nullptr) delete tunnelWid;
|
||||
if (tuntapWid != nullptr) delete tuntapWid;
|
||||
if (vlanWid != nullptr) delete vlanWid;
|
||||
if (wirelessWid != nullptr) delete wirelessWid;
|
||||
|
||||
if (aboutWin != nullptr) delete aboutWin;
|
||||
if (errorWin != nullptr) delete errorWin;
|
||||
if (netctlAutoWin != nullptr) delete netctlAutoWin;
|
||||
if (settingsWin != nullptr) delete settingsWin;
|
||||
if (trayIcon != nullptr) delete trayIcon;
|
||||
if (ui != nullptr) delete ui;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[keyPressEvent]";
|
||||
@ -489,28 +480,72 @@ void MainWindow::showSettingsWindow()
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setTab(const int tab)
|
||||
void MainWindow::setTab(int tab)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[setTab]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[setTab]" << ":" << "Update tab" << tab;
|
||||
|
||||
switch (tab) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
break;
|
||||
default:
|
||||
tab = 0;
|
||||
break;
|
||||
}
|
||||
ui->tabWidget->setCurrentIndex(tab);
|
||||
|
||||
updateTabs(tab);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateTabs(const int tab)
|
||||
void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[updateTabs]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[updateTabs]" << ":" << "Update tab" << tab;
|
||||
if (debug) qDebug() << "[MainWindow]" << "[updateConfiguration]";
|
||||
|
||||
if (tab == 0)
|
||||
updateMainTab();
|
||||
else if (tab == 1)
|
||||
updateProfileTab();
|
||||
else if (tab == 2)
|
||||
updateWifiTab();
|
||||
updateMenu();
|
||||
deleteObjects();
|
||||
|
||||
settingsWin = new SettingsWindow(this, debug, configPath);
|
||||
if (args[QString("defauls")].toBool())
|
||||
settingsWin->setDefault();
|
||||
configuration = settingsWin->getSettings();
|
||||
QMap<QString, QString> optionsDict = parseOptions(args[QString("options")].toString());
|
||||
for (int i=0; i<optionsDict.keys().count(); i++)
|
||||
configuration[optionsDict.keys()[i]] = optionsDict[optionsDict.keys()[i]];
|
||||
|
||||
// update translation
|
||||
qApp->removeTranslator(translator);
|
||||
QString language = Language::defineLanguage(configPath,
|
||||
args[QString("options")].toString());
|
||||
translator->load(QString(":/translations/") + language);
|
||||
qApp->installTranslator(translator);
|
||||
|
||||
createObjects();
|
||||
setTab(args[QString("tab")].toInt() - 1);
|
||||
createActions();
|
||||
setIconsToTabs();
|
||||
|
||||
// tray
|
||||
if (args[QString("minimized")].toInt() == 1)
|
||||
return;
|
||||
if ((QSystemTrayIcon::isSystemTrayAvailable()) &&
|
||||
(configuration[QString("SYSTRAY")] == QString("true")))
|
||||
trayIcon->setVisible(true);
|
||||
else
|
||||
trayIcon->setVisible(false);
|
||||
if (trayIcon->isVisible()) {
|
||||
if (configuration[QString("STARTTOTRAY")] == QString("true"))
|
||||
hide();
|
||||
else
|
||||
show();
|
||||
if (args[QString("minimized")].toInt() == 2)
|
||||
show();
|
||||
else if (args[QString("minimized")].toInt() == 3)
|
||||
hide();
|
||||
}
|
||||
else
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
@ -530,6 +565,21 @@ void MainWindow::updateMenu()
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateTabs(const int tab)
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[updateTabs]";
|
||||
if (debug) qDebug() << "[MainWindow]" << "[updateTabs]" << ":" << "Update tab" << tab;
|
||||
|
||||
if (tab == 0)
|
||||
updateMainTab();
|
||||
else if (tab == 1)
|
||||
updateProfileTab();
|
||||
else if (tab == 2)
|
||||
updateWifiTab();
|
||||
updateMenu();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateMainTab()
|
||||
{
|
||||
if (debug) qDebug() << "[MainWindow]" << "[updateMainTab]";
|
||||
|
@ -54,7 +54,8 @@ class MainWindow : public QMainWindow
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0,
|
||||
const QMap<QString, QVariant> args = QMap<QString, QVariant>());
|
||||
const QMap<QString, QVariant> args = QMap<QString, QVariant>(),
|
||||
QTranslator *appTranslator = 0);
|
||||
~MainWindow();
|
||||
QString getInformation();
|
||||
QStringList getSettings();
|
||||
@ -63,18 +64,20 @@ protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
public slots:
|
||||
void setTab(const int tab);
|
||||
void updateTabs(const int tab);
|
||||
void updateMenu();
|
||||
// wifi tab slots
|
||||
void connectToUnknownEssid(const QString passwd);
|
||||
void setHiddenName(const QString name);
|
||||
// actions from trayicon
|
||||
void closeMainWindow();
|
||||
void showAboutWindow();
|
||||
void showMainWindow();
|
||||
void showNetctlAutoWindow();
|
||||
void showSettingsWindow();
|
||||
// main
|
||||
void setTab(int tab);
|
||||
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>());
|
||||
void updateMenu();
|
||||
void updateTabs(const int tab);
|
||||
// wifi tab slots
|
||||
void connectToUnknownEssid(const QString passwd);
|
||||
void setHiddenName(const QString name);
|
||||
|
||||
private slots:
|
||||
void reportABug();
|
||||
@ -109,36 +112,40 @@ private slots:
|
||||
|
||||
private:
|
||||
// ui
|
||||
Ui::MainWindow *ui;
|
||||
AboutWindow *aboutWin;
|
||||
ErrorWindow *errorWin;
|
||||
NetctlAutoWindow *netctlAutoWin;
|
||||
PasswdWidget *passwdWid;
|
||||
SettingsWindow *settingsWin;
|
||||
BridgeWidget *bridgeWid;
|
||||
EthernetWidget *ethernetWid;
|
||||
GeneralWidget *generalWid;
|
||||
IpWidget *ipWid;
|
||||
MacvlanWidget *macvlanWid;
|
||||
MobileWidget *mobileWid;
|
||||
PppoeWidget *pppoeWid;
|
||||
TunnelWidget *tunnelWid;
|
||||
TuntapWidget *tuntapWid;
|
||||
VlanWidget *vlanWid;
|
||||
WirelessWidget *wirelessWid;
|
||||
TrayIcon *trayIcon;
|
||||
TrayIcon *trayIcon = nullptr;
|
||||
Ui::MainWindow *ui = nullptr;
|
||||
AboutWindow *aboutWin = nullptr;
|
||||
ErrorWindow *errorWin = nullptr;
|
||||
NetctlAutoWindow *netctlAutoWin = nullptr;
|
||||
PasswdWidget *passwdWid = nullptr;
|
||||
SettingsWindow *settingsWin = nullptr;
|
||||
BridgeWidget *bridgeWid = nullptr;
|
||||
EthernetWidget *ethernetWid = nullptr;
|
||||
GeneralWidget *generalWid = nullptr;
|
||||
IpWidget *ipWid = nullptr;
|
||||
MacvlanWidget *macvlanWid = nullptr;
|
||||
MobileWidget *mobileWid = nullptr;
|
||||
PppoeWidget *pppoeWid = nullptr;
|
||||
TunnelWidget *tunnelWid = nullptr;
|
||||
TuntapWidget *tuntapWid = nullptr;
|
||||
VlanWidget *vlanWid = nullptr;
|
||||
WirelessWidget *wirelessWid = nullptr;
|
||||
// backend
|
||||
Netctl *netctlCommand;
|
||||
NetctlProfile *netctlProfile;
|
||||
WpaSup *wpaCommand;
|
||||
Netctl *netctlCommand = nullptr;
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
WpaSup *wpaCommand = nullptr;
|
||||
bool checkExternalApps(const QString apps);
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||
void createActions();
|
||||
void createDBusSession();
|
||||
void createObjects();
|
||||
void deleteObjects();
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
void setIconsToTabs();
|
||||
QString configPath;
|
||||
bool debug;
|
||||
bool hiddenNetwork;
|
||||
QTranslator *translator = nullptr;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
QMap<QString, QString> parseOptions(const QString options);
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QTextStream>
|
||||
|
||||
#include "language.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QString configFile)
|
||||
@ -55,7 +56,6 @@ void SettingsWindow::createActions()
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(saveSettings()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||
connect(ui->checkBox_enableTray, SIGNAL(stateChanged(int)), this, SLOT(setTray()));
|
||||
connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
|
||||
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
|
||||
// buttons
|
||||
@ -115,6 +115,8 @@ void SettingsWindow::saveSettings()
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
out << settings.keys()[i] << QString("=") << settings[settings.keys()[i]] << endl;
|
||||
configFile.close();
|
||||
|
||||
((MainWindow *)parent())->updateConfiguration();
|
||||
}
|
||||
|
||||
|
||||
@ -123,15 +125,11 @@ void SettingsWindow::setTray()
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[setTray]";
|
||||
|
||||
if (ui->checkBox_enableTray->checkState() == 0) {
|
||||
ui->checkBox_closeToTray->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_closeToTray->setDisabled(true);
|
||||
ui->checkBox_startToTray->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_startToTray->setDisabled(true);
|
||||
}
|
||||
else if (ui->checkBox_enableTray->checkState() == 2) {
|
||||
ui->checkBox_closeToTray->setCheckState(Qt::Checked);
|
||||
ui->checkBox_closeToTray->setEnabled(true);
|
||||
ui->checkBox_startToTray->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_startToTray->setEnabled(true);
|
||||
}
|
||||
}
|
||||
@ -274,7 +272,7 @@ void SettingsWindow::showWindow()
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[showWindow]";
|
||||
|
||||
setSettings(getSettings());
|
||||
ui->label_info->hide();
|
||||
setTray();
|
||||
|
||||
show();
|
||||
}
|
||||
@ -285,10 +283,10 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]";
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
if (ui->checkBox_closeToTray->checkState() == 0)
|
||||
settings[QString("CLOSETOTRAY")] = QString("false");
|
||||
else
|
||||
if (ui->checkBox_closeToTray->checkState() == 2)
|
||||
settings[QString("CLOSETOTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("CLOSETOTRAY")] = QString("false");
|
||||
settings[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
|
||||
settings[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->text();
|
||||
settings[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
|
||||
@ -300,16 +298,16 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
settings[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
|
||||
settings[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
|
||||
settings[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
|
||||
if (ui->checkBox_startToTray->checkState() == 0)
|
||||
settings[QString("STARTTOTRAY")] = QString("false");
|
||||
else
|
||||
if (ui->checkBox_startToTray->checkState() == 2)
|
||||
settings[QString("STARTTOTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("STARTTOTRAY")] = QString("false");
|
||||
settings[QString("SUDO_PATH")] = ui->lineEdit_sudo->text();
|
||||
settings[QString("SYSTEMCTL_PATH")] = ui->lineEdit_systemctlPath->text();
|
||||
if (ui->checkBox_enableTray->checkState() == 0)
|
||||
settings[QString("SYSTRAY")] = QString("false");
|
||||
else
|
||||
if (ui->checkBox_enableTray->checkState() == 2)
|
||||
settings[QString("SYSTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("SYSTRAY")] = QString("false");
|
||||
settings[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
|
||||
settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
|
||||
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>662</width>
|
||||
<height>323</height>
|
||||
<width>660</width>
|
||||
<height>321</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -127,8 +127,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>446</width>
|
||||
<height>262</height>
|
||||
<width>444</width>
|
||||
<height>260</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
@ -150,16 +150,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_info">
|
||||
<property name="text">
|
||||
<string>You will need to restart the application</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_enableTray">
|
||||
<property name="text">
|
||||
|
@ -242,7 +242,7 @@ private:
|
||||
/**
|
||||
* @brief NetctlProfile class
|
||||
*/
|
||||
NetctlProfile *netctlProfile;
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
/**
|
||||
* @brief show debug messages
|
||||
*/
|
||||
@ -250,7 +250,7 @@ private:
|
||||
/**
|
||||
* @brief directory with interfaces. Default is "/sys/class/net/"
|
||||
*/
|
||||
QDir *ifaceDirectory;
|
||||
QDir *ifaceDirectory = nullptr;
|
||||
/**
|
||||
* @brief prefered interface for WiFi. Default is ""
|
||||
*/
|
||||
|
@ -95,7 +95,7 @@ private:
|
||||
/**
|
||||
* @brief directory which contains profiles. Default is "/etc/netctl"
|
||||
*/
|
||||
QDir *profileDirectory;
|
||||
QDir *profileDirectory = nullptr;
|
||||
/**
|
||||
* @brief path to sudo command. Default is "/usr/bin/kdesu"
|
||||
*/
|
||||
|
@ -129,11 +129,11 @@ private:
|
||||
/**
|
||||
* @brief Netctl class
|
||||
*/
|
||||
Netctl *netctlCommand;
|
||||
Netctl *netctlCommand = nullptr;
|
||||
/**
|
||||
* @brief NetctlProfile class
|
||||
*/
|
||||
NetctlProfile *netctlProfile;
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
/**
|
||||
* @brief show debug messages
|
||||
*/
|
||||
|
@ -78,10 +78,8 @@ Netctl::~Netctl()
|
||||
{
|
||||
if (debug) qDebug() << "[Netctl]" << "[~Netctl]";
|
||||
|
||||
if (netctlProfile != 0)
|
||||
delete netctlProfile;
|
||||
if (ifaceDirectory != 0)
|
||||
delete ifaceDirectory;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
if (ifaceDirectory != nullptr) delete ifaceDirectory;
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,8 +59,7 @@ NetctlProfile::~NetctlProfile()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlProfile]" << "[~NetctlProfile]";
|
||||
|
||||
if (profileDirectory != 0)
|
||||
delete profileDirectory;
|
||||
if (profileDirectory != nullptr) delete profileDirectory;
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,10 +79,8 @@ WpaSup::~WpaSup()
|
||||
{
|
||||
if (debug) qDebug() << "[WpaSup]" << "[~WpaSup]";
|
||||
|
||||
if (netctlCommand != 0)
|
||||
delete netctlCommand;
|
||||
if (netctlProfile != 0)
|
||||
delete netctlProfile;
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user