forked from github_mirror/framelesshelper
little simplify
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
4af48d84b9
commit
90ad8d281a
|
@ -8,6 +8,8 @@ project(FramelessHelper
|
|||
)
|
||||
|
||||
option(FRAMELESSHELPER_BUILD_STATIC "Build FramelessHelper as a static library." OFF)
|
||||
option(FRAMELESSHELPER_BUILD_WIDGETS "Build FramelessHelper's Widgets module." ON)
|
||||
option(FRAMELESSHELPER_BUILD_QUICK "Build FramelessHelper's Quick module." ON)
|
||||
option(FRAMELESSHELPER_BUILD_EXAMPLES "Build FramelessHelper demo applications." ON)
|
||||
|
||||
if(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
if(TARGET Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
if(FRAMELESSHELPER_BUILD_WIDGETS AND TARGET Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
add_subdirectory(widget)
|
||||
add_subdirectory(mainwindow)
|
||||
endif()
|
||||
|
||||
if(TARGET Qt${QT_VERSION_MAJOR}::Quick)
|
||||
if(FRAMELESSHELPER_BUILD_QUICK AND TARGET Qt${QT_VERSION_MAJOR}::Quick)
|
||||
add_subdirectory(quick)
|
||||
endif()
|
||||
|
|
|
@ -23,16 +23,13 @@
|
|||
*/
|
||||
|
||||
#include <QtWidgets/qapplication.h>
|
||||
#include <Utils>
|
||||
#include "mainwindow.h"
|
||||
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
Utils::tryToEnableHighestDpiAwarenessLevel();
|
||||
#endif
|
||||
FramelessHelper::Core::initialize();
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
@ -42,8 +39,6 @@ int main(int argc, char *argv[])
|
|||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
|
||||
#endif
|
||||
|
||||
FramelessHelperEarlyInitialize();
|
||||
|
||||
QApplication application(argc, argv);
|
||||
|
||||
MainWindow mainWindow;
|
||||
|
|
|
@ -27,15 +27,12 @@
|
|||
#include <QtQuick/qquickwindow.h>
|
||||
#include <QtQuickControls2/qquickstyle.h>
|
||||
#include <FramelessHelper_Quick>
|
||||
#include <Utils>
|
||||
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
Utils::tryToEnableHighestDpiAwarenessLevel();
|
||||
#endif
|
||||
FramelessHelper::Core::initialize();
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
@ -45,8 +42,6 @@ int main(int argc, char *argv[])
|
|||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
|
||||
#endif
|
||||
|
||||
FramelessHelperEarlyInitialize();
|
||||
|
||||
QGuiApplication application(argc, argv);
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
|
|
@ -23,16 +23,13 @@
|
|||
*/
|
||||
|
||||
#include <QtWidgets/qapplication.h>
|
||||
#include <Utils>
|
||||
#include "widget.h"
|
||||
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
Utils::tryToEnableHighestDpiAwarenessLevel();
|
||||
#endif
|
||||
FramelessHelper::Core::initialize();
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
@ -42,8 +39,6 @@ int main(int argc, char *argv[])
|
|||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
|
||||
#endif
|
||||
|
||||
FramelessHelperEarlyInitialize();
|
||||
|
||||
QApplication application(argc, argv);
|
||||
|
||||
Widget widget;
|
||||
|
|
|
@ -116,7 +116,10 @@ using NATIVE_EVENT_RESULT_TYPE = long;
|
|||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
FRAMELESSHELPER_CORE_API void FramelessHelperEarlyInitialize();
|
||||
namespace FramelessHelper::Core
|
||||
{
|
||||
FRAMELESSHELPER_CORE_API void initialize();
|
||||
}
|
||||
|
||||
namespace Global
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
add_subdirectory(core)
|
||||
|
||||
if(TARGET Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
if(FRAMELESSHELPER_BUILD_WIDGETS AND TARGET Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
add_subdirectory(widgets)
|
||||
endif()
|
||||
|
||||
if(TARGET Qt${QT_VERSION_MAJOR}::Quick)
|
||||
if(FRAMELESSHELPER_BUILD_QUICK AND TARGET Qt${QT_VERSION_MAJOR}::Quick)
|
||||
add_subdirectory(quick)
|
||||
endif()
|
||||
|
|
|
@ -131,16 +131,17 @@ void FramelessWindowsManager::addWindow(const UserSettings &settings, const Syst
|
|||
#endif
|
||||
}
|
||||
|
||||
void FramelessHelperEarlyInitialize()
|
||||
void FramelessHelper::Core::initialize()
|
||||
{
|
||||
static bool inited = false;
|
||||
if (inited) {
|
||||
return;
|
||||
}
|
||||
inited = true;
|
||||
if (!QCoreApplication::testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) {
|
||||
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||
}
|
||||
#ifdef Q_OS_WINDOWS
|
||||
Utils::tryToEnableHighestDpiAwarenessLevel();
|
||||
#endif
|
||||
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||
qRegisterMetaType<UserSettings>();
|
||||
qRegisterMetaType<SystemParameters>();
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ void FramelessWidgetsHelper::paintEventHandler(QPaintEvent *event)
|
|||
pen.setColor(Utils::getFrameBorderColor(q->isActiveWindow()));
|
||||
pen.setWidth(1);
|
||||
painter.setPen(pen);
|
||||
painter.drawLine(0, 0, q->width()-1, 0);
|
||||
painter.drawLine(0, 0, (q->width() - 1), 0);
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue