添加了ColorHelper
parent
64c4646783
commit
412e2eec5e
|
@ -0,0 +1,49 @@
|
|||
#pragma once
|
||||
#include <lib/qtmaterialstyle.h>
|
||||
#include <lib/qtmaterialtheme.h>
|
||||
#include <QColorDialog>
|
||||
|
||||
class ColorHelper
|
||||
{
|
||||
QtMaterialTheme theme;
|
||||
QColor primary1;
|
||||
public:
|
||||
|
||||
void setPrimary1(const QColor& color)
|
||||
{
|
||||
theme.setColor("primary1", color);
|
||||
primary1 = color;
|
||||
}
|
||||
|
||||
[[nodiscard]] QColor getPrimary1() const
|
||||
{
|
||||
return primary1;
|
||||
}
|
||||
|
||||
ColorHelper()
|
||||
{
|
||||
setPrimary1(QColor::fromRgb(0, 90, 158));
|
||||
QtMaterialStyle::instance().setTheme(&theme);
|
||||
}
|
||||
|
||||
static ColorHelper& instance()
|
||||
{
|
||||
static ColorHelper instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
static QColor execColorDialog(
|
||||
const QColor& initial = instance().getPrimary1(),
|
||||
QWidget* parent = nullptr,
|
||||
const QString& title = ""
|
||||
) {
|
||||
auto dialog = QColorDialog(initial, parent);
|
||||
if (!title.isEmpty())
|
||||
{
|
||||
dialog.setWindowTitle(title);
|
||||
}
|
||||
dialog.adjustSize();
|
||||
dialog.exec();
|
||||
return dialog.selectedColor();
|
||||
}
|
||||
};
|
|
@ -1,4 +1,5 @@
|
|||
#include "MainWindow.h"
|
||||
#include "ColorHelper.hpp"
|
||||
#include <QGuiApplication>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
||||
|
@ -51,9 +52,7 @@ int main(int argc, char* argv[])
|
|||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
QApplication a(argc, argv);
|
||||
Q_INIT_RESOURCE(resources);
|
||||
QtMaterialTheme theme;
|
||||
theme.setColor("primary1", QColor(0, 90, 158));
|
||||
QtMaterialStyle::instance().setTheme(&theme);
|
||||
ColorHelper::instance();
|
||||
//FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
|
||||
//FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
|
|
Loading…
Reference in New Issue