comparison widgets/KeyReference.cpp @ 740:a31c8ee2e17e tonioni

Allow registering an alternative shortcut using QKeySequence so as to get the right native string
author Chris Cannam
date Thu, 06 Mar 2014 14:27:59 +0000
parents dfe543438d52
children 394caa98d21a
comparison
equal deleted inserted replaced
739:dfe543438d52 740:a31c8ee2e17e
85 QString name = action->text(); 85 QString name = action->text();
86 registerAlternativeShortcut(name, alternative); 86 registerAlternativeShortcut(name, alternative);
87 } 87 }
88 88
89 void 89 void
90 KeyReference::registerAlternativeShortcut(QAction *action, QKeySequence shortcut)
91 {
92 QString name = action->text();
93 registerAlternativeShortcut(name, shortcut.toString(QKeySequence::NativeText));
94 }
95
96 void
90 KeyReference::registerAlternativeShortcut(QString name, QString alternative) 97 KeyReference::registerAlternativeShortcut(QString name, QString alternative)
91 { 98 {
92 name.replace(tr("&"), ""); 99 name.replace(tr("&"), "");
93 100
94 KeyList &list = m_map[m_currentCategory]; 101 KeyList &list = m_map[m_currentCategory];
97 if (i->actionName == name) { 104 if (i->actionName == name) {
98 i->alternatives.push_back(alternative); 105 i->alternatives.push_back(alternative);
99 return; 106 return;
100 } 107 }
101 } 108 }
109 }
110
111 void
112 KeyReference::registerAlternativeShortcut(QString name, QKeySequence shortcut)
113 {
114 registerAlternativeShortcut(name, shortcut.toString(QKeySequence::NativeText));
102 } 115 }
103 116
104 void 117 void
105 KeyReference::show() 118 KeyReference::show()
106 { 119 {
145 altdesc += tr("<i>or</i>&nbsp;<b>%1</b>").arg(alt); 158 altdesc += tr("<i>or</i>&nbsp;<b>%1</b>").arg(alt);
146 } 159 }
147 altdesc = tr("</b>&nbsp;(%1)<b>").arg(altdesc); 160 altdesc = tr("</b>&nbsp;(%1)<b>").arg(altdesc);
148 } 161 }
149 162
150 text += QString("<tr><td>&nbsp;<b>%1%2</b></td><td>&nbsp;%3</td><td>%4</td></tr>\n") 163 text += QString("<tr><td width=\"12%\">&nbsp;<b>%1%2</b></td><td>&nbsp;%3</td><td>%4</td></tr>\n")
151 .arg(shortcut).arg(altdesc).arg(actionName).arg(tip); 164 .arg(shortcut).arg(altdesc).arg(actionName).arg(tip);
152 } 165 }
153 } 166 }
154 167
155 text += "</table></center>\n"; 168 text += "</table></center>\n";