r17723 by craig - #10886: Add tooltips in for all action with their shortcuts

scribus-commit scribus-commit at lists.scribus.net
Tue Jul 17 20:58:51 UTC 2012


Author: craig
Date: Tue Jul 17 20:58:51 2012
New Revision: 17723

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17723
Log:
#10886: Add tooltips in for all action with their shortcuts

Modified:
    trunk/Scribus/scribus/actionmanager.cpp
    trunk/Scribus/scribus/actionmanager.h
    trunk/Scribus/scribus/prefsmanager.cpp
    trunk/Scribus/scribus/scraction.cpp
    trunk/Scribus/scribus/scraction.h
    trunk/Scribus/scribus/ui/storyeditor.cpp

Modified: trunk/Scribus/scribus/actionmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17723&path=/trunk/Scribus/scribus/actionmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/actionmanager.cpp (original)
+++ trunk/Scribus/scribus/actionmanager.cpp Tue Jul 17 20:58:51 2012
@@ -75,6 +75,7 @@
 	createDefaultMenus();
 	createDefaultNonMenuActions();
 	languageChange();
+	setActionTooltips(scrActions);
 }
 
 void ActionManager::createActions()
@@ -94,7 +95,6 @@
 	initUnicodeActions(scrActions, mainWindow, unicodeCharActionNames);
 	enableUnicodeActions(scrActions, false);
 	initSpecialActions();
-	
 }
 
 void ActionManager::initFileMenuActions()
@@ -1083,6 +1083,12 @@
 	connect( (*scrActions)["specialToggleAllGuides"], SIGNAL(triggered()), mainWindow, SLOT(ToggleAllGuides()) );
 }
 
