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