mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-25 07:57:20 +00:00
added --set-opts
This commit is contained in:
parent
39b8ff834f
commit
51659c7a42
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required (VERSION 3.0)
|
cmake_minimum_required (VERSION 2.8)
|
||||||
|
|
||||||
cmake_policy (SET CMP0003 OLD)
|
cmake_policy (SET CMP0003 OLD)
|
||||||
cmake_policy (SET CMP0002 OLD)
|
cmake_policy (SET CMP0002 OLD)
|
||||||
@ -14,6 +14,7 @@ set (PROJECT_VERSION_MINOR 2)
|
|||||||
set (PROJECT_VERSION_PATCH 0)
|
set (PROJECT_VERSION_PATCH 0)
|
||||||
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||||
string (TIMESTAMP CURRENT_DATE UTC)
|
string (TIMESTAMP CURRENT_DATE UTC)
|
||||||
|
string (REGEX REPLACE "T|Z" " " CURRENT_DATE ${CURRENT_DATE})
|
||||||
string (TIMESTAMP CURRENT_YEAR "%Y")
|
string (TIMESTAMP CURRENT_YEAR "%Y")
|
||||||
|
|
||||||
message (STATUS "Project: ${PROJECT_NAME}")
|
message (STATUS "Project: ${PROJECT_NAME}")
|
||||||
@ -22,10 +23,14 @@ message (STATUS "Build date: ${CURRENT_DATE}")
|
|||||||
|
|
||||||
# install options
|
# install options
|
||||||
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
|
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
|
||||||
|
option (BUILD_DOCS "Build documentation" OFF)
|
||||||
option (BUILD_GUI "Build GUI" ON)
|
option (BUILD_GUI "Build GUI" ON)
|
||||||
option (BUILD_LIBRARY "Build library" 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_DOCS)
|
||||||
|
set (BUILD_LIBRARY ON)
|
||||||
|
endif ()
|
||||||
if (BUILD_GUI)
|
if (BUILD_GUI)
|
||||||
set (BUILD_LIBRARY ON)
|
set (BUILD_LIBRARY ON)
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -6,7 +6,8 @@ netctl-gui is a graphical interface for netctl
|
|||||||
[ --about ] [ --netctl-auto ] [ --settings ]
|
[ --about ] [ --netctl-auto ] [ --settings ]
|
||||||
[ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]
|
[ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]
|
||||||
[ -s PROFILE | --select PROFILE ]
|
[ -s PROFILE | --select PROFILE ]
|
||||||
[ -d | --debug ] [ --default ] [ -t NUM | --tab NUM ]
|
[ -d | --debug ] [ --default ] [ --set-opts OPTIONS ]
|
||||||
|
[ -t NUM | --tab NUM ]
|
||||||
[ -v | --version ] [ -i | --info ] [ -h | --help]
|
[ -v | --version ] [ -i | --info ] [ -h | --help]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Graphical user interface for netctl written on C++ using Qt toolkit. Provides shared library for interaction with netctl and Plasmoid and DataEngine for KDE.
|
Graphical user interface for netctl written on C++ using Qt toolkit. Provides shared library for interaction with netctl and Plasmoid and DataEngine for KDE.
|
||||||
@ -25,10 +26,10 @@ show settings window
|
|||||||
select ESSID ESSID. This option will set tab to 3 automatically
|
select ESSID ESSID. This option will set tab to 3 automatically
|
||||||
.TP
|
.TP
|
||||||
-o, --open PROFILE
|
-o, --open PROFILE
|
||||||
open profile PROFILE. This option will set tab to 2 automatically.
|
open profile PROFILE. This option will set tab to 2 automatically
|
||||||
.TP
|
.TP
|
||||||
-s, --select PROFILE
|
-s, --select PROFILE
|
||||||
select profile PROFILE. This option will set tab to 1 automatically.
|
select profile PROFILE. This option will set tab to 1 automatically
|
||||||
.TP
|
.TP
|
||||||
-d, --debug
|
-d, --debug
|
||||||
print debug information
|
print debug information
|
||||||
@ -36,6 +37,9 @@ print debug information
|
|||||||
--default
|
--default
|
||||||
start with default settings
|
start with default settings
|
||||||
.TP
|
.TP
|
||||||
|
--set-opts OPTIONS
|
||||||
|
set options OPTIONS for this run, comma separated. Example "LANGUAGE=en,NETCTL_PATH=/usr/bin/netctl"
|
||||||
|
.TP
|
||||||
-t, --tab NUM
|
-t, --tab NUM
|
||||||
open a tab with number NUM
|
open a tab with number NUM
|
||||||
.TP
|
.TP
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
|
||||||
|
|
||||||
Language::Language(const QString configPath)
|
Language::Language()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,8 +41,13 @@ QString Language::checkLanguage(const QString language, const QString defaultLan
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Language::defineLanguage(const QString configPath)
|
QString Language::defineLanguage(const QString configPath, const QString options)
|
||||||
{
|
{
|
||||||
|
QMap<QString, QString> optionsDict = parseOptions(options);
|
||||||
|
if (optionsDict.contains(QString("LANGUAGE")))
|
||||||
|
if (getAvailableLanguages().contains(optionsDict[QString("LANGUAGE")]))
|
||||||
|
return optionsDict[QString("LANGUAGE")];
|
||||||
|
|
||||||
QString language;
|
QString language;
|
||||||
language = defineLanguageFromFile(configPath);
|
language = defineLanguageFromFile(configPath);
|
||||||
if (language.isEmpty())
|
if (language.isEmpty())
|
||||||
@ -92,3 +97,17 @@ QStringList Language::getAvailableLanguages()
|
|||||||
|
|
||||||
return languages;
|
return languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QMap<QString, QString> Language::parseOptions(const QString options)
|
||||||
|
{
|
||||||
|
QMap<QString, QString> optionsDict;
|
||||||
|
for (int i=0; i<options.split(QChar(',')).count(); i++) {
|
||||||
|
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2)
|
||||||
|
continue;
|
||||||
|
optionsDict[options.split(QChar(','))[i].split(QChar('='))[0]] =
|
||||||
|
options.split(QChar(','))[i].split(QChar('='))[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return optionsDict;
|
||||||
|
}
|
||||||
|
@ -26,13 +26,17 @@ class Language : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Language(const QString configPath);
|
explicit Language();
|
||||||
static QString checkLanguage(const QString language,
|
static QString checkLanguage(const QString language,
|
||||||
const QString defaultLanguage = QString("en"));
|
const QString defaultLanguage = QString("en"));
|
||||||
static QString defineLanguage(const QString configPath);
|
static QString defineLanguage(const QString configPath,
|
||||||
|
const QString options = QString("OPTIONS"));
|
||||||
static QString defineLanguageFromFile(const QString configPath);
|
static QString defineLanguageFromFile(const QString configPath);
|
||||||
static QString defineLanguageFromLocale();
|
static QString defineLanguageFromLocale();
|
||||||
static QStringList getAvailableLanguages();
|
static QStringList getAvailableLanguages();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static QMap<QString, QString> parseOptions(const QString options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ int main(int argc, char *argv[])
|
|||||||
// additional functions
|
// additional functions
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
bool defaultSettings = false;
|
bool defaultSettings = false;
|
||||||
|
QString options = QString("OPTIONS");
|
||||||
int tabNumber = 1;
|
int tabNumber = 1;
|
||||||
// messages
|
// messages
|
||||||
bool showVersion = false;
|
bool showVersion = false;
|
||||||
@ -109,6 +110,11 @@ int main(int argc, char *argv[])
|
|||||||
else if (QString(argv[i]) == QString("--default")) {
|
else if (QString(argv[i]) == QString("--default")) {
|
||||||
defaultSettings = true;
|
defaultSettings = true;
|
||||||
}
|
}
|
||||||
|
// options
|
||||||
|
else if (QString(argv[i]) == QString("--set-opts")) {
|
||||||
|
options = QString(argv[i+1]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
// 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)
|
||||||
@ -151,7 +157,8 @@ int main(int argc, char *argv[])
|
|||||||
helpMessage += QString("netctl-gui [ --about ] [ --netctl-auto ] [ --settings ]\n");
|
helpMessage += QString("netctl-gui [ --about ] [ --netctl-auto ] [ --settings ]\n");
|
||||||
helpMessage += QString(" [ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]\n");
|
helpMessage += QString(" [ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]\n");
|
||||||
helpMessage += QString(" [ -s PROFILE | --select PROFILE ]\n");
|
helpMessage += QString(" [ -s PROFILE | --select PROFILE ]\n");
|
||||||
helpMessage += QString(" [ -d | --debug ] [ --default ] [ -t NUM | --tab NUM ]\n");
|
helpMessage += QString(" [ -d | --debug ] [ --default ] [ --set-opts OPTIONS ]\n");
|
||||||
|
helpMessage += QString(" [ -t NUM | --tab NUM ]\n");
|
||||||
helpMessage += QString(" [ -v | --version ] [ -i | --info ] [ -h | --help]\n\n");
|
helpMessage += QString(" [ -v | --version ] [ -i | --info ] [ -h | --help]\n\n");
|
||||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Parametrs:"));
|
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Parametrs:"));
|
||||||
// windows
|
// windows
|
||||||
@ -184,6 +191,10 @@ int main(int argc, char *argv[])
|
|||||||
helpMessage += QString("%1 --default - %2\n")
|
helpMessage += QString("%1 --default - %2\n")
|
||||||
.arg(isParametrEnable(defaultSettings))
|
.arg(isParametrEnable(defaultSettings))
|
||||||
.arg(QApplication::translate("MainWindow", "start with default settings"));
|
.arg(QApplication::translate("MainWindow", "start with default settings"));
|
||||||
|
helpMessage += QString(" --set-opts %1\n")
|
||||||
|
.arg(options, -10);
|
||||||
|
helpMessage += QString(" - %1\n")
|
||||||
|
.arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
|
||||||
helpMessage += QString(" -t %1 --tab %1 - %2\n")
|
helpMessage += QString(" -t %1 --tab %1 - %2\n")
|
||||||
.arg(QString::number(tabNumber), -3)
|
.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)));
|
||||||
@ -202,6 +213,7 @@ int main(int argc, char *argv[])
|
|||||||
infoMessage += QString("\n%1\n").arg(QApplication::translate("MainWindow", "cmake flags:"));
|
infoMessage += QString("\n%1\n").arg(QApplication::translate("MainWindow", "cmake flags:"));
|
||||||
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1 \\\n").arg(QString(CMAKE_BUILD_TYPE));
|
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1 \\\n").arg(QString(CMAKE_BUILD_TYPE));
|
||||||
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1 \\\n").arg(QString(CMAKE_INSTALL_PREFIX));
|
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1 \\\n").arg(QString(CMAKE_INSTALL_PREFIX));
|
||||||
|
infoMessage += QString("\t-DBUILD_DOCS=%1 \\\n").arg(QString(PROJECT_BUILD_DOCS));
|
||||||
infoMessage += QString("\t-DBUILD_LIBRARY=%1 \\\n").arg(QString(PROJECT_BUILD_LIBRARY));
|
infoMessage += QString("\t-DBUILD_LIBRARY=%1 \\\n").arg(QString(PROJECT_BUILD_LIBRARY));
|
||||||
infoMessage += QString("\t-DBUILD_GUI=%1 \\\n").arg(QString(PROJECT_BUILD_GUI));
|
infoMessage += QString("\t-DBUILD_GUI=%1 \\\n").arg(QString(PROJECT_BUILD_GUI));
|
||||||
infoMessage += QString("\t-DUSE_QT5=%1 \\\n").arg(QString(PROJECT_USE_QT5));
|
infoMessage += QString("\t-DUSE_QT5=%1 \\\n").arg(QString(PROJECT_USE_QT5));
|
||||||
@ -214,6 +226,12 @@ int main(int argc, char *argv[])
|
|||||||
versionMessage += QApplication::translate("MainWindow", "Author : %1\n").arg(QString(AUTHOR));
|
versionMessage += QApplication::translate("MainWindow", "Author : %1\n").arg(QString(AUTHOR));
|
||||||
versionMessage += QApplication::translate("MainWindow", "License : %1\n").arg(QString(LICENSE));
|
versionMessage += QApplication::translate("MainWindow", "License : %1\n").arg(QString(LICENSE));
|
||||||
|
|
||||||
|
// reread translations
|
||||||
|
a.removeTranslator(&translator);
|
||||||
|
language = Language::defineLanguage(configPath, options);
|
||||||
|
translator.load(QString(":/translations/") + language);
|
||||||
|
a.installTranslator(&translator);
|
||||||
|
|
||||||
// running
|
// running
|
||||||
if (error) {
|
if (error) {
|
||||||
cout << errorMessage.toUtf8().data() << endl;
|
cout << errorMessage.toUtf8().data() << endl;
|
||||||
@ -236,7 +254,7 @@ int main(int argc, char *argv[])
|
|||||||
MainWindow w(0,
|
MainWindow w(0,
|
||||||
showAbout, showNetctlAuto, showSettings,
|
showAbout, showNetctlAuto, showSettings,
|
||||||
selectEssid, openProfile, selectProfile,
|
selectEssid, openProfile, selectProfile,
|
||||||
debug, defaultSettings, tabNumber);
|
debug, defaultSettings, options, tabNumber);
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ MainWindow::MainWindow(QWidget *parent,
|
|||||||
const QString selectProfile,
|
const QString selectProfile,
|
||||||
const bool debugCmd,
|
const bool debugCmd,
|
||||||
const bool defaultSettings,
|
const bool defaultSettings,
|
||||||
|
const QString options,
|
||||||
const int tabNum)
|
const int tabNum)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow),
|
ui(new Ui::MainWindow),
|
||||||
@ -67,6 +68,7 @@ MainWindow::MainWindow(QWidget *parent,
|
|||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "selectProfile" << selectProfile;
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "selectProfile" << selectProfile;
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "debug" << debug;
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "debug" << debug;
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "defaultSettings" << defaultSettings;
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "defaultSettings" << defaultSettings;
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "options" << options;
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "tabNum" << tabNum;
|
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "tabNum" << tabNum;
|
||||||
|
|
||||||
// reading configuration
|
// reading configuration
|
||||||
@ -76,6 +78,9 @@ MainWindow::MainWindow(QWidget *parent,
|
|||||||
if (defaultSettings)
|
if (defaultSettings)
|
||||||
settingsWin->setDefault();
|
settingsWin->setDefault();
|
||||||
configuration = settingsWin->getSettings();
|
configuration = settingsWin->getSettings();
|
||||||
|
QMap<QString, QString> optionsDict = parseOptions(options);
|
||||||
|
for (int i=0; i<optionsDict.keys().count(); i++)
|
||||||
|
configuration[optionsDict.keys()[i]] = optionsDict[optionsDict.keys()[i]];
|
||||||
|
|
||||||
// backend
|
// backend
|
||||||
netctlCommand = new Netctl(debug, configuration);
|
netctlCommand = new Netctl(debug, configuration);
|
||||||
@ -302,6 +307,26 @@ void MainWindow::setIconsToButtons()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QMap<QString, QString> MainWindow::parseOptions(const QString options)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[parseOptions]";
|
||||||
|
|
||||||
|
QMap<QString, QString> settings;
|
||||||
|
for (int i=0; i<options.split(QChar(',')).count(); i++) {
|
||||||
|
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2)
|
||||||
|
continue;
|
||||||
|
settings[options.split(QChar(','))[i].split(QChar('='))[0]] =
|
||||||
|
options.split(QChar(','))[i].split(QChar('='))[1];
|
||||||
|
}
|
||||||
|
for (int i=0; i<settings.keys().count(); i++)
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[parseOptions]" << ":" <<
|
||||||
|
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||||
|
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// window slots
|
// window slots
|
||||||
void MainWindow::setMenuActionsShown(const bool state)
|
void MainWindow::setMenuActionsShown(const bool state)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +61,7 @@ public:
|
|||||||
const QString selectProfile = QString("PROFILE"),
|
const QString selectProfile = QString("PROFILE"),
|
||||||
const bool debugCmd = false,
|
const bool debugCmd = false,
|
||||||
const bool defaultSettings = false,
|
const bool defaultSettings = false,
|
||||||
|
const QString options = QString("OPTIONS"),
|
||||||
const int tabNum = 1);
|
const int tabNum = 1);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
@ -133,6 +134,7 @@ private:
|
|||||||
bool hiddenNetwork;
|
bool hiddenNetwork;
|
||||||
// configuration
|
// configuration
|
||||||
QMap<QString, QString> configuration;
|
QMap<QString, QString> configuration;
|
||||||
|
QMap<QString, QString> parseOptions(const QString options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ void NetctlAutoWindow::showWindow()
|
|||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[showWindow]";
|
if (debug) qDebug() << "[NetctlAutoWindow]" << "[showWindow]";
|
||||||
|
|
||||||
netctlAutoUpdateTable();
|
netctlAutoUpdateTable();
|
||||||
|
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,6 +270,7 @@ void SettingsWindow::showWindow()
|
|||||||
|
|
||||||
setSettings(getSettings());
|
setSettings(getSettings());
|
||||||
ui->label_info->hide();
|
ui->label_info->hide();
|
||||||
|
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@"
|
#define CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@"
|
||||||
#define CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
|
#define CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
|
||||||
#define PROJECT_BUILD_DATAENGINE "@BUILD_DATAENGINE@"
|
#define PROJECT_BUILD_DATAENGINE "@BUILD_DATAENGINE@"
|
||||||
|
#define PROJECT_BUILD_DOCS "@BUILD_DOCS@"
|
||||||
#define PROJECT_BUILD_GUI "@BUILD_GUI@"
|
#define PROJECT_BUILD_GUI "@BUILD_GUI@"
|
||||||
#define PROJECT_BUILD_LIBRARY "@BUILD_LIBRARY@"
|
#define PROJECT_BUILD_LIBRARY "@BUILD_LIBRARY@"
|
||||||
#define PROJECT_BUILD_PLASMOID "@BUILD_PLASMOID@"
|
#define PROJECT_BUILD_PLASMOID "@BUILD_PLASMOID@"
|
||||||
|
Loading…
Reference in New Issue
Block a user