Freeciv21
Develop your civilization from humble roots to a global empire
optiondlg.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  part of Freeciv21. Freeciv21 is free software: you can redistribute it
4  and/or modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation, either version 3 of the
6  License, or (at your option) any later version. You should have received
7  a copy of the GNU General Public License along with Freeciv21. If not,
8  see https://www.gnu.org/licenses/.
9 **************************************************************************/
10 #pragma once
11 
12 // Qt
13 #include <QDialog>
14 #include <QMap>
15 // client
16 #include "optiondlg_g.h"
17 // qt-client
18 #include "dialogs.h"
19 
20 struct option_set;
21 
22 QString split_text(const QString &text, bool cut);
23 QString cut_helptext(const QString &text);
24 /****************************************************************************
25  Dialog for client/server options
26 ****************************************************************************/
27 class option_dialog : public qfc_dialog {
28  Q_OBJECT
29  QVBoxLayout *main_layout;
30  QTabWidget *tab_widget;
31  QDialogButtonBox *button_box;
32  QList<QString> categories;
34 
35 public:
36  option_dialog(const QString &name, const option_set *options,
37  QWidget *parent = 0);
38  ~option_dialog() override;
39  void fill(const struct option_set *poptset);
40  void add_option(struct option *poption);
41  void option_dialog_refresh(struct option *poption);
42  void option_dialog_reset(struct option *poption);
43  void full_refresh();
44  void apply_options();
45 
46 private:
48  void set_bool(struct option *poption, bool value);
49  void set_int(struct option *poption, int value);
50  void set_string(struct option *poption, const char *string);
51  void set_enum(struct option *poption, int index);
52  void set_bitwise(struct option *poption, unsigned value);
53  void set_color(struct option *poption, struct ft_color color);
54  void set_font(struct option *poption, const QFont &font);
55  void get_color(struct option *poption, QByteArray &a1, QByteArray &a2);
56  bool get_bool(struct option *poption);
57  int get_int(struct option *poption);
58  QFont get_font(struct option *poption);
59  QFont get_button_font(struct option *poption);
60  QByteArray get_string(struct option *poption);
61  int get_enum(struct option *poption);
62  struct option *get_color_option();
63  unsigned get_bitwise(struct option *poption);
64  void full_reset();
65 private slots:
66  void apply_option(int response);
67  void set_color();
68  void set_font();
69 };
unsigned get_bitwise(struct option *poption)
Return the enum value from groupbox.
Definition: optiondlg.cpp:417
const option_set * curr_options
Definition: optiondlg.h:47
struct option * get_color_option()
Find option indicating colors.
Definition: optiondlg.cpp:438
QTabWidget * tab_widget
Definition: optiondlg.h:30
QMap< QString, QWidget * > widget_map
Definition: optiondlg.h:33
void set_font()
Sets font and text in pushbutton (user just chosen font)
Definition: optiondlg.cpp:739
void get_color(struct option *poption, QByteArray &a1, QByteArray &a2)
Return selected colors (for highlighting chat).
Definition: optiondlg.cpp:215
bool get_bool(struct option *poption)
Get the boolean value from checkbox.
Definition: optiondlg.cpp:289
QDialogButtonBox * button_box
Definition: optiondlg.h:31
void set_string(struct option *poption, const char *string)
Set the string value of the option.
Definition: optiondlg.cpp:336
void set_int(struct option *poption, int value)
Set the integer value of the option.
Definition: optiondlg.cpp:300
void full_reset()
Reset all options.
Definition: optiondlg.cpp:518
~option_dialog() override
Destructor for options dialog.
Definition: optiondlg.cpp:173
QList< QString > categories
Definition: optiondlg.h:32
QByteArray get_string(struct option *poption)
Get string for desired option from combobox or lineedit.
Definition: optiondlg.cpp:357
int get_enum(struct option *poption)
Get indexed value from combobox.
Definition: optiondlg.cpp:385
void add_option(struct option *poption)
Create widget for option.
Definition: optiondlg.cpp:566
void set_bool(struct option *poption, bool value)
Set the boolean value of the option.
Definition: optiondlg.cpp:274
void set_enum(struct option *poption, int index)
Set desired index(text) in combobox.
Definition: optiondlg.cpp:374
void apply_option(int response)
Apply desired action depending on user's request (clicked button).
Definition: optiondlg.cpp:184
QVBoxLayout * main_layout
Definition: optiondlg.h:29
void apply_options()
Apply all options.
Definition: optiondlg.cpp:237
option_dialog(const QString &name, const option_set *options, QWidget *parent=0)
Constructor for options dialog.
Definition: optiondlg.cpp:109
void full_refresh()
Refresh all options.
Definition: optiondlg.cpp:509
QFont get_font(struct option *poption)
QFont get_button_font(struct option *poption)
Get font from pushbutton.
Definition: optiondlg.cpp:757
void option_dialog_reset(struct option *poption)
Reset one option.
Definition: optiondlg.cpp:527
void fill(const struct option_set *poptset)
Create all widgets.
Definition: optiondlg.cpp:557
void option_dialog_refresh(struct option *poption)
Refresh one given option for option dialog.
Definition: optiondlg.cpp:479
int get_int(struct option *poption)
Get int value from spinbox.
Definition: optiondlg.cpp:325
void set_bitwise(struct option *poption, unsigned value)
Set the enum value of the option.
Definition: optiondlg.cpp:396
void set_color()
Set color of buttons (user just changed colors).
Definition: optiondlg.cpp:766
const char * name
Definition: inputfile.cpp:118
QString cut_helptext(const QString &text)
Remove some text from given text(help text) to show as tooltip.
Definition: optiondlg.cpp:87
QString split_text(const QString &text, bool cut)
Splits long text to 80 characters.
Definition: optiondlg.cpp:45
Option set structure.
Definition: options.cpp:88
The base class for options.
Definition: options.cpp:209