mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
implement contextual menu to listWidgets
This commit is contained in:
parent
f56f319075
commit
f0c79a4dab
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>700</width>
|
<width>700</width>
|
||||||
<height>592</height>
|
<height>590</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -41,9 +41,9 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>-225</y>
|
<y>-239</y>
|
||||||
<width>677</width>
|
<width>675</width>
|
||||||
<height>801</height>
|
<height>813</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
@ -469,7 +469,11 @@ $m - uptime minutes without zero</string>
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="listWidget_bars"/>
|
<widget class="QListWidget" name="listWidget_bars">
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
@ -82,6 +82,8 @@ private slots:
|
|||||||
void addBar();
|
void addBar();
|
||||||
void addCustomScript();
|
void addCustomScript();
|
||||||
void addNewPkgCommand(QTableWidgetItem *item);
|
void addNewPkgCommand(QTableWidgetItem *item);
|
||||||
|
void contextMenuBars(const QPoint pos);
|
||||||
|
void contextMenuCustomCommand(const QPoint pos);
|
||||||
void contextMenuPkgCommand(const QPoint pos);
|
void contextMenuPkgCommand(const QPoint pos);
|
||||||
void editBar(QListWidgetItem *item);
|
void editBar(QListWidgetItem *item);
|
||||||
void editCustomCommand(QListWidgetItem *item);
|
void editCustomCommand(QListWidgetItem *item);
|
||||||
|
@ -451,8 +451,12 @@ void AwesomeWidget::createConfigurationInterface(KConfigDialog *parent)
|
|||||||
this, SLOT(editTempItem(QListWidgetItem *)));
|
this, SLOT(editTempItem(QListWidgetItem *)));
|
||||||
connect(uiAdvancedConfig.listWidget_bars, SIGNAL(itemActivated(QListWidgetItem *)),
|
connect(uiAdvancedConfig.listWidget_bars, SIGNAL(itemActivated(QListWidgetItem *)),
|
||||||
this, SLOT(editBar(QListWidgetItem *)));
|
this, SLOT(editBar(QListWidgetItem *)));
|
||||||
|
connect(uiAdvancedConfig.listWidget_bars, SIGNAL(customContextMenuRequested(QPoint)),
|
||||||
|
this, SLOT(contextMenuBars(QPoint)));
|
||||||
connect(uiDEConfig.listWidget_custom, SIGNAL(itemActivated(QListWidgetItem *)),
|
connect(uiDEConfig.listWidget_custom, SIGNAL(itemActivated(QListWidgetItem *)),
|
||||||
this, SLOT(editCustomCommand(QListWidgetItem *)));
|
this, SLOT(editCustomCommand(QListWidgetItem *)));
|
||||||
|
connect(uiDEConfig.listWidget_custom, SIGNAL(customContextMenuRequested(QPoint)),
|
||||||
|
this, SLOT(contextMenuCustomCommand(QPoint)));
|
||||||
connect(uiDEConfig.tableWidget_pkgCommand, SIGNAL(itemChanged(QTableWidgetItem *)),
|
connect(uiDEConfig.tableWidget_pkgCommand, SIGNAL(itemChanged(QTableWidgetItem *)),
|
||||||
this, SLOT(addNewPkgCommand(QTableWidgetItem *)));
|
this, SLOT(addNewPkgCommand(QTableWidgetItem *)));
|
||||||
connect(uiDEConfig.tableWidget_pkgCommand, SIGNAL(customContextMenuRequested(QPoint)),
|
connect(uiDEConfig.tableWidget_pkgCommand, SIGNAL(customContextMenuRequested(QPoint)),
|
||||||
@ -763,6 +767,50 @@ void AwesomeWidget::addNewPkgCommand(QTableWidgetItem *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AwesomeWidget::contextMenuBars(const QPoint pos)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (uiAdvancedConfig.listWidget_bars->currentItem() == 0) return;
|
||||||
|
|
||||||
|
QMenu menu(uiAdvancedConfig.listWidget_bars);
|
||||||
|
QAction *edit = menu.addAction(QIcon::fromTheme("document-edit"), i18n("Edit"));
|
||||||
|
QAction *remove = menu.addAction(QIcon::fromTheme("edit-delete"), i18n("Remove"));
|
||||||
|
QAction *action = menu.exec(uiAdvancedConfig.listWidget_bars->viewport()->mapToGlobal(pos));
|
||||||
|
if (action == edit)
|
||||||
|
editBar(uiAdvancedConfig.listWidget_bars->currentItem());
|
||||||
|
else if (action == remove)
|
||||||
|
for (int i=0; i<graphicalItems.count(); i++) {
|
||||||
|
if (graphicalItems[i]->getFileName() != uiAdvancedConfig.listWidget_bars->currentItem()->text())
|
||||||
|
continue;
|
||||||
|
graphicalItems[i]->tryDelete();
|
||||||
|
graphicalItems.takeAt(i);
|
||||||
|
uiAdvancedConfig.listWidget_bars->takeItem(uiAdvancedConfig.listWidget_bars->currentRow());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AwesomeWidget::contextMenuCustomCommand(const QPoint pos)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (uiDEConfig.listWidget_custom->currentItem() == 0) return;
|
||||||
|
|
||||||
|
QMenu menu(uiDEConfig.listWidget_custom);
|
||||||
|
QAction *edit = menu.addAction(QIcon::fromTheme("document-edit"), i18n("Edit"));
|
||||||
|
QAction *remove = menu.addAction(QIcon::fromTheme("edit-delete"), i18n("Remove"));
|
||||||
|
QAction *action = menu.exec(uiDEConfig.listWidget_custom->viewport()->mapToGlobal(pos));
|
||||||
|
if (action == edit)
|
||||||
|
editCustomCommand(uiDEConfig.listWidget_custom->currentItem());
|
||||||
|
else if (action == remove) {
|
||||||
|
QStringList dirs = KGlobal::dirs()->findDirs("data", "plasma_engine_extsysmon/scripts");
|
||||||
|
ExtScript *script = new ExtScript(0, uiDEConfig.listWidget_custom->currentItem()->text(), dirs, debug);
|
||||||
|
script->tryDelete();
|
||||||
|
delete script;
|
||||||
|
uiDEConfig.listWidget_custom->takeItem(uiDEConfig.listWidget_custom->currentRow());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AwesomeWidget::contextMenuPkgCommand(const QPoint pos)
|
void AwesomeWidget::contextMenuPkgCommand(const QPoint pos)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>700</width>
|
<width>700</width>
|
||||||
<height>584</height>
|
<height>582</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -43,7 +43,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>684</width>
|
<width>684</width>
|
||||||
<height>568</height>
|
<height>566</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
@ -507,7 +507,11 @@ del - remove item</string>
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="listWidget_custom"/>
|
<widget class="QListWidget" name="listWidget_custom">
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user