From 9beebd15ee59664e39b7e770ac2bdfdbc70d4801 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 1 Jun 2023 01:33:49 +0300 Subject: [PATCH 37/37] Qt: Avoid deprecated QColor methods Replace calls of QColor methods deprecated in Qt-6.6, when building in Qt6x mode. See osdn #48125 Signed-off-by: Marko Lindqvist --- client/gui-qt/chatline.cpp | 12 +++++++++++- client/gui-qt/optiondlg.cpp | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/client/gui-qt/chatline.cpp b/client/gui-qt/chatline.cpp index 3fe55a4edb..e9cc520b40 100644 --- a/client/gui-qt/chatline.cpp +++ b/client/gui-qt/chatline.cpp @@ -603,7 +603,11 @@ QString apply_tags(QString str, const struct text_tag_list *tags, if (color == "#00008B") { color = bg_color.name(); } else { +#ifdef FC_QT6X_MODE + qc = QColor::fromString(color); +#else // FC_QT6X_MODE qc.setNamedColor(color); +#endif // FC_QT6X_MODE qc = qc.lighter(200); color = qc.name(); } @@ -613,7 +617,13 @@ QString apply_tags(QString str, const struct text_tag_list *tags, } if (text_tag_color_background(ptag)) { color = text_tag_color_background(ptag); - if (QColor::isValidColor(color)) { + if ( +#ifdef FC_QT6X_MODE + QColor::isValidColorName(color) +#else // FC_QT6X_MODE + QColor::isValidColor(color) +#endif // FC_QT6X_MODE + ) { str_col = QString("").arg(color); mm.insert(stop, ""); mm.insert(start, str_col); diff --git a/client/gui-qt/optiondlg.cpp b/client/gui-qt/optiondlg.cpp index 5209b1784d..4e618f8816 100644 --- a/client/gui-qt/optiondlg.cpp +++ b/client/gui-qt/optiondlg.cpp @@ -479,7 +479,11 @@ void option_dialog::set_button_color(QPushButton *button, QString s2 = ";}"; QColor col; +#ifdef FC_QT6X_MODE + col = QColor::fromString(colorname); +#else // FC_QT6X_MODE col.setNamedColor(colorname); +#endif // FC_QT6X_MODE button->setStyleSheet(s1 + col.name() + s2); } } @@ -720,7 +724,11 @@ void option_dialog::add_option(struct option *poption) button->setObjectName("text_color"); button->setAutoFillBackground(true); button->setAutoDefault(false); +#ifdef FC_QT6X_MODE + c = QColor::fromString(ft_color.foreground); +#else // FC_QT6X_MODE c.setNamedColor(ft_color.foreground); +#endif // FC_QT6X_MODE pal = button->palette(); pal.setColor(QPalette::Button, c); button->setPalette(pal); @@ -732,7 +740,11 @@ void option_dialog::add_option(struct option *poption) button->setObjectName("text_background"); button->setAutoFillBackground(true); button->setAutoDefault(false); +#ifdef FC_QT6X_MODE + c = QColor::fromString(ft_color.background); +#else // FC_QT6X_MODE c.setNamedColor(ft_color.background); +#endif // FC_QT6X_MODE pal = button->palette(); pal.setColor(QPalette::Button, c); button->setPalette(pal); -- 2.39.2