mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-28 09:27:18 +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 ?
|
* add helper polkit-qt integration ?
|
||||||
* update to show error messages if debug=true
|
|
||||||
* autotests
|
* autotests
|
||||||
|
|
||||||
Links
|
Links
|
||||||
|
@ -66,6 +66,8 @@ void MainWindow::setMenuActionsShown(const bool state)
|
|||||||
ui->actionMainRemove->setVisible(state);
|
ui->actionMainRemove->setVisible(state);
|
||||||
ui->actionMainRestart->setVisible(state);
|
ui->actionMainRestart->setVisible(state);
|
||||||
ui->actionMainStart->setVisible(state);
|
ui->actionMainStart->setVisible(state);
|
||||||
|
ui->actionMainStopAll->setVisible(state);
|
||||||
|
ui->actionMainSwitch->setVisible(state);
|
||||||
// profile
|
// profile
|
||||||
ui->actionProfileClear->setVisible(state);
|
ui->actionProfileClear->setVisible(state);
|
||||||
ui->actionProfileLoad->setVisible(state);
|
ui->actionProfileLoad->setVisible(state);
|
||||||
@ -88,10 +90,15 @@ void MainWindow::updateMenuMain()
|
|||||||
ui->actionMainStart->setText(QApplication::translate("MainWindow", "Stop profile"));
|
ui->actionMainStart->setText(QApplication::translate("MainWindow", "Stop profile"));
|
||||||
ui->actionMainStart->setIcon(QIcon::fromTheme("process-stop"));
|
ui->actionMainStart->setIcon(QIcon::fromTheme("process-stop"));
|
||||||
} else {
|
} else {
|
||||||
ui->actionMainRestart->setVisible(false);
|
|
||||||
ui->actionMainStart->setText(QApplication::translate("MainWindow", "Start profile"));
|
ui->actionMainStart->setText(QApplication::translate("MainWindow", "Start profile"));
|
||||||
ui->actionMainStart->setIcon(QIcon::fromTheme("system-run"));
|
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);
|
ui->actionMainStart->setVisible(true);
|
||||||
if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) {
|
if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) {
|
||||||
ui->actionMainEnable->setText(QApplication::translate("MainWindow", "Disable profile"));
|
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()
|
void MainWindow::mainTabRemoveProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
// call netctlprofile
|
|
||||||
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();
|
||||||
bool status;
|
bool status;
|
||||||
if (useHelper) {
|
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)
|
void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||||
{
|
{
|
||||||
Q_UNUSED(previous);
|
Q_UNUSED(previous);
|
||||||
|
@ -346,6 +346,8 @@ void MainWindow::createActions()
|
|||||||
connect(ui->actionMainRemove, SIGNAL(triggered(bool)), this, SLOT(mainTabRemoveProfile()));
|
connect(ui->actionMainRemove, SIGNAL(triggered(bool)), this, SLOT(mainTabRemoveProfile()));
|
||||||
connect(ui->actionMainRestart, SIGNAL(triggered(bool)), this, SLOT(mainTabRestartProfile()));
|
connect(ui->actionMainRestart, SIGNAL(triggered(bool)), this, SLOT(mainTabRestartProfile()));
|
||||||
connect(ui->actionMainStart, SIGNAL(triggered(bool)), this, SLOT(mainTabStartProfile()));
|
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->actionProfileClear, SIGNAL(triggered(bool)), this, SLOT(profileTabClear()));
|
||||||
connect(ui->actionProfileLoad, SIGNAL(triggered(bool)), this, SLOT(profileTabLoadProfile()));
|
connect(ui->actionProfileLoad, SIGNAL(triggered(bool)), this, SLOT(profileTabLoadProfile()));
|
||||||
connect(ui->actionProfileRemove, SIGNAL(triggered(bool)), this, SLOT(profileTabRemoveProfile()));
|
connect(ui->actionProfileRemove, SIGNAL(triggered(bool)), this, SLOT(profileTabRemoveProfile()));
|
||||||
|
@ -110,9 +110,12 @@ private slots:
|
|||||||
void mainTabContextualMenu(const QPoint &pos);
|
void mainTabContextualMenu(const QPoint &pos);
|
||||||
void mainTabEditProfile();
|
void mainTabEditProfile();
|
||||||
void mainTabEnableProfile();
|
void mainTabEnableProfile();
|
||||||
|
QStringList mainTabGetActiveProfiles();
|
||||||
void mainTabRemoveProfile();
|
void mainTabRemoveProfile();
|
||||||
void mainTabRestartProfile();
|
void mainTabRestartProfile();
|
||||||
void mainTabStartProfile();
|
void mainTabStartProfile();
|
||||||
|
void mainTabStopAllProfiles();
|
||||||
|
void mainTabSwitchToProfile();
|
||||||
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||||
// profile tab slots
|
// profile tab slots
|
||||||
void profileTabChangeState(const QString current);
|
void profileTabChangeState(const QString current);
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>471</width>
|
<width>469</width>
|
||||||
<height>499</height>
|
<height>497</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -182,7 +182,9 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="icon">
|
<attribute name="icon">
|
||||||
<iconset theme="document-new"/>
|
<iconset theme="document-new">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Create a new profile</string>
|
<string>Create a new profile</string>
|
||||||
@ -225,8 +227,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>439</width>
|
<width>437</width>
|
||||||
<height>340</height>
|
<height>338</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -419,7 +421,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>471</width>
|
<width>469</width>
|
||||||
<height>22</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -440,8 +442,10 @@
|
|||||||
<addaction name="actionProfileClear"/>
|
<addaction name="actionProfileClear"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionMainStart"/>
|
<addaction name="actionMainStart"/>
|
||||||
|
<addaction name="actionMainSwitch"/>
|
||||||
<addaction name="actionMainRestart"/>
|
<addaction name="actionMainRestart"/>
|
||||||
<addaction name="actionMainEnable"/>
|
<addaction name="actionMainEnable"/>
|
||||||
|
<addaction name="actionMainStopAll"/>
|
||||||
<addaction name="actionProfileLoad"/>
|
<addaction name="actionProfileLoad"/>
|
||||||
<addaction name="actionProfileSave"/>
|
<addaction name="actionProfileSave"/>
|
||||||
<addaction name="actionWifiStart"/>
|
<addaction name="actionWifiStart"/>
|
||||||
@ -657,6 +661,22 @@
|
|||||||
<string>Library documentation</string>
|
<string>Library documentation</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</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>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>tabWidget</tabstop>
|
<tabstop>tabWidget</tabstop>
|
||||||
|
Loading…
Reference in New Issue
Block a user