21 #include <QVBoxLayout> 22 #include <QDialogButtonBox> 23 #include <QApplication> 50 QString name = action->text();
51 if (overrideName !=
"") name = overrideName;
53 QString shortcut = action->shortcut().toString(QKeySequence::NativeText);
54 QString tip = action->statusTip();
62 name.replace(tr(
"&"),
"");
66 for (KeyList::iterator i = list.begin(); i != list.end(); ++i) {
67 if (i->actionName == name) {
68 i->shortcut = shortcut;
70 i->alternatives.clear();
80 list.push_back(details);
86 QString name = action->text();
93 QString name = action->text();
100 name.replace(tr(
"&"),
"");
104 for (KeyList::iterator i = list.begin(); i != list.end(); ++i) {
105 if (i->actionName == name) {
106 i->alternatives.push_back(alternative);
129 QColor bgcolor = QApplication::palette().window().color();
130 bool darkbg = (bgcolor.red() + bgcolor.green() + bgcolor.blue() < 384);
132 text += QString(
"<center><table bgcolor=\"%1\">")
133 .arg(darkbg ?
"#121212" :
"#e8e8e8");
138 QString category = *i;
141 text += QString(
"<tr><td bgcolor=\"%1\" colspan=3 align=\"center\"><br><b>%2</b><br></td></tr>\n").arg(darkbg ?
"#303030" :
"#d0d0d0").arg(category);
143 for (KeyList::iterator j = list.begin(); j != list.end(); ++j) {
145 QString actionName = j->actionName;
147 QString shortcut = j->shortcut;
148 shortcut.replace(
" ",
" ");
150 QString tip = j->tip;
151 if (tip !=
"") tip = QString(
"<i>%1</i>").arg(tip);
154 if (!j->alternatives.empty()) {
155 for (std::vector<QString>::iterator k = j->alternatives.begin();
156 k != j->alternatives.end(); ++k) {
158 alt.replace(
" ",
" ");
159 altdesc += tr(
"<i>or</i> <b>%1</b>").arg(alt);
161 altdesc = tr(
"</b> (%1)<b>").arg(altdesc);
164 text += QString(
"<tr><td width=\"12%\"> <b>%1%2</b></td><td> %3</td><td>%4</td></tr>\n")
165 .arg(shortcut).arg(altdesc).arg(actionName).arg(tip);
169 text +=
"</table></center>\n";
173 m_text->setReadOnly(
true);
176 m_dialog->setWindowTitle(tr(
"%1: Key and Mouse Reference")
177 .arg(QApplication::applicationName()));
179 QVBoxLayout *layout =
new QVBoxLayout;
181 layout->addWidget(
m_text);
183 QDialogButtonBox *bb =
new QDialogButtonBox(QDialogButtonBox::Close);
184 connect(bb, SIGNAL(clicked(QAbstractButton *)),
this, SLOT(
dialogButtonClicked(QAbstractButton *)));
185 layout->addWidget(bb);
189 QScreen *screen = QGuiApplication::primaryScreen();
190 QRect available = screen->availableGeometry();
192 int width = available.width() * 3 / 5;
193 int height = available.height() * 2 / 3;
195 if (available.height() > 500) height = 450;
198 if (available.width() > 650) width = 600;
void dialogButtonClicked(QAbstractButton *)
QString m_currentCategory
void setCategory(QString category)
CategoryList m_categoryOrder
std::vector< KeyDetails > KeyList
void registerAlternativeShortcut(QAction *, QString alternative)
void registerShortcut(QAction *, QString overrideName="")