Freeciv-3.1
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
28void write_shortcuts();
29bool read_shortcuts();
30void shortcutreset();
31
32// Assign numbers for casting
96
97#define SC_NUM_SHORTCUTS 60
98
99
100/**************************************************************************
101 Base shortcut struct
102**************************************************************************/
104{
106 int key;
107 Qt::MouseButton mouse;
108 Qt::KeyboardModifiers mod;
109 QString str;
110 bool operator==(const fc_shortcut& a) const {
111 return ((key == a.key) && (mouse == a.mouse) && (mod == a.mod));
112 }
113};
114
115/**************************************************************************
116 Class with static members holding all shortcuts
117**************************************************************************/
119{
121 fc_shortcuts();
123
124public:
126 static fc_shortcuts *sc();
127 static bool is_instantiated();
128 static void drop();
129 static QMap<shortcut_id, fc_shortcut*> hash;
130public:
131 static void init_default(bool read);
135 QString get_desc(shortcut_id id);
136};
137
138/**************************************************************************
139 Widget for picking shortcuts
140**************************************************************************/
141class line_edit : public QLineEdit
142{
143 Q_OBJECT
144public:
145 line_edit();
147 protected:
148 void mousePressEvent(QMouseEvent *event);
149 void keyReleaseEvent(QKeyEvent *event);
150};
151
152/**************************************************************************
153 Popup for picking shortcuts
154**************************************************************************/
155class fc_shortcut_popup : public QDialog
156{
157 Q_OBJECT
158public:
159 fc_shortcut_popup(QWidget *parent);
160 void run(fc_shortcut *s);
162protected:
163 void closeEvent(QCloseEvent*);
164private:
165 bool check_if_exist();
167};
168
169/**************************************************************************
170 QPushButton holding shortcut
171**************************************************************************/
172class fc_sc_button : public QPushButton
173{
174 Q_OBJECT
175 QString err_message;
176public:
177 fc_sc_button();
181 void show_info(QString str);
182private slots:
183 void popup_error();
184};
185
186/**************************************************************************
187 Shortcut dialog
188**************************************************************************/
189class 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 */
#define str
Definition astring.c:76
fc_shortcut * sc_orig
Definition shortcuts.h:180
void show_info(QString str)
void popup_error()
fc_shortcut * sc
Definition shortcuts.h:179
QString err_message
Definition shortcuts.h:175
void closeEvent(QCloseEvent *)
fc_shortcut * sc
Definition shortcuts.h:161
void run(fc_shortcut *s)
virtual ~fc_shortcuts_dialog()
void add_option(fc_shortcut *sc)
void apply_option(int response)
QDialogButtonBox * button_box
Definition shortcuts.h:194
QVBoxLayout * scroll_layout
Definition shortcuts.h:193
QMap< shortcut_id, fc_shortcut * > * hashcopy
Definition shortcuts.h:195
QVBoxLayout * main_layout
Definition shortcuts.h:192
static fc_shortcuts * m_instance
Definition shortcuts.h:122
static QMap< shortcut_id, fc_shortcut * > hash
Definition shortcuts.h:129
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()
Q_DISABLE_COPY(fc_shortcuts)
void set_shortcut(fc_shortcut *sc)
shortcut_id get_id(fc_shortcut *sc)
void mousePressEvent(QMouseEvent *event)
fc_shortcut shc
Definition shortcuts.h:146
void keyReleaseEvent(QKeyEvent *event)
enum event_type event
Definition events.c:81
struct player_slot * slots
Definition player.c:50
shortcut_id
Definition shortcuts.h:33
@ SC_PARADROP
Definition shortcuts.h:82
@ 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_NONE
Definition shortcuts.h:34
@ 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_NAT_BORDERS
Definition shortcuts.h:41
@ SC_SHOW_FULLBAR
Definition shortcuts.h:86
void popup_shortcuts_dialog()
bool read_shortcuts()
void shortcutreset()
QString shortcut_to_string(fc_shortcut *sc)
void write_shortcuts()
QString str
Definition shortcuts.h:109
Qt::KeyboardModifiers mod
Definition shortcuts.h:108
Qt::MouseButton mouse
Definition shortcuts.h:107
bool operator==(const fc_shortcut &a) const
Definition shortcuts.h:110
shortcut_id id
Definition shortcuts.h:105