Freeciv-3.2
Loading...
Searching...
No Matches
shortcuts.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18
19// Qt
20#include <QDialog>
21#include <QDialogButtonBox>
22#include <QGridLayout>
23#include <QLabel>
24#include <QMouseEvent>
25#include <QLineEdit>
26#include <QScrollArea>
27#include <QSettings>
28#include <QVBoxLayout>
29#include <QWidget>
30
31// client
32#include "options.h"
33
34// gui-qt
35#include "fc_client.h"
36#include "shortcuts.h"
37
38extern "C" void real_menus_init();
39
41static QString button_name(Qt::MouseButton bt);
45
46enum {
52};
53
54static bool use_default_shortcuts = false;
55
57
59 {SC_SCROLL_MAP, 0, Qt::RightButton, Qt::NoModifier, "Scroll map" },
60 {SC_CENTER_VIEW, Qt::Key_C, Qt::AllButtons, Qt::NoModifier,
61 _("Center View") },
62 {SC_FULLSCREEN, Qt::Key_Return, Qt::AllButtons, Qt::AltModifier,
63 _("Fullscreen") },
64 {SC_MINIMAP, Qt::Key_H, Qt::AllButtons, Qt::ShiftModifier,
65 _("Show minimap") },
66 {SC_CITY_OUTPUT, Qt::Key_V, Qt::AllButtons, Qt::ControlModifier,
67 _("City Output") },
68 {SC_MAP_GRID, Qt::Key_G, Qt::AllButtons, Qt::ControlModifier,
69 _("Map Grid") },
70 {SC_NAT_BORDERS, Qt::Key_B, Qt::AllButtons, Qt::ControlModifier,
71 _("National Borders") },
72 {SC_QUICK_BUY, 0, Qt::LeftButton, Qt::ControlModifier | Qt::ShiftModifier,
73 _("Quick buy from map") },
74 {SC_QUICK_SELECT, 0, Qt::LeftButton, Qt::ControlModifier,
75 _("Quick production select from map") },
76 {SC_SELECT_BUTTON, 0, Qt::LeftButton, Qt::NoModifier,
77 _("Select button") },
78 {SC_ADJUST_WORKERS, 0, Qt::LeftButton,
79 Qt::MetaModifier | Qt::ControlModifier, _("Adjust workers") },
80 {SC_APPEND_FOCUS, 0, Qt::LeftButton, Qt::MetaModifier,
81 _("Append focus") },
82 {SC_POPUP_INFO, 0, Qt::MiddleButton, Qt::NoModifier,
83 _("Popup tile info") },
84 {SC_WAKEUP_SENTRIES, 0, Qt::MiddleButton, Qt::ControlModifier,
85 _("Wakeup sentries") },
86 {SC_MAKE_LINK, 0, Qt::RightButton, Qt::ControlModifier | Qt::AltModifier,
87 _("Show link to tile") },
88 {SC_PASTE_PROD, 0, Qt::RightButton,
89 Qt::ShiftModifier | Qt::ControlModifier, _("Paste production") },
90 {SC_COPY_PROD, 0, Qt::RightButton,
91 Qt::ShiftModifier, _("Copy production") },
92 {SC_HIDE_WORKERS, 0, Qt::RightButton,
93 Qt::ShiftModifier | Qt::AltModifier, _("Show/hide workers") },
94 {SC_SHOW_UNITS, Qt::Key_Space, Qt::AllButtons, Qt::ControlModifier,
95 _("Units selection (for tile under mouse position)") },
96 {SC_TRADE_ROUTES, Qt::Key_D, Qt::AllButtons, Qt::ControlModifier,
97 _("City Trade Routes") },
98 {SC_CITY_PROD, Qt::Key_P, Qt::AllButtons, Qt::ControlModifier,
99 _("City Production Levels") },
100 {SC_CITY_NAMES, Qt::Key_N, Qt::AllButtons, Qt::ControlModifier,
101 _("City Names") },
102 {SC_DONE_MOVING, Qt::Key_Space, Qt::AllButtons, Qt::NoModifier,
103 _("Done Moving") },
104 {SC_GOTOAIRLIFT, Qt::Key_T, Qt::AllButtons, Qt::NoModifier,
105 _("Go to/Airlift to City...") },
106 {SC_AUTOEXPLORE, Qt::Key_X, Qt::AllButtons, Qt::NoModifier,
107 _("Auto Explore") },
108 {SC_PATROL, Qt::Key_Q, Qt::AllButtons, Qt::NoModifier,
109 _("Patrol") },
110 {SC_UNSENTRY_TILE, Qt::Key_D, Qt::AllButtons,
111 Qt::ShiftModifier | Qt::ControlModifier, _("Unsentry All On Tile") },
112 {SC_DO, Qt::Key_D, Qt::AllButtons, Qt::NoModifier, _("Do...") },
113 {SC_UPGRADE_UNIT, Qt::Key_U, Qt::AllButtons, Qt::ShiftModifier,
114 _("Upgrade") },
115 {SC_SETHOME, Qt::Key_H, Qt::AllButtons, Qt::NoModifier,
116 _("Set Home City") },
117 {SC_BUILDMINE, Qt::Key_M, Qt::AllButtons, Qt::NoModifier,
118 _("Build Mine") },
119 {SC_PLANT, Qt::Key_M, Qt::AllButtons, Qt::ShiftModifier,
120 _("Plant") },
121 {SC_BUILDIRRIGATION, Qt::Key_I, Qt::AllButtons, Qt::NoModifier,
122 _("Build Irrigation") },
123 {SC_CULTIVATE, Qt::Key_I, Qt::AllButtons, Qt::ShiftModifier,
124 _("Cultivate") },
125 {SC_BUILDROAD, Qt::Key_R, Qt::AllButtons, Qt::NoModifier,
126 _("Build Road") },
127 {SC_BUILDCITY, Qt::Key_B, Qt::AllButtons, Qt::NoModifier,
128 _("Build City") },
129 {SC_SENTRY, Qt::Key_S, Qt::AllButtons, Qt::NoModifier,
130 _("Sentry") },
131 {SC_FORTIFY, Qt::Key_F, Qt::AllButtons, Qt::NoModifier,
132 _("Fortify") },
133 {SC_GOTO, Qt::Key_G, Qt::AllButtons, Qt::NoModifier,
134 _("Go to Tile") },
135 {SC_WAIT, Qt::Key_W, Qt::AllButtons, Qt::NoModifier,
136 _("Wait") },
137 {SC_TRANSFORM, Qt::Key_O, Qt::AllButtons, Qt::NoModifier,
138 _("Transform") },
139 {SC_NUKE, Qt::Key_N, Qt::AllButtons, Qt::ShiftModifier,
140 _("Explode Nuclear") },
141 {SC_BOARD, Qt::Key_L, Qt::AllButtons, Qt::NoModifier,
142 _("Load") },
143 {SC_DEBOARD, Qt::Key_U, Qt::AllButtons, Qt::NoModifier,
144 _("Unload") },
145 {SC_BUY_MAP, 0, Qt::BackButton, Qt::NoModifier,
146 _("Quick buy current production from map") },
147 {SC_IFACE_LOCK, Qt::Key_L, Qt::AllButtons, Qt::ControlModifier
148 | Qt::ShiftModifier, _("Lock/unlock interface") },
149 {SC_AUTOMATE, Qt::Key_A, Qt::AllButtons, Qt::NoModifier,
150 _("Auto worker") },
151 {SC_CLEAN, Qt::Key_P, Qt::AllButtons, Qt::NoModifier,
152 _("Clean") },
153 {SC_POPUP_COMB_INF, Qt::Key_F1, Qt::AllButtons, Qt::ControlModifier,
154 _("Popup combat information") },
155 {SC_RELOAD_THEME, Qt::Key_F5, Qt::AllButtons, Qt::ControlModifier
156 | Qt::ShiftModifier, _("Reload theme") },
157 {SC_RELOAD_TILESET, Qt::Key_F6, Qt::AllButtons, Qt::ControlModifier
158 | Qt::ShiftModifier, _("Reload tileset") },
159 {SC_SHOW_FULLBAR, Qt::Key_F, Qt::AllButtons, Qt::ControlModifier,
160 _("Toggle city full bar visibility") },
161 {SC_ZOOM_IN, Qt::Key_Plus, Qt::AllButtons, Qt::NoModifier,
162 _("Reload zoomed in tileset") },
163 {SC_ZOOM_OUT, Qt::Key_Minus, Qt::AllButtons, Qt::NoModifier,
164 _("Reload zoomed out tileset") },
165 {SC_LOAD_LUA, Qt::Key_J, Qt::AllButtons, Qt::ControlModifier
166 | Qt::ShiftModifier, _("Load Lua script") },
167 {SC_RELOAD_LUA, Qt::Key_K, Qt::AllButtons, Qt::ControlModifier
168 | Qt::ShiftModifier, _("Load last loaded Lua script") },
169 {SC_ZOOM_RESET, Qt::Key_Backspace, Qt::AllButtons, Qt::ControlModifier,
170 _("Reload tileset with default scale") },
171 {SC_GOBUILDCITY, Qt::Key_B, Qt::AllButtons, Qt::ShiftModifier,
172 _("Go And Build City") },
173 {SC_GOJOINCITY, Qt::Key_J, Qt::AllButtons, Qt::ShiftModifier,
174 _("Go And Join City") },
175 {SC_STACK_SIZE, Qt::Key_Plus, Qt::AllButtons, Qt::ControlModifier,
176 _("Unit Stack Size") },
177 {SC_PARADROP, Qt::Key_J, Qt::AllButtons, Qt::NoModifier,
178 _("Paradrop") }
179};
180
181/**********************************************************************/
185{
186 QString ret, m, bn, k;
187
188 if (sc == nullptr) {
189 return "";
190 }
191 if (sc->mod != Qt::NoModifier) {
192 m = QKeySequence(sc->mod).toString(QKeySequence::NativeText);
193 }
194 if (sc->mouse != Qt::AllButtons) {
195 bn = button_name(sc->mouse);
196 }
197 if (sc->key != 0) {
198 k = QKeySequence(sc->key).toString(QKeySequence::NativeText);
199 }
200 ret = m + bn + k;
201
202 return ret;
203}
204
205/**********************************************************************/
212
213/**********************************************************************/
217{
218 qDeleteAll(hash.begin(), hash.end());
219 hash.clear();
220}
221
222
223/**********************************************************************/
227{
228 fc_shortcut *s;
229 s = hash.value(id);
230 return s->str;
231}
232
233/**********************************************************************/
237{
238 fc_shortcut *s;
239 s = hash.value(id);
240 return s;
241}
242
243/**********************************************************************/
250
251/**********************************************************************/
255{
257
258 sc = hash.value(s->id);
259 sc->key = s->key;
260 sc->mod = s->mod;
261 sc->mouse = s->mouse;
262}
263
264/**********************************************************************/
268{
269 if (m_instance) {
270 delete m_instance;
271 m_instance = nullptr;
272 }
273}
274
275/**********************************************************************/
279{
280 if (!m_instance) {
282 }
283
284 return m_instance;
285}
286
287/**********************************************************************/
292{
293 return m_instance != nullptr;
294}
295
296/**********************************************************************/
300{
301 int i;
302 bool suc = false;
303
304 hash.clear();
305
306 if (read) {
308 }
309
310 for (i = 0 ; i < num_shortcuts; i++) {
311 fc_shortcut *s = nullptr;
312
313 if (suc) {
314 s = fc_shortcuts::hash.value(static_cast<shortcut_id>(i + 1));
315 }
316 if (s == nullptr) {
317 s = new fc_shortcut();
318 s->id = default_shortcuts[i].id;
323 hash.insert(default_shortcuts[i].id, s);
324 }
325 }
326}
327
328/**********************************************************************/
332{
335 setAttribute(Qt::WA_DeleteOnClose);
336 setWindowFlags(Qt::Popup);
337 vb->addWidget(&edit);
338 setLayout(vb);
339 sc = nullptr;
340}
341
342/**********************************************************************/
346{
347 setContextMenuPolicy(Qt::NoContextMenu);
348 setWindowModality(Qt::WindowModal);
349}
350
351/**********************************************************************/
355{
357 shc.mouse = event->button();
358 shc.mod = event->modifiers();
359 fcp = reinterpret_cast<fc_shortcut_popup *>(parentWidget());
360 fcp->sc->mouse = shc.mouse;
361 fcp->sc->mod = shc.mod;
362 fcp->sc->key = 0;
363 parentWidget()->close();
364}
365
366/**********************************************************************/
370{
372
373 shc.key = event->key();
374 shc.mod = event->modifiers();
375 fcp = reinterpret_cast<fc_shortcut_popup *>(parentWidget());
376 fcp->sc->mouse = Qt::AllButtons;
377 fcp->sc->key = shc.key;
378 fcp->sc->mod = shc.mod;
379 parentWidget()->close();
380}
381
382/**********************************************************************/
386{
387 QPoint p(50, 20);
388 edit.setReadOnly(true);
389 edit.setFocus();
390 setWindowModality(Qt::WindowModal);
391 sc = s;
392 move(QCursor::pos() - p);
393 show();
394}
395
396/**********************************************************************/
400{
402
403 if (sc != nullptr) {
404 if (!check_if_exist()) {
405 scp = reinterpret_cast<fc_sc_button *>(parentWidget());
406 scp->setText(shortcut_to_string(scp->sc));
408 }
409 }
410
411 QDialog::closeEvent(ev);
412}
413
414/**********************************************************************/
419{
421 QString desc;
422 int id = 0;
423
424 desc = "";
425 if (sc != nullptr) {
426 foreach (fsc, fc_shortcuts::sc()->hash) {
427 if (id == 0) {
428 id++;
429 continue;
430 }
431 if (*sc == *fsc) {
432 desc = fc_shortcuts::sc()->get_desc(static_cast<shortcut_id>(id + 1));
433 }
434 id++;
435 }
436 if (desc.isEmpty()) {
437 desc = gui()->menu_bar->shortcut_exist(sc);
438 }
439 if (!desc.isEmpty()) {
442 fsb->show_info(desc);
443 return true;
444 }
445 }
446
447 return false;
448}
449
450/**********************************************************************/
453QString button_name(Qt::MouseButton bt)
454{
455 switch (bt) {
456 case Qt::NoButton:
457 return _("NoButton");
458 case Qt::LeftButton:
459 return _("LeftButton");
460 case Qt::RightButton:
461 return _("RightButton");
462 case Qt::MiddleButton:
463 return _("MiddleButton");
464 case Qt::BackButton:
465 return _("BackButton");
466 case Qt::ForwardButton:
467 return _("ForwardButton");
468 case Qt::TaskButton:
469 return _("TaskButton");
470 case Qt::ExtraButton4:
471 return _("ExtraButton4");
472 case Qt::ExtraButton5:
473 return _("ExtraButton5");
474 case Qt::ExtraButton6:
475 return _("ExtraButton6");
476 case Qt::ExtraButton7:
477 return _("ExtraButton7");
478 case Qt::ExtraButton8:
479 return _("ExtraButton8");
480 case Qt::ExtraButton9:
481 return _("ExtraButton9");
482 case Qt::ExtraButton10:
483 return _("ExtraButton10");
484 case Qt::ExtraButton11:
485 return _("ExtraButton11");
486 case Qt::ExtraButton12:
487 return _("ExtraButton12");
488 case Qt::ExtraButton13:
489 return _("ExtraButton13");
490 case Qt::ExtraButton14:
491 return _("ExtraButton14");
492 case Qt::ExtraButton15:
493 return _("ExtraButton15");
494 case Qt::ExtraButton16:
495 return _("ExtraButton16");
496 case Qt::ExtraButton17:
497 return _("ExtraButton17");
498 case Qt::ExtraButton18:
499 return _("ExtraButton18");
500 case Qt::ExtraButton19:
501 return _("ExtraButton19");
502 case Qt::ExtraButton20:
503 return _("ExtraButton20");
504 case Qt::ExtraButton21:
505 return _("ExtraButton21");
506 case Qt::ExtraButton22:
507 return _("ExtraButton22");
508 case Qt::ExtraButton23:
509 return _("ExtraButton23");
510 case Qt::ExtraButton24:
511 return _("ExtraButton24");
512 default:
513 return "";
514 }
515}
516
517/**********************************************************************/
521{
522 sc = new fc_shortcut;
523}
524
525/**********************************************************************/
529{
530 sc_orig = s;
531 sc = new fc_shortcut;
532 sc->id = sc_orig->id;
533 sc->key = sc_orig->key;
534 sc->mouse = sc_orig->mouse;
535 sc->mod = sc_orig->mod;
536 sc->str = sc_orig->str;
538}
539
540/**********************************************************************/
548
549/**********************************************************************/
553{
557
558 // Wait until shortcut popup is destroyed
560 if (fsb_list.count() > 0) {
561 QTimer::singleShot(20, this, SLOT(popup_error()));
562 return;
563 }
564
565 // TRANS: Given shortcut(%1) is already assigned
566 title = QString(_("%1 is already assigned to"))
567 .arg(shortcut_to_string(sc));
568 scinfo = new hud_message_box(gui()->central_wdg);
569 scinfo->setStandardButtons(QMessageBox::Ok);
570 scinfo->setDefaultButton(QMessageBox::Ok);
571 scinfo->set_text_title(err_message, title);
572 scinfo->setAttribute(Qt::WA_DeleteOnClose);
573 scinfo->show();
574}
575
576/**********************************************************************/
580 : QDialog(parent)
581{
582 setWindowTitle(_("Shortcuts options"));
584 init();
585}
586
587/**********************************************************************/
593
594/**********************************************************************/
598{
599 fc_shortcut *sc;
600 QPushButton *but;
601 QScrollArea *scroll;
602 QSize size;
603 QString desc;
604 QWidget *widget;
606
607 widget = new QWidget(this);
608 scroll = new QScrollArea(this);
609 scroll->setWidgetResizable(true);
612 foreach (sc, fc_shortcuts::sc()->hash) {
613 id = fc_shortcuts::sc()->get_id(sc);
614 desc = fc_shortcuts::sc()->get_desc(id);
615 add_option(sc);
616 }
617 widget->setProperty("doomed", true);
618 widget->setLayout(scroll_layout);
619 scroll->setWidget(widget);
620 main_layout->addWidget(scroll);
621
623 but = new QPushButton(style()->standardIcon(QStyle::SP_DialogCancelButton),
624 _("Cancel"));
625 button_box->addButton(but, QDialogButtonBox::ActionRole);
626 QObject::connect(but, &QPushButton::clicked, [this]() {
628 });
629
630 but = new QPushButton(style()->standardIcon(QStyle::SP_DialogResetButton),
631 _("Reset"));
632 button_box->addButton(but, QDialogButtonBox::ResetRole);
633 QObject::connect(but, &QPushButton::clicked, [this]() {
635 });
636
637 but = new QPushButton(style()->standardIcon(QStyle::SP_DialogApplyButton),
638 _("Apply"));
639 button_box->addButton(but, QDialogButtonBox::ActionRole);
640 QObject::connect(but, &QPushButton::clicked, [this]() {
642 });
643
644 but = new QPushButton(style()->standardIcon(QStyle::SP_DialogSaveButton),
645 _("Save"));
646 button_box->addButton(but, QDialogButtonBox::ActionRole);
647 QObject::connect(but, &QPushButton::clicked, [this]() {
649 });
650
651 but = new QPushButton(style()->standardIcon(QStyle::SP_DialogOkButton),
652 _("Ok"));
653 button_box->addButton(but, QDialogButtonBox::ActionRole);
654 QObject::connect(but, &QPushButton::clicked, [this]() {
656 });
657
658 main_layout->addWidget(button_box);
660 size = sizeHint();
661 size.setWidth(size.width() + 10
662 + style()->pixelMetric(QStyle::PM_ScrollBarExtent));
663 resize(size);
664 setAttribute(Qt::WA_DeleteOnClose);
665}
666
667/**********************************************************************/
671{
673 QLabel *l;
674
675 l = new QLabel(sc->str);
676 hb = new QHBoxLayout();
677
678 fc_sc_button *fb = new fc_sc_button(sc);
679 connect(fb, &QAbstractButton::clicked, this, &fc_shortcuts_dialog::edit_shortcut);
680
681 hb->addWidget(l, 1, Qt::AlignLeft);
682 hb->addStretch();
683 hb->addWidget(fb, 1, Qt::AlignRight);
684
685 scroll_layout->addLayout(hb);
686}
687
688/**********************************************************************/
698
699/**********************************************************************/
703{
706 QWidget *widget;
707
709 while ((item = layout->takeAt(0))) {
710 if (item->layout() != nullptr) {
711 // Nothing
712 } else if ((widget = item->widget()) != nullptr) {
713 widget->hide();
714 delete widget;
715 } else {
716 delete item;
717 }
718 }
719 delete main_layout;
720 init();
721}
722
723/**********************************************************************/
727{
728 switch (response) {
729 case RESPONSE_APPLY:
731 gui()->menuBar()->setVisible(true);
732 break;
733 case RESPONSE_CANCEL:
735 fc_shortcuts::hash.detach();
736 close();
737 break;
738 case RESPONSE_OK:
740 gui()->menuBar()->setVisible(true);
741 close();
742 break;
743 case RESPONSE_SAVE:
745 break;
746 case RESPONSE_RESET:
748 refresh();
749 break;
750 }
751}
752
753/**********************************************************************/
757{
759 sh->show();
760}
761
762/**********************************************************************/
766{
768 fc_shortcut *s;
769 fc_shortcut *sc;
770 int i;
773
774 for (i = 1 ; i < num_shortcuts + 1; i++) {
775 sc = new fc_shortcut();
776 id = static_cast<shortcut_id>(i);
777 s = h->value(id);
778 sc->id = id;
779 sc->key = s->key;
780 sc->mouse = s->mouse;
781 sc->mod = s->mod;
782 sc->str = s->str;
783 new_hash->insert(sc->id, sc);
784 }
785
786 return new_hash;
787}
788
789/**********************************************************************/
793{
794 fc_shortcut *sc;
796 // This can't be shared between freeciv versions as shortcut
797 // ids can change incompatible way between versions.
798 QString sname = "freeciv-qt-client-sc-"
799 + QString::number(MAJOR_NEW_OPTION_FILE_NAME) + "."
800 + QString::number(MINOR_NEW_OPTION_FILE_NAME);
801 QSettings s(QSettings::IniFormat, QSettings::UserScope,
802 sname);
803
805 // Shortcuts not even initialized yet. Happens e.g. when we quit from
806 // the main menu without ever visiting the game.
807 return;
808 }
809
810 s.beginWriteArray("Shortcuts");
811 for (int i = 0; i < num_shortcuts; ++i) {
812 s.setArrayIndex(i);
813 sc = h.value(static_cast<shortcut_id>(i + 1));
814 s.setValue("id", sc->id);
815 s.setValue("key", sc->key);
816 s.setValue("mouse", sc->mouse);
817 s.setValue("mod", QVariant(sc->mod));
818 }
819 s.endArray();
820}
821
822/**********************************************************************/
826{
827 int num, i;
828 fc_shortcut *sc;
829
831 return false;
832 }
833
834 QString sname = "freeciv-qt-client-sc-"
835 + QString::number(MAJOR_NEW_OPTION_FILE_NAME) + "."
836 + QString::number(MINOR_NEW_OPTION_FILE_NAME);
837 QSettings s(QSettings::IniFormat, QSettings::UserScope,
838 sname);
839
840 num = s.beginReadArray("Shortcuts");
841 if (num == num_shortcuts) {
842 for (i = 0; i < num_shortcuts; ++i) {
843 s.setArrayIndex(i);
844 sc = new fc_shortcut();
845 sc->id = static_cast<shortcut_id>(s.value("id").toInt());
846 sc->key = s.value("key").toInt();
847 sc->mouse = static_cast<Qt::MouseButton>(s.value("mouse").toInt());
848 sc->mod = static_cast<Qt::KeyboardModifiers>(s.value("mod").toInt());
849 sc->str = default_shortcuts[i].str;
850 fc_shortcuts::hash.insert(sc->id, sc);
851 }
852 } else {
853 s.endArray();
854
855 return false;
856 }
857 s.endArray();
858
859 return true;
860}
861
862/**********************************************************************/
866{
868}
#define str
Definition astring.c:76
fc_shortcut * sc_orig
Definition shortcuts.h:181
void show_info(QString str)
void popup_error()
fc_shortcut * sc
Definition shortcuts.h:180
QString err_message
Definition shortcuts.h:176
void closeEvent(QCloseEvent *)
fc_shortcut * sc
Definition shortcuts.h:162
void run(fc_shortcut *s)
fc_shortcut_popup(QWidget *parent)
virtual ~fc_shortcuts_dialog()
void add_option(fc_shortcut *sc)
void apply_option(int response)
fc_shortcuts_dialog(QWidget *parent=0)
QDialogButtonBox * button_box
Definition shortcuts.h:195
QVBoxLayout * scroll_layout
Definition shortcuts.h:194
QMap< shortcut_id, fc_shortcut * > * hashcopy
Definition shortcuts.h:196
QVBoxLayout * main_layout
Definition shortcuts.h:193
static fc_shortcuts * m_instance
Definition shortcuts.h:123
static QMap< shortcut_id, fc_shortcut * > hash
Definition shortcuts.h:130
static fc_shortcuts * sc()
static void init_default(bool read)
static void drop()
QString get_desc(shortcut_id id)
fc_shortcut * get_shortcut(shortcut_id id)
static bool is_instantiated()
void set_shortcut(fc_shortcut *sc)
shortcut_id get_id(fc_shortcut *sc)
void mousePressEvent(QMouseEvent *event)
fc_shortcut shc
Definition shortcuts.h:147
void keyReleaseEvent(QKeyEvent *event)
char * incite_cost
Definition comments.c:75
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
#define _(String)
Definition fcintl.h:67
static PangoLayout * layout
Definition canvas.c:325
void real_menus_init(void)
Definition menu.c:2915
@ RESPONSE_SAVE
Definition optiondlg.c:66
@ RESPONSE_APPLY
Definition optiondlg.c:63
@ RESPONSE_CANCEL
Definition optiondlg.c:61
@ RESPONSE_OK
Definition optiondlg.c:62
@ RESPONSE_RESET
Definition optiondlg.c:64
const char * title
Definition repodlgs.c:1314
static GHashTable * hash
Definition wldlg.c:322
#define show(id)
Definition widget.h:235
static mpgui * gui
Definition mpgui_qt.cpp:52
#define MAJOR_NEW_OPTION_FILE_NAME
Definition options.h:38
#define MINOR_NEW_OPTION_FILE_NAME
Definition options.h:42
static QHash< int, const char * > key_map
Definition shortcuts.cpp:40
void popup_shortcuts_dialog()
fc_shortcut default_shortcuts[]
Definition shortcuts.cpp:58
bool read_shortcuts()
void shortcutreset()
QString shortcut_to_string(fc_shortcut *sc)
@ RESPONSE_SAVE
Definition shortcuts.cpp:51
@ RESPONSE_APPLY
Definition shortcuts.cpp:49
@ RESPONSE_CANCEL
Definition shortcuts.cpp:47
@ RESPONSE_OK
Definition shortcuts.cpp:48
@ RESPONSE_RESET
Definition shortcuts.cpp:50
static QMap< shortcut_id, fc_shortcut * > * hash_copy(QMap< shortcut_id, fc_shortcut * > *h)
void real_menus_init()
Definition menu.c:2915
static bool use_default_shortcuts
Definition shortcuts.cpp:54
static QString button_name(Qt::MouseButton bt)
void write_shortcuts()
static int num_shortcuts
Definition shortcuts.cpp:56
shortcut_id
Definition shortcuts.h:33
@ SC_PARADROP
Definition shortcuts.h:95
@ SC_UPGRADE_UNIT
Definition shortcuts.h:63
@ SC_BUILDIRRIGATION
Definition shortcuts.h:67
@ SC_BUILDCITY
Definition shortcuts.h:70
@ SC_DONE_MOVING
Definition shortcuts.h:57
@ SC_BUILDROAD
Definition shortcuts.h:69
@ SC_UNSENTRY_TILE
Definition shortcuts.h:61
@ SC_CULTIVATE
Definition shortcuts.h:68
@ SC_DO
Definition shortcuts.h:62
@ SC_CENTER_VIEW
Definition shortcuts.h:36
@ SC_POPUP_COMB_INF
Definition shortcuts.h:83
@ SC_SENTRY
Definition shortcuts.h:71
@ SC_GOBUILDCITY
Definition shortcuts.h:92
@ SC_NUKE
Definition shortcuts.h:76
@ SC_HIDE_WORKERS
Definition shortcuts.h:52
@ SC_AUTOEXPLORE
Definition shortcuts.h:59
@ SC_POPUP_INFO
Definition shortcuts.h:47
@ SC_SETHOME
Definition shortcuts.h:64
@ SC_RELOAD_LUA
Definition shortcuts.h:90
@ SC_PLANT
Definition shortcuts.h:66
@ SC_BUILDMINE
Definition shortcuts.h:65
@ SC_FULLSCREEN
Definition shortcuts.h:37
@ SC_TRADE_ROUTES
Definition shortcuts.h:54
@ SC_CITY_OUTPUT
Definition shortcuts.h:39
@ SC_TRANSFORM
Definition shortcuts.h:75
@ SC_STACK_SIZE
Definition shortcuts.h:94
@ SC_SHOW_UNITS
Definition shortcuts.h:53
@ SC_PASTE_PROD
Definition shortcuts.h:50
@ SC_WAKEUP_SENTRIES
Definition shortcuts.h:48
@ SC_MAKE_LINK
Definition shortcuts.h:49
@ SC_FORTIFY
Definition shortcuts.h:72
@ SC_APPEND_FOCUS
Definition shortcuts.h:46
@ SC_ZOOM_IN
Definition shortcuts.h:87
@ SC_GOJOINCITY
Definition shortcuts.h:93
@ SC_MAP_GRID
Definition shortcuts.h:40
@ SC_MINIMAP
Definition shortcuts.h:38
@ SC_QUICK_BUY
Definition shortcuts.h:42
@ SC_CITY_PROD
Definition shortcuts.h:55
@ SC_RELOAD_THEME
Definition shortcuts.h:84
@ SC_PATROL
Definition shortcuts.h:60
@ SC_GOTO
Definition shortcuts.h:73
@ SC_RELOAD_TILESET
Definition shortcuts.h:85
@ SC_BUY_MAP
Definition shortcuts.h:79
@ SC_SCROLL_MAP
Definition shortcuts.h:35
@ SC_GOTOAIRLIFT
Definition shortcuts.h:58
@ SC_WAIT
Definition shortcuts.h:74
@ SC_QUICK_SELECT
Definition shortcuts.h:43
@ SC_IFACE_LOCK
Definition shortcuts.h:80
@ SC_DEBOARD
Definition shortcuts.h:78
@ SC_ZOOM_RESET
Definition shortcuts.h:91
@ SC_ZOOM_OUT
Definition shortcuts.h:88
@ SC_ADJUST_WORKERS
Definition shortcuts.h:45
@ SC_SELECT_BUTTON
Definition shortcuts.h:44
@ SC_AUTOMATE
Definition shortcuts.h:81
@ SC_CITY_NAMES
Definition shortcuts.h:56
@ SC_COPY_PROD
Definition shortcuts.h:51
@ SC_LOAD_LUA
Definition shortcuts.h:89
@ SC_BOARD
Definition shortcuts.h:77
@ SC_CLEAN
Definition shortcuts.h:82
@ SC_NAT_BORDERS
Definition shortcuts.h:41
@ SC_SHOW_FULLBAR
Definition shortcuts.h:86
bool read_shortcuts()
QString shortcut_to_string(fc_shortcut *sc)
#define SC_NUM_SHORTCUTS
Definition shortcuts.h:98
void write_shortcuts()
size_t size
Definition specvec.h:72
QString str
Definition shortcuts.h:110
Qt::KeyboardModifiers mod
Definition shortcuts.h:109
Qt::MouseButton mouse
Definition shortcuts.h:108
shortcut_id id
Definition shortcuts.h:106
Definition climisc.h:82