add openProfile

This commit is contained in:
arcan1s 2014-07-14 19:36:14 +04:00
parent 63ae04cd8d
commit 5e1a4be134
4 changed files with 38 additions and 18 deletions

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>396</width> <width>394</width>
<height>296</height> <height>294</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">

View File

@ -61,6 +61,7 @@ int main(int argc, char *argv[])
bool showNetctlAuto = false; bool showNetctlAuto = false;
bool showSettings = false; bool showSettings = false;
bool showVersion = false; bool showVersion = false;
QString openProfile = QString("PROFILE");
int tabNumber = 1; int tabNumber = 1;
for (int i=1; i<argc; i++) { for (int i=1; i<argc; i++) {
// about // about
@ -75,6 +76,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;
} }
// default settings
else if ((QString(argv[i]) == QString("-o")) || (QString(argv[i]) == QString("--open"))) {
openProfile = QString(argv[i+1]);
i++;
}
// netctl-auto // netctl-auto
else if (QString(argv[i]) == QString("--netctl-auto")) { else if (QString(argv[i]) == QString("--netctl-auto")) {
showNetctlAuto = true; showNetctlAuto = true;
@ -109,14 +115,16 @@ int main(int argc, char *argv[])
error = true; error = true;
} }
} }
if (openProfile != QString("PROFILE"))
tabNumber = 2;
// messages // messages
QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n"); QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n");
QString helpMessage = QString(""); QString helpMessage = QString("");
helpMessage += QApplication::translate("MainWindow", "Usage:\n"); helpMessage += QApplication::translate("MainWindow", "Usage:\n");
helpMessage += QString("netctl-gui [ --about ] [ -d | --debug ] [ --default ] [ --netctl-auto ]\n"); helpMessage += QString("netctl-gui [ --about ] [ -d | --debug ] [ --default ] [ -o PROFILE | --open PROFILE ]\n");
helpMessage += QString(" [ --settings ] [ -t NUM | --tab NUM ] [ -v | --version ]\n"); helpMessage += QString(" [ --netctl-auto ] [ --settings ] [ -t NUM | --tab NUM ] [ -v | --version ]\n");
helpMessage += QString(" [ -i | --info ] [ -h | --help]\n\n"); helpMessage += QString(" [ -i | --info ] [ -h | --help]\n\n");
helpMessage += QApplication::translate("MainWindow", "Parametrs:\n"); helpMessage += QApplication::translate("MainWindow", "Parametrs:\n");
helpMessage += QString("%1 --about - %2\n") helpMessage += QString("%1 --about - %2\n")
@ -128,6 +136,9 @@ 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(" -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(isParametrEnable(showNetctlAuto))
.arg(QApplication::translate("MainWindow", "show netctl-auto window")); .arg(QApplication::translate("MainWindow", "show netctl-auto window"));
@ -174,7 +185,6 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
if (showHelp) { if (showHelp) {
cout << versionMessage.toUtf8().data() << endl;
cout << helpMessage.toUtf8().data(); cout << helpMessage.toUtf8().data();
return 0; return 0;
} }
@ -182,7 +192,7 @@ int main(int argc, char *argv[])
cout << versionMessage.toUtf8().data(); cout << versionMessage.toUtf8().data();
return 0; return 0;
} }
MainWindow w(0, debug, defaultSettings, showAbout, showNetctlAuto, showSettings, tabNumber); MainWindow w(0, debug, defaultSettings, showAbout, showNetctlAuto, showSettings, tabNumber, openProfile);
w.show(); w.show();
return a.exec(); return a.exec();
} }

View File

@ -51,7 +51,8 @@ MainWindow::MainWindow(QWidget *parent,
const bool showAbout, const bool showAbout,
const bool showNetctlAuto, const bool showNetctlAuto,
const bool showSettings, const bool showSettings,
const int tabNum) const int tabNum,
const QString openProfile)
: QMainWindow(parent), : QMainWindow(parent),
ui(new Ui::MainWindow), ui(new Ui::MainWindow),
debug(debugCmd) debug(debugCmd)
@ -61,6 +62,7 @@ MainWindow::MainWindow(QWidget *parent,
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showNetctlAuto" << showNetctlAuto; if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showNetctlAuto" << showNetctlAuto;
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showSettings" << showSettings; if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "showSettings" << showSettings;
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "tabNum" << tabNum; if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "tabNum" << tabNum;
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "openProfile" << openProfile;
ui->setupUi(this); ui->setupUi(this);
ui->tabWidget->setCurrentIndex(tabNum-1); ui->tabWidget->setCurrentIndex(tabNum-1);
@ -107,6 +109,12 @@ MainWindow::MainWindow(QWidget *parent,
updateTabs(ui->tabWidget->currentIndex()); updateTabs(ui->tabWidget->currentIndex());
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready")); 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) if (showAbout)
aboutWin->show(); aboutWin->show();
if (showNetctlAuto) if (showNetctlAuto)
@ -599,7 +607,8 @@ void MainWindow::mainTabEditProfile()
ui->tabWidget->setDisabled(true); ui->tabWidget->setDisabled(true);
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text(); QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
ui->tabWidget->setCurrentIndex(1); 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(); profileTabLoadProfile();
} }

View File

@ -58,7 +58,8 @@ public:
const bool showAbout = false, const bool showAbout = false,
const bool showNetctlAuto = false, const bool showNetctlAuto = false,
const bool showSettings = false, const bool showSettings = false,
const int tabNum = 1); const int tabNum = 1,
const QString openProfile = QString("PROFILE"));
~MainWindow(); ~MainWindow();
public slots: public slots: