Project

General

Profile

Feature #327 ยป 0046-Ruledit-Add-values_dlg.patch

Marko Lindqvist, 03/23/2024 08:02 AM

View differences:

meson.build
'tools/ruledit/tab_building.h',
'tools/ruledit/tab_good.h',
'tools/ruledit/tab_gov.h',
'tools/ruledit/tab_unit.h']
'tools/ruledit/tab_unit.h',
'tools/ruledit/values_dlg.h']
)
executable('freeciv-ruledit',
......
'tools/ruledit/tab_unit.cpp',
'tools/ruledit/univ_value.c',
'tools/ruledit/validity.c',
'tools/ruledit/values_dlg.cpp',
mocced_ruledit, rulediticon,
include_directories: tool_inc,
dependencies: [qt_dep, m_dep, net_dep, readline_dep, gettext_dep,
tools/ruledit/Makefile.am
meta_tab_nation.cpp \
meta_tab_tech.cpp \
meta_tab_terrains.cpp \
meta_tab_unit.cpp
meta_tab_unit.cpp \
meta_values_dlg.cpp
freeciv_ruledit_SOURCES = \
conversion_log.cpp \
......
univ_value.c \
univ_value.h \
validity.c \
validity.h
validity.h \
values_dlg.cpp \
values_dlg.h
nodist_freeciv_ruledit_SOURCES = $(MOC_FILES)
tools/ruledit/edit_impr.cpp
/**********************************************************************//**
Setup edit_impr object
**************************************************************************/
edit_impr::edit_impr(ruledit_gui *ui_in, struct impr_type *impr_in) : QDialog()
edit_impr::edit_impr(ruledit_gui *ui_in, struct impr_type *impr_in) : values_dlg()
{
QHBoxLayout *main_layout = new QHBoxLayout(this);
QGridLayout *impr_layout = new QGridLayout();
......
**************************************************************************/
void edit_impr::closeEvent(QCloseEvent *cevent)
{
close_help();
// Save values from text fields.
gfx_tag_given();
gfx_tag_alt_given();
......
**************************************************************************/
void edit_impr::helptext()
{
helpeditor *editor = new helpeditor(impr->helptext);
editor->show();
open_help(impr->helptext);
}
tools/ruledit/edit_impr.h
// Qt
#include <QDialog>
// ruledit
#include "values_dlg.h"
class QGridLayout;
class QLineEdit;
class QSpinBox;
......
class ruledit_gui;
class edit_impr : public QDialog
class edit_impr : public values_dlg
{
Q_OBJECT
tools/ruledit/helpeditor.cpp
#include "fcintl.h"
#include "string_vector.h"
// ruledit
#include "values_dlg.h"
#include "helpeditor.h"
/**********************************************************************//**
Setup helpeditor object
**************************************************************************/
helpeditor::helpeditor(struct strvec *helptext_in) : QDialog()
helpeditor::helpeditor(values_dlg *parent_dlg, struct strvec *helptext_in) : QDialog()
{
QGridLayout *main_layout = new QGridLayout(this);
QPushButton *close_button;
int row = 0;
pdlg = parent_dlg;
helptext = helptext_in;
area = new QTextEdit();
......
setLayout(main_layout);
}
/**********************************************************************//**
Close helpeditor
**************************************************************************/
void helpeditor::close()
{
done(0);
}
/**********************************************************************//**
User pushed close button
**************************************************************************/
void helpeditor::close_now()
{
done(0);
// Both closes this dialog, and handles parent's own bookkeeping
pdlg->close_help();
}
tools/ruledit/helpeditor.h
#include <QTextEdit>
class ruledit_gui;
class values_dlg;
class helpeditor : public QDialog
{
Q_OBJECT
public:
explicit helpeditor(struct strvec *helptext_in);
explicit helpeditor(values_dlg *parent_dlg, struct strvec *helptext_in);
void close();
private:
struct strvec *helptext;
values_dlg *pdlg;
QTextEdit *area;
tools/ruledit/values_dlg.cpp
/***********************************************************************
Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#ifdef HAVE_CONFIG_H
#include <fc_config.h>
#endif
// ruledit
#include "helpeditor.h"
#include "values_dlg.h"
/**********************************************************************//**
values_dlg constructor
**************************************************************************/
values_dlg::values_dlg() : QDialog()
{
help = nullptr;
}
/**********************************************************************//**
Open help editor
**************************************************************************/
void values_dlg::open_help(struct strvec *helptext)
{
if (help == nullptr) {
help = new helpeditor(this, helptext);
help->show();
}
}
/**********************************************************************//**
Help editor is closing.
**************************************************************************/
void values_dlg::close_help()
{
if (help != nullptr) {
help->close();
help = nullptr;
}
}
tools/ruledit/values_dlg.h
/***********************************************************************
Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#ifndef FC__VALUES_DLG_H
#define FC__VALUES_DLG_H
#ifdef HAVE_CONFIG_H
#include <fc_config.h>
#endif
// Qt
#include <QDialog>
class helpeditor;
struct strvec;
class values_dlg : public QDialog
{
Q_OBJECT
public:
values_dlg();
void open_help(struct strvec *help);
void close_help();
private:
helpeditor *help;
protected:
private slots:
};
#endif // FC__VALUES_DLG_H
    (1-1/1)