mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
add system tray
This commit is contained in:
parent
0432579f5b
commit
fdb5b46ea1
@ -8,6 +8,7 @@ Ver.1.3.0
|
|||||||
* change internal IP definition
|
* change internal IP definition
|
||||||
* gui:
|
* gui:
|
||||||
+ add 3rd party license information
|
+ add 3rd party license information
|
||||||
|
+ add system tray icon
|
||||||
* update to library changes
|
* update to library changes
|
||||||
* rewrite tables to use toolTip
|
* rewrite tables to use toolTip
|
||||||
* library:
|
* library:
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
# variables
|
# variables
|
||||||
_netctl_gui_arglist=(
|
_netctl_gui_arglist=(
|
||||||
|
'--maximized'
|
||||||
|
'--minimized'
|
||||||
'--about'
|
'--about'
|
||||||
'--netctl-auto'
|
'--netctl-auto'
|
||||||
'--settings'
|
'--settings'
|
||||||
@ -44,6 +46,7 @@ _netctl_gui_arglist=(
|
|||||||
)
|
)
|
||||||
|
|
||||||
_netctl_gui_settings=(
|
_netctl_gui_settings=(
|
||||||
|
'CLOSETOTRAY'
|
||||||
'CTRL_DIR'
|
'CTRL_DIR'
|
||||||
'CTRL_GROUP'
|
'CTRL_GROUP'
|
||||||
'IFACE_DIR'
|
'IFACE_DIR'
|
||||||
@ -55,8 +58,10 @@ _netctl_gui_settings=(
|
|||||||
'PREFERED_IFACE'
|
'PREFERED_IFACE'
|
||||||
'PROFILE_DIR'
|
'PROFILE_DIR'
|
||||||
'RFKILL_DIR'
|
'RFKILL_DIR'
|
||||||
|
'STARTTOTRAY'
|
||||||
'SUDO_PATH'
|
'SUDO_PATH'
|
||||||
'SYSTEMCTL_PATH'
|
'SYSTEMCTL_PATH'
|
||||||
|
'SYSTRAY'
|
||||||
'WPACLI_PATH'
|
'WPACLI_PATH'
|
||||||
'WPASUP_PATH'
|
'WPASUP_PATH'
|
||||||
'WPA_DRIVERS'
|
'WPA_DRIVERS'
|
||||||
|
@ -54,6 +54,7 @@ int main(int argc, char *argv[])
|
|||||||
// reading command line flags
|
// reading command line flags
|
||||||
bool error = false;
|
bool error = false;
|
||||||
// windows
|
// windows
|
||||||
|
int startMinimized = 0;
|
||||||
bool showAbout = false;
|
bool showAbout = false;
|
||||||
bool showNetctlAuto = false;
|
bool showNetctlAuto = false;
|
||||||
bool showSettings = false;
|
bool showSettings = false;
|
||||||
@ -73,8 +74,16 @@ int main(int argc, char *argv[])
|
|||||||
// reading
|
// reading
|
||||||
for (int i=1; i<argc; i++) {
|
for (int i=1; i<argc; i++) {
|
||||||
// windows
|
// windows
|
||||||
|
// maximized
|
||||||
|
if (QString(argv[i]) == QString("--maximized")) {
|
||||||
|
startMinimized = 1;
|
||||||
|
}
|
||||||
|
// minimized
|
||||||
|
else if (QString(argv[i]) == QString("--minimized")) {
|
||||||
|
startMinimized = 2;
|
||||||
|
}
|
||||||
// about
|
// about
|
||||||
if (QString(argv[i]) == QString("--about")) {
|
else if (QString(argv[i]) == QString("--about")) {
|
||||||
showAbout = true;
|
showAbout = true;
|
||||||
}
|
}
|
||||||
// netctl-auto
|
// netctl-auto
|
||||||
@ -159,7 +168,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
QString helpMessage = QString("");
|
QString helpMessage = QString("");
|
||||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Usage:"));
|
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Usage:"));
|
||||||
helpMessage += QString("netctl-gui [ --about ] [ --netctl-auto ] [ --settings ]\n");
|
helpMessage += QString("netctl-gui [ --maximized ] [ --minimized ]\n");
|
||||||
|
helpMessage += QString(" [ --about ] [ --netctl-auto ] [ --settings ]\n");
|
||||||
helpMessage += QString(" [ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]\n");
|
helpMessage += QString(" [ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]\n");
|
||||||
helpMessage += QString(" [ -s PROFILE | --select PROFILE ]\n");
|
helpMessage += QString(" [ -s PROFILE | --select PROFILE ]\n");
|
||||||
helpMessage += QString(" [ -c FILE | --config FILE ] [ -d | --debug ] [ --default ]\n");
|
helpMessage += QString(" [ -c FILE | --config FILE ] [ -d | --debug ] [ --default ]\n");
|
||||||
@ -168,6 +178,12 @@ int main(int argc, char *argv[])
|
|||||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Parametrs:"));
|
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Parametrs:"));
|
||||||
// windows
|
// windows
|
||||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Open window:"));
|
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Open window:"));
|
||||||
|
helpMessage += QString("%1 --maximized - %2\n")
|
||||||
|
.arg(isParametrEnable(startMinimized))
|
||||||
|
.arg(QApplication::translate("MainWindow", "start maximized"));
|
||||||
|
helpMessage += QString("%1 --minimized - %2\n")
|
||||||
|
.arg(isParametrEnable(startMinimized))
|
||||||
|
.arg(QApplication::translate("MainWindow", "start minimized"));
|
||||||
helpMessage += QString("%1 --about - %2\n")
|
helpMessage += QString("%1 --about - %2\n")
|
||||||
.arg(isParametrEnable(showAbout))
|
.arg(isParametrEnable(showAbout))
|
||||||
.arg(QApplication::translate("MainWindow", "show about window"));
|
.arg(QApplication::translate("MainWindow", "show about window"));
|
||||||
@ -266,10 +282,9 @@ int main(int argc, char *argv[])
|
|||||||
cout << versionMessage.toUtf8().data();
|
cout << versionMessage.toUtf8().data();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
MainWindow w(0,
|
MainWindow w(0, startMinimized,
|
||||||
showAbout, showNetctlAuto, showSettings,
|
showAbout, showNetctlAuto, showSettings,
|
||||||
selectEssid, openProfile, selectProfile,
|
selectEssid, openProfile, selectProfile,
|
||||||
configPath, debug, defaultSettings, options, tabNumber);
|
configPath, debug, defaultSettings, options, tabNumber);
|
||||||
w.show();
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "passwdwidget.h"
|
#include "passwdwidget.h"
|
||||||
#include "pppoewidget.h"
|
#include "pppoewidget.h"
|
||||||
#include "settingswindow.h"
|
#include "settingswindow.h"
|
||||||
|
#include "trayicon.h"
|
||||||
#include "tunnelwidget.h"
|
#include "tunnelwidget.h"
|
||||||
#include "tuntapwidget.h"
|
#include "tuntapwidget.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
@ -47,6 +48,7 @@
|
|||||||
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent,
|
MainWindow::MainWindow(QWidget *parent,
|
||||||
|
const int startMinimized,
|
||||||
const bool showAbout,
|
const bool showAbout,
|
||||||
const bool showNetctlAuto,
|
const bool showNetctlAuto,
|
||||||
const bool showSettings,
|
const bool showSettings,
|
||||||
@ -62,6 +64,7 @@ MainWindow::MainWindow(QWidget *parent,
|
|||||||
ui(new Ui::MainWindow),
|
ui(new Ui::MainWindow),
|
||||||
debug(debugCmd)
|
debug(debugCmd)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "startMinimized" << startMinimized;
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showAbout" << showAbout;
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showAbout" << showAbout;
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showNetctlAuto" << showNetctlAuto;
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showNetctlAuto" << showNetctlAuto;
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showSettings" << showSettings;
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showSettings" << showSettings;
|
||||||
@ -153,6 +156,26 @@ MainWindow::MainWindow(QWidget *parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready"));
|
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready"));
|
||||||
|
|
||||||
|
// tray
|
||||||
|
trayIcon = new TrayIcon(this, debug);
|
||||||
|
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 (startMinimized == 1)
|
||||||
|
show();
|
||||||
|
else if (startMinimized == 2)
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -181,6 +204,48 @@ MainWindow::~MainWindow()
|
|||||||
delete netctlAutoWin;
|
delete netctlAutoWin;
|
||||||
delete settingsWin;
|
delete settingsWin;
|
||||||
delete ui;
|
delete ui;
|
||||||
|
delete trayIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString MainWindow::getInformation()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[getInformation]";
|
||||||
|
|
||||||
|
QString profile;
|
||||||
|
QString status;
|
||||||
|
if (netctlCommand->isNetctlAutoRunning()) {
|
||||||
|
profile = netctlCommand->autoGetActiveProfile();
|
||||||
|
status = QString("netctl-auto");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile = netctlCommand->getActiveProfile();
|
||||||
|
status = netctlCommand->getProfileStatus(profile);
|
||||||
|
}
|
||||||
|
QString output = QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Profile")).arg(profile);
|
||||||
|
output += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Status")).arg(status);
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool MainWindow::isNetctlAutoWindowHidden()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[isNetctlAutoWindowHidden]";
|
||||||
|
|
||||||
|
return netctlAutoWin->isHidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[closeEvent]";
|
||||||
|
|
||||||
|
if (configuration[QString("CLOSETOTRAY")] == QString("true"))
|
||||||
|
if (trayIcon->isVisible()) {
|
||||||
|
hide();
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -240,7 +305,7 @@ void MainWindow::createActions()
|
|||||||
connect(ui->actionNetctlAuto, SIGNAL(triggered(bool)), netctlAutoWin, SLOT(showWindow()));
|
connect(ui->actionNetctlAuto, SIGNAL(triggered(bool)), netctlAutoWin, SLOT(showWindow()));
|
||||||
connect(ui->actionSettings, SIGNAL(triggered(bool)), settingsWin, SLOT(showWindow()));
|
connect(ui->actionSettings, SIGNAL(triggered(bool)), settingsWin, SLOT(showWindow()));
|
||||||
connect(ui->actionReport, SIGNAL(triggered(bool)), this, SLOT(reportABug()));
|
connect(ui->actionReport, SIGNAL(triggered(bool)), this, SLOT(reportABug()));
|
||||||
connect(ui->actionQuit, SIGNAL(triggered(bool)), this, SLOT(close()));
|
connect(ui->actionQuit, SIGNAL(triggered(bool)), this, SLOT(closeMainWindow()));
|
||||||
|
|
||||||
// actions menu
|
// actions menu
|
||||||
connect(ui->menuActions, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
connect(ui->menuActions, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
||||||
@ -356,6 +421,36 @@ void MainWindow::setMenuActionsShown(const bool state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::closeMainWindow()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[closeMainWindow]";
|
||||||
|
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::showNetctlAutoWindow()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[showNetctlAutoWindow]";
|
||||||
|
|
||||||
|
if (netctlAutoWin->isHidden())
|
||||||
|
netctlAutoWin->showWindow();
|
||||||
|
else
|
||||||
|
netctlAutoWin->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::showMainWindow()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[showMainWindow]";
|
||||||
|
|
||||||
|
if (isHidden())
|
||||||
|
show();
|
||||||
|
else
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::updateTabs(const int tab)
|
void MainWindow::updateTabs(const int tab)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[updateTabs]";
|
if (debug) qDebug() << "[MainWindow]" << "[updateTabs]";
|
||||||
|
@ -37,6 +37,7 @@ class NetctlProfile;
|
|||||||
class PasswdWidget;
|
class PasswdWidget;
|
||||||
class PppoeWidget;
|
class PppoeWidget;
|
||||||
class SettingsWindow;
|
class SettingsWindow;
|
||||||
|
class TrayIcon;
|
||||||
class TunnelWidget;
|
class TunnelWidget;
|
||||||
class TuntapWidget;
|
class TuntapWidget;
|
||||||
class VlanWidget;
|
class VlanWidget;
|
||||||
@ -53,6 +54,7 @@ class MainWindow : public QMainWindow
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = 0,
|
explicit MainWindow(QWidget *parent = 0,
|
||||||
|
const int startMinimized = false,
|
||||||
const bool showAbout = false,
|
const bool showAbout = false,
|
||||||
const bool showNetctlAuto = false,
|
const bool showNetctlAuto = false,
|
||||||
const bool showSettings = false,
|
const bool showSettings = false,
|
||||||
@ -65,6 +67,11 @@ public:
|
|||||||
const QString options = QString("OPTIONS"),
|
const QString options = QString("OPTIONS"),
|
||||||
const int tabNum = 1);
|
const int tabNum = 1);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
QString getInformation();
|
||||||
|
bool isNetctlAutoWindowHidden();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateTabs(const int tab);
|
void updateTabs(const int tab);
|
||||||
@ -72,6 +79,10 @@ public slots:
|
|||||||
// wifi tab slots
|
// wifi tab slots
|
||||||
void connectToUnknownEssid(const QString passwd);
|
void connectToUnknownEssid(const QString passwd);
|
||||||
void setHiddenName(const QString name);
|
void setHiddenName(const QString name);
|
||||||
|
// actions from trayicon
|
||||||
|
void closeMainWindow();
|
||||||
|
void showNetctlAutoWindow();
|
||||||
|
void showMainWindow();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void reportABug();
|
void reportABug();
|
||||||
@ -123,6 +134,7 @@ private:
|
|||||||
TuntapWidget *tuntapWid;
|
TuntapWidget *tuntapWid;
|
||||||
VlanWidget *vlanWid;
|
VlanWidget *vlanWid;
|
||||||
WirelessWidget *wirelessWid;
|
WirelessWidget *wirelessWid;
|
||||||
|
TrayIcon *trayIcon;
|
||||||
// backend
|
// backend
|
||||||
Netctl *netctlCommand;
|
Netctl *netctlCommand;
|
||||||
NetctlProfile *netctlProfile;
|
NetctlProfile *netctlProfile;
|
||||||
|
@ -54,6 +54,7 @@ void SettingsWindow::createActions()
|
|||||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
|
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
|
||||||
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->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
|
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 *)));
|
||||||
@ -117,6 +118,25 @@ void SettingsWindow::saveSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SettingsWindow::setDefault()
|
void SettingsWindow::setDefault()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[setDefault]";
|
if (debug) qDebug() << "[SettingsWindow]" << "[setDefault]";
|
||||||
@ -265,6 +285,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)
|
||||||
|
settings[QString("CLOSETOTRAY")] = QString("false");
|
||||||
|
else
|
||||||
|
settings[QString("CLOSETOTRAY")] = QString("true");
|
||||||
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();
|
||||||
@ -276,8 +300,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)
|
||||||
|
settings[QString("STARTTOTRAY")] = QString("false");
|
||||||
|
else
|
||||||
|
settings[QString("STARTTOTRAY")] = QString("true");
|
||||||
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)
|
||||||
|
settings[QString("SYSTRAY")] = QString("false");
|
||||||
|
else
|
||||||
|
settings[QString("SYSTRAY")] = QString("true");
|
||||||
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();
|
||||||
@ -293,6 +325,10 @@ void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]";
|
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]";
|
||||||
|
|
||||||
|
if (settings[QString("CLOSETOTRAY")] == QString("true"))
|
||||||
|
ui->checkBox_closeToTray->setCheckState(Qt::Checked);
|
||||||
|
else
|
||||||
|
ui->checkBox_closeToTray->setCheckState(Qt::Unchecked);
|
||||||
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
|
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
|
||||||
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
|
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
|
||||||
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
|
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
|
||||||
@ -307,8 +343,16 @@ void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
|||||||
ui->lineEdit_interface->setText(settings[QString("PREFERED_IFACE")]);
|
ui->lineEdit_interface->setText(settings[QString("PREFERED_IFACE")]);
|
||||||
ui->lineEdit_profilePath->setText(settings[QString("PROFILE_DIR")]);
|
ui->lineEdit_profilePath->setText(settings[QString("PROFILE_DIR")]);
|
||||||
ui->lineEdit_rfkill->setText(settings[QString("RFKILL_DIR")]);
|
ui->lineEdit_rfkill->setText(settings[QString("RFKILL_DIR")]);
|
||||||
|
if (settings[QString("STARTTOTRAY")] == QString("true"))
|
||||||
|
ui->checkBox_startToTray->setCheckState(Qt::Checked);
|
||||||
|
else
|
||||||
|
ui->checkBox_startToTray->setCheckState(Qt::Unchecked);
|
||||||
ui->lineEdit_sudo->setText(settings[QString("SUDO_PATH")]);
|
ui->lineEdit_sudo->setText(settings[QString("SUDO_PATH")]);
|
||||||
ui->lineEdit_systemctlPath->setText(settings[QString("SYSTEMCTL_PATH")]);
|
ui->lineEdit_systemctlPath->setText(settings[QString("SYSTEMCTL_PATH")]);
|
||||||
|
if (settings[QString("SYSTRAY")] == QString("true"))
|
||||||
|
ui->checkBox_enableTray->setCheckState(Qt::Checked);
|
||||||
|
else
|
||||||
|
ui->checkBox_enableTray->setCheckState(Qt::Unchecked);
|
||||||
ui->lineEdit_wpaCliPath->setText(settings[QString("WPACLI_PATH")]);
|
ui->lineEdit_wpaCliPath->setText(settings[QString("WPACLI_PATH")]);
|
||||||
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
|
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
|
||||||
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
|
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
|
||||||
@ -323,6 +367,7 @@ QMap<QString, QString> SettingsWindow::getDefault()
|
|||||||
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]";
|
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]";
|
||||||
|
|
||||||
QMap<QString, QString> settings;
|
QMap<QString, QString> settings;
|
||||||
|
settings[QString("CLOSETOTRAY")] = QString("true");
|
||||||
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
|
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
|
||||||
settings[QString("CTRL_GROUP")] = QString("users");
|
settings[QString("CTRL_GROUP")] = QString("users");
|
||||||
settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
|
settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
|
||||||
@ -334,8 +379,10 @@ QMap<QString, QString> SettingsWindow::getDefault()
|
|||||||
settings[QString("PREFERED_IFACE")] = QString("");
|
settings[QString("PREFERED_IFACE")] = QString("");
|
||||||
settings[QString("PROFILE_DIR")] = QString("/etc/netctl/");
|
settings[QString("PROFILE_DIR")] = QString("/etc/netctl/");
|
||||||
settings[QString("RFKILL_DIR")] = QString("/sys/class/rfkill/");
|
settings[QString("RFKILL_DIR")] = QString("/sys/class/rfkill/");
|
||||||
|
settings[QString("STARTTOTRAY")] = QString("false");
|
||||||
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
|
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
|
||||||
settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl");
|
settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl");
|
||||||
|
settings[QString("SYSTRAY")] = QString("true");
|
||||||
settings[QString("WPACLI_PATH")] = QString("/usr/bin/wpa_cli");
|
settings[QString("WPACLI_PATH")] = QString("/usr/bin/wpa_cli");
|
||||||
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
|
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
|
||||||
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
|
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
|
||||||
|
@ -49,6 +49,7 @@ private slots:
|
|||||||
void addLanguages();
|
void addLanguages();
|
||||||
void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
void setTray();
|
||||||
// buttons
|
// buttons
|
||||||
void selectIfaceDir();
|
void selectIfaceDir();
|
||||||
void selectNetctlPath();
|
void selectNetctlPath();
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>668</width>
|
<width>662</width>
|
||||||
<height>329</height>
|
<height>323</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>452</width>
|
<width>446</width>
|
||||||
<height>268</height>
|
<height>262</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
@ -160,6 +160,27 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBox_enableTray">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable system tray</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBox_closeToTray">
|
||||||
|
<property name="text">
|
||||||
|
<string>Minimize to tray instead of closing</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBox_startToTray">
|
||||||
|
<property name="text">
|
||||||
|
<string>Start minimized to tray</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="spacer_general">
|
<spacer name="spacer_general">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -194,8 +215,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>452</width>
|
<width>436</width>
|
||||||
<height>268</height>
|
<height>165</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
@ -381,8 +402,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>452</width>
|
<width>436</width>
|
||||||
<height>268</height>
|
<height>43</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
@ -451,8 +472,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>452</width>
|
<width>277</width>
|
||||||
<height>268</height>
|
<height>190</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||||
|
118
sources/gui/src/trayicon.cpp
Normal file
118
sources/gui/src/trayicon.cpp
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of netctl-gui *
|
||||||
|
* *
|
||||||
|
* netctl-gui is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* netctl-gui is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "trayicon.h"
|
||||||
|
|
||||||
|
|
||||||
|
TrayIcon::TrayIcon(QObject *parent, const bool debugCmd)
|
||||||
|
: QSystemTrayIcon(parent),
|
||||||
|
debug(debugCmd)
|
||||||
|
{
|
||||||
|
mainWindow = (MainWindow *)parent;
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TrayIcon::~TrayIcon()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[TrayIcon]" << "[~TrayIcon]";
|
||||||
|
|
||||||
|
setContextMenu(0);
|
||||||
|
delete exit;
|
||||||
|
delete showMainWindow;
|
||||||
|
delete showNetctlAutoWindow;
|
||||||
|
delete showStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TrayIcon::showInformation()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[TrayIcon]" << "[showInformation]";
|
||||||
|
|
||||||
|
QString title = QApplication::translate("TrayIcon", "netctl status");
|
||||||
|
QString message = mainWindow->getInformation();
|
||||||
|
|
||||||
|
if (supportsMessages())
|
||||||
|
showMessage(title, message, QSystemTrayIcon::Information);
|
||||||
|
else
|
||||||
|
QMessageBox::information(0, title, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TrayIcon::init()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[TrayIcon]" << "[init]";
|
||||||
|
|
||||||
|
setIcon(QIcon(":icon"));
|
||||||
|
setToolTip(QString("netctl-gui"));
|
||||||
|
|
||||||
|
exit = new QAction(QIcon::fromTheme("exit"), QApplication::translate("TrayIcon", "Quit"), this);
|
||||||
|
connect(exit, SIGNAL(triggered(bool)), mainWindow, SLOT(closeMainWindow()));
|
||||||
|
showMainWindow = new QAction(QApplication::translate("TrayIcon", "Show"), this);
|
||||||
|
connect(showMainWindow, SIGNAL(triggered(bool)), mainWindow, SLOT(showMainWindow()));
|
||||||
|
showNetctlAutoWindow = new QAction(QApplication::translate("TrayIcon", "Show netctl-auto"), this);
|
||||||
|
connect(showNetctlAutoWindow, SIGNAL(triggered(bool)),mainWindow, SLOT(showNetctlAutoWindow()));
|
||||||
|
showStatus = new QAction(QIcon(":icon"), QApplication::translate("TrayIcon", "Status"), this);
|
||||||
|
connect(showStatus, SIGNAL(triggered(bool)), this, SLOT(showInformation()));
|
||||||
|
|
||||||
|
QMenu *menu = new QMenu();
|
||||||
|
menu->addAction(showStatus);
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addAction(showMainWindow);
|
||||||
|
menu->addAction(showNetctlAutoWindow);
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addAction(exit);
|
||||||
|
setContextMenu(menu);
|
||||||
|
|
||||||
|
connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||||
|
this, SLOT(itemActivated(QSystemTrayIcon::ActivationReason)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TrayIcon::itemActivated(const QSystemTrayIcon::ActivationReason reason)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[TrayIcon]" << "[itemActivated]";
|
||||||
|
if (debug) qDebug() << "[TrayIcon]" << "[itemActivated]" << ":" << "Reason" << reason;
|
||||||
|
|
||||||
|
switch (reason) {
|
||||||
|
case QSystemTrayIcon::Trigger:
|
||||||
|
showInformation();
|
||||||
|
break;
|
||||||
|
case QSystemTrayIcon::DoubleClick:
|
||||||
|
mainWindow->showMainWindow();
|
||||||
|
break;
|
||||||
|
case QSystemTrayIcon::Context:
|
||||||
|
if (mainWindow->isHidden())
|
||||||
|
showMainWindow->setText(QApplication::translate("TrayIcon", "Show"));
|
||||||
|
else
|
||||||
|
showMainWindow->setText(QApplication::translate("TrayIcon", "Hide"));
|
||||||
|
if (mainWindow->isNetctlAutoWindowHidden())
|
||||||
|
showNetctlAutoWindow->setText(QApplication::translate("TrayIcon", "Show netctl-auto"));
|
||||||
|
else
|
||||||
|
showNetctlAutoWindow->setText(QApplication::translate("TrayIcon", "Hide netctl-auto"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
55
sources/gui/src/trayicon.h
Normal file
55
sources/gui/src/trayicon.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of netctl-gui *
|
||||||
|
* *
|
||||||
|
* netctl-gui is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* netctl-gui is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TRAYICON_H
|
||||||
|
#define TRAYICON_H
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
|
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
|
class TrayIcon : public QSystemTrayIcon
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TrayIcon(QObject *parent = 0,
|
||||||
|
const bool debugCmd = false);
|
||||||
|
~TrayIcon();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void showInformation();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void itemActivated(const QSystemTrayIcon::ActivationReason reason);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool debug;
|
||||||
|
MainWindow *mainWindow;
|
||||||
|
// contextual actions
|
||||||
|
QMenu *menu;
|
||||||
|
QAction *exit;
|
||||||
|
QAction *showMainWindow;
|
||||||
|
QAction *showNetctlAutoWindow;
|
||||||
|
QAction *showStatus;
|
||||||
|
void init();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* TRAYICON_H */
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
# variables
|
# variables
|
||||||
_netctl_gui_arglist=(
|
_netctl_gui_arglist=(
|
||||||
|
{'--maximized','--maximized'}'[start maximized]'
|
||||||
|
{'--minimized','--minimized'}'[start minimized]'
|
||||||
{'--about','--about'}'[show about window]'
|
{'--about','--about'}'[show about window]'
|
||||||
{'--netctl-auto','--netctl-auto'}'[show netctl-auto window]'
|
{'--netctl-auto','--netctl-auto'}'[show netctl-auto window]'
|
||||||
{'--settings','--settings'}'[show settings window]'
|
{'--settings','--settings'}'[show settings window]'
|
||||||
@ -36,6 +38,7 @@ _netctl_gui_arglist=(
|
|||||||
)
|
)
|
||||||
|
|
||||||
_netctl_gui_settings=(
|
_netctl_gui_settings=(
|
||||||
|
'CLOSETOTRAY'
|
||||||
'CTRL_DIR'
|
'CTRL_DIR'
|
||||||
'CTRL_GROUP'
|
'CTRL_GROUP'
|
||||||
'IFACE_DIR'
|
'IFACE_DIR'
|
||||||
@ -47,8 +50,10 @@ _netctl_gui_settings=(
|
|||||||
'PREFERED_IFACE'
|
'PREFERED_IFACE'
|
||||||
'PROFILE_DIR'
|
'PROFILE_DIR'
|
||||||
'RFKILL_DIR'
|
'RFKILL_DIR'
|
||||||
|
'STARTTOTRAY'
|
||||||
'SUDO_PATH'
|
'SUDO_PATH'
|
||||||
'SYSTEMCTL_PATH'
|
'SYSTEMCTL_PATH'
|
||||||
|
'SYSTRAY'
|
||||||
'WPACLI_PATH'
|
'WPACLI_PATH'
|
||||||
'WPASUP_PATH'
|
'WPASUP_PATH'
|
||||||
'WPA_DRIVERS'
|
'WPA_DRIVERS'
|
||||||
|
Loading…
Reference in New Issue
Block a user