3 Copyright (C) 2010 Christian Pulvermacher
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 KeyMenu::KeyMenu(QWidget *parent):
26 setWindowTitle(tr("Additional Keys"));
27 QTabWidget *tabwidget = new QTabWidget(this);
30 ActionTab *mod_tab = new ActionTab(this);
31 QAction *win = new QAction(tr("Win"), this);
32 win->setShortcut(Qt::META);
33 win->setCheckable(true);
34 mod_tab->addAction(win);
35 QAction *alt = new QAction(tr("Alt"), this);
36 alt->setShortcut(Qt::ALT);
37 alt->setCheckable(true);
38 mod_tab->addAction(alt);
39 tabwidget->addTab(mod_tab, tr("Modifiers"));
41 //movement/text editing keys
42 ActionTab *other_tab = new ActionTab(this);
43 other_tab->addAction(tr("Insert"), Qt::Key_Insert);
44 other_tab->addAction(tr("Delete"), Qt::Key_Delete);
45 other_tab->addAction(tr("Backspace"), Qt::Key_Backspace);
46 other_tab->addAction(tr("Home"), Qt::Key_Home);
47 other_tab->addAction(tr("End"), Qt::Key_End);
48 tabwidget->addTab(other_tab, tr("Editing"));
51 ActionTab *fx_tab = new ActionTab(this);
52 for(int i = 1; i<=12; i++)
53 fx_tab->addAction(tr("F%1").arg(i), QString("F%1").arg(i));
54 tabwidget->addTab(fx_tab, tr("F1-F12"));
57 ActionTab *misc_tab = new ActionTab(this);
58 misc_tab->addAction(tr("Pause"), QString("Pause"));
59 misc_tab->addAction(tr("Print"), QString("print"));
60 misc_tab->addAction(tr("Menu"), QString("Menu"));
61 misc_tab->addAction(tr("Ctrl+Alt+Del"), QString("Ctrl+Alt+Delete"));
62 misc_tab->addAction(tr("Ctrl+Alt+Backspace"), QString("Ctrl+Alt+Backspace"));
63 tabwidget->addTab(misc_tab, tr("Misc"));
65 QVBoxLayout *layout = new QVBoxLayout();
66 layout->addWidget(tabwidget);
70 void KeyMenu::accept()
72 QAction* selected_action = qobject_cast<QAction* >(sender());
73 if(!selected_action) {
74 keysequence = QKeySequence();
76 keysequence = selected_action->shortcut();
82 ActionTab::ActionTab(KeyMenu *parent):
86 setWidgetResizable(true);
88 widget.setLayout(&layout);
91 void ActionTab::addAction(QString text, QKeySequence keysequence)
93 QAction *action = new QAction(text, this);
94 action->setShortcut(keysequence);
99 void ActionTab::addAction(QAction *action)
101 connect(action, SIGNAL(triggered()),
102 keymenu, SLOT(accept()));
104 QToolButton *button = new QToolButton();
105 button->setDefaultAction(action);
106 layout.addWidget(button);