19#include <QApplication>
21#include <QColorDialog>
23#include <QDialogButtonBox>
69 sl = text.split(
"\n");
72 while (
st.length() >= 80) {
74 i =
str.lastIndexOf(
' ');
78 result = result +
str.left(
i) +
'\n';
88 if (
str.left(
str.length()) !=
"") {
89 result = result +
str.left(
str.length()) +
'\n';
93 result = result +
_(
"... read more in help") +
"\n";
97 result.remove(result.lastIndexOf(
'\n'), 1);
111 sl = text.split(
'\n');
113 if (s.length() > 2) {
114 if (s.at(0) !=
'*' && s.at(1) !=
'*' && s.at(2) !=
'*') {
139 but =
new QPushButton(style()->
standardIcon(QStyle::SP_DialogCancelButton),
142 QObject::connect(
but, &QPushButton::clicked, [
this]() {
146 but =
new QPushButton(style()->
standardIcon(QStyle::SP_DialogResetButton),
149 QObject::connect(
but, &QPushButton::clicked, [
this]() {
153 but =
new QPushButton(QIcon::fromTheme(
"view-refresh"),
_(
"Refresh"));
155 QObject::connect(
but, &QPushButton::clicked, [
this]() {
159 but =
new QPushButton(style()->
standardIcon(QStyle::SP_DialogApplyButton),
162 QObject::connect(
but, &QPushButton::clicked, [
this]() {
166 but =
new QPushButton(style()->
standardIcon(QStyle::SP_DialogSaveButton),
169 QObject::connect(
but, &QPushButton::clicked, [
this]() {
173 but =
new QPushButton(style()->
standardIcon(QStyle::SP_DialogOkButton),
176 QObject::connect(
but, &QPushButton::clicked, [
this]() {
244 but = w->findChild<QPushButton *>(
"text_color");
246 col1 =
pal.color(QPalette::Button);
247 but = w->findChild<QPushButton *>(
"text_background");
249 col2 =
pal.color(QPalette::Button);
250 a1 =
col1.name().toUtf8();
251 a2 =
col2.name().toUtf8();
286 log_error(
"Option type %s (%d) not supported yet.",
304 c->setCheckState(Qt::Checked);
306 c->setCheckState(Qt::Unchecked);
318 if (c->checkState() == Qt::Checked) {
349 qApp->processEvents();
353 qp->setText(
ql[0] +
" " +
ql[1]);
380 i = cb->findText(
string);
382 cb->setCurrentIndex(
i);
400 return cb->currentText().toUtf8();
403 return le->displayText().toUtf8();
415 cb->setCurrentIndex(index);
426 return cb->currentIndex();
442 if (value & (1 <<
i)) {
457 unsigned int value = 0;
478 QString s1 =
"QPushButton { background-color: ";
487 button->setStyleSheet(
s1 +
col.name() +
s2);
500 but = w->findChild<QPushButton *>(
"text_color");
503 but = w->findChild<QPushButton *>(
"text_background");
535 log_error(
"Option type %s (%d) not supported yet.",
589 log_error(
"Option type %s (%d) not supported yet.",
616 const struct strvec *values;
640 twidget->setProperty(
"doomed",
true);
642 scroll->setProperty(
"doomed",
true);
643 scroll->setWidgetResizable(
true);
644 twidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
666 spin->setMinimum(min);
667 spin->setMaximum(max);
668 spin->setSingleStep(
MAX((max - min) / 50, 1));
674 if (values !=
nullptr) {
677 combo->addItem(value);
681 edit =
new QLineEdit();
691 combo->addItem(
_(
str),
i);
709 button =
new QPushButton();
713 qlist =
qstr.split(
",");
715 button->setText(qlist[0] +
" " + qlist[1]);
722 button =
new QPushButton();
723 button->setToolTip(
_(
"Select the text color"));
724 button->setObjectName(
"text_color");
725 button->setAutoFillBackground(
true);
726 button->setAutoDefault(
false);
732 pal = button->palette();
733 pal.setColor(QPalette::Button, c);
734 button->setPalette(
pal);
738 button =
new QPushButton();
739 button->setToolTip(
_(
"Select the background color"));
740 button->setObjectName(
"text_background");
741 button->setAutoFillBackground(
true);
742 button->setAutoDefault(
false);
748 pal = button->palette();
749 pal.setColor(QPalette::Button, c);
750 button->setPalette(
pal);
759 log_error(
"Option type %s (%d) not supported yet.",
767 label =
new QLabel(description);
815 pb = (QPushButton *) QObject::sender();
817 qf = QFontDialog::getFont(&ok,
qf,
this,
820 ql =
qf.toString().split(
",");
821 pb->setText(
ql[0] +
" " +
ql[1]);
848 return f.toString().toUtf8();
863 color = QColorDialog::getColor(
pal.color(QPalette::Button),
this,
865 if (
color.isValid()) {
866 pal.setColor(QPalette::Button,
color);
881 if (!
gui()->qt_settings.options_client_geometry.isNull()) {
885 if (!
gui()->qt_settings.options_server_geometry.isNull()) {
QString split_text(QString text, bool cut)
void update_nationset_combo()
static struct ft_color ft_color_construct(const char *foreground, const char *background)
static struct dialog_list * dialog_list
#define log_error(message,...)
void option_gui_remove(struct option *poption)
void option_dialog_popdown(const struct option_set *poptset)
QString split_text(QString text, bool cut)
void option_gui_add(struct option *poption)
QMap< const struct option_set *, option_dialog * > dialog_list
void option_gui_update(struct option *poption)
void option_dialog_popup(QString name, const struct option_set *poptset, bool client_set)
QString cut_helptext(QString text)
const struct strvec * option_str_values(const struct option *poption)
unsigned option_bitwise_def(const struct option *poption)
int option_int_min(const struct option *poption)
bool option_bool_def(const struct option *poption)
const char * option_font_def(const struct option *poption)
const struct option_set * server_optset
const char * option_description(const struct option *poption)
const char * option_help_text(const struct option *poption)
struct ft_color option_color_get(const struct option *poption)
int option_enum_get_int(const struct option *poption)
bool option_str_set(struct option *poption, const char *str)
const char * option_name(const struct option *poption)
int option_int_get(const struct option *poption)
bool option_color_set(struct option *poption, struct ft_color color)
bool option_bool_set(struct option *poption, bool val)
bool option_is_changeable(const struct option *poption)
void option_set_gui_data(struct option *poption, void *data)
const char * option_str_get(const struct option *poption)
void * option_get_gui_data(const struct option *poption)
bool option_enum_set_int(struct option *poption, int val)
bool option_bool_get(const struct option *poption)
enum option_type option_type(const struct option *poption)
const char * option_enum_int_to_str(const struct option *poption, int val)
const struct option_set * option_optset(const struct option *poption)
const char * option_str_def(const struct option *poption)
int option_int_max(const struct option *poption)
bool option_font_set(struct option *poption, const char *font)
void options_save(option_save_log_callback log_cb)
const struct strvec * option_bitwise_values(const struct option *poption)
bool option_bitwise_set(struct option *poption, unsigned val)
const char * option_font_get(const struct option *poption)
void desired_settable_options_update(void)
struct ft_color option_color_def(const struct option *poption)
unsigned option_bitwise_get(const struct option *poption)
int option_enum_def_int(const struct option *poption)
bool option_int_set(struct option *poption, int val)
const char * option_category_name(const struct option *poption)
int option_int_def(const struct option *poption)
#define options_iterate(poptset, poption)
#define options_iterate_end
const char * strvec_get(const struct strvec *psv, size_t svindex)
size_t strvec_size(const struct strvec *psv)
#define strvec_iterate(psv, str)
#define strvec_iterate_end
unsigned get_bitwise(struct option *poption)
const option_set * curr_options
void hideEvent(QHideEvent *event)
QMap< QString, QWidget * > widget_map
QByteArray get_button_font(struct option *poption)
void get_color(struct option *poption, QByteArray &a1, QByteArray &a2)
bool get_bool(struct option *poption)
QDialogButtonBox * button_box
void set_string(struct option *poption, const char *string)
void set_int(struct option *poption, int value)
QList< QString > categories
void showEvent(QShowEvent *event)
QByteArray get_string(struct option *poption)
int get_enum(struct option *poption)
void add_option(struct option *poption)
void set_bool(struct option *poption, bool value)
void set_enum(struct option *poption, int index)
void apply_option(int response)
void closeEvent(QCloseEvent *event)
QVBoxLayout * main_layout
void set_font(struct option *poption, QString s)
QFont get_font(struct option *poption)
const struct option_set * poptset
void option_dialog_reset(struct option *poption)
void set_color(struct option *poption, struct ft_color color)
void fill(const struct option_set *poptset)
void option_dialog_refresh(struct option *poption)
int get_int(struct option *poption)
void set_button_color(QPushButton *button, const char *colorname)
void set_bitwise(struct option *poption, unsigned value)
option_dialog(const QString &name, const option_set *options, bool client_set, QWidget *parent=nullptr)