Freeciv21
Develop your civilization from humble roots to a global empire
requirers_dlg.cpp
Go to the documentation of this file.
1 /*__ ___ ***************************************
2 / \ / \ Copyright (c) 1996-2020 Freeciv21 and Freeciv
3 \_ \ / __/ contributors. This file is part of Freeciv21.
4  _\ \ / /__ Freeciv21 is free software: you can redistribute it
5  \___ \____/ __/ and/or modify it under the terms of the GNU General
6  \_ _/ Public License as published by the Free Software
7  | @ @ \_ Foundation, either version 3 of the License,
8  | or (at your option) any later version.
9  _/ /\ You should have received a copy of the GNU
10  /o) (o/\ \_ General Public License along with Freeciv21.
11  \_____/ / If not, see https://www.gnu.org/licenses/.
12  \____/ ********************************************************/
13 
14 // Qt
15 #include <QGridLayout>
16 #include <QPushButton>
17 
18 // utility
19 #include "fcintl.h"
20 
21 #include "requirers_dlg.h"
22 
27 {
28  QGridLayout *main_layout = new QGridLayout(this);
29  QPushButton *close_button;
30  int row = 0;
31 
32  ui = ui_in;
33 
34  area = new QTextEdit();
35  area->setParent(this);
36  area->setReadOnly(true);
37  main_layout->addWidget(area, row++, 0);
38 
39  close_button = new QPushButton(QString::fromUtf8(R__("Close")), this);
40  connect(close_button, &QAbstractButton::pressed, this,
42  main_layout->addWidget(close_button, row++, 0);
43 
44  setLayout(main_layout);
45 }
46 
50 void requirers_dlg::clear(const char *title)
51 {
52  char buffer[256];
53 
54  fc_snprintf(buffer, sizeof(buffer), R__("Removing %s"), title);
55 
56  setWindowTitle(QString::fromUtf8(buffer));
57  area->clear();
58 }
59 
63 void requirers_dlg::add(const char *msg)
64 {
65  char buffer[2048];
66 
67  /* TRANS: %s could be any of a number of ruleset items (e.g., tech,
68  * unit type, ... */
69  fc_snprintf(buffer, sizeof(buffer), R__("Needed by %s"), msg);
70 
71  area->append(QString::fromUtf8(buffer));
72 }
73 
77 void requirers_dlg::close_now() { done(0); }
void close_now()
User pushed close button.
QTextEdit * area
Definition: requirers_dlg.h:34
void clear(const char *title)
Clear text area.
requirers_dlg(ruledit_gui *ui_in)
Setup requirers_dlg object.
ruledit_gui * ui
Definition: requirers_dlg.h:32
void add(const char *msg)
Add requirer entry.
#define R__(String)
Definition: fcintl.h:58
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
Definition: support.cpp:537