Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-qt/shortcuts.h Source File

Freeciv-3.2

Loading...
Searching...
No Matches
shortcuts.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2003 - The Freeciv Project
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#ifndef FC__SHORTCUTSDLG_H
15#define FC__SHORTCUTSDLG_H
16
17// Qt
18#include <QDialog>
19#include <QLineEdit>
20#include <QPushButton>
21
22class QDialogButtonBox;
23class QVBoxLayout;
24struct fc_shortcut;
25
26void popup_shortcuts_dialog();
27 QString shortcut_to_string(fc_shortcut *sc);
28void write_shortcuts();
29bool read_shortcuts();
30void shortcutreset();
31
32// Assign numbers for casting
33 enum shortcut_id {
34 SC_NONE = 0,
35 SC_SCROLL_MAP = 1,
36 SC_CENTER_VIEW = 2,
37 SC_FULLSCREEN = 3,
38 SC_MINIMAP = 4,
39 SC_CITY_OUTPUT = 5,
40 SC_MAP_GRID = 6,
41 SC_NAT_BORDERS = 7,
42 SC_QUICK_BUY = 8,
43 SC_QUICK_SELECT = 9,
44 SC_SELECT_BUTTON = 10,
45 SC_ADJUST_WORKERS = 11,
46 SC_APPEND_FOCUS = 12,
47 SC_POPUP_INFO = 13,
48 SC_WAKEUP_SENTRIES = 14,
49 SC_MAKE_LINK = 15,
50 SC_PASTE_PROD = 16,
51 SC_COPY_PROD = 17,
52 SC_HIDE_WORKERS = 18,
53 SC_SHOW_UNITS = 19,
54 SC_TRADE_ROUTES = 20,
55 SC_CITY_PROD = 21,
56 SC_CITY_NAMES = 22,
57 SC_DONE_MOVING = 23,
58 SC_GOTOAIRLIFT = 24,
59 SC_AUTOEXPLORE = 25,
60 SC_PATROL = 26,
61 SC_UNSENTRY_TILE = 27,
62 SC_DO = 28,
63 SC_UPGRADE_UNIT = 29,
64 SC_SETHOME = 30,
65 SC_BUILDMINE = 31,
66 SC_PLANT = 32,
67 SC_BUILDIRRIGATION = 33,
68 SC_CULTIVATE = 34,
69 SC_BUILDROAD = 35,
70 SC_BUILDCITY = 36,
71 SC_SENTRY = 37,
72 SC_FORTIFY = 38,
73 SC_GOTO = 39,
74 SC_WAIT = 40,
75 SC_TRANSFORM = 41,
76 SC_NUKE = 42,
77 SC_BOARD = 43,
78 SC_DEBOARD = 44,
79 SC_BUY_MAP = 45,
80 SC_IFACE_LOCK = 46,
81 SC_AUTOMATE = 47,
82 SC_CLEAN = 48,
83 SC_POPUP_COMB_INF = 49,
84 SC_RELOAD_THEME = 50,
85 SC_RELOAD_TILESET = 51,
86 SC_SHOW_FULLBAR = 52,
87 SC_ZOOM_IN = 53,
88 SC_ZOOM_OUT = 54,
89 SC_LOAD_LUA = 55,
90 SC_RELOAD_LUA = 56,
91 SC_ZOOM_RESET = 57,
92 SC_GOBUILDCITY = 58,
93 SC_GOJOINCITY = 59,
94 SC_STACK_SIZE = 60,
95 SC_PARADROP = 61
96};
97
98#define SC_NUM_SHORTCUTS 61
99
100
101/**************************************************************************
102 Base shortcut struct
103**************************************************************************/
104 struct fc_shortcut
105{
106 shortcut_id id;
107 int key;
108 Qt::MouseButton mouse;
109 Qt::KeyboardModifiers mod;
110 QString str;
111 bool operator==(const fc_shortcut& a) const {
112 return ((key == a.key) && (mouse == a.mouse) && (mod == a.mod));
113 }
114};
115
116/**************************************************************************
117 Class with static members holding all shortcuts
118**************************************************************************/
119 class fc_shortcuts
120{
121 Q_DISABLE_COPY(fc_shortcuts);
122 fc_shortcuts();
123 static fc_shortcuts *m_instance;
124
125public:
126 ~fc_shortcuts();
127 static fc_shortcuts *sc();
128 static bool is_instantiated();
129 static void drop();
130 static QMap<shortcut_id, fc_shortcut*> hash;
131public:
132 static void init_default(bool read);
133 fc_shortcut *get_shortcut(shortcut_id id);
134 shortcut_id get_id(fc_shortcut *sc);
135 void set_shortcut(fc_shortcut *sc);
136 QString get_desc(shortcut_id id);
137};
138
139/**************************************************************************
140 Widget for picking shortcuts
141**************************************************************************/
142 class line_edit : public QLineEdit
143{
144 Q_OBJECT
145public:
146 line_edit();
147 fc_shortcut shc;
148 protected:
149 void mousePressEvent(QMouseEvent *event);
150 void keyReleaseEvent(QKeyEvent *event);
151};
152
153/**************************************************************************
154 Popup for picking shortcuts
155**************************************************************************/
156 class fc_shortcut_popup : public QDialog
157{
158public:
159 fc_shortcut_popup(QWidget *parent);
160 void run(fc_shortcut *s);
161 fc_shortcut *sc;
162protected:
163 void closeEvent(QCloseEvent*);
164private:
165 bool check_if_exist();
166 line_edit edit;
167};
168
169/**************************************************************************
170 QPushButton holding shortcut
171**************************************************************************/
172 class fc_sc_button : public QPushButton
173{
174 Q_OBJECT
175 QString err_message;
176public:
177 fc_sc_button();
178 fc_sc_button(fc_shortcut *s);
179 fc_shortcut *sc;
180 fc_shortcut *sc_orig;
181 void show_info(QString str);
182private slots:
183 void popup_error();
184};
185
186/**************************************************************************
187 Shortcut dialog
188**************************************************************************/
189 class fc_shortcuts_dialog : public QDialog
190{
191 Q_OBJECT
192 QVBoxLayout *main_layout;
193 QVBoxLayout *scroll_layout;
194 QDialogButtonBox *button_box;
195 QMap<shortcut_id, fc_shortcut*> *hashcopy;
196 void add_option(fc_shortcut *sc);
197 void init();
198 void refresh();
199public:
200 fc_shortcuts_dialog(QWidget *parent = 0);
201virtual ~fc_shortcuts_dialog();
202private slots:
203 void apply_option(int response);
204 void edit_shortcut();
205};
206
207#endif // FC__SHORTCUSDLG_H
str
#define str
Definition astring.c:76
fc_sc_button
Definition shortcuts.h:173
fc_sc_button::fc_sc_button
fc_sc_button()
Definition shortcuts.cpp:520
fc_sc_button::sc_orig
fc_shortcut * sc_orig
Definition shortcuts.h:180
fc_sc_button::show_info
void show_info(QString str)
Definition shortcuts.cpp:543
fc_sc_button::popup_error
void popup_error()
Definition shortcuts.cpp:552
fc_sc_button::sc
fc_shortcut * sc
Definition shortcuts.h:179
fc_sc_button::err_message
QString err_message
Definition shortcuts.h:175
fc_shortcut_popup
Definition shortcuts.h:157
fc_shortcut_popup::closeEvent
void closeEvent(QCloseEvent *)
Definition shortcuts.cpp:399
fc_shortcut_popup::check_if_exist
bool check_if_exist()
Definition shortcuts.cpp:418
fc_shortcut_popup::sc
fc_shortcut * sc
Definition shortcuts.h:161
fc_shortcut_popup::edit
line_edit edit
Definition shortcuts.h:166
fc_shortcut_popup::run
void run(fc_shortcut *s)
Definition shortcuts.cpp:385
fc_shortcuts_dialog
Definition shortcuts.h:190
fc_shortcuts_dialog::init
void init()
Definition shortcuts.cpp:597
fc_shortcuts_dialog::~fc_shortcuts_dialog
virtual ~fc_shortcuts_dialog()
Definition shortcuts.cpp:590
fc_shortcuts_dialog::add_option
void add_option(fc_shortcut *sc)
Definition shortcuts.cpp:670
fc_shortcuts_dialog::apply_option
void apply_option(int response)
Definition shortcuts.cpp:726
fc_shortcuts_dialog::edit_shortcut
void edit_shortcut()
Definition shortcuts.cpp:691
fc_shortcuts_dialog::button_box
QDialogButtonBox * button_box
Definition shortcuts.h:194
fc_shortcuts_dialog::scroll_layout
QVBoxLayout * scroll_layout
Definition shortcuts.h:193
fc_shortcuts_dialog::hashcopy
QMap< shortcut_id, fc_shortcut * > * hashcopy
Definition shortcuts.h:195
fc_shortcuts_dialog::main_layout
QVBoxLayout * main_layout
Definition shortcuts.h:192
fc_shortcuts_dialog::refresh
void refresh()
Definition shortcuts.cpp:702
fc_shortcuts
Definition shortcuts.h:120
fc_shortcuts::m_instance
static fc_shortcuts * m_instance
Definition shortcuts.h:123
fc_shortcuts::hash
static QMap< shortcut_id, fc_shortcut * > hash
Definition shortcuts.h:130
fc_shortcuts::sc
static fc_shortcuts * sc()
Definition shortcuts.cpp:278
fc_shortcuts::init_default
static void init_default(bool read)
Definition shortcuts.cpp:299
fc_shortcuts::drop
static void drop()
Definition shortcuts.cpp:267
fc_shortcuts::get_desc
QString get_desc(shortcut_id id)
Definition shortcuts.cpp:226
fc_shortcuts::get_shortcut
fc_shortcut * get_shortcut(shortcut_id id)
Definition shortcuts.cpp:236
fc_shortcuts::is_instantiated
static bool is_instantiated()
Definition shortcuts.cpp:291
fc_shortcuts::Q_DISABLE_COPY
Q_DISABLE_COPY(fc_shortcuts)
fc_shortcuts::set_shortcut
void set_shortcut(fc_shortcut *sc)
Definition shortcuts.cpp:254
fc_shortcuts::get_id
shortcut_id get_id(fc_shortcut *sc)
Definition shortcuts.cpp:246
fc_shortcuts::~fc_shortcuts
~fc_shortcuts()
Definition shortcuts.cpp:216
fc_shortcuts::fc_shortcuts
fc_shortcuts()
Definition shortcuts.cpp:208
line_edit
Definition shortcuts.h:143
line_edit::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition shortcuts.cpp:354
line_edit::shc
fc_shortcut shc
Definition shortcuts.h:147
line_edit::keyReleaseEvent
void keyReleaseEvent(QKeyEvent *event)
Definition shortcuts.cpp:369
line_edit::line_edit
line_edit()
Definition shortcuts.cpp:345
incite_cost
char * incite_cost
Definition comments.c:74
event
enum event_type event
Definition events.c:81
slots
struct player_slot * slots
Definition player.c:51
shortcut_id
shortcut_id
Definition shortcuts.h:33
SC_PARADROP
@ SC_PARADROP
Definition shortcuts.h:95
SC_UPGRADE_UNIT
@ SC_UPGRADE_UNIT
Definition shortcuts.h:63
SC_BUILDIRRIGATION
@ SC_BUILDIRRIGATION
Definition shortcuts.h:67
SC_BUILDCITY
@ SC_BUILDCITY
Definition shortcuts.h:70
SC_DONE_MOVING
@ SC_DONE_MOVING
Definition shortcuts.h:57
SC_BUILDROAD
@ SC_BUILDROAD
Definition shortcuts.h:69
SC_UNSENTRY_TILE
@ SC_UNSENTRY_TILE
Definition shortcuts.h:61
SC_NONE
@ SC_NONE
Definition shortcuts.h:34
SC_CULTIVATE
@ SC_CULTIVATE
Definition shortcuts.h:68
SC_DO
@ SC_DO
Definition shortcuts.h:62
SC_CENTER_VIEW
@ SC_CENTER_VIEW
Definition shortcuts.h:36
SC_POPUP_COMB_INF
@ SC_POPUP_COMB_INF
Definition shortcuts.h:83
SC_SENTRY
@ SC_SENTRY
Definition shortcuts.h:71
SC_GOBUILDCITY
@ SC_GOBUILDCITY
Definition shortcuts.h:92
SC_NUKE
@ SC_NUKE
Definition shortcuts.h:76
SC_HIDE_WORKERS
@ SC_HIDE_WORKERS
Definition shortcuts.h:52
SC_AUTOEXPLORE
@ SC_AUTOEXPLORE
Definition shortcuts.h:59
SC_POPUP_INFO
@ SC_POPUP_INFO
Definition shortcuts.h:47
SC_SETHOME
@ SC_SETHOME
Definition shortcuts.h:64
SC_RELOAD_LUA
@ SC_RELOAD_LUA
Definition shortcuts.h:90
SC_PLANT
@ SC_PLANT
Definition shortcuts.h:66
SC_BUILDMINE
@ SC_BUILDMINE
Definition shortcuts.h:65
SC_FULLSCREEN
@ SC_FULLSCREEN
Definition shortcuts.h:37
SC_TRADE_ROUTES
@ SC_TRADE_ROUTES
Definition shortcuts.h:54
SC_CITY_OUTPUT
@ SC_CITY_OUTPUT
Definition shortcuts.h:39
SC_TRANSFORM
@ SC_TRANSFORM
Definition shortcuts.h:75
SC_STACK_SIZE
@ SC_STACK_SIZE
Definition shortcuts.h:94
SC_SHOW_UNITS
@ SC_SHOW_UNITS
Definition shortcuts.h:53
SC_PASTE_PROD
@ SC_PASTE_PROD
Definition shortcuts.h:50
SC_WAKEUP_SENTRIES
@ SC_WAKEUP_SENTRIES
Definition shortcuts.h:48
SC_MAKE_LINK
@ SC_MAKE_LINK
Definition shortcuts.h:49
SC_FORTIFY
@ SC_FORTIFY
Definition shortcuts.h:72
SC_APPEND_FOCUS
@ SC_APPEND_FOCUS
Definition shortcuts.h:46
SC_ZOOM_IN
@ SC_ZOOM_IN
Definition shortcuts.h:87
SC_GOJOINCITY
@ SC_GOJOINCITY
Definition shortcuts.h:93
SC_MAP_GRID
@ SC_MAP_GRID
Definition shortcuts.h:40
SC_MINIMAP
@ SC_MINIMAP
Definition shortcuts.h:38
SC_QUICK_BUY
@ SC_QUICK_BUY
Definition shortcuts.h:42
SC_CITY_PROD
@ SC_CITY_PROD
Definition shortcuts.h:55
SC_RELOAD_THEME
@ SC_RELOAD_THEME
Definition shortcuts.h:84
SC_PATROL
@ SC_PATROL
Definition shortcuts.h:60
SC_GOTO
@ SC_GOTO
Definition shortcuts.h:73
SC_RELOAD_TILESET
@ SC_RELOAD_TILESET
Definition shortcuts.h:85
SC_BUY_MAP
@ SC_BUY_MAP
Definition shortcuts.h:79
SC_SCROLL_MAP
@ SC_SCROLL_MAP
Definition shortcuts.h:35
SC_GOTOAIRLIFT
@ SC_GOTOAIRLIFT
Definition shortcuts.h:58
SC_WAIT
@ SC_WAIT
Definition shortcuts.h:74
SC_QUICK_SELECT
@ SC_QUICK_SELECT
Definition shortcuts.h:43
SC_IFACE_LOCK
@ SC_IFACE_LOCK
Definition shortcuts.h:80
SC_DEBOARD
@ SC_DEBOARD
Definition shortcuts.h:78
SC_ZOOM_RESET
@ SC_ZOOM_RESET
Definition shortcuts.h:91
SC_ZOOM_OUT
@ SC_ZOOM_OUT
Definition shortcuts.h:88
SC_ADJUST_WORKERS
@ SC_ADJUST_WORKERS
Definition shortcuts.h:45
SC_SELECT_BUTTON
@ SC_SELECT_BUTTON
Definition shortcuts.h:44
SC_AUTOMATE
@ SC_AUTOMATE
Definition shortcuts.h:81
SC_CITY_NAMES
@ SC_CITY_NAMES
Definition shortcuts.h:56
SC_COPY_PROD
@ SC_COPY_PROD
Definition shortcuts.h:51
SC_LOAD_LUA
@ SC_LOAD_LUA
Definition shortcuts.h:89
SC_BOARD
@ SC_BOARD
Definition shortcuts.h:77
SC_CLEAN
@ SC_CLEAN
Definition shortcuts.h:82
SC_NAT_BORDERS
@ SC_NAT_BORDERS
Definition shortcuts.h:41
SC_SHOW_FULLBAR
@ SC_SHOW_FULLBAR
Definition shortcuts.h:86
popup_shortcuts_dialog
void popup_shortcuts_dialog()
Definition shortcuts.cpp:756
read_shortcuts
bool read_shortcuts()
Definition shortcuts.cpp:825
shortcutreset
void shortcutreset()
Definition shortcuts.cpp:865
shortcut_to_string
QString shortcut_to_string(fc_shortcut *sc)
Definition shortcuts.cpp:184
write_shortcuts
void write_shortcuts()
Definition shortcuts.cpp:792
fc_shortcut
Definition shortcuts.h:105
fc_shortcut::key
int key
Definition shortcuts.h:107
fc_shortcut::str
QString str
Definition shortcuts.h:110
fc_shortcut::mod
Qt::KeyboardModifiers mod
Definition shortcuts.h:109
fc_shortcut::mouse
Qt::MouseButton mouse
Definition shortcuts.h:108
fc_shortcut::operator==
bool operator==(const fc_shortcut &a) const
Definition shortcuts.h:111
fc_shortcut::id
shortcut_id id
Definition shortcuts.h:106