forked from github_mirror/framelesshelper
add synchronize api to wait for the ready signal
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
e2652fc2a9
commit
598de50290
|
@ -136,16 +136,20 @@ void Dialog::setupUi()
|
||||||
// programatically, but we also want the user not able to resize the window manually.
|
// programatically, but we also want the user not able to resize the window manually.
|
||||||
// So apparently we can't use QWidget::setFixedWidth/Height/Size() here.
|
// So apparently we can't use QWidget::setFixedWidth/Height/Size() here.
|
||||||
FramelessWidgetsHelperPrivate::get(helper)->setProperty(kDontOverrideCursorVar, true);
|
FramelessWidgetsHelperPrivate::get(helper)->setProperty(kDontOverrideCursorVar, true);
|
||||||
connect(helper, &FramelessWidgetsHelper::ready, this, [this, helper](){
|
}
|
||||||
const auto savedGeometry = Settings::get<QRect>({}, kGeometry);
|
|
||||||
if (savedGeometry.isValid() && !parent()) {
|
void Dialog::waitReady()
|
||||||
const auto savedDpr = Settings::get<qreal>({}, kDevicePixelRatio);
|
{
|
||||||
// Qt doesn't support dpr < 1.
|
FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this);
|
||||||
const qreal oldDpr = std::max(savedDpr, qreal(1));
|
helper->waitForReady();
|
||||||
const qreal scale = (devicePixelRatioF() / oldDpr);
|
const auto savedGeometry = Settings::get<QRect>({}, kGeometry);
|
||||||
setGeometry({savedGeometry.topLeft() * scale, savedGeometry.size() * scale});
|
if (savedGeometry.isValid() && !parent()) {
|
||||||
} else {
|
const auto savedDpr = Settings::get<qreal>({}, kDevicePixelRatio);
|
||||||
helper->moveWindowToDesktopCenter();
|
// Qt doesn't support dpr < 1.
|
||||||
}
|
const qreal oldDpr = std::max(savedDpr, qreal(1));
|
||||||
});
|
const qreal scale = (devicePixelRatioF() / oldDpr);
|
||||||
|
setGeometry({savedGeometry.topLeft() * scale, savedGeometry.size() * scale});
|
||||||
|
} else {
|
||||||
|
helper->moveWindowToDesktopCenter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ public:
|
||||||
explicit Dialog(QWidget *parent = nullptr);
|
explicit Dialog(QWidget *parent = nullptr);
|
||||||
~Dialog() override;
|
~Dialog() override;
|
||||||
|
|
||||||
|
void waitReady();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ int main(int argc, char *argv[])
|
||||||
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||||
|
|
||||||
const auto dialog = std::make_unique<Dialog>();
|
const auto dialog = std::make_unique<Dialog>();
|
||||||
|
dialog->waitReady();
|
||||||
dialog->show();
|
dialog->show();
|
||||||
|
|
||||||
return QCoreApplication::exec();
|
return QCoreApplication::exec();
|
||||||
|
|
|
@ -54,6 +54,7 @@ int main(int argc, char *argv[])
|
||||||
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||||
|
|
||||||
const auto mainWindow = std::make_unique<MainWindow>();
|
const auto mainWindow = std::make_unique<MainWindow>();
|
||||||
|
mainWindow->waitReady();
|
||||||
mainWindow->show();
|
mainWindow->show();
|
||||||
|
|
||||||
return QCoreApplication::exec();
|
return QCoreApplication::exec();
|
||||||
|
|
|
@ -107,33 +107,39 @@ QMenuBar::item:pressed {
|
||||||
helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close);
|
helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close);
|
||||||
#endif // Q_OS_MACOS
|
#endif // Q_OS_MACOS
|
||||||
helper->setHitTestVisible(mb); // IMPORTANT!
|
helper->setHitTestVisible(mb); // IMPORTANT!
|
||||||
connect(helper, &FramelessWidgetsHelper::ready, this, [this, helper](){
|
|
||||||
const auto savedGeometry = Settings::get<QRect>({}, kGeometry);
|
|
||||||
if (savedGeometry.isValid() && !parent()) {
|
|
||||||
const auto savedDpr = Settings::get<qreal>({}, kDevicePixelRatio);
|
|
||||||
// Qt doesn't support dpr < 1.
|
|
||||||
const qreal oldDpr = std::max(savedDpr, qreal(1));
|
|
||||||
const qreal scale = (devicePixelRatioF() / oldDpr);
|
|
||||||
setGeometry({savedGeometry.topLeft() * scale, savedGeometry.size() * scale});
|
|
||||||
} else {
|
|
||||||
helper->moveWindowToDesktopCenter();
|
|
||||||
}
|
|
||||||
const QByteArray savedState = Settings::get<QByteArray>({}, kState);
|
|
||||||
if (!savedState.isEmpty() && !parent()) {
|
|
||||||
restoreState(savedState);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setWindowTitle(tr("FramelessHelper demo application - Qt MainWindow"));
|
setWindowTitle(tr("FramelessHelper demo application - Qt MainWindow"));
|
||||||
setWindowIcon(QFileIconProvider().icon(QFileIconProvider::Computer));
|
setWindowIcon(QFileIconProvider().icon(QFileIconProvider::Computer));
|
||||||
connect(m_mainWindow->pushButton, &QPushButton::clicked, this, [this]{
|
connect(m_mainWindow->pushButton, &QPushButton::clicked, this, [this]{
|
||||||
const auto dialog = new Dialog(this);
|
const auto dialog = new Dialog(this);
|
||||||
|
dialog->waitReady();
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
});
|
});
|
||||||
connect(m_mainWindow->pushButton_2, &QPushButton::clicked, this, [this]{
|
connect(m_mainWindow->pushButton_2, &QPushButton::clicked, this, [this]{
|
||||||
const auto widget = new Widget(this);
|
const auto widget = new Widget(this);
|
||||||
|
widget->waitReady();
|
||||||
widget->setAttribute(Qt::WA_DeleteOnClose);
|
widget->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
widget->show();
|
widget->show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::waitReady()
|
||||||
|
{
|
||||||
|
FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this);
|
||||||
|
helper->waitForReady();
|
||||||
|
const auto savedGeometry = Settings::get<QRect>({}, kGeometry);
|
||||||
|
if (savedGeometry.isValid() && !parent()) {
|
||||||
|
const auto savedDpr = Settings::get<qreal>({}, kDevicePixelRatio);
|
||||||
|
// Qt doesn't support dpr < 1.
|
||||||
|
const qreal oldDpr = std::max(savedDpr, qreal(1));
|
||||||
|
const qreal scale = (devicePixelRatioF() / oldDpr);
|
||||||
|
setGeometry({savedGeometry.topLeft() * scale, savedGeometry.size() * scale});
|
||||||
|
} else {
|
||||||
|
helper->moveWindowToDesktopCenter();
|
||||||
|
}
|
||||||
|
const QByteArray savedState = Settings::get<QByteArray>({}, kState);
|
||||||
|
if (!savedState.isEmpty() && !parent()) {
|
||||||
|
restoreState(savedState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -44,6 +44,8 @@ public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr, const Qt::WindowFlags flags = {});
|
explicit MainWindow(QWidget *parent = nullptr, const Qt::WindowFlags flags = {});
|
||||||
~MainWindow() override;
|
~MainWindow() override;
|
||||||
|
|
||||||
|
void waitReady();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,7 @@ int main(int argc, char *argv[])
|
||||||
QSurfaceFormat::setDefaultFormat(fmt);
|
QSurfaceFormat::setDefaultFormat(fmt);
|
||||||
|
|
||||||
const auto mainWindow = std::make_unique<MainWindow>();
|
const auto mainWindow = std::make_unique<MainWindow>();
|
||||||
|
mainWindow->waitReady();
|
||||||
mainWindow->show();
|
mainWindow->show();
|
||||||
|
|
||||||
return QCoreApplication::exec();
|
return QCoreApplication::exec();
|
||||||
|
|
|
@ -82,16 +82,20 @@ void MainWindow::initialize()
|
||||||
helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize);
|
helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize);
|
||||||
helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close);
|
helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close);
|
||||||
#endif // Q_OS_MACOS
|
#endif // Q_OS_MACOS
|
||||||
connect(helper, &FramelessWidgetsHelper::ready, this, [this, helper](){
|
}
|
||||||
const auto savedGeometry = Settings::get<QRect>({}, kGeometry);
|
|
||||||
if (savedGeometry.isValid() && !parent()) {
|
void MainWindow::waitReady()
|
||||||
const auto savedDpr = Settings::get<qreal>({}, kDevicePixelRatio);
|
{
|
||||||
// Qt doesn't support dpr < 1.
|
FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this);
|
||||||
const qreal oldDpr = std::max(savedDpr, qreal(1));
|
helper->waitForReady();
|
||||||
const qreal scale = (devicePixelRatioF() / oldDpr);
|
const auto savedGeometry = Settings::get<QRect>({}, kGeometry);
|
||||||
setGeometry({savedGeometry.topLeft() * scale, savedGeometry.size() * scale});
|
if (savedGeometry.isValid() && !parent()) {
|
||||||
} else {
|
const auto savedDpr = Settings::get<qreal>({}, kDevicePixelRatio);
|
||||||
helper->moveWindowToDesktopCenter();
|
// Qt doesn't support dpr < 1.
|
||||||
}
|
const qreal oldDpr = std::max(savedDpr, qreal(1));
|
||||||
});
|
const qreal scale = (devicePixelRatioF() / oldDpr);
|
||||||
|
setGeometry({savedGeometry.topLeft() * scale, savedGeometry.size() * scale});
|
||||||
|
} else {
|
||||||
|
helper->moveWindowToDesktopCenter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow() override;
|
~MainWindow() override;
|
||||||
|
|
||||||
|
void waitReady();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ FramelessApplicationWindow {
|
||||||
visible: false // Hide the window before we sets up it's correct size and position.
|
visible: false // Hide the window before we sets up it's correct size and position.
|
||||||
width: 800
|
width: 800
|
||||||
height: 600
|
height: 600
|
||||||
title: qsTr("FramelessHelper demo application - Qt Quick")
|
title: qsTr("FramelessHelper demo application - Qt Quick [") + objectName + ']'
|
||||||
color: {
|
color: {
|
||||||
if (FramelessHelper.blurBehindWindowEnabled) {
|
if (FramelessHelper.blurBehindWindowEnabled) {
|
||||||
return "transparent";
|
return "transparent";
|
||||||
|
|
|
@ -33,7 +33,7 @@ FramelessWindow {
|
||||||
visible: false // Hide the window before we sets up it's correct size and position.
|
visible: false // Hide the window before we sets up it's correct size and position.
|
||||||
width: 800
|
width: 800
|
||||||
height: 600
|
height: 600
|
||||||
title: qsTr("FramelessHelper demo application - Qt Quick")
|
title: qsTr("FramelessHelper demo application - Qt Quick [") + objectName +']'
|
||||||
color: {
|
color: {
|
||||||
if (FramelessHelper.blurBehindWindowEnabled) {
|
if (FramelessHelper.blurBehindWindowEnabled) {
|
||||||
return "transparent";
|
return "transparent";
|
||||||
|
|
|
@ -55,10 +55,12 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
const auto window1 = std::make_unique<Widget>();
|
const auto window1 = std::make_unique<Widget>();
|
||||||
window1->setObjectName(FRAMELESSHELPER_STRING_LITERAL("window1"));
|
window1->setObjectName(FRAMELESSHELPER_STRING_LITERAL("window1"));
|
||||||
|
window1->waitReady();
|
||||||
window1->show();
|
window1->show();
|
||||||
|
|
||||||
const auto window2 = std::make_unique<Widget>();
|
const auto window2 = std::make_unique<Widget>();
|
||||||
window2->setObjectName(FRAMELESSHELPER_STRING_LITERAL("window2"));
|
window2->setObjectName(FRAMELESSHELPER_STRING_LITERAL("window2"));
|
||||||
|
window2->waitReady();
|
||||||
window2->show();
|
window2->show();
|
||||||
|
|
||||||
return QCoreApplication::exec();
|
return QCoreApplication::exec();
|
||||||
|
|
|
@ -126,6 +126,13 @@ void Widget::initialize()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(this, &Widget::objectNameChanged, this, [this](const QString &name){
|
||||||
|
if (name.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setWindowTitle(windowTitle() + FRAMELESSHELPER_STRING_LITERAL(" [%1]").arg(name));
|
||||||
|
});
|
||||||
|
|
||||||
FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this);
|
FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this);
|
||||||
helper->setTitleBarWidget(m_titleBar);
|
helper->setTitleBarWidget(m_titleBar);
|
||||||
#ifndef Q_OS_MACOS
|
#ifndef Q_OS_MACOS
|
||||||
|
@ -133,19 +140,6 @@ void Widget::initialize()
|
||||||
helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize);
|
helper->setSystemButton(m_titleBar->maximizeButton(), SystemButtonType::Maximize);
|
||||||
helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close);
|
helper->setSystemButton(m_titleBar->closeButton(), SystemButtonType::Close);
|
||||||
#endif // Q_OS_MACOS
|
#endif // Q_OS_MACOS
|
||||||
connect(helper, &FramelessWidgetsHelper::ready, this, [this, helper](){
|
|
||||||
const QString objName = objectName();
|
|
||||||
const auto savedGeometry = Settings::get<QRect>(objName, kGeometry);
|
|
||||||
if (savedGeometry.isValid() && !parent()) {
|
|
||||||
const auto savedDpr = Settings::get<qreal>(objName, kDevicePixelRatio);
|
|
||||||
// Qt doesn't support dpr < 1.
|
|
||||||
const qreal oldDpr = std::max(savedDpr, qreal(1));
|
|
||||||
const qreal scale = (devicePixelRatioF() / oldDpr);
|
|
||||||
setGeometry({savedGeometry.topLeft() * scale, savedGeometry.size() * scale});
|
|
||||||
} else {
|
|
||||||
helper->moveWindowToDesktopCenter();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::updateStyleSheet()
|
void Widget::updateStyleSheet()
|
||||||
|
@ -162,3 +156,20 @@ void Widget::updateStyleSheet()
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::waitReady()
|
||||||
|
{
|
||||||
|
FramelessWidgetsHelper *helper = FramelessWidgetsHelper::get(this);
|
||||||
|
helper->waitForReady();
|
||||||
|
const QString objName = objectName();
|
||||||
|
const auto savedGeometry = Settings::get<QRect>(objName, kGeometry);
|
||||||
|
if (savedGeometry.isValid() && !parent()) {
|
||||||
|
const auto savedDpr = Settings::get<qreal>(objName, kDevicePixelRatio);
|
||||||
|
// Qt doesn't support dpr < 1.
|
||||||
|
const qreal oldDpr = std::max(savedDpr, qreal(1));
|
||||||
|
const qreal scale = (devicePixelRatioF() / oldDpr);
|
||||||
|
setGeometry({savedGeometry.topLeft() * scale, savedGeometry.size() * scale});
|
||||||
|
} else {
|
||||||
|
helper->moveWindowToDesktopCenter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -44,6 +44,8 @@ public:
|
||||||
explicit Widget(QWidget *parent = nullptr);
|
explicit Widget(QWidget *parent = nullptr);
|
||||||
~Widget() override;
|
~Widget() override;
|
||||||
|
|
||||||
|
void waitReady();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void timerEvent(QTimerEvent *event) override;
|
void timerEvent(QTimerEvent *event) override;
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
|
@ -66,6 +66,9 @@ public:
|
||||||
Q_NODISCARD QuickMicaMaterial *micaMaterial() const;
|
Q_NODISCARD QuickMicaMaterial *micaMaterial() const;
|
||||||
Q_NODISCARD QuickWindowBorder *windowBorder() const;
|
Q_NODISCARD QuickWindowBorder *windowBorder() const;
|
||||||
|
|
||||||
|
Q_NODISCARD bool isReady() const;
|
||||||
|
void waitForReady();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void extendsContentIntoTitleBar(const bool value = true);
|
void extendsContentIntoTitleBar(const bool value = true);
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,9 @@ public:
|
||||||
|
|
||||||
Q_NODISCARD static FramelessQuickHelper *findOrCreateFramelessHelper(QObject *object);
|
Q_NODISCARD static FramelessQuickHelper *findOrCreateFramelessHelper(QObject *object);
|
||||||
|
|
||||||
|
Q_NODISCARD bool isReady() const;
|
||||||
|
void waitForReady();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_NODISCARD QRect mapItemGeometryToScene(const QQuickItem * const item) const;
|
Q_NODISCARD QRect mapItemGeometryToScene(const QQuickItem * const item) const;
|
||||||
Q_NODISCARD bool isInSystemButtons(const QPoint &pos, QuickGlobal::SystemButtonType *button) const;
|
Q_NODISCARD bool isInSystemButtons(const QPoint &pos, QuickGlobal::SystemButtonType *button) const;
|
||||||
|
@ -101,6 +104,7 @@ private:
|
||||||
bool m_blurBehindWindowEnabled = false;
|
bool m_blurBehindWindowEnabled = false;
|
||||||
std::optional<bool> m_extendIntoTitleBar = std::nullopt;
|
std::optional<bool> m_extendIntoTitleBar = std::nullopt;
|
||||||
bool m_destroying = false;
|
bool m_destroying = false;
|
||||||
|
bool m_qpaReady = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -59,6 +59,9 @@ public:
|
||||||
Q_NODISCARD MicaMaterial *micaMaterial() const;
|
Q_NODISCARD MicaMaterial *micaMaterial() const;
|
||||||
Q_NODISCARD WindowBorderPainter *windowBorder() const;
|
Q_NODISCARD WindowBorderPainter *windowBorder() const;
|
||||||
|
|
||||||
|
Q_NODISCARD bool isReady() const;
|
||||||
|
void waitForReady();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void extendsContentIntoTitleBar(const bool value = true);
|
void extendsContentIntoTitleBar(const bool value = true);
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,9 @@ public:
|
||||||
Q_NODISCARD static WidgetsSharedHelper *findOrCreateSharedHelper(QWidget *window);
|
Q_NODISCARD static WidgetsSharedHelper *findOrCreateSharedHelper(QWidget *window);
|
||||||
Q_NODISCARD static FramelessWidgetsHelper *findOrCreateFramelessHelper(QObject *object);
|
Q_NODISCARD static FramelessWidgetsHelper *findOrCreateFramelessHelper(QObject *object);
|
||||||
|
|
||||||
|
Q_NODISCARD bool isReady() const;
|
||||||
|
void waitForReady();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_NODISCARD QRect mapWidgetGeometryToScene(const QWidget * const widget) const;
|
Q_NODISCARD QRect mapWidgetGeometryToScene(const QWidget * const widget) const;
|
||||||
Q_NODISCARD bool isInSystemButtons(const QPoint &pos, Global::SystemButtonType *button) const;
|
Q_NODISCARD bool isInSystemButtons(const QPoint &pos, Global::SystemButtonType *button) const;
|
||||||
|
@ -102,6 +105,7 @@ private:
|
||||||
bool m_blurBehindWindowEnabled = false;
|
bool m_blurBehindWindowEnabled = false;
|
||||||
QPointer<QWidget> m_window = nullptr;
|
QPointer<QWidget> m_window = nullptr;
|
||||||
bool m_destroying = false;
|
bool m_destroying = false;
|
||||||
|
bool m_qpaReady = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#endif // Q_OS_WINDOWS
|
#endif // Q_OS_WINDOWS
|
||||||
#include <QtCore/qmutex.h>
|
#include <QtCore/qmutex.h>
|
||||||
#include <QtCore/qtimer.h>
|
#include <QtCore/qtimer.h>
|
||||||
|
#include <QtCore/qeventloop.h>
|
||||||
#include <QtCore/qloggingcategory.h>
|
#include <QtCore/qloggingcategory.h>
|
||||||
#ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE
|
#ifndef FRAMELESSHELPER_QUICK_NO_PRIVATE
|
||||||
# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
@ -237,6 +238,7 @@ void FramelessQuickHelperPrivate::attach()
|
||||||
// due to QPA will reset the position and size of the window during it's
|
// due to QPA will reset the position and size of the window during it's
|
||||||
// initialization process.
|
// initialization process.
|
||||||
QTimer::singleShot(0, this, [this](){
|
QTimer::singleShot(0, this, [this](){
|
||||||
|
m_qpaReady = true;
|
||||||
if (FramelessConfig::instance()->isSet(Option::CenterWindowBeforeShow)) {
|
if (FramelessConfig::instance()->isSet(Option::CenterWindowBeforeShow)) {
|
||||||
moveWindowToDesktopCenter();
|
moveWindowToDesktopCenter();
|
||||||
}
|
}
|
||||||
|
@ -660,6 +662,30 @@ FramelessQuickHelper *FramelessQuickHelperPrivate::findOrCreateFramelessHelper(Q
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FramelessQuickHelperPrivate::isReady() const
|
||||||
|
{
|
||||||
|
return m_qpaReady;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FramelessQuickHelperPrivate::waitForReady()
|
||||||
|
{
|
||||||
|
if (m_qpaReady) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if 1
|
||||||
|
QEventLoop loop;
|
||||||
|
Q_Q(FramelessQuickHelper);
|
||||||
|
const QMetaObject::Connection connection = connect(
|
||||||
|
q, &FramelessQuickHelper::ready, &loop, &QEventLoop::quit);
|
||||||
|
loop.exec();
|
||||||
|
disconnect(connection);
|
||||||
|
#else
|
||||||
|
while (!m_qpaReady) {
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
QRect FramelessQuickHelperPrivate::mapItemGeometryToScene(const QQuickItem * const item) const
|
QRect FramelessQuickHelperPrivate::mapItemGeometryToScene(const QQuickItem * const item) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(item);
|
Q_ASSERT(item);
|
||||||
|
@ -993,6 +1019,18 @@ QuickWindowBorder *FramelessQuickHelper::windowBorder() const
|
||||||
return d->findOrCreateWindowBorder();
|
return d->findOrCreateWindowBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FramelessQuickHelper::isReady() const
|
||||||
|
{
|
||||||
|
Q_D(const FramelessQuickHelper);
|
||||||
|
return d->isReady();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FramelessQuickHelper::waitForReady()
|
||||||
|
{
|
||||||
|
Q_D(FramelessQuickHelper);
|
||||||
|
d->waitForReady();
|
||||||
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::extendsContentIntoTitleBar(const bool value)
|
void FramelessQuickHelper::extendsContentIntoTitleBar(const bool value)
|
||||||
{
|
{
|
||||||
Q_D(FramelessQuickHelper);
|
Q_D(FramelessQuickHelper);
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <QtCore/qmutex.h>
|
#include <QtCore/qmutex.h>
|
||||||
#include <QtCore/qhash.h>
|
#include <QtCore/qhash.h>
|
||||||
#include <QtCore/qtimer.h>
|
#include <QtCore/qtimer.h>
|
||||||
|
#include <QtCore/qeventloop.h>
|
||||||
#include <QtCore/qloggingcategory.h>
|
#include <QtCore/qloggingcategory.h>
|
||||||
#include <QtGui/qwindow.h>
|
#include <QtGui/qwindow.h>
|
||||||
#include <QtGui/qpalette.h>
|
#include <QtGui/qpalette.h>
|
||||||
|
@ -320,6 +321,30 @@ FramelessWidgetsHelper *FramelessWidgetsHelperPrivate::findOrCreateFramelessHelp
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FramelessWidgetsHelperPrivate::isReady() const
|
||||||
|
{
|
||||||
|
return m_qpaReady;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FramelessWidgetsHelperPrivate::waitForReady()
|
||||||
|
{
|
||||||
|
if (m_qpaReady) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if 1
|
||||||
|
QEventLoop loop;
|
||||||
|
Q_Q(FramelessWidgetsHelper);
|
||||||
|
const QMetaObject::Connection connection = connect(
|
||||||
|
q, &FramelessWidgetsHelper::ready, &loop, &QEventLoop::quit);
|
||||||
|
loop.exec();
|
||||||
|
disconnect(connection);
|
||||||
|
#else
|
||||||
|
while (!m_qpaReady) {
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool FramelessWidgetsHelperPrivate::isContentExtendedIntoTitleBar() const
|
bool FramelessWidgetsHelperPrivate::isContentExtendedIntoTitleBar() const
|
||||||
{
|
{
|
||||||
return getWindowData().ready;
|
return getWindowData().ready;
|
||||||
|
@ -476,6 +501,7 @@ void FramelessWidgetsHelperPrivate::attach()
|
||||||
// due to QPA will reset the position and size of the window during it's
|
// due to QPA will reset the position and size of the window during it's
|
||||||
// initialization process.
|
// initialization process.
|
||||||
QTimer::singleShot(0, this, [this](){
|
QTimer::singleShot(0, this, [this](){
|
||||||
|
m_qpaReady = true;
|
||||||
if (FramelessConfig::instance()->isSet(Option::CenterWindowBeforeShow)) {
|
if (FramelessConfig::instance()->isSet(Option::CenterWindowBeforeShow)) {
|
||||||
moveWindowToDesktopCenter();
|
moveWindowToDesktopCenter();
|
||||||
}
|
}
|
||||||
|
@ -916,6 +942,18 @@ WindowBorderPainter *FramelessWidgetsHelper::windowBorder() const
|
||||||
return d->getWindowBorderIfAny();
|
return d->getWindowBorderIfAny();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FramelessWidgetsHelper::isReady() const
|
||||||
|
{
|
||||||
|
Q_D(const FramelessWidgetsHelper);
|
||||||
|
return d->isReady();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FramelessWidgetsHelper::waitForReady()
|
||||||
|
{
|
||||||
|
Q_D(FramelessWidgetsHelper);
|
||||||
|
d->waitForReady();
|
||||||
|
}
|
||||||
|
|
||||||
void FramelessWidgetsHelper::extendsContentIntoTitleBar(const bool value)
|
void FramelessWidgetsHelper::extendsContentIntoTitleBar(const bool value)
|
||||||
{
|
{
|
||||||
Q_D(FramelessWidgetsHelper);
|
Q_D(FramelessWidgetsHelper);
|
||||||
|
|
Loading…
Reference in New Issue