mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
rewrite mainwindow.cpp to use helper
This commit is contained in:
parent
d01bb8834a
commit
23f4a7f141
@ -18,13 +18,10 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
#include <QDBusConnection>
|
|
||||||
#include <QDBusMessage>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QTranslator>
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include "aboutwindow.h"
|
#include "aboutwindow.h"
|
||||||
|
@ -21,11 +21,7 @@
|
|||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopServices>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QUrl>
|
|
||||||
|
|
||||||
#include "aboutwindow.h"
|
#include "aboutwindow.h"
|
||||||
#include "bridgewidget.h"
|
#include "bridgewidget.h"
|
||||||
@ -125,13 +121,21 @@ QString MainWindow::getInformation()
|
|||||||
|
|
||||||
QString profile;
|
QString profile;
|
||||||
QString status;
|
QString status;
|
||||||
if (netctlCommand->isNetctlAutoRunning()) {
|
if (useHelper) {
|
||||||
profile = netctlCommand->autoGetActiveProfile();
|
QStringList request = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||||
status = QString("netctl-auto");
|
DBUS_HELPER_INTERFACE, QString("Information"))[0].toStringList();
|
||||||
|
profile = request[0];
|
||||||
|
status = request[1];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile = netctlCommand->getActiveProfile();
|
if (netctlCommand->isNetctlAutoRunning()) {
|
||||||
status = netctlCommand->getProfileStatus(profile);
|
profile = netctlCommand->autoGetActiveProfile();
|
||||||
|
status = QString("netctl-auto");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile = netctlCommand->getActiveProfile();
|
||||||
|
status = netctlCommand->getProfileStatus(profile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QString output = QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Profile")).arg(profile);
|
QString output = QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Profile")).arg(profile);
|
||||||
output += QString("%1: %2").arg(QApplication::translate("MainWindow", "Status")).arg(status);
|
output += QString("%1: %2").arg(QApplication::translate("MainWindow", "Status")).arg(status);
|
||||||
@ -753,7 +757,12 @@ void MainWindow::updateWifiTab()
|
|||||||
return errorWin->showWindow(1, QString("[MainWindow] : [updateWifiTab]"));
|
return errorWin->showWindow(1, QString("[MainWindow] : [updateWifiTab]"));
|
||||||
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
QList<netctlWifiInfo> scanResults = wpaCommand->scanWifi();
|
QList<netctlWifiInfo> scanResults;
|
||||||
|
if (useHelper)
|
||||||
|
scanResults = parseOutputWifi(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||||
|
DBUS_HELPER_INTERFACE, QString("WiFi")));
|
||||||
|
else
|
||||||
|
scanResults = wpaCommand->scanWifi();
|
||||||
|
|
||||||
ui->tableWidget_wifi->setSortingEnabled(false);
|
ui->tableWidget_wifi->setSortingEnabled(false);
|
||||||
ui->tableWidget_wifi->selectRow(-1);
|
ui->tableWidget_wifi->selectRow(-1);
|
||||||
|
@ -39,7 +39,7 @@ NetctlAdaptor::~NetctlAdaptor()
|
|||||||
// netctlCommand
|
// netctlCommand
|
||||||
QString NetctlAdaptor::ActiveProfile()
|
QString NetctlAdaptor::ActiveProfile()
|
||||||
{
|
{
|
||||||
if (netctlCommand->isNetctlAutoRunning())
|
if (isNetctlAutoActive())
|
||||||
return netctlCommand->autoGetActiveProfile();
|
return netctlCommand->autoGetActiveProfile();
|
||||||
else
|
else
|
||||||
return netctlCommand->getActiveProfile();
|
return netctlCommand->getActiveProfile();
|
||||||
@ -48,7 +48,7 @@ QString NetctlAdaptor::ActiveProfile()
|
|||||||
|
|
||||||
QString NetctlAdaptor::ActiveProfileStatus()
|
QString NetctlAdaptor::ActiveProfileStatus()
|
||||||
{
|
{
|
||||||
if (netctlCommand->isNetctlAutoRunning())
|
if (isNetctlAutoActive())
|
||||||
return QString("netctl-auto");
|
return QString("netctl-auto");
|
||||||
else
|
else
|
||||||
return netctlCommand->getProfileStatus(ActiveProfile());
|
return netctlCommand->getProfileStatus(ActiveProfile());
|
||||||
@ -70,13 +70,19 @@ bool NetctlAdaptor::autoIsProfileEnabled(const QString profile)
|
|||||||
QStringList NetctlAdaptor::Information()
|
QStringList NetctlAdaptor::Information()
|
||||||
{
|
{
|
||||||
QStringList output;
|
QStringList output;
|
||||||
output.append(QString("Profile: %1").arg(ActiveProfile()));
|
output.append(ActiveProfile());
|
||||||
output.append(QString("Status: %1").arg(ActiveProfileStatus()));
|
output.append(ActiveProfileStatus());
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool NetctlAdaptor::isNetctlAutoActive()
|
||||||
|
{
|
||||||
|
return netctlCommand->isNetctlAutoRunning();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NetctlAdaptor::isProfileActive(const QString profile)
|
bool NetctlAdaptor::isProfileActive(const QString profile)
|
||||||
{
|
{
|
||||||
return netctlCommand->isProfileActive(profile);
|
return netctlCommand->isProfileActive(profile);
|
||||||
@ -92,7 +98,7 @@ bool NetctlAdaptor::isProfileEnabled(const QString profile)
|
|||||||
QStringList NetctlAdaptor::ProfileList()
|
QStringList NetctlAdaptor::ProfileList()
|
||||||
{
|
{
|
||||||
QList<netctlProfileInfo> profilesInfo;
|
QList<netctlProfileInfo> profilesInfo;
|
||||||
if (netctlCommand->isNetctlAutoRunning())
|
if (isNetctlAutoActive())
|
||||||
profilesInfo = netctlCommand->getProfileListFromNetctlAuto();
|
profilesInfo = netctlCommand->getProfileListFromNetctlAuto();
|
||||||
else
|
else
|
||||||
profilesInfo = netctlCommand->getProfileList();
|
profilesInfo = netctlCommand->getProfileList();
|
||||||
|
@ -41,6 +41,7 @@ public slots:
|
|||||||
bool autoIsProfileActive(const QString profile);
|
bool autoIsProfileActive(const QString profile);
|
||||||
bool autoIsProfileEnabled(const QString profile);
|
bool autoIsProfileEnabled(const QString profile);
|
||||||
QStringList Information();
|
QStringList Information();
|
||||||
|
bool isNetctlAutoActive();
|
||||||
bool isProfileActive(const QString profile);
|
bool isProfileActive(const QString profile);
|
||||||
bool isProfileEnabled(const QString profile);
|
bool isProfileEnabled(const QString profile);
|
||||||
QStringList ProfileList();
|
QStringList ProfileList();
|
||||||
|
Loading…
Reference in New Issue
Block a user