This repository has been archived on 2020-09-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
libs/qad/styles/DarkStyle.cpp
Бычков Андрей d4c2c077b1 add qad styles
git-svn-id: svn://db.shs.com.ru/libs@547 a8b55f48-bf90-11e4-a774-851b48703e85
2019-06-17 11:01:11 +00:00

74 lines
3.2 KiB
C++

/*
###############################################################################
# #
# The MIT License #
# #
# Copyright (C) 2017 by Juergen Skrotzky (JorgenVikingGod@gmail.com) #
# >> https://github.com/Jorgen-VikingGod #
# #
# Sources: https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle #
# #
###############################################################################
*/
#include "DarkStyle.h"
DarkStyle::DarkStyle() : DarkStyle(styleBase()) {}
DarkStyle::DarkStyle(QStyle *style) : QProxyStyle(style) {}
QStyle *DarkStyle::styleBase(QStyle *style) const {
static QStyle *base =
!style ? QStyleFactory::create(QStringLiteral("Fusion")) : style;
return base;
}
QStyle *DarkStyle::baseStyle() const { return styleBase(); }
void DarkStyle::polish(QPalette &palette) {
// modify palette to dark
palette.setColor(QPalette::Window, QColor(53, 53, 53));
palette.setColor(QPalette::WindowText, Qt::white);
palette.setColor(QPalette::Disabled, QPalette::WindowText,
QColor(127, 127, 127));
palette.setColor(QPalette::Base, QColor(42, 42, 42));
palette.setColor(QPalette::AlternateBase, QColor(66, 66, 66));
palette.setColor(QPalette::ToolTipBase, Qt::white);
palette.setColor(QPalette::ToolTipText, QColor(53, 53, 53));
palette.setColor(QPalette::Text, Qt::white);
palette.setColor(QPalette::Disabled, QPalette::Text, QColor(127, 127, 127));
palette.setColor(QPalette::Dark, QColor(35, 35, 35));
palette.setColor(QPalette::Shadow, QColor(20, 20, 20));
palette.setColor(QPalette::Button, QColor(53, 53, 53));
palette.setColor(QPalette::ButtonText, Qt::white);
palette.setColor(QPalette::Disabled, QPalette::ButtonText,
QColor(127, 127, 127));
palette.setColor(QPalette::BrightText, Qt::red);
palette.setColor(QPalette::Link, QColor(42, 130, 218));
palette.setColor(QPalette::Highlight, QColor(42, 130, 218));
palette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(80, 80, 80));
palette.setColor(QPalette::HighlightedText, Qt::white);
palette.setColor(QPalette::Disabled, QPalette::HighlightedText,
QColor(127, 127, 127));
}
void DarkStyle::polish(QApplication *app) {
if (!app) return;
// increase font size for better reading,
// setPointSize was reduced from +2 because when applied this way in Qt5, the
// font is larger than intended for some reason
QFont defaultFont = QApplication::font();
defaultFont.setPointSize(defaultFont.pointSize() + 1);
app->setFont(defaultFont);
// loadstylesheet
QFile qfDarkstyle(QStringLiteral(":/darkstyle/darkstyle.qss"));
if (qfDarkstyle.open(QIODevice::ReadOnly | QIODevice::Text)) {
// set stylesheet
QString qsStylesheet = QString::fromLatin1(qfDarkstyle.readAll());
app->setStyleSheet(qsStylesheet);
qfDarkstyle.close();
}
}