+void ActionManager::setActionTooltips(QMap<QString, QPointer<ScrAction> > *actionMap)
+{
+	for( QMap<QString, QPointer<ScrAction> >::Iterator it = actionMap->begin(); it!=actionMap->end(); ++it )
+		it.value()->setToolTipFromTextAndShortcut();
+}
+
 void ActionManager::disconnectModeActions()
 {
 	for ( QStringList::Iterator it = modeActionNames->begin(); it != modeActionNames->end(); ++it )
@@ -1358,14 +1364,10 @@
 
 	//File Menu
 	(*scrActions)["fileNew"]->setTexts( tr("&New"));
-	(*scrActions)["fileNew"]->setToolTip( tr("New")+" <b>"+QString(defaultKey("fileNew"))+"</b>");
 	(*scrActions)["fileNewFromTemplate"]->setTexts( tr("New &from Template..."));
 	(*scrActions)["fileOpen"]->setTexts( tr("&Open..."));
-	(*scrActions)["fileOpen"]->setToolTip( tr("Open...")+" <b>"+QString(defaultKey("fileOpen"))+"</b>");
 	(*scrActions)["fileClose"]->setTexts( tr("&Close"));
-	(*scrActions)["fileClose"]->setToolTip( tr("Close")+" <b>"+QString(defaultKey("fileClose"))+"</b>");
 	(*scrActions)["fileSave"]->setTexts( tr("&Save"));
-	(*scrActions)["fileSave"]->setToolTip( tr("Save")+" <b>"+QString(defaultKey("fileSave"))+"</b>");
 	(*scrActions)["fileSaveAs"]->setTexts( tr("Save &As..."));
 	(*scrActions)["fileRevert"]->setTexts( tr("Re&vert to Saved"));
 	(*scrActions)["fileCollect"]->setTexts( tr("Collect for O&utput..."));
@@ -1382,14 +1384,11 @@
 //	(*scrActions)["filePreferences"]->setTexts( tr("P&references (old)..."));
 	(*scrActions)["filePreferences150"]->setTexts( tr("P&references..."));
 	(*scrActions)["filePrint"]->setTexts( tr("&Print..."));
-	(*scrActions)["filePrint"]->setToolTip( tr("Print...")+" <b>"+QString(defaultKey("filePrint"))+"</b>");
 	(*scrActions)["PrintPreview"]->setTexts( tr("Print Previe&w"));
 	(*scrActions)["fileQuit"]->setTexts( tr("&Quit"));
 	//Edit Menu
 	(*scrActions)["editUndoAction"]->setTexts( tr("&Undo"));
-	(*scrActions)["editUndoAction"]->setToolTip( tr("Undo")+" <b>"+QString(defaultKey("editUndoAction"))+"</b>");
 	(*scrActions)["editRedoAction"]->setTexts( tr("&Redo"));
-	(*scrActions)["editRedoAction"]->setToolTip( tr("Redo")+" <b>"+QString(defaultKey("editRedoAction"))+"</b>");
 	(*scrActions)["editActionMode"]->setTexts( tr("&Item Action Mode"));
 	(*scrActions)["editCut"]->setTexts( tr("Cu&t"));
 	(*scrActions)["editCopy"]->setTexts( tr("&Copy"));
@@ -1562,49 +1561,31 @@
 
 	//toolbar only items
 	(*scrActions)["toolsSelect"]->setTexts( tr("Select Item"));
-	(*scrActions)["toolsSelect"]->setToolTip( tr("Select Item")+" <b>"+QString(defaultKey("toolsSelect"))+"</b>");
 	(*scrActions)["toolsRotate"]->setTexts( tr("Rotate Item"));
-	(*scrActions)["toolsRotate"]->setToolTip( tr("Rotate Item")+" <b>"+QString(defaultKey("toolsRotate"))+"</b>");
 	(*scrActions)["toolsZoom"]->setTexts( tr("Zoom in or out"));
-	(*scrActions)["toolsZoom"]->setToolTip( tr("Zoom in or out")+" <b>"+QString(defaultKey("toolsZoom"))+"</b>");
 	(*scrActions)["toolsZoomIn"]->setTexts( tr("Zoom in"));
 	(*scrActions)["toolsZoomOut"]->setTexts( tr("Zoom out"));
 	(*scrActions)["toolsEditContents"]->setTexts( tr("Edit Contents of Frame"));
-	(*scrActions)["toolsEditContents"]->setToolTip( tr("Edit Contents of Frame")+" <b>"+QString(defaultKey("toolsEditContents"))+"</b>");
 	(*scrActions)["toolsEditWithStoryEditor"]->setText( tr("Edit Text..."));
-	(*scrActions)["toolsEditWithStoryEditor"]->setToolTip( tr("Edit Text...")+" <b>"+QString(defaultKey("toolsEditWithStoryEditor"))+"</b>");
 	(*scrActions)["toolsLinkTextFrame"]->setTexts( tr("Link Text Frames"));
-	(*scrActions)["toolsLinkTextFrame"]->setToolTip( tr("Link Text Frames")+" <b>"+QString(defaultKey("toolsLinkTextFrame"))+"</b>");
 	(*scrActions)["toolsUnlinkTextFrame"]->setTexts( tr("Unlink Text Frames"));
-	(*scrActions)["toolsUnlinkTextFrame"]->setToolTip( tr("Unlink Text Frames")+" <b>"+QString(defaultKey("toolsUnlinkTextFrame"))+"</b>");
 	(*scrActions)["toolsUnlinkTextFrameWithTextCopy"]->setTexts( tr("Unlink Text Frame with Text Copy"));
 	(*scrActions)["toolsUnlinkTextFrameWithTextCut"]->setTexts( tr("Unlink Text Frame with Text Cut"));
 	(*scrActions)["toolsEyeDropper"]->setTexts( tr("&Eye Dropper"));
-	(*scrActions)["toolsEyeDropper"]->setToolTip( tr("Eye Dropper")+" <b>"+QString(defaultKey("toolsEyeDropper"))+"</b>");
 	(*scrActions)["toolsCopyProperties"]->setTexts( tr("Copy Item Properties"));
-	(*scrActions)["toolsCopyProperties"]->setToolTip( tr("Copy Item Properties")+" <b>"+QString(defaultKey("toolsCopyProperties"))+"</b>");
 
 	(*scrActions)["toolsInsertTextFrame"]->setText( tr("Insert &Text Frame"));
-	(*scrActions)["toolsInsertTextFrame"]->setToolTip( tr("Insert Text Frame")+" <b>"+QString(defaultKey("toolsInsertTextFrame"))+"</b>");
 	(*scrActions)["toolsInsertImageFrame"]->setText( tr("Insert &Image Frame"));
-	(*scrActions)["toolsInsertImageFrame"]->setToolTip( tr("Insert Image Frame")+" <b>"+QString(defaultKey("toolsInsertImageFrame"))+"</b>");
 	(*scrActions)["toolsInsertRenderFrame"]->setText( tr("Insert &Render Frame"));
-	(*scrActions)["toolsInsertRenderFrame"]->setToolTip( tr("Insert Render Frame")+" <b>"+QString(defaultKey("toolsInsertRenderFrame"))+"</b>");
 	(*scrActions)["toolsInsertTable"]->setText( tr("Insert T&able"));
-	(*scrActions)["toolsInsertTable"]->setToolTip( tr("Insert Table")+" <b>"+QString(defaultKey("toolsInsertTable"))+"</b>");
 	(*scrActions)["toolsInsertShape"]->setText( tr("Insert &Shape"));
-	(*scrActions)["toolsInsertShape"]->setToolTip( tr("Insert Shape")+" <b>"+QString(defaultKey("toolsInsertShape"))+"</b>");
 	(*scrActions)["toolsInsertPolygon"]->setText( tr("Insert &Polygon"));
-	(*scrActions)["toolsInsertPolygon"]->setToolTip( tr("Insert Polygon")+" <b>"+QString(defaultKey("toolsInsertPolygon"))+"</b>");
 	(*scrActions)["toolsInsertArc"]->setText( tr("Insert Arc"));
 	(*scrActions)["toolsInsertSpiral"]->setText( tr("Insert Spiral"));
 	(*scrActions)["toolsInsertLine"]->setText( tr("Insert &Line"));
-	(*scrActions)["toolsInsertLine"]->setToolTip( tr("Insert Line")+" <b>"+QString(defaultKey("toolsInsertLine"))+"</b>");
 	(*scrActions)["toolsInsertCalligraphicLine"]->setText( tr("Insert Calligraphic Line"));
 	(*scrActions)["toolsInsertBezier"]->setText( tr("Insert &Bezier Curve"));
-	(*scrActions)["toolsInsertBezier"]->setToolTip( tr("Insert Bezier Curve")+" <b>"+QString(defaultKey("toolsInsertBezier"))+"</b>");
 	(*scrActions)["toolsInsertFreehandLine"]->setText( tr("Insert &Freehand Line"));
-	(*scrActions)["toolsInsertFreehandLine"]->setToolTip( tr("Insert Freehand Line")+" <b>"+QString(defaultKey("toolsInsertFreehandLine"))+"</b>");
 
 	(*scrActions)["toolsPDFPushButton"]->setTexts( tr("Insert PDF Push Button"));
 	(*scrActions)["toolsPDFTextField"]->setTexts( tr("Insert PDF Text Field"));

Modified: trunk/Scribus/scribus/actionmanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17723&path=/trunk/Scribus/scribus/actionmanager.h
==============================================================================
--- trunk/Scribus/scribus/actionmanager.h (original)
+++ trunk/Scribus/scribus/actionmanager.h Tue Jul 17 20:58:51 2012
@@ -103,6 +103,7 @@
 		void initHelpMenuActions();
 		static void initUnicodeActions(QMap<QString, QPointer<ScrAction> > *actionMap, QWidget *actionParent, QStringList *actionNamesList);
 		void initSpecialActions();
+		static void setActionTooltips(QMap<QString, QPointer<ScrAction> > *actionMap);
 		static void languageChangeUnicodeActions(QMap<QString, QPointer<ScrAction> > *actionMap);
 		void languageChangeActions();
 		static QKeySequence defaultKey(const QString &actionName);

Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17723&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp (original)
+++ trunk/Scribus/scribus/prefsmanager.cpp Tue Jul 17 20:58:51 2012
@@ -512,7 +512,10 @@
 		if (!it.value().actionName.isEmpty())
 		{
 			if (ScCore->primaryMainWindow()->scrActions[it.value().actionName])
+			{
 				ScCore->primaryMainWindow()->scrActions[it.value().actionName]->setShortcut(it.value().keySequence);
+				ScCore->primaryMainWindow()->scrActions[it.value().actionName]->setToolTipFromTextAndShortcut();
+			}
 		}
 	}
 }

