Author: mir3x Date: Sun Nov 6 22:03:53 2016 New Revision: 34409 URL: http://svn.gna.org/viewcvs/freeciv?rev=34409&view=rev Log: Qt client: fixed some fonts not updated when changed in the settings Reported by Louis Moureaux <louis94>
See bug #25023 Modified: trunk/client/gui-qt/fc_client.cpp trunk/client/gui-qt/fc_client.h trunk/client/gui-qt/gui_main.cpp trunk/client/gui-qt/helpdlg.cpp trunk/client/gui-qt/helpdlg.h Modified: trunk/client/gui-qt/fc_client.cpp URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.cpp?rev=34409&r1=34408&r2=34409&view=diff ============================================================================== --- trunk/client/gui-qt/fc_client.cpp (original) +++ trunk/client/gui-qt/fc_client.cpp Sun Nov 6 22:03:53 2016 @@ -276,16 +276,6 @@ output_window->append(str); output_window->verticalScrollBar()->setSliderPosition( output_window->verticalScrollBar()->maximum()); - } -} - -/**************************************************************************** - Updates the application's default font when it changes -****************************************************************************/ -void fc_client::update_font(const QString &name, const QFont &font) -{ - if (name == fonts::default_font) { - QApplication::setFont(font); } } Modified: trunk/client/gui-qt/fc_client.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.h?rev=34409&r1=34408&r2=34409&view=diff ============================================================================== --- trunk/client/gui-qt/fc_client.h (original) +++ trunk/client/gui-qt/fc_client.h Sun Nov 6 22:03:53 2016 @@ -307,8 +307,6 @@ private: void chat_message_received(const QString &message, const struct text_tag_list *tags); - void update_font(const QString &name, const QFont &font); - void create_main_page(); void create_network_page(); void create_load_page(); Modified: trunk/client/gui-qt/gui_main.cpp URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/gui_main.cpp?rev=34409&r1=34408&r2=34409&view=diff ============================================================================== --- trunk/client/gui-qt/gui_main.cpp (original) +++ trunk/client/gui-qt/gui_main.cpp Sun Nov 6 22:03:53 2016 @@ -433,40 +433,22 @@ ****************************************************************************/ static void apply_notify_font(struct option *poption) { - QFont *f; - QFont *remove_old; + if (gui()) { + qtg_gui_update_font("notify_label", option_font_get(poption)); + restart_notify_dialogs(); + } +} + + +/**************************************************************************** + Changes city label font +****************************************************************************/ +void apply_city_font(option *poption) +{ QString s; - if (gui()) { - f = new QFont; - s = option_font_get(poption); - f->fromString(s); - s = option_name(poption); - remove_old = fc_font::instance()->get_font(s); - delete remove_old; - fc_font::instance()->set_font(s, f); - restart_notify_dialogs(); - } -} - - -/**************************************************************************** - Changes city label font -****************************************************************************/ -void apply_city_font(option *poption) -{ - QFont *f; - QFont *remove_old; - QString s; - if (gui() && qtg_get_current_client_page() == PAGE_GAME) { - f = new QFont; - s = option_font_get(poption); - f->fromString(s); - s = option_name(poption); - remove_old = fc_font::instance()->get_font(s); - delete remove_old; - fc_font::instance()->set_font(s, f); + qtg_gui_update_font("city_label", option_font_get(poption)); city_font_update(); } } Modified: trunk/client/gui-qt/helpdlg.cpp URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/helpdlg.cpp?rev=34409&r1=34408&r2=34409&view=diff ============================================================================== --- trunk/client/gui-qt/helpdlg.cpp (original) +++ trunk/client/gui-qt/helpdlg.cpp Sun Nov 6 22:03:53 2016 @@ -357,9 +357,11 @@ box_wdg->setFrameShadow(QFrame::Raised); title_label = new QLabel(box_wdg); + title_label->setProperty(fonts::help_title, "true"); group_layout->addWidget(title_label); text_browser = new QTextBrowser(this); + text_browser->setProperty(fonts::help_text, "true"); layout->addWidget(text_browser); main_widget = text_browser; @@ -429,19 +431,28 @@ **************************************************************************/ void help_widget::update_fonts() { - QFont *help_font, *label_font, *title_font; - QLabel *label; - - label_font = fc_font::instance()->get_font(fonts::help_label); - help_font = fc_font::instance()->get_font(fonts::help_text); - title_font = fc_font::instance()->get_font(fonts::help_title); - text_browser->setFont(*help_font); - title_label->setFont(*title_font); - foreach (label, label_list) { - label->setFont(*label_font); - } - foreach (label, title_list) { - label->setFont(*title_font); + QList<QWidget *> l; + QFont *f; + + l = findChildren<QWidget *>(); + + f = fc_font::instance()->get_font(fonts::help_label); + for (int i = 0; i < l.size(); ++i) { + if (l.at(i)->property(fonts::help_label).isValid()) { + l.at(i)->setFont(*f); + } + } + f = fc_font::instance()->get_font(fonts::help_text); + for (int i = 0; i < l.size(); ++i) { + if (l.at(i)->property(fonts::help_text).isValid()) { + l.at(i)->setFont(*f); + } + } + f = fc_font::instance()->get_font(fonts::help_title); + for (int i = 0; i < l.size(); ++i) { + if (l.at(i)->property(fonts::help_title).isValid()) { + l.at(i)->setFont(*f); + } } } @@ -466,8 +477,6 @@ info_panel = NULL; splitter = NULL; info_layout = NULL; - label_list.clear(); - title_list.clear(); } /**************************************************************************** @@ -507,8 +516,7 @@ { QLabel *label = new QLabel(text); label->setWordWrap(true); - - label_list << label; + label->setProperty(fonts::help_label, "true"); info_layout->addWidget(label); } @@ -535,14 +543,14 @@ label = new QLabel(text, wdg); layout->addWidget(label, 0, 0); - label_list << label; + label->setProperty(fonts::help_label, "true"); label = new QLabel(wdg); if (value.isEmpty()) { label->setNum(progress); } else { label->setText(value); } - label_list << label; + label->setProperty(fonts::help_label, "true"); layout->addWidget(label, 0, 1, Qt::AlignRight); bar = new QProgressBar(wdg); @@ -580,6 +588,7 @@ QLabel *tb; QString str; tb = new QLabel(this); + tb->setProperty(fonts::help_label, "true"); tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse); tb->setTextFormat(Qt::RichText); @@ -919,6 +928,7 @@ if (VUT_ADVANCE == preq->source.kind && preq->source.value.advance == padvance) { tb = new QLabel(this); + tb->setProperty(fonts::help_label, "true"); tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse); tb->setTextFormat(Qt::RichText); str = _("Allows"); @@ -942,6 +952,7 @@ is_great_wonder(pimprove) ? HELP_WONDER : HELP_IMPROVEMENT); tb = new QLabel(this); + tb->setProperty(fonts::help_label, "true"); tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse); tb->setTextFormat(Qt::RichText); tb->setText(str.trimmed()); @@ -960,6 +971,7 @@ is_great_wonder(pimprove) ? HELP_WONDER : HELP_IMPROVEMENT); tb = new QLabel(this); + tb->setProperty(fonts::help_label, "true"); tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse); tb->setTextFormat(Qt::RichText); tb->setText(str.trimmed()); @@ -978,6 +990,7 @@ str = "<b>" + str + "</b> " + link_me(utype_name_translation(punittype), HELP_UNIT); tb = new QLabel(this); + tb->setProperty(fonts::help_label, "true"); tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse); tb->setTextFormat(Qt::RichText); tb->setText(str.trimmed()); @@ -1064,11 +1077,11 @@ label = new QLabel(title); layout->addWidget(label, 0, 1, Qt::AlignBottom); - title_list << label; + label->setProperty(fonts::help_title, "true"); label = new QLabel(legend); layout->addWidget(label, 1, 1, Qt::AlignTop); - label_list << label; + label->setProperty(fonts::help_label, "true"); if (!tooltip.isEmpty()) { label->setToolTip(tooltip); Modified: trunk/client/gui-qt/helpdlg.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/helpdlg.h?rev=34409&r1=34408&r2=34409&view=diff ============================================================================== --- trunk/client/gui-qt/helpdlg.h (original) +++ trunk/client/gui-qt/helpdlg.h Sun Nov 6 22:03:53 2016 @@ -64,8 +64,6 @@ Q_OBJECT QFrame *box_wdg; QLabel *title_label; - QList<QLabel *> label_list; - QList<QLabel *> title_list; QWidget *main_widget; QTextBrowser *text_browser; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits