View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0010289 | Scribus | Styles | public | 2011-09-29 16:13 | 2024-02-16 19:55 |
Reporter | cezaryece | Assigned To | |||
Priority | normal | Severity | tweak | Reproducibility | N/A |
Status | new | Resolution | open | ||
Product Version | 1.5.0svn | ||||
Summary | 0010289: [patch] make shortcuts for styles working | ||||
Description | My patch enabling feature of shortcuts for styles: paragraphs, chars, line and introducing feature for incoming table and cell styles. | ||||
Tags | #rottenpatch, oif, patch | ||||
Patch | Yes | ||||
has duplicate | 0012283 | closed | jghali | Apply style shortcut not available as proposed |
has duplicate | 0013558 | closed | jghali | In Character / Paragraph styles SHORTCUTS are missing |
has duplicate | 0015125 | closed | jghali | Make it possible to assign keyboard shortcuts to styles |
has duplicate | 0015200 | closed | jghali | How to asign keybord shortcuts to self created styles? |
has duplicate | 0016117 | closed | jghali | Assigning keyboard shortcuts for paragraph and charactert styles |
related to | 0009830 | new | Keyboard Shortcuts for Special Characters don't work | |
related to | 0017162 | new | [PATCH] apply style "shortcuts" based on the "action search" tool |
|
stylesshortcut.patch (4,980 bytes)
Index: scribus/scribusdoc.cpp =================================================================== --- scribus/scribusdoc.cpp (wersja 16859) +++ scribus/scribusdoc.cpp (kopia robocza) @@ -6564,8 +6564,13 @@ changed(); } } +void ScribusDoc::itemSelection_SetNamedTableStyle(const QString &name, Selection* customSelection) +{ +} +void ScribusDoc::itemSelection_SetNamedCellStyle(const QString &name, Selection* customSelection) +{ +} - void ScribusDoc::itemSelection_SetItemPen(QString farbe) { uint selectedItemCount=m_Selection->count(); @@ -14268,3 +14273,71 @@ } } +bool ScribusDoc::stylesShortcutKeyEvent(const QKeyEvent* k) +{ + int keyCode =0; + if (k->modifiers() & Qt::ShiftModifier) + keyCode |= Qt::SHIFT; + if (k->modifiers() & Qt::ControlModifier) + keyCode |= Qt::CTRL; + if (k->modifiers() & Qt::AltModifier) + keyCode |= Qt::ALT; + keyCode|=k->key(); + + QKeySequence key = QKeySequence(keyCode); + QString shortcut = key.toString(); + + //check if shortcut is used by setyles + for (int ff = 0; ff < paragraphStyles().count(); ++ff) + { + if (paragraphStyles()[ff].shortcut() == shortcut) + { + QString name = paragraphStyles()[ff].name(); + itemSelection_SetNamedParagraphStyle(name); +// ParagraphStyle newStyle; +// newStyle.setParent(name.isEmpty()? Style::INHERIT_PARENT : name); +// itemSelection_ApplyParagraphStyle(newStyle, m_Selection, true); + return true; + } + } + for (int ff = 0; ff < charStyles().count(); ++ff) + { + if (charStyles()[ff].shortcut() == shortcut) + { + QString name = charStyles()[ff].name(); + itemSelection_SetNamedCharStyle(name.isEmpty()? Style::INHERIT_PARENT : name); +// CharStyle newStyle; +// newStyle.setParent(name.isEmpty()? Style::INHERIT_PARENT : name); +// itemSelection_ApplyCharStyle(charStyles()[ff]); + return true; + } + } + for (QMap<QString,multiLine>::Iterator itMU = MLineStyles.begin(); itMU != MLineStyles.end(); ++itMU) + { + if (itMU.value().shortcut == shortcut) + { + QString name = itMU.key(); + itemSelection_SetNamedLineStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + for (int ff = 0; ff < tableStyles().count(); ++ff) + { + if (tableStyles()[ff].shortcut() == shortcut) + { + QString name = tableStyles()[ff].name(); + itemSelection_SetNamedTableStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + for (int ff = 0; ff < cellStyles().count(); ++ff) + { + if (cellStyles()[ff].shortcut() == shortcut) + { + QString name = cellStyles()[ff].name(); + itemSelection_SetNamedCellStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + return false; +} Index: scribus/scribusdoc.h =================================================================== --- scribus/scribusdoc.h (wersja 16859) +++ scribus/scribusdoc.h (kopia robocza) @@ -520,7 +520,6 @@ bool isDefaultStyle( const ParagraphStyle& p ) const { return docParagraphStyles.isDefault(p); } bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); } // bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; } - /** * Returns the table style named @a name. */ @@ -996,6 +995,8 @@ void itemSelection_SetNamedParagraphStyle(const QString & name, Selection* customSelection=0); void itemSelection_SetNamedCharStyle(const QString & name, Selection* customSelection=0); void itemSelection_SetNamedLineStyle(const QString & name, Selection* customSelection=0); + void itemSelection_SetNamedTableStyle(const QString & name, Selection* customSelection=0); + void itemSelection_SetNamedCellStyle(const QString & name, Selection* customSelection=0); void itemSelection_SetLineWidth(double w); void itemSelection_SetLineArt(Qt::PenStyle w); @@ -1529,6 +1530,10 @@ void updatePict(QString name); void updatePictDir(QString name); void removePict(QString name); + +//for styles shortcuts +public: + bool stylesShortcutKeyEvent(const QKeyEvent*); }; Q_DECLARE_METATYPE(ScribusDoc*); Index: scribus/scribusview.cpp =================================================================== --- scribus/scribusview.cpp (wersja 16859) +++ scribus/scribusview.cpp (kopia robocza) @@ -4214,6 +4214,8 @@ else if (event->type() == QEvent::KeyPress) { QKeyEvent* m = static_cast<QKeyEvent*> (event); + if (Doc->stylesShortcutKeyEvent(m)) + return true; if (m_canvasMode->handleKeyEvents()) m_canvasMode->keyPressEvent(m); else Index: scribus/ui/stylemanager.cpp =================================================================== --- scribus/ui/stylemanager.cpp (wersja 16859) +++ scribus/ui/stylemanager.cpp (kopia robocza) @@ -1318,7 +1318,7 @@ } m_widget = m_item->widget(); // show the widget for the style type //<<#8230: Hide the shortcut page as it does not work - //insertShortcutPage(m_widget); + insertShortcutPage(m_widget); //>> m_widget->setParent(mainFrame); m_layout->addWidget(m_widget, 0, 0); |
|
Several notes about the initial patch - processing of gui element in a non gui element (ScribusDoc) : i would feel quite uncomfortable in committing that - circumvent Qt shortcut system hence opening path to future bugs I looked if another approach was possible and discovered what we probably need in this case : QShortcut (damn, how did i not see that one before...). Contrary to QAction/ScrAction which need to be bound to a visible gui element to have its shortcut usable, QShortcut does not have such requirement. I consequently add a try to see how it works and... it works :) Attached the corresponding patch. We need to look a bit closer at how StyleManager manage shortcuts tho. Given how it works, i'm almost sure there are some bugs around here. |
|
What about this feature Jean? What can I do with it? |
|
Jean needs to comment here.. so I will assign it to him. We'd need a patch against current trunk, we'd need separation of GUI/non GUI, shortcut de-duplication with existing actions if its not there already. |
|
stylesShortCuts.diff (5,344 bytes)
diff --git a/Scribus/scribus/scribus.cpp b/Scribus/scribus/scribus.cpp index 47011bd..3fec90b 100644 --- a/Scribus/scribus/scribus.cpp +++ b/Scribus/scribus/scribus.cpp @@ -10255,3 +10255,65 @@ void ScribusMainWindow::updateTableMenuActions() scrActions["tableAdjustTableToFrame"]->setEnabled(table); } +bool ScribusMainWindow::stylesShortcutKeyEvent(const QKeyEvent* k) +{ + int keyCode =0; + if (k->modifiers() & Qt::ShiftModifier) + keyCode |= Qt::SHIFT; + if (k->modifiers() & Qt::ControlModifier) + keyCode |= Qt::CTRL; + if (k->modifiers() & Qt::AltModifier) + keyCode |= Qt::ALT; + keyCode|=k->key(); + + QKeySequence key = QKeySequence(keyCode); + QString shortcut = key.toString(); + + //check if shortcut is used by setyles + for (int ff = 0; ff < doc->paragraphStyles().count(); ++ff) + { + if (doc->paragraphStyles()[ff].shortcut() == shortcut) + { + QString name = doc->paragraphStyles()[ff].name(); + doc->itemSelection_SetNamedParagraphStyle(name); + return true; + } + } + for (int ff = 0; ff < doc->charStyles().count(); ++ff) + { + if (doc->charStyles()[ff].shortcut() == shortcut) + { + QString name = doc->charStyles()[ff].name(); + doc->itemSelection_SetNamedCharStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + for (QHash<QString,multiLine>::Iterator itMU = doc->MLineStyles.begin(); itMU != doc->MLineStyles.end(); ++itMU) + { + if (itMU.value().shortcut == shortcut) + { + QString name = itMU.key(); + doc->itemSelection_SetNamedLineStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + for (int ff = 0; ff < doc->tableStyles().count(); ++ff) + { + if (doc->tableStyles()[ff].shortcut() == shortcut) + { + QString name = doc->tableStyles()[ff].name(); + doc->itemSelection_SetNamedTableStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + for (int ff = 0; ff < doc->cellStyles().count(); ++ff) + { + if (doc->cellStyles()[ff].shortcut() == shortcut) + { + QString name = doc->cellStyles()[ff].name(); + doc->itemSelection_SetNamedCellStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + return false; +} diff --git a/Scribus/scribus/scribus.h b/Scribus/scribus/scribus.h index 042af8f..743495b 100644 --- a/Scribus/scribus/scribus.h +++ b/Scribus/scribus/scribus.h @@ -608,6 +608,10 @@ private: FormatsManager *formatsManager; QPointer<HelpBrowser> helpBrowser; + +//for styles shortcuts +public: + bool stylesShortcutKeyEvent(const QKeyEvent*); }; #endif diff --git a/Scribus/scribus/scribusdoc.cpp b/Scribus/scribus/scribusdoc.cpp index 99f5c32..410749d 100644 --- a/Scribus/scribus/scribusdoc.cpp +++ b/Scribus/scribus/scribusdoc.cpp @@ -7384,7 +7384,13 @@ void ScribusDoc::itemSelection_SetNamedLineStyle(const QString &name, Selection* changed(); } } - +//FIX ME - please implement these method +void ScribusDoc::itemSelection_SetNamedTableStyle(const QString &name, Selection* customSelection) +{ +} +void ScribusDoc::itemSelection_SetNamedCellStyle(const QString &name, Selection* customSelection) +{ +} void ScribusDoc::itemSelection_SetItemPen(QString farbe) { diff --git a/Scribus/scribus/scribusdoc.h b/Scribus/scribus/scribusdoc.h index d51441c..b529823 100644 --- a/Scribus/scribus/scribusdoc.h +++ b/Scribus/scribus/scribusdoc.h @@ -537,7 +537,6 @@ public: bool isDefaultStyle( const ParagraphStyle& p ) const { return docParagraphStyles.isDefault(p); } bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); } // bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; } - /** * Returns the table style named @a name. */ @@ -1031,6 +1030,8 @@ public: void itemSelection_SetNamedParagraphStyle(const QString & name, Selection* customSelection=0); void itemSelection_SetNamedCharStyle(const QString & name, Selection* customSelection=0); void itemSelection_SetNamedLineStyle(const QString & name, Selection* customSelection=0); + void itemSelection_SetNamedTableStyle(const QString & name, Selection* customSelection=0); + void itemSelection_SetNamedCellStyle(const QString & name, Selection* customSelection=0); void itemSelection_SetLineWidth(double w); void itemSelection_SetLineArt(Qt::PenStyle w); diff --git a/Scribus/scribus/scribusview.cpp b/Scribus/scribus/scribusview.cpp index f13d616..ca1b076 100644 --- a/Scribus/scribus/scribusview.cpp +++ b/Scribus/scribus/scribusview.cpp @@ -4256,6 +4256,8 @@ bool ScribusView::eventFilter(QObject *obj, QEvent *event) else if (event->type() == QEvent::KeyPress) { QKeyEvent* m = static_cast<QKeyEvent*> (event); + if (m_ScMW->stylesShortcutKeyEvent(m)) + return true; if (m_canvasMode->handleKeyEvents()) m_canvasMode->keyPressEvent(m); else diff --git a/Scribus/scribus/ui/stylemanager.cpp b/Scribus/scribus/ui/stylemanager.cpp index ffd34be..6a18076 100644 --- a/Scribus/scribus/ui/stylemanager.cpp +++ b/Scribus/scribus/ui/stylemanager.cpp @@ -1318,7 +1318,7 @@ void StyleManager::loadType(const QString &name) } m_widget = m_item->widget(); // show the widget for the style type //<<#8230: Hide the shortcut page as it does not work - //insertShortcutPage(m_widget); + insertShortcutPage(m_widget); //>> m_widget->setParent(mainFrame); m_layout->addWidget(m_widget, 0, 0); |
|
New patch. Processing moved to ScMW. As for now old Scrobus shortcuts manner. I think there should be complex move to usage of QShortcuts class for all shortcuts in Scribus, not only here. |
|
I have tested this feature in the scribusECE build to be found on http://www.scribus-ece.info/ and i must say it is a great enhancement for my use of 1.4 As for now, as a 1.4 user, so as to apply a style to some parts of text i need to reach the option where available, that is not easily : 1) In the PP it is a maze through opening and scrolling panes and subpanes just to reach the style selects. 2) Other ways are through the story editor, but since it doesnt open at the right place (see 0010963) it is difficult to use, since it takes very long and cautious reading to find the place where is the text to be styled. Whit this "shortcut for styles" patch, i have defined shortcuts for all the most common styles. I can then apply them at the speed of a keystroke. It speeds greatly my layout work, particularly on documents with long textes (where the story editor cannot be used). This patch is a must for scribus. I strongly recommend to bring it to 1.5 and even to 1.4 ! |
|
The "clear previous formatting before applying" option, that goes along with this patch too, is an greaaaat feature too, that helps really. |
|
No JLuc, ClearOnApply property is only in my ECE branches, not in this patch. |
|
Like JLuc i think this patch really improves comfort in text manipulation and increase productivity. The old patch now make rejection. here is a new one. |
|
scribus-stylesShortCuts-20140321.diff (5,246 bytes)
Index: scribus/scribusdoc.h =================================================================== --- scribus/scribusdoc.h (révision 18925) +++ scribus/scribusdoc.h (copie de travail) @@ -544,7 +544,6 @@ bool isDefaultStyle( const ParagraphStyle& p ) const { return docParagraphStyles.isDefault(p); } bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); } // bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; } - /** * Returns the table style named @a name. */ @@ -1045,6 +1044,8 @@ void itemSelection_SetNamedParagraphStyle(const QString & name, Selection* customSelection=0); void itemSelection_SetNamedCharStyle(const QString & name, Selection* customSelection=0); void itemSelection_SetNamedLineStyle(const QString & name, Selection* customSelection=0); + void itemSelection_SetNamedTableStyle(const QString & name, Selection* customSelection=0); + void itemSelection_SetNamedCellStyle(const QString & name, Selection* customSelection=0); void itemSelection_SetSoftShadow(bool has, QString color, double dx, double dy, double radius, int shade, double opac, int blend); Index: scribus/scribus.h =================================================================== --- scribus/scribus.h (révision 18925) +++ scribus/scribus.h (copie de travail) @@ -641,6 +641,10 @@ int m_marksCount; //remember marks count from last call bool m_WasAutoSave; bool m_pagePalVisible; + +public: + //for styles shortcuts + bool stylesShortcutKeyEvent(const QKeyEvent*); }; #endif Index: scribus/scribusview.cpp =================================================================== --- scribus/scribusview.cpp (révision 18925) +++ scribus/scribusview.cpp (copie de travail) @@ -4320,6 +4320,8 @@ else if (event->type() == QEvent::KeyPress) { QKeyEvent* m = static_cast<QKeyEvent*> (event); + if (m_ScMW->stylesShortcutKeyEvent(m)) + return true; if(m->key() == Qt::Key_Shift) { m_oldSnapToElem = Doc->SnapElement; Index: scribus/ui/stylemanager.cpp =================================================================== --- scribus/ui/stylemanager.cpp (révision 18925) +++ scribus/ui/stylemanager.cpp (copie de travail) @@ -1328,7 +1328,7 @@ } m_widget = m_item->widget(); // show the widget for the style type //<<#8230: Hide the shortcut page as it does not work - //insertShortcutPage(m_widget); + insertShortcutPage(m_widget); //>> m_widget->setParent(mainFrame); m_layout->addWidget(m_widget, 0, 0); Index: scribus/scribusdoc.cpp =================================================================== --- scribus/scribusdoc.cpp (révision 18925) +++ scribus/scribusdoc.cpp (copie de travail) @@ -7966,8 +7966,14 @@ changed(); } } +//FIX ME - please implement these method +void ScribusDoc::itemSelection_SetNamedTableStyle(const QString &name, Selection* customSelection) +{ +} +void ScribusDoc::itemSelection_SetNamedCellStyle(const QString &name, Selection* customSelection) +{ +} - void ScribusDoc::itemSelection_SetItemPen(QString farbe) { uint selectedItemCount=m_Selection->count(); Index: scribus/scribus.cpp =================================================================== --- scribus/scribus.cpp (révision 18925) +++ scribus/scribus.cpp (copie de travail) @@ -10601,3 +10601,67 @@ d.exec(); */ } + +bool ScribusMainWindow::stylesShortcutKeyEvent(const QKeyEvent* k) +{ + int keyCode =0; + if (k->modifiers() & Qt::ShiftModifier) + keyCode |= Qt::SHIFT; + if (k->modifiers() & Qt::ControlModifier) + keyCode |= Qt::CTRL; + if (k->modifiers() & Qt::AltModifier) + keyCode |= Qt::ALT; + keyCode|=k->key(); + + QKeySequence key = QKeySequence(keyCode); + QString shortcut = key.toString(); + if (shortcut.isEmpty()) + return false; + //check if shortcut is used by setyles + for (int ff = 0; ff < doc->paragraphStyles().count(); ++ff) + { + if (doc->paragraphStyles()[ff].shortcut() == shortcut) + { + QString name = doc->paragraphStyles()[ff].name(); + doc->itemSelection_SetNamedParagraphStyle(name); + return true; + } + } + for (int ff = 0; ff < doc->charStyles().count(); ++ff) + { + if (doc->charStyles()[ff].shortcut() == shortcut) + { + QString name = doc->charStyles()[ff].name(); + doc->itemSelection_SetNamedCharStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + for (QHash<QString,multiLine>::Iterator itMU = doc->MLineStyles.begin(); itMU != doc->MLineStyles.end(); ++itMU) + { + if (itMU.value().shortcut == shortcut) + { + QString name = itMU.key(); + doc->itemSelection_SetNamedLineStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + for (int ff = 0; ff < doc->tableStyles().count(); ++ff) + { + if (doc->tableStyles()[ff].shortcut() == shortcut) + { + QString name = doc->tableStyles()[ff].name(); + doc->itemSelection_SetNamedTableStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + for (int ff = 0; ff < doc->cellStyles().count(); ++ff) + { + if (doc->cellStyles()[ff].shortcut() == shortcut) + { + QString name = doc->cellStyles()[ff].name(); + doc->itemSelection_SetNamedCellStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + return false; +} |
|
0012283 has been closed because dupe of this one, but it isn't. Cezariece's #31818 patch and its by pygmee renewed version introduce a new property for each style, that possibly enables to apply the style using a user defined shortcut. 0012283 is about the allready existing "Apply" stylewindow context menu, whose supposed to exist shortcut (ALT+CTRL+") does not work properly. Unless you mean that this allready existing shortcut will not be necessary anymore because cezariece's new feature has to be merged and can to some extent replace it more powerfully ? FYI, " is available directly on the french keyboard (no need for a SHIFT modifier to reach it). |
|
I've uploaded updodate patch |
|
keyboardshortcutpatch_2014-05-03.diff (4,892 bytes)
Index: scribus/scribus.cpp =================================================================== --- scribus/scribus.cpp (révision 19097) +++ scribus/scribus.cpp (copie de travail) @@ -10896,3 +10896,68 @@ doc->allItems_ChangePreviewResolution(index); doc->view()->DrawNew(); } + +bool ScribusMainWindow::stylesShortcutKeyEvent(const QKeyEvent* k) +{ + int keyCode =0; + if (k->modifiers() & Qt::ShiftModifier) + keyCode |= Qt::SHIFT; + if (k->modifiers() & Qt::ControlModifier) + keyCode |= Qt::CTRL; + if (k->modifiers() & Qt::AltModifier) + keyCode |= Qt::ALT; + keyCode|=k->key(); + + QKeySequence key = QKeySequence(keyCode); + QString shortcut = key.toString(); + if (shortcut.isEmpty()) + return false; + //check if shortcut is used by setyles + for (int ff = 0; ff < doc->paragraphStyles().count(); ++ff) + { + if (doc->paragraphStyles()[ff].shortcut() == shortcut) + { + QString name = doc->paragraphStyles()[ff].name(); + doc->itemSelection_SetNamedParagraphStyle(name); + return true; + } + } + for (int ff = 0; ff < doc->charStyles().count(); ++ff) + { + if (doc->charStyles()[ff].shortcut() == shortcut) + { + QString name = doc->charStyles()[ff].name(); + doc->itemSelection_SetNamedCharStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + for (QHash<QString,multiLine>::Iterator itMU = doc->MLineStyles.begin(); itMU != doc->MLineStyles.end(); ++itMU) + { + if (itMU.value().shortcut == shortcut) + { + QString name = itMU.key(); + doc->itemSelection_SetNamedLineStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + for (int ff = 0; ff < doc->tableStyles().count(); ++ff) + { + if (doc->tableStyles()[ff].shortcut() == shortcut) + { + QString name = doc->tableStyles()[ff].name(); + doc->itemSelection_SetNamedTableStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + for (int ff = 0; ff < doc->cellStyles().count(); ++ff) + { + if (doc->cellStyles()[ff].shortcut() == shortcut) + { + QString name = doc->cellStyles()[ff].name(); + doc->itemSelection_SetNamedCellStyle(name.isEmpty()? Style::INHERIT_PARENT : name); + return true; + } + } + return false; +} + Index: scribus/scribus.h =================================================================== --- scribus/scribus.h (révision 19097) +++ scribus/scribus.h (copie de travail) @@ -673,6 +673,10 @@ bool m_pagePalVisible; QQuickView *qqview; + +public: + //for styles shortcuts + bool stylesShortcutKeyEvent(const QKeyEvent*); }; #endif Index: scribus/scribusdoc.cpp =================================================================== --- scribus/scribusdoc.cpp (révision 19097) +++ scribus/scribusdoc.cpp (copie de travail) @@ -7992,6 +7992,13 @@ } } +//FIX ME - please implement these method +void ScribusDoc::itemSelection_SetNamedTableStyle(const QString &name, Selection* customSelection) +{ +} +void ScribusDoc::itemSelection_SetNamedCellStyle(const QString &name, Selection* customSelection) +{ +} void ScribusDoc::itemSelection_SetItemPen(QString farbe) { Index: scribus/scribusdoc.h =================================================================== --- scribus/scribusdoc.h (révision 19097) +++ scribus/scribusdoc.h (copie de travail) @@ -1050,6 +1050,8 @@ void itemSelection_SetNamedParagraphStyle(const QString & name, Selection* customSelection=0); void itemSelection_SetNamedCharStyle(const QString & name, Selection* customSelection=0); void itemSelection_SetNamedLineStyle(const QString & name, Selection* customSelection=0); + void itemSelection_SetNamedTableStyle(const QString & name, Selection* customSelection=0); + void itemSelection_SetNamedCellStyle(const QString & name, Selection* customSelection=0); void itemSelection_SetSoftShadow(bool has, QString color, double dx, double dy, double radius, int shade, double opac, int blend); Index: scribus/scribusview.cpp =================================================================== --- scribus/scribusview.cpp (révision 19097) +++ scribus/scribusview.cpp (copie de travail) @@ -4040,6 +4040,9 @@ else if (event->type() == QEvent::KeyPress) { QKeyEvent* m = static_cast<QKeyEvent*> (event); + if (m_ScMW->stylesShortcutKeyEvent(m)) + return true; + if(m->key() == Qt::Key_Shift) { m_oldSnapToElem = Doc->SnapElement; Index: scribus/ui/stylemanager.cpp =================================================================== --- scribus/ui/stylemanager.cpp (révision 19097) +++ scribus/ui/stylemanager.cpp (copie de travail) @@ -1327,7 +1327,7 @@ } m_widget = m_item->widget(); // show the widget for the style type //<<#8230: Hide the shortcut page as it does not work - //insertShortcutPage(m_widget); + insertShortcutPage(m_widget); //>> m_widget->setParent(mainFrame); m_layout->addWidget(m_widget, 0, 0); |
|
My comment on the mailing list today: Right now, Scribus shortcuts do not allow a differentiation between application mode shortcuts or text mode shortcuts, nor do we set up actions with default keys like a,A,b,B. So, with this patch, styles can have a shortcut set as 'b', or 'shift b' for example.. which then stops you typing any more 'b's. Any thoughts on how to avoid that? |
|
10289_stylesshortcut.patch (11,824 bytes)
Index: scribus/CMakeLists.txt =================================================================== --- scribus/CMakeLists.txt (revision 19097) +++ scribus/CMakeLists.txt (working copy) @@ -474,6 +474,7 @@ ui/storyeditor.h ui/stylemanager.h ui/styleselect.h + ui/styleshortcut.h ui/styleview.h ui/swatchcombo.h ui/symbolpalette.h @@ -929,6 +930,7 @@ ui/storyeditor.cpp ui/stylemanager.cpp ui/styleselect.cpp + ui/styleshortcut.cpp ui/styleview.cpp ui/swatchcombo.cpp ui/symbolpalette.cpp Index: scribus/ui/stylemanager.cpp =================================================================== --- scribus/ui/stylemanager.cpp (revision 19097) +++ scribus/ui/stylemanager.cpp (working copy) @@ -27,6 +27,7 @@ #include "smtextstyles.h" #include "styleitem.h" #include "stylemanager.h" +#include "styleshortcut.h" #include "ui/customfdialog.h" #include "ui/styleview.h" @@ -209,7 +210,7 @@ m_rightClickPopup->removeAction(m_selectedStyleAction); m_selectedStyleAction = 0; } - m_styleActions.clear(); + m_styleShortcuts.clear(); for (int i = 0; i < m_items.count(); ++i) { m_items.at(i)->setCurrentDoc(doc); @@ -611,13 +612,12 @@ if (styleView->selectedItems().count() == 1) { QString key = item->rootName() + SEPARATOR + item->text(NAME_COL); - if (m_styleActions.contains(key)) + if (m_styleShortcuts.contains(key)) { - m_selectedStyleAction = m_styleActions[key]; - if (m_selectedStyleAction) - { - m_rightClickPopup->insertAction(m_rightClickPopup->actions().first(), m_selectedStyleAction); - } + QAction* action = m_rightClickPopup->addAction(tr("&Apply"), 0, 0, m_styleShortcuts[key]->key()); + m_rightClickPopup->removeAction(action); + m_rightClickPopup->insertAction( m_rightClickPopup->actions().first(), action); + m_selectedStyleAction = action; } } @@ -873,11 +873,11 @@ sitem->setText(SHORTCUT_COL, shortcutValue); QString key = sitem->rootName() + SEPARATOR + sitem->text(NAME_COL); - if (m_styleActions.contains(key)) + if (m_styleShortcuts.contains(key)) continue; - m_styleActions[key] = new ScrAction(ScrAction::DataQString, QPixmap(), QPixmap(), tr("&Apply"), shortcutValue, m_doc->view(), 0, 0.0, key); - connect(m_styleActions[key], SIGNAL(triggeredData(QString)), this, SLOT(slotApplyStyle(QString))); + m_styleShortcuts[key] = new StyleShortcut(shortcutValue, m_doc->view(), key); + connect(m_styleShortcuts[key], SIGNAL(activatedData(QString)), this, SLOT(slotApplyStyle(QString))); } } } @@ -1030,21 +1030,20 @@ QString oldKey = m_item->typeName() + SEPARATOR + oldName; QString newKey = m_item->typeName() + SEPARATOR + newName; - if (m_styleActions.contains(oldKey)) + if (m_styleShortcuts.contains(oldKey)) { - ScrAction *a = m_styleActions[oldKey]; - disconnect(a, SIGNAL(triggeredData(QString)), this, SLOT(slotApplyStyle(QString))); - ScrAction *b = new ScrAction(ScrAction::DataQString, QPixmap(), QPixmap(), tr("&Apply"), - a->shortcut(), m_doc->view(), 0, 0.0, newKey); - m_styleActions.remove(oldKey); - if (m_selectedStyleAction == a) + StyleShortcut *a = m_styleShortcuts[oldKey]; + disconnect(a, SIGNAL(activatedData(QString)), this, SLOT(slotApplyStyle(QString))); + StyleShortcut *b = new StyleShortcut(a->key(), m_doc->view(), newKey); + m_styleShortcuts.remove(oldKey); + if (m_selectedStyleAction) { m_rightClickPopup->removeAction(m_selectedStyleAction); m_selectedStyleAction = 0; } delete a; - m_styleActions[newKey] = b; - connect(b, SIGNAL(triggeredData(QString)), this, SLOT(slotApplyStyle(QString))); + m_styleShortcuts[newKey] = b; + connect(b, SIGNAL(activatedData(QString)), this, SLOT(slotApplyStyle(QString))); } } @@ -1069,13 +1068,12 @@ sitem->setText(SHORTCUT_COL, shortcut.isNull() ? "" : shortcut); QString key = sitem->rootName() + SEPARATOR + sitem->text(NAME_COL); - if (m_styleActions.contains(key)) - m_styleActions[key]->setShortcut(shortcut); + if (m_styleShortcuts.contains(key)) + m_styleShortcuts[key]->setKey(shortcut); else { - m_styleActions[key] = - new ScrAction(ScrAction::DataQString, QPixmap(), QPixmap(), tr("&Apply"), shortcut, m_doc->view(), 0, 0.0, key); - connect(m_styleActions[key], SIGNAL(triggeredData(QString)), + m_styleShortcuts[key] = new StyleShortcut(shortcut, m_doc->view(), key); + connect(m_styleShortcuts[key], SIGNAL(activatedData(QString)), this, SLOT(slotApplyStyle(QString))); } @@ -1087,10 +1085,10 @@ { QKeySequence key(keys); - QMap<QString, QPointer<ScrAction> >::iterator it; - for (it = m_styleActions.begin(); it != m_styleActions.end(); ++it) + QMap<QString, QPointer<StyleShortcut> >::iterator it; + for (it = m_styleShortcuts.begin(); it != m_styleShortcuts.end(); ++it) { - if ((*it)->shortcut() == key) + if ((*it)->key() == key) return true; } @@ -1327,7 +1325,7 @@ } m_widget = m_item->widget(); // show the widget for the style type //<<#8230: Hide the shortcut page as it does not work - //insertShortcutPage(m_widget); + insertShortcutPage(m_widget); //>> m_widget->setParent(mainFrame); m_layout->addWidget(m_widget, 0, 0); Index: scribus/ui/stylemanager.h =================================================================== --- scribus/ui/stylemanager.h (revision 19097) +++ scribus/ui/stylemanager.h (working copy) @@ -18,7 +18,7 @@ class StyleItem; class ScribusDoc; class ShortcutWidget; -class ScrAction; +class StyleShortcut; struct Keys; class SCRIBUS_API StyleManager : public ScrPaletteBase, Ui::StyleManager @@ -63,7 +63,7 @@ QAction *m_rcpEditId; QAction *m_rcpCloneId; // QAction *m_rcpToScrapId; - ScrAction *m_selectedStyleAction; + QAction *m_selectedStyleAction; bool m_isEditMode; bool m_isStoryEditMode; @@ -78,7 +78,7 @@ ScribusDoc *m_doc; PrefsContext *m_prefs; - QMap<QString, QPointer<ScrAction> > m_styleActions; + QMap<QString, QPointer<StyleShortcut> > m_styleShortcuts; static const int NAME_COL = 0; static const int SHORTCUT_COL = 1; Index: scribus/ui/styleshortcut.cpp =================================================================== --- scribus/ui/styleshortcut.cpp (revision 0) +++ scribus/ui/styleshortcut.cpp (revision 0) @@ -0,0 +1,20 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ + +#include "styleshortcut.h" + +StyleShortcut::StyleShortcut(const QKeySequence & key, QWidget * parent, const QString& data) + : QShortcut(key, parent), m_data(data) +{ + connect(this, SIGNAL(activated()), this, SLOT(activateData())); +} + +void StyleShortcut::activateData() +{ + emit activatedData(m_data); +} + Index: scribus/ui/styleshortcut.h =================================================================== --- scribus/ui/styleshortcut.h (revision 0) +++ scribus/ui/styleshortcut.h (revision 0) @@ -0,0 +1,31 @@ +/* +For general Scribus (>=1.3.2) copyright and licensing information please refer +to the COPYING file provided with the program. Following this notice may exist +a copyright and/or license notice that predates the release of Scribus 1.3.2 +for which a new license (GPL+exception) is in place. +*/ + +#ifndef STYLESHORTCUT_H +#define STYLESHORTCUT_H + +#include <QKeySequence> +#include <QShortcut> +#include <QString> + +class StyleShortcut : public QShortcut +{ + Q_OBJECT +public: + StyleShortcut(const QKeySequence & key, QWidget * parent, const QString& data); + +protected: + QString m_data; + +protected slots: + void activateData(); + +signals: + void activatedData(QString); +}; + +#endif Index: win32/vc10/scribus-main/Scribus.vcxproj =================================================================== --- win32/vc10/scribus-main/Scribus.vcxproj (revision 19097) +++ win32/vc10/scribus-main/Scribus.vcxproj (working copy) @@ -453,6 +453,7 @@ <moc Include="..\..\..\scribus\upgradechecker.h" /> <moc Include="..\..\..\scribus\ui\proptree.h" /> <moc Include="..\..\..\scribus\ui\viewtoolbar.h" /> + <moc Include="..\..\..\scribus\ui\styleshortcut.h" /> <ClInclude Include="resource.h" /> <ClInclude Include="..\..\..\scribus\resourcecollection.h" /> <moc Include="..\..\..\scribus\ui\rulermover.h" /> @@ -998,6 +999,7 @@ <ClCompile Include="..\..\..\scribus\mesh.cpp" /> <ClCompile Include="..\..\..\scribus\ui\missing.cpp" /> <ClCompile Include="..\..\..\scribus\ui\moc_proptree.cpp" /> + <ClCompile Include="..\..\..\scribus\ui\moc_styleshortcut.cpp" /> <ClCompile Include="..\..\..\scribus\ui\moc_viewtoolbar.cpp" /> <ClCompile Include="..\..\..\scribus\ui\modetoolbar.cpp" /> <ClCompile Include="..\..\..\scribus\ui\movepage.cpp" /> @@ -1202,6 +1204,7 @@ <ClCompile Include="..\..\..\scribus\scribusapp.cpp" /> <ClCompile Include="..\..\..\scribus\scribuscore.cpp" /> <ClCompile Include="..\..\..\scribus\scribusdoc.cpp" /> + <ClCompile Include="..\..\..\scribus\ui\styleshortcut.cpp" /> <ClCompile Include="..\..\..\scribus\ui\viewtoolbar.cpp" /> <ClCompile Include="..\..\..\scribus\upgradechecker.cpp" /> <ClCompile Include="scribuspch.cpp"> Index: win32/vc10/scribus-main/Scribus.vcxproj.filters =================================================================== --- win32/vc10/scribus-main/Scribus.vcxproj.filters (revision 19097) +++ win32/vc10/scribus-main/Scribus.vcxproj.filters (working copy) @@ -3455,6 +3455,12 @@ <ClCompile Include="..\..\..\scribus\ui\viewtoolbar.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="..\..\..\scribus\ui\styleshortcut.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\..\scribus\ui\moc_styleshortcut.cpp"> + <Filter>Generated Moc Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ResourceCompile Include="Scribus.rc"> @@ -4893,5 +4899,8 @@ <moc Include="..\..\..\scribus\ui\viewtoolbar.h"> <Filter>Header Files</Filter> </moc> + <moc Include="..\..\..\scribus\ui\styleshortcut.h"> + <Filter>Header Files</Filter> + </moc> </ItemGroup> </Project> \ No newline at end of file Index: win32/vc10/Scribus.sln =================================================================== --- win32/vc10/Scribus.sln (revision 19097) +++ win32/vc10/Scribus.sln (working copy) @@ -53,11 +53,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gettext-odtim", "gettext-odtim\gettext-odtim.vcxproj", "{181977C6-17C1-4ADB-B16A-5C6A9CD95427}" ProjectSection(ProjectDependencies) = postProject {B17FCD80-7978-4544-93C4-2FE1AC6FE9F3} = {B17FCD80-7978-4544-93C4-2FE1AC6FE9F3} + {6CC39EED-B1E2-4209-8F65-0E6242EE63E5} = {6CC39EED-B1E2-4209-8F65-0E6242EE63E5} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gettext-sxwim", "gettext-sxwim\gettext-sxwim.vcxproj", "{743095DE-B828-40AF-92F7-96FB751E0AF2}" ProjectSection(ProjectDependencies) = postProject {B17FCD80-7978-4544-93C4-2FE1AC6FE9F3} = {B17FCD80-7978-4544-93C4-2FE1AC6FE9F3} + {6CC39EED-B1E2-4209-8F65-0E6242EE63E5} = {6CC39EED-B1E2-4209-8F65-0E6242EE63E5} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gettext-textfilter", "gettext-textfilter\gettext-textfilter.vcxproj", "{3CF57996-98BE-4C6A-85D6-91A85107D52A}" |
|
i've created a plugin that allows to apply the styles by typing their names. i've been using it for some time now, but it still needs some testing. once it is ready, i think it's a better solution to "real shortcuts" for styles. |
|
I guess this is the source code for your plugin ale : https://github.com/aoloe/scribus-plugin-applyStyle How about your tests ? |
|
hi @JLuc, I've been using this plugin in production for a couple of years. as i wrote in the other ticket: """now, if there was a way to get the team to discuss and review this plugin and the whole infrastructure behind it...""" i need the feedback of the team on the API, i know it's not a simple thing and it will take time, but i'm not willing anymore to do the programming and then see the code rotting away for years. |
|
Nice to read it's working. Sad to read that bringing external contributions in scribus core is still very restricted. Didnt you discuss a patch quality and merge protocol agreement during previous LGM ? |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-09-29 16:13 | cezaryece | New Issue | |
2011-09-29 16:13 | cezaryece | File Added: stylesshortcut.patch | |
2011-09-30 08:55 | ale | Tag Attached: oif | |
2011-09-30 08:55 | ale | Tag Attached: oif 2011 | |
2011-10-01 14:50 | jghali | File Added: 10289_stylesshortcut.patch | |
2011-10-01 14:59 | jghali | File Deleted: 10289_stylesshortcut.patch | |
2011-10-01 15:03 | jghali | File Added: 10289_stylesshortcut.patch | |
2011-10-01 15:11 | jghali | Note Added: 0026937 | |
2011-10-02 18:31 | jghali | Note Edited: 0026937 | |
2012-06-18 12:50 | cezaryece | Note Added: 0028183 | |
2012-06-18 18:41 | cbradney | Note Added: 0028185 | |
2012-06-27 07:49 | cezaryece | File Added: stylesShortCuts.diff | |
2012-06-27 07:51 | cezaryece | Note Added: 0028309 | |
2012-06-27 07:53 | cezaryece | Note Edited: 0028309 | |
2012-09-21 08:44 | JLuc | Note Added: 0028952 | |
2012-09-21 10:28 | JLuc | Note Edited: 0028952 | |
2012-09-23 19:31 | JLuc | Note Added: 0028965 | |
2012-09-24 05:18 | cezaryece | Note Added: 0028968 | |
2014-03-21 08:51 | pygmee | Note Added: 0031530 | |
2014-03-21 08:51 | pygmee | File Added: scribus-stylesShortCuts-20140321.diff | |
2014-04-05 15:52 | christoph_s | Tag Attached: patch | |
2014-04-26 09:52 | jghali | Relationship added | has duplicate 0012283 |
2014-04-26 11:43 | JLuc | Note Added: 0031818 | |
2014-04-26 12:35 | JLuc | Note Edited: 0031818 | |
2014-04-26 12:36 | JLuc | Note Edited: 0031818 | |
2014-05-03 09:51 | JLuc | File Added: keyboardshortcutpatch_2014-05-03.diff | |
2014-05-03 09:51 | JLuc | Note Added: 0031836 | |
2014-05-03 09:54 | JLuc | File Deleted: keyboardshortcutpatch_2014-05-03.diff | |
2014-05-03 09:54 | JLuc | File Added: keyboardshortcutpatch_2014-05-03.diff | |
2014-05-04 18:08 | cbradney | Note Added: 0031837 | |
2014-05-05 21:27 | jghali | File Deleted: 10289_stylesshortcut.patch | |
2014-05-05 21:30 | jghali | File Added: 10289_stylesshortcut.patch | |
2014-10-08 22:59 | Kunda | Tag Attached: oif2011 | |
2014-10-08 22:59 | Kunda | Tag Detached: oif 2011 | |
2014-10-11 18:35 | Kunda | Tag Detached: oif2011 | |
2014-10-24 22:57 | Kunda | Patch | => Yes |
2015-10-27 16:40 | Kunda | Relationship added | related to 0009830 |
2015-11-24 18:14 | jghali | Relationship added | has duplicate 0013558 |
2018-02-02 13:25 | jghali | Relationship added | has duplicate 0015125 |
2018-02-02 16:56 | JLuc | Tag Attached: #rottenpatch | |
2018-03-19 01:54 | jghali | Relationship added | has duplicate 0015200 |
2018-03-20 09:33 | ale | File Added: apply-h1-list.gif | |
2018-03-20 09:33 | ale | Note Added: 0045059 | |
2020-05-26 13:52 | jghali | Relationship added | has duplicate 0016117 |
2020-05-26 15:19 | JLuc | Note Added: 0047640 | |
2020-05-27 07:35 | ale | Note Added: 0047642 | |
2020-05-27 14:01 | JLuc | Note Added: 0047643 | |
2024-02-16 19:55 | ale | Relationship added | related to 0017162 |