Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
minor fixes of the last commit
Browse files Browse the repository at this point in the history
Signed-off-by: Yuhang Zhao <[email protected]>
  • Loading branch information
wangwenx190 committed Aug 31, 2022
1 parent 463ac0a commit abf4b29
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions examples/mainwindow/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@

#include <QtWidgets/qapplication.h>
#include <framelessconfig_p.h>
#include <clocale>
#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();
Expand Down
3 changes: 3 additions & 0 deletions examples/openglwidget/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include <QSurfaceFormat>
#include <QOpenGLContext>
#include <framelessconfig_p.h>
#include <clocale>
#include "mainwindow.h"

// This example demonstrates easy, cross-platform usage of OpenGL ES 3.0 functions via
Expand All @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions examples/quick/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <QtQuickControls2/qquickstyle.h>
#include <framelessquickmodule.h>
#include <framelessconfig_p.h>
#include <clocale>
#include "settings.h"
#if QMLTC_ENABLED
# include <mainwindow.h>
Expand All @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions examples/widget/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@

#include <QtWidgets/qapplication.h>
#include <framelessconfig_p.h>
#include <clocale>
#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();
Expand Down
16 changes: 6 additions & 10 deletions include/FramelessHelper/Quick/private/quickimageitem_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>
#include <QtCore/qvariant.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qicon.h>

FRAMELESSHELPER_BEGIN_NAMESPACE

Expand All @@ -48,25 +46,23 @@ class FRAMELESSHELPER_QUICK_API QuickImageItemPrivate : public QObject
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<QuickImageItem> q_ptr = nullptr;
QVariant m_source = {};
QPixmap m_pixmap = {};
QIcon m_icon = {};
};

FRAMELESSHELPER_END_NAMESPACE
Expand Down
17 changes: 11 additions & 6 deletions src/quick/quickimageitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <QtCore/qdebug.h>
#include <QtGui/qpainter.h>
#include <QtGui/qimage.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qicon.h>

FRAMELESSHELPER_BEGIN_NAMESPACE

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -147,14 +149,17 @@ 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);
if (value.isEmpty() || !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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit abf4b29

Please sign in to comment.