mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
test fix #9
This commit is contained in:
parent
e64e8810f8
commit
172624b494
2
PKGBUILD
2
PKGBUILD
@ -13,7 +13,7 @@ license=('GPL3')
|
|||||||
makedepends=('automoc4' 'cmake' 'kdelibs' 'qt5-base' 'qt5-tools')
|
makedepends=('automoc4' 'cmake' 'kdelibs' 'qt5-base' 'qt5-tools')
|
||||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
||||||
install="${pkgbase}.install"
|
install="${pkgbase}.install"
|
||||||
md5sums=('0cd01301241d3b6c809f98b5d8e88b35')
|
md5sums=('fe694c52999c0470f5afbab16fc1e6c6')
|
||||||
|
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
|
@ -74,17 +74,6 @@ QStringList Netctl::sources() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Netctl::initValues()
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << "[DE]" << "[initValues]";
|
|
||||||
|
|
||||||
netctlAutoStatus = false;
|
|
||||||
QStringList sourcesList = sources();
|
|
||||||
for (int i=0; i<sourcesList.count(); i++)
|
|
||||||
sourceRequestEvent(sourcesList[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Netctl::setKeys()
|
void Netctl::setKeys()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[DE]" << "[setKeys]";
|
if (debug) qDebug() << "[DE]" << "[setKeys]";
|
||||||
@ -92,8 +81,6 @@ void Netctl::setKeys()
|
|||||||
QStringList sourcesList = sources();
|
QStringList sourcesList = sources();
|
||||||
for (int i=0; i<sourcesList.count(); i++)
|
for (int i=0; i<sourcesList.count(); i++)
|
||||||
setData(sourcesList[i], QString("value"), QString(""));
|
setData(sourcesList[i], QString("value"), QString(""));
|
||||||
|
|
||||||
initValues();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ private:
|
|||||||
// configuration
|
// configuration
|
||||||
bool debug;
|
bool debug;
|
||||||
QMap<QString, QString> configuration;
|
QMap<QString, QString> configuration;
|
||||||
void initValues();
|
|
||||||
void setKeys();
|
void setKeys();
|
||||||
void readConfiguration();
|
void readConfiguration();
|
||||||
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
|
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
|
||||||
|
104
sources/gui/src/dbusoperation.cpp
Normal file
104
sources/gui/src/dbusoperation.cpp
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of netctl-gui *
|
||||||
|
* *
|
||||||
|
* netctl-gui is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* netctl-gui is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "dbusoperation.h"
|
||||||
|
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusMessage>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
|
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
|
||||||
|
const bool debug)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[parseOutputNetctl]";
|
||||||
|
|
||||||
|
QList<netctlProfileInfo> profileInfo;
|
||||||
|
if (raw.size() == 0)
|
||||||
|
return profileInfo;
|
||||||
|
for (int i=0; i<raw[0].toStringList().count(); i++) {
|
||||||
|
netctlProfileInfo profile;
|
||||||
|
QStringList info = raw[0].toStringList()[i].split(QChar('|'));
|
||||||
|
profile.name = info[0];
|
||||||
|
profile.description = info[1];
|
||||||
|
profile.active = info[2].toInt();
|
||||||
|
profile.enabled = info[3].toInt();
|
||||||
|
profileInfo.append(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
return profileInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
|
||||||
|
const bool debug)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[parseOutputNetctl]";
|
||||||
|
|
||||||
|
QList<netctlWifiInfo> wifiInfo;
|
||||||
|
if (raw.size() == 0)
|
||||||
|
return wifiInfo;
|
||||||
|
for (int i=0; i<raw[0].toStringList().count(); i++) {
|
||||||
|
netctlWifiInfo wifi;
|
||||||
|
QStringList info = raw[0].toStringList()[i].split(QChar('|'));
|
||||||
|
wifi.name = info[0];
|
||||||
|
wifi.security = info[1];
|
||||||
|
wifi.signal = info[2];
|
||||||
|
wifi.active = info[3].toInt();
|
||||||
|
wifi.exists = info[4].toInt();
|
||||||
|
wifiInfo.append(wifi);
|
||||||
|
}
|
||||||
|
|
||||||
|
return wifiInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<QVariant> sendDBusRequest(const QString service, const QString path,
|
||||||
|
const QString interface, const QString cmd,
|
||||||
|
const QList<QVariant> args, const bool system,
|
||||||
|
const bool debug)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[sendDBusRequest]";
|
||||||
|
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "Service" << service;
|
||||||
|
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "Path" << path;
|
||||||
|
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "Interface" << interface;
|
||||||
|
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "cmd" << cmd;
|
||||||
|
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "args" << args;
|
||||||
|
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "is system bus" << system;
|
||||||
|
|
||||||
|
QList<QVariant> arguments;
|
||||||
|
QDBusMessage response;
|
||||||
|
if (system) {
|
||||||
|
QDBusConnection bus = QDBusConnection::systemBus();
|
||||||
|
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
||||||
|
if (!args.isEmpty())
|
||||||
|
request.setArguments(args);
|
||||||
|
response = bus.call(request);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||||
|
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
||||||
|
if (!args.isEmpty())
|
||||||
|
request.setArguments(args);
|
||||||
|
response = bus.call(request);
|
||||||
|
}
|
||||||
|
arguments = response.arguments();
|
||||||
|
if (arguments.size() == 0)
|
||||||
|
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "Error message" << response.errorMessage();
|
||||||
|
|
||||||
|
return arguments;
|
||||||
|
}
|
36
sources/gui/src/dbusoperation.h
Normal file
36
sources/gui/src/dbusoperation.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of netctl-gui *
|
||||||
|
* *
|
||||||
|
* netctl-gui is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* netctl-gui is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DBUSOPERATION_H
|
||||||
|
#define DBUSOPERATION_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
#include <netctlgui/netctlgui.h>
|
||||||
|
|
||||||
|
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
|
||||||
|
const bool debug = false);
|
||||||
|
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
|
||||||
|
const bool debug = false);
|
||||||
|
QList<QVariant> sendDBusRequest(const QString service, const QString path,
|
||||||
|
const QString interface, const QString cmd,
|
||||||
|
const QList<QVariant> args = QList<QVariant>(),
|
||||||
|
const bool system = true, const bool debug = false);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* DBUSOPERATION_H */
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "aboutwindow.h"
|
#include "aboutwindow.h"
|
||||||
#include "bridgewidget.h"
|
#include "bridgewidget.h"
|
||||||
|
#include "dbusoperation.h"
|
||||||
#include "errorwindow.h"
|
#include "errorwindow.h"
|
||||||
#include "ethernetwidget.h"
|
#include "ethernetwidget.h"
|
||||||
#include "generalwidget.h"
|
#include "generalwidget.h"
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "aboutwindow.h"
|
#include "aboutwindow.h"
|
||||||
#include "bridgewidget.h"
|
#include "bridgewidget.h"
|
||||||
|
#include "dbusoperation.h"
|
||||||
#include "errorwindow.h"
|
#include "errorwindow.h"
|
||||||
#include "ethernetwidget.h"
|
#include "ethernetwidget.h"
|
||||||
#include "generalwidget.h"
|
#include "generalwidget.h"
|
||||||
@ -373,48 +374,6 @@ void MainWindow::deleteObjects()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<QVariant> MainWindow::sendDBusRequest(const QString service, const QString path,
|
|
||||||
const QString interface, const QString cmd,
|
|
||||||
const QList<QVariant> args, bool system)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]";
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "Service" << service;
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "Path" << path;
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "Interface" << interface;
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "cmd" << cmd;
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "args" << args;
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "is system bus" << system;
|
|
||||||
|
|
||||||
QList<QVariant> arguments;
|
|
||||||
QDBusMessage response;
|
|
||||||
if (system) {
|
|
||||||
QDBusConnection bus = QDBusConnection::systemBus();
|
|
||||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
|
||||||
if (!args.isEmpty())
|
|
||||||
request.setArguments(args);
|
|
||||||
response = bus.call(request);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
|
||||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
|
||||||
if (!args.isEmpty())
|
|
||||||
request.setArguments(args);
|
|
||||||
response = bus.call(request);
|
|
||||||
}
|
|
||||||
arguments = response.arguments();
|
|
||||||
if ((arguments.size() == 0) &&
|
|
||||||
(service != DBUS_HELPER_SERVICE) &&
|
|
||||||
(path != DBUS_CONTROL_PATH) &&
|
|
||||||
(interface != DBUS_HELPER_INTERFACE) &&
|
|
||||||
(cmd != QString("Active"))) {
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[sendDBusRequest]" << ":" << "Error message" << response.errorMessage();
|
|
||||||
errorWin->showWindow(0, QString("[MainWindow] : [sendDBusRequest]"), response.errorMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return arguments;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::setIconsToTabs()
|
void MainWindow::setIconsToTabs()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[setIconsToTabs]";
|
if (debug) qDebug() << "[MainWindow]" << "[setIconsToTabs]";
|
||||||
@ -445,49 +404,6 @@ QMap<QString, QString> MainWindow::parseOptions(const QString options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<netctlProfileInfo> MainWindow::parseOutputNetctl(const QList<QVariant> raw)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[parseOutputNetctl]";
|
|
||||||
|
|
||||||
QList<netctlProfileInfo> profileInfo;
|
|
||||||
if (raw.size() == 0)
|
|
||||||
return profileInfo;
|
|
||||||
for (int i=0; i<raw[0].toStringList().count(); i++) {
|
|
||||||
netctlProfileInfo profile;
|
|
||||||
QStringList info = raw[0].toStringList()[i].split(QChar('|'));
|
|
||||||
profile.name = info[0];
|
|
||||||
profile.description = info[1];
|
|
||||||
profile.active = info[2].toInt();
|
|
||||||
profile.enabled = info[3].toInt();
|
|
||||||
profileInfo.append(profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
return profileInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QList<netctlWifiInfo> MainWindow::parseOutputWifi(const QList<QVariant> raw)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[parseOutputNetctl]";
|
|
||||||
|
|
||||||
QList<netctlWifiInfo> wifiInfo;
|
|
||||||
if (raw.size() == 0)
|
|
||||||
return wifiInfo;
|
|
||||||
for (int i=0; i<raw[0].toStringList().count(); i++) {
|
|
||||||
netctlWifiInfo wifi;
|
|
||||||
QStringList info = raw[0].toStringList()[i].split(QChar('|'));
|
|
||||||
wifi.name = info[0];
|
|
||||||
wifi.security = info[1];
|
|
||||||
wifi.signal = info[2];
|
|
||||||
wifi.active = info[3].toInt();
|
|
||||||
wifi.exists = info[4].toInt();
|
|
||||||
wifiInfo.append(wifi);
|
|
||||||
}
|
|
||||||
|
|
||||||
return wifiInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// window slots
|
// window slots
|
||||||
void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
||||||
{
|
{
|
||||||
@ -505,8 +421,10 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
|||||||
if ((configuration[QString("USE_HELPER")] == QString("true")) &&
|
if ((configuration[QString("USE_HELPER")] == QString("true")) &&
|
||||||
(checkExternalApps(QString("helper"))))
|
(checkExternalApps(QString("helper"))))
|
||||||
useHelper = true;
|
useHelper = true;
|
||||||
else
|
else {
|
||||||
useHelper = false;
|
useHelper = false;
|
||||||
|
configuration[QString("USE_HELPER")] = QString("false");
|
||||||
|
}
|
||||||
|
|
||||||
// update translation
|
// update translation
|
||||||
qApp->removeTranslator(translator);
|
qApp->removeTranslator(translator);
|
||||||
|
@ -145,10 +145,6 @@ private:
|
|||||||
void createObjects();
|
void createObjects();
|
||||||
void deleteObjects();
|
void deleteObjects();
|
||||||
void keyPressEvent(QKeyEvent *pressedKey);
|
void keyPressEvent(QKeyEvent *pressedKey);
|
||||||
QList<QVariant> sendDBusRequest(const QString service, const QString path,
|
|
||||||
const QString interface, const QString cmd,
|
|
||||||
const QList<QVariant> args = QList<QVariant>(),
|
|
||||||
const bool system = true);
|
|
||||||
void setIconsToTabs();
|
void setIconsToTabs();
|
||||||
QString configPath;
|
QString configPath;
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
@ -159,8 +155,6 @@ private:
|
|||||||
// configuration
|
// configuration
|
||||||
QMap<QString, QString> configuration;
|
QMap<QString, QString> configuration;
|
||||||
QMap<QString, QString> parseOptions(const QString options);
|
QMap<QString, QString> parseOptions(const QString options);
|
||||||
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw);
|
|
||||||
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,12 +22,19 @@
|
|||||||
|
|
||||||
#include <netctlgui/netctlgui.h>
|
#include <netctlgui/netctlgui.h>
|
||||||
|
|
||||||
|
#include "dbusoperation.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)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
ui(new Ui::NetctlAutoWindow),
|
ui(new Ui::NetctlAutoWindow),
|
||||||
debug(debugCmd)
|
debug(debugCmd)
|
||||||
{
|
{
|
||||||
|
if (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);
|
||||||
@ -100,13 +107,67 @@ void NetctlAutoWindow::showWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]";
|
||||||
|
|
||||||
|
if (ui->tableWidget->currentItem() == 0)
|
||||||
|
return;
|
||||||
|
// create menu
|
||||||
|
QMenu menu(this);
|
||||||
|
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
|
||||||
|
startProfile->setIcon(QIcon::fromTheme("system-run"));
|
||||||
|
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
||||||
|
menu.addSeparator();
|
||||||
|
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
|
||||||
|
enableAllProfiles->setIcon(QIcon::fromTheme("edit-add"));
|
||||||
|
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
|
||||||
|
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
|
||||||
|
|
||||||
|
// set text
|
||||||
|
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty()) {
|
||||||
|
enableProfile->setVisible(false);
|
||||||
|
startProfile->setVisible(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
enableProfile->setVisible(true);
|
||||||
|
startProfile->setVisible(true);
|
||||||
|
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
|
||||||
|
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||||
|
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||||
|
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// actions
|
||||||
|
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
||||||
|
if (action == startProfile) {
|
||||||
|
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Switch to profile";
|
||||||
|
netctlAutoStartProfile();
|
||||||
|
}
|
||||||
|
else if (action == enableProfile) {
|
||||||
|
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable profile";
|
||||||
|
netctlAutoEnableProfile();
|
||||||
|
}
|
||||||
|
else if (action == enableAllProfiles) {
|
||||||
|
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable all profiles";
|
||||||
|
netctlAutoEnableAllProfiles();
|
||||||
|
}
|
||||||
|
else if (action == disableAllProfiles) {
|
||||||
|
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Disable all profiles";
|
||||||
|
netctlAutoDisableAllProfiles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAutoWindow::netctlAutoUpdateTable()
|
void NetctlAutoWindow::netctlAutoUpdateTable()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoUpdateTable]";
|
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoUpdateTable]";
|
||||||
|
|
||||||
ui->tableWidget->setDisabled(true);
|
ui->tableWidget->setDisabled(true);
|
||||||
QList<netctlProfileInfo> profiles = netctlCommand->getProfileListFromNetctlAuto();
|
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
if (netctlCommand->isNetctlAutoEnabled())
|
if (netctlCommand->isNetctlAutoEnabled())
|
||||||
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
|
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
|
||||||
@ -129,6 +190,7 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
|||||||
netctlAutoRefreshButtons(0, 0);
|
netctlAutoRefreshButtons(0, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
QList<netctlProfileInfo> profiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||||
|
|
||||||
ui->tableWidget->setSortingEnabled(false);
|
ui->tableWidget->setSortingEnabled(false);
|
||||||
ui->tableWidget->selectRow(-1);
|
ui->tableWidget->selectRow(-1);
|
||||||
@ -190,62 +252,6 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]";
|
|
||||||
|
|
||||||
if (ui->tableWidget->currentItem() == 0)
|
|
||||||
return;
|
|
||||||
// create menu
|
|
||||||
QMenu menu(this);
|
|
||||||
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
|
|
||||||
startProfile->setIcon(QIcon::fromTheme("system-run"));
|
|
||||||
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
|
||||||
menu.addSeparator();
|
|
||||||
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
|
|
||||||
enableAllProfiles->setIcon(QIcon::fromTheme("edit-add"));
|
|
||||||
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
|
|
||||||
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
|
|
||||||
|
|
||||||
// set text
|
|
||||||
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty()) {
|
|
||||||
enableProfile->setVisible(false);
|
|
||||||
startProfile->setVisible(false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
enableProfile->setVisible(true);
|
|
||||||
startProfile->setVisible(true);
|
|
||||||
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
|
|
||||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
|
||||||
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
|
||||||
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// actions
|
|
||||||
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
|
||||||
if (action == startProfile) {
|
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Switch to profile";
|
|
||||||
netctlAutoStartProfile();
|
|
||||||
}
|
|
||||||
else if (action == enableProfile) {
|
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable profile";
|
|
||||||
netctlAutoEnableProfile();
|
|
||||||
}
|
|
||||||
else if (action == enableAllProfiles) {
|
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable all profiles";
|
|
||||||
netctlAutoEnableAllProfiles();
|
|
||||||
}
|
|
||||||
else if (action == disableAllProfiles) {
|
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Disable all profiles";
|
|
||||||
netctlAutoDisableAllProfiles();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void NetctlAutoWindow::netctlAutoDisableAllProfiles()
|
void NetctlAutoWindow::netctlAutoDisableAllProfiles()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoDisableAllProfiles]";
|
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoDisableAllProfiles]";
|
||||||
|
@ -58,9 +58,10 @@ private slots:
|
|||||||
void netctlAutoStartService();
|
void netctlAutoStartService();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Netctl *netctlCommand;
|
Netctl *netctlCommand = nullptr;
|
||||||
Ui::NetctlAutoWindow *ui;
|
Ui::NetctlAutoWindow *ui = nullptr;
|
||||||
bool debug;
|
bool debug = false;
|
||||||
|
bool useHelper = true;
|
||||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||||
void createActions();
|
void createActions();
|
||||||
};
|
};
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "trayicon.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "trayicon.h"
|
|
||||||
|
|
||||||
|
|
||||||
TrayIcon::TrayIcon(QObject *parent, const bool debugCmd)
|
TrayIcon::TrayIcon(QObject *parent, const bool debugCmd)
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "controladaptor.h"
|
||||||
|
|
||||||
#include "netctlhelper.h"
|
#include "netctlhelper.h"
|
||||||
#include "controladaptor.h"
|
|
||||||
|
|
||||||
|
|
||||||
ControlAdaptor::ControlAdaptor(NetctlHelper *parent, const QMap<QString, QString> configuration)
|
ControlAdaptor::ControlAdaptor(NetctlHelper *parent, const QMap<QString, QString> configuration)
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "netctladaptor.h"
|
#include "netctladaptor.h"
|
||||||
|
|
||||||
|
|
||||||
@ -83,6 +82,12 @@ bool NetctlAdaptor::isNetctlAutoActive()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool NetctlAdaptor::isNetctlAutoEnabled()
|
||||||
|
{
|
||||||
|
return netctlCommand->isNetctlAutoEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NetctlAdaptor::isProfileActive(const QString profile)
|
bool NetctlAdaptor::isProfileActive(const QString profile)
|
||||||
{
|
{
|
||||||
return netctlCommand->isProfileActive(profile);
|
return netctlCommand->isProfileActive(profile);
|
||||||
|
@ -42,6 +42,7 @@ public slots:
|
|||||||
bool autoIsProfileEnabled(const QString profile);
|
bool autoIsProfileEnabled(const QString profile);
|
||||||
QStringList Information();
|
QStringList Information();
|
||||||
bool isNetctlAutoActive();
|
bool isNetctlAutoActive();
|
||||||
|
bool isNetctlAutoEnabled();
|
||||||
bool isProfileActive(const QString profile);
|
bool isProfileActive(const QString profile);
|
||||||
bool isProfileEnabled(const QString profile);
|
bool isProfileEnabled(const QString profile);
|
||||||
QStringList ProfileList();
|
QStringList ProfileList();
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "netctlhelper.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
@ -26,7 +27,6 @@
|
|||||||
|
|
||||||
#include "controladaptor.h"
|
#include "controladaptor.h"
|
||||||
#include "netctladaptor.h"
|
#include "netctladaptor.h"
|
||||||
#include "netctlhelper.h"
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user