mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
add actions
This commit is contained in:
parent
d3e1c4bca0
commit
82c3690dcb
@ -65,7 +65,6 @@ TODO (wish list)
|
||||
----------------
|
||||
|
||||
* add helper polkit-qt integration ?
|
||||
* update to show error messages if debug=true
|
||||
* autotests
|
||||
|
||||
Links
|
||||
|
@ -66,6 +66,8 @@ void MainWindow::setMenuActionsShown(const bool state)
|
||||
ui->actionMainRemove->setVisible(state);
|
||||
ui->actionMainRestart->setVisible(state);
|
||||
ui->actionMainStart->setVisible(state);
|
||||
ui->actionMainStopAll->setVisible(state);
|
||||
ui->actionMainSwitch->setVisible(state);
|
||||
// profile
|
||||
ui->actionProfileClear->setVisible(state);
|
||||
ui->actionProfileLoad->setVisible(state);
|
||||
@ -88,10 +90,15 @@ void MainWindow::updateMenuMain()
|
||||
ui->actionMainStart->setText(QApplication::translate("MainWindow", "Stop profile"));
|
||||
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("system-run"));
|
||||
}
|
||||
if (!mainTabGetActiveProfiles().isEmpty()) {
|
||||
if (!mainTabGetActiveProfiles()
|
||||
.contains(ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text()))
|
||||
ui->actionMainSwitch->setVisible(true);
|
||||
ui->actionMainStopAll->setVisible(true);
|
||||
}
|
||||
ui->actionMainStart->setVisible(true);
|
||||
if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) {
|
||||
ui->actionMainEnable->setText(QApplication::translate("MainWindow", "Disable profile"));
|
||||
@ -416,12 +423,24 @@ void MainWindow::mainTabEnableProfile()
|
||||
}
|
||||
|
||||
|
||||
QStringList MainWindow::mainTabGetActiveProfiles()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList profiles;
|
||||
for (int i=0; i<ui->tableWidget_main->rowCount(); i++)
|
||||
if (!ui->tableWidget_main->item(i, 2)->text().isEmpty())
|
||||
profiles.append(ui->tableWidget_main->item(i, 0)->text());
|
||||
|
||||
return profiles;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::mainTabRemoveProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->tabWidget->setDisabled(true);
|
||||
// call netctlprofile
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
bool status;
|
||||
if (useHelper) {
|
||||
@ -480,6 +499,49 @@ void MainWindow::mainTabStartProfile()
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::mainTabStopAllProfiles()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl")))
|
||||
return errorWin->showWindow(1, QString(PDEBUG));
|
||||
|
||||
ui->tabWidget->setDisabled(true);
|
||||
bool status;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("StopAll"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->stopAllProfiles();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::mainTabSwitchToProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl")))
|
||||
return errorWin->showWindow(1, QString(PDEBUG));
|
||||
if (ui->tableWidget_main->currentItem() == 0) return;
|
||||
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
bool previous = !ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty();
|
||||
bool current = switchToProfileSlot(profile);
|
||||
if (current != previous)
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
|
@ -346,6 +346,8 @@ void MainWindow::createActions()
|
||||
connect(ui->actionMainRemove, SIGNAL(triggered(bool)), this, SLOT(mainTabRemoveProfile()));
|
||||
connect(ui->actionMainRestart, SIGNAL(triggered(bool)), this, SLOT(mainTabRestartProfile()));
|
||||
connect(ui->actionMainStart, SIGNAL(triggered(bool)), this, SLOT(mainTabStartProfile()));
|
||||
connect(ui->actionMainStopAll, SIGNAL(triggered(bool)), this, SLOT(mainTabStopAllProfiles()));
|
||||
connect(ui->actionMainSwitch, SIGNAL(triggered(bool)), this, SLOT(mainTabSwitchToProfile()));
|
||||
connect(ui->actionProfileClear, SIGNAL(triggered(bool)), this, SLOT(profileTabClear()));
|
||||
connect(ui->actionProfileLoad, SIGNAL(triggered(bool)), this, SLOT(profileTabLoadProfile()));
|
||||
connect(ui->actionProfileRemove, SIGNAL(triggered(bool)), this, SLOT(profileTabRemoveProfile()));
|
||||
|
@ -110,9 +110,12 @@ private slots:
|
||||
void mainTabContextualMenu(const QPoint &pos);
|
||||
void mainTabEditProfile();
|
||||
void mainTabEnableProfile();
|
||||
QStringList mainTabGetActiveProfiles();
|
||||
void mainTabRemoveProfile();
|
||||
void mainTabRestartProfile();
|
||||
void mainTabStartProfile();
|
||||
void mainTabStopAllProfiles();
|
||||
void mainTabSwitchToProfile();
|
||||
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
// profile tab slots
|
||||
void profileTabChangeState(const QString current);
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>471</width>
|
||||
<height>499</height>
|
||||
<width>469</width>
|
||||
<height>497</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -182,7 +182,9 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="icon">
|
||||
<iconset theme="document-new"/>
|
||||
<iconset theme="document-new">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Create a new profile</string>
|
||||
@ -225,8 +227,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>439</width>
|
||||
<height>340</height>
|
||||
<width>437</width>
|
||||
<height>338</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -419,7 +421,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>471</width>
|
||||
<width>469</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -440,8 +442,10 @@
|
||||
<addaction name="actionProfileClear"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionMainStart"/>
|
||||
<addaction name="actionMainSwitch"/>
|
||||
<addaction name="actionMainRestart"/>
|
||||
<addaction name="actionMainEnable"/>
|
||||
<addaction name="actionMainStopAll"/>
|
||||
<addaction name="actionProfileLoad"/>
|
||||
<addaction name="actionProfileSave"/>
|
||||
<addaction name="actionWifiStart"/>
|
||||
@ -657,6 +661,22 @@
|
||||
<string>Library documentation</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainSwitch">
|
||||
<property name="icon">
|
||||
<iconset theme="system-run"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Switch to profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainStopAll">
|
||||
<property name="icon">
|
||||
<iconset theme="process-stop"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stop all profiles</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
|
Loading…
Reference in New Issue
Block a user