From 1c20cbda6f9dda373f77bbb5525b1ffd9ff9af13 Mon Sep 17 00:00:00 2001 From: yuanxing Date: Sun, 23 Apr 2023 10:07:32 +0800 Subject: [PATCH 4/6] fix(*):Compatible for versions below 5.14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 兼容5.14以下版本 去掉对 QPixmap pixmap(Qt::ReturnByValueConstant) 接口的使用 --- launcher/src/main.cpp | 6 +- lib/plugin-framework/category.h | 3 +- lib/plugin-framework/plugin-manager.cpp | 3 +- plugins/appearance/src/appearance-subitem.h | 1 + .../dbus-interface/appearance-global-info.cpp | 5 +- plugins/appearance/src/pages/font/fonts.cpp | 136 +++++++++++++----- plugins/authentication/src/auth-subitem.h | 2 + plugins/keybinding/src/keycode-translator.cpp | 4 + .../src/plugin/connection-itemwidget.cpp | 6 +- plugins/network/src/tray/tray-itemwidget.cpp | 2 +- 10 files changed, 123 insertions(+), 45 deletions(-) diff --git a/launcher/src/main.cpp b/launcher/src/main.cpp index eaeee99..1c6d6c6 100644 --- a/launcher/src/main.cpp +++ b/launcher/src/main.cpp @@ -60,7 +60,11 @@ int main(int argc, char *argv[]) QString lang = qgetenv("LANG"); if(lang.contains(".")) { - QStringList splitRes = lang.split(".",Qt::SkipEmptyParts); +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) + QStringList splitRes = lang.split(".", QString::SkipEmptyParts); +#else + QStringList splitRes = lang.split(".", Qt::SkipEmptyParts); +#endif if(splitRes.size() == 2 && splitRes.at(1)!="UTF-8" ) { splitRes.replace(1,"UTF-8"); diff --git a/lib/plugin-framework/category.h b/lib/plugin-framework/category.h index 1e48a64..723c601 100644 --- a/lib/plugin-framework/category.h +++ b/lib/plugin-framework/category.h @@ -17,6 +17,7 @@ #include #include #include +#include #include "plugin-subitem-interface.h" @@ -74,4 +75,4 @@ private: QVector m_subitems; // 维系子功能项ID和功能项之前的映射关键 QMap m_subitemIDMap; -}; \ No newline at end of file +}; diff --git a/lib/plugin-framework/plugin-manager.cpp b/lib/plugin-framework/plugin-manager.cpp index 4444a55..3a8c50b 100644 --- a/lib/plugin-framework/plugin-manager.cpp +++ b/lib/plugin-framework/plugin-manager.cpp @@ -15,6 +15,7 @@ #include "plugin-loader.h" #include +#include PluginManager* PluginManager::_instance = nullptr; @@ -71,4 +72,4 @@ void PluginManager::dump() QList PluginManager::getPlugins() { return m_plugins; -} \ No newline at end of file +} diff --git a/plugins/appearance/src/appearance-subitem.h b/plugins/appearance/src/appearance-subitem.h index bbec7d8..97b79f0 100644 --- a/plugins/appearance/src/appearance-subitem.h +++ b/plugins/appearance/src/appearance-subitem.h @@ -2,6 +2,7 @@ #define __APPEARANCE_SUBITEM_H__ #include +#include #include "panel-interface.h" #include "plugin-subitem-interface.h" diff --git a/plugins/appearance/src/dbus-interface/appearance-global-info.cpp b/plugins/appearance/src/dbus-interface/appearance-global-info.cpp index ab033d6..6913197 100644 --- a/plugins/appearance/src/dbus-interface/appearance-global-info.cpp +++ b/plugins/appearance/src/dbus-interface/appearance-global-info.cpp @@ -206,8 +206,11 @@ bool AppearanceGlobalInfo::getFont(int type, QStringList &fontList) fontInfo = reply.argumentAt(0).toString(); KLOG_INFO() << "Font type is: " << type << " Font info is:" << fontInfo; - +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) + fontInfoList = fontInfo.split(" ", QString::SkipEmptyParts); +#else fontInfoList = fontInfo.split(" ", Qt::SkipEmptyParts); +#endif if (!fontInfoList.isEmpty()) { fontSize = fontInfoList.takeLast(); diff --git a/plugins/appearance/src/pages/font/fonts.cpp b/plugins/appearance/src/pages/font/fonts.cpp index 41c184e..65e1b82 100644 --- a/plugins/appearance/src/pages/font/fonts.cpp +++ b/plugins/appearance/src/pages/font/fonts.cpp @@ -150,42 +150,100 @@ void Fonts::connectSignals() { connect(AppearanceGlobalInfo::instance(), &AppearanceGlobalInfo::fontChanged, this, &Fonts::handleFontChanged); - connect(ui->cbox_application_font_name, &QComboBox::textActivated, [=](QString text) { - m_applicationFontInfo.replace(0, text); - KLOG_INFO() << "select applicationFont name = " << m_applicationFontInfo.at(0); - KLOG_INFO() << "select applicationFont size = " << m_applicationFontInfo.at(1); - setFont(APPEARANCE_FONT_TYPE_APPLICATION, m_applicationFontInfo); - }); - connect(ui->cbox_application_font_size, &QComboBox::textActivated, [=](QString text) { - m_applicationFontInfo.replace(1, text); - KLOG_INFO() << "select applicationFont name = " << m_applicationFontInfo.at(0); - KLOG_INFO() << "select applicationFont size = " << m_applicationFontInfo.at(1); - setFont(APPEARANCE_FONT_TYPE_APPLICATION, m_applicationFontInfo); - }); - connect(ui->cbox_monospace_font_name, &QComboBox::textActivated, [=](QString text) { - m_monospaceFontInfo.replace(0, text); - KLOG_INFO() << "monospaceFontInfo name = " << m_monospaceFontInfo.at(0); - KLOG_INFO() << "monospaceFontInfo size = " << m_monospaceFontInfo.at(1); - setFont(APPEARANCE_FONT_TYPE_MONOSPACE, m_monospaceFontInfo); - }); - connect(ui->cbox_monospace_font_size, &QComboBox::textActivated, [=](QString text) { - m_monospaceFontInfo.replace(1, text); - KLOG_INFO() << "monospaceFontInfo name = " << m_monospaceFontInfo.at(0); - KLOG_INFO() << "monospaceFontInfo size = " << m_monospaceFontInfo.at(1); - setFont(APPEARANCE_FONT_TYPE_MONOSPACE, m_monospaceFontInfo); - }); - connect(ui->cbox_titlebar_font_name, &QComboBox::textActivated, [=](QString text) { - m_windowTitleFontInfo.replace(0, text); - KLOG_INFO() << "windowTitleFontInfo name = " << m_windowTitleFontInfo.at(0); - KLOG_INFO() << "windowTitleFontInfo size = " << m_windowTitleFontInfo.at(1); - setFont(APPEARANCE_FONT_TYPE_WINDOW_TITLE, m_windowTitleFontInfo); - }); - connect(ui->cbox_titlebar_font_size, &QComboBox::textActivated, [=](QString text) { - m_windowTitleFontInfo.replace(1, text); - KLOG_INFO() << "windowTitleFont name = " << m_windowTitleFontInfo.at(0); - KLOG_INFO() << "windowTitleFont size = " << m_windowTitleFontInfo.at(1); - setFont(APPEARANCE_FONT_TYPE_WINDOW_TITLE, m_windowTitleFontInfo); - }); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + connect(ui->cbox_application_font_name, &QComboBox::textActivated, [=](QString text) + { + m_applicationFontInfo.replace(0, text); + KLOG_INFO() << "select applicationFont name = " << m_applicationFontInfo.at(0); + KLOG_INFO() << "select applicationFont size = " << m_applicationFontInfo.at(1); + setFont(APPEARANCE_FONT_TYPE_APPLICATION, m_applicationFontInfo); + }); + connect(ui->cbox_application_font_size, &QComboBox::textActivated, [=](QString text) + { + m_applicationFontInfo.replace(1, text); + KLOG_INFO() << "select applicationFont name = " << m_applicationFontInfo.at(0); + KLOG_INFO() << "select applicationFont size = " << m_applicationFontInfo.at(1); + setFont(APPEARANCE_FONT_TYPE_APPLICATION, m_applicationFontInfo); + }); + connect(ui->cbox_monospace_font_name, &QComboBox::textActivated, [=](QString text) + { + m_monospaceFontInfo.replace(0, text); + KLOG_INFO() << "monospaceFontInfo name = " << m_monospaceFontInfo.at(0); + KLOG_INFO() << "monospaceFontInfo size = " << m_monospaceFontInfo.at(1); + setFont(APPEARANCE_FONT_TYPE_MONOSPACE, m_monospaceFontInfo); + }); + connect(ui->cbox_monospace_font_size, &QComboBox::textActivated, [=](QString text) + { + m_monospaceFontInfo.replace(1, text); + KLOG_INFO() << "monospaceFontInfo name = " << m_monospaceFontInfo.at(0); + KLOG_INFO() << "monospaceFontInfo size = " << m_monospaceFontInfo.at(1); + setFont(APPEARANCE_FONT_TYPE_MONOSPACE, m_monospaceFontInfo); + }); + connect(ui->cbox_titlebar_font_name, &QComboBox::textActivated, [=](QString text) + { + m_windowTitleFontInfo.replace(0, text); + KLOG_INFO() << "windowTitleFontInfo name = " << m_windowTitleFontInfo.at(0); + KLOG_INFO() << "windowTitleFontInfo size = " << m_windowTitleFontInfo.at(1); + setFont(APPEARANCE_FONT_TYPE_WINDOW_TITLE, m_windowTitleFontInfo); + }); + connect(ui->cbox_titlebar_font_size, &QComboBox::textActivated, [=](QString text) + { + m_windowTitleFontInfo.replace(1, text); + KLOG_INFO() << "windowTitleFont name = " << m_windowTitleFontInfo.at(0); + KLOG_INFO() << "windowTitleFont size = " << m_windowTitleFontInfo.at(1); + setFont(APPEARANCE_FONT_TYPE_WINDOW_TITLE, m_windowTitleFontInfo); + }); +#else + connect(ui->cbox_application_font_name, QOverload::of(&QComboBox::activated), + [=](const QString text) + { + m_applicationFontInfo.replace(0, text); + KLOG_INFO() << "select applicationFont name = " << m_applicationFontInfo.at(0); + KLOG_INFO() << "select applicationFont size = " << m_applicationFontInfo.at(1); + setFont(APPEARANCE_FONT_TYPE_APPLICATION, m_applicationFontInfo); + }); + connect(ui->cbox_application_font_size, QOverload::of(&QComboBox::activated), + [=](const QString text) + { + m_applicationFontInfo.replace(1, text); + KLOG_INFO() << "select applicationFont name = " << m_applicationFontInfo.at(0); + KLOG_INFO() << "select applicationFont size = " << m_applicationFontInfo.at(1); + setFont(APPEARANCE_FONT_TYPE_APPLICATION, m_applicationFontInfo); + }); + connect(ui->cbox_monospace_font_name, QOverload::of(&QComboBox::activated), + [=](const QString text) + { + m_monospaceFontInfo.replace(0, text); + KLOG_INFO() << "monospaceFontInfo name = " << m_monospaceFontInfo.at(0); + KLOG_INFO() << "monospaceFontInfo size = " << m_monospaceFontInfo.at(1); + setFont(APPEARANCE_FONT_TYPE_MONOSPACE, m_monospaceFontInfo); + + }); + connect(ui->cbox_monospace_font_size, QOverload::of(&QComboBox::activated), + [=](const QString text) + { + m_monospaceFontInfo.replace(1, text); + KLOG_INFO() << "monospaceFontInfo name = " << m_monospaceFontInfo.at(0); + KLOG_INFO() << "monospaceFontInfo size = " << m_monospaceFontInfo.at(1); + setFont(APPEARANCE_FONT_TYPE_MONOSPACE, m_monospaceFontInfo); + }); + connect(ui->cbox_titlebar_font_name, QOverload::of(&QComboBox::activated), + [=](const QString text) + { + m_windowTitleFontInfo.replace(0, text); + KLOG_INFO() << "windowTitleFontInfo name = " << m_windowTitleFontInfo.at(0); + KLOG_INFO() << "windowTitleFontInfo size = " << m_windowTitleFontInfo.at(1); + setFont(APPEARANCE_FONT_TYPE_WINDOW_TITLE, m_windowTitleFontInfo); + }); + connect(ui->cbox_titlebar_font_size, QOverload::of(&QComboBox::activated), + [=](const QString text) + { + m_windowTitleFontInfo.replace(1, text); + KLOG_INFO() << "windowTitleFont name = " << m_windowTitleFontInfo.at(0); + KLOG_INFO() << "windowTitleFont size = " << m_windowTitleFontInfo.at(1); + setFont(APPEARANCE_FONT_TYPE_WINDOW_TITLE, m_windowTitleFontInfo); + }); +#endif } void Fonts::showFontInfo(QComboBox* nameParent, QComboBox* sizeParent, QString name, QString size) @@ -222,7 +280,11 @@ void Fonts::showFontInfo(QComboBox* nameParent, QComboBox* sizeParent, QString n void Fonts::handleFontChanged(int type, QString fontInfo) { +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) + QStringList fontInfoList = fontInfo.split(" ", QString::SkipEmptyParts); +#else QStringList fontInfoList = fontInfo.split(" ", Qt::SkipEmptyParts); +#endif QString fontSize = fontInfoList.takeLast(); QString fontName = fontInfoList.join(" "); KLOG_INFO() << "font changed : " << type << ",name: " << fontName << ",size: " << fontSize; @@ -267,5 +329,5 @@ void Fonts::handleFontChanged(int type, QString fontInfo) QSize Fonts::sizeHint() const { - return {500,657}; + return {500, 657}; } diff --git a/plugins/authentication/src/auth-subitem.h b/plugins/authentication/src/auth-subitem.h index e09a3c8..3aa7f1f 100644 --- a/plugins/authentication/src/auth-subitem.h +++ b/plugins/authentication/src/auth-subitem.h @@ -1,6 +1,8 @@ #pragma once #include +#include +#include #include "panel-interface.h" #include "plugin-subitem-interface.h" diff --git a/plugins/keybinding/src/keycode-translator.cpp b/plugins/keybinding/src/keycode-translator.cpp index c75ee07..f692fef 100644 --- a/plugins/keybinding/src/keycode-translator.cpp +++ b/plugins/keybinding/src/keycode-translator.cpp @@ -146,7 +146,11 @@ QString KeycodeTranslator::backendKeyString2Readable(const QString &keyString) QString temp = keyString; temp = temp.replace("<",""); temp = temp.replace(">","-"); +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) + QStringList keyList = temp.split("-", QString::SkipEmptyParts); +#else QStringList keyList = temp.split("-",Qt::SkipEmptyParts); +#endif for(int i=0;ipixmap(Qt::ReturnByValue)); - if (!pixmap.isNull()) - m_connectionTypeIcon->setPixmap(pixmap); + QImage image = m_connectionTypeIcon->pixmap()->toImage(); + image.invertPixels(QImage::InvertRgb); + m_connectionTypeIcon->setPixmap(QPixmap::fromImage(image)); m_editButton->setIcon(NetworkUtils::trayIconColorSwitch(":/kcp-network-images/details-info.svg")); } diff --git a/plugins/network/src/tray/tray-itemwidget.cpp b/plugins/network/src/tray/tray-itemwidget.cpp index 2f85842..19c79af 100644 --- a/plugins/network/src/tray/tray-itemwidget.cpp +++ b/plugins/network/src/tray/tray-itemwidget.cpp @@ -297,7 +297,7 @@ void TrayItemWidget::paintEvent(QPaintEvent *event) void TrayItemWidget::handleThemeChanged(Kiran::PaletteType paletteType) { - QImage image = ui->connectionTypeIcon->pixmap(Qt::ReturnByValue).toImage(); + QImage image = ui->connectionTypeIcon->pixmap()->toImage(); image.invertPixels(QImage::InvertRgb); QPixmap pixmap = QPixmap::fromImage(image); ui->connectionTypeIcon->setPixmap(pixmap); -- 2.33.0