mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-25 07:57:20 +00:00
detached backend from frontend
This commit is contained in:
parent
eccb6b6578
commit
9852fb8f68
@ -4,7 +4,10 @@ Ver.1.2.0:
|
|||||||
+ [gui] added ability to remove profile
|
+ [gui] added ability to remove profile
|
||||||
+ [gui] added support of hidden wifi network
|
+ [gui] added support of hidden wifi network
|
||||||
+ [gui] added contextual menu to tables
|
+ [gui] added contextual menu to tables
|
||||||
|
+ [gui] added actions menu
|
||||||
|
+ [lib] detached backend from frontend
|
||||||
* [all] small changes in the project architecture
|
* [all] small changes in the project architecture
|
||||||
|
* [gui] more debug information
|
||||||
* [plasmoid] edited configuration interface
|
* [plasmoid] edited configuration interface
|
||||||
|
|
||||||
Ver.1.1.0 (netctl-1.7 update):
|
Ver.1.1.0 (netctl-1.7 update):
|
||||||
|
@ -17,8 +17,12 @@ message (STATUS "Version: ${PROJECT_VERSION}")
|
|||||||
# install options
|
# install options
|
||||||
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
|
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
|
||||||
option (BUILD_GUI "Build GUI" ON)
|
option (BUILD_GUI "Build GUI" ON)
|
||||||
|
option (BUILD_LIBRARY "Build library" ON)
|
||||||
option (BUILD_DATAENGINE "Build data engine" ON)
|
option (BUILD_DATAENGINE "Build data engine" ON)
|
||||||
option (BUILD_PLASMOID "Build plasmoid" ON)
|
option (BUILD_PLASMOID "Build plasmoid" ON)
|
||||||
|
if (BUILD_GUI)
|
||||||
|
set (BUILD_LIBRARY ON)
|
||||||
|
endif ()
|
||||||
if (BUILD_PLASMOID)
|
if (BUILD_PLASMOID)
|
||||||
set (BUILD_DATAENGINE ON)
|
set (BUILD_DATAENGINE ON)
|
||||||
endif ()
|
endif ()
|
||||||
@ -34,10 +38,14 @@ else ()
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# resources
|
# resources
|
||||||
|
set (PROJECT_LIBRARY netctlgui)
|
||||||
set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
|
set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
|
||||||
add_subdirectory (${PROJECT_RESOURCE_DIR})
|
add_subdirectory (${PROJECT_RESOURCE_DIR})
|
||||||
|
|
||||||
# components
|
# components
|
||||||
|
if (BUILD_LIBRARY)
|
||||||
|
add_subdirectory (${PROJECT_LIBRARY})
|
||||||
|
endif()
|
||||||
if (BUILD_GUI)
|
if (BUILD_GUI)
|
||||||
add_subdirectory (gui)
|
add_subdirectory (gui)
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -11,7 +11,12 @@ message (STATUS "${SUBPROJECT} Headers: ${HEADERS}")
|
|||||||
message (STATUS "${SUBPROJECT} Forms: ${FORMS}")
|
message (STATUS "${SUBPROJECT} Forms: ${FORMS}")
|
||||||
|
|
||||||
# include_path
|
# include_path
|
||||||
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
|
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/include/
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||||
|
${CMAKE_SOURCE_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
link_directories (${PROJECT_LIBRARY}/src/lib)
|
||||||
|
|
||||||
if (USE_QT5)
|
if (USE_QT5)
|
||||||
find_package(Qt5Core REQUIRED)
|
find_package(Qt5Core REQUIRED)
|
||||||
@ -41,7 +46,7 @@ if (USE_QT5)
|
|||||||
|
|
||||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||||
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
||||||
target_link_libraries (${SUBPROJECT} ${Qt5Widgets_LIBRARIES} ${Qt5Core_LIBRARIES})
|
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${Qt5Widgets_LIBRARIES} ${Qt5Core_LIBRARIES})
|
||||||
else ()
|
else ()
|
||||||
find_package (Qt4 REQUIRED)
|
find_package (Qt4 REQUIRED)
|
||||||
include (${QT_USE_FILE})
|
include (${QT_USE_FILE})
|
||||||
@ -65,7 +70,7 @@ else ()
|
|||||||
source_group ("Generated Files" FILES ${MOC_SOURCES})
|
source_group ("Generated Files" FILES ${MOC_SOURCES})
|
||||||
|
|
||||||
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
||||||
target_link_libraries (${SUBPROJECT} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
|
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# install properties
|
# install properties
|
||||||
|
@ -26,18 +26,23 @@ ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd, const int message
|
|||||||
debug(debugCmd),
|
debug(debugCmd),
|
||||||
ui(new Ui::ErrorWindow)
|
ui(new Ui::ErrorWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
|
||||||
if (debug) qDebug() << "[ErrorWindow]" << "[ErrorWindow]" << ":" << "Initializate with error code" << messageNumber;
|
if (debug) qDebug() << "[ErrorWindow]" << "[ErrorWindow]" << ":" << "Initializate with error code" << messageNumber;
|
||||||
|
|
||||||
|
ui->setupUi(this);
|
||||||
setMessage(messageNumber);
|
setMessage(messageNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorWindow::~ErrorWindow()
|
ErrorWindow::~ErrorWindow()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[ErrorWindow]" << "[~ErrorWindow]";
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorWindow::setMessage(const int mess)
|
void ErrorWindow::setMessage(const int mess)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[ErrorWindow]" << "[setMessage]";
|
||||||
|
|
||||||
QString message;
|
QString message;
|
||||||
switch(mess) {
|
switch(mess) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -27,6 +27,19 @@ Language::Language(const QString configPath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Language::checkLanguage(const QString language, const QString defaultLanguage)
|
||||||
|
{
|
||||||
|
QStringList availableLanguages = getAvailableLanguages();
|
||||||
|
for (int i=0; i<availableLanguages.count(); i++)
|
||||||
|
if (language == availableLanguages[i])
|
||||||
|
return availableLanguages[i];
|
||||||
|
for (int i=0; i<availableLanguages.count(); i++)
|
||||||
|
if (language.contains(availableLanguages[i] + QChar('_')))
|
||||||
|
return availableLanguages[i];
|
||||||
|
return defaultLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Language::defineLanguage(const QString configPath)
|
QString Language::defineLanguage(const QString configPath)
|
||||||
{
|
{
|
||||||
QString language;
|
QString language;
|
||||||
@ -66,19 +79,6 @@ QString Language::defineLanguageFromLocale()
|
|||||||
{
|
{
|
||||||
return QLocale::system().name();
|
return QLocale::system().name();
|
||||||
}
|
}
|
||||||
\
|
|
||||||
|
|
||||||
QString Language::checkLanguage(const QString language, const QString defaultLanguage)
|
|
||||||
{
|
|
||||||
QStringList availableLanguages = getAvailableLanguages();
|
|
||||||
for (int i=0; i<availableLanguages.count(); i++)
|
|
||||||
if (language == availableLanguages[i])
|
|
||||||
return availableLanguages[i];
|
|
||||||
for (int i=0; i<availableLanguages.count(); i++)
|
|
||||||
if (language.contains(availableLanguages[i] + QChar('_')))
|
|
||||||
return availableLanguages[i];
|
|
||||||
return defaultLanguage;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QStringList Language::getAvailableLanguages()
|
QStringList Language::getAvailableLanguages()
|
||||||
|
@ -21,17 +21,17 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
||||||
class Language
|
class Language : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Language(const QString configPath);
|
explicit Language(const QString configPath);
|
||||||
|
static QString checkLanguage(const QString language,
|
||||||
|
const QString defaultLanguage = QString("en"));
|
||||||
static QString defineLanguage(const QString configPath);
|
static QString defineLanguage(const QString configPath);
|
||||||
static QString defineLanguageFromFile(const QString configPath);
|
static QString defineLanguageFromFile(const QString configPath);
|
||||||
static QString defineLanguageFromLocale();
|
static QString defineLanguageFromLocale();
|
||||||
|
|
||||||
private:
|
|
||||||
static QString checkLanguage(const QString language,
|
|
||||||
const QString defaultLanguage = QString("en"));
|
|
||||||
static QStringList getAvailableLanguages();
|
static QStringList getAvailableLanguages();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
|
#include <netctlgui/netctlinteract.h>
|
||||||
|
#include <netctlgui/netctlprofile.h>
|
||||||
|
#include <netctlgui/wpasupinteract.h>
|
||||||
|
|
||||||
#include "bridgewidget.h"
|
#include "bridgewidget.h"
|
||||||
#include "errorwindow.h"
|
#include "errorwindow.h"
|
||||||
#include "ethernetwidget.h"
|
#include "ethernetwidget.h"
|
||||||
@ -30,15 +34,12 @@
|
|||||||
#include "ipwidget.h"
|
#include "ipwidget.h"
|
||||||
#include "macvlanwidget.h"
|
#include "macvlanwidget.h"
|
||||||
#include "mobilewidget.h"
|
#include "mobilewidget.h"
|
||||||
#include "netctlinteract.h"
|
|
||||||
#include "netctlprofile.h"
|
|
||||||
#include "passwdwidget.h"
|
#include "passwdwidget.h"
|
||||||
#include "pppoewidget.h"
|
#include "pppoewidget.h"
|
||||||
#include "settingswindow.h"
|
#include "settingswindow.h"
|
||||||
#include "tunnelwidget.h"
|
#include "tunnelwidget.h"
|
||||||
#include "tuntapwidget.h"
|
#include "tuntapwidget.h"
|
||||||
#include "vlanwidget.h"
|
#include "vlanwidget.h"
|
||||||
#include "wpasupinteract.h"
|
|
||||||
#include "wirelesswidget.h"
|
#include "wirelesswidget.h"
|
||||||
|
|
||||||
|
|
||||||
@ -85,9 +86,9 @@ MainWindow::MainWindow(QWidget *parent, const bool defaultSettings, const bool d
|
|||||||
wirelessWid = new WirelessWidget(this, configuration);
|
wirelessWid = new WirelessWidget(this, configuration);
|
||||||
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
|
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
|
||||||
// backend
|
// backend
|
||||||
netctlCommand = new Netctl(this, debug, configuration);
|
netctlCommand = new Netctl(debug, configuration);
|
||||||
netctlProfile = new NetctlProfile(this, debug, configuration);
|
netctlProfile = new NetctlProfile(debug, configuration);
|
||||||
wpaCommand = new WpaSup(this, debug, configuration);
|
wpaCommand = new WpaSup(debug, configuration);
|
||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
setIconsToButtons();
|
setIconsToButtons();
|
||||||
@ -98,6 +99,8 @@ MainWindow::MainWindow(QWidget *parent, const bool defaultSettings, const bool d
|
|||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[~MainWindow]";
|
||||||
|
|
||||||
delete netctlCommand;
|
delete netctlCommand;
|
||||||
delete netctlProfile;
|
delete netctlProfile;
|
||||||
delete wpaCommand;
|
delete wpaCommand;
|
||||||
@ -121,6 +124,8 @@ MainWindow::~MainWindow()
|
|||||||
|
|
||||||
bool MainWindow::checkExternalApps(const QString apps = QString("all"))
|
bool MainWindow::checkExternalApps(const QString apps = QString("all"))
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]";
|
||||||
|
|
||||||
QStringList commandLine;
|
QStringList commandLine;
|
||||||
commandLine.append("which");
|
commandLine.append("which");
|
||||||
commandLine.append(configuration[QString("SUDO_PATH")]);
|
commandLine.append(configuration[QString("SUDO_PATH")]);
|
||||||
@ -145,6 +150,10 @@ bool MainWindow::checkExternalApps(const QString apps = QString("all"))
|
|||||||
|
|
||||||
bool MainWindow::checkState(const QString state, const QString item)
|
bool MainWindow::checkState(const QString state, const QString item)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[checkState]";
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[checkState]" << ":" << "Text" << item;
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[checkState]" << ":" << "State" << state;
|
||||||
|
|
||||||
if (item.contains(state))
|
if (item.contains(state))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
@ -155,14 +164,29 @@ bool MainWindow::checkState(const QString state, const QString item)
|
|||||||
// window signals
|
// window signals
|
||||||
void MainWindow::createActions()
|
void MainWindow::createActions()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[createActions]";
|
||||||
|
|
||||||
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
|
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
|
||||||
connect(ui->actionSettings, SIGNAL(triggered(bool)), settingsWin, SLOT(showWindow()));
|
connect(ui->actionSettings, SIGNAL(triggered(bool)), settingsWin, SLOT(showWindow()));
|
||||||
connect(ui->actionQuit, SIGNAL(triggered(bool)), this, SLOT(close()));
|
connect(ui->actionQuit, SIGNAL(triggered(bool)), this, SLOT(close()));
|
||||||
|
|
||||||
|
// actions menu
|
||||||
|
connect(ui->menuActions, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
||||||
|
connect(ui->actionMainEdit, SIGNAL(triggered(bool)), this, SLOT(mainTabEditProfile()));
|
||||||
|
connect(ui->actionMainEnable, SIGNAL(triggered(bool)), this, SLOT(mainTabEnableProfile()));
|
||||||
|
connect(ui->actionMainRefresh, SIGNAL(triggered(bool)), this, SLOT(updateMainTab()));
|
||||||
|
connect(ui->actionMainRemove, SIGNAL(triggered(bool)), this, SLOT(mainTabRemoveProfile()));
|
||||||
|
connect(ui->actionMainRestart, SIGNAL(triggered(bool)), this, SLOT(mainTabRestartProfile()));
|
||||||
|
connect(ui->actionMainStart, SIGNAL(triggered(bool)), this, SLOT(mainTabStartProfile()));
|
||||||
|
connect(ui->actionProfileClear, SIGNAL(triggered(bool)), this, SLOT(profileTabClear()));
|
||||||
|
connect(ui->actionProfileLoad, SIGNAL(triggered(bool)), this, SLOT(profileTabLoadProfile()));
|
||||||
|
connect(ui->actionProfileRemove, SIGNAL(triggered(bool)), this, SLOT(profileTabRemoveProfile()));
|
||||||
|
connect(ui->actionProfileSave, SIGNAL(triggered(bool)), this, SLOT(profileTabCreateProfile()));
|
||||||
|
connect(ui->actionWifiRefresh, SIGNAL(triggered(bool)), this, SLOT(updateWifiTab()));
|
||||||
|
connect(ui->actionWifiStart, SIGNAL(triggered(bool)), this, SLOT(wifiTabStart()));
|
||||||
|
|
||||||
// main tab events
|
// main tab events
|
||||||
connect(ui->pushButton_mainRefresh, SIGNAL(clicked(bool)), this, SLOT(updateMainTab()));
|
connect(ui->pushButton_mainRefresh, SIGNAL(clicked(bool)), this, SLOT(updateMainTab()));
|
||||||
connect(ui->pushButton_mainRemove, SIGNAL(clicked(bool)), this, SLOT(mainTabRemoveProfile()));
|
|
||||||
connect(ui->pushButton_mainEnable, SIGNAL(clicked(bool)), this, SLOT(mainTabEnableProfile()));
|
|
||||||
connect(ui->pushButton_mainRestart, SIGNAL(clicked(bool)), this, SLOT(mainTabRestartProfile()));
|
connect(ui->pushButton_mainRestart, SIGNAL(clicked(bool)), this, SLOT(mainTabRestartProfile()));
|
||||||
connect(ui->pushButton_mainStart, SIGNAL(clicked(bool)), this, SLOT(mainTabStartProfile()));
|
connect(ui->pushButton_mainStart, SIGNAL(clicked(bool)), this, SLOT(mainTabStartProfile()));
|
||||||
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
|
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
|
||||||
@ -188,6 +212,8 @@ void MainWindow::createActions()
|
|||||||
|
|
||||||
void MainWindow::setIconsToButtons()
|
void MainWindow::setIconsToButtons()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[setIconsToButtons]";
|
||||||
|
|
||||||
// tab widget
|
// tab widget
|
||||||
ui->tabWidget->setTabIcon(0, QIcon(":icon"));
|
ui->tabWidget->setTabIcon(0, QIcon(":icon"));
|
||||||
ui->tabWidget->setTabIcon(1, QIcon::fromTheme("document-new"));
|
ui->tabWidget->setTabIcon(1, QIcon::fromTheme("document-new"));
|
||||||
@ -195,7 +221,6 @@ void MainWindow::setIconsToButtons()
|
|||||||
|
|
||||||
// main tab
|
// main tab
|
||||||
ui->pushButton_mainRefresh->setIcon(QIcon::fromTheme("stock-refresh"));
|
ui->pushButton_mainRefresh->setIcon(QIcon::fromTheme("stock-refresh"));
|
||||||
ui->pushButton_mainRemove->setIcon(QIcon::fromTheme("edit-delete"));
|
|
||||||
ui->pushButton_mainRestart->setIcon(QIcon::fromTheme("stock-refresh"));
|
ui->pushButton_mainRestart->setIcon(QIcon::fromTheme("stock-refresh"));
|
||||||
|
|
||||||
// profile tab
|
// profile tab
|
||||||
@ -206,13 +231,38 @@ void MainWindow::setIconsToButtons()
|
|||||||
|
|
||||||
// wifi tab
|
// wifi tab
|
||||||
ui->pushButton_wifiRefresh->setIcon(QIcon::fromTheme("stock-refresh"));
|
ui->pushButton_wifiRefresh->setIcon(QIcon::fromTheme("stock-refresh"));
|
||||||
// ui->pushButton_wifiStart->setIcon(QIcon(""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// window slots
|
// window slots
|
||||||
|
void MainWindow::setMenuActionsShown(const bool state)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[setMenuActionsShown]";
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[setMenuActionsShown]" << ":" << "State" << state;
|
||||||
|
|
||||||
|
// main
|
||||||
|
ui->actionMainEdit->setVisible(state);
|
||||||
|
ui->actionMainEnable->setVisible(state);
|
||||||
|
ui->actionMainRefresh->setVisible(state);
|
||||||
|
ui->actionMainRemove->setVisible(state);
|
||||||
|
ui->actionMainRestart->setVisible(state);
|
||||||
|
ui->actionMainStart->setVisible(state);
|
||||||
|
// profile
|
||||||
|
ui->actionProfileClear->setVisible(state);
|
||||||
|
ui->actionProfileLoad->setVisible(state);
|
||||||
|
ui->actionProfileRemove->setVisible(state);
|
||||||
|
ui->actionProfileSave->setVisible(state);
|
||||||
|
// wifi
|
||||||
|
ui->actionWifiRefresh->setVisible(state);
|
||||||
|
ui->actionWifiStart->setVisible(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::updateTabs(const int tab)
|
void MainWindow::updateTabs(const int tab)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[updateTabs]";
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[updateTabs]" << ":" << "Update tab" << tab;
|
||||||
|
|
||||||
if (tab == 0)
|
if (tab == 0)
|
||||||
updateMainTab();
|
updateMainTab();
|
||||||
else if (tab == 1)
|
else if (tab == 1)
|
||||||
@ -222,15 +272,32 @@ void MainWindow::updateTabs(const int tab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::updateMenu()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[updateMenu]";
|
||||||
|
|
||||||
|
setMenuActionsShown(false);
|
||||||
|
int tab = ui->tabWidget->currentIndex();
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[updateMenu]" << ":" << "Current tab" << tab;
|
||||||
|
if (tab == 0)
|
||||||
|
updateMenuMain();
|
||||||
|
else if (tab == 1)
|
||||||
|
updateMenuProfile();
|
||||||
|
else if (tab == 2)
|
||||||
|
updateMenuWifi();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::updateMainTab()
|
void MainWindow::updateMainTab()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[updateMainTab]";
|
||||||
|
|
||||||
if (!checkExternalApps(QString("netctl"))) {
|
if (!checkExternalApps(QString("netctl"))) {
|
||||||
errorWin = new ErrorWindow(this, debug, 1);
|
errorWin = new ErrorWindow(this, debug, 1);
|
||||||
errorWin->show();
|
errorWin->show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[updateMainTab]";
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
QList<QStringList> profiles = netctlCommand->getProfileList();;
|
QList<QStringList> profiles = netctlCommand->getProfileList();;
|
||||||
|
|
||||||
@ -270,9 +337,39 @@ void MainWindow::updateMainTab()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::updateMenuMain()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[updateMenuMain]";
|
||||||
|
|
||||||
|
ui->actionMainRefresh->setVisible(true);
|
||||||
|
if (ui->tableWidget_main->currentItem() == 0)
|
||||||
|
return;
|
||||||
|
QString item = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text();
|
||||||
|
if (!checkState(QString("inactive"), item)) {
|
||||||
|
ui->actionMainRestart->setVisible(true);
|
||||||
|
ui->actionMainStart->setText(QApplication::translate("MainWindow", "Stop profile"));
|
||||||
|
ui->actionMainStart->setIcon(QIcon::fromTheme("dialog-close"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->actionMainRestart->setVisible(false);
|
||||||
|
ui->actionMainStart->setText(QApplication::translate("MainWindow", "Start profile"));
|
||||||
|
ui->actionMainStart->setIcon(QIcon::fromTheme("dialog-apply"));
|
||||||
|
}
|
||||||
|
ui->actionMainStart->setVisible(true);
|
||||||
|
if (checkState(QString("enabled"), item))
|
||||||
|
ui->actionMainEnable->setText(QApplication::translate("MainWindow", "Disable profile"));
|
||||||
|
else
|
||||||
|
ui->actionMainEnable->setText(QApplication::translate("MainWindow", "Enable profile"));
|
||||||
|
ui->actionMainEnable->setVisible(true);
|
||||||
|
ui->actionMainEdit->setVisible(true);
|
||||||
|
ui->actionMainRemove->setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::updateProfileTab()
|
void MainWindow::updateProfileTab()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[updateProfileTab]";
|
if (debug) qDebug() << "[MainWindow]" << "[updateProfileTab]";
|
||||||
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
profileTabClear();
|
profileTabClear();
|
||||||
ui->tabWidget->setEnabled(true);
|
ui->tabWidget->setEnabled(true);
|
||||||
@ -282,8 +379,28 @@ void MainWindow::updateProfileTab()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::updateMenuProfile()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[updateMenuProfile]";
|
||||||
|
|
||||||
|
ui->actionProfileClear->setVisible(true);
|
||||||
|
if (ui->lineEdit_profile->text().isEmpty()) {
|
||||||
|
ui->actionProfileLoad->setVisible(false);
|
||||||
|
ui->actionProfileRemove->setVisible(false);
|
||||||
|
ui->actionProfileSave->setVisible(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->actionProfileLoad->setVisible(true);
|
||||||
|
ui->actionProfileRemove->setVisible(true);
|
||||||
|
ui->actionProfileSave->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::updateWifiTab()
|
void MainWindow::updateWifiTab()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[updateWifiTab]";
|
||||||
|
|
||||||
wifiTabSetEnabled(checkExternalApps(QString("wpasup")));
|
wifiTabSetEnabled(checkExternalApps(QString("wpasup")));
|
||||||
if (!checkExternalApps(QString("wpasup"))) {
|
if (!checkExternalApps(QString("wpasup"))) {
|
||||||
errorWin = new ErrorWindow(this, debug, 1);
|
errorWin = new ErrorWindow(this, debug, 1);
|
||||||
@ -293,7 +410,6 @@ void MainWindow::updateWifiTab()
|
|||||||
|
|
||||||
QList<QStringList> scanResults = wpaCommand->scanWifi();
|
QList<QStringList> scanResults = wpaCommand->scanWifi();
|
||||||
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[updateWifiTab]";
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
ui->tableWidget_wifi->setSortingEnabled(false);
|
ui->tableWidget_wifi->setSortingEnabled(false);
|
||||||
ui->tableWidget_wifi->selectRow(-1);
|
ui->tableWidget_wifi->selectRow(-1);
|
||||||
@ -334,11 +450,40 @@ void MainWindow::updateWifiTab()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::updateMenuWifi()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[updateMenuWifi]";
|
||||||
|
|
||||||
|
ui->actionWifiRefresh->setVisible(true);
|
||||||
|
if (ui->tableWidget_wifi->currentItem() == 0)
|
||||||
|
return;
|
||||||
|
QString item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text();
|
||||||
|
if (checkState(QString("exists"), item)) {
|
||||||
|
if (!checkState(QString("inactive"), item)) {
|
||||||
|
ui->actionWifiStart->setText(QApplication::translate("MainWindow", "Stop WiFi"));
|
||||||
|
ui->actionWifiStart->setIcon(QIcon::fromTheme("dialog-close"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->actionWifiStart->setText(QApplication::translate("MainWindow", "Start WiFi"));
|
||||||
|
ui->actionWifiStart->setIcon(QIcon::fromTheme("dialog-apply"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->actionWifiStart->setText(QApplication::translate("MainWindow", "Start WiFi"));
|
||||||
|
ui->actionWifiStart->setIcon(QIcon::fromTheme("dialog-apply"));
|
||||||
|
}
|
||||||
|
ui->actionWifiStart->setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// main tab slots
|
// main tab slots
|
||||||
void MainWindow::mainTabContextualMenu(const QPoint &pos)
|
void MainWindow::mainTabContextualMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]";
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]";
|
||||||
|
|
||||||
|
if (ui->tableWidget_main->currentItem() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// create menu
|
// create menu
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh"));
|
QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh"));
|
||||||
@ -349,6 +494,8 @@ void MainWindow::mainTabContextualMenu(const QPoint &pos)
|
|||||||
restartProfile->setIcon(QIcon::fromTheme("stock-refresh"));
|
restartProfile->setIcon(QIcon::fromTheme("stock-refresh"));
|
||||||
QAction *enableProfile = menu.addAction(QApplication::translate("MainWindow", "Enable profile"));
|
QAction *enableProfile = menu.addAction(QApplication::translate("MainWindow", "Enable profile"));
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
QAction *editProfile = menu.addAction(QApplication::translate("MainWindow", "Edit profile"));
|
||||||
|
editProfile->setIcon(QIcon::fromTheme("edit"));
|
||||||
QAction *removeProfile = menu.addAction(QApplication::translate("MainWindow", "Remove profile"));
|
QAction *removeProfile = menu.addAction(QApplication::translate("MainWindow", "Remove profile"));
|
||||||
removeProfile->setIcon(QIcon::fromTheme("edit-delete"));
|
removeProfile->setIcon(QIcon::fromTheme("edit-delete"));
|
||||||
|
|
||||||
@ -387,6 +534,10 @@ void MainWindow::mainTabContextualMenu(const QPoint &pos)
|
|||||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Enable profile";
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Enable profile";
|
||||||
mainTabEnableProfile();
|
mainTabEnableProfile();
|
||||||
}
|
}
|
||||||
|
else if (action == editProfile) {
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Edit profile";
|
||||||
|
mainTabEditProfile();
|
||||||
|
}
|
||||||
else if (action == removeProfile) {
|
else if (action == removeProfile) {
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Remove profile";
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Remove profile";
|
||||||
mainTabRemoveProfile();
|
mainTabRemoveProfile();
|
||||||
@ -394,9 +545,23 @@ void MainWindow::mainTabContextualMenu(const QPoint &pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::mainTabEditProfile()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabEditProfile]";
|
||||||
|
|
||||||
|
ui->tabWidget->setDisabled(true);
|
||||||
|
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||||
|
ui->tabWidget->setCurrentIndex(1);
|
||||||
|
ui->lineEdit_profile->setText(profile);
|
||||||
|
|
||||||
|
profileTabLoadProfile();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::mainTabRemoveProfile()
|
void MainWindow::mainTabRemoveProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabRemoveProfile]";
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabRemoveProfile]";
|
||||||
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
// call netctlprofile
|
// call netctlprofile
|
||||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||||
@ -411,6 +576,8 @@ void MainWindow::mainTabRemoveProfile()
|
|||||||
|
|
||||||
void MainWindow::mainTabEnableProfile()
|
void MainWindow::mainTabEnableProfile()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabEnableProfile]";
|
||||||
|
|
||||||
if (!checkExternalApps(QString("netctl"))) {
|
if (!checkExternalApps(QString("netctl"))) {
|
||||||
errorWin = new ErrorWindow(this, debug, 1);
|
errorWin = new ErrorWindow(this, debug, 1);
|
||||||
errorWin->show();
|
errorWin->show();
|
||||||
@ -419,7 +586,6 @@ void MainWindow::mainTabEnableProfile()
|
|||||||
if (ui->tableWidget_main->currentItem() == 0)
|
if (ui->tableWidget_main->currentItem() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabEnableProfile]";
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||||
netctlCommand->enableProfile(profile);
|
netctlCommand->enableProfile(profile);
|
||||||
@ -436,12 +602,15 @@ void MainWindow::mainTabEnableProfile()
|
|||||||
else
|
else
|
||||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMainTab();
|
updateMainTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::mainTabRestartProfile()
|
void MainWindow::mainTabRestartProfile()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabRestartProfile]";
|
||||||
|
|
||||||
if (!checkExternalApps(QString("netctl"))) {
|
if (!checkExternalApps(QString("netctl"))) {
|
||||||
errorWin = new ErrorWindow(this, debug, 1);
|
errorWin = new ErrorWindow(this, debug, 1);
|
||||||
errorWin->show();
|
errorWin->show();
|
||||||
@ -450,7 +619,6 @@ void MainWindow::mainTabRestartProfile()
|
|||||||
if (ui->tableWidget_main->currentItem() == 0)
|
if (ui->tableWidget_main->currentItem() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabRestartProfile]";
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||||
netctlCommand->restartProfile(profile);
|
netctlCommand->restartProfile(profile);
|
||||||
@ -458,12 +626,15 @@ void MainWindow::mainTabRestartProfile()
|
|||||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||||
else
|
else
|
||||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||||
|
|
||||||
updateMainTab();
|
updateMainTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::mainTabStartProfile()
|
void MainWindow::mainTabStartProfile()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabStartProfile]";
|
||||||
|
|
||||||
if (!checkExternalApps(QString("netctl"))) {
|
if (!checkExternalApps(QString("netctl"))) {
|
||||||
errorWin = new ErrorWindow(this, debug, 1);
|
errorWin = new ErrorWindow(this, debug, 1);
|
||||||
errorWin->show();
|
errorWin->show();
|
||||||
@ -472,7 +643,6 @@ void MainWindow::mainTabStartProfile()
|
|||||||
if (ui->tableWidget_main->currentItem() == 0)
|
if (ui->tableWidget_main->currentItem() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabStartProfile]";
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||||
netctlCommand->startProfile(profile);
|
netctlCommand->startProfile(profile);
|
||||||
@ -489,6 +659,7 @@ void MainWindow::mainTabStartProfile()
|
|||||||
else
|
else
|
||||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMainTab();
|
updateMainTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,20 +667,19 @@ void MainWindow::mainTabStartProfile()
|
|||||||
void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||||
{
|
{
|
||||||
Q_UNUSED(previous);
|
Q_UNUSED(previous);
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabRefreshButtons]";
|
||||||
|
|
||||||
if (!checkExternalApps(QString("netctl"))) {
|
if (!checkExternalApps(QString("netctl"))) {
|
||||||
errorWin = new ErrorWindow(this, debug, 1);
|
errorWin = new ErrorWindow(this, debug, 1);
|
||||||
errorWin->show();
|
errorWin->show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (current == 0) {
|
if (current == 0) {
|
||||||
ui->pushButton_mainEnable->setDisabled(true);
|
|
||||||
ui->pushButton_mainRestart->setDisabled(true);
|
ui->pushButton_mainRestart->setDisabled(true);
|
||||||
ui->pushButton_mainStart->setDisabled(true);
|
ui->pushButton_mainStart->setDisabled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabRefreshButtons]";
|
|
||||||
ui->pushButton_mainEnable->setEnabled(true);
|
|
||||||
ui->pushButton_mainStart->setEnabled(true);
|
ui->pushButton_mainStart->setEnabled(true);
|
||||||
|
|
||||||
QString item = ui->tableWidget_main->item(current->row(), 2)->text();
|
QString item = ui->tableWidget_main->item(current->row(), 2)->text();
|
||||||
@ -523,10 +693,6 @@ void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt
|
|||||||
ui->pushButton_mainStart->setText(QApplication::translate("MainWindow", "Start"));
|
ui->pushButton_mainStart->setText(QApplication::translate("MainWindow", "Start"));
|
||||||
ui->pushButton_mainStart->setIcon(QIcon::fromTheme("dialog-apply"));
|
ui->pushButton_mainStart->setIcon(QIcon::fromTheme("dialog-apply"));
|
||||||
}
|
}
|
||||||
if (checkState(QString("enabled"), item))
|
|
||||||
ui->pushButton_mainEnable->setText(QApplication::translate("MainWindow", "Disable"));
|
|
||||||
else
|
|
||||||
ui->pushButton_mainEnable->setText(QApplication::translate("MainWindow", "Enable"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -534,6 +700,7 @@ void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt
|
|||||||
void MainWindow::profileTabBrowseProfile()
|
void MainWindow::profileTabBrowseProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[profileTabBrowseProfile]";
|
if (debug) qDebug() << "[MainWindow]" << "[profileTabBrowseProfile]";
|
||||||
|
|
||||||
QString filename = QFileDialog::getSaveFileName(
|
QString filename = QFileDialog::getSaveFileName(
|
||||||
this,
|
this,
|
||||||
QApplication::translate("MainWindow", "Save profile as..."),
|
QApplication::translate("MainWindow", "Save profile as..."),
|
||||||
@ -547,6 +714,8 @@ void MainWindow::profileTabBrowseProfile()
|
|||||||
void MainWindow::profileTabChangeState(const QString current)
|
void MainWindow::profileTabChangeState(const QString current)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[profileTabChangeState]";
|
if (debug) qDebug() << "[MainWindow]" << "[profileTabChangeState]";
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[profileTabChangeState]" << ":" << "Current type" << current;
|
||||||
|
|
||||||
if (current == QString("ethernet")) {
|
if (current == QString("ethernet")) {
|
||||||
generalWid->setShown(true);
|
generalWid->setShown(true);
|
||||||
ipWid->setShown(true);
|
ipWid->setShown(true);
|
||||||
@ -684,6 +853,7 @@ void MainWindow::profileTabChangeState(const QString current)
|
|||||||
void MainWindow::profileTabClear()
|
void MainWindow::profileTabClear()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[profileTabClear]";
|
if (debug) qDebug() << "[MainWindow]" << "[profileTabClear]";
|
||||||
|
|
||||||
ui->lineEdit_profile->clear();
|
ui->lineEdit_profile->clear();
|
||||||
|
|
||||||
generalWid->clear();
|
generalWid->clear();
|
||||||
@ -704,6 +874,8 @@ void MainWindow::profileTabClear()
|
|||||||
|
|
||||||
void MainWindow::profileTabCreateProfile()
|
void MainWindow::profileTabCreateProfile()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[profileTabCreateProfile]";
|
||||||
|
|
||||||
// error checking
|
// error checking
|
||||||
if (ui->lineEdit_profile->text().isEmpty()) {
|
if (ui->lineEdit_profile->text().isEmpty()) {
|
||||||
errorWin = new ErrorWindow(this, debug, 3);
|
errorWin = new ErrorWindow(this, debug, 3);
|
||||||
@ -839,10 +1011,9 @@ void MainWindow::profileTabCreateProfile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[profileTabCreateProfile]";
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
// read settings
|
// read settings
|
||||||
QString profile = ui->lineEdit_profile->text();
|
QString profile = netctlProfile->getNameByString(ui->lineEdit_profile->text());
|
||||||
QMap<QString, QString> settings;
|
QMap<QString, QString> settings;
|
||||||
settings = generalWid->getSettings();
|
settings = generalWid->getSettings();
|
||||||
if (generalWid->connectionType->currentText() == QString("ethernet")) {
|
if (generalWid->connectionType->currentText() == QString("ethernet")) {
|
||||||
@ -938,7 +1109,8 @@ void MainWindow::profileTabCreateProfile()
|
|||||||
void MainWindow::profileTabLoadProfile()
|
void MainWindow::profileTabLoadProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[profileTabLoadProfile]";
|
if (debug) qDebug() << "[MainWindow]" << "[profileTabLoadProfile]";
|
||||||
QString profile = ui->lineEdit_profile->text();
|
|
||||||
|
QString profile = netctlProfile->getNameByString(ui->lineEdit_profile->text());
|
||||||
QMap<QString, QString> settings = netctlProfile->getSettingsFromProfile(profile);
|
QMap<QString, QString> settings = netctlProfile->getSettingsFromProfile(profile);
|
||||||
|
|
||||||
generalWid->setSettings(settings);
|
generalWid->setSettings(settings);
|
||||||
@ -985,11 +1157,30 @@ void MainWindow::profileTabLoadProfile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::profileTabRemoveProfile()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[profileTabRemoveProfile]";
|
||||||
|
|
||||||
|
ui->tabWidget->setDisabled(true);
|
||||||
|
// call netctlprofile
|
||||||
|
QString profile = netctlProfile->getNameByString(ui->lineEdit_profile->text());
|
||||||
|
if (netctlProfile->removeProfile(profile))
|
||||||
|
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||||
|
else
|
||||||
|
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||||
|
|
||||||
|
updateProfileTab();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// wifi tab slots
|
// wifi tab slots
|
||||||
void MainWindow::wifiTabContextualMenu(const QPoint &pos)
|
void MainWindow::wifiTabContextualMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[wifiTabContextualMenu]";
|
if (debug) qDebug() << "[MainWindow]" << "[wifiTabContextualMenu]";
|
||||||
|
|
||||||
|
if (ui->tableWidget_wifi->currentItem() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// create menu
|
// create menu
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh"));
|
QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh"));
|
||||||
@ -1029,6 +1220,9 @@ void MainWindow::wifiTabContextualMenu(const QPoint &pos)
|
|||||||
|
|
||||||
void MainWindow::wifiTabSetEnabled(const bool state)
|
void MainWindow::wifiTabSetEnabled(const bool state)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[wifiTabSetEnables]";
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[wifiTabSetEnables]" << ":" << "State" << state;
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
ui->tableWidget_wifi->show();
|
ui->tableWidget_wifi->show();
|
||||||
ui->pushButton_wifiRefresh->setEnabled(true);
|
ui->pushButton_wifiRefresh->setEnabled(true);
|
||||||
@ -1045,10 +1239,11 @@ void MainWindow::wifiTabSetEnabled(const bool state)
|
|||||||
|
|
||||||
void MainWindow::connectToUnknownEssid(const QString passwd)
|
void MainWindow::connectToUnknownEssid(const QString passwd)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[connectToUnknownEssid]";
|
||||||
|
|
||||||
if (!passwd.isEmpty())
|
if (!passwd.isEmpty())
|
||||||
delete passwdWid;
|
delete passwdWid;
|
||||||
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[connectToUnknownEssid]";
|
|
||||||
QMap<QString, QString> settings;
|
QMap<QString, QString> settings;
|
||||||
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
|
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
|
||||||
settings[QString("Interface")] = wpaCommand->getInterfaceList()[0];
|
settings[QString("Interface")] = wpaCommand->getInterfaceList()[0];
|
||||||
@ -1076,19 +1271,26 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
|
|||||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||||
else
|
else
|
||||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||||
|
|
||||||
updateWifiTab();
|
updateWifiTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::setHiddenName(const QString name)
|
void MainWindow::setHiddenName(const QString name)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[setHiddenName]";
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[setHiddenName]" << ":" << "Set name" << name;
|
||||||
|
|
||||||
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->setText(name);
|
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->setText(name);
|
||||||
|
|
||||||
wifiTabStart();
|
wifiTabStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::wifiTabStart()
|
void MainWindow::wifiTabStart()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[wifiTabStart]";
|
||||||
|
|
||||||
if (!checkExternalApps(QString("wpasup"))) {
|
if (!checkExternalApps(QString("wpasup"))) {
|
||||||
errorWin = new ErrorWindow(this, debug, 1);
|
errorWin = new ErrorWindow(this, debug, 1);
|
||||||
errorWin->show();
|
errorWin->show();
|
||||||
@ -1109,7 +1311,6 @@ void MainWindow::wifiTabStart()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[wifiTabStart]";
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
QString profile = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text();
|
QString profile = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text();
|
||||||
QString item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text();
|
QString item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text();
|
||||||
@ -1147,6 +1348,7 @@ void MainWindow::wifiTabStart()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateWifiTab();
|
updateWifiTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1154,6 +1356,8 @@ void MainWindow::wifiTabStart()
|
|||||||
void MainWindow::wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
void MainWindow::wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||||
{
|
{
|
||||||
Q_UNUSED(previous);
|
Q_UNUSED(previous);
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[wifiTabRefreshButtons]";
|
||||||
|
|
||||||
if (!checkExternalApps(QString("wpasup"))) {
|
if (!checkExternalApps(QString("wpasup"))) {
|
||||||
errorWin = new ErrorWindow(this, debug, 1);
|
errorWin = new ErrorWindow(this, debug, 1);
|
||||||
errorWin->show();
|
errorWin->show();
|
||||||
@ -1168,7 +1372,6 @@ void MainWindow::wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[wifiTabRefreshButtons]";
|
|
||||||
ui->pushButton_wifiStart->setEnabled(true);
|
ui->pushButton_wifiStart->setEnabled(true);
|
||||||
QString item = ui->tableWidget_wifi->item(current->row(), 1)->text();
|
QString item = ui->tableWidget_wifi->item(current->row(), 1)->text();
|
||||||
if (checkState(QString("exists"), item)) {
|
if (checkState(QString("exists"), item)) {
|
||||||
|
@ -55,9 +55,6 @@ public:
|
|||||||
const bool debugCmd = false,
|
const bool debugCmd = false,
|
||||||
const int tabNum = 1);
|
const int tabNum = 1);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
Netctl *netctlCommand;
|
|
||||||
NetctlProfile *netctlProfile;
|
|
||||||
WpaSup *wpaCommand;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateTabs(const int tab);
|
void updateTabs(const int tab);
|
||||||
@ -66,11 +63,19 @@ public slots:
|
|||||||
void setHiddenName(const QString name);
|
void setHiddenName(const QString name);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
// menu update slots
|
||||||
|
void setMenuActionsShown(const bool state = true);
|
||||||
|
void updateMenu();
|
||||||
|
void updateMenuMain();
|
||||||
|
void updateMenuProfile();
|
||||||
|
void updateMenuWifi();
|
||||||
|
// tab update slots
|
||||||
void updateMainTab();
|
void updateMainTab();
|
||||||
void updateProfileTab();
|
void updateProfileTab();
|
||||||
void updateWifiTab();
|
void updateWifiTab();
|
||||||
// main tab slots
|
// main tab slots
|
||||||
void mainTabContextualMenu(const QPoint &pos);
|
void mainTabContextualMenu(const QPoint &pos);
|
||||||
|
void mainTabEditProfile();
|
||||||
void mainTabRemoveProfile();
|
void mainTabRemoveProfile();
|
||||||
void mainTabEnableProfile();
|
void mainTabEnableProfile();
|
||||||
void mainTabRestartProfile();
|
void mainTabRestartProfile();
|
||||||
@ -82,6 +87,7 @@ private slots:
|
|||||||
void profileTabClear();
|
void profileTabClear();
|
||||||
void profileTabCreateProfile();
|
void profileTabCreateProfile();
|
||||||
void profileTabLoadProfile();
|
void profileTabLoadProfile();
|
||||||
|
void profileTabRemoveProfile();
|
||||||
// wifi tab slots
|
// wifi tab slots
|
||||||
void wifiTabContextualMenu(const QPoint &pos);
|
void wifiTabContextualMenu(const QPoint &pos);
|
||||||
void wifiTabSetEnabled(const bool state);
|
void wifiTabSetEnabled(const bool state);
|
||||||
@ -103,6 +109,9 @@ private:
|
|||||||
VlanWidget *vlanWid;
|
VlanWidget *vlanWid;
|
||||||
WirelessWidget *wirelessWid;
|
WirelessWidget *wirelessWid;
|
||||||
// backend
|
// backend
|
||||||
|
Netctl *netctlCommand;
|
||||||
|
NetctlProfile *netctlProfile;
|
||||||
|
WpaSup *wpaCommand;
|
||||||
ErrorWindow *errorWin;
|
ErrorWindow *errorWin;
|
||||||
PasswdWidget *passwdWid;
|
PasswdWidget *passwdWid;
|
||||||
SettingsWindow *settingsWin;
|
SettingsWindow *settingsWin;
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>487</width>
|
<width>483</width>
|
||||||
<height>515</height>
|
<height>511</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -89,16 +89,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_mainRemove">
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove</string>
|
|
||||||
</property>
|
|
||||||
<property name="autoDefault">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="spacer_mainButtons">
|
<spacer name="spacer_mainButtons">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -112,19 +102,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_mainEnable">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Enable</string>
|
|
||||||
</property>
|
|
||||||
<property name="autoDefault">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_mainRestart">
|
<widget class="QPushButton" name="pushButton_mainRestart">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
@ -203,8 +180,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>96</width>
|
<width>451</width>
|
||||||
<height>26</height>
|
<height>353</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -371,7 +348,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>487</width>
|
<width>483</width>
|
||||||
<height>22</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -382,12 +359,34 @@
|
|||||||
<addaction name="actionSettings"/>
|
<addaction name="actionSettings"/>
|
||||||
<addaction name="actionQuit"/>
|
<addaction name="actionQuit"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuActions">
|
||||||
|
<property name="title">
|
||||||
|
<string>Actions</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionMainRefresh"/>
|
||||||
|
<addaction name="actionWifiRefresh"/>
|
||||||
|
<addaction name="actionProfileClear"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionMainStart"/>
|
||||||
|
<addaction name="actionMainRestart"/>
|
||||||
|
<addaction name="actionMainEnable"/>
|
||||||
|
<addaction name="actionProfileLoad"/>
|
||||||
|
<addaction name="actionProfileSave"/>
|
||||||
|
<addaction name="actionWifiStart"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionMainEdit"/>
|
||||||
|
<addaction name="actionMainRemove"/>
|
||||||
|
<addaction name="actionProfileRemove"/>
|
||||||
|
</widget>
|
||||||
<addaction name="menuMenu"/>
|
<addaction name="menuMenu"/>
|
||||||
|
<addaction name="menuActions"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusBar"/>
|
<widget class="QStatusBar" name="statusBar"/>
|
||||||
<action name="actionSettings">
|
<action name="actionSettings">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="configure"/>
|
<iconset theme="configure">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Settings</string>
|
<string>Settings</string>
|
||||||
@ -398,7 +397,9 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionQuit">
|
<action name="actionQuit">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="exit"/>
|
<iconset theme="exit">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Quit</string>
|
<string>Quit</string>
|
||||||
@ -407,13 +408,104 @@
|
|||||||
<string>Ctrl+Q</string>
|
<string>Ctrl+Q</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionMainRefresh">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="stock-refresh"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Refresh</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionMainStart">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="dialog-apply"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Start profile</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionMainRestart">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="stock-refresh"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Restart profile</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionMainEnable">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable profile</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionMainEdit">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="edit"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Edit profile</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionMainRemove">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="edit-delete"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove profile</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionProfileClear">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="edit-clear"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Clear</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionWifiRefresh">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="stock-refresh"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Refresh</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionProfileLoad">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-open"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Load profile</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionProfileSave">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-save"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Save profile</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionWifiStart">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="dialog-apply"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Start Wi-Fi</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionProfileRemove">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="edit-delete"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove profile</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>tabWidget</tabstop>
|
<tabstop>tabWidget</tabstop>
|
||||||
<tabstop>tableWidget_main</tabstop>
|
<tabstop>tableWidget_main</tabstop>
|
||||||
<tabstop>pushButton_mainRefresh</tabstop>
|
<tabstop>pushButton_mainRefresh</tabstop>
|
||||||
<tabstop>pushButton_mainRemove</tabstop>
|
|
||||||
<tabstop>pushButton_mainEnable</tabstop>
|
|
||||||
<tabstop>pushButton_mainRestart</tabstop>
|
<tabstop>pushButton_mainRestart</tabstop>
|
||||||
<tabstop>pushButton_mainStart</tabstop>
|
<tabstop>pushButton_mainStart</tabstop>
|
||||||
<tabstop>lineEdit_profile</tabstop>
|
<tabstop>lineEdit_profile</tabstop>
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
|
#include "language.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
|
||||||
@ -41,12 +42,16 @@ SettingsWindow::SettingsWindow(MainWindow *wid, const bool debugCmd, const QStri
|
|||||||
|
|
||||||
SettingsWindow::~SettingsWindow()
|
SettingsWindow::~SettingsWindow()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[~SettingsWindow]";
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SettingsWindow::createActions()
|
void SettingsWindow::createActions()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[createActions]";
|
||||||
|
|
||||||
connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
|
connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
|
||||||
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(close()));
|
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
|
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
|
||||||
@ -66,6 +71,8 @@ void SettingsWindow::createActions()
|
|||||||
// ESC press event
|
// ESC press event
|
||||||
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[keyPressEvent]";
|
||||||
|
|
||||||
if (pressedKey->key() == Qt::Key_Escape)
|
if (pressedKey->key() == Qt::Key_Escape)
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@ -73,14 +80,17 @@ void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
|||||||
|
|
||||||
void SettingsWindow::addLanguages()
|
void SettingsWindow::addLanguages()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[addLanguages]";
|
||||||
|
|
||||||
ui->comboBox_language->clear();
|
ui->comboBox_language->clear();
|
||||||
ui->comboBox_language->addItem(QString("en"));
|
ui->comboBox_language->addItems(Language::getAvailableLanguages());
|
||||||
ui->comboBox_language->addItem(QString("ru"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SettingsWindow::saveSettings()
|
void SettingsWindow::saveSettings()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[saveSettings]";
|
||||||
|
|
||||||
QMap<QString, QString> settings = readSettings();
|
QMap<QString, QString> settings = readSettings();
|
||||||
QFile configFile(file);
|
QFile configFile(file);
|
||||||
|
|
||||||
@ -95,6 +105,8 @@ void SettingsWindow::saveSettings()
|
|||||||
|
|
||||||
void SettingsWindow::setDefault()
|
void SettingsWindow::setDefault()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[setDefault]";
|
||||||
|
|
||||||
setSettings(getDefault());
|
setSettings(getDefault());
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
@ -102,6 +114,8 @@ void SettingsWindow::setDefault()
|
|||||||
|
|
||||||
void SettingsWindow::selectIfaceDir()
|
void SettingsWindow::selectIfaceDir()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[selectIfaceDir]";
|
||||||
|
|
||||||
QString directory = QFileDialog::getExistingDirectory(
|
QString directory = QFileDialog::getExistingDirectory(
|
||||||
this,
|
this,
|
||||||
QApplication::translate("SettingsWindow", "Select path to directory with interfaces"),
|
QApplication::translate("SettingsWindow", "Select path to directory with interfaces"),
|
||||||
@ -113,6 +127,8 @@ void SettingsWindow::selectIfaceDir()
|
|||||||
|
|
||||||
void SettingsWindow::selectNetctlPath()
|
void SettingsWindow::selectNetctlPath()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[selectNetctlPath]";
|
||||||
|
|
||||||
QString filename = QFileDialog::getOpenFileName(
|
QString filename = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
QApplication::translate("SettingsWindow", "Select netctl command"),
|
QApplication::translate("SettingsWindow", "Select netctl command"),
|
||||||
@ -125,6 +141,8 @@ void SettingsWindow::selectNetctlPath()
|
|||||||
|
|
||||||
void SettingsWindow::selectProfileDir()
|
void SettingsWindow::selectProfileDir()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[selectProfileDir]";
|
||||||
|
|
||||||
QString directory = QFileDialog::getExistingDirectory(
|
QString directory = QFileDialog::getExistingDirectory(
|
||||||
this,
|
this,
|
||||||
QApplication::translate("SettingsWindow", "Select path to profile directory"),
|
QApplication::translate("SettingsWindow", "Select path to profile directory"),
|
||||||
@ -136,6 +154,8 @@ void SettingsWindow::selectProfileDir()
|
|||||||
|
|
||||||
void SettingsWindow::selectRfkillDir()
|
void SettingsWindow::selectRfkillDir()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[selectRfkillDir]";
|
||||||
|
|
||||||
QString directory = QFileDialog::getExistingDirectory(
|
QString directory = QFileDialog::getExistingDirectory(
|
||||||
this,
|
this,
|
||||||
QApplication::translate("SettingsWindow", "Select path to directory with rfkill devices"),
|
QApplication::translate("SettingsWindow", "Select path to directory with rfkill devices"),
|
||||||
@ -147,6 +167,8 @@ void SettingsWindow::selectRfkillDir()
|
|||||||
|
|
||||||
void SettingsWindow::selectSudoPath()
|
void SettingsWindow::selectSudoPath()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[selectSudoPath]";
|
||||||
|
|
||||||
QString filename = QFileDialog::getOpenFileName(
|
QString filename = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
QApplication::translate("SettingsWindow", "Select sudo command"),
|
QApplication::translate("SettingsWindow", "Select sudo command"),
|
||||||
@ -159,6 +181,8 @@ void SettingsWindow::selectSudoPath()
|
|||||||
|
|
||||||
void SettingsWindow::selectWpaCliPath()
|
void SettingsWindow::selectWpaCliPath()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaCliPath]";
|
||||||
|
|
||||||
QString filename = QFileDialog::getOpenFileName(
|
QString filename = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
QApplication::translate("SettingsWindow", "Select wpa_cli command"),
|
QApplication::translate("SettingsWindow", "Select wpa_cli command"),
|
||||||
@ -171,6 +195,8 @@ void SettingsWindow::selectWpaCliPath()
|
|||||||
|
|
||||||
void SettingsWindow::selectWpaSupPath()
|
void SettingsWindow::selectWpaSupPath()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaSupPath]";
|
||||||
|
|
||||||
QString filename = QFileDialog::getOpenFileName(
|
QString filename = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
QApplication::translate("SettingsWindow", "Select wpa_supplicant command"),
|
QApplication::translate("SettingsWindow", "Select wpa_supplicant command"),
|
||||||
@ -183,6 +209,8 @@ void SettingsWindow::selectWpaSupPath()
|
|||||||
|
|
||||||
void SettingsWindow::showWindow()
|
void SettingsWindow::showWindow()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[showWindow]";
|
||||||
|
|
||||||
setSettings(getSettings());
|
setSettings(getSettings());
|
||||||
ui->label_info->hide();
|
ui->label_info->hide();
|
||||||
show();
|
show();
|
||||||
@ -191,6 +219,8 @@ void SettingsWindow::showWindow()
|
|||||||
|
|
||||||
QMap<QString, QString> SettingsWindow::readSettings()
|
QMap<QString, QString> SettingsWindow::readSettings()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]";
|
||||||
|
|
||||||
QMap<QString, QString> settings;
|
QMap<QString, QString> settings;
|
||||||
|
|
||||||
settings[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
|
settings[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
|
||||||
@ -217,6 +247,8 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
|||||||
|
|
||||||
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]";
|
||||||
|
|
||||||
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
|
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
|
||||||
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
|
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
|
||||||
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
|
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
|
||||||
@ -242,6 +274,8 @@ void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
|||||||
|
|
||||||
QMap<QString, QString> SettingsWindow::getDefault()
|
QMap<QString, QString> SettingsWindow::getDefault()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]";
|
||||||
|
|
||||||
QMap<QString, QString> settings;
|
QMap<QString, QString> settings;
|
||||||
|
|
||||||
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
|
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
|
||||||
@ -268,6 +302,8 @@ QMap<QString, QString> SettingsWindow::getDefault()
|
|||||||
|
|
||||||
QMap<QString, QString> SettingsWindow::getSettings()
|
QMap<QString, QString> SettingsWindow::getSettings()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]";
|
||||||
|
|
||||||
QMap<QString, QString> settings;
|
QMap<QString, QString> settings;
|
||||||
QFile configFile(file);
|
QFile configFile(file);
|
||||||
QString fileStr;
|
QString fileStr;
|
||||||
|
13
sources/netctlgui/CMakeLists.txt
Normal file
13
sources/netctlgui/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# set project name
|
||||||
|
set (SUBPROJECT ${PROJECT_LIBRARY})
|
||||||
|
message (STATUS "Subproject ${SUBPROJECT}")
|
||||||
|
|
||||||
|
# set directories
|
||||||
|
set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
|
set (SUBPROJECT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
|
# additional targets
|
||||||
|
set (TARGETS "")
|
||||||
|
set (HEADERS "")
|
||||||
|
|
||||||
|
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
|
@ -23,15 +23,12 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
class MainWindow;
|
|
||||||
|
|
||||||
class Netctl : public QObject
|
class Netctl : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Netctl(MainWindow *wid = 0,
|
explicit Netctl(const bool debugCmd = false,
|
||||||
const bool debugCmd = false,
|
|
||||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||||
~Netctl();
|
~Netctl();
|
||||||
// general information
|
// general information
|
||||||
@ -49,7 +46,6 @@ public slots:
|
|||||||
bool startProfile(const QString profile);
|
bool startProfile(const QString profile);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainWindow *parent;
|
|
||||||
bool debug;
|
bool debug;
|
||||||
QString netctlCommand;
|
QString netctlCommand;
|
||||||
QDir *profileDirectory;
|
QDir *profileDirectory;
|
@ -23,24 +23,21 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
class MainWindow;
|
|
||||||
|
|
||||||
class NetctlProfile : public QObject
|
class NetctlProfile : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NetctlProfile(MainWindow *wid = 0,
|
explicit NetctlProfile(const bool debugCmd = false,
|
||||||
const bool debugCmd = false,
|
|
||||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||||
~NetctlProfile();
|
~NetctlProfile();
|
||||||
bool copyProfile(const QString oldPath);
|
bool copyProfile(const QString oldPath);
|
||||||
bool removeProfile(const QString profile);
|
bool removeProfile(const QString profile);
|
||||||
QString createProfile(const QString profile, const QMap<QString, QString> settings);
|
QString createProfile(const QString profile, const QMap<QString, QString> settings);
|
||||||
|
QString getNameByString(const QString profile);
|
||||||
QMap<QString, QString> getSettingsFromProfile(const QString profile);
|
QMap<QString, QString> getSettingsFromProfile(const QString profile);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainWindow *parent;
|
|
||||||
bool debug;
|
bool debug;
|
||||||
QDir *profileDirectory;
|
QDir *profileDirectory;
|
||||||
QString sudoCommand;
|
QString sudoCommand;
|
@ -23,15 +23,14 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
class MainWindow;
|
class Netctl;
|
||||||
|
|
||||||
class WpaSup : public QObject
|
class WpaSup : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WpaSup(MainWindow *wid = 0,
|
explicit WpaSup(const bool debugCmd = false,
|
||||||
const bool debugCmd = false,
|
|
||||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||||
~WpaSup();
|
~WpaSup();
|
||||||
// general information
|
// general information
|
||||||
@ -47,7 +46,7 @@ public slots:
|
|||||||
bool stopWpaSupplicant();
|
bool stopWpaSupplicant();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainWindow *parent;
|
Netctl *netctlCommand;
|
||||||
bool debug;
|
bool debug;
|
||||||
QString ctrlDir;
|
QString ctrlDir;
|
||||||
QString ctrlGroup;
|
QString ctrlGroup;
|
46
sources/netctlgui/src/CMakeLists.txt
Normal file
46
sources/netctlgui/src/CMakeLists.txt
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# set files
|
||||||
|
file (GLOB SOURCES *.cpp)
|
||||||
|
file (GLOB HEADERS ${SUBPROJECT_INCLUDE_DIR}/${SUBPROJECT}/*.h)
|
||||||
|
|
||||||
|
message (STATUS "${SUBPROJECT} Sources: ${SOURCES}")
|
||||||
|
message (STATUS "${SUBPROJECT} Headers: ${HEADERS}")
|
||||||
|
|
||||||
|
# include_path
|
||||||
|
include_directories (${SUBPROJECT_INCLUDE_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||||
|
${CMAKE_SOURCE_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
if (USE_QT5)
|
||||||
|
find_package(Qt5Core REQUIRED)
|
||||||
|
find_package(Qt5Widgets REQUIRED)
|
||||||
|
add_definitions(${Qt5Core_DEFINITIONS})
|
||||||
|
add_definitions(${Qt5Widgets_DEFINITIONS})
|
||||||
|
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||||
|
|
||||||
|
source_group ("Header Files" FILES ${HEADERS})
|
||||||
|
source_group ("Source Files" FILES ${SOURCES})
|
||||||
|
source_group ("Generated Files" FILES ${MOC_SOURCES})
|
||||||
|
|
||||||
|
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||||
|
add_library (${SUBPROJECT} SHARED ${SOURCES} ${HEADERS} ${MOC_SOURCES})
|
||||||
|
set_target_properties (${SUBPROJECT} PROPERTIES SOVERSION ${PROJECT_VERSION})
|
||||||
|
target_link_libraries (${SUBPROJECT} ${Qt5Widgets_LIBRARIES} ${Qt5Core_LIBRARIES})
|
||||||
|
else ()
|
||||||
|
find_package (Qt4 REQUIRED)
|
||||||
|
include (${QT_USE_FILE})
|
||||||
|
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||||
|
|
||||||
|
source_group ("Header Files" FILES ${HEADERS})
|
||||||
|
source_group ("Source Files" FILES ${SOURCES})
|
||||||
|
source_group ("Generated Files" FILES ${MOC_SOURCES})
|
||||||
|
|
||||||
|
add_library (${SUBPROJECT} SHARED ${SOURCES} ${HEADERS} ${MOC_SOURCES})
|
||||||
|
set_target_properties (${SUBPROJECT} PROPERTIES SOVERSION ${PROJECT_VERSION})
|
||||||
|
target_link_libraries (${SUBPROJECT} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# install properties
|
||||||
|
install (TARGETS ${SUBPROJECT} DESTINATION lib)
|
||||||
|
install (DIRECTORY ${SUBPROJECT_INCLUDE_DIR}/ DESTINATION include/)
|
28
sources/netctlgui/src/main.cpp
Normal file
28
sources/netctlgui/src/main.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 <netctlgui/netctlinteract.h>
|
||||||
|
#include <netctlgui/netctlprofile.h>
|
||||||
|
#include <netctlgui/sleepthread.h>
|
||||||
|
#include <netctlgui/wpasupinteract.h>
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
@ -15,18 +15,15 @@
|
|||||||
* 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 "netctlinteract.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include <netctlgui/netctlinteract.h>
|
||||||
|
|
||||||
|
|
||||||
Netctl::Netctl(MainWindow *wid, const bool debugCmd, const QMap<QString, QString> settings)
|
Netctl::Netctl(const bool debugCmd, const QMap<QString, QString> settings)
|
||||||
: parent(wid),
|
: debug(debugCmd)
|
||||||
debug(debugCmd)
|
|
||||||
{
|
{
|
||||||
netctlCommand = settings[QString("NETCTL_PATH")];
|
netctlCommand = settings[QString("NETCTL_PATH")];
|
||||||
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
||||||
@ -36,6 +33,8 @@ Netctl::Netctl(MainWindow *wid, const bool debugCmd, const QMap<QString, QString
|
|||||||
|
|
||||||
Netctl::~Netctl()
|
Netctl::~Netctl()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Netctl]" << "[~Netctl]";
|
||||||
|
|
||||||
delete profileDirectory;
|
delete profileDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +42,8 @@ Netctl::~Netctl()
|
|||||||
// functions
|
// functions
|
||||||
QString Netctl::getNetctlOutput(const bool sudo, const QString commandLine, const QString profile)
|
QString Netctl::getNetctlOutput(const bool sudo, const QString commandLine, const QString profile)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]";
|
||||||
|
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandText;
|
QString commandText;
|
||||||
if (sudo)
|
if (sudo)
|
||||||
@ -53,12 +54,15 @@ QString Netctl::getNetctlOutput(const bool sudo, const QString commandLine, cons
|
|||||||
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Run cmd" << commandText;
|
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Run cmd" << commandText;
|
||||||
command.start(commandText);
|
command.start(commandText);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
|
||||||
return command.readAllStandardOutput();
|
return command.readAllStandardOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QString profile)
|
bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QString profile)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Netctl]" << "[netctlCall]";
|
||||||
|
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandText;
|
QString commandText;
|
||||||
if (sudo)
|
if (sudo)
|
||||||
@ -70,6 +74,7 @@ bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QStrin
|
|||||||
command.start(commandText);
|
command.start(commandText);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Cmd returns" << command.exitCode();
|
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Cmd returns" << command.exitCode();
|
||||||
|
|
||||||
if (command.exitCode() == 0)
|
if (command.exitCode() == 0)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
@ -80,6 +85,8 @@ bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QStrin
|
|||||||
// general information
|
// general information
|
||||||
QList<QStringList> Netctl::getProfileList()
|
QList<QStringList> Netctl::getProfileList()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Netctl]" << "[getProfileList]";
|
||||||
|
|
||||||
QList<QStringList> fullProfilesInfo;
|
QList<QStringList> fullProfilesInfo;
|
||||||
QStringList profiles = profileDirectory->entryList(QDir::Files);
|
QStringList profiles = profileDirectory->entryList(QDir::Files);
|
||||||
QStringList descriptions = getProfileDescriptions(profiles);
|
QStringList descriptions = getProfileDescriptions(profiles);
|
||||||
@ -92,12 +99,14 @@ QList<QStringList> Netctl::getProfileList()
|
|||||||
profileInfo.append(statuses[i]);
|
profileInfo.append(statuses[i]);
|
||||||
fullProfilesInfo.append(profileInfo);
|
fullProfilesInfo.append(profileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fullProfilesInfo;
|
return fullProfilesInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList Netctl::getProfileDescriptions(const QStringList profileList)
|
QStringList Netctl::getProfileDescriptions(const QStringList profileList)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]";
|
||||||
QStringList descriptions;
|
QStringList descriptions;
|
||||||
|
|
||||||
for (int i=0; i<profileList.count(); i++) {
|
for (int i=0; i<profileList.count(); i++) {
|
||||||
@ -130,6 +139,8 @@ QStringList Netctl::getProfileDescriptions(const QStringList profileList)
|
|||||||
|
|
||||||
QStringList Netctl::getProfileStatuses(const QStringList profileList)
|
QStringList Netctl::getProfileStatuses(const QStringList profileList)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Netctl]" << "[getProfileStatuses]";
|
||||||
|
|
||||||
QStringList statuses;
|
QStringList statuses;
|
||||||
|
|
||||||
for (int i=0; i<profileList.count(); i++) {
|
for (int i=0; i<profileList.count(); i++) {
|
||||||
@ -151,6 +162,8 @@ QStringList Netctl::getProfileStatuses(const QStringList profileList)
|
|||||||
|
|
||||||
QString Netctl::getSsidFromProfile(const QString profile)
|
QString Netctl::getSsidFromProfile(const QString profile)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]";
|
||||||
|
|
||||||
QString ssidName = QString("");
|
QString ssidName = QString("");
|
||||||
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
|
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
|
||||||
if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Check" << profileUrl;
|
if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Check" << profileUrl;
|
||||||
@ -180,17 +193,22 @@ QString Netctl::getSsidFromProfile(const QString profile)
|
|||||||
|
|
||||||
bool Netctl::isProfileActive(const QString profile)
|
bool Netctl::isProfileActive(const QString profile)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Netctl]" << "[isProfileActive]";
|
||||||
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
QString cmdOutput = getNetctlOutput(false, QString("status"), profile);
|
QString cmdOutput = getNetctlOutput(false, QString("status"), profile);
|
||||||
if (!cmdOutput.isEmpty())
|
if (!cmdOutput.isEmpty())
|
||||||
if (cmdOutput.contains(QString("Active: active")))
|
if (cmdOutput.contains(QString("Active: active")))
|
||||||
status = true;
|
status = true;
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Netctl::isProfileEnabled(const QString profile)
|
bool Netctl::isProfileEnabled(const QString profile)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Netctl]" << "[isProfileEnabled]";
|
||||||
|
|
||||||
return netctlCall(false, QString("is-enabled"), profile);
|
return netctlCall(false, QString("is-enabled"), profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +216,8 @@ bool Netctl::isProfileEnabled(const QString profile)
|
|||||||
// functions
|
// functions
|
||||||
bool Netctl::enableProfile(const QString profile)
|
bool Netctl::enableProfile(const QString profile)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Netctl]" << "[enableProfile]";
|
||||||
|
|
||||||
if (isProfileEnabled(profile))
|
if (isProfileEnabled(profile))
|
||||||
return netctlCall(true, QString("disable"), profile);
|
return netctlCall(true, QString("disable"), profile);
|
||||||
else
|
else
|
||||||
@ -207,12 +227,16 @@ bool Netctl::enableProfile(const QString profile)
|
|||||||
|
|
||||||
bool Netctl::restartProfile(const QString profile)
|
bool Netctl::restartProfile(const QString profile)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Netctl]" << "[restartProfile]";
|
||||||
|
|
||||||
return netctlCall(true, QString("restart"), profile);
|
return netctlCall(true, QString("restart"), profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Netctl::startProfile(const QString profile)
|
bool Netctl::startProfile(const QString profile)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Netctl]" << "[startProfile]";
|
||||||
|
|
||||||
if (isProfileActive(profile))
|
if (isProfileActive(profile))
|
||||||
return netctlCall(true, QString("stop"), profile);
|
return netctlCall(true, QString("stop"), profile);
|
||||||
else
|
else
|
@ -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 "netctlprofile.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -23,12 +22,11 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include <netctlgui/netctlprofile.h>
|
||||||
|
|
||||||
|
|
||||||
NetctlProfile::NetctlProfile(MainWindow *wid, const bool debugCmd, const QMap<QString, QString> settings)
|
NetctlProfile::NetctlProfile(const bool debugCmd, const QMap<QString, QString> settings)
|
||||||
: parent(wid),
|
: debug(debugCmd)
|
||||||
debug(debugCmd)
|
|
||||||
{
|
{
|
||||||
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
||||||
sudoCommand = settings[QString("SUDO_PATH")];
|
sudoCommand = settings[QString("SUDO_PATH")];
|
||||||
@ -37,18 +35,23 @@ NetctlProfile::NetctlProfile(MainWindow *wid, const bool debugCmd, const QMap<QS
|
|||||||
|
|
||||||
NetctlProfile::~NetctlProfile()
|
NetctlProfile::~NetctlProfile()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[NetctlProfile]" << "[~NetctlProfile]";
|
||||||
|
|
||||||
delete profileDirectory;
|
delete profileDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NetctlProfile::copyProfile(const QString oldPath)
|
bool NetctlProfile::copyProfile(const QString oldPath)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]";
|
||||||
|
|
||||||
QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
|
QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandText = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath;
|
QString commandText = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath;
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << commandText;
|
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << commandText;
|
||||||
command.start(commandText);
|
command.start(commandText);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
|
||||||
if (command.exitCode() == 0)
|
if (command.exitCode() == 0)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
@ -58,12 +61,15 @@ bool NetctlProfile::copyProfile(const QString oldPath)
|
|||||||
|
|
||||||
bool NetctlProfile::removeProfile(const QString profile)
|
bool NetctlProfile::removeProfile(const QString profile)
|
||||||
{
|
{
|
||||||
QString profilePath = profileDirectory->absolutePath() + QDir::separator() + profile;
|
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]";
|
||||||
|
|
||||||
|
QString profilePath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandText = sudoCommand + QString(" /usr/bin/rm ") + profilePath;
|
QString commandText = sudoCommand + QString(" /usr/bin/rm ") + profilePath;
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Run cmd" << commandText;
|
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Run cmd" << commandText;
|
||||||
command.start(commandText);
|
command.start(commandText);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
|
||||||
if (command.exitCode() == 0)
|
if (command.exitCode() == 0)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
@ -74,6 +80,8 @@ bool NetctlProfile::removeProfile(const QString profile)
|
|||||||
|
|
||||||
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings)
|
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]";
|
||||||
|
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Profile name" << profile;
|
||||||
|
|
||||||
QString profileTempName = QDir::homePath() + QDir::separator() +
|
QString profileTempName = QDir::homePath() + QDir::separator() +
|
||||||
QString(".cache") + QDir::separator() + QFileInfo(profile).fileName();
|
QString(".cache") + QDir::separator() + QFileInfo(profile).fileName();
|
||||||
@ -107,14 +115,22 @@ QString NetctlProfile::createProfile(const QString profile, const QMap<QString,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString NetctlProfile::getNameByString(const QString profile)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[NetctlProfile]" << "[getNameByString]";
|
||||||
|
if (debug) qDebug() << "[NetctlProfile]" << "[getNameByString]" << ":" << "Raw string" << profile;
|
||||||
|
|
||||||
|
return QFileInfo(profile).fileName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile)
|
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]";
|
||||||
|
|
||||||
QMap<QString, QString> settings;
|
QMap<QString, QString> settings;
|
||||||
QString fileStr, profileUrl;
|
QString fileStr, profileUrl;
|
||||||
if (profile[0] == QDir::separator())
|
profileUrl = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
|
||||||
profileUrl = profile;
|
|
||||||
else
|
|
||||||
profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
|
|
||||||
QFile profileFile(profileUrl);
|
QFile profileFile(profileUrl);
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Read from" << profileUrl;
|
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Read from" << profileUrl;
|
||||||
|
|
@ -15,20 +15,19 @@
|
|||||||
* 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 "wpasupinteract.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include <netctlgui/netctlinteract.h>
|
||||||
#include "netctlinteract.h"
|
#include <netctlgui/sleepthread.h>
|
||||||
#include "sleepthread.h"
|
#include <netctlgui/wpasupinteract.h>
|
||||||
|
|
||||||
|
|
||||||
WpaSup::WpaSup(MainWindow *wid, const bool debugCmd, const QMap<QString, QString> settings)
|
WpaSup::WpaSup(const bool debugCmd, const QMap<QString, QString> settings)
|
||||||
: parent(wid),
|
: debug(debugCmd)
|
||||||
debug(debugCmd)
|
|
||||||
{
|
{
|
||||||
|
netctlCommand = new Netctl(debug, settings);
|
||||||
|
|
||||||
ctrlDir = settings[QString("CTRL_DIR")];
|
ctrlDir = settings[QString("CTRL_DIR")];
|
||||||
ctrlGroup = settings[QString("CTRL_GROUP")];
|
ctrlGroup = settings[QString("CTRL_GROUP")];
|
||||||
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
|
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
|
||||||
@ -47,6 +46,9 @@ WpaSup::WpaSup(MainWindow *wid, const bool debugCmd, const QMap<QString, QString
|
|||||||
|
|
||||||
WpaSup::~WpaSup()
|
WpaSup::~WpaSup()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[~WpaSup]";
|
||||||
|
|
||||||
|
delete netctlCommand;
|
||||||
delete ifaceDirectory;
|
delete ifaceDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,17 +56,22 @@ WpaSup::~WpaSup()
|
|||||||
// general information
|
// general information
|
||||||
QString WpaSup::existentProfile(const QString profile)
|
QString WpaSup::existentProfile(const QString profile)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]";
|
||||||
|
|
||||||
QString profileFile = QString("");
|
QString profileFile = QString("");
|
||||||
QList<QStringList> profileList = parent->netctlCommand->getProfileList();
|
QList<QStringList> profileList = netctlCommand->getProfileList();
|
||||||
for (int i=0; i<profileList.count(); i++)
|
for (int i=0; i<profileList.count(); i++)
|
||||||
if (profile == parent->netctlCommand->getSsidFromProfile(profileList[i][0]))
|
if (profile == netctlCommand->getSsidFromProfile(profileList[i][0]))
|
||||||
profileFile = profileList[i][0];
|
profileFile = profileList[i][0];
|
||||||
|
|
||||||
return profileFile;
|
return profileFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList WpaSup::getInterfaceList()
|
QStringList WpaSup::getInterfaceList()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[getInterfaceList]";
|
||||||
|
|
||||||
QStringList interfaces;
|
QStringList interfaces;
|
||||||
|
|
||||||
if (!mainInterface.isEmpty())
|
if (!mainInterface.isEmpty())
|
||||||
@ -84,22 +91,28 @@ QStringList WpaSup::getInterfaceList()
|
|||||||
|
|
||||||
bool WpaSup::isProfileActive(const QString profile)
|
bool WpaSup::isProfileActive(const QString profile)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]";
|
||||||
|
|
||||||
QString profileFile;
|
QString profileFile;
|
||||||
QList<QStringList> profileList = parent->netctlCommand->getProfileList();
|
QList<QStringList> profileList = netctlCommand->getProfileList();
|
||||||
for (int i=0; i<profileList.count(); i++)
|
for (int i=0; i<profileList.count(); i++)
|
||||||
if (profile == parent->netctlCommand->getSsidFromProfile(profileList[i][0]))
|
if (profile == netctlCommand->getSsidFromProfile(profileList[i][0]))
|
||||||
profileFile = profileList[i][0];
|
profileFile = profileList[i][0];
|
||||||
return parent->netctlCommand->isProfileActive(profileFile);
|
|
||||||
|
return netctlCommand->isProfileActive(profileFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool WpaSup::isProfileExists(const QString profile)
|
bool WpaSup::isProfileExists(const QString profile)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]";
|
||||||
|
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
QList<QStringList> profileList = parent->netctlCommand->getProfileList();
|
QList<QStringList> profileList = netctlCommand->getProfileList();
|
||||||
for (int i=0; i<profileList.count(); i++)
|
for (int i=0; i<profileList.count(); i++)
|
||||||
if (profile == parent->netctlCommand->getSsidFromProfile(profileList[i][0]))
|
if (profile == netctlCommand->getSsidFromProfile(profileList[i][0]))
|
||||||
exists = true;
|
exists = true;
|
||||||
|
|
||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +120,8 @@ bool WpaSup::isProfileExists(const QString profile)
|
|||||||
// functions
|
// functions
|
||||||
bool WpaSup::wpaCliCall(const QString commandLine)
|
bool WpaSup::wpaCliCall(const QString commandLine)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[getInterfaceList]";
|
||||||
|
|
||||||
QString interface = getInterfaceList()[0];
|
QString interface = getInterfaceList()[0];
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
|
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
|
||||||
@ -125,6 +140,8 @@ bool WpaSup::wpaCliCall(const QString commandLine)
|
|||||||
|
|
||||||
QString WpaSup::getWpaCliOutput(const QString commandLine)
|
QString WpaSup::getWpaCliOutput(const QString commandLine)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]";
|
||||||
|
|
||||||
QString interface = getInterfaceList()[0];
|
QString interface = getInterfaceList()[0];
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
|
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
|
||||||
@ -132,12 +149,15 @@ QString WpaSup::getWpaCliOutput(const QString commandLine)
|
|||||||
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << commandText;
|
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << commandText;
|
||||||
command.start(commandText);
|
command.start(commandText);
|
||||||
command.waitForFinished(-1);
|
command.waitForFinished(-1);
|
||||||
|
|
||||||
return command.readAllStandardOutput();
|
return command.readAllStandardOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<QStringList> WpaSup::scanWifi()
|
QList<QStringList> WpaSup::scanWifi()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[scanWifi]";
|
||||||
|
|
||||||
QList<QStringList> scanResults;
|
QList<QStringList> scanResults;
|
||||||
if (!startWpaSupplicant()) {
|
if (!startWpaSupplicant()) {
|
||||||
stopWpaSupplicant();
|
stopWpaSupplicant();
|
||||||
@ -208,6 +228,8 @@ QList<QStringList> WpaSup::scanWifi()
|
|||||||
|
|
||||||
bool WpaSup::startWpaSupplicant()
|
bool WpaSup::startWpaSupplicant()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]";
|
||||||
|
|
||||||
if (!QFile(pidFile).exists()) {
|
if (!QFile(pidFile).exists()) {
|
||||||
QString interface = getInterfaceList()[0];
|
QString interface = getInterfaceList()[0];
|
||||||
QProcess command;
|
QProcess command;
|
||||||
@ -222,11 +244,14 @@ bool WpaSup::startWpaSupplicant()
|
|||||||
if (command.exitCode() != 0)
|
if (command.exitCode() != 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool WpaSup::stopWpaSupplicant()
|
bool WpaSup::stopWpaSupplicant()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[WpaSup]" << "[stopWpaSupplicant]";
|
||||||
|
|
||||||
return wpaCliCall(QString("terminate"));
|
return wpaCliCall(QString("terminate"));
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user