diff --git a/client/gui-qt/diplodlg.cpp b/client/gui-qt/diplodlg.cpp index 24edfc1785..b786073d99 100644 --- a/client/gui-qt/diplodlg.cpp +++ b/client/gui-qt/diplodlg.cpp @@ -675,8 +675,8 @@ void diplo_wdg::update_wdg() */ void diplo_wdg::restore_pixmap() { - queen()->sw_diplo->setPixmap( - fcIcons::instance()->getPixmap(QStringLiteral("nations"))); + queen()->sw_diplo->setIcon( + fcIcons::instance()->getIcon(QStringLiteral("nations"))); queen()->sw_diplo->setCustomLabels(QString()); queen()->sw_diplo->update(); } @@ -884,11 +884,12 @@ void handle_diplomacy_init_meeting(int counterpart, int initiated_from) hmid = qMax(1, hmid); p.drawPixmap(1, hmid, *pix2); p.end(); - queen()->sw_diplo->setPixmap(pix3); + queen()->sw_diplo->setIcon(QIcon(*pix3)); queen()->sw_diplo->setCustomLabels( QString(nation_plural_for_player(player_by_number(counterpart)))); queen()->sw_diplo->update(); delete pix2; + delete pix3; if (!queen()->isRepoDlgOpen(QStringLiteral("DDI"))) { dd = new diplo_dlg(counterpart, initiated_from); diff --git a/client/gui-qt/page_game.cpp b/client/gui-qt/page_game.cpp index 931540a10f..aadf53aaad 100644 --- a/client/gui-qt/page_game.cpp +++ b/client/gui-qt/page_game.cpp @@ -68,42 +68,45 @@ pageGame::pageGame(QWidget *parent) mapview_wdg->setFocusPolicy(Qt::WheelFocus); top_bar_wdg = new top_bar(); sw_map = new top_bar_widget( - fcIcons::instance()->getPixmap(QStringLiteral("view")), Q_("?noun:View"), QStringLiteral("MAP"), top_bar_show_map); + sw_map->setIcon(fcIcons::instance()->getIcon(QStringLiteral("view"))); sw_map->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - sw_tax = new top_bar_widget(nullptr, nullptr, QLatin1String(""), - top_bar_rates_wdg, top_bar_widget::SW_TAX); + sw_tax = new top_bar_widget(nullptr, QLatin1String(""), top_bar_rates_wdg, + top_bar_widget::SW_TAX); sw_indicators = - new top_bar_widget(nullptr, nullptr, QLatin1String(""), - top_bar_show_map, top_bar_widget::SW_INDICATORS); + new top_bar_widget(nullptr, QLatin1String(""), top_bar_show_map, + top_bar_widget::SW_INDICATORS); sw_indicators->setRightClick(top_bar_indicators_menu); - sw_cunit = new top_bar_widget( - fcIcons::instance()->getPixmap(QStringLiteral("units")), _("Units"), - QLatin1String(""), toggle_units_report); + sw_cunit = + new top_bar_widget(_("Units"), QLatin1String(""), toggle_units_report); + sw_cunit->setIcon(fcIcons::instance()->getIcon(QStringLiteral("units"))); sw_cunit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - sw_cities = new top_bar_widget( - fcIcons::instance()->getPixmap(QStringLiteral("cities")), _("Cities"), - QStringLiteral("CTS"), city_report_dialog_popup); + sw_cities = new top_bar_widget(_("Cities"), QStringLiteral("CTS"), + city_report_dialog_popup); + sw_cities->setIcon(fcIcons::instance()->getIcon(QStringLiteral("cities"))); sw_cities->setWheelUp(center_next_enemy_city); sw_cities->setWheelDown(center_next_player_city); sw_cities->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); sw_diplo = new top_bar_widget( - fcIcons::instance()->getPixmap(QStringLiteral("nations")), _("Nations"), QStringLiteral("PLR"), popup_players_dialog); + sw_diplo->setIcon(fcIcons::instance()->getIcon(QStringLiteral("nations"))); sw_diplo->setWheelUp(center_next_player_capital); sw_diplo->setWheelDown(key_center_capital); sw_diplo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); sw_science = new top_bar_widget( - fcIcons::instance()->getPixmap(QStringLiteral("research")), _("Research"), QStringLiteral("SCI"), top_bar_left_click_science); + sw_science->setIcon( + fcIcons::instance()->getIcon(QStringLiteral("research"))); sw_science->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); sw_economy = new top_bar_widget( - fcIcons::instance()->getPixmap(QStringLiteral("economy")), _("Economy"), QStringLiteral("ECO"), economy_report_dialog_popup); + sw_economy->setIcon( + fcIcons::instance()->getIcon(QStringLiteral("economy"))); sw_economy->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); sw_endturn = new top_bar_widget( - fcIcons::instance()->getPixmap(QStringLiteral("endturn")), _("Turn Done"), QLatin1String(""), top_bar_finish_turn); + sw_endturn->setIcon( + fcIcons::instance()->getIcon(QStringLiteral("endturn"))); sw_endturn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); sw_cunit->setRightClick(top_bar_center_unit); sw_cunit->setWheelUp(cycle_enemy_units); @@ -178,19 +181,16 @@ pageGame::~pageGame() = default; */ void pageGame::reloadSidebarIcons() { - sw_map->setPixmap(fcIcons::instance()->getPixmap(QStringLiteral("view"))); - sw_cunit->setPixmap( - fcIcons::instance()->getPixmap(QStringLiteral("units"))); - sw_cities->setPixmap( - fcIcons::instance()->getPixmap(QStringLiteral("cities"))); - sw_diplo->setPixmap( - fcIcons::instance()->getPixmap(QStringLiteral("nations"))); - sw_science->setPixmap( - fcIcons::instance()->getPixmap(QStringLiteral("research"))); - sw_economy->setPixmap( - fcIcons::instance()->getPixmap(QStringLiteral("economy"))); - sw_endturn->setPixmap( - fcIcons::instance()->getPixmap(QStringLiteral("endturn"))); + sw_map->setIcon(fcIcons::instance()->getIcon(QStringLiteral("view"))); + sw_cunit->setIcon(fcIcons::instance()->getIcon(QStringLiteral("units"))); + sw_cities->setIcon(fcIcons::instance()->getIcon(QStringLiteral("cities"))); + sw_diplo->setIcon(fcIcons::instance()->getIcon(QStringLiteral("nations"))); + sw_science->setIcon( + fcIcons::instance()->getIcon(QStringLiteral("research"))); + sw_economy->setIcon( + fcIcons::instance()->getIcon(QStringLiteral("economy"))); + sw_endturn->setIcon( + fcIcons::instance()->getIcon(QStringLiteral("endturn"))); } /** diff --git a/client/gui-qt/top_bar.cpp b/client/gui-qt/top_bar.cpp index ff547d3d74..49a23a8e40 100644 --- a/client/gui-qt/top_bar.cpp +++ b/client/gui-qt/top_bar.cpp @@ -57,25 +57,16 @@ void reduce_mod(int &mod, int &val) /** Sidewidget constructor */ -top_bar_widget::top_bar_widget(QPixmap *pix, const QString &label, - const QString &pg, pfcn_bool func, - standards type) +top_bar_widget::top_bar_widget(const QString &label, const QString &pg, + pfcn_bool func, standards type) : QToolButton(), blink(false), keep_blinking(false), standard(type), page(pg), hover(false), right_click(nullptr), wheel_down(nullptr), - wheel_up(nullptr), left_click(func), def_pixmap(pix), desc(label) + wheel_up(nullptr), left_click(func), desc(label) { - if (def_pixmap == nullptr) { - def_pixmap = new QPixmap(5, 5); - } - setText(label); setToolButtonStyle(Qt::ToolButtonTextBesideIcon); setContextMenuPolicy(Qt::CustomContextMenu); - if (def_pixmap) { - setIcon(QIcon(*def_pixmap)); - } - timer = new QTimer; timer->setSingleShot(false); timer->setInterval(700); @@ -87,20 +78,9 @@ top_bar_widget::top_bar_widget(QPixmap *pix, const QString &label, */ top_bar_widget::~top_bar_widget() { - NFCN_FREE(def_pixmap); - delete timer; } -/** - Sets default pixmap for sidewidget - */ -void top_bar_widget::setPixmap(QPixmap *pm) -{ - NFCN_FREE(def_pixmap); - def_pixmap = pm; -} - /** Sets custom text visible on top of sidewidget */ @@ -193,21 +173,6 @@ void top_bar_widget::paintEvent(QPaintEvent *event) pos = pos + w; sprite = client_government_sprite(); p.drawPixmap(pos, 5, *sprite); - - } else { - auto pix_rect = QRectF(def_pixmap->rect()); - - // Shrink to make it fit - if (pix_rect.width() > width()) { - pix_rect.setSize(pix_rect.size() * width() / pix_rect.width()); - } - if (pix_rect.height() > height()) { - pix_rect.setSize(pix_rect.size() * height() / pix_rect.height()); - } - - pix_rect.moveCenter(rect.center()); - p.drawPixmap(pix_rect, *def_pixmap, def_pixmap->rect()); - p.drawText(rect, desc); } p.setPen(palette().color(QPalette::Text)); diff --git a/client/gui-qt/top_bar.h b/client/gui-qt/top_bar.h index a552ff3966..3c770a2e6e 100644 --- a/client/gui-qt/top_bar.h +++ b/client/gui-qt/top_bar.h @@ -39,8 +39,8 @@ class top_bar_widget : public QToolButton { public: enum standards { SW_STD, SW_TAX, SW_INDICATORS }; - top_bar_widget(QPixmap *pix, const QString &label, const QString &pg, - pfcn_bool func, standards type = SW_STD); + top_bar_widget(const QString &label, const QString &pg, pfcn_bool func, + standards type = SW_STD); ~top_bar_widget() override; int getPriority(); QPixmap *get_pixmap(); @@ -48,7 +48,6 @@ class top_bar_widget : public QToolButton { void setCustomLabels(const QString &); void setLabel(const QString &str); void setLeftClick(pfcn_bool func); - void setPixmap(QPixmap *pm); void setRightClick(pfcn func); void setTooltip(const QString &tooltip); void setWheelDown(pfcn func); @@ -78,7 +77,6 @@ public slots: pfcn_bool left_click; QFont sfont; QFont info_font; - QPixmap *def_pixmap; QString custom_label; QString desc; QTimer *timer;