mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-25 19:49:56 +00:00
added flags
This commit is contained in:
@ -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<argc; i++) {
|
||||
// windows
|
||||
// about
|
||||
if (QString(argv[i]) == QString("--about")) {
|
||||
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
|
||||
else if (QString(argv[i]) == QString("--netctl-auto")) {
|
||||
showNetctlAuto = true;
|
||||
@ -89,6 +84,31 @@ int main(int argc, char *argv[])
|
||||
else if (QString(argv[i]) == QString("--settings")) {
|
||||
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
|
||||
else if ((QString(argv[i]) == QString("-t")) || (QString(argv[i]) == QString("--tab"))) {
|
||||
if (atoi(argv[i+1]) > 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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user