mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 23:47:21 +00:00
add openProfile
This commit is contained in:
parent
63ae04cd8d
commit
5e1a4be134
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>396</width>
|
||||
<height>296</height>
|
||||
<width>394</width>
|
||||
<height>294</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
|
@ -61,6 +61,7 @@ int main(int argc, char *argv[])
|
||||
bool showNetctlAuto = false;
|
||||
bool showSettings = false;
|
||||
bool showVersion = false;
|
||||
QString openProfile = QString("PROFILE");
|
||||
int tabNumber = 1;
|
||||
for (int i=1; i<argc; i++) {
|
||||
// about
|
||||
@ -75,6 +76,11 @@ int main(int argc, char *argv[])
|
||||
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;
|
||||
@ -109,39 +115,44 @@ int main(int argc, char *argv[])
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
if (openProfile != QString("PROFILE"))
|
||||
tabNumber = 2;
|
||||
|
||||
// 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 ] [ --netctl-auto ]\n");
|
||||
helpMessage += QString(" [ --settings ] [ -t NUM | --tab NUM ] [ -v | --version ]\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 --about - %2\n")
|
||||
.arg(isParametrEnable(showAbout))
|
||||
.arg(QApplication::translate("MainWindow", "show about window"));
|
||||
helpMessage += QString("%1 -d --debug - %2\n")
|
||||
helpMessage += QString("%1 -d --debug - %2\n")
|
||||
.arg(isParametrEnable(debug))
|
||||
.arg(QApplication::translate("MainWindow", "print debug information"));
|
||||
helpMessage += QString("%1 --default - %2\n")
|
||||
helpMessage += QString("%1 --default - %2\n")
|
||||
.arg(isParametrEnable(defaultSettings))
|
||||
.arg(QApplication::translate("MainWindow", "start with default settings"));
|
||||
helpMessage += QString("%1 --netctl-auto - %2\n")
|
||||
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(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")
|
||||
helpMessage += QString(" -t %1 --tab %1 - %2\n")
|
||||
.arg(QString::number(tabNumber))
|
||||
.arg(QApplication::translate("MainWindow", "open a tab with number %1").arg(QString::number(tabNumber)));
|
||||
helpMessage += QString(" -v --version - %1\n")
|
||||
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("");
|
||||
@ -174,7 +185,6 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
if (showHelp) {
|
||||
cout << versionMessage.toUtf8().data() << endl;
|
||||
cout << helpMessage.toUtf8().data();
|
||||
return 0;
|
||||
}
|
||||
@ -182,7 +192,7 @@ int main(int argc, char *argv[])
|
||||
cout << versionMessage.toUtf8().data();
|
||||
return 0;
|
||||
}
|
||||
MainWindow w(0, debug, defaultSettings, showAbout, showNetctlAuto, showSettings, tabNumber);
|
||||
MainWindow w(0, debug, defaultSettings, showAbout, showNetctlAuto, showSettings, tabNumber, openProfile);
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ MainWindow::MainWindow(QWidget *parent,
|
||||
const bool showAbout,
|
||||
const bool showNetctlAuto,
|
||||
const bool showSettings,
|
||||
const int tabNum)
|
||||
const int tabNum,
|
||||
const QString openProfile)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
debug(debugCmd)
|
||||
@ -61,6 +62,7 @@ MainWindow::MainWindow(QWidget *parent,
|
||||
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]" << ":" << "openProfile" << openProfile;
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->tabWidget->setCurrentIndex(tabNum-1);
|
||||
@ -107,6 +109,12 @@ MainWindow::MainWindow(QWidget *parent,
|
||||
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();
|
||||
if (showNetctlAuto)
|
||||
@ -599,7 +607,8 @@ void MainWindow::mainTabEditProfile()
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
ui->tabWidget->setCurrentIndex(1);
|
||||
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->findText(profile));
|
||||
ui->comboBox_profile->addItem(profile);
|
||||
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count()-1);
|
||||
|
||||
profileTabLoadProfile();
|
||||
}
|
||||
|
@ -58,7 +58,8 @@ public:
|
||||
const bool showAbout = false,
|
||||
const bool showNetctlAuto = false,
|
||||
const bool showSettings = false,
|
||||
const int tabNum = 1);
|
||||
const int tabNum = 1,
|
||||
const QString openProfile = QString("PROFILE"));
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
|
Loading…
Reference in New Issue
Block a user