Modified: trunk/Scribus/scribus/scraction.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17723&path=/trunk/Scribus/scribus/scraction.cpp
==============================================================================
--- trunk/Scribus/scribus/scraction.cpp (original)
+++ trunk/Scribus/scribus/scraction.cpp Tue Jul 17 20:58:51 2012
@@ -238,6 +238,15 @@
 	return text().remove('&').remove("...");
 }
 
+void ScrAction::setToolTipFromTextAndShortcut()
+{
+	QString sct(shortcut());
+	if (sct.isEmpty())
+		QAction::setToolTip("<qt>" + cleanMenuText() + "</qt>");
+	else
+		QAction::setToolTip("<qt>" + cleanMenuText() + " (<b>" + sct + "</b>)" + "</qt>");
+}
+
 int ScrAction::getMenuIndex() const
 {
 	return menuIndex;

Modified: trunk/Scribus/scribus/scraction.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17723&path=/trunk/Scribus/scribus/scraction.h
==============================================================================
--- trunk/Scribus/scribus/scraction.h (original)
+++ trunk/Scribus/scribus/scraction.h Tue Jul 17 20:58:51 2012
@@ -112,6 +112,8 @@
 		\retval QString Stripped copy of the menu text
 	*/
 	QString cleanMenuText();
+
+	void setToolTipFromTextAndShortcut();
 
 	/*!
 		\author Craig Bradney

Modified: trunk/Scribus/scribus/ui/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17723&path=/trunk/Scribus/scribus/ui/storyeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/storyeditor.cpp (original)
+++ trunk/Scribus/scribus/ui/storyeditor.cpp Tue Jul 17 20:58:51 2012
@@ -1965,6 +1965,7 @@
 	EditorBar->editor = Editor;
 	Editor->installEventFilter(this);
 	languageChange();
+	ActionManager::setActionTooltips(&seActions);
 }
 
 void StoryEditor::changeEvent(QEvent *e)




More information about the scribus-commit mailing list