mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
implement #37
This commit is contained in:
parent
bf7521481a
commit
308f9824b4
@ -72,3 +72,30 @@ QString checkStatus(const bool statusBool, const bool nullFalse)
|
||||
|
||||
return QString("");
|
||||
}
|
||||
|
||||
|
||||
QStringList externalApps(const QString apps, const QMap<QString, QString> configuration)
|
||||
{
|
||||
QStringList app;
|
||||
if ((apps == QString("helper")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("HELPER_PATH")]);
|
||||
}
|
||||
if ((apps == QString("netctl")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("NETCTL_PATH")]);
|
||||
app.append(configuration[QString("NETCTLAUTO_PATH")]);
|
||||
app.append(configuration[QString("SUDO_PATH")]);
|
||||
}
|
||||
if ((apps == QString("sudo")) || (apps == QString("wpasup")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("SUDO_PATH")]);
|
||||
}
|
||||
if ((apps == QString("systemctl")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("SYSTEMCTL_PATH")]);
|
||||
app.append(configuration[QString("SUDO_PATH")]);
|
||||
}
|
||||
if ((apps == QString("wpasup")) || (apps == QString("wpasup-only")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("WPACLI_PATH")]);
|
||||
app.append(configuration[QString("WPASUP_PATH")]);
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
@ -19,13 +19,15 @@
|
||||
#define COMMONFUNCTIONS_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
bool checkExternalApps(const QString apps = QString("all"),
|
||||
const QMap<QString, QString> configuration = QMap<QString, QString>(),
|
||||
const bool debug = false);
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||
QStringList externalApps(const QString apps,
|
||||
const QMap<QString, QString> configuration = QMap<QString, QString>());
|
||||
|
||||
|
||||
#endif /* COMMONFUNCTIONS_H */
|
||||
|
@ -186,9 +186,10 @@ void ErrorWindow::showWindow(const int mess, const QString sender, const bool de
|
||||
QMessageBox messageBox;
|
||||
messageBox.setText(message[0]);
|
||||
messageBox.setInformativeText(message[1]);
|
||||
if (debugCmd)
|
||||
messageBox.setDetailedText(QApplication::translate("ErrorWindow", "Sender : %1").
|
||||
arg(sender));
|
||||
if (mess == 1)
|
||||
messageBox.setDetailedText(sender);
|
||||
else if (debugCmd)
|
||||
messageBox.setDetailedText(QApplication::translate("ErrorWindow", "Sender : %1").arg(sender));
|
||||
messageBox.setIcon(errorWin->getIcon(mess));
|
||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||
|
@ -147,7 +147,7 @@ void MainWidget::updateMainTab()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ void MainWidget::mainTabEnableProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
@ -332,7 +332,7 @@ void MainWidget::mainTabRestartProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
@ -351,7 +351,7 @@ void MainWidget::mainTabStartProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
@ -370,7 +370,7 @@ void MainWidget::mainTabStopAllProfiles()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
@ -387,7 +387,7 @@ void MainWidget::mainTabSwitchToProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
@ -268,7 +268,7 @@ bool MainWindow::forceStartHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("helper"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
|
||||
ErrorWindow::showWindow(1, externalApps(QString("helper"), configuration).join(QChar('\n')), debug);
|
||||
emit(needToBeConfigured());
|
||||
return false;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ void WiFiMenuWidget::updateText(const netctlWifiInfo current)
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!wifiTabSetEnabled(checkExternalApps(QString("wpasup-only"), configuration, debug))) return;
|
||||
if (!checkExternalApps(QString("wpasup"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
|
||||
ErrorWindow::showWindow(1, externalApps(QString("wpasup"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
ui->label_wifi->setText(QApplication::translate("WiFiMenuWidget", "Processing..."));
|
||||
@ -202,7 +202,7 @@ void WiFiMenuWidget::updateWifiTab()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!wifiTabSetEnabled(checkExternalApps(QString("wpasup-only"), configuration, debug))) return;
|
||||
if (!checkExternalApps(QString("wpasup"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
|
||||
ErrorWindow::showWindow(1, externalApps(QString("wpasup"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
@ -374,7 +374,7 @@ void WiFiMenuWidget::wifiTabStart()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("wpasup"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, QString(PDEBUG), debug);
|
||||
ErrorWindow::showWindow(1, externalApps(QString("wpasup"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_wifi->currentItem() == nullptr) return;
|
||||
|
Loading…
Reference in New Issue
Block a user