mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
rewrite netctlautowindow ui
This commit is contained in:
parent
de0c1f208d
commit
9993fee336
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QShortcut>
|
|
||||||
#include <QTableWidgetItem>
|
#include <QTableWidgetItem>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include <pdebug/pdebug.h>
|
#include <pdebug/pdebug.h>
|
||||||
|
|
||||||
#include "dbusoperation.h"
|
#include "dbusoperation.h"
|
||||||
#include "version.h"
|
// #include "version.h"
|
||||||
|
|
||||||
|
|
||||||
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const QMap<QString, QString> settings)
|
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const QMap<QString, QString> settings)
|
||||||
@ -32,15 +32,13 @@ NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const Q
|
|||||||
ui(new Ui::NetctlAutoWindow),
|
ui(new Ui::NetctlAutoWindow),
|
||||||
debug(debugCmd)
|
debug(debugCmd)
|
||||||
{
|
{
|
||||||
if (settings[QString("USE_HELPER")] == QString("true"))
|
useHelper = (settings[QString("USE_HELPER")] == QString("true"));
|
||||||
useHelper = true;
|
|
||||||
else
|
|
||||||
useHelper = false;
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->tableWidget->setColumnHidden(2, true);
|
ui->tableWidget->setColumnHidden(2, true);
|
||||||
ui->tableWidget->setColumnHidden(3, true);
|
ui->tableWidget->setColumnHidden(3, true);
|
||||||
netctlCommand = new Netctl(debug, settings);
|
netctlCommand = new Netctl(debug, settings);
|
||||||
|
|
||||||
|
createToolBars();
|
||||||
createActions();
|
createActions();
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Ready"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Ready"));
|
||||||
}
|
}
|
||||||
@ -50,8 +48,17 @@ NetctlAutoWindow::~NetctlAutoWindow()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
delete ui;
|
|
||||||
delete netctlCommand;
|
delete netctlCommand;
|
||||||
|
|
||||||
|
if (actionMenu != nullptr) {
|
||||||
|
actionMenu->menu()->clear();
|
||||||
|
delete actionMenu;
|
||||||
|
}
|
||||||
|
if (actionToolBar != nullptr) {
|
||||||
|
actionToolBar->clear();
|
||||||
|
delete actionToolBar;
|
||||||
|
}
|
||||||
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,12 +68,10 @@ QString NetctlAutoWindow::checkStatus(const bool statusBool, const bool nullFals
|
|||||||
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
|
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
|
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
|
||||||
|
|
||||||
if (statusBool)
|
if (statusBool) return QApplication::translate("NetctlAutoWindow", "yes");
|
||||||
return QApplication::translate("NetctlAutoWindow", "yes");
|
if (!nullFalse) return QApplication::translate("NetctlAutoWindow", "no");
|
||||||
if (nullFalse)
|
|
||||||
return QString("");
|
return QString("");
|
||||||
else
|
|
||||||
return QApplication::translate("NetctlAutoWindow", "no");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -78,8 +83,7 @@ void NetctlAutoWindow::createActions()
|
|||||||
connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close()));
|
connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close()));
|
||||||
connect(ui->actionDisableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoDisableAllProfiles()));
|
connect(ui->actionDisableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoDisableAllProfiles()));
|
||||||
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableProfile()));
|
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableProfile()));
|
||||||
connect(ui->actionEnableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableAllProfiles()));\
|
connect(ui->actionEnableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableAllProfiles()));
|
||||||
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(netctlAutoUpdateTable()));
|
|
||||||
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartProfile()));
|
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartProfile()));
|
||||||
// service
|
// service
|
||||||
connect(ui->actionEnableService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableService()));
|
connect(ui->actionEnableService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableService()));
|
||||||
@ -90,11 +94,32 @@ void NetctlAutoWindow::createActions()
|
|||||||
connect(ui->tableWidget, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(netctlAutoStartProfile()));
|
connect(ui->tableWidget, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(netctlAutoStartProfile()));
|
||||||
connect(ui->tableWidget, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(netctlAutoRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
|
connect(ui->tableWidget, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(netctlAutoRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
|
||||||
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(netctlAutoContextualMenu(QPoint)));
|
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(netctlAutoContextualMenu(QPoint)));
|
||||||
|
}
|
||||||
|
|
||||||
// buttons
|
|
||||||
connect(ui->pushButton_enable, SIGNAL(clicked(bool)), this, SLOT(netctlAutoEnableProfile()));
|
void NetctlAutoWindow::createToolBars()
|
||||||
connect(ui->pushButton_refresh, SIGNAL(clicked(bool)), this, SLOT(netctlAutoUpdateTable()));
|
{
|
||||||
connect(ui->pushButton_switch, SIGNAL(clicked(bool)), this, SLOT(netctlAutoStartProfile()));
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
actionToolBar = new QToolBar(this);
|
||||||
|
actionToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
|
||||||
|
toolBarActions[QString("refresh")] = actionToolBar->addAction(QIcon::fromTheme(QString("view-refresh")),
|
||||||
|
QApplication::translate("NetctlAutoWindow", "Refresh"),
|
||||||
|
this, SLOT(netctlAutoUpdateTable()));
|
||||||
|
|
||||||
|
actionMenu = new QToolButton(this);
|
||||||
|
actionMenu->setPopupMode(QToolButton::DelayedPopup);
|
||||||
|
actionMenu->setToolButtonStyle(Qt::ToolButtonFollowStyle);
|
||||||
|
QMenu *menu = new QMenu(actionMenu);
|
||||||
|
toolBarActions[QString("enable")] = menu->addAction(QApplication::translate("NetctlAutoWindow", "Enable"),
|
||||||
|
this, SLOT(netctlAutoEnableProfile()));
|
||||||
|
toolBarActions[QString("switch")] = menu->addAction(QIcon::fromTheme(QString("system-run")),
|
||||||
|
QApplication::translate("NetctlAutoWindow", "Switch"),
|
||||||
|
this, SLOT(netctlAutoStartProfile()));
|
||||||
|
actionMenu->setDefaultAction(toolBarActions[QString("switch")]);
|
||||||
|
actionMenu->setMenu(menu);
|
||||||
|
actionToolBar->addWidget(actionMenu);
|
||||||
|
ui->centralLayout->insertWidget(0, actionToolBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -112,8 +137,7 @@ void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (ui->tableWidget->currentItem() == 0)
|
if (ui->tableWidget->currentItem() == nullptr) return;
|
||||||
return;
|
|
||||||
// create menu
|
// create menu
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
|
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
|
||||||
@ -168,12 +192,20 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
|||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
bool running = false;
|
bool running = false;
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
enabled = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
QList<QVariant> responce = sendRequestToLib(QString("isNetctlAutoActive"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoEnabled"),
|
if (responce.isEmpty()) {
|
||||||
QList<QVariant>(), true, debug)[0].toBool();
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
running = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
useHelper = false;
|
||||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
|
return netctlAutoUpdateTable();
|
||||||
QList<QVariant>(), true, debug)[0].toBool();
|
}
|
||||||
|
enabled = responce[0].toBool();
|
||||||
|
responce = sendRequestToLib(QString("isNetctlAutoActive"), debug);
|
||||||
|
if (responce.isEmpty()) {
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
|
useHelper = false;
|
||||||
|
return netctlAutoUpdateTable();
|
||||||
|
}
|
||||||
|
running = responce[0].toBool();
|
||||||
} else {
|
} else {
|
||||||
enabled = netctlCommand->isNetctlAutoEnabled();
|
enabled = netctlCommand->isNetctlAutoEnabled();
|
||||||
running = netctlCommand->isNetctlAutoRunning();
|
running = netctlCommand->isNetctlAutoRunning();
|
||||||
@ -200,9 +232,7 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
|||||||
}
|
}
|
||||||
QList<netctlProfileInfo> profiles;
|
QList<netctlProfileInfo> profiles;
|
||||||
if (useHelper)
|
if (useHelper)
|
||||||
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
profiles = parseOutputNetctl(sendRequestToLib(QString("ProfileList"), debug));
|
||||||
DBUS_HELPER_INTERFACE, QString("ProfileList"),
|
|
||||||
QList<QVariant>(), true, debug), debug);
|
|
||||||
else
|
else
|
||||||
profiles = netctlCommand->getProfileListFromNetctlAuto();
|
profiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||||
|
|
||||||
@ -272,11 +302,15 @@ void NetctlAutoWindow::netctlAutoDisableAllProfiles()
|
|||||||
|
|
||||||
ui->tableWidget->setDisabled(true);
|
ui->tableWidget->setDisabled(true);
|
||||||
bool status = false;
|
bool status = false;
|
||||||
if (useHelper)
|
if (useHelper) {
|
||||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrl(QString("autoDisableAll"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("autoDisableAll"),
|
if (responce.isEmpty()) {
|
||||||
QList<QVariant>(), true, debug)[0].toBool();
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
else
|
useHelper = false;
|
||||||
|
return netctlAutoDisableAllProfiles();
|
||||||
|
}
|
||||||
|
status = responce[0].toBool();
|
||||||
|
} else
|
||||||
status = netctlCommand->autoDisableAllProfiles();
|
status = netctlCommand->autoDisableAllProfiles();
|
||||||
if (status)
|
if (status)
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||||
@ -299,9 +333,13 @@ void NetctlAutoWindow::netctlAutoEnableProfile()
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrlWithArgs(QString("autoEnable"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("autoEnable"),
|
if (responce.isEmpty()) {
|
||||||
args, true, debug)[0].toBool();
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
|
useHelper = false;
|
||||||
|
return netctlAutoEnableProfile();
|
||||||
|
}
|
||||||
|
status = responce[0].toBool();
|
||||||
} else
|
} else
|
||||||
status = netctlCommand->autoEnableProfile(profile);
|
status = netctlCommand->autoEnableProfile(profile);
|
||||||
if (status)
|
if (status)
|
||||||
@ -319,11 +357,15 @@ void NetctlAutoWindow::netctlAutoEnableAllProfiles()
|
|||||||
|
|
||||||
ui->tableWidget->setDisabled(true);
|
ui->tableWidget->setDisabled(true);
|
||||||
bool status = false;
|
bool status = false;
|
||||||
if (useHelper)
|
if (useHelper) {
|
||||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrl(QString("autoEnableAll"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("autoEnableAll"),
|
if (responce.isEmpty()) {
|
||||||
QList<QVariant>(), true, debug)[0].toBool();
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
else
|
useHelper = false;
|
||||||
|
return netctlAutoEnableAllProfiles();
|
||||||
|
}
|
||||||
|
status = responce[0].toBool();
|
||||||
|
} else
|
||||||
status = netctlCommand->autoEnableAllProfiles();
|
status = netctlCommand->autoEnableAllProfiles();
|
||||||
if (status)
|
if (status)
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||||
@ -338,7 +380,7 @@ void NetctlAutoWindow::netctlAutoStartProfile()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (ui->tableWidget->currentItem() == 0)
|
if (ui->tableWidget->currentItem() == nullptr)
|
||||||
return;
|
return;
|
||||||
ui->tableWidget->setDisabled(true);
|
ui->tableWidget->setDisabled(true);
|
||||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||||
@ -346,9 +388,13 @@ void NetctlAutoWindow::netctlAutoStartProfile()
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrlWithArgs(QString("autoStart"), args, debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("autoStart"),
|
if (responce.isEmpty()) {
|
||||||
args, true, debug)[0].toBool();
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
|
useHelper = false;
|
||||||
|
return netctlAutoStartProfile();
|
||||||
|
}
|
||||||
|
status = responce[0].toBool();
|
||||||
} else
|
} else
|
||||||
status = netctlCommand->autoStartProfile(profile);
|
status = netctlCommand->autoStartProfile(profile);
|
||||||
if (status)
|
if (status)
|
||||||
@ -365,11 +411,15 @@ void NetctlAutoWindow::netctlAutoEnableService()
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
if (useHelper)
|
if (useHelper) {
|
||||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrl(QString("autoServiceEnable"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("autoServiceEnable"),
|
if (responce.isEmpty()) {
|
||||||
QList<QVariant>(), true, debug)[0].toBool();
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
else
|
useHelper = false;
|
||||||
|
return netctlAutoEnableService();
|
||||||
|
}
|
||||||
|
status = responce[0].toBool();
|
||||||
|
} else
|
||||||
status = netctlCommand->autoEnableService();
|
status = netctlCommand->autoEnableService();
|
||||||
if (status)
|
if (status)
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||||
@ -385,11 +435,15 @@ void NetctlAutoWindow::netctlAutoRestartService()
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
if (useHelper)
|
if (useHelper) {
|
||||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrl(QString("autoServiceRestart"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("autoServiceRestart"),
|
if (responce.isEmpty()) {
|
||||||
QList<QVariant>(), true, debug)[0].toBool();
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
else
|
useHelper = false;
|
||||||
|
return netctlAutoRestartService();
|
||||||
|
}
|
||||||
|
status = responce[0].toBool();
|
||||||
|
} else
|
||||||
status = netctlCommand->autoRestartService();
|
status = netctlCommand->autoRestartService();
|
||||||
if (status)
|
if (status)
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||||
@ -405,11 +459,15 @@ void NetctlAutoWindow::netctlAutoStartService()
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
if (useHelper)
|
if (useHelper) {
|
||||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
QList<QVariant> responce = sendRequestToCtrl(QString("autoServiceStart"), debug);
|
||||||
DBUS_HELPER_INTERFACE, QString("autoServiceStart"),
|
if (responce.isEmpty()) {
|
||||||
QList<QVariant>(), true, debug)[0].toBool();
|
if (debug) qDebug() << PDEBUG << ":" << "Could not interact with helper, disable it";
|
||||||
else
|
useHelper = false;
|
||||||
|
return netctlAutoStartService();
|
||||||
|
}
|
||||||
|
status = responce[0].toBool();
|
||||||
|
} else
|
||||||
status = netctlCommand->autoStartService();
|
status = netctlCommand->autoStartService();
|
||||||
if (status)
|
if (status)
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||||
@ -425,10 +483,10 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl
|
|||||||
Q_UNUSED(previous);
|
Q_UNUSED(previous);
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (current == 0) {
|
if (current == nullptr) {
|
||||||
// buttons
|
// buttons
|
||||||
ui->pushButton_enable->setDisabled(true);
|
toolBarActions[QString("enable")]->setDisabled(true);
|
||||||
ui->pushButton_switch->setDisabled(true);
|
toolBarActions[QString("switch")]->setDisabled(true);
|
||||||
// menu
|
// menu
|
||||||
ui->actionEnable->setVisible(false);
|
ui->actionEnable->setVisible(false);
|
||||||
ui->actionSwitch->setVisible(false);
|
ui->actionSwitch->setVisible(false);
|
||||||
@ -436,29 +494,29 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl
|
|||||||
}
|
}
|
||||||
if (!ui->tableWidget->item(current->row(), 2)->text().isEmpty()) {
|
if (!ui->tableWidget->item(current->row(), 2)->text().isEmpty()) {
|
||||||
// buttons
|
// buttons
|
||||||
ui->pushButton_enable->setDisabled(true);
|
toolBarActions[QString("enable")]->setDisabled(true);
|
||||||
ui->pushButton_switch->setDisabled(true);
|
toolBarActions[QString("switch")]->setDisabled(true);
|
||||||
// menu
|
// menu
|
||||||
ui->actionEnable->setVisible(false);
|
ui->actionEnable->setVisible(false);
|
||||||
ui->actionSwitch->setVisible(false);
|
ui->actionSwitch->setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
// buttons
|
// buttons
|
||||||
ui->pushButton_enable->setEnabled(true);
|
toolBarActions[QString("enable")]->setEnabled(true);
|
||||||
ui->pushButton_switch->setEnabled(true);
|
toolBarActions[QString("switch")]->setEnabled(true);
|
||||||
// menu
|
// menu
|
||||||
ui->actionEnable->setVisible(true);
|
ui->actionEnable->setVisible(true);
|
||||||
ui->actionSwitch->setVisible(true);
|
ui->actionSwitch->setVisible(true);
|
||||||
if (!ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
|
if (!ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
|
||||||
// buttons
|
// buttons
|
||||||
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
toolBarActions[QString("enable")]->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||||
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-add"));
|
toolBarActions[QString("enable")]->setIcon(QIcon::fromTheme("edit-add"));
|
||||||
// menu
|
// menu
|
||||||
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
||||||
ui->actionEnable->setIcon(QIcon::fromTheme("edit-add"));
|
ui->actionEnable->setIcon(QIcon::fromTheme("edit-add"));
|
||||||
} else {
|
} else {
|
||||||
// buttons
|
// buttons
|
||||||
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
toolBarActions[QString("enable")]->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||||
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-delete"));
|
toolBarActions[QString("enable")]->setIcon(QIcon::fromTheme("edit-delete"));
|
||||||
// menu
|
// menu
|
||||||
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable profile"));
|
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable profile"));
|
||||||
ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete"));
|
ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete"));
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QTableWidgetItem>
|
#include <QTableWidgetItem>
|
||||||
|
#include <QToolBar>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
|
|
||||||
class Netctl;
|
class Netctl;
|
||||||
@ -58,12 +60,18 @@ private slots:
|
|||||||
void netctlAutoStartService();
|
void netctlAutoStartService();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Netctl *netctlCommand = nullptr;
|
// ui
|
||||||
|
QMap<QString, QAction *> toolBarActions;
|
||||||
|
QToolButton *actionMenu = nullptr;
|
||||||
|
QToolBar *actionToolBar = nullptr;
|
||||||
Ui::NetctlAutoWindow *ui = nullptr;
|
Ui::NetctlAutoWindow *ui = nullptr;
|
||||||
bool debug = false;
|
// backend
|
||||||
bool useHelper = true;
|
Netctl *netctlCommand = nullptr;
|
||||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||||
void createActions();
|
void createActions();
|
||||||
|
void createToolBars();
|
||||||
|
bool debug = false;
|
||||||
|
bool useHelper = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<string>netctl-auto</string>
|
<string>netctl-auto</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="centralLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_info">
|
<widget class="QLabel" name="label_info">
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
@ -62,65 +62,6 @@
|
|||||||
<column/>
|
<column/>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="layout_buttons">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_refresh">
|
|
||||||
<property name="text">
|
|
||||||
<string>Refresh</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="view-refresh">
|
|
||||||
<normaloff/>
|
|
||||||
</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="spacer_buttons">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_enable">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Enable</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="edit-add">
|
|
||||||
<normaloff/>
|
|
||||||
</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_switch">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Switch</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="system-run">
|
|
||||||
<normaloff/>
|
|
||||||
</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
@ -136,8 +77,6 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Menu</string>
|
<string>Menu</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionRefresh"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="actionSwitch"/>
|
<addaction name="actionSwitch"/>
|
||||||
<addaction name="actionEnable"/>
|
<addaction name="actionEnable"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
@ -221,16 +160,6 @@
|
|||||||
<string>Enable service</string>
|
<string>Enable service</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionRefresh">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="view-refresh">
|
|
||||||
<normaloff/>
|
|
||||||
</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Refresh</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
Loading…
Reference in New Issue
Block a user