* remove margins
* create more pretty toolbars
* edit toolbar update action (s/setVisible/setEnabled/g)
This commit is contained in:
arcan1s 2015-03-12 02:02:20 +03:00
parent 275d71d75f
commit 02432be630
32 changed files with 832 additions and 516 deletions

View File

@ -8,7 +8,7 @@ ProjectRootRelative=./
[CMake][CMake Build Directory 0] [CMake][CMake Build Directory 0]
Build Directory Path=file:///home/arcanis/Documents/github/netctl-gui/build Build Directory Path=file:///home/arcanis/Documents/github/netctl-gui/build
Build Type=Debug Build Type=Release
CMake Binary=file:///usr/bin/cmake CMake Binary=file:///usr/bin/cmake
Environment Profile= Environment Profile=
Extra Arguments= Extra Arguments=

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>550</width> <width>550</width>
<height>76</height> <height>44</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_bridge"> <widget class="QDockWidget" name="dockWidget_bridge">
<property name="features"> <property name="features">
@ -24,6 +24,9 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_bridge"> <widget class="QWidget" name="dockWidgetContents_bridge">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_skip"> <layout class="QHBoxLayout" name="layout_skip">
<item> <item>

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>550</width> <width>550</width>
<height>275</height> <height>227</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_ethernet"> <widget class="QDockWidget" name="dockWidget_ethernet">
<property name="features"> <property name="features">
@ -24,6 +24,9 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_ethernet"> <widget class="QWidget" name="dockWidgetContents_ethernet">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_ethernetAdvanced"> <layout class="QHBoxLayout" name="layout_ethernetAdvanced">
<item> <item>
@ -51,6 +54,9 @@
<item> <item>
<widget class="QWidget" name="widget_ethernetAdvanced" native="true"> <widget class="QWidget" name="widget_ethernetAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_skip"> <layout class="QHBoxLayout" name="layout_skip">
<item> <item>
@ -117,6 +123,9 @@
<item> <item>
<widget class="QWidget" name="widget_wpa" native="true"> <widget class="QWidget" name="widget_wpa" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_wpaConfig"> <layout class="QHBoxLayout" name="layout_wpaConfig">
<item> <item>

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>550</width> <width>550</width>
<height>492</height> <height>452</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_general"> <widget class="QDockWidget" name="dockWidget_general">
<property name="sizePolicy"> <property name="sizePolicy">
@ -30,6 +30,9 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_general"> <widget class="QWidget" name="dockWidgetContents_general">
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_description"> <layout class="QHBoxLayout" name="layout_description">
<item> <item>
@ -282,6 +285,9 @@
<item> <item>
<widget class="QWidget" name="widget_generalAdvanced" native="true"> <widget class="QWidget" name="widget_generalAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QVBoxLayout" name="layout_after"> <layout class="QVBoxLayout" name="layout_after">
<item> <item>

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>550</width> <width>550</width>
<height>1286</height> <height>1154</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_ip"> <widget class="QDockWidget" name="dockWidget_ip">
<property name="features"> <property name="features">
@ -24,6 +24,9 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_ip"> <widget class="QWidget" name="dockWidgetContents_ip">
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_ip"> <layout class="QHBoxLayout" name="layout_ip">
<item> <item>
@ -76,6 +79,9 @@
<item> <item>
<widget class="QWidget" name="widget_ip" native="true"> <widget class="QWidget" name="widget_ip" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QVBoxLayout" name="layout_ipAddress"> <layout class="QVBoxLayout" name="layout_ipAddress">
<item> <item>
@ -238,6 +244,9 @@ Should be according to standards</string>
<item> <item>
<widget class="QWidget" name="widget_ip6" native="true"> <widget class="QWidget" name="widget_ip6" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QVBoxLayout" name="layout_ipAddress6"> <layout class="QVBoxLayout" name="layout_ipAddress6">
<item> <item>
@ -371,9 +380,15 @@ Should be according to standards</string>
<item> <item>
<widget class="QWidget" name="widget_ipAdvanced" native="true"> <widget class="QWidget" name="widget_ipAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_6">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QWidget" name="widget_ipRoutes" native="true"> <widget class="QWidget" name="widget_ipRoutes" native="true">
<layout class="QVBoxLayout" name="layout_ipRoutes"> <layout class="QVBoxLayout" name="layout_ipRoutes">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_ipRoutesLine"> <layout class="QHBoxLayout" name="layout_ipRoutesLine">
<item> <item>
@ -478,6 +493,9 @@ Should be according to standards</string>
<item> <item>
<widget class="QWidget" name="widget_ipRoutes6" native="true"> <widget class="QWidget" name="widget_ipRoutes6" native="true">
<layout class="QVBoxLayout" name="layout_ipRoutes6"> <layout class="QVBoxLayout" name="layout_ipRoutes6">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_ipRoutes6Line"> <layout class="QHBoxLayout" name="layout_ipRoutes6Line">
<item> <item>
@ -717,6 +735,9 @@ Should be according to standards</string>
<item> <item>
<widget class="QWidget" name="widget_dhcp" native="true"> <widget class="QWidget" name="widget_dhcp" native="true">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_dhcp"> <layout class="QHBoxLayout" name="layout_dhcp">
<item> <item>
@ -763,6 +784,9 @@ Should be according to standards</string>
<item> <item>
<widget class="QWidget" name="widget_dhcpcdOpt" native="true"> <widget class="QWidget" name="widget_dhcpcdOpt" native="true">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_dhcpcdOpt"> <widget class="QLabel" name="label_dhcpcdOpt">
<property name="sizePolicy"> <property name="sizePolicy">
@ -798,6 +822,9 @@ Should be according to standards</string>
<item> <item>
<widget class="QWidget" name="widget_dhclientOpt" native="true"> <widget class="QWidget" name="widget_dhclientOpt" native="true">
<layout class="QVBoxLayout" name="verticalLayout_8"> <layout class="QVBoxLayout" name="verticalLayout_8">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_dhclientOpt"> <layout class="QHBoxLayout" name="layout_dhclientOpt">
<item> <item>
@ -945,6 +972,9 @@ Should be according to standards</string>
<item> <item>
<widget class="QWidget" name="widget_dns" native="true"> <widget class="QWidget" name="widget_dns" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QVBoxLayout" name="layout_dns"> <layout class="QVBoxLayout" name="layout_dns">
<item> <item>

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>396</width> <width>396</width>
<height>103</height> <height>79</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_macvlan"> <widget class="QDockWidget" name="dockWidget_macvlan">
<property name="features"> <property name="features">
@ -24,6 +24,9 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_macvlan"> <widget class="QWidget" name="dockWidgetContents_macvlan">
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0"> <item row="0" column="0">
<layout class="QHBoxLayout" name="layout_mode"> <layout class="QHBoxLayout" name="layout_mode">
<item> <item>

View File

@ -21,6 +21,7 @@
#include <QDBusMessage> #include <QDBusMessage>
#include <QDir> #include <QDir>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QProcessEnvironment>
#include <QTranslator> #include <QTranslator>
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
@ -130,6 +131,9 @@ int main(int argc, char *argv[])
args[QString("error")] = true; args[QString("error")] = true;
} }
} }
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
if (!args[QString("debug")].toBool()) args[QString("debug")] = (debugEnv == QString("yes"));
if ((args[QString("debug")].toBool()) || if ((args[QString("debug")].toBool()) ||
(args[QString("help")].toBool()) || (args[QString("help")].toBool()) ||
(args[QString("info")].toBool()) || (args[QString("info")].toBool()) ||
@ -143,6 +147,13 @@ int main(int argc, char *argv[])
if (args[QString("select")].toString() != QString("PROFILE")) if (args[QString("select")].toString() != QString("PROFILE"))
args[QString("tab")] = static_cast<int>(1); args[QString("tab")] = static_cast<int>(1);
// check
QString robotEnv = environment.value(QString("SKYNET"), QString(""));
if (!robotEnv.isEmpty()) {
cout << "Sorry, this software is only for humans" << endl;
return 2;
}
// detach from console // detach from console
if (args[QString("detached")].toBool()) if (args[QString("detached")].toBool())
daemon(0, 0); daemon(0, 0);

View File

@ -31,7 +31,7 @@
MainWidget::MainWidget(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd) MainWidget::MainWidget(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd)
: QWidget(parent), : QMainWindow(parent),
debug(debugCmd), debug(debugCmd),
configuration(settings) configuration(settings)
{ {
@ -39,7 +39,6 @@ MainWidget::MainWidget(QWidget *parent, const QMap<QString, QString> settings, c
useHelper = (configuration[QString("USE_HELPER")] == QString("true")); useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
createObjects(); createObjects();
createToolBars();
createActions(); createActions();
} }
@ -52,6 +51,20 @@ MainWidget::~MainWidget()
} }
bool MainWidget::mainTabSelectProfileSlot(const QString profile)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
for (int i=0; i<ui->tableWidget_main->rowCount(); i++) {
if (ui->tableWidget_main->item(i, 0)->text() != profile) continue;
ui->tableWidget_main->setCurrentCell(i, 0);
}
return (ui->tableWidget_main->currentItem() != nullptr);
}
void MainWidget::showNetctlAutoWindow() void MainWidget::showNetctlAutoWindow()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -74,33 +87,32 @@ void MainWidget::updateMenuMain()
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
bool selected = (ui->tableWidget_main->currentItem() != nullptr); bool selected = (ui->tableWidget_main->currentItem() != nullptr);
toolBarActions[QString("mainStart")]->setVisible(selected); ui->actionStart->setEnabled(selected);
toolBarActions[QString("mainEnable")]->setVisible(selected); ui->actionEnable->setEnabled(selected);
toolBarActions[QString("mainEdit")]->setVisible(selected); ui->actionEdit->setEnabled(selected);
toolBarActions[QString("mainRemove")]->setVisible(selected); ui->actionRemove->setEnabled(selected);
toolBarActions[QString("mainStopAll")]->setVisible(!mainTabGetActiveProfiles().isEmpty());
if (selected && !ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) { if (selected && !ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) {
// visible // visible
toolBarActions[QString("mainRestart")]->setVisible(true); ui->actionRestart->setEnabled(true);
toolBarActions[QString("mainSwitch")]->setVisible(true); ui->actionSwitch->setEnabled(false);
// text // text
toolBarActions[QString("mainStart")]->setText(QApplication::translate("MainWidget", "Stop")); ui->actionStart->setText(QApplication::translate("MainWidget", "Stop"));
toolBarActions[QString("mainStart")]->setIcon(QIcon::fromTheme("process-stop")); ui->actionStart->setIcon(QIcon::fromTheme("process-stop"));
} else { } else {
// visible // visible
toolBarActions[QString("mainRestart")]->setVisible(false); ui->actionRestart->setEnabled(false);
toolBarActions[QString("mainSwitch")]->setVisible(false); ui->actionSwitch->setEnabled(selected);
// text // text
toolBarActions[QString("mainStart")]->setText(QApplication::translate("MainWidget", "Start")); ui->actionStart->setText(QApplication::translate("MainWidget", "Start"));
toolBarActions[QString("mainStart")]->setIcon(QIcon::fromTheme("system-run")); ui->actionStart->setIcon(QIcon::fromTheme("system-run"));
} }
if (selected && !ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) { if (selected && !ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) {
toolBarActions[QString("mainEnable")]->setText(QApplication::translate("MainWidget", "Disable")); ui->actionEnable->setText(QApplication::translate("MainWidget", "Disable"));
toolBarActions[QString("mainEnable")]->setIcon(QIcon::fromTheme("edit-remove")); ui->actionEnable->setIcon(QIcon::fromTheme("edit-remove"));
} else { } else {
toolBarActions[QString("mainEnable")]->setText(QApplication::translate("MainWidget", "Enable")); ui->actionEnable->setText(QApplication::translate("MainWidget", "Enable"));
toolBarActions[QString("mainEnable")]->setIcon(QIcon::fromTheme("list-add")); ui->actionEnable->setIcon(QIcon::fromTheme("list-add"));
} }
} }
@ -286,20 +298,6 @@ void MainWidget::mainTabEnableProfile()
} }
QStringList MainWidget::mainTabGetActiveProfiles()
{
if (debug) qDebug() << PDEBUG;
QStringList profiles;
for (int i=0; i<ui->tableWidget_main->rowCount(); i++) {
if (ui->tableWidget_main->item(i, 2)->text().isEmpty()) continue;
profiles.append(ui->tableWidget_main->item(i, 0)->text());
}
return profiles;
}
void MainWidget::mainTabRemoveProfile() void MainWidget::mainTabRemoveProfile()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -411,6 +409,16 @@ void MainWidget::createActions()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
// menu actions
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(mainTabEnableProfile()));
connect(ui->actionEdit, SIGNAL(triggered(bool)), this, SLOT(mainTabEditProfile()));
connect(ui->actionNetctl_auto, SIGNAL(triggered(bool)), this, SLOT(showNetctlAutoWindow()));
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(updateMainTab()));
connect(ui->actionRemove, SIGNAL(triggered(bool)), this, SLOT(mainTabRemoveProfile()));
connect(ui->actionRestart, SIGNAL(triggered(bool)), this, SLOT(mainTabRestartProfile()));
connect(ui->actionStart, SIGNAL(triggered(bool)), this, SLOT(mainTabStartProfile()));
connect(ui->actionStop_all, SIGNAL(triggered(bool)), this, SLOT(mainTabStopAllProfiles()));
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(mainTabSwitchToProfile()));
// main tab events // main tab events
connect(ui->pushButton_netctlAuto, SIGNAL(clicked(bool)), this, SLOT(showNetctlAutoWindow())); connect(ui->pushButton_netctlAuto, SIGNAL(clicked(bool)), this, SLOT(showNetctlAutoWindow()));
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile())); connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
@ -433,52 +441,13 @@ void MainWidget::createObjects()
ui->tableWidget_main->setColumnHidden(2, true); ui->tableWidget_main->setColumnHidden(2, true);
ui->tableWidget_main->setColumnHidden(3, true); ui->tableWidget_main->setColumnHidden(3, true);
netctlAutoWin = new NetctlAutoWindow(this, debug, configuration); netctlAutoWin = new NetctlAutoWindow(this, debug, configuration);
}
// append toolbar
void MainWidget::createToolBars() QMenu *actionMenu = new QMenu(this);
{ actionMenu->addAction(ui->actionSwitch);
if (debug) qDebug() << PDEBUG; actionMenu->addAction(ui->actionRestart);
actionMenu->addAction(ui->actionEnable);
actionToolBar = new QToolBar(this); ui->actionStart->setMenu(actionMenu);
actionToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
toolBarActions[QString("netctlAuto")] = actionToolBar->addAction(QApplication::translate("MainWidget", "netctl-auto"),
this, SLOT(showNetctlAutoWindow()));
toolBarActions[QString("mainRefresh")] = actionToolBar->addAction(QIcon::fromTheme(QString("view-refresh")),
QApplication::translate("MainWidget", "Refresh"),
this, SLOT(updateMainTab()));
actionMenu = new QToolButton(this);
actionMenu->setPopupMode(QToolButton::DelayedPopup);
actionMenu->setToolButtonStyle(Qt::ToolButtonFollowStyle);
QMenu *menu = new QMenu(actionMenu);
toolBarActions[QString("mainStart")] = menu->addAction(QIcon::fromTheme(QString("system-run")),
QApplication::translate("MainWidget", "Start"),
this, SLOT(mainTabStartProfile()));
toolBarActions[QString("mainSwitch")] = menu->addAction(QIcon::fromTheme(QString("system-run")),
QApplication::translate("MainWidget", "Switch"),
this, SLOT(mainTabSwitchToProfile()));
toolBarActions[QString("mainRestart")] = menu->addAction(QIcon::fromTheme(QString("view-refresh")),
QApplication::translate("MainWidget", "Restart"),
this, SLOT(mainTabRestartProfile()));
toolBarActions[QString("mainEnable")] = menu->addAction(QIcon::fromTheme(QString("list-add")),
QApplication::translate("MainWidget", "Enable"),
this, SLOT(mainTabEnableProfile()));
toolBarActions[QString("mainStopAll")] = menu->addAction(QIcon::fromTheme(QString("process-stop")),
QApplication::translate("MainWidget", "Stop all"),
this, SLOT(mainTabStopAllProfiles()));
actionMenu->setMenu(menu);
actionToolBar->addWidget(actionMenu);
toolBarActions[QString("mainEdit")] = actionToolBar->addAction(QIcon::fromTheme(QString("document-edit")),
QApplication::translate("MainWidget", "Edit"),
this, SLOT(mainTabEditProfile()));
toolBarActions[QString("mainRemove")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-delete")),
QApplication::translate("MainWidget", "Remove"),
this, SLOT(mainTabRemoveProfile()));
actionMenu->setDefaultAction(toolBarActions[QString("mainStart")]);
ui->verticalLayout->insertWidget(0, actionToolBar);
} }
@ -490,13 +459,5 @@ void MainWidget::deleteObjects()
if (netctlProfile != nullptr) delete netctlProfile; if (netctlProfile != nullptr) delete netctlProfile;
if (netctlAutoWin != nullptr) delete netctlAutoWin; if (netctlAutoWin != nullptr) delete netctlAutoWin;
if (actionMenu != nullptr) {
actionMenu->menu()->clear();
delete actionMenu;
}
if (actionToolBar != nullptr) {
actionToolBar->clear();
delete actionToolBar;
}
if (ui != nullptr) delete ui; if (ui != nullptr) delete ui;
} }

View File

@ -18,10 +18,8 @@
#ifndef MAINWIDGET_H #ifndef MAINWIDGET_H
#define MAINWIDGET_H #define MAINWIDGET_H
#include <QMainWindow>
#include <QTableWidgetItem> #include <QTableWidgetItem>
#include <QToolBar>
#include <QToolButton>
#include <QWidget>
#include <netctlgui/netctlgui.h> #include <netctlgui/netctlgui.h>
@ -33,7 +31,7 @@ namespace Ui {
class MainWidget; class MainWidget;
} }
class MainWidget : public QWidget class MainWidget : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -44,6 +42,7 @@ public:
~MainWidget(); ~MainWidget();
public slots: public slots:
bool mainTabSelectProfileSlot(const QString profile);
void showNetctlAutoWindow(); void showNetctlAutoWindow();
void update(); void update();
@ -55,7 +54,6 @@ private slots:
void mainTabContextualMenu(const QPoint &pos); void mainTabContextualMenu(const QPoint &pos);
void mainTabEditProfile(); void mainTabEditProfile();
void mainTabEnableProfile(); void mainTabEnableProfile();
QStringList mainTabGetActiveProfiles();
void mainTabRemoveProfile(); void mainTabRemoveProfile();
void mainTabRestartProfile(); void mainTabRestartProfile();
void mainTabStartProfile(); void mainTabStartProfile();
@ -64,9 +62,6 @@ private slots:
private: private:
// ui // ui
QMap<QString, QAction *> toolBarActions;
QToolButton *actionMenu = nullptr;
QToolBar *actionToolBar = nullptr;
MainWindow *mainWindow = nullptr; MainWindow *mainWindow = nullptr;
Ui::MainWidget *ui = nullptr; Ui::MainWidget *ui = nullptr;
NetctlAutoWindow *netctlAutoWin = nullptr; NetctlAutoWindow *netctlAutoWin = nullptr;
@ -75,7 +70,6 @@ private:
NetctlProfile *netctlProfile = nullptr; NetctlProfile *netctlProfile = nullptr;
void createActions(); void createActions();
void createObjects(); void createObjects();
void createToolBars();
void deleteObjects(); void deleteObjects();
QString configPath; QString configPath;
bool debug = false; bool debug = false;

View File

@ -1,22 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>MainWidget</class> <class>MainWidget</class>
<widget class="QWidget" name="MainWidget"> <widget class="QMainWindow" name="MainWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>516</width> <width>515</width>
<height>477</height> <height>477</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <widget class="QWidget" name="centralwidget">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QWidget" name="widget_netctlAuto" native="true"> <widget class="QWidget" name="widget_netctlAuto" native="true">
<layout class="QHBoxLayout" name="layout_netctlAuto"> <layout class="QHBoxLayout" name="layout_netctlAuto">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_netctlAuto"> <widget class="QLabel" name="label_netctlAuto">
<property name="sizePolicy"> <property name="sizePolicy">
@ -88,6 +92,139 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>Main actions toolbar</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonFollowStyle</enum>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionNetctl_auto"/>
<addaction name="actionRefresh"/>
<addaction name="separator"/>
<addaction name="actionStart"/>
<addaction name="actionStop_all"/>
<addaction name="separator"/>
<addaction name="actionEdit"/>
<addaction name="actionRemove"/>
</widget>
<action name="actionNetctl_auto">
<property name="text">
<string>netctl-auto</string>
</property>
<property name="toolTip">
<string>Show netctl-auto window</string>
</property>
</action>
<action name="actionRefresh">
<property name="icon">
<iconset theme="view-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Refresh</string>
</property>
<property name="toolTip">
<string>Refresh table</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
</action>
<action name="actionStart">
<property name="icon">
<iconset theme="system-run">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="toolTip">
<string>Start or stop selected profile</string>
</property>
</action>
<action name="actionSwitch">
<property name="text">
<string>Switch</string>
</property>
<property name="toolTip">
<string>Switch to selected profile</string>
</property>
</action>
<action name="actionRestart">
<property name="icon">
<iconset theme="view-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Restart</string>
</property>
<property name="toolTip">
<string>Restart selected profile</string>
</property>
</action>
<action name="actionEnable">
<property name="icon">
<iconset theme="list-add">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Enable</string>
</property>
<property name="toolTip">
<string>Enable or disable selected profile</string>
</property>
</action>
<action name="actionStop_all">
<property name="icon">
<iconset theme="process-stop">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Stop all</string>
</property>
<property name="toolTip">
<string>Stop all profiles</string>
</property>
</action>
<action name="actionEdit">
<property name="icon">
<iconset theme="document-edit">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Edit</string>
</property>
<property name="toolTip">
<string>Edit selected profile</string>
</property>
</action>
<action name="actionRemove">
<property name="icon">
<iconset theme="edit-delete">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Remove</string>
</property>
<property name="toolTip">
<string>Remove selected profile</string>
</property>
</action>
</widget>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -25,6 +25,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QProcessEnvironment>
#include <QTranslator> #include <QTranslator>
#include <QUrl> #include <QUrl>
@ -73,22 +74,15 @@ MainWindow::MainWindow(QWidget *parent,
updateConfiguration(args); updateConfiguration(args);
// main actions // 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++) if (!wifiMenuWidget->wifiTabSelectEssidSlot(args[QString("essid")].toString()))
// if (ui->tableWidget_wifi->item(i, 0)->text() == args[QString("essid")].toString()) ErrorWindow::showWindow(18, QString(PDEBUG), debug);
// ui->tableWidget_wifi->setCurrentCell(i, 0); } else if (args[QString("open")].toString() != QString("PROFILE")) {
// if (ui->tableWidget_wifi->currentItem() == nullptr) newProfileWidget->profileTabOpenProfileSlot(args[QString("open")].toString());
// ErrorWindow::showWindow(18, QString(PDEBUG), debug); } else if (args[QString("select")].toString() != QString("PROFILE")) {
// } else if (args[QString("open")].toString() != QString("PROFILE")) { if (!mainWidget->mainTabSelectProfileSlot(args[QString("select")].toString()))
// ui->comboBox_profile->addItem(args[QString("open")].toString()); ErrorWindow::showWindow(17, QString(PDEBUG), debug);
// ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count()-1); }
// } else if (args[QString("select")].toString() != QString("PROFILE")) {
// for (int i=0; i<ui->tableWidget_main->rowCount(); i++)
// if (ui->tableWidget_main->item(i, 0)->text() == args[QString("select")].toString())
// ui->tableWidget_main->setCurrentCell(i, 0);
// if (ui->tableWidget_main->currentItem() == nullptr)
// ErrorWindow::showWindow(17, QString(PDEBUG), debug);
// }
// show windows // show windows
if (args[QString("about")].toBool()) if (args[QString("about")].toBool())
@ -341,7 +335,7 @@ void MainWindow::openProfileSlot(const QString profile)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
newProfileWidget->profileTabOpenProfile(profile); newProfileWidget->profileTabOpenProfileSlot(profile);
} }
@ -687,8 +681,8 @@ void MainWindow::createActions()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
connect(ui->actionConnect_to_profile, SIGNAL(triggered()), this, SLOT(setMainTab())); connect(ui->actionNetctl, SIGNAL(triggered()), this, SLOT(setMainTab()));
connect(ui->actionCreate_a_new_profile, SIGNAL(triggered()), this, SLOT(setProfileTab())); connect(ui->actionProfiles, SIGNAL(triggered()), this, SLOT(setProfileTab()));
connect(ui->actionWiFi_menu, SIGNAL(triggered()), this, SLOT(setWifiTab())); connect(ui->actionWiFi_menu, SIGNAL(triggered()), this, SLOT(setWifiTab()));
connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(setTab(int))); connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(setTab(int)));
connect(this, SIGNAL(needToBeConfigured()), this, SLOT(showSettingsWindow())); connect(this, SIGNAL(needToBeConfigured()), this, SLOT(showSettingsWindow()));
@ -775,9 +769,9 @@ QMap<QString, QString> MainWindow::parseOptions(const QString options)
QMap<QString, QString> settings; QMap<QString, QString> settings;
for (int i=0; i<options.split(QChar(',')).count(); i++) { for (int i=0; i<options.split(QChar(',')).count(); i++) {
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2) continue; QStringList option = options.split(QChar(','))[i].split(QChar('='));
settings[options.split(QChar(','))[i].split(QChar('='))[0]] = if (option.count() != 2) continue;
options.split(QChar(','))[i].split(QChar('='))[1]; settings[option[0]] = option[1];
} }
for (int i=0; i<settings.keys().count(); i++) for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << QString("%1=%2").arg(settings.keys()[i]).arg(settings[settings.keys()[i]]); if (debug) qDebug() << PDEBUG << ":" << QString("%1=%2").arg(settings.keys()[i]).arg(settings[settings.keys()[i]]);

View File

@ -24,13 +24,25 @@
</sizepolicy> </sizepolicy>
</property> </property>
<widget class="QWidget" name="page_main"> <widget class="QWidget" name="page_main">
<layout class="QVBoxLayout" name="layout_main"/> <layout class="QVBoxLayout" name="layout_main">
<property name="margin">
<number>0</number>
</property>
</layout>
</widget> </widget>
<widget class="QWidget" name="page_new"> <widget class="QWidget" name="page_new">
<layout class="QVBoxLayout" name="layout_new"/> <layout class="QVBoxLayout" name="layout_new">
<property name="margin">
<number>0</number>
</property>
</layout>
</widget> </widget>
<widget class="QWidget" name="page_wifi"> <widget class="QWidget" name="page_wifi">
<layout class="QVBoxLayout" name="layout_wifi"/> <layout class="QVBoxLayout" name="layout_wifi">
<property name="margin">
<number>0</number>
</property>
</layout>
</widget> </widget>
</widget> </widget>
</item> </item>
@ -64,8 +76,8 @@
<addaction name="menuMenu"/> <addaction name="menuMenu"/>
</widget> </widget>
<widget class="QToolBar" name="toolBar"> <widget class="QToolBar" name="toolBar">
<property name="movable"> <property name="windowTitle">
<bool>false</bool> <string>Toolbar</string>
</property> </property>
<property name="toolButtonStyle"> <property name="toolButtonStyle">
<enum>Qt::ToolButtonFollowStyle</enum> <enum>Qt::ToolButtonFollowStyle</enum>
@ -76,8 +88,8 @@
<attribute name="toolBarBreak"> <attribute name="toolBarBreak">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<addaction name="actionConnect_to_profile"/> <addaction name="actionNetctl"/>
<addaction name="actionCreate_a_new_profile"/> <addaction name="actionProfiles"/>
<addaction name="actionWiFi_menu"/> <addaction name="actionWiFi_menu"/>
</widget> </widget>
<action name="actionSecurity"> <action name="actionSecurity">
@ -89,16 +101,25 @@
<property name="text"> <property name="text">
<string>Security</string> <string>Security</string>
</property> </property>
<property name="toolTip">
<string>Show security notes</string>
</property>
</action> </action>
<action name="actionDBus_API"> <action name="actionDBus_API">
<property name="text"> <property name="text">
<string>DBus API</string> <string>DBus API</string>
</property> </property>
<property name="toolTip">
<string>Show DBus API</string>
</property>
</action> </action>
<action name="actionLibrary"> <action name="actionLibrary">
<property name="text"> <property name="text">
<string>Library</string> <string>Library</string>
</property> </property>
<property name="toolTip">
<string>Show library docs</string>
</property>
</action> </action>
<action name="actionReport_a_bug"> <action name="actionReport_a_bug">
<property name="icon"> <property name="icon">
@ -119,6 +140,9 @@
<property name="text"> <property name="text">
<string>About</string> <string>About</string>
</property> </property>
<property name="toolTip">
<string>About this application</string>
</property>
</action> </action>
<action name="actionQuit"> <action name="actionQuit">
<property name="icon"> <property name="icon">
@ -146,32 +170,37 @@
<string>Ctrl+S</string> <string>Ctrl+S</string>
</property> </property>
</action> </action>
<action name="actionConnect_to_profile"> <action name="actionNetctl">
<property name="icon"> <property name="icon">
<iconset resource="../../resources/resources.qrc"> <iconset resource="../../resources/resources.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset> <normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Connect to profile</string> <string>netctl control</string>
</property>
<property name="shortcut">
<string>Ctrl+P</string>
</property>
</action>
<action name="actionCreate_a_new_profile">
<property name="icon">
<iconset theme="document-new"/>
</property>
<property name="text">
<string>Create a new profile</string>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Create a new profile</string> <string>netctl control</string>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+N</string> <string>Ctrl+N</string>
</property> </property>
</action> </action>
<action name="actionProfiles">
<property name="icon">
<iconset theme="document-new">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Profiles</string>
</property>
<property name="toolTip">
<string>Profiles</string>
</property>
<property name="shortcut">
<string>Ctrl+P</string>
</property>
</action>
<action name="actionWiFi_menu"> <action name="actionWiFi_menu">
<property name="icon"> <property name="icon">
<iconset resource="../../resources/resources.qrc"> <iconset resource="../../resources/resources.qrc">

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>445</width> <width>445</width>
<height>350</height> <height>314</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_mobile"> <widget class="QDockWidget" name="dockWidget_mobile">
<property name="features"> <property name="features">
@ -24,6 +24,9 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_mobile"> <widget class="QWidget" name="dockWidgetContents_mobile">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_username"> <layout class="QHBoxLayout" name="layout_username">
<item> <item>
@ -247,6 +250,9 @@
<item> <item>
<widget class="QWidget" name="widget_mobileAdvanced" native="true"> <widget class="QWidget" name="widget_mobileAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_route"> <layout class="QHBoxLayout" name="layout_route">
<item> <item>

View File

@ -169,23 +169,19 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
enabled = netctlCommand->isNetctlAutoEnabled(); enabled = netctlCommand->isNetctlAutoEnabled();
running = netctlCommand->isNetctlAutoRunning(); running = netctlCommand->isNetctlAutoRunning();
} }
ui->actionDisableAll->setEnabled(running);
ui->actionEnableAll->setEnabled(running);
ui->actionRestartService->setEnabled(running);
if (enabled) if (enabled)
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service")); ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
else else
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service")); ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
ui->actionEnableService->setVisible(true);
if (running) { if (running) {
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running")); ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service")); ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
ui->actionDisableAll->setVisible(true);
ui->actionEnableAll->setVisible(true);
ui->actionRestartService->setVisible(true);
} else { } else {
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running")); ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running"));
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service")); ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
ui->actionDisableAll->setVisible(false);
ui->actionEnableAll->setVisible(false);
ui->actionRestartService->setVisible(false);
netctlAutoRefreshButtons(nullptr, nullptr); netctlAutoRefreshButtons(nullptr, nullptr);
return; return;
} }
@ -441,15 +437,10 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl
Q_UNUSED(previous); Q_UNUSED(previous);
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (current == nullptr) { bool selected = (current != nullptr);
// menu ui->actionEnable->setEnabled(selected);
ui->actionEnable->setEnabled(false); ui->actionSwitch->setEnabled(selected && ui->tableWidget->item(current->row(), 2)->text().isEmpty());
ui->actionSwitch->setEnabled(false); if (selected && !ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
return;
}
ui->actionSwitch->setEnabled(ui->tableWidget->item(current->row(), 2)->text().isEmpty());
ui->actionEnable->setEnabled(true);
if (!ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable")); ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
ui->actionEnable->setIcon(QIcon::fromTheme("list-add")); ui->actionEnable->setIcon(QIcon::fromTheme("list-add"));
} else { } else {

View File

@ -66,8 +66,8 @@
</widget> </widget>
<widget class="QStatusBar" name="statusBar"/> <widget class="QStatusBar" name="statusBar"/>
<widget class="QToolBar" name="toolBar"> <widget class="QToolBar" name="toolBar">
<property name="movable"> <property name="windowTitle">
<bool>false</bool> <string>Toolbar</string>
</property> </property>
<property name="toolButtonStyle"> <property name="toolButtonStyle">
<enum>Qt::ToolButtonFollowStyle</enum> <enum>Qt::ToolButtonFollowStyle</enum>
@ -79,6 +79,7 @@
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<addaction name="actionRefresh"/> <addaction name="actionRefresh"/>
<addaction name="separator"/>
<addaction name="actionSwitch"/> <addaction name="actionSwitch"/>
<addaction name="actionEnable"/> <addaction name="actionEnable"/>
</widget> </widget>
@ -143,6 +144,9 @@
<property name="text"> <property name="text">
<string>Start service</string> <string>Start service</string>
</property> </property>
<property name="toolTip">
<string>Start or stop service</string>
</property>
</action> </action>
<action name="actionRestartService"> <action name="actionRestartService">
<property name="text"> <property name="text">
@ -153,6 +157,9 @@
<property name="text"> <property name="text">
<string>Enable service</string> <string>Enable service</string>
</property> </property>
<property name="toolTip">
<string>Enable or disable service</string>
</property>
</action> </action>
<action name="actionRefresh"> <action name="actionRefresh">
<property name="icon"> <property name="icon">
@ -163,6 +170,9 @@
<property name="text"> <property name="text">
<string>Refresh</string> <string>Refresh</string>
</property> </property>
<property name="toolTip">
<string>Refresh table</string>
</property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+R</string> <string>Ctrl+R</string>
</property> </property>
@ -176,6 +186,9 @@
<property name="text"> <property name="text">
<string>Enable</string> <string>Enable</string>
</property> </property>
<property name="toolTip">
<string>Enable or disable profile</string>
</property>
</action> </action>
<action name="actionSwitch"> <action name="actionSwitch">
<property name="icon"> <property name="icon">
@ -186,6 +199,9 @@
<property name="text"> <property name="text">
<string>Switch</string> <string>Switch</string>
</property> </property>
<property name="toolTip">
<string>Switch to profile</string>
</property>
</action> </action>
</widget> </widget>
<resources/> <resources/>

View File

@ -42,7 +42,7 @@
NewProfileWidget::NewProfileWidget(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd) NewProfileWidget::NewProfileWidget(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd)
: QWidget(parent), : QMainWindow(parent),
debug(debugCmd), debug(debugCmd),
configuration(settings) configuration(settings)
{ {
@ -50,7 +50,6 @@ NewProfileWidget::NewProfileWidget(QWidget *parent, const QMap<QString, QString>
useHelper = (configuration[QString("USE_HELPER")] == QString("true")); useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
createObjects(); createObjects();
createToolBars();
createActions(); createActions();
} }
@ -63,7 +62,7 @@ NewProfileWidget::~NewProfileWidget()
} }
void NewProfileWidget::profileTabOpenProfile(const QString profile) void NewProfileWidget::profileTabOpenProfileSlot(const QString profile)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -84,12 +83,11 @@ void NewProfileWidget::update()
void NewProfileWidget::updateMenuProfile() void NewProfileWidget::updateMenuProfile()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
actionMenu->setDefaultAction(toolBarActions[QString("profileSave")]);
bool selected = !ui->comboBox_profile->currentText().isEmpty(); bool selected = !ui->comboBox_profile->currentText().isEmpty();
toolBarActions[QString("profileLoad")]->setVisible(selected); ui->actionLoad->setEnabled(selected);
toolBarActions[QString("profileRemove")]->setVisible(selected); ui->actionRemove->setEnabled(selected);
toolBarActions[QString("profileSave")]->setVisible(selected); ui->actionSave->setEnabled(selected);
} }
@ -427,6 +425,11 @@ void NewProfileWidget::createActions()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
// menu actions
connect(ui->actionClear, SIGNAL(triggered(bool)), this, SLOT(profileTabClear()));
connect(ui->actionLoad, SIGNAL(triggered(bool)), this, SLOT(profileTabLoadProfile()));
connect(ui->actionRemove, SIGNAL(triggered(bool)), this, SLOT(profileTabRemoveProfile()));
connect(ui->actionSave, SIGNAL(triggered(bool)), this, SLOT(profileTabCreateProfile()));
// main tab events // main tab events
connect(ui->comboBox_profile, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabLoadProfile())); connect(ui->comboBox_profile, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabLoadProfile()));
connect(ui->comboBox_profile, SIGNAL(editTextChanged(QString)), this, SLOT(updateMenuProfile())); connect(ui->comboBox_profile, SIGNAL(editTextChanged(QString)), this, SLOT(updateMenuProfile()));
@ -471,38 +474,6 @@ void NewProfileWidget::createObjects()
} }
void NewProfileWidget::createToolBars()
{
if (debug) qDebug() << PDEBUG;
actionToolBar = new QToolBar(this);
actionToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
toolBarActions[QString("profileClear")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-clear")),
QApplication::translate("NewProfileWidget", "Clear"),
this, SLOT(profileTabClear()));
actionMenu = new QToolButton(this);
actionMenu->setPopupMode(QToolButton::DelayedPopup);
actionMenu->setToolButtonStyle(Qt::ToolButtonFollowStyle);
QMenu *menu = new QMenu(actionMenu);
toolBarActions[QString("profileLoad")] = menu->addAction(QIcon::fromTheme(QString("document-open")),
QApplication::translate("NewProfileWidget", "Load"),
this, SLOT(profileTabLoadProfile()));
toolBarActions[QString("profileSave")] = menu->addAction(QIcon::fromTheme(QString("document-save")),
QApplication::translate("NewProfileWidget", "Save"),
this, SLOT(profileTabCreateProfile()));
actionMenu->setMenu(menu);
actionToolBar->addWidget(actionMenu);
toolBarActions[QString("profileRemove")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-delete")),
QApplication::translate("NewProfileWidget", "Remove"),
this, SLOT(profileTabRemoveProfile()));
actionMenu->setDefaultAction(toolBarActions[QString("profileSave")]);
ui->verticalLayout->insertWidget(0, actionToolBar);
}
void NewProfileWidget::deleteObjects() void NewProfileWidget::deleteObjects()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -522,13 +493,5 @@ void NewProfileWidget::deleteObjects()
if (vlanWid != nullptr) delete vlanWid; if (vlanWid != nullptr) delete vlanWid;
if (wirelessWid != nullptr) delete wirelessWid; if (wirelessWid != nullptr) delete wirelessWid;
if (actionMenu != nullptr) {
actionMenu->menu()->clear();
delete actionMenu;
}
if (actionToolBar != nullptr) {
actionToolBar->clear();
delete actionToolBar;
}
if (ui != nullptr) delete ui; if (ui != nullptr) delete ui;
} }

View File

@ -18,9 +18,7 @@
#ifndef NEWPROFILEWIDGET_H #ifndef NEWPROFILEWIDGET_H
#define NEWPROFILEWIDGET_H #define NEWPROFILEWIDGET_H
#include <QToolBar> #include <QMainWindow>
#include <QToolButton>
#include <QWidget>
#include <netctlgui/netctlgui.h> #include <netctlgui/netctlgui.h>
@ -42,7 +40,7 @@ namespace Ui {
class NewProfileWidget; class NewProfileWidget;
} }
class NewProfileWidget : public QWidget class NewProfileWidget : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -53,7 +51,7 @@ public:
~NewProfileWidget(); ~NewProfileWidget();
public slots: public slots:
void profileTabOpenProfile(const QString profile); void profileTabOpenProfileSlot(const QString profile);
void update(); void update();
private slots: private slots:
@ -69,9 +67,6 @@ private slots:
private: private:
// ui // ui
QMap<QString, QAction *> toolBarActions;
QToolButton *actionMenu = nullptr;
QToolBar *actionToolBar = nullptr;
MainWindow *mainWindow; MainWindow *mainWindow;
Ui::NewProfileWidget *ui = nullptr; Ui::NewProfileWidget *ui = nullptr;
BridgeWidget *bridgeWid = nullptr; BridgeWidget *bridgeWid = nullptr;
@ -90,7 +85,6 @@ private:
NetctlProfile *netctlProfile = nullptr; NetctlProfile *netctlProfile = nullptr;
void createActions(); void createActions();
void createObjects(); void createObjects();
void createToolBars();
void deleteObjects(); void deleteObjects();
bool debug = false; bool debug = false;
bool useHelper = true; bool useHelper = true;

View File

@ -1,19 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>NewProfileWidget</class> <class>NewProfileWidget</class>
<widget class="QWidget" name="NewProfileWidget"> <widget class="QMainWindow" name="NewProfileWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>473</width> <width>472</width>
<height>410</height> <height>409</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <widget class="QWidget" name="centralwidget">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_profile"> <layout class="QHBoxLayout" name="layout_profile">
<item> <item>
@ -52,6 +53,9 @@
</item> </item>
<item> <item>
<widget class="QScrollArea" name="scrollArea"> <widget class="QScrollArea" name="scrollArea">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -60,8 +64,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>457</width> <width>461</width>
<height>363</height> <height>342</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -70,12 +74,92 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QVBoxLayout" name="scrollArea_layout"/> <layout class="QVBoxLayout" name="scrollArea_layout">
<property name="margin">
<number>0</number>
</property>
</layout>
</widget> </widget>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>New profile toolbar</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonFollowStyle</enum>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionClear"/>
<addaction name="separator"/>
<addaction name="actionLoad"/>
<addaction name="actionSave"/>
<addaction name="separator"/>
<addaction name="actionRemove"/>
</widget>
<action name="actionClear">
<property name="icon">
<iconset theme="edit-clear">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Clear</string>
</property>
<property name="toolTip">
<string>Clear data</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
</action>
<action name="actionLoad">
<property name="icon">
<iconset theme="document-open">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Load</string>
</property>
<property name="toolTip">
<string>Load selected profile</string>
</property>
</action>
<action name="actionSave">
<property name="icon">
<iconset theme="document-save">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Save</string>
</property>
<property name="toolTip">
<string>Save selected profile</string>
</property>
</action>
<action name="actionRemove">
<property name="icon">
<iconset theme="edit-delete">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Remove</string>
</property>
<property name="toolTip">
<string>Remove selected profile</string>
</property>
</action>
</widget>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -16,9 +16,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<spacer name="spacer2"> <spacer name="spacer2">

View File

