diff --git a/README.md b/README.md index 6b9011b..17783e6 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ You can join our [Discord channel](https://discord.gg/grrM4Tmesy) to communicate ## Highlights v2.2 -- Common: Added blur behind window feature for Windows (7~11), Linux and macOS. On Windows 11 and macOS, FramelessHelper will make use of the blur effect provided by the OS to get the best appearance and performance, while on Windows 7~10 and Linux, FramelessHelper will use a homemade blur effect to provide as much consistent experience as possible. +- Common: Added blur behind window feature for Windows (7\~11), Linux and macOS. On Windows 11 and macOS, FramelessHelper will make use of the blur effect provided by the OS to get the best appearance and performance, while on Windows 7\~10 and Linux, FramelessHelper will use a homemade blur effect to provide as much consistent experience as possible. - Common: Added window icon support. It's now possible to set the window icon's image, size and visibility for the standard title bar control. - Windows: If you are using Qt 6.4+, your Qt Widgets applications will now automatically switch to light/dark theme if the OS theme changes. It requires you are using the default palette provided by Qt. Qt Quick applications will not be affected. - Linux: FramelessHelper is now theme-aware. If you change your OS theme, FramelessHelper will now emit the theme change signal and refresh it's internal palette. diff --git a/examples/mainwindow/main.cpp b/examples/mainwindow/main.cpp index bbb7c87..e1132a0 100644 --- a/examples/mainwindow/main.cpp +++ b/examples/mainwindow/main.cpp @@ -24,12 +24,15 @@ #include #include +#include #include "mainwindow.h" FRAMELESSHELPER_USE_NAMESPACE int main(int argc, char *argv[]) { + std::setlocale(LC_ALL, "en_US.UTF-8"); + // Not necessary, but better call this function, before the construction // of any Q(Core|Gui)Application instances. FramelessHelper::Widgets::initialize(); diff --git a/examples/openglwidget/main.cpp b/examples/openglwidget/main.cpp index 41c3eda..fcaf60c 100644 --- a/examples/openglwidget/main.cpp +++ b/examples/openglwidget/main.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include "mainwindow.h" // This example demonstrates easy, cross-platform usage of OpenGL ES 3.0 functions via @@ -67,6 +68,8 @@ FRAMELESSHELPER_USE_NAMESPACE int main(int argc, char *argv[]) { + std::setlocale(LC_ALL, "en_US.UTF-8"); + // Not necessary, but better call this function, before the construction // of any Q(Core|Gui)Application instances. FramelessHelper::Widgets::initialize(); diff --git a/examples/quick/main.cpp b/examples/quick/main.cpp index 9063323..c1f2373 100644 --- a/examples/quick/main.cpp +++ b/examples/quick/main.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "settings.h" #if QMLTC_ENABLED # include @@ -42,6 +43,8 @@ FRAMELESSHELPER_USE_NAMESPACE int main(int argc, char *argv[]) { + std::setlocale(LC_ALL, "en_US.UTF-8"); + // Not necessary, but better call this function, before the construction // of any Q(Core|Gui)Application instances. FramelessHelper::Quick::initialize(); diff --git a/examples/widget/main.cpp b/examples/widget/main.cpp index 8f6ba1c..a04e6a7 100644 --- a/examples/widget/main.cpp +++ b/examples/widget/main.cpp @@ -24,12 +24,15 @@ #include #include +#include #include "widget.h" FRAMELESSHELPER_USE_NAMESPACE int main(int argc, char *argv[]) { + std::setlocale(LC_ALL, "en_US.UTF-8"); + // Not necessary, but better call this function, before the construction // of any Q(Core|Gui)Application instances. FramelessHelper::Widgets::initialize(); diff --git a/include/FramelessHelper/Quick/private/quickimageitem_p.h b/include/FramelessHelper/Quick/private/quickimageitem_p.h index b6d61ea..38373c0 100644 --- a/include/FramelessHelper/Quick/private/quickimageitem_p.h +++ b/include/FramelessHelper/Quick/private/quickimageitem_p.h @@ -28,8 +28,6 @@ #include #include #include -#include -#include FRAMELESSHELPER_BEGIN_NAMESPACE @@ -48,25 +46,23 @@ public: Q_NODISCARD static QuickImageItemPrivate *get(QuickImageItem *q); Q_NODISCARD static const QuickImageItemPrivate *get(const QuickImageItem *q); - void paint(QPainter *painter); + void paint(QPainter *painter) const; Q_NODISCARD QVariant source() const; void setSource(const QVariant &value); private: void initialize(); - void fromUrl(const QUrl &value, QPainter *painter); - void fromString(const QString &value, QPainter *painter); - void fromImage(const QImage &value, QPainter *painter); - void fromPixmap(const QPixmap &value, QPainter *painter); - void fromIcon(const QIcon &value, QPainter *painter); + void fromUrl(const QUrl &value, QPainter *painter) const; + void fromString(const QString &value, QPainter *painter) const; + void fromImage(const QImage &value, QPainter *painter) const; + void fromPixmap(const QPixmap &value, QPainter *painter) const; + void fromIcon(const QIcon &value, QPainter *painter) const; Q_NODISCARD QRect paintArea() const; private: QPointer q_ptr = nullptr; QVariant m_source = {}; - QPixmap m_pixmap = {}; - QIcon m_icon = {}; }; FRAMELESSHELPER_END_NAMESPACE diff --git a/src/quick/quickimageitem.cpp b/src/quick/quickimageitem.cpp index 120d431..61a76fb 100644 --- a/src/quick/quickimageitem.cpp +++ b/src/quick/quickimageitem.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include FRAMELESSHELPER_BEGIN_NAMESPACE @@ -73,7 +75,7 @@ const QuickImageItemPrivate *QuickImageItemPrivate::get(const QuickImageItem *q) return q->d_func(); } -void QuickImageItemPrivate::paint(QPainter *painter) +void QuickImageItemPrivate::paint(QPainter *painter) const { Q_ASSERT(painter); if (!painter) { @@ -137,7 +139,7 @@ void QuickImageItemPrivate::initialize() q->setClip(true); } -void QuickImageItemPrivate::fromUrl(const QUrl &value, QPainter *painter) +void QuickImageItemPrivate::fromUrl(const QUrl &value, QPainter *painter) const { Q_ASSERT(value.isValid()); Q_ASSERT(painter); @@ -147,7 +149,7 @@ void QuickImageItemPrivate::fromUrl(const QUrl &value, QPainter *painter) fromString((value.isLocalFile() ? value.toLocalFile() : value.toString()), painter); } -void QuickImageItemPrivate::fromString(const QString &value, QPainter *painter) +void QuickImageItemPrivate::fromString(const QString &value, QPainter *painter) const { Q_ASSERT(!value.isEmpty()); Q_ASSERT(painter); @@ -155,6 +157,9 @@ void QuickImageItemPrivate::fromString(const QString &value, QPainter *painter) return; } return fromPixmap(QPixmap([&value]() -> QString { + // For most Qt classes, the "qrc:///" prefix won't be recognized as a valid + // file system path, unless it accepts a QUrl object. For QString constructors + // we can only use ":/" to represent the file system path. QString path = value; if (path.startsWith(kQrcPrefix, Qt::CaseInsensitive)) { path.replace(kQrcPrefix, kFileSystemPrefix, Qt::CaseInsensitive); @@ -166,7 +171,7 @@ void QuickImageItemPrivate::fromString(const QString &value, QPainter *painter) }()), painter); } -void QuickImageItemPrivate::fromImage(const QImage &value, QPainter *painter) +void QuickImageItemPrivate::fromImage(const QImage &value, QPainter *painter) const { Q_ASSERT(!value.isNull()); Q_ASSERT(painter); @@ -176,7 +181,7 @@ void QuickImageItemPrivate::fromImage(const QImage &value, QPainter *painter) fromPixmap(QPixmap::fromImage(value), painter); } -void QuickImageItemPrivate::fromPixmap(const QPixmap &value, QPainter *painter) +void QuickImageItemPrivate::fromPixmap(const QPixmap &value, QPainter *painter) const { Q_ASSERT(!value.isNull()); Q_ASSERT(painter); @@ -186,7 +191,7 @@ void QuickImageItemPrivate::fromPixmap(const QPixmap &value, QPainter *painter) painter->drawPixmap(paintArea(), value); } -void QuickImageItemPrivate::fromIcon(const QIcon &value, QPainter *painter) +void QuickImageItemPrivate::fromIcon(const QIcon &value, QPainter *painter) const { Q_ASSERT(!value.isNull()); Q_ASSERT(painter);