demo: update
This commit is contained in:
parent
ad595c59e4
commit
c8511bacf6
|
@ -41,7 +41,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// Not necessary, but better call this function, before the construction
|
// Not necessary, but better call this function, before the construction
|
||||||
// of any Q(Core|Gui)Application instances.
|
// of any Q(Core|Gui)Application instances.
|
||||||
FramelessHelper::Widgets::initialize();
|
FramelessHelperWidgetsInitialize();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) {
|
if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) {
|
||||||
|
@ -54,7 +54,7 @@ int main(int argc, char *argv[])
|
||||||
// Must be called after QGuiApplication has been constructed, we are using
|
// Must be called after QGuiApplication has been constructed, we are using
|
||||||
// some private functions from QPA which won't be available until there's
|
// some private functions from QPA which won't be available until there's
|
||||||
// a QGuiApplication instance.
|
// a QGuiApplication instance.
|
||||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
FramelessHelperEnableThemeAware();
|
||||||
|
|
||||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||||
//FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
//FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||||
|
|
|
@ -41,7 +41,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// Not necessary, but better call this function, before the construction
|
// Not necessary, but better call this function, before the construction
|
||||||
// of any Q(Core|Gui)Application instances.
|
// of any Q(Core|Gui)Application instances.
|
||||||
FramelessHelper::Widgets::initialize();
|
FramelessHelperWidgetsInitialize();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) {
|
if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) {
|
||||||
|
@ -54,7 +54,7 @@ int main(int argc, char *argv[])
|
||||||
// Must be called after QGuiApplication has been constructed, we are using
|
// Must be called after QGuiApplication has been constructed, we are using
|
||||||
// some private functions from QPA which won't be available until there's
|
// some private functions from QPA which won't be available until there's
|
||||||
// a QGuiApplication instance.
|
// a QGuiApplication instance.
|
||||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
FramelessHelperEnableThemeAware();
|
||||||
|
|
||||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||||
//FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
//FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||||
|
|
|
@ -56,14 +56,14 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// Not necessary, but better call this function, before the construction
|
// Not necessary, but better call this function, before the construction
|
||||||
// of any Q(Core|Gui)Application instances.
|
// of any Q(Core|Gui)Application instances.
|
||||||
FramelessHelper::Quick::initialize();
|
FramelessHelperQuickInitialize();
|
||||||
|
|
||||||
const auto application = std::make_unique<QGuiApplication>(argc, argv);
|
const auto application = std::make_unique<QGuiApplication>(argc, argv);
|
||||||
|
|
||||||
// Must be called after QGuiApplication has been constructed, we are using
|
// Must be called after QGuiApplication has been constructed, we are using
|
||||||
// some private functions from QPA which won't be available until there's
|
// some private functions from QPA which won't be available until there's
|
||||||
// a QGuiApplication instance.
|
// a QGuiApplication instance.
|
||||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
FramelessHelperEnableThemeAware();
|
||||||
|
|
||||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||||
//FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
//FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||||
|
@ -116,7 +116,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
#if (((QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) || defined(QUICK_USE_QMAKE)) && !QMLTC_ENABLED)
|
#if (((QT_VERSION < QT_VERSION_CHECK(6, 2, 0)) || defined(QUICK_USE_QMAKE)) && !QMLTC_ENABLED)
|
||||||
// Don't forget to register our own custom QML types!
|
// Don't forget to register our own custom QML types!
|
||||||
FramelessHelper::Quick::registerTypes(engine.get());
|
FramelessHelperQuickRegisterTypes(engine.get());
|
||||||
|
|
||||||
qmlRegisterSingletonType<QuickSettings>("Demo", 1, 0, "Settings",
|
qmlRegisterSingletonType<QuickSettings>("Demo", 1, 0, "Settings",
|
||||||
[](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
|
[](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
|
||||||
|
|
|
@ -41,7 +41,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// Not necessary, but better call this function, before the construction
|
// Not necessary, but better call this function, before the construction
|
||||||
// of any Q(Core|Gui)Application instances.
|
// of any Q(Core|Gui)Application instances.
|
||||||
FramelessHelper::Widgets::initialize();
|
FramelessHelperWidgetsInitialize();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) {
|
if (!qEnvironmentVariableIsSet("QT_WIDGETS_RHI")) {
|
||||||
|
@ -54,7 +54,7 @@ int main(int argc, char *argv[])
|
||||||
// Must be called after QGuiApplication has been constructed, we are using
|
// Must be called after QGuiApplication has been constructed, we are using
|
||||||
// some private functions from QPA which won't be available until there's
|
// some private functions from QPA which won't be available until there's
|
||||||
// a QGuiApplication instance.
|
// a QGuiApplication instance.
|
||||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
FramelessHelperEnableThemeAware();
|
||||||
|
|
||||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||||
//FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
//FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include <QtCore/qdatetime.h>
|
#include <QtCore/qdatetime.h>
|
||||||
|
#include <QtCore/qcoreevent.h>
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
# include <QtGui/qshortcut.h>
|
# include <QtGui/qshortcut.h>
|
||||||
#else
|
#else
|
||||||
|
@ -54,7 +55,7 @@ FRAMELESSHELPER_STRING_CONSTANT(DevicePixelRatio)
|
||||||
Widget::Widget(QWidget *parent) : FramelessWidget(parent)
|
Widget::Widget(QWidget *parent) : FramelessWidget(parent)
|
||||||
{
|
{
|
||||||
initialize();
|
initialize();
|
||||||
startTimer(100);
|
m_timerId = startTimer(100);
|
||||||
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &Widget::updateStyleSheet);
|
connect(FramelessManager::instance(), &FramelessManager::systemThemeChanged, this, &Widget::updateStyleSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ Widget::~Widget() = default;
|
||||||
void Widget::timerEvent(QTimerEvent *event)
|
void Widget::timerEvent(QTimerEvent *event)
|
||||||
{
|
{
|
||||||
FramelessWidget::timerEvent(event);
|
FramelessWidget::timerEvent(event);
|
||||||
if (m_clockLabel) {
|
if ((event->timerId() == m_timerId) && m_clockLabel) {
|
||||||
m_clockLabel->setText(QTime::currentTime().toString(FRAMELESSHELPER_STRING_LITERAL("hh:mm:ss")));
|
m_clockLabel->setText(QTime::currentTime().toString(FRAMELESSHELPER_STRING_LITERAL("hh:mm:ss")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,23 +90,55 @@ void Widget::initialize()
|
||||||
#endif
|
#endif
|
||||||
m_clockLabel = new QLabel(this);
|
m_clockLabel = new QLabel(this);
|
||||||
m_clockLabel->setFrameShape(QFrame::NoFrame);
|
m_clockLabel->setFrameShape(QFrame::NoFrame);
|
||||||
|
m_clockLabel->setAlignment(Qt::AlignCenter);
|
||||||
QFont clockFont = font();
|
QFont clockFont = font();
|
||||||
clockFont.setBold(true);
|
clockFont.setBold(true);
|
||||||
clockFont.setPointSize(70);
|
clockFont.setPointSize(70);
|
||||||
m_clockLabel->setFont(clockFont);
|
m_clockLabel->setFont(clockFont);
|
||||||
const auto contentLayout = new QHBoxLayout;
|
m_compilerInfoLabel = new QLabel(this);
|
||||||
contentLayout->setContentsMargins(0, 0, 0, 0);
|
m_compilerInfoLabel->setFrameShape(QFrame::NoFrame);
|
||||||
contentLayout->setSpacing(0);
|
m_compilerInfoLabel->setAlignment(Qt::AlignCenter);
|
||||||
contentLayout->addStretch();
|
static const VersionInfo versionInfo = FramelessHelperVersion();
|
||||||
contentLayout->addWidget(m_clockLabel);
|
m_compilerInfoLabel->setText(
|
||||||
contentLayout->addStretch();
|
FRAMELESSHELPER_STRING_LITERAL("Compiler: %1 %2")
|
||||||
|
.arg(QString::fromUtf8(versionInfo.compiler.name),
|
||||||
|
QString::fromUtf8(versionInfo.compiler.version)));
|
||||||
|
m_commitInfoLabel = new QLabel(this);
|
||||||
|
m_commitInfoLabel->setFrameShape(QFrame::NoFrame);
|
||||||
|
m_commitInfoLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
m_commitInfoLabel->setText(
|
||||||
|
FRAMELESSHELPER_STRING_LITERAL("Commit: %1 (%2)")
|
||||||
|
.arg(QString::fromUtf8(versionInfo.commit.hash),
|
||||||
|
QString::fromUtf8(versionInfo.commit.author)));
|
||||||
|
const auto clockLabelLayout = new QHBoxLayout;
|
||||||
|
clockLabelLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
clockLabelLayout->setSpacing(0);
|
||||||
|
clockLabelLayout->addStretch();
|
||||||
|
clockLabelLayout->addWidget(m_clockLabel);
|
||||||
|
clockLabelLayout->addStretch();
|
||||||
|
const auto compilerInfoLabelLayout = new QHBoxLayout;
|
||||||
|
compilerInfoLabelLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
compilerInfoLabelLayout->setSpacing(0);
|
||||||
|
compilerInfoLabelLayout->addStretch();
|
||||||
|
compilerInfoLabelLayout->addWidget(m_compilerInfoLabel);
|
||||||
|
compilerInfoLabelLayout->addStretch();
|
||||||
|
const auto commitInfoLabelLayout = new QHBoxLayout;
|
||||||
|
commitInfoLabelLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
commitInfoLabelLayout->setSpacing(0);
|
||||||
|
commitInfoLabelLayout->addStretch();
|
||||||
|
commitInfoLabelLayout->addWidget(m_commitInfoLabel);
|
||||||
|
commitInfoLabelLayout->addStretch();
|
||||||
const auto mainLayout = new QVBoxLayout(this);
|
const auto mainLayout = new QVBoxLayout(this);
|
||||||
mainLayout->setSpacing(0);
|
mainLayout->setSpacing(0);
|
||||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
#if FRAMELESSHELPER_CONFIG(titlebar)
|
#if FRAMELESSHELPER_CONFIG(titlebar)
|
||||||
mainLayout->addWidget(m_titleBar);
|
mainLayout->addWidget(m_titleBar);
|
||||||
#endif
|
#endif
|
||||||
mainLayout->addLayout(contentLayout);
|
mainLayout->addStretch();
|
||||||
|
mainLayout->addLayout(clockLabelLayout);
|
||||||
|
mainLayout->addStretch();
|
||||||
|
mainLayout->addLayout(compilerInfoLabelLayout);
|
||||||
|
mainLayout->addLayout(commitInfoLabelLayout);
|
||||||
updateStyleSheet();
|
updateStyleSheet();
|
||||||
|
|
||||||
m_cancelShortcut = new QShortcut(this);
|
m_cancelShortcut = new QShortcut(this);
|
||||||
|
@ -149,9 +182,11 @@ void Widget::initialize()
|
||||||
void Widget::updateStyleSheet()
|
void Widget::updateStyleSheet()
|
||||||
{
|
{
|
||||||
const bool dark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark);
|
const bool dark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark);
|
||||||
const QColor clockLabelTextColor = (dark ? kDefaultWhiteColor : kDefaultBlackColor);
|
const QColor labelTextColor = (dark ? kDefaultWhiteColor : kDefaultBlackColor);
|
||||||
m_clockLabel->setStyleSheet(FRAMELESSHELPER_STRING_LITERAL("background-color: transparent; color: %1;")
|
const QString labelStyleSheet = FRAMELESSHELPER_STRING_LITERAL("background-color: transparent; color: %1;").arg(labelTextColor.name());
|
||||||
.arg(clockLabelTextColor.name()));
|
m_clockLabel->setStyleSheet(labelStyleSheet);
|
||||||
|
m_compilerInfoLabel->setStyleSheet(labelStyleSheet);
|
||||||
|
m_commitInfoLabel->setStyleSheet(labelStyleSheet);
|
||||||
if (FramelessWidgetsHelper::get(this)->isBlurBehindWindowEnabled()) {
|
if (FramelessWidgetsHelper::get(this)->isBlurBehindWindowEnabled()) {
|
||||||
setStyleSheet(FRAMELESSHELPER_STRING_LITERAL("background-color: transparent;"));
|
setStyleSheet(FRAMELESSHELPER_STRING_LITERAL("background-color: transparent;"));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -65,6 +65,9 @@ private:
|
||||||
FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *m_titleBar = nullptr;
|
FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar) *m_titleBar = nullptr;
|
||||||
#endif
|
#endif
|
||||||
QLabel *m_clockLabel = nullptr;
|
QLabel *m_clockLabel = nullptr;
|
||||||
|
QLabel *m_compilerInfoLabel = nullptr;
|
||||||
|
QLabel *m_commitInfoLabel = nullptr;
|
||||||
QShortcut *m_fullScreenShortcut = nullptr;
|
QShortcut *m_fullScreenShortcut = nullptr;
|
||||||
QShortcut *m_cancelShortcut = nullptr;
|
QShortcut *m_cancelShortcut = nullptr;
|
||||||
|
int m_timerId = -1;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue