mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
added flags
This commit is contained in:
parent
79fc70efa1
commit
ea522b3864
@ -20,6 +20,7 @@ Ver.1.2.0:
|
|||||||
* [gui] changed lineEdit_profile to comboBox
|
* [gui] changed lineEdit_profile to comboBox
|
||||||
* [gui] refactoring of configuration interface
|
* [gui] refactoring of configuration interface
|
||||||
* [gui] changed setting of the interface to profile tab
|
* [gui] changed setting of the interface to profile tab
|
||||||
|
* [gui] rewrited ErrorWindow class
|
||||||
* [lib] more debug information
|
* [lib] more debug information
|
||||||
* [lib] rewrited getSettingsFromProfile() function
|
* [lib] rewrited getSettingsFromProfile() function
|
||||||
* [plasmoid] edited configuration interface
|
* [plasmoid] edited configuration interface
|
||||||
|
@ -106,6 +106,14 @@ QStringList ErrorWindow::getMessage(const int mess)
|
|||||||
title = QApplication::translate("ErrorWindow", "Error!");
|
title = QApplication::translate("ErrorWindow", "Error!");
|
||||||
message = QApplication::translate("ErrorWindow", "Empty user/group name");
|
message = QApplication::translate("ErrorWindow", "Empty user/group name");
|
||||||
break;
|
break;
|
||||||
|
case 17:
|
||||||
|
title = QApplication::translate("ErrorWindow", "Error!");
|
||||||
|
message = QApplication::translate("ErrorWindow", "Could not find profile");
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
title = QApplication::translate("ErrorWindow", "Error!");
|
||||||
|
message = QApplication::translate("ErrorWindow", "Could not find ESSID");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
title = QApplication::translate("ErrorWindow", "Error!");
|
title = QApplication::translate("ErrorWindow", "Error!");
|
||||||
message = QApplication::translate("ErrorWindow", "Unknown error");
|
message = QApplication::translate("ErrorWindow", "Unknown error");
|
||||||
@ -174,6 +182,12 @@ QMessageBox::Icon ErrorWindow::getIcon(const int mess)
|
|||||||
case 16:
|
case 16:
|
||||||
icon = QMessageBox::Critical;
|
icon = QMessageBox::Critical;
|
||||||
break;
|
break;
|
||||||
|
case 17:
|
||||||
|
icon = QMessageBox::Critical;
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
icon = QMessageBox::Critical;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
icon = QMessageBox::NoIcon;
|
icon = QMessageBox::NoIcon;
|
||||||
break;
|
break;
|
||||||
|
@ -1,123 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>ErrorWindow</class>
|
|
||||||
<widget class="QMainWindow" name="ErrorWindow">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>287</width>
|
|
||||||
<height>101</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Error</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="centralwidget">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<spacer name="spacer2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>10</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="layout_main">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>30</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Error text</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="spacer1">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>10</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="layout_button">
|
|
||||||
<item>
|
|
||||||
<spacer name="spacer_button1">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Ok</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="spacer_button2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>pushButton</sender>
|
|
||||||
<signal>clicked(bool)</signal>
|
|
||||||
<receiver>ErrorWindow</receiver>
|
|
||||||
<slot>close()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>143</x>
|
|
||||||
<y>83</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>252</x>
|
|
||||||
<y>80</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
@ -52,35 +52,30 @@ int main(int argc, char *argv[])
|
|||||||
a.installTranslator(&translator);
|
a.installTranslator(&translator);
|
||||||
|
|
||||||
// reading command line flags
|
// reading command line flags
|
||||||
bool debug = false;
|
|
||||||
bool defaultSettings = false;
|
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
// windows
|
||||||
bool showAbout = false;
|
bool showAbout = false;
|
||||||
bool showHelp = false;
|
|
||||||
bool showInfo = false;
|
|
||||||
bool showNetctlAuto = false;
|
bool showNetctlAuto = false;
|
||||||
bool showSettings = false;
|
bool showSettings = false;
|
||||||
bool showVersion = false;
|
// main functions
|
||||||
|
QString selectEssid = QString("ESSID");
|
||||||
QString openProfile = QString("PROFILE");
|
QString openProfile = QString("PROFILE");
|
||||||
|
QString selectProfile = QString("PROFILE");
|
||||||
|
// additional functions
|
||||||
|
bool debug = false;
|
||||||
|
bool defaultSettings = false;
|
||||||
int tabNumber = 1;
|
int tabNumber = 1;
|
||||||
|
// messages
|
||||||
|
bool showVersion = false;
|
||||||
|
bool showInfo = false;
|
||||||
|
bool showHelp = false;
|
||||||
|
// reading
|
||||||
for (int i=1; i<argc; i++) {
|
for (int i=1; i<argc; i++) {
|
||||||
|
// windows
|
||||||
// about
|
// about
|
||||||
if (QString(argv[i]) == QString("--about")) {
|
if (QString(argv[i]) == QString("--about")) {
|
||||||
showAbout = true;
|
showAbout = true;
|
||||||
}
|
}
|
||||||
// debug
|
|
||||||
else if ((QString(argv[i]) == QString("-d")) || (QString(argv[i]) == QString("--debug"))) {
|
|
||||||
debug = true;
|
|
||||||
}
|
|
||||||
// default settings
|
|
||||||
else if (QString(argv[i]) == QString("--default")) {
|
|
||||||
defaultSettings = true;
|
|
||||||
}
|
|
||||||
// default settings
|
|
||||||
else if ((QString(argv[i]) == QString("-o")) || (QString(argv[i]) == QString("--open"))) {
|
|
||||||
openProfile = QString(argv[i+1]);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
// netctl-auto
|
// netctl-auto
|
||||||
else if (QString(argv[i]) == QString("--netctl-auto")) {
|
else if (QString(argv[i]) == QString("--netctl-auto")) {
|
||||||
showNetctlAuto = true;
|
showNetctlAuto = true;
|
||||||
@ -89,6 +84,31 @@ int main(int argc, char *argv[])
|
|||||||
else if (QString(argv[i]) == QString("--settings")) {
|
else if (QString(argv[i]) == QString("--settings")) {
|
||||||
showSettings = true;
|
showSettings = true;
|
||||||
}
|
}
|
||||||
|
// main functions
|
||||||
|
// select ESSID
|
||||||
|
else if ((QString(argv[i]) == QString("-e")) || (QString(argv[i]) == QString("--essid"))) {
|
||||||
|
selectEssid = QString(argv[i+1]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
// open profile
|
||||||
|
else if ((QString(argv[i]) == QString("-o")) || (QString(argv[i]) == QString("--open"))) {
|
||||||
|
openProfile = QString(argv[i+1]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
// select profile
|
||||||
|
else if ((QString(argv[i]) == QString("-s")) || (QString(argv[i]) == QString("--select"))) {
|
||||||
|
selectProfile = QString(argv[i+1]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
// additional functions
|
||||||
|
// debug
|
||||||
|
else if ((QString(argv[i]) == QString("-d")) || (QString(argv[i]) == QString("--debug"))) {
|
||||||
|
debug = true;
|
||||||
|
}
|
||||||
|
// default settings
|
||||||
|
else if (QString(argv[i]) == QString("--default")) {
|
||||||
|
defaultSettings = true;
|
||||||
|
}
|
||||||
// tab number
|
// tab number
|
||||||
else if ((QString(argv[i]) == QString("-t")) || (QString(argv[i]) == QString("--tab"))) {
|
else if ((QString(argv[i]) == QString("-t")) || (QString(argv[i]) == QString("--tab"))) {
|
||||||
if (atoi(argv[i+1]) > 3)
|
if (atoi(argv[i+1]) > 3)
|
||||||
@ -99,6 +119,7 @@ int main(int argc, char *argv[])
|
|||||||
tabNumber = atoi(argv[i+1]);
|
tabNumber = atoi(argv[i+1]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
// messages
|
||||||
// version message
|
// version message
|
||||||
else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
|
else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
|
||||||
showVersion = true;
|
showVersion = true;
|
||||||
@ -115,44 +136,64 @@ int main(int argc, char *argv[])
|
|||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (selectEssid != QString("ESSID"))
|
||||||
|
tabNumber = 3;
|
||||||
if (openProfile != QString("PROFILE"))
|
if (openProfile != QString("PROFILE"))
|
||||||
tabNumber = 2;
|
tabNumber = 2;
|
||||||
|
if (selectProfile != QString("PROFILE"))
|
||||||
|
tabNumber = 1;
|
||||||
|
|
||||||
// messages
|
// messages
|
||||||
QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n");
|
QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n");
|
||||||
|
|
||||||
QString helpMessage = QString("");
|
QString helpMessage = QString("");
|
||||||
helpMessage += QApplication::translate("MainWindow", "Usage:\n");
|
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Usage:"));
|
||||||
helpMessage += QString("netctl-gui [ --about ] [ -d | --debug ] [ --default ] [ -o PROFILE | --open PROFILE ]\n");
|
helpMessage += QString("netctl-gui [ --about ] [ --netctl-auto ] [ --settings ]\n");
|
||||||
helpMessage += QString(" [ --netctl-auto ] [ --settings ] [ -t NUM | --tab NUM ] [ -v | --version ]\n");
|
helpMessage += QString(" [ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]\n");
|
||||||
helpMessage += QString(" [ -i | --info ] [ -h | --help]\n\n");
|
helpMessage += QString(" [ -s PROFILE | --select PROFILE ]\n");
|
||||||
helpMessage += QApplication::translate("MainWindow", "Parametrs:\n");
|
helpMessage += QString(" [ -d | --debug ] [ --default ] [ -t NUM | --tab NUM ]\n");
|
||||||
helpMessage += QString("%1 --about - %2\n")
|
helpMessage += QString(" [ -v | --version ] [ -i | --info ] [ -h | --help]\n\n");
|
||||||
|
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Parametrs:"));
|
||||||
|
// windows
|
||||||
|
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Open window:"));
|
||||||
|
helpMessage += QString("%1 --about - %2\n")
|
||||||
.arg(isParametrEnable(showAbout))
|
.arg(isParametrEnable(showAbout))
|
||||||
.arg(QApplication::translate("MainWindow", "show about window"));
|
.arg(QApplication::translate("MainWindow", "show about window"));
|
||||||
helpMessage += QString("%1 -d --debug - %2\n")
|
helpMessage += QString("%1 --netctl-auto - %2\n")
|
||||||
.arg(isParametrEnable(debug))
|
|
||||||
.arg(QApplication::translate("MainWindow", "print debug information"));
|
|
||||||
helpMessage += QString("%1 --default - %2\n")
|
|
||||||
.arg(isParametrEnable(defaultSettings))
|
|
||||||
.arg(QApplication::translate("MainWindow", "start with default settings"));
|
|
||||||
helpMessage += QString(" -o %1 --open %1 - %2\n")
|
|
||||||
.arg(openProfile)
|
|
||||||
.arg(QApplication::translate("MainWindow", "open profile %1").arg(openProfile));
|
|
||||||
helpMessage += QString("%1 --netctl-auto - %2\n")
|
|
||||||
.arg(isParametrEnable(showNetctlAuto))
|
.arg(isParametrEnable(showNetctlAuto))
|
||||||
.arg(QApplication::translate("MainWindow", "show netctl-auto window"));
|
.arg(QApplication::translate("MainWindow", "show netctl-auto window"));
|
||||||
helpMessage += QString("%1 --settings - %2\n")
|
helpMessage += QString("%1 --settings - %2\n")
|
||||||
.arg(isParametrEnable(showSettings))
|
.arg(isParametrEnable(showSettings))
|
||||||
.arg(QApplication::translate("MainWindow", "show settings window"));
|
.arg(QApplication::translate("MainWindow", "show settings window"));
|
||||||
helpMessage += QString(" -t %1 --tab %1 - %2\n")
|
// main functions
|
||||||
.arg(QString::number(tabNumber))
|
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Functions:"));
|
||||||
|
helpMessage += QString(" -e %1 --essid %1 - %2\n")
|
||||||
|
.arg(selectEssid, -10)
|
||||||
|
.arg(QApplication::translate("MainWindow", "select ESSID %1").arg(selectEssid));
|
||||||
|
helpMessage += QString(" -o %1 --open %1 - %2\n")
|
||||||
|
.arg(openProfile, -10)
|
||||||
|
.arg(QApplication::translate("MainWindow", "open profile %1").arg(openProfile));
|
||||||
|
helpMessage += QString(" -s %1 --select %1 - %2\n")
|
||||||
|
.arg(selectProfile, -10)
|
||||||
|
.arg(QApplication::translate("MainWindow", "select profile %1").arg(selectProfile));
|
||||||
|
// additional functions
|
||||||
|
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Additional flags:"));
|
||||||
|
helpMessage += QString("%1 -d --debug - %2\n")
|
||||||
|
.arg(isParametrEnable(debug))
|
||||||
|
.arg(QApplication::translate("MainWindow", "print debug information"));
|
||||||
|
helpMessage += QString("%1 --default - %2\n")
|
||||||
|
.arg(isParametrEnable(defaultSettings))
|
||||||
|
.arg(QApplication::translate("MainWindow", "start with default settings"));
|
||||||
|
helpMessage += QString(" -t %1 --tab %1 - %2\n")
|
||||||
|
.arg(QString::number(tabNumber), -3)
|
||||||
.arg(QApplication::translate("MainWindow", "open a tab with number %1").arg(QString::number(tabNumber)));
|
.arg(QApplication::translate("MainWindow", "open a tab with number %1").arg(QString::number(tabNumber)));
|
||||||
helpMessage += QString(" -v --version - %1\n")
|
// messages
|
||||||
|
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Show messages:"));
|
||||||
|
helpMessage += QString(" -v --version - %1\n")
|
||||||
.arg(QApplication::translate("MainWindow", "show version and exit"));
|
.arg(QApplication::translate("MainWindow", "show version and exit"));
|
||||||
helpMessage += QString(" -i --info - %1\n")
|
helpMessage += QString(" -i --info - %1\n")
|
||||||
.arg(QApplication::translate("MainWindow", "show build information and exit"));
|
.arg(QApplication::translate("MainWindow", "show build information and exit"));
|
||||||
helpMessage += QString(" -h --help - %1\n")
|
helpMessage += QString(" -h --help - %1\n")
|
||||||
.arg(QApplication::translate("MainWindow", "show this help and exit"));
|
.arg(QApplication::translate("MainWindow", "show this help and exit"));
|
||||||
|
|
||||||
QString infoMessage = QString("");
|
QString infoMessage = QString("");
|
||||||
@ -192,7 +233,10 @@ int main(int argc, char *argv[])
|
|||||||
cout << versionMessage.toUtf8().data();
|
cout << versionMessage.toUtf8().data();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
MainWindow w(0, debug, defaultSettings, showAbout, showNetctlAuto, showSettings, tabNumber, openProfile);
|
MainWindow w(0,
|
||||||
|
showAbout, showNetctlAuto, showSettings,
|
||||||
|
selectEssid, openProfile, selectProfile,
|
||||||
|
debug, defaultSettings, tabNumber);
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
@ -46,27 +46,30 @@
|
|||||||
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent,
|
MainWindow::MainWindow(QWidget *parent,
|
||||||
const bool debugCmd,
|
|
||||||
const bool defaultSettings,
|
|
||||||
const bool showAbout,
|
const bool showAbout,
|
||||||
const bool showNetctlAuto,
|
const bool showNetctlAuto,
|
||||||
const bool showSettings,
|
const bool showSettings,
|
||||||
const int tabNum,
|
const QString selectEssid,
|
||||||
const QString openProfile)
|
const QString openProfile,
|
||||||
|
const QString selectProfile,
|
||||||
|
const bool debugCmd,
|
||||||
|
const bool defaultSettings,
|
||||||
|
const int tabNum)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow),
|
ui(new Ui::MainWindow),
|
||||||
debug(debugCmd)
|
debug(debugCmd)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "debug" << debug;
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showAbout" << showAbout;
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "defaultSettings" << defaultSettings;
|
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showNetctlAuto" << showNetctlAuto;
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showNetctlAuto" << showNetctlAuto;
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showSettings" << showSettings;
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showSettings" << showSettings;
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "tabNum" << tabNum;
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "selectEssid" << selectEssid;
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "openProfile" << openProfile;
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "openProfile" << openProfile;
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "selectProfile" << selectProfile;
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "debug" << debug;
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "defaultSettings" << defaultSettings;
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "tabNum" << tabNum;
|
||||||
|
|
||||||
ui->setupUi(this);
|
// reading configuration
|
||||||
ui->tabWidget->setCurrentIndex(tabNum-1);
|
|
||||||
|
|
||||||
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
|
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
|
||||||
QDir::separator() + QString("netctl-gui.conf");
|
QDir::separator() + QString("netctl-gui.conf");
|
||||||
settingsWin = new SettingsWindow(this, debug, configPath);
|
settingsWin = new SettingsWindow(this, debug, configPath);
|
||||||
@ -74,8 +77,14 @@ MainWindow::MainWindow(QWidget *parent,
|
|||||||
settingsWin->setDefault();
|
settingsWin->setDefault();
|
||||||
configuration = settingsWin->getSettings();
|
configuration = settingsWin->getSettings();
|
||||||
|
|
||||||
// gui
|
// backend
|
||||||
|
netctlCommand = new Netctl(debug, configuration);
|
||||||
|
netctlProfile = new NetctlProfile(debug, configuration);
|
||||||
|
wpaCommand = new WpaSup(debug, configuration);
|
||||||
|
// frontend
|
||||||
// windows
|
// windows
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->tabWidget->setCurrentIndex(tabNum-1);
|
||||||
aboutWin = new AboutWindow(this, debug);
|
aboutWin = new AboutWindow(this, debug);
|
||||||
errorWin = new ErrorWindow(this, debug);
|
errorWin = new ErrorWindow(this, debug);
|
||||||
netctlAutoWin = new NetctlAutoWindow(this, debug, configuration);
|
netctlAutoWin = new NetctlAutoWindow(this, debug, configuration);
|
||||||
@ -102,21 +111,10 @@ MainWindow::MainWindow(QWidget *parent,
|
|||||||
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
|
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
|
||||||
wirelessWid = new WirelessWidget(this, configuration);
|
wirelessWid = new WirelessWidget(this, configuration);
|
||||||
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
|
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
|
||||||
// backend
|
|
||||||
netctlCommand = new Netctl(debug, configuration);
|
|
||||||
netctlProfile = new NetctlProfile(debug, configuration);
|
|
||||||
wpaCommand = new WpaSup(debug, configuration);
|
|
||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
setIconsToButtons();
|
setIconsToButtons();
|
||||||
updateTabs(ui->tabWidget->currentIndex());
|
updateTabs(ui->tabWidget->currentIndex());
|
||||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready"));
|
|
||||||
|
|
||||||
if (openProfile != QString("PROFILE")) {
|
|
||||||
ui->comboBox_profile->addItem(openProfile);
|
|
||||||
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count()-1);
|
|
||||||
profileTabLoadProfile();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showAbout)
|
if (showAbout)
|
||||||
aboutWin->show();
|
aboutWin->show();
|
||||||
@ -124,6 +122,27 @@ MainWindow::MainWindow(QWidget *parent,
|
|||||||
netctlAutoWin->showWindow();
|
netctlAutoWin->showWindow();
|
||||||
if (showSettings)
|
if (showSettings)
|
||||||
settingsWin->showWindow();
|
settingsWin->showWindow();
|
||||||
|
|
||||||
|
if (selectEssid != QString("ESSID")) {
|
||||||
|
for (int i=0; i<ui->tableWidget_wifi->rowCount(); i++)
|
||||||
|
if (ui->tableWidget_wifi->item(i, 0)->text() == selectEssid)
|
||||||
|
ui->tableWidget_wifi->setCurrentCell(i, 0);
|
||||||
|
if (ui->tableWidget_wifi->currentItem() == 0)
|
||||||
|
errorWin->showWindow(18, QString("[MainWindow] : [MainWindow]"));
|
||||||
|
}
|
||||||
|
else if (openProfile != QString("PROFILE")) {
|
||||||
|
ui->comboBox_profile->addItem(openProfile);
|
||||||
|
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count()-1);
|
||||||
|
}
|
||||||
|
else if (selectProfile != QString("PROFILE")) {
|
||||||
|
for (int i=0; i<ui->tableWidget_main->rowCount(); i++)
|
||||||
|
if (ui->tableWidget_main->item(i, 0)->text() == selectProfile)
|
||||||
|
ui->tableWidget_main->setCurrentCell(i, 0);
|
||||||
|
if (ui->tableWidget_main->currentItem() == 0)
|
||||||
|
errorWin->showWindow(17, QString("[MainWindow] : [MainWindow]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -608,8 +627,6 @@ void MainWindow::mainTabEditProfile()
|
|||||||
ui->tabWidget->setCurrentIndex(1);
|
ui->tabWidget->setCurrentIndex(1);
|
||||||
ui->comboBox_profile->addItem(profile);
|
ui->comboBox_profile->addItem(profile);
|
||||||
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count()-1);
|
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count()-1);
|
||||||
|
|
||||||
profileTabLoadProfile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1077,7 +1094,11 @@ void MainWindow::profileTabLoadProfile()
|
|||||||
if (debug) qDebug() << "[MainWindow]" << "[profileTabLoadProfile]";
|
if (debug) qDebug() << "[MainWindow]" << "[profileTabLoadProfile]";
|
||||||
|
|
||||||
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
|
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
|
||||||
|
if (profile.isEmpty())
|
||||||
|
return;
|
||||||
QMap<QString, QString> settings = netctlProfile->getSettingsFromProfile(profile);
|
QMap<QString, QString> settings = netctlProfile->getSettingsFromProfile(profile);
|
||||||
|
if (settings.isEmpty())
|
||||||
|
return errorWin->showWindow(17, QString("[MainWindow] : [profileTabLoadProfile]"));
|
||||||
|
|
||||||
generalWid->setSettings(settings);
|
generalWid->setSettings(settings);
|
||||||
if (generalWid->connectionType->currentText() == QString("ethernet")) {
|
if (generalWid->connectionType->currentText() == QString("ethernet")) {
|
||||||
|
@ -53,13 +53,15 @@ class MainWindow : public QMainWindow
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = 0,
|
explicit MainWindow(QWidget *parent = 0,
|
||||||
const bool debugCmd = false,
|
|
||||||
const bool defaultSettings = false,
|
|
||||||
const bool showAbout = false,
|
const bool showAbout = false,
|
||||||
const bool showNetctlAuto = false,
|
const bool showNetctlAuto = false,
|
||||||
const bool showSettings = false,
|
const bool showSettings = false,
|
||||||
const int tabNum = 1,
|
const QString selectEssid = QString("ESSID"),
|
||||||
const QString openProfile = QString("PROFILE"));
|
const QString openProfile = QString("PROFILE"),
|
||||||
|
const QString selectProfile = QString("PROFILE"),
|
||||||
|
const bool debugCmd = false,
|
||||||
|
const bool defaultSettings = false,
|
||||||
|
const int tabNum = 1);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -116,20 +116,33 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getting variables list
|
// getting variables list
|
||||||
QMap<QString, QString> settings;
|
// system variables
|
||||||
QProcess shell;
|
QProcess shell;
|
||||||
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
|
QString cmd = QString("env -i bash -c \"set\"");
|
||||||
QString cmd = QString("env -i bash -c \"source ") + profileUrl + QString("; set\"");
|
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Run cmd" << cmd;
|
||||||
shell.start(cmd);
|
shell.start(cmd);
|
||||||
shell.waitForFinished(-1);
|
shell.waitForFinished(-1);
|
||||||
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Cmd returns" << shell.exitCode();
|
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Cmd returns" << shell.exitCode();
|
||||||
QStringList output = QString(shell.readAllStandardOutput()).trimmed().split(QChar('\n'));
|
QStringList output = QString(shell.readAllStandardOutput()).trimmed().split(QChar('\n'));
|
||||||
|
QStringList systemVariables;
|
||||||
|
systemVariables.append(QString("PIPESTATUS"));
|
||||||
|
for (int i=0; i<output.count(); i++)
|
||||||
|
systemVariables.append(output[i].split(QChar('='))[0]);
|
||||||
|
// profile variables
|
||||||
|
QMap<QString, QString> settings;
|
||||||
|
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
|
||||||
|
cmd = QString("env -i bash -c \"source ") + profileUrl + QString("; set\"");
|
||||||
|
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Run cmd" << cmd;
|
||||||
|
shell.start(cmd);
|
||||||
|
shell.waitForFinished(-1);
|
||||||
|
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Cmd returns" << shell.exitCode();
|
||||||
|
output = QString(shell.readAllStandardOutput()).trimmed().split(QChar('\n'));
|
||||||
|
|
||||||
// gettings variables
|
// gettings variables
|
||||||
QStringList keys;
|
QStringList keys;
|
||||||
for (int i=0; i<output.count(); i++)
|
for (int i=0; i<output.count(); i++)
|
||||||
keys.append(output[i].split(QChar('='))[0]);
|
if (!systemVariables.contains(output[i].split(QChar('='))[0]))
|
||||||
|
keys.append(output[i].split(QChar('='))[0]);
|
||||||
for (int i=0; i<keys.count(); i++){
|
for (int i=0; i<keys.count(); i++){
|
||||||
cmd = QString("env -i bash -c \"source ") + profileUrl +
|
cmd = QString("env -i bash -c \"source ") + profileUrl +
|
||||||
QString("; for i in ${!") + keys[i] + QString("[@]}; do echo ${") +
|
QString("; for i in ${!") + keys[i] + QString("[@]}; do echo ${") +
|
||||||
|
Loading…
Reference in New Issue
Block a user