diff --git a/CHANGELOG b/CHANGELOG
index ddffe5e..29aba6f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -20,6 +20,7 @@ Ver.1.2.0:
* [gui] changed lineEdit_profile to comboBox
* [gui] refactoring of configuration interface
* [gui] changed setting of the interface to profile tab
+* [gui] rewrited ErrorWindow class
* [lib] more debug information
* [lib] rewrited getSettingsFromProfile() function
* [plasmoid] edited configuration interface
diff --git a/sources/gui/src/errorwindow.cpp b/sources/gui/src/errorwindow.cpp
index dea2186..3f74b53 100644
--- a/sources/gui/src/errorwindow.cpp
+++ b/sources/gui/src/errorwindow.cpp
@@ -106,6 +106,14 @@ QStringList ErrorWindow::getMessage(const int mess)
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Empty user/group name");
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:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Unknown error");
@@ -174,6 +182,12 @@ QMessageBox::Icon ErrorWindow::getIcon(const int mess)
case 16:
icon = QMessageBox::Critical;
break;
+ case 17:
+ icon = QMessageBox::Critical;
+ break;
+ case 18:
+ icon = QMessageBox::Critical;
+ break;
default:
icon = QMessageBox::NoIcon;
break;
diff --git a/sources/gui/src/errorwindow.ui b/sources/gui/src/errorwindow.ui
deleted file mode 100644
index 2e55c85..0000000
--- a/sources/gui/src/errorwindow.ui
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
- ErrorWindow
-
-
-
- 0
- 0
- 287
- 101
-
-
-
- Error
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 10
-
-
-
-
- -
-
-
-
-
-
-
- 0
- 30
-
-
-
- Error text
-
-
- Qt::AlignCenter
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 10
-
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Ok
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
-
-
-
-
-
- pushButton
- clicked(bool)
- ErrorWindow
- close()
-
-
- 143
- 83
-
-
- 252
- 80
-
-
-
-
-
diff --git a/sources/gui/src/main.cpp b/sources/gui/src/main.cpp
index 85c33d5..1482292 100644
--- a/sources/gui/src/main.cpp
+++ b/sources/gui/src/main.cpp
@@ -52,35 +52,30 @@ int main(int argc, char *argv[])
a.installTranslator(&translator);
// reading command line flags
- bool debug = false;
- bool defaultSettings = false;
bool error = false;
+ // windows
bool showAbout = false;
- bool showHelp = false;
- bool showInfo = false;
bool showNetctlAuto = false;
bool showSettings = false;
- bool showVersion = false;
+ // main functions
+ QString selectEssid = QString("ESSID");
QString openProfile = QString("PROFILE");
+ QString selectProfile = QString("PROFILE");
+ // additional functions
+ bool debug = false;
+ bool defaultSettings = false;
int tabNumber = 1;
+ // messages
+ bool showVersion = false;
+ bool showInfo = false;
+ bool showHelp = false;
+ // reading
for (int i=1; i 3)
@@ -99,6 +119,7 @@ int main(int argc, char *argv[])
tabNumber = atoi(argv[i+1]);
i++;
}
+ // messages
// version message
else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
showVersion = true;
@@ -115,44 +136,64 @@ int main(int argc, char *argv[])
error = true;
}
}
+ if (selectEssid != QString("ESSID"))
+ tabNumber = 3;
if (openProfile != QString("PROFILE"))
tabNumber = 2;
+ if (selectProfile != QString("PROFILE"))
+ tabNumber = 1;
// messages
QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n");
QString helpMessage = QString("");
- helpMessage += QApplication::translate("MainWindow", "Usage:\n");
- helpMessage += QString("netctl-gui [ --about ] [ -d | --debug ] [ --default ] [ -o PROFILE | --open PROFILE ]\n");
- helpMessage += QString(" [ --netctl-auto ] [ --settings ] [ -t NUM | --tab NUM ] [ -v | --version ]\n");
- helpMessage += QString(" [ -i | --info ] [ -h | --help]\n\n");
- helpMessage += QApplication::translate("MainWindow", "Parametrs:\n");
- helpMessage += QString("%1 --about - %2\n")
+ helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Usage:"));
+ helpMessage += QString("netctl-gui [ --about ] [ --netctl-auto ] [ --settings ]\n");
+ helpMessage += QString(" [ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]\n");
+ helpMessage += QString(" [ -s PROFILE | --select PROFILE ]\n");
+ helpMessage += QString(" [ -d | --debug ] [ --default ] [ -t NUM | --tab NUM ]\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(QApplication::translate("MainWindow", "show about window"));
- 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(" -o %1 --open %1 - %2\n")
- .arg(openProfile)
- .arg(QApplication::translate("MainWindow", "open profile %1").arg(openProfile));
- helpMessage += QString("%1 --netctl-auto - %2\n")
+ helpMessage += QString("%1 --netctl-auto - %2\n")
.arg(isParametrEnable(showNetctlAuto))
.arg(QApplication::translate("MainWindow", "show netctl-auto window"));
- helpMessage += QString("%1 --settings - %2\n")
+ helpMessage += QString("%1 --settings - %2\n")
.arg(isParametrEnable(showSettings))
.arg(QApplication::translate("MainWindow", "show settings window"));
- helpMessage += QString(" -t %1 --tab %1 - %2\n")
- .arg(QString::number(tabNumber))
+ // main functions
+ 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)));
- 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"));
- helpMessage += QString(" -i --info - %1\n")
+ helpMessage += QString(" -i --info - %1\n")
.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"));
QString infoMessage = QString("");
@@ -192,7 +233,10 @@ int main(int argc, char *argv[])
cout << versionMessage.toUtf8().data();
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();
return a.exec();
}
diff --git a/sources/gui/src/mainwindow.cpp b/sources/gui/src/mainwindow.cpp
index eea7095..0b58bfb 100644
--- a/sources/gui/src/mainwindow.cpp
+++ b/sources/gui/src/mainwindow.cpp
@@ -46,27 +46,30 @@
MainWindow::MainWindow(QWidget *parent,
- const bool debugCmd,
- const bool defaultSettings,
const bool showAbout,
const bool showNetctlAuto,
const bool showSettings,
- const int tabNum,
- const QString openProfile)
+ const QString selectEssid,
+ const QString openProfile,
+ const QString selectProfile,
+ const bool debugCmd,
+ const bool defaultSettings,
+ const int tabNum)
: QMainWindow(parent),
ui(new Ui::MainWindow),
debug(debugCmd)
{
- if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "debug" << debug;
- if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "defaultSettings" << defaultSettings;
+ if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showAbout" << showAbout;
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showNetctlAuto" << showNetctlAuto;
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]" << ":" << "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);
- ui->tabWidget->setCurrentIndex(tabNum-1);
-
+ // reading configuration
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
QDir::separator() + QString("netctl-gui.conf");
settingsWin = new SettingsWindow(this, debug, configPath);
@@ -74,8 +77,14 @@ MainWindow::MainWindow(QWidget *parent,
settingsWin->setDefault();
configuration = settingsWin->getSettings();
- // gui
+ // backend
+ netctlCommand = new Netctl(debug, configuration);
+ netctlProfile = new NetctlProfile(debug, configuration);
+ wpaCommand = new WpaSup(debug, configuration);
+ // frontend
// windows
+ ui->setupUi(this);
+ ui->tabWidget->setCurrentIndex(tabNum-1);
aboutWin = new AboutWindow(this, debug);
errorWin = new ErrorWindow(this, debug);
netctlAutoWin = new NetctlAutoWindow(this, debug, configuration);
@@ -102,21 +111,10 @@ MainWindow::MainWindow(QWidget *parent,
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
wirelessWid = new WirelessWidget(this, configuration);
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
- // backend
- netctlCommand = new Netctl(debug, configuration);
- netctlProfile = new NetctlProfile(debug, configuration);
- wpaCommand = new WpaSup(debug, configuration);
createActions();
setIconsToButtons();
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)
aboutWin->show();
@@ -124,6 +122,27 @@ MainWindow::MainWindow(QWidget *parent,
netctlAutoWin->showWindow();
if (showSettings)
settingsWin->showWindow();
+
+ if (selectEssid != QString("ESSID")) {
+ for (int i=0; itableWidget_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; itableWidget_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->comboBox_profile->addItem(profile);
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count()-1);
-
- profileTabLoadProfile();
}
@@ -1077,7 +1094,11 @@ void MainWindow::profileTabLoadProfile()
if (debug) qDebug() << "[MainWindow]" << "[profileTabLoadProfile]";
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
+ if (profile.isEmpty())
+ return;
QMap settings = netctlProfile->getSettingsFromProfile(profile);
+ if (settings.isEmpty())
+ return errorWin->showWindow(17, QString("[MainWindow] : [profileTabLoadProfile]"));
generalWid->setSettings(settings);
if (generalWid->connectionType->currentText() == QString("ethernet")) {
diff --git a/sources/gui/src/mainwindow.h b/sources/gui/src/mainwindow.h
index c9296eb..4bd2088 100644
--- a/sources/gui/src/mainwindow.h
+++ b/sources/gui/src/mainwindow.h
@@ -53,13 +53,15 @@ class MainWindow : public QMainWindow
public:
explicit MainWindow(QWidget *parent = 0,
- const bool debugCmd = false,
- const bool defaultSettings = false,
const bool showAbout = false,
const bool showNetctlAuto = false,
const bool showSettings = false,
- const int tabNum = 1,
- const QString openProfile = QString("PROFILE"));
+ const QString selectEssid = QString("ESSID"),
+ const QString openProfile = QString("PROFILE"),
+ const QString selectProfile = QString("PROFILE"),
+ const bool debugCmd = false,
+ const bool defaultSettings = false,
+ const int tabNum = 1);
~MainWindow();
public slots:
diff --git a/sources/netctlgui/src/netctlprofile.cpp b/sources/netctlgui/src/netctlprofile.cpp
index 3b871db..bebe2c4 100644
--- a/sources/netctlgui/src/netctlprofile.cpp
+++ b/sources/netctlgui/src/netctlprofile.cpp
@@ -116,20 +116,33 @@ QMap NetctlProfile::getSettingsFromProfile(const QString profi
}
// getting variables list
- QMap settings;
+ // system variables
QProcess shell;
- QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
- QString cmd = QString("env -i bash -c \"source ") + profileUrl + QString("; set\"");
+ QString cmd = QString("env -i bash -c \"set\"");
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Run cmd" << cmd;
shell.start(cmd);
shell.waitForFinished(-1);
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Cmd returns" << shell.exitCode();
QStringList output = QString(shell.readAllStandardOutput()).trimmed().split(QChar('\n'));
+ QStringList systemVariables;
+ systemVariables.append(QString("PIPESTATUS"));
+ for (int i=0; i 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
QStringList keys;
for (int i=0; i