r20409 by fschmid -
scribus-commit
scribus-commit at lists.scribus.net
Sun Sep 20 16:07:16 UTC 2015
Author: fschmid
Date: Sun Sep 20 16:07:15 2015
New Revision: 20409
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20409
Log:
Fixed Bug #13291: Add Edit/Remove in right-click menu of Symbols palette
Modified:
trunk/Scribus/scribus/ui/symbolpalette.cpp
trunk/Scribus/scribus/ui/symbolpalette.h
Modified: trunk/Scribus/scribus/ui/symbolpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20409&path=/trunk/Scribus/scribus/ui/symbolpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/symbolpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/symbolpalette.cpp Sun Sep 20 16:07:15 2015
@@ -48,16 +48,20 @@
connect(this, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleContextMenu(QPoint)));
}
-void SymbolView::HandleContextMenu(QPoint)
-{
- QMenu *pmenu = new QMenu();
- QAction* viewAct;
- viewAct = pmenu->addAction( tr("Display Icons only"));
- viewAct->setCheckable(true);
- viewAct->setChecked(delegate->iconOnly());
- connect(viewAct, SIGNAL(triggered()), this, SLOT(changeDisplay()));
- pmenu->exec(QCursor::pos());
- delete pmenu;
+void SymbolView::HandleContextMenu(QPoint p)
+{
+ QListWidgetItem *item = itemAt(p);
+ if (!item)
+ {
+ QMenu *pmenu = new QMenu();
+ QAction* viewAct;
+ viewAct = pmenu->addAction( tr("Display Icons only"));
+ viewAct->setCheckable(true);
+ viewAct->setChecked(delegate->iconOnly());
+ connect(viewAct, SIGNAL(triggered()), this, SLOT(changeDisplay()));
+ pmenu->exec(QCursor::pos());
+ delete pmenu;
+ }
}
void SymbolView::changeDisplay()
@@ -159,14 +163,57 @@
m_scMW = NULL;
editItemNames.clear();
languageChange();
+ m_item = NULL;
connect(SymbolViewWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
+ connect(SymbolViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(handleContextMenue(QPoint)));
connect(SymbolViewWidget, SIGNAL(objectDropped()), this, SIGNAL(objectDropped()));
+}
+
+void SymbolPalette::handleContextMenue(QPoint p)
+{
+ if (!m_doc)
+ return;
+ QListWidgetItem *item = SymbolViewWidget->itemAt(p);
+ if (item)
+ {
+ m_item = item;
+ QMenu *pmenu = new QMenu();
+ QAction* editAct = pmenu->addAction( tr("Edit Item"));
+ connect(editAct, SIGNAL(triggered()), this, SLOT(handleEditItem()));
+ QAction* delAct = pmenu->addAction( tr("Remove Item"));
+ connect(delAct, SIGNAL(triggered()), this, SLOT(handleDeleteItem()));
+ pmenu->exec(QCursor::pos());
+ delete pmenu;
+ }
}
void SymbolPalette::handleDoubleClick(QListWidgetItem *item)
{
if (item)
emit startEdit(item->text());
+}
+
+void SymbolPalette::handleEditItem()
+{
+ if (m_item != NULL)
+ {
+ emit startEdit(m_item->text());
+ m_item = NULL;
+ }
+}
+
+void SymbolPalette::handleDeleteItem()
+{
+ if (m_item != NULL)
+ {
+ if (m_doc->docPatterns.contains(m_item->text()))
+ {
+ m_doc->removePattern(m_item->text());
+ updateSymbolList();
+ m_doc->regionsChanged()->update(QRect());
+ }
+ m_item = NULL;
+ }
}
void SymbolPalette::editingStart(QStringList names)
@@ -291,6 +338,7 @@
{
m_doc->removePattern(it->text());
updateSymbolList();
+ m_doc->regionsChanged()->update(QRect());
e->accept();
}
}
Modified: trunk/Scribus/scribus/ui/symbolpalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20409&path=/trunk/Scribus/scribus/ui/symbolpalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/symbolpalette.h (original)
+++ trunk/Scribus/scribus/ui/symbolpalette.h Sun Sep 20 16:07:15 2015
@@ -53,7 +53,7 @@
~SymbolView() {};
public slots:
- void HandleContextMenu(QPoint);
+ void HandleContextMenu(QPoint p);
void changeDisplay();
protected:
@@ -87,7 +87,10 @@
virtual void changeEvent(QEvent *e);
public slots:
+ void handleContextMenue(QPoint p);
void handleDoubleClick(QListWidgetItem *item);
+ void handleEditItem();
+ void handleDeleteItem();
void handleUpdateRequest(int);
void languageChange();
void keyPressEvent(QKeyEvent *e);
@@ -103,6 +106,7 @@
ScribusDoc *m_doc;
ScribusMainWindow *m_scMW;
QStringList editItemNames;
+ QListWidgetItem *m_item;
};
#endif
More information about the scribus-commit
mailing list