19#include <QApplication>
27#include <QProgressBar>
29#include <QTableWidget>
62#define ML_COL_SUBTYPE 4
71 const char *version,
const char *license,
72 enum modpack_type
type,
const char *subtype,
83int main(
int argc,
char **argv)
92 if (ui_options != -1) {
95 for (i = 1; i <= ui_options; i++) {
98 _(
"This modpack installer accepts the standard Qt command-line options\n"
99 "after '--'. See the Qt documentation.\n\n"));
102 fc_fprintf(stderr,
_(
"Report bugs at %s\n"), BUG_URL);
109 if (ui_options != -1) {
116 const QString fip = QString(full_icon_path);
120 qapp =
new QApplication(ui_options, argv);
121 central =
new QWidget;
126 qapp->setWindowIcon(QIcon(*pm));
128 main_window->setGeometry(0, 30, 640, 60);
129 main_window->setWindowTitle(QString::fromUtf8(
_(
"Freeciv modpack installer (Qt)")));
135 main_window->setCentralWidget(central);
136 main_window->setVisible(
true);
139 if (errmsg !=
nullptr) {
146 if (
worker->isRunning()) {
193#define URL_LABEL_TEXT N_("Modpack URL")
194 QVBoxLayout *main_layout =
new QVBoxLayout();
195 QHBoxLayout *hl =
new QHBoxLayout();
196 QPushButton *install_button =
new QPushButton(QString::fromUtf8(
_(
"Install modpack")));
199 QLabel *version_label;
207 mode =
R__(
"built in Qt6 mode.");
209 mode =
R__(
"built in Qt5 mode.");
212 if (rev_ver ==
nullptr) {
214 VERSION_STRING, mode);
216 fc_snprintf(verbuf,
sizeof(verbuf),
_(
"%s%s\ncommit: %s\n%s"),
220 version_label =
new QLabel(QString::fromUtf8(verbuf));
221 version_label->setAlignment(Qt::AlignHCenter);
222 version_label->setParent(central);
223 version_label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
224 main_layout->addWidget(version_label);
227 mplist_table->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
229 headers << QString::fromUtf8(
_(
"Name")) << QString::fromUtf8(
_(
"Version"));
230 headers << QString::fromUtf8(
_(
"Installed")) << QString::fromUtf8(
Q_(
"?modpack:Type"));
231 headers << QString::fromUtf8(
_(
"Subtype")) << QString::fromUtf8(
_(
"License"));
232 headers << QString::fromUtf8(
_(
"URL")) <<
"typeint";
235 mplist_table->setEditTriggers(QAbstractItemView::NoEditTriggers);
236 mplist_table->setSelectionBehavior(QAbstractItemView::SelectRows);
237 mplist_table->setSelectionMode(QAbstractItemView::SingleSelection);
249 URL_label->setParent(central);
250 hl->addWidget(URL_label);
252 URLedit =
new QLineEdit(central);
263 main_layout->addLayout(hl);
265 connect(install_button, SIGNAL(pressed()),
this, SLOT(
URL_given()));
266 main_layout->addWidget(install_button);
268 bar =
new QProgressBar(central);
269 main_layout->addWidget(
bar);
271 msg_dspl =
new QLabel(QString::fromUtf8(
_(
"Select modpack to install")));
275 msg_dspl->setAlignment(Qt::AlignHCenter);
277 central->setLayout(main_layout);
285 QByteArray msg_bytes = msg.toLocal8Bit();
304 bar->setMaximum(max);
305 bar->setValue(downloaded);
322 if (
worker->isRunning()) {
346 for (
int i = 0; i <
mpcount; i++) {
349 const char *new_inst;
350 enum modpack_type
type;
351 QByteArray name_bytes;
355 type = (
enum modpack_type) type_int;
356 name_bytes = name_str.toUtf8();
359 if (new_inst ==
nullptr) {
360 new_inst =
_(
"Not installed");
381 const char *version,
const char *license,
382 enum modpack_type
type,
const char *subtype,
385 const char *type_str;
387 const char *inst_str;
389 QTableWidgetItem *
item;
391 if (modpack_type_is_valid(
type)) {
392 type_str =
_(modpack_type_name(
type));
398 if (license !=
nullptr) {
402 lic_str =
Q_(
"?license:Unknown");
406 if (inst_str ==
nullptr) {
407 inst_str =
_(
"Not installed");
412 item =
new QTableWidgetItem(QString::fromUtf8(
name));
413 item->setToolTip(QString::fromUtf8(notes));
415 item =
new QTableWidgetItem(QString::fromUtf8(version));
416 item->setToolTip(QString::fromUtf8(notes));
418 item =
new QTableWidgetItem(QString::fromUtf8(inst_str));
419 item->setToolTip(QString::fromUtf8(notes));
421 item =
new QTableWidgetItem(QString::fromUtf8(type_str));
422 item->setToolTip(QString::fromUtf8(notes));
424 item =
new QTableWidgetItem(QString::fromUtf8(subtype));
425 item->setToolTip(QString::fromUtf8(notes));
427 item =
new QTableWidgetItem(QString::fromUtf8(lic_str));
428 item->setToolTip(QString::fromUtf8(notes));
430 item =
new QTableWidgetItem(QString::fromUtf8(URL));
431 item->setToolTip(QString::fromUtf8(notes));
434 type_nbr.setNum(
type);
435 item =
new QTableWidgetItem(type_nbr);
436 item->setToolTip(notes);
447 const char *version,
const char *license,
448 enum modpack_type
type,
const char *subtype,
494 ask.setText(
_(
"Modpack installation in progress.\nAre you sure you want to quit?"));
495 ask.setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
496 ask.setDefaultButton(QMessageBox::Cancel);
497 ask.setIcon(QMessageBox::Warning);
498 ask.setWindowTitle(
_(
"Quit?"));
502 case QMessageBox::Cancel:
505 case QMessageBox::Ok:
mpgui_main(QApplication *qapp_in, QWidget *central_in)
void closeEvent(QCloseEvent *event)
void refresh_list_versions_thr()
void row_selected(int, int)
void display_msg(QString msg)
void row_download(const QModelIndex &)
void display_msg_thr_signal(QString msg)
void display_msg_thr(const char *msg)
void refresh_list_versions_thr_signal()
void progress_thr_signal(int downloaded, int max)
QTableWidget * mplist_table
void progress_thr(int downloaded, int max)
void setup_list(const char *name, const char *URL, const char *version, const char *license, enum modpack_type type, const char *subtype, const char *notes)
void refresh_list_versions()
void setup(QWidget *central, struct fcmp_params *fcmp)
void progress(int downloaded, int max)
void download(QString URL_in, class mpgui *gui_in, struct fcmp_params *fcmp_in, dl_msg_callback msg_callback_in, dl_pb_callback pb_callback_in)
const char * download_modpack_list(const struct fcmp_params *fcmp, modpack_list_setup_cb cb, dl_msg_callback mcb)
bool is_option(const char *option_name, char *option)
void cmdline_option_values_free(void)
void fc_fprintf(FILE *stream, const char *format,...) fc__attribute((__format__(__printf__
static QApplication * qapp
#define log_verbose(message,...)
void load_install_info_lists(struct fcmp_params *fcmp)
#define DEFAULT_URL_START
int fcmp_parse_cmdline(int argc, char *argv[])
const char * mpdb_installed_version(const char *name, enum modpack_type type)
static void gui_download_modpack(const char *URL)
static void progress_callback_thr(int downloaded, int max)
int main(int argc, char **argv)
static void msg_callback_thr(const char *msg)
static void gui_download_modpack(QString URL)
static mpqt_worker * worker
static void setup_modpack_list(const char *name, const char *URL, const char *version, const char *license, enum modpack_type type, const char *subtype, const char *notes)
static void msg_callback(const char *msg)
const char * fileinfoname(const struct strvec *dirs, const char *filename)
const struct strvec * get_data_dirs(void)
int fc_snprintf(char *str, size_t n, const char *format,...)
const char * fc_git_revision(void)
const char * word_version(void)