mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-25 07:57:20 +00:00
add contextual actions to the main table
This commit is contained in:
parent
028546540c
commit
a845e32960
@ -166,6 +166,7 @@ void MainWindow::createActions()
|
|||||||
connect(ui->pushButton_mainStart, SIGNAL(clicked(bool)), this, SLOT(mainTabStartProfile()));
|
connect(ui->pushButton_mainStart, SIGNAL(clicked(bool)), this, SLOT(mainTabStartProfile()));
|
||||||
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
|
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
|
||||||
connect(ui->tableWidget_main, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(mainTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
|
connect(ui->tableWidget_main, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(mainTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
|
||||||
|
connect(ui->tableWidget_main, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(mainTabContextualMenu(QPoint)));
|
||||||
|
|
||||||
// profile tab events
|
// profile tab events
|
||||||
connect(ui->lineEdit_profile, SIGNAL(returnPressed()), this, SLOT(profileTabLoadProfile()));
|
connect(ui->lineEdit_profile, SIGNAL(returnPressed()), this, SLOT(profileTabLoadProfile()));
|
||||||
@ -308,6 +309,60 @@ void MainWindow::updateWifiTab()
|
|||||||
|
|
||||||
|
|
||||||
// main tab slots
|
// main tab slots
|
||||||
|
void MainWindow::mainTabContextualMenu(const QPoint &pos)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]";
|
||||||
|
|
||||||
|
// create menu
|
||||||
|
QMenu menu(this);
|
||||||
|
QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh"));
|
||||||
|
menu.addSeparator();
|
||||||
|
QAction *startProfile = menu.addAction(QApplication::translate("MainWindow", "Start profile"));
|
||||||
|
QAction *restartProfile = menu.addAction(QApplication::translate("MainWindow", "Restart profile"));
|
||||||
|
QAction *enableProfile = menu.addAction(QApplication::translate("MainWindow", "Enable profile"));
|
||||||
|
menu.addSeparator();
|
||||||
|
QAction *removeProfile = menu.addAction(QApplication::translate("MainWindow", "Remove profile"));
|
||||||
|
|
||||||
|
// set text
|
||||||
|
QString item = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text();
|
||||||
|
if (!checkState(QString("inactive"), item)) {
|
||||||
|
restartProfile->setVisible(true);
|
||||||
|
startProfile->setText(QApplication::translate("MainWindow", "Stop profile"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
restartProfile->setVisible(false);
|
||||||
|
startProfile->setText(QApplication::translate("MainWindow", "Start profile"));
|
||||||
|
}
|
||||||
|
if (checkState(QString("enabled"), item))
|
||||||
|
enableProfile->setText(QApplication::translate("MainWindow", "Disable profile"));
|
||||||
|
else
|
||||||
|
enableProfile->setText(QApplication::translate("MainWindow", "Enable profile"));
|
||||||
|
|
||||||
|
// actions
|
||||||
|
QAction *action = menu.exec(ui->tableWidget_main->viewport()->mapToGlobal(pos));
|
||||||
|
if (action == refreshTable) {
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Refresh table";
|
||||||
|
updateMainTab();
|
||||||
|
}
|
||||||
|
else if (action == startProfile) {
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Start profile";
|
||||||
|
mainTabStartProfile();
|
||||||
|
}
|
||||||
|
else if (action == restartProfile) {
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Restart profile";
|
||||||
|
mainTabRestartProfile();
|
||||||
|
}
|
||||||
|
else if (action == enableProfile) {
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Enable profile";
|
||||||
|
mainTabEnableProfile();
|
||||||
|
}
|
||||||
|
else if (action == removeProfile) {
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Remove profile";
|
||||||
|
mainTabRemoveProfile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::mainTabRemoveProfile()
|
void MainWindow::mainTabRemoveProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[MainWindow]" << "[mainTabRemoveProfile]";
|
if (debug) qDebug() << "[MainWindow]" << "[mainTabRemoveProfile]";
|
||||||
|
@ -70,6 +70,7 @@ private slots:
|
|||||||
void updateProfileTab();
|
void updateProfileTab();
|
||||||
void updateWifiTab();
|
void updateWifiTab();
|
||||||
// main tab slots
|
// main tab slots
|
||||||
|
void mainTabContextualMenu(const QPoint &pos);
|
||||||
void mainTabRemoveProfile();
|
void mainTabRemoveProfile();
|
||||||
void mainTabEnableProfile();
|
void mainTabEnableProfile();
|
||||||
void mainTabRestartProfile();
|
void mainTabRestartProfile();
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>491</width>
|
<width>489</width>
|
||||||
<height>519</height>
|
<height>517</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -27,6 +27,9 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableWidget" name="tableWidget_main">
|
<widget class="QTableWidget" name="tableWidget_main">
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
<property name="editTriggers">
|
<property name="editTriggers">
|
||||||
<set>QAbstractItemView::NoEditTriggers</set>
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
</property>
|
</property>
|
||||||
@ -200,8 +203,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>96</width>
|
<width>457</width>
|
||||||
<height>26</height>
|
<height>359</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -365,7 +368,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>491</width>
|
<width>489</width>
|
||||||
<height>22</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user