mirror of
				https://github.com/arcan1s/netctl-gui.git
				synced 2025-10-27 03:43:42 +00:00 
			
		
		
		
	rewrite tables
This commit is contained in:
		| @ -119,7 +119,7 @@ MainWindow::MainWindow(QWidget *parent, | ||||
|     ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid); | ||||
|  | ||||
|     createActions(); | ||||
|     setIconsToButtons(); | ||||
|     setIconsToTabs(); | ||||
|     updateTabs(ui->tabWidget->currentIndex()); | ||||
|  | ||||
|     if (showAbout) | ||||
| @ -211,16 +211,18 @@ bool MainWindow::checkExternalApps(const QString apps = QString("all")) | ||||
| } | ||||
|  | ||||
|  | ||||
| bool MainWindow::checkState(const QString state, const QString item) | ||||
| QString MainWindow::checkStatus(const bool statusBool, const bool nullFalse) | ||||
| { | ||||
|     if (debug) qDebug() << "[MainWindow]" << "[checkState]"; | ||||
|     if (debug) qDebug() << "[MainWindow]" << "[checkState]" << ":" << "Text" << item; | ||||
|     if (debug) qDebug() << "[MainWindow]" << "[checkState]" << ":" << "State" << state; | ||||
|     if (debug) qDebug() << "[MainWindow]" << "[checkStatus]"; | ||||
|     if (debug) qDebug() << "[MainWindow]" << "[checkStatus]" << ":" << "Status" << statusBool; | ||||
|     if (debug) qDebug() << "[MainWindow]" << "[checkStatus]" << ":" << "Return null false" << nullFalse; | ||||
|  | ||||
|     if (item.contains(state)) | ||||
|         return true; | ||||
|     if (statusBool) | ||||
|         return QApplication::translate("MainWindow", "yes"); | ||||
|     if (nullFalse) | ||||
|         return QString(""); | ||||
|     else | ||||
|         return false; | ||||
|         return QApplication::translate("MainWindow", "no"); | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -285,22 +287,14 @@ void MainWindow::keyPressEvent(QKeyEvent *pressedKey) | ||||
| } | ||||
|  | ||||
|  | ||||
| void MainWindow::setIconsToButtons() | ||||
| void MainWindow::setIconsToTabs() | ||||
| { | ||||
|     if (debug) qDebug() << "[MainWindow]" << "[setIconsToButtons]"; | ||||
|     if (debug) qDebug() << "[MainWindow]" << "[setIconsToTabs]"; | ||||
|  | ||||
|     // tab widget | ||||
|     ui->tabWidget->setTabIcon(0, QIcon(":icon")); | ||||
|     ui->tabWidget->setTabIcon(1, QIcon::fromTheme("document-new")); | ||||
|     ui->tabWidget->setTabIcon(2, QIcon(":wifi")); | ||||
|     // main tab | ||||
|     ui->pushButton_mainRefresh->setIcon(QIcon::fromTheme("stock-refresh")); | ||||
|     ui->pushButton_mainRestart->setIcon(QIcon::fromTheme("stock-refresh")); | ||||
|     // profile tab | ||||
|     ui->pushButton_profileClear->setIcon(QIcon::fromTheme("edit-clear")); | ||||
|     ui->pushButton_profileSave->setIcon(QIcon::fromTheme("document-save")); | ||||
|     // wifi tab | ||||
|     ui->pushButton_wifiRefresh->setIcon(QIcon::fromTheme("stock-refresh")); | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -416,45 +410,44 @@ void MainWindow::updateMainTab() | ||||
|     headerList.append(QApplication::translate("MainWindow", "Active")); | ||||
|     headerList.append(QApplication::translate("MainWindow", "Enabled")); | ||||
|     ui->tableWidget_main->setHorizontalHeaderLabels(headerList); | ||||
|     ui->tableWidget_main->setColumnHidden(2, true); | ||||
|     ui->tableWidget_main->setColumnHidden(3, true); | ||||
|     // create items | ||||
|     for (int i=0; i<profiles.count(); i++) { | ||||
|         // font | ||||
|         QFont font; | ||||
|         font.setBold(profiles[i].active); | ||||
|         font.setItalic(profiles[i].enabled); | ||||
|         // tooltip | ||||
|         QString toolTip = QString(""); | ||||
|         toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Profile")).arg(profiles[i].name); | ||||
|         toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Active")).arg(checkStatus(profiles[i].active)); | ||||
|         toolTip += QString("%1: %2").arg(QApplication::translate("MainWindow", "Enabled")).arg(checkStatus(profiles[i].enabled)); | ||||
|         // name | ||||
|         ui->tableWidget_main->setItem(i, 0, new QTableWidgetItem(profiles[i].name)); | ||||
|         ui->tableWidget_main->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); | ||||
|         ui->tableWidget_main->item(i, 0)->setToolTip(toolTip); | ||||
|         ui->tableWidget_main->item(i, 0)->setFont(font); | ||||
|         // description | ||||
|         ui->tableWidget_main->setItem(i, 1, new QTableWidgetItem(profiles[i].description)); | ||||
|         ui->tableWidget_main->item(i, 1)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); | ||||
|         // status | ||||
|         if (profiles[i].active) { | ||||
|             // active | ||||
|             QFont font; | ||||
|             font.setBold(true); | ||||
|             ui->tableWidget_main->item(i, 0)->setFont(font); | ||||
|             ui->tableWidget_main->setItem(i, 2, new QTableWidgetItem(QApplication::translate("MainWindow", "yes"))); | ||||
|             ui->tableWidget_main->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|         } | ||||
|         else | ||||
|             ui->tableWidget_main->setItem(i, 2, new QTableWidgetItem(QString(""))); | ||||
|         if (profiles[i].enabled) { | ||||
|             // enabled | ||||
|             ui->tableWidget_main->setItem(i, 3, new QTableWidgetItem(QApplication::translate("MainWindow", "yes"))); | ||||
|             ui->tableWidget_main->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|         } | ||||
|         else { | ||||
|             QFont font; | ||||
|             font.setItalic(true); | ||||
|             ui->tableWidget_main->item(i, 0)->setFont(font); | ||||
|             ui->tableWidget_main->setItem(i, 3, new QTableWidgetItem(QString(""))); | ||||
|         } | ||||
|         ui->tableWidget_main->item(i, 1)->setTextAlignment(Qt::AlignJustify | Qt::AlignVCenter); | ||||
|         ui->tableWidget_main->item(i, 1)->setToolTip(toolTip); | ||||
|         // active | ||||
|         ui->tableWidget_main->setItem(i, 2, new QTableWidgetItem(checkStatus(profiles[i].active, true))); | ||||
|         ui->tableWidget_main->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|         // enabled | ||||
|         ui->tableWidget_main->setItem(i, 3, new QTableWidgetItem(checkStatus(profiles[i].enabled, true))); | ||||
|         ui->tableWidget_main->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|     } | ||||
|  | ||||
|     ui->tableWidget_main->setSortingEnabled(true); | ||||
|     ui->tableWidget_main->resizeRowsToContents(); | ||||
| #if QT_VERSION >= 0x050000 | ||||
|     ui->tableWidget_main->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); | ||||
| #else | ||||
|     ui->tableWidget_main->horizontalHeader()->setResizeMode(QHeaderView::Stretch); | ||||
| #endif | ||||
|     ui->tableWidget_main->resizeRowsToContents(); | ||||
|     ui->tableWidget_main->resizeColumnToContents(0); | ||||
|     ui->tabWidget->setEnabled(true); | ||||
|     ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated")); | ||||
|  | ||||
| @ -469,19 +462,18 @@ void MainWindow::updateMenuMain() | ||||
|     ui->actionMainRefresh->setVisible(true); | ||||
|     if (ui->tableWidget_main->currentItem() == 0) | ||||
|         return; | ||||
|     QString item = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text(); | ||||
|     if (!checkState(QString("inactive"), item)) { | ||||
|     if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) { | ||||
|         ui->actionMainRestart->setVisible(true); | ||||
|         ui->actionMainStart->setText(QApplication::translate("MainWindow", "Stop profile")); | ||||
|         ui->actionMainStart->setIcon(QIcon::fromTheme("dialog-close")); | ||||
|         ui->actionMainStart->setIcon(QIcon::fromTheme("process-stop")); | ||||
|     } | ||||
|     else { | ||||
|         ui->actionMainRestart->setVisible(false); | ||||
|         ui->actionMainStart->setText(QApplication::translate("MainWindow", "Start profile")); | ||||
|         ui->actionMainStart->setIcon(QIcon::fromTheme("dialog-apply")); | ||||
|         ui->actionMainStart->setIcon(QIcon::fromTheme("system-run")); | ||||
|     } | ||||
|     ui->actionMainStart->setVisible(true); | ||||
|     if (checkState(QString("enabled"), item)) { | ||||
|     if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) { | ||||
|         ui->actionMainEnable->setText(QApplication::translate("MainWindow", "Disable profile")); | ||||
|         ui->actionMainEnable->setIcon(QIcon::fromTheme("edit-remove")); | ||||
|     } | ||||
| @ -545,33 +537,48 @@ void MainWindow::updateWifiTab() | ||||
|     // create header | ||||
|     QStringList headerList; | ||||
|     headerList.append(QApplication::translate("MainWindow", "Name")); | ||||
|     headerList.append(QApplication::translate("MainWindow", "Status")); | ||||
|     headerList.append(QApplication::translate("MainWindow", "Signal")); | ||||
|     headerList.append(QApplication::translate("MainWindow", "Security")); | ||||
|     headerList.append(QApplication::translate("MainWindow", "Active")); | ||||
|     headerList.append(QApplication::translate("MainWindow", "Exists")); | ||||
|     ui->tableWidget_wifi->setHorizontalHeaderLabels(headerList); | ||||
|     ui->tableWidget_wifi->setColumnHidden(3, true); | ||||
|     ui->tableWidget_wifi->setColumnHidden(4, true); | ||||
|     // create items | ||||
|     for (int i=0; i<scanResults.count(); i++) { | ||||
|         // font | ||||
|         QFont font; | ||||
|         font.setBold(scanResults[i].active); | ||||
|         font.setItalic(scanResults[i].exists); | ||||
|         // tooltip | ||||
|         QString toolTip = QString(""); | ||||
|         toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "ESSID")).arg(scanResults[i].name); | ||||
|         toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Active")).arg(checkStatus(scanResults[i].active)); | ||||
|         toolTip += QString("%1: %2").arg(QApplication::translate("MainWindow", "Exists")).arg(checkStatus(scanResults[i].exists)); | ||||
|         // name | ||||
|         ui->tableWidget_wifi->setItem(i, 0, new QTableWidgetItem(scanResults[i].name)); | ||||
|         ui->tableWidget_wifi->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); | ||||
|         // status | ||||
|         ui->tableWidget_wifi->setItem(i, 1, new QTableWidgetItem(scanResults[i].status)); | ||||
|         ui->tableWidget_wifi->item(i, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|         ui->tableWidget_wifi->item(i, 0)->setToolTip(toolTip); | ||||
|         ui->tableWidget_wifi->item(i, 0)->setFont(font); | ||||
|         // signal | ||||
|         ui->tableWidget_wifi->setItem(i, 2, new QTableWidgetItem(scanResults[i].signal)); | ||||
|         ui->tableWidget_wifi->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|         ui->tableWidget_wifi->setItem(i, 1, new QTableWidgetItem(scanResults[i].signal)); | ||||
|         ui->tableWidget_wifi->item(i, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|         ui->tableWidget_wifi->item(i, 1)->setToolTip(toolTip); | ||||
|         // security | ||||
|         ui->tableWidget_wifi->setItem(i, 3, new QTableWidgetItem(scanResults[i].security)); | ||||
|         ui->tableWidget_wifi->setItem(i, 2, new QTableWidgetItem(scanResults[i].security)); | ||||
|         ui->tableWidget_wifi->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|         ui->tableWidget_wifi->item(i, 2)->setToolTip(toolTip); | ||||
|         // active | ||||
|         ui->tableWidget_wifi->setItem(i, 3, new QTableWidgetItem(checkStatus(scanResults[i].active, true))); | ||||
|         ui->tableWidget_wifi->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|         // exists | ||||
|         ui->tableWidget_wifi->setItem(i, 4, new QTableWidgetItem(checkStatus(scanResults[i].exists, true))); | ||||
|         ui->tableWidget_wifi->item(i, 4)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|     } | ||||
|  | ||||
|     ui->tableWidget_wifi->setSortingEnabled(true); | ||||
|     ui->tableWidget_wifi->resizeColumnsToContents(); | ||||
|     ui->tableWidget_wifi->resizeRowsToContents(); | ||||
| #if QT_VERSION >= 0x050000 | ||||
|     ui->tableWidget_wifi->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); | ||||
| #else | ||||
|     ui->tableWidget_wifi->horizontalHeader()->setResizeMode(QHeaderView::Stretch); | ||||
| #endif | ||||
|     ui->tabWidget->setEnabled(true); | ||||
|     ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated")); | ||||
|  | ||||
| @ -586,20 +593,19 @@ void MainWindow::updateMenuWifi() | ||||
|     ui->actionWifiRefresh->setVisible(true); | ||||
|     if (ui->tableWidget_wifi->currentItem() == 0) | ||||
|         return; | ||||
|     QString item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text(); | ||||
|     if (checkState(QString("exists"), item)) { | ||||
|         if (!checkState(QString("inactive"), item)) { | ||||
|     if (!ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 4)->text().isEmpty()) { | ||||
|         if (!ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text().isEmpty()) { | ||||
|             ui->actionWifiStart->setText(QApplication::translate("MainWindow", "Stop WiFi")); | ||||
|             ui->actionWifiStart->setIcon(QIcon::fromTheme("dialog-close")); | ||||
|             ui->actionWifiStart->setIcon(QIcon::fromTheme("process-stop")); | ||||
|         } | ||||
|         else { | ||||
|             ui->actionWifiStart->setText(QApplication::translate("MainWindow", "Start WiFi")); | ||||
|             ui->actionWifiStart->setIcon(QIcon::fromTheme("dialog-apply")); | ||||
|             ui->actionWifiStart->setIcon(QIcon::fromTheme("system-run")); | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
|         ui->actionWifiStart->setText(QApplication::translate("MainWindow", "Start WiFi")); | ||||
|         ui->actionWifiStart->setIcon(QIcon::fromTheme("dialog-apply")); | ||||
|         ui->actionWifiStart->setIcon(QIcon::fromTheme("system-run")); | ||||
|     } | ||||
|     ui->actionWifiStart->setVisible(true); | ||||
| } | ||||
| @ -628,18 +634,17 @@ void MainWindow::mainTabContextualMenu(const QPoint &pos) | ||||
|     removeProfile->setIcon(QIcon::fromTheme("edit-delete")); | ||||
|  | ||||
|     // set text | ||||
|     QString item = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text(); | ||||
|     if (!checkState(QString("inactive"), item)) { | ||||
|     if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) { | ||||
|         restartProfile->setVisible(true); | ||||
|         startProfile->setText(QApplication::translate("MainWindow", "Stop profile")); | ||||
|         startProfile->setIcon(QIcon::fromTheme("dialog-close")); | ||||
|         startProfile->setIcon(QIcon::fromTheme("process-stop")); | ||||
|     } | ||||
|     else { | ||||
|         restartProfile->setVisible(false); | ||||
|         startProfile->setText(QApplication::translate("MainWindow", "Start profile")); | ||||
|         startProfile->setIcon(QIcon::fromTheme("dialog-apply")); | ||||
|         startProfile->setIcon(QIcon::fromTheme("system-run")); | ||||
|     } | ||||
|     if (checkState(QString("enabled"), item)) { | ||||
|     if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) { | ||||
|         enableProfile->setText(QApplication::translate("MainWindow", "Disable profile")); | ||||
|         enableProfile->setIcon(QIcon::fromTheme("edit-remove")); | ||||
|     } | ||||
| @ -716,8 +721,7 @@ void MainWindow::mainTabEnableProfile() | ||||
|     ui->tabWidget->setDisabled(true); | ||||
|     QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text(); | ||||
|     netctlCommand->enableProfile(profile); | ||||
|     QString item = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text(); | ||||
|     if (checkState(QString("enabled"), item)) { | ||||
|     if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) { | ||||
|         if (netctlCommand->isProfileEnabled(profile)) | ||||
|             ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); | ||||
|         else | ||||
| @ -764,15 +768,18 @@ void MainWindow::mainTabStartProfile() | ||||
|  | ||||
|     ui->tabWidget->setDisabled(true); | ||||
|     QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text(); | ||||
|     netctlCommand->startProfile(profile); | ||||
|     QString item = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text(); | ||||
|     if (checkState(QString("inactive"), item)) { | ||||
|     if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) { | ||||
|         netctlCommand->startProfile(profile); | ||||
|         if (netctlCommand->isProfileActive(profile)) | ||||
|             ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); | ||||
|         else | ||||
|             ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); | ||||
|     } | ||||
|     else { | ||||
|         if (netctlCommand->getActiveProfile().isEmpty()) | ||||
|             netctlCommand->startProfile(profile); | ||||
|         else | ||||
|             netctlCommand->switchToProfile(profile); | ||||
|         if (netctlCommand->isProfileActive(profile)) | ||||
|             ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done")); | ||||
|         else | ||||
| @ -797,16 +804,15 @@ void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt | ||||
|  | ||||
|     ui->pushButton_mainStart->setEnabled(true); | ||||
|  | ||||
|     QString item = ui->tableWidget_main->item(current->row(), 2)->text(); | ||||
|     if (!checkState(QString("inactive"), item)) { | ||||
|     if (!ui->tableWidget_main->item(current->row(), 2)->text().isEmpty()) { | ||||
|         ui->pushButton_mainRestart->setEnabled(true); | ||||
|         ui->pushButton_mainStart->setText(QApplication::translate("MainWindow", "Stop")); | ||||
|         ui->pushButton_mainStart->setIcon(QIcon::fromTheme("dialog-close")); | ||||
|         ui->pushButton_mainStart->setIcon(QIcon::fromTheme("process-stop")); | ||||
|     } | ||||
|     else { | ||||
|         ui->pushButton_mainRestart->setDisabled(true); | ||||
|         ui->pushButton_mainStart->setText(QApplication::translate("MainWindow", "Start")); | ||||
|         ui->pushButton_mainStart->setIcon(QIcon::fromTheme("dialog-apply")); | ||||
|         ui->pushButton_mainStart->setIcon(QIcon::fromTheme("system-run")); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1234,20 +1240,19 @@ void MainWindow::wifiTabContextualMenu(const QPoint &pos) | ||||
|     QAction *startWifi = menu.addAction(QApplication::translate("MainWindow", "Start WiFi")); | ||||
|  | ||||
|     // set text | ||||
|     QString item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text(); | ||||
|     if (checkState(QString("exists"), item)) { | ||||
|         if (!checkState(QString("inactive"), item)) { | ||||
|     if (!ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 4)->text().isEmpty()) { | ||||
|         if (!ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text().isEmpty()) { | ||||
|             startWifi->setText(QApplication::translate("MainWindow", "Stop WiFi")); | ||||
|             startWifi->setIcon(QIcon::fromTheme("dialog-close")); | ||||
|             startWifi->setIcon(QIcon::fromTheme("process-stop")); | ||||
|         } | ||||
|         else { | ||||
|             startWifi->setText(QApplication::translate("MainWindow", "Start WiFi")); | ||||
|             startWifi->setIcon(QIcon::fromTheme("dialog-apply")); | ||||
|             startWifi->setIcon(QIcon::fromTheme("system-run")); | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
|         startWifi->setText(QApplication::translate("MainWindow", "Start WiFi")); | ||||
|         startWifi->setIcon(QIcon::fromTheme("dialog-apply")); | ||||
|         startWifi->setIcon(QIcon::fromTheme("system-run")); | ||||
|     } | ||||
|  | ||||
|     // actions | ||||
| @ -1295,10 +1300,10 @@ void MainWindow::connectToUnknownEssid(const QString passwd) | ||||
|     settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'"); | ||||
|     settings[QString("Interface")] = netctlCommand->getWirelessInterfaceList()[0]; | ||||
|     settings[QString("Connection")] = QString("wireless"); | ||||
|     QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text(); | ||||
|     if (checkState(QString("WPA"), security)) | ||||
|     QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 2)->text(); | ||||
|     if (security.contains(QString("WPA"))) | ||||
|         settings[QString("Security")] = QString("wpa"); | ||||
|     else if (checkState(QString("wep"), security)) | ||||
|     else if (security.contains(QString("WEP"))) | ||||
|         settings[QString("Security")] = QString("wep"); | ||||
|     else | ||||
|         settings[QString("Security")] = QString("none"); | ||||
| @ -1363,12 +1368,10 @@ void MainWindow::wifiTabStart() | ||||
|     ui->tabWidget->setDisabled(true); | ||||
|     hiddenNetwork = false; | ||||
|     QString profile = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text(); | ||||
|     QString item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text(); | ||||
|     if (checkState(QString("exists"), item)) { | ||||
|     if (!ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 4)->text().isEmpty()) { | ||||
|         QString profileName = wpaCommand->existentProfile(profile); | ||||
|         netctlCommand->startProfile(profileName); | ||||
|         item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text(); | ||||
|         if (checkState(QString("inactive"), item)) { | ||||
|         if (!ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text().isEmpty()) { | ||||
|             if (netctlCommand->isProfileActive(profileName)) | ||||
|                 ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error")); | ||||
|             else | ||||
| @ -1382,8 +1385,8 @@ void MainWindow::wifiTabStart() | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
|         QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text(); | ||||
|         if (checkState(QString("none"), security)) | ||||
|         QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text(); | ||||
|         if (security.contains(QString("none"))) | ||||
|             return connectToUnknownEssid(QString("")); | ||||
|         else { | ||||
|             passwdWid = new PasswdWidget(this); | ||||
| @ -1419,19 +1422,18 @@ void MainWindow::wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt | ||||
|     } | ||||
|  | ||||
|     ui->pushButton_wifiStart->setEnabled(true); | ||||
|     QString item = ui->tableWidget_wifi->item(current->row(), 1)->text(); | ||||
|     if (checkState(QString("exists"), item)) { | ||||
|         if (!checkState(QString("inactive"), item)) { | ||||
|     if (!ui->tableWidget_wifi->item(current->row(), 4)->text().isEmpty()) { | ||||
|         if (!ui->tableWidget_wifi->item(current->row(), 3)->text().isEmpty()) { | ||||
|             ui->pushButton_wifiStart->setText(QApplication::translate("MainWindow", "Stop")); | ||||
|             ui->pushButton_wifiStart->setIcon(QIcon::fromTheme("dialog-close")); | ||||
|             ui->pushButton_wifiStart->setIcon(QIcon::fromTheme("process-stop")); | ||||
|         } | ||||
|         else { | ||||
|             ui->pushButton_wifiStart->setText(QApplication::translate("MainWindow", "Start")); | ||||
|             ui->pushButton_wifiStart->setIcon(QIcon::fromTheme("dialog-apply")); | ||||
|             ui->pushButton_wifiStart->setIcon(QIcon::fromTheme("system-run")); | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
|         ui->pushButton_wifiStart->setText(QApplication::translate("MainWindow", "Start")); | ||||
|         ui->pushButton_wifiStart->setIcon(QIcon::fromTheme("dialog-apply")); | ||||
|         ui->pushButton_wifiStart->setIcon(QIcon::fromTheme("system-run")); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -128,10 +128,10 @@ private: | ||||
|     NetctlProfile *netctlProfile; | ||||
|     WpaSup *wpaCommand; | ||||
|     bool checkExternalApps(const QString apps); | ||||
|     bool checkState(const QString state, const QString item); | ||||
|     QString checkStatus(const bool statusBool, const bool nullFalse = false); | ||||
|     void createActions(); | ||||
|     void keyPressEvent(QKeyEvent *pressedKey); | ||||
|     void setIconsToButtons(); | ||||
|     void setIconsToTabs(); | ||||
|     bool debug; | ||||
|     bool hiddenNetwork; | ||||
|     // configuration | ||||
|  | ||||
| @ -68,6 +68,9 @@ | ||||
|           <property name="sortingEnabled"> | ||||
|            <bool>true</bool> | ||||
|           </property> | ||||
|           <property name="columnCount"> | ||||
|            <number>4</number> | ||||
|           </property> | ||||
|           <attribute name="horizontalHeaderStretchLastSection"> | ||||
|            <bool>true</bool> | ||||
|           </attribute> | ||||
| @ -90,22 +93,8 @@ | ||||
|             <set>AlignHCenter|AlignVCenter|AlignCenter</set> | ||||
|            </property> | ||||
|           </column> | ||||
|           <column> | ||||
|            <property name="text"> | ||||
|             <string>Active</string> | ||||
|            </property> | ||||
|            <property name="textAlignment"> | ||||
|             <set>AlignHCenter|AlignVCenter|AlignCenter</set> | ||||
|            </property> | ||||
|           </column> | ||||
|           <column> | ||||
|            <property name="text"> | ||||
|             <string>Enabled</string> | ||||
|            </property> | ||||
|            <property name="textAlignment"> | ||||
|             <set>AlignHCenter|AlignVCenter|AlignCenter</set> | ||||
|            </property> | ||||
|           </column> | ||||
|           <column/> | ||||
|           <column/> | ||||
|          </widget> | ||||
|         </item> | ||||
|         <item> | ||||
| @ -115,6 +104,9 @@ | ||||
|             <property name="text"> | ||||
|              <string>Refresh</string> | ||||
|             </property> | ||||
|             <property name="icon"> | ||||
|              <iconset theme="stock-refresh"/> | ||||
|             </property> | ||||
|             <property name="shortcut"> | ||||
|              <string>Ctrl+R</string> | ||||
|             </property> | ||||
| @ -144,6 +136,9 @@ | ||||
|             <property name="text"> | ||||
|              <string>Restart</string> | ||||
|             </property> | ||||
|             <property name="icon"> | ||||
|              <iconset theme="stock-refresh"/> | ||||
|             </property> | ||||
|             <property name="autoDefault"> | ||||
|              <bool>true</bool> | ||||
|             </property> | ||||
| @ -157,6 +152,9 @@ | ||||
|             <property name="text"> | ||||
|              <string>Start</string> | ||||
|             </property> | ||||
|             <property name="icon"> | ||||
|              <iconset theme="system-run"/> | ||||
|             </property> | ||||
|             <property name="autoDefault"> | ||||
|              <bool>true</bool> | ||||
|             </property> | ||||
| @ -215,7 +213,7 @@ | ||||
|              <x>0</x> | ||||
|              <y>0</y> | ||||
|              <width>443</width> | ||||
|              <height>347</height> | ||||
|              <height>345</height> | ||||
|             </rect> | ||||
|            </property> | ||||
|            <property name="sizePolicy"> | ||||
| @ -235,6 +233,9 @@ | ||||
|             <property name="text"> | ||||
|              <string>Clear</string> | ||||
|             </property> | ||||
|             <property name="icon"> | ||||
|              <iconset theme="edit-clear"/> | ||||
|             </property> | ||||
|            </widget> | ||||
|           </item> | ||||
|           <item> | ||||
| @ -255,6 +256,9 @@ | ||||
|             <property name="text"> | ||||
|              <string>Save</string> | ||||
|             </property> | ||||
|             <property name="icon"> | ||||
|              <iconset theme="document-save"/> | ||||
|             </property> | ||||
|            </widget> | ||||
|           </item> | ||||
|          </layout> | ||||
| @ -293,6 +297,9 @@ | ||||
|           <property name="sortingEnabled"> | ||||
|            <bool>true</bool> | ||||
|           </property> | ||||
|           <property name="columnCount"> | ||||
|            <number>5</number> | ||||
|           </property> | ||||
|           <attribute name="horizontalHeaderStretchLastSection"> | ||||
|            <bool>true</bool> | ||||
|           </attribute> | ||||
| @ -303,22 +310,28 @@ | ||||
|            <property name="text"> | ||||
|             <string>Name</string> | ||||
|            </property> | ||||
|           </column> | ||||
|           <column> | ||||
|            <property name="text"> | ||||
|             <string>Status</string> | ||||
|            <property name="textAlignment"> | ||||
|             <set>AlignHCenter|AlignVCenter|AlignCenter</set> | ||||
|            </property> | ||||
|           </column> | ||||
|           <column> | ||||
|            <property name="text"> | ||||
|             <string>Signal</string> | ||||
|            </property> | ||||
|            <property name="textAlignment"> | ||||
|             <set>AlignHCenter|AlignVCenter|AlignCenter</set> | ||||
|            </property> | ||||
|           </column> | ||||
|           <column> | ||||
|            <property name="text"> | ||||
|             <string>Security</string> | ||||
|            </property> | ||||
|            <property name="textAlignment"> | ||||
|             <set>AlignHCenter|AlignVCenter|AlignCenter</set> | ||||
|            </property> | ||||
|           </column> | ||||
|           <column/> | ||||
|           <column/> | ||||
|          </widget> | ||||
|         </item> | ||||
|         <item> | ||||
| @ -328,6 +341,9 @@ | ||||
|             <property name="text"> | ||||
|              <string>Refresh</string> | ||||
|             </property> | ||||
|             <property name="icon"> | ||||
|              <iconset theme="stock-refresh"/> | ||||
|             </property> | ||||
|             <property name="shortcut"> | ||||
|              <string>Ctrl+R</string> | ||||
|             </property> | ||||
| @ -357,6 +373,9 @@ | ||||
|             <property name="text"> | ||||
|              <string>Start</string> | ||||
|             </property> | ||||
|             <property name="icon"> | ||||
|              <iconset theme="system-run"/> | ||||
|             </property> | ||||
|             <property name="autoDefault"> | ||||
|              <bool>true</bool> | ||||
|             </property> | ||||
| @ -456,7 +475,7 @@ | ||||
|   </action> | ||||
|   <action name="actionMainStart"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="dialog-apply"> | ||||
|     <iconset theme="system-run"> | ||||
|      <normaloff/> | ||||
|     </iconset> | ||||
|    </property> | ||||
| @ -546,7 +565,7 @@ | ||||
|   </action> | ||||
|   <action name="actionWifiStart"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="dialog-apply"> | ||||
|     <iconset theme="system-run"> | ||||
|      <normaloff/> | ||||
|     </iconset> | ||||
|    </property> | ||||
|  | ||||
| @ -45,6 +45,21 @@ NetctlAutoWindow::~NetctlAutoWindow() | ||||
| } | ||||
|  | ||||
|  | ||||
| QString NetctlAutoWindow::checkStatus(const bool statusBool, const bool nullFalse) | ||||
| { | ||||
|     if (debug) qDebug() << "[NetctlAutoWindow]" << "[checkStatus]"; | ||||
|     if (debug) qDebug() << "[NetctlAutoWindow]" << "[checkStatus]" << ":" << "Status" << statusBool; | ||||
|     if (debug) qDebug() << "[NetctlAutoWindow]" << "[checkStatus]" << ":" << "Return null false" << nullFalse; | ||||
|  | ||||
|     if (statusBool) | ||||
|         return QApplication::translate("NetctlAutoWindow", "yes"); | ||||
|     if (nullFalse) | ||||
|         return QString(""); | ||||
|     else | ||||
|         return QApplication::translate("NetctlAutoWindow", "no"); | ||||
| } | ||||
|  | ||||
|  | ||||
| void NetctlAutoWindow::createActions() | ||||
| { | ||||
|     if (debug) qDebug() << "[NetctlAutoWindow]" << "[createActions]"; | ||||
| @ -126,44 +141,39 @@ void NetctlAutoWindow::netctlAutoUpdateTable() | ||||
|     headerList.append(QApplication::translate("NetctlAutoWindow", "Active")); | ||||
|     headerList.append(QApplication::translate("NetctlAutoWindow", "Disabled")); | ||||
|     ui->tableWidget->setHorizontalHeaderLabels(headerList); | ||||
|     ui->tableWidget->setColumnHidden(2, true); | ||||
|     ui->tableWidget->setColumnHidden(3, true); | ||||
|     // create items | ||||
|     for (int i=0; i<profiles.count(); i++) { | ||||
|         // font | ||||
|         QFont font; | ||||
|         font.setBold(profiles[i].active); | ||||
|         font.setItalic(profiles[i].enabled); | ||||
|         // tooltip | ||||
|         QString toolTip = QString(""); | ||||
|         toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Profile")).arg(profiles[i].name); | ||||
|         toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Active")).arg(checkStatus(profiles[i].active)); | ||||
|         toolTip += QString("%1: %2").arg(QApplication::translate("NetctlAutoWindow", "Disabled")).arg(checkStatus(!profiles[i].enabled)); | ||||
|         // name | ||||
|         ui->tableWidget->setItem(i, 0, new QTableWidgetItem(profiles[i].name)); | ||||
|         ui->tableWidget->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); | ||||
|         ui->tableWidget->item(i, 0)->setToolTip(toolTip); | ||||
|         ui->tableWidget->item(i, 0)->setFont(font); | ||||
|         // description | ||||
|         ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i].description)); | ||||
|         ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); | ||||
|         // status | ||||
|         if (profiles[i].active) { | ||||
|             // active | ||||
|             QFont font; | ||||
|             font.setBold(true); | ||||
|             ui->tableWidget->item(i, 0)->setFont(font); | ||||
|             ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QApplication::translate("NetctlAutoWindow", "yes"))); | ||||
|             ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|         } | ||||
|         else | ||||
|             ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QString(""))); | ||||
|         if (profiles[i].enabled) { | ||||
|             // disabled | ||||
|             QFont font; | ||||
|             font.setItalic(true); | ||||
|             ui->tableWidget->item(i, 0)->setFont(font); | ||||
|             ui->tableWidget->setItem(i, 3, new QTableWidgetItem(QApplication::translate("NetctlAutoWindow", "yes"))); | ||||
|             ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|         } | ||||
|         else | ||||
|             ui->tableWidget->setItem(i, 3, new QTableWidgetItem(QString(""))); | ||||
|         ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignJustify | Qt::AlignVCenter); | ||||
|         ui->tableWidget->item(i, 1)->setToolTip(toolTip); | ||||
|         // active | ||||
|         ui->tableWidget->setItem(i, 2, new QTableWidgetItem(checkStatus(profiles[i].active, true))); | ||||
|         ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|         // enabled | ||||
|         ui->tableWidget->setItem(i, 3, new QTableWidgetItem(checkStatus(!profiles[i].enabled, true))); | ||||
|         ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | ||||
|     } | ||||
|  | ||||
|     ui->tableWidget->setSortingEnabled(true); | ||||
|     ui->tableWidget->resizeColumnsToContents(); | ||||
|     ui->tableWidget->resizeRowsToContents(); | ||||
| #if QT_VERSION >= 0x050000 | ||||
|     ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); | ||||
| #else | ||||
|     ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch); | ||||
| #endif | ||||
|     ui->tableWidget->setEnabled(true); | ||||
|     ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated")); | ||||
|  | ||||
| @ -181,7 +191,7 @@ void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos) | ||||
|     // create menu | ||||
|     QMenu menu(this); | ||||
|     QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile")); | ||||
|     startProfile->setIcon(QIcon::fromTheme("dialog-apply")); | ||||
|     startProfile->setIcon(QIcon::fromTheme("system-run")); | ||||
|     QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile")); | ||||
|     menu.addSeparator(); | ||||
|     QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles")); | ||||
| @ -190,14 +200,14 @@ void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos) | ||||
|     disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete")); | ||||
|  | ||||
|     // set text | ||||
|     if (ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text() == QString("yes")) { | ||||
|     if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty()) { | ||||
|         enableProfile->setVisible(false); | ||||
|         startProfile->setVisible(false); | ||||
|     } | ||||
|     else { | ||||
|         enableProfile->setVisible(true); | ||||
|         startProfile->setVisible(true); | ||||
|         if (ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text() == QString("yes")) { | ||||
|         if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) { | ||||
|             enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable")); | ||||
|             enableProfile->setIcon(QIcon::fromTheme("edit-add")); | ||||
|         } | ||||
| @ -343,7 +353,7 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl | ||||
|         ui->actionSwitch->setVisible(false); | ||||
|         return; | ||||
|     } | ||||
|     if (ui->tableWidget->item(current->row(), 2)->text() == QString("yes")) { | ||||
|     if (!ui->tableWidget->item(current->row(), 2)->text().isEmpty()) { | ||||
|         // buttons | ||||
|         ui->pushButton_enable->setDisabled(true); | ||||
|         ui->pushButton_switch->setDisabled(true); | ||||
| @ -358,7 +368,7 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl | ||||
|         // menu | ||||
|         ui->actionEnable->setVisible(true); | ||||
|         ui->actionSwitch->setVisible(true); | ||||
|         if (ui->tableWidget->item(current->row(), 3)->text() == QString("yes")) { | ||||
|         if (!ui->tableWidget->item(current->row(), 3)->text().isEmpty()) { | ||||
|             // buttons | ||||
|             ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Enable")); | ||||
|             ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-add")); | ||||
|  | ||||
| @ -61,6 +61,7 @@ private: | ||||
|     Netctl *netctlCommand; | ||||
|     Ui::NetctlAutoWindow *ui; | ||||
|     bool debug; | ||||
|     QString checkStatus(const bool statusBool, const bool nullFalse = false); | ||||
|     void createActions(); | ||||
| }; | ||||
|  | ||||
|  | ||||
| @ -6,8 +6,8 @@ | ||||
|    <rect> | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>432</width> | ||||
|     <height>343</height> | ||||
|     <width>428</width> | ||||
|     <height>339</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="windowTitle"> | ||||
| @ -42,6 +42,9 @@ | ||||
|       <property name="sortingEnabled"> | ||||
|        <bool>true</bool> | ||||
|       </property> | ||||
|       <property name="columnCount"> | ||||
|        <number>4</number> | ||||
|       </property> | ||||
|       <attribute name="horizontalHeaderStretchLastSection"> | ||||
|        <bool>true</bool> | ||||
|       </attribute> | ||||
| @ -58,16 +61,8 @@ | ||||
|         <string>Description</string> | ||||
|        </property> | ||||
|       </column> | ||||
|       <column> | ||||
|        <property name="text"> | ||||
|         <string>Active</string> | ||||
|        </property> | ||||
|       </column> | ||||
|       <column> | ||||
|        <property name="text"> | ||||
|         <string>Disabled</string> | ||||
|        </property> | ||||
|       </column> | ||||
|       <column/> | ||||
|       <column/> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item> | ||||
| @ -105,6 +100,9 @@ | ||||
|         <property name="text"> | ||||
|          <string>Enable</string> | ||||
|         </property> | ||||
|         <property name="icon"> | ||||
|          <iconset theme="edit-add"/> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item> | ||||
| @ -116,7 +114,7 @@ | ||||
|          <string>Switch</string> | ||||
|         </property> | ||||
|         <property name="icon"> | ||||
|          <iconset theme="dialog-apply"> | ||||
|          <iconset theme="system-run"> | ||||
|           <normaloff/> | ||||
|          </iconset> | ||||
|         </property> | ||||
| @ -131,7 +129,7 @@ | ||||
|     <rect> | ||||
|      <x>0</x> | ||||
|      <y>0</y> | ||||
|      <width>432</width> | ||||
|      <width>428</width> | ||||
|      <height>22</height> | ||||
|     </rect> | ||||
|    </property> | ||||
| @ -168,7 +166,7 @@ | ||||
|   </action> | ||||
|   <action name="actionSwitch"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="dialog-apply"> | ||||
|     <iconset theme="system-run"> | ||||
|      <normaloff/> | ||||
|     </iconset> | ||||
|    </property> | ||||
|  | ||||
| @ -41,9 +41,9 @@ class NetctlProfile; | ||||
|  * @var netctlProfileInfo::description | ||||
|  * profile description | ||||
|  * @var netctlProfileInfo::active | ||||
|  * profile status | ||||
|  * whether profile is active | ||||
|  * @var netctlProfileInfo::enabled | ||||
|  * profile status | ||||
|  * whether profile is enabled | ||||
|  */ | ||||
| typedef struct | ||||
| { | ||||
| @ -81,6 +81,16 @@ public: | ||||
|      */ | ||||
|     ~Netctl(); | ||||
|     // general information | ||||
|     /** | ||||
|      * @brief method which returns active profile name | ||||
|      * @return profile name or "" | ||||
|      */ | ||||
|     QString getActiveProfile(); | ||||
|     /** | ||||
|      * @brief method which returns active profile name from netctl-auto | ||||
|      * @return profile name or "" | ||||
|      */ | ||||
|     QString autoGetActiveProfile(); | ||||
|     /** | ||||
|      * @brief method which returns profile informations from netctl | ||||
|      * @return list of profiles | ||||
| @ -174,6 +184,13 @@ public slots: | ||||
|      * @return true if the method was completed without errors | ||||
|      */ | ||||
|     bool startProfile(const QString profile); | ||||
|     /** | ||||
|      * @brief method which starts another profile | ||||
|      * @param profile        profile name | ||||
|      * @return false if components are not found or command exit code is not equal to 0 | ||||
|      * @return true if the method was completed without errors | ||||
|      */ | ||||
|     bool switchToProfile(const QString profile); | ||||
|     // netctl-auto | ||||
|     /** | ||||
|      * @brief method which sets all profiles disabled (netctl-auto) | ||||
|  | ||||
| @ -43,15 +43,18 @@ class NetctlProfile; | ||||
|  * may be "WPA2", "WEP", "WEP", "none" | ||||
|  * @var netctlWifiInfo::signal | ||||
|  * Wifi point signal | ||||
|  * @var netctlWifiInfo::status | ||||
|  * netctl status, may be "new", "exist (active)", "exist (inactive)" | ||||
|  * @var netctlWifiInfo::active | ||||
|  * whether associated profile is active | ||||
|  * @var netctlWifiInfo::exists | ||||
|  * whether associated profile exists | ||||
|  */ | ||||
| typedef struct | ||||
| { | ||||
|     QString name; | ||||
|     QString security; | ||||
|     QString signal; | ||||
|     QString status; | ||||
|     bool active; | ||||
|     bool exists; | ||||
| } netctlWifiInfo; | ||||
|  | ||||
| /** | ||||
|  | ||||
| @ -150,6 +150,44 @@ QString Netctl::getCmdOutput(const bool sudo, const QString command, const QStri | ||||
|  | ||||
|  | ||||
| // general information | ||||
| /** | ||||
|  * @fn getActiveProfile | ||||
|  */ | ||||
| QString Netctl::getActiveProfile() | ||||
| { | ||||
|     if (debug) qDebug() << "[Netctl]" << "[getActiveProfile]"; | ||||
|  | ||||
|     QString profile = QString(""); | ||||
|     QList<netctlProfileInfo> fullProfilesInfo = getProfileList(); | ||||
|     for (int i=0; i<fullProfilesInfo.count(); i++) | ||||
|         if (fullProfilesInfo[i].active) { | ||||
|             profile = fullProfilesInfo[i].name; | ||||
|             break; | ||||
|         } | ||||
|  | ||||
|     return profile; | ||||
| } | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * @fn autoGetActiveProfile | ||||
|  */ | ||||
| QString Netctl::autoGetActiveProfile() | ||||
| { | ||||
|     if (debug) qDebug() << "[Netctl]" << "[autoGetActiveProfile]"; | ||||
|  | ||||
|     QString profile = QString(""); | ||||
|     QList<netctlProfileInfo> fullProfilesInfo = getProfileListFromNetctlAuto(); | ||||
|     for (int i=0; i<fullProfilesInfo.count(); i++) | ||||
|         if (fullProfilesInfo[i].active) { | ||||
|             profile = fullProfilesInfo[i].name; | ||||
|             break; | ||||
|         } | ||||
|  | ||||
|     return profile; | ||||
| } | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * @fn getProfileList | ||||
|  */ | ||||
| @ -164,7 +202,10 @@ QList<netctlProfileInfo> Netctl::getProfileList() | ||||
|         netctlProfileInfo profileInfo; | ||||
|         profileInfo.name = output[i].mid(2, -1); | ||||
|         profileInfo.description = getProfileDescription(profileInfo.name); | ||||
|         profileInfo.active = isProfileActive(profileInfo.name); | ||||
|         if (output[i][0] == QChar('*')) | ||||
|             profileInfo.active = true; | ||||
|         else | ||||
|             profileInfo.active = false; | ||||
|         profileInfo.enabled = isProfileEnabled(profileInfo.name); | ||||
|         fullProfilesInfo.append(profileInfo); | ||||
|     } | ||||
| @ -187,8 +228,12 @@ QList<netctlProfileInfo> Netctl::getProfileListFromNetctlAuto() | ||||
|         netctlProfileInfo profileInfo; | ||||
|         profileInfo.name = output[i].mid(2, -1); | ||||
|         profileInfo.description = getProfileDescription(profileInfo.name); | ||||
|         profileInfo.active = autoIsProfileActive(profileInfo.name); | ||||
|         profileInfo.enabled = autoIsProfileEnabled(profileInfo.name); | ||||
|         profileInfo.active = false; | ||||
|         profileInfo.enabled = true; | ||||
|         if (output[i][0] == QChar('*')) | ||||
|             profileInfo.active = true; | ||||
|         else if (output[i][0] == QChar('!')) | ||||
|             profileInfo.enabled = false; | ||||
|         fullProfilesInfo.append(profileInfo); | ||||
|     } | ||||
|  | ||||
| @ -320,12 +365,8 @@ bool Netctl::isNetctlAutoEnabled() | ||||
|  | ||||
|     QString interface = getWirelessInterfaceList()[0]; | ||||
|     QString argument = netctlAutoService + QString("@") + interface + QString(".service"); | ||||
|     QString output = getCmdOutput(false, systemctlCommand, QString("is-enabled"), argument).trimmed(); | ||||
|  | ||||
|     if (output == QString("enabled")) | ||||
|         return true; | ||||
|     else | ||||
|         return false; | ||||
|     return cmdCall(false, systemctlCommand, QString("is-enabled"), argument); | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -346,12 +387,8 @@ bool Netctl::isNetctlAutoRunning() | ||||
|  | ||||
|     QString interface = getWirelessInterfaceList()[0]; | ||||
|     QString argument = netctlAutoService + QString("@") + interface + QString(".service"); | ||||
|     QString output = getCmdOutput(false, systemctlCommand, QString("is-active"), argument).trimmed(); | ||||
|  | ||||
|     if (output == QString("active")) | ||||
|         return true; | ||||
|     else | ||||
|         return false; | ||||
|     return cmdCall(false, systemctlCommand, QString("is-active"), argument); | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -425,6 +462,21 @@ bool Netctl::startProfile(const QString profile) | ||||
| } | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * @fn switchToProfile | ||||
|  */ | ||||
| bool Netctl::switchToProfile(const QString profile) | ||||
| { | ||||
|     if (debug) qDebug() << "[Netctl]" << "[switchToProfile]"; | ||||
|     if (debug) qDebug() << "[Netctl]" << "[switchToProfile]" << ":" << "Profile" << profile; | ||||
|  | ||||
|     if (isProfileActive(profile)) | ||||
|         return true; | ||||
|     else | ||||
|         return cmdCall(true, netctlCommand, QString("switch-to"), profile); | ||||
| } | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * @fn autoDisableAllProfiles | ||||
|  */ | ||||
|  | ||||
| @ -210,17 +210,8 @@ QList<netctlWifiInfo> WpaSup::scanWifi() | ||||
|         else | ||||
|             wifiPoint.name = QString("<hidden>"); | ||||
|         // profile status | ||||
|         QString status; | ||||
|         if (isProfileExists(wifiPoint.name)) { | ||||
|             status = QString("exists"); | ||||
|             if (isProfileActive(wifiPoint.name)) | ||||
|                 status = status + QString(" (active)"); | ||||
|             else | ||||
|                 status = status + QString(" (inactive)"); | ||||
|         } | ||||
|         else | ||||
|             status = QString("new"); | ||||
|         wifiPoint.status = status; | ||||
|         wifiPoint.active = isProfileActive(wifiPoint.name); | ||||
|         wifiPoint.exists = isProfileExists(wifiPoint.name); | ||||
|         // point signal | ||||
|         wifiPoint.signal = rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[2]; | ||||
|         // point security | ||||
|  | ||||
		Reference in New Issue
	
	Block a user