mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 23:47:21 +00:00
add contextual actions to wifi tab
This commit is contained in:
parent
a845e32960
commit
bf799ce061
@ -181,6 +181,7 @@ void MainWindow::createActions()
|
|||||||
connect(ui->pushButton_wifiStart, SIGNAL(clicked(bool)), this, SLOT(wifiTabStart()));
|
connect(ui->pushButton_wifiStart, SIGNAL(clicked(bool)), this, SLOT(wifiTabStart()));
|
||||||
connect(ui->tableWidget_wifi, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(wifiTabStart()));
|
connect(ui->tableWidget_wifi, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(wifiTabStart()));
|
||||||
connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(wifiTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
|
connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(wifiTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
|
||||||
|
connect(ui->tableWidget_wifi, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(wifiTabContextualMenu(QPoint)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -657,6 +658,7 @@ void MainWindow::profileTabClear()
|
|||||||
ipWid->clear();
|
ipWid->clear();
|
||||||
bridgeWid->clear();
|
bridgeWid->clear();
|
||||||
ethernetWid->clear();
|
ethernetWid->clear();
|
||||||
|
macvlanWid->clear();
|
||||||
mobileWid->clear();
|
mobileWid->clear();
|
||||||
pppoeWid->clear();
|
pppoeWid->clear();
|
||||||
tunnelWid->clear();
|
tunnelWid->clear();
|
||||||
@ -952,6 +954,40 @@ void MainWindow::profileTabLoadProfile()
|
|||||||
|
|
||||||
|
|
||||||
// wifi tab slots
|
// wifi tab slots
|
||||||
|
void MainWindow::wifiTabContextualMenu(const QPoint &pos)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[wifiTabContextualMenu]";
|
||||||
|
|
||||||
|
// create menu
|
||||||
|
QMenu menu(this);
|
||||||
|
QAction *refreshTable = menu.addAction(QApplication::translate("MainWindow", "Refresh"));
|
||||||
|
menu.addSeparator();
|
||||||
|
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))
|
||||||
|
startWifi->setText(QApplication::translate("MainWindow", "Stop WiFi"));
|
||||||
|
else
|
||||||
|
startWifi->setText(QApplication::translate("MainWindow", "Start WiFi"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
startWifi->setText(QApplication::translate("MainWindow", "Start WiFi"));
|
||||||
|
|
||||||
|
// actions
|
||||||
|
QAction *action = menu.exec(ui->tableWidget_main->viewport()->mapToGlobal(pos));
|
||||||
|
if (action == refreshTable) {
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[wifiTabContextualMenu]" << "Refresh WiFi";
|
||||||
|
updateWifiTab();
|
||||||
|
}
|
||||||
|
else if (action == startWifi) {
|
||||||
|
if (debug) qDebug() << "[MainWindow]" << "[wifiTabContextualMenu]" << "Start WiFi";
|
||||||
|
wifiTabStart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::wifiTabSetEnabled(const bool state)
|
void MainWindow::wifiTabSetEnabled(const bool state)
|
||||||
{
|
{
|
||||||
if (state) {
|
if (state) {
|
||||||
|
@ -83,6 +83,7 @@ private slots:
|
|||||||
void profileTabCreateProfile();
|
void profileTabCreateProfile();
|
||||||
void profileTabLoadProfile();
|
void profileTabLoadProfile();
|
||||||
// wifi tab slots
|
// wifi tab slots
|
||||||
|
void wifiTabContextualMenu(const QPoint &pos);
|
||||||
void wifiTabSetEnabled(const bool state);
|
void wifiTabSetEnabled(const bool state);
|
||||||
void wifiTabStart();
|
void wifiTabStart();
|
||||||
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||||
|
@ -274,6 +274,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableWidget" name="tableWidget_wifi">
|
<widget class="QTableWidget" name="tableWidget_wifi">
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
<property name="editTriggers">
|
<property name="editTriggers">
|
||||||
<set>QAbstractItemView::NoEditTriggers</set>
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user