@ -10,9 +10,6 @@
<height>561</height> <height>561</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QDockWidget" name="dockWidget_pppoe"> <widget class="QDockWidget" name="dockWidget_pppoe">

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>411</width> <width>411</width>
<height>146</height> <height>108</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_tunnel"> <widget class="QDockWidget" name="dockWidget_tunnel">
<property name="features"> <property name="features">
@ -24,6 +24,9 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_tunnel"> <widget class="QWidget" name="dockWidgetContents_tunnel">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_mode"> <layout class="QHBoxLayout" name="layout_mode">
<item> <item>

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>424</width> <width>424</width>
<height>146</height> <height>108</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_tuntap"> <widget class="QDockWidget" name="dockWidget_tuntap">
<property name="features"> <property name="features">
@ -24,6 +24,9 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_tuntap"> <widget class="QWidget" name="dockWidgetContents_tuntap">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_mode"> <layout class="QHBoxLayout" name="layout_mode">
<item> <item>

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>393</width> <width>393</width>
<height>81</height> <height>46</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_vlan"> <widget class="QDockWidget" name="dockWidget_vlan">
<property name="features"> <property name="features">
@ -24,6 +24,9 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_vlan"> <widget class="QWidget" name="dockWidgetContents_vlan">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_vlan"> <layout class="QHBoxLayout" name="layout_vlan">
<item> <item>

View File

@ -31,7 +31,7 @@
WiFiMenuWidget::WiFiMenuWidget(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd) WiFiMenuWidget::WiFiMenuWidget(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd)
: QWidget(parent), : QMainWindow(parent),
debug(debugCmd), debug(debugCmd),
configuration(settings) configuration(settings)
{ {
@ -39,7 +39,6 @@ WiFiMenuWidget::WiFiMenuWidget(QWidget *parent, const QMap<QString, QString> set
useHelper = (configuration[QString("USE_HELPER")] == QString("true")); useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
createObjects(); createObjects();
createToolBars();
createActions(); createActions();
} }
@ -61,6 +60,19 @@ void WiFiMenuWidget::update()
} }
bool WiFiMenuWidget::wifiTabSelectEssidSlot(const QString essid)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Essid" << essid;
for (int i=0; i<ui->tableWidget_wifi->rowCount(); i++) {
if (ui->tableWidget_wifi->item(i, 0)->text() != essid) continue;
ui->tableWidget_wifi->setCurrentCell(i, 0);
}
return (ui->tableWidget_wifi->currentItem() != nullptr);
}
void WiFiMenuWidget::connectToUnknownEssid(const QString passwd) void WiFiMenuWidget::connectToUnknownEssid(const QString passwd)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -155,13 +167,13 @@ void WiFiMenuWidget::updateMenuWifi()
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
bool selected = (ui->tableWidget_wifi->currentItem() != nullptr); bool selected = (ui->tableWidget_wifi->currentItem() != nullptr);
toolBarActions[QString("wifiStart")]->setVisible(selected); ui->actionStart->setEnabled(selected);
if (selected && ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 5)->text().isEmpty()) { if (selected && ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 5)->text().isEmpty()) {
toolBarActions[QString("wifiStart")]->setText(QApplication::translate("WiFiMenuWidget", "Start")); ui->actionStart->setText(QApplication::translate("WiFiMenuWidget", "Start"));
toolBarActions[QString("wifiStart")]->setIcon(QIcon::fromTheme("system-run")); ui->actionStart->setIcon(QIcon::fromTheme("system-run"));
} else { } else {
toolBarActions[QString("wifiStart")]->setText(QApplication::translate("WiFiMenuWidget", "Stop")); ui->actionStart->setText(QApplication::translate("WiFiMenuWidget", "Stop"));
toolBarActions[QString("wifiStart")]->setIcon(QIcon::fromTheme("process-stop")); ui->actionStart->setIcon(QIcon::fromTheme("process-stop"));
} }
} }
@ -394,6 +406,9 @@ void WiFiMenuWidget::createActions()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
// menu actions
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(updateWifiTab()));
connect(ui->actionStart, SIGNAL(triggered(bool)), this, SLOT(wifiTabStart()));
// wifi tab events // wifi tab events
connect(ui->tableWidget_wifi, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(wifiTabStart())); connect(ui->tableWidget_wifi, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(wifiTabStart()));
connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
@ -418,23 +433,6 @@ void WiFiMenuWidget::createObjects()
} }
void WiFiMenuWidget::createToolBars()
{
if (debug) qDebug() << PDEBUG;
actionToolBar = new QToolBar(this);
actionToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
toolBarActions[QString("wifiRefresh")] = actionToolBar->addAction(QIcon::fromTheme(QString("view-refresh")),
QApplication::translate("WiFiMenuWidget", "Refresh"),
this, SLOT(updateWifiTab()));
toolBarActions[QString("wifiStart")] = actionToolBar->addAction(QIcon::fromTheme(QString("system-run")),
QApplication::translate("WiFiMenuWidget", "Start"),
this, SLOT(wifiTabStart()));
ui->verticalLayout->insertWidget(0, actionToolBar);
}
void WiFiMenuWidget::deleteObjects() void WiFiMenuWidget::deleteObjects()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -443,9 +441,5 @@ void WiFiMenuWidget::deleteObjects()
if (netctlProfile != nullptr) delete netctlProfile; if (netctlProfile != nullptr) delete netctlProfile;
if (wpaCommand != nullptr) delete wpaCommand; if (wpaCommand != nullptr) delete wpaCommand;
if (actionToolBar != nullptr) {
actionToolBar->clear();
delete actionToolBar;
}
if (ui != nullptr) delete ui; if (ui != nullptr) delete ui;
} }

View File

@ -19,9 +19,7 @@
#define WIFIMENUWIDGET_H #define WIFIMENUWIDGET_H
#include <QApplication> #include <QApplication>
#include <QToolBar> #include <QMainWindow>
#include <QToolButton>
#include <QWidget>
#include <netctlgui/netctlgui.h> #include <netctlgui/netctlgui.h>
@ -33,7 +31,7 @@ namespace Ui {
class WiFiMenuWidget; class WiFiMenuWidget;
} }
class WiFiMenuWidget : public QWidget class WiFiMenuWidget : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -45,6 +43,7 @@ public:
public slots: public slots:
void update(); void update();
bool wifiTabSelectEssidSlot(const QString essid);
// 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);
@ -60,8 +59,6 @@ private slots:
private: private:
// ui // ui
QMap<QString, QAction *> toolBarActions;
QToolBar *actionToolBar = nullptr;
MainWindow *mainWindow = nullptr; MainWindow *mainWindow = nullptr;
Ui::WiFiMenuWidget *ui = nullptr; Ui::WiFiMenuWidget *ui = nullptr;
PasswdWidget *passwdWid = nullptr; PasswdWidget *passwdWid = nullptr;
@ -71,7 +68,6 @@ private:
WpaSup *wpaCommand = nullptr; WpaSup *wpaCommand = nullptr;
void createActions(); void createActions();
void createObjects(); void createObjects();
void createToolBars();
void deleteObjects(); void deleteObjects();
bool debug = false; bool debug = false;
bool hiddenNetwork; bool hiddenNetwork;

View File

@ -1,19 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>WiFiMenuWidget</class> <class>WiFiMenuWidget</class>
<widget class="QWidget" name="WiFiMenuWidget"> <widget class="QMainWindow" name="WiFiMenuWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>571</width> <width>570</width>
<height>467</height> <height>467</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <widget class="QWidget" name="centralwidget">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_wifi"> <widget class="QLabel" name="label_wifi">
<property name="text"> <property name="text">
@ -96,6 +97,53 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>WiFi menu toolbar</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonFollowStyle</enum>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionRefresh"/>
<addaction name="separator"/>
<addaction name="actionStart"/>
</widget>
<action name="actionRefresh">
<property name="icon">
<iconset theme="view-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Refresh</string>
</property>
<property name="toolTip">
<string>Refresh table</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
</action>
<action name="actionStart">
<property name="icon">
<iconset theme="system-run">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="toolTip">
<string>Connect or disconnect from selected ESSID</string>
</property>
</action>
</widget>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -50,6 +50,7 @@ void WirelessWidget::clear()
ui->listWidget_wpaConfigSection->setCurrentRow(-1); ui->listWidget_wpaConfigSection->setCurrentRow(-1);
ui->listWidget_wpaConfigSection->clear(); ui->listWidget_wpaConfigSection->clear();
ui->lineEdit_wpaConfig->setText(QString("/etc/wpa_supplicant/wpa_supplicant.conf")); ui->lineEdit_wpaConfig->setText(QString("/etc/wpa_supplicant/wpa_supplicant.conf"));
ui->checkBox_key->setCheckState(Qt::Unchecked);
ui->lineEdit_key->clear(); ui->lineEdit_key->clear();
ui->checkBox_hidden->setCheckState(Qt::Unchecked); ui->checkBox_hidden->setCheckState(Qt::Unchecked);
ui->checkBox_adhoc->setCheckState(Qt::Unchecked); ui->checkBox_adhoc->setCheckState(Qt::Unchecked);
@ -93,6 +94,7 @@ void WirelessWidget::createActions()
connect(ui->lineEdit_wpaConfigSection, SIGNAL(returnPressed()), this, SLOT(addOption())); connect(ui->lineEdit_wpaConfigSection, SIGNAL(returnPressed()), this, SLOT(addOption()));
connect(ui->pushButton_wpaConfig, SIGNAL(clicked(bool)), this, SLOT(selectWpaConfig())); connect(ui->pushButton_wpaConfig, SIGNAL(clicked(bool)), this, SLOT(selectWpaConfig()));
connect(ui->comboBox_security, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeSecurity(QString))); connect(ui->comboBox_security, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeSecurity(QString)));
connect(ui->checkBox_key, SIGNAL(stateChanged(int)), this, SLOT(setKeyEchoMode(int)));
} }
@ -157,6 +159,15 @@ void WirelessWidget::selectWpaConfig()
} }
void WirelessWidget::setKeyEchoMode(const int mode)
{
if (mode == 0)
ui->lineEdit_key->setEchoMode(QLineEdit::Password);
else
ui->lineEdit_key->setEchoMode(QLineEdit::Normal);
}
void WirelessWidget::showAdvanced() void WirelessWidget::showAdvanced()
{ {
if (ui->pushButton_wirelessAdvanced->isChecked()) { if (ui->pushButton_wirelessAdvanced->isChecked()) {

View File

@ -47,6 +47,7 @@ private slots:
void addFreq(); void addFreq();
void addOption(); void addOption();
void changeSecurity(const QString currentText); void changeSecurity(const QString currentText);
void setKeyEchoMode(const int mode);
void showAdvanced(); void showAdvanced();
void selectWpaConfig(); void selectWpaConfig();

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>584</width> <width>584</width>
<height>776</height> <height>697</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_wireless"> <widget class="QDockWidget" name="dockWidget_wireless">
<property name="features"> <property name="features">
@ -24,6 +24,9 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_wireless"> <widget class="QWidget" name="dockWidgetContents_wireless">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_security"> <layout class="QHBoxLayout" name="layout_security">
<item> <item>
@ -82,6 +85,9 @@
<item> <item>
<widget class="QWidget" name="widget_essid" native="true"> <widget class="QWidget" name="widget_essid" native="true">
<layout class="QHBoxLayout" name="layout_essid"> <layout class="QHBoxLayout" name="layout_essid">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_essid"> <widget class="QLabel" name="label_essid">
<property name="sizePolicy"> <property name="sizePolicy">
@ -117,6 +123,9 @@
<item> <item>
<widget class="QWidget" name="widget_wpaConfigSection" native="true"> <widget class="QWidget" name="widget_wpaConfigSection" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_wpaConfigSection"> <layout class="QHBoxLayout" name="layout_wpaConfigSection">
<item> <item>
@ -179,6 +188,9 @@
<item> <item>
<widget class="QWidget" name="widget_wpaConfig" native="true"> <widget class="QWidget" name="widget_wpaConfig" native="true">
<layout class="QHBoxLayout" name="layout_wpaConfigFile"> <layout class="QHBoxLayout" name="layout_wpaConfigFile">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_wpaConfig"> <widget class="QLabel" name="label_wpaConfig">
<property name="sizePolicy"> <property name="sizePolicy">
@ -227,20 +239,23 @@
<item> <item>
<widget class="QWidget" name="widget_key" native="true"> <widget class="QWidget" name="widget_key" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="label_key"> <widget class="QCheckBox" name="checkBox_key">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch> <horstretch>1</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text"> <property name="text">
<string>Key</string> <string>Key</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -254,6 +269,9 @@
<property name="toolTip"> <property name="toolTip">
<string>The secret key to a WEP, or WPA encrypted network</string> <string>The secret key to a WEP, or WPA encrypted network</string>
</property> </property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -292,6 +310,9 @@
<item> <item>
<widget class="QWidget" name="widget_wirelessAdvanced" native="true"> <widget class="QWidget" name="widget_wirelessAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_exclude"> <layout class="QHBoxLayout" name="layout_exclude">
<item> <item>

View File

@ -70,7 +70,7 @@ public slots:
// wpaCommand // wpaCommand
QString CurrentWiFi(); QString CurrentWiFi();
QStringList VerboseWiFi(); QStringList VerboseWiFi();
QStringList WiFi(); Q_DECL_DEPRECATED QStringList WiFi();
private: private:
bool debug; bool debug;

View File

@ -21,6 +21,7 @@
#include <QDBusMessage> #include <QDBusMessage>
#include <QDir> #include <QDir>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QProcessEnvironment>
#include <QTranslator> #include <QTranslator>
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
@ -87,6 +88,9 @@ int main(int argc, char *argv[])
args[QString("error")] = true; args[QString("error")] = true;
} }
} }
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
if (!args[QString("debug")].toBool()) args[QString("debug")] = (debugEnv == QString("yes"));
if ((args[QString("debug")].toBool()) || if ((args[QString("debug")].toBool()) ||
(args[QString("help")].toBool()) || (args[QString("help")].toBool()) ||
(args[QString("info")].toBool()) || (args[QString("info")].toBool()) ||
@ -102,6 +106,13 @@ int main(int argc, char *argv[])
args[QString("session")] = true; args[QString("session")] = true;
} }
// check
QString robotEnv = environment.value(QString("SKYNET"), QString(""));
if (!robotEnv.isEmpty()) {
cout << "Sorry, this software is only for humans" << endl;
return 2;
}
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
QCoreApplication::setSetuidAllowed(true); QCoreApplication::setSetuidAllowed(true);
#endif #endif

View File

@ -49,7 +49,7 @@ public slots:
QString netctlActiveProfile(); QString netctlActiveProfile();
QStringList netctlProfileList(); QStringList netctlProfileList();
QStringList netctlVerboseProfileList(); QStringList netctlVerboseProfileList();
QStringList ProfileList(); Q_DECL_DEPRECATED QStringList ProfileList();
QStringList VerboseProfileList(); QStringList VerboseProfileList();
// netctlProfile // netctlProfile
QStringList Profile(const QString profile); QStringList Profile(const QString profile);