Freeciv-3.1
Loading...
Searching...
No Matches
edit_gov.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// Qt
19#include <QGridLayout>
20#include <QLineEdit>
21#include <QPushButton>
22
23// common
24#include "government.h"
25
26// ruledit
27#include "helpeditor.h"
28#include "ruledit.h"
29#include "ruledit_qt.h"
30
31#include "edit_gov.h"
32
33
34/**********************************************************************/
38{
39 QHBoxLayout *main_layout = new QHBoxLayout(this);
40 QGridLayout *gov_layout = new QGridLayout();
41 QLabel *label;
42 QPushButton *button;
43 int row;
44
45 ui = ui_in;
46 gov = gov_in;
47
48 setWindowTitle(QString::fromUtf8(government_rule_name(gov)));
49
50 row = 0;
51
52 label = new QLabel(QString::fromUtf8(R__("Graphics tag")));
53 label->setParent(this);
54
55 gfx_tag = new QLineEdit(this);
56 connect(gfx_tag, SIGNAL(returnPressed()), this, SLOT(gfx_tag_given()));
57
58 gov_layout->addWidget(label, row, 0);
59 gov_layout->addWidget(gfx_tag, row++, 1);
60
61 label = new QLabel(QString::fromUtf8(R__("Alt graphics tag")));
62 label->setParent(this);
63
64 gfx_tag_alt = new QLineEdit(this);
65 connect(gfx_tag_alt, SIGNAL(returnPressed()), this, SLOT(gfx_tag_alt_given()));
66
67 gov_layout->addWidget(label, row, 0);
68 gov_layout->addWidget(gfx_tag_alt, row++, 1);
69
70 button = new QPushButton(QString::fromUtf8(R__("Helptext")), this);
71 connect(button, SIGNAL(pressed()), this, SLOT(helptext()));
72 gov_layout->addWidget(button, row++, 1);
73
74 refresh();
75
76 main_layout->addLayout(gov_layout);
77
78 setLayout(main_layout);
79}
80
81/**********************************************************************/
84void edit_gov::closeEvent(QCloseEvent *cevent)
85{
86 close_help();
87
88 // Save values from text fields.
91
92 gov->ruledit_dlg = nullptr;
93}
94
95/**********************************************************************/
99{
100 gfx_tag->setText(gov->graphic_str);
101 gfx_tag_alt->setText(gov->graphic_alt);
102}
103
104/**********************************************************************/
108{
109 QByteArray tag_bytes = gfx_tag->text().toUtf8();
110
111 sz_strlcpy(gov->graphic_str, tag_bytes);
112}
113
114/**********************************************************************/
118{
119 QByteArray tag_bytes = gfx_tag_alt->text().toUtf8();
120
121 sz_strlcpy(gov->graphic_alt, tag_bytes);
122}
123
124/**********************************************************************/
128{
130}
struct government * gov
Definition edit_gov.h:42
ruledit_gui * ui
Definition edit_gov.h:41
void gfx_tag_alt_given()
Definition edit_gov.cpp:117
void refresh()
Definition edit_gov.cpp:98
void closeEvent(QCloseEvent *cevent)
Definition edit_gov.cpp:84
void gfx_tag_given()
Definition edit_gov.cpp:107
void helptext()
Definition edit_gov.cpp:127
QLineEdit * gfx_tag_alt
Definition edit_gov.h:44
edit_gov(ruledit_gui *ui_in, struct government *gov_in)
Definition edit_gov.cpp:37
QLineEdit * gfx_tag
Definition edit_gov.h:43
void close_help()
void open_help(struct strvec **help)
#define R__(String)
Definition fcintl.h:75
const char * government_rule_name(const struct government *pgovern)
Definition government.c:132
struct strvec * helptext
Definition government.h:62
void * ruledit_dlg
Definition government.h:56
char graphic_alt[MAX_LEN_NAME]
Definition government.h:58
char graphic_str[MAX_LEN_NAME]
Definition government.h:57
#define sz_strlcpy(dest, src)
Definition support.h:167