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