diff --git a/installer/packages/trik-studio/ru.qreal.root.trik_studio_kernel/meta/prebuild-common.sh b/installer/packages/trik-studio/ru.qreal.root.trik_studio_kernel/meta/prebuild-common.sh index 8492c7e4b6..9f276ed171 100755 --- a/installer/packages/trik-studio/ru.qreal.root.trik_studio_kernel/meta/prebuild-common.sh +++ b/installer/packages/trik-studio/ru.qreal.root.trik_studio_kernel/meta/prebuild-common.sh @@ -10,5 +10,6 @@ mkdir -p "$PWD"/../data/plugins/editors mkdir -p "$PWD"/../data/plugins/tools rsync -a "$BIN_DIR"/help "$PWD"/../data rsync -a "$BIN_DIR"/images "$PWD"/../data +rsync -a "$BIN_DIR"/palettes "$PWD"/../data rsync -a "$BIN_DIR"/externalToolsConfig "$PWD"/../data rsync -a "$BIN_DIR"/splashscreen.png "$PWD"/../data diff --git a/plugins/robots/common/twoDModel/src/engine/items/commentItem.cpp b/plugins/robots/common/twoDModel/src/engine/items/commentItem.cpp index 0a17021580..221402ae46 100644 --- a/plugins/robots/common/twoDModel/src/engine/items/commentItem.cpp +++ b/plugins/robots/common/twoDModel/src/engine/items/commentItem.cpp @@ -39,7 +39,7 @@ CommentItem::CommentItem(const QPointF &begin, const QPointF &end) QAction *CommentItem::commentTool() { - QAction * const result = new QAction(QIcon(":/icons/2d_comment.svg"), tr("Text (T)"), nullptr); + auto * const result = new QAction(loadTextColorIcon(":/icons/2d_comment.svg"), tr("Text (T)"), nullptr); result->setShortcuts({QKeySequence(Qt::Key_T), QKeySequence(Qt::Key_0)}); result->setCheckable(true); return result; diff --git a/plugins/robots/common/twoDModel/src/engine/items/curveItem.cpp b/plugins/robots/common/twoDModel/src/engine/items/curveItem.cpp index 64648a8ab9..f1ed885500 100644 --- a/plugins/robots/common/twoDModel/src/engine/items/curveItem.cpp +++ b/plugins/robots/common/twoDModel/src/engine/items/curveItem.cpp @@ -59,7 +59,7 @@ AbstractItem *CurveItem::clone() const QAction *CurveItem::curveTool() { - QAction * const result = new QAction(QIcon(":/icons/2d_bezier.svg"), tr("Bezier Curve (Z)"), nullptr); + QAction * const result = new QAction(loadTextColorIcon(":/icons/2d_bezier.svg"), tr("Bezier Curve (Z)"), nullptr); result->setShortcuts({QKeySequence(Qt::Key_Z), QKeySequence(Qt::Key_6)}); result->setCheckable(true); return result; diff --git a/plugins/robots/common/twoDModel/src/engine/items/imageItem.cpp b/plugins/robots/common/twoDModel/src/engine/items/imageItem.cpp index 2b3e04ca6f..08ab336d19 100644 --- a/plugins/robots/common/twoDModel/src/engine/items/imageItem.cpp +++ b/plugins/robots/common/twoDModel/src/engine/items/imageItem.cpp @@ -75,7 +75,7 @@ QPainterPath ImageItem::resizeArea() const QAction *ImageItem::imageTool() { - QAction * const result = new QAction(QIcon(":/icons/2d_image.svg"), tr("Image (I)"), nullptr); + auto * const result = new QAction(loadTextColorIcon(":/icons/2d_image.svg"), tr("Image (I)"), nullptr); result->setShortcuts({QKeySequence(Qt::Key_I), QKeySequence(Qt::Key_Minus)}); result->setCheckable(false); return result; diff --git a/plugins/robots/common/twoDModel/src/engine/items/rectangleItem.cpp b/plugins/robots/common/twoDModel/src/engine/items/rectangleItem.cpp index d00f7a31e1..7e929cf5f4 100644 --- a/plugins/robots/common/twoDModel/src/engine/items/rectangleItem.cpp +++ b/plugins/robots/common/twoDModel/src/engine/items/rectangleItem.cpp @@ -37,7 +37,7 @@ AbstractItem *RectangleItem::clone() const QAction *RectangleItem::rectangleTool() { - QAction * const result = new QAction(QIcon(":/icons/2d_rectangle.svg"), tr("Rectangle (R)"), nullptr); + QAction * const result = new QAction(loadTextColorIcon(":/icons/2d_rectangle.svg"), tr("Rectangle (R)"), nullptr); result->setShortcuts({QKeySequence(Qt::Key_R), QKeySequence(Qt::Key_7)}); result->setCheckable(true); return result; diff --git a/plugins/robots/common/twoDModel/src/engine/items/stylusItem.cpp b/plugins/robots/common/twoDModel/src/engine/items/stylusItem.cpp index b7fd4b2e73..5b8c453cf4 100644 --- a/plugins/robots/common/twoDModel/src/engine/items/stylusItem.cpp +++ b/plugins/robots/common/twoDModel/src/engine/items/stylusItem.cpp @@ -55,8 +55,8 @@ AbstractItem *StylusItem::clone() const } QAction *StylusItem::stylusTool() -{ - QAction * const result = new QAction(QIcon(":/icons/2d_pencil.png"), tr("Stylus (S)"), nullptr); +{ + QAction * const result = new QAction(loadTextColorIcon(":/icons/2d_pencil.png"), tr("Stylus (S)"), nullptr); result->setShortcuts({QKeySequence(Qt::Key_S), QKeySequence(Qt::Key_9)}); result->setCheckable(true); return result; diff --git a/plugins/robots/common/twoDModel/src/engine/view/parts/actionsBox.cpp b/plugins/robots/common/twoDModel/src/engine/view/parts/actionsBox.cpp index b287233462..781c7c9c32 100644 --- a/plugins/robots/common/twoDModel/src/engine/view/parts/actionsBox.cpp +++ b/plugins/robots/common/twoDModel/src/engine/view/parts/actionsBox.cpp @@ -13,13 +13,16 @@ * limitations under the License. */ #include "actionsBox.h" +#include +using namespace graphicsUtils; using namespace twoDModel::view; ActionsBox::ActionsBox(QObject *parent) : QObject(parent) , mSceneModeActions(this) - , mScrollHandModeAction(new QAction(QIcon(":/icons/2d_hand.png"), tr("Hand dragging mode"), this)) + , mScrollHandModeAction(new QAction(AbstractItem::loadTextColorIcon(":/icons/2d_hand.png") + , tr("Hand dragging mode"), this)) , mMultiSelectionModeAction(new QAction(QIcon(":/icons/2d_multiselection.png"), tr("Multiselection mode"), this)) , mSeparator1(new QAction(this)) , mSaveWorldModelAction(new QAction(QIcon(":/icons/2d_save.png"), tr("Save world model..."), this)) @@ -27,8 +30,10 @@ ActionsBox::ActionsBox(QObject *parent) , mLoadWorldWithoutRobotAction(new QAction(QIcon(":/icons/2d_open.png") , tr("Load world model without robot configuration..."), this)) , mSeparator2(new QAction(this)) - , mDeleteAllAction(new QAction(QIcon(":/icons/2d_clear.png"), tr("Clear items"), this)) - , mClearFloorAction(new QAction(QIcon(":/icons/2d_clear_floor.svg"), tr("Clear floor"), this)) + , mDeleteAllAction(new QAction(AbstractItem::loadTextColorIcon(":/icons/2d_clear.png") + , tr("Clear items"), this)) + , mClearFloorAction(new QAction(AbstractItem::loadTextColorIcon(":/icons/2d_clear_floor.svg") + , tr("Clear floor"), this)) { mScrollHandModeAction->setCheckable(true); mMultiSelectionModeAction->setCheckable(true); diff --git a/plugins/robots/common/twoDModel/src/engine/view/parts/robotItemPopup.cpp b/plugins/robots/common/twoDModel/src/engine/view/parts/robotItemPopup.cpp index fac58c3933..7a1db7028e 100644 --- a/plugins/robots/common/twoDModel/src/engine/view/parts/robotItemPopup.cpp +++ b/plugins/robots/common/twoDModel/src/engine/view/parts/robotItemPopup.cpp @@ -17,7 +17,7 @@ #include #include #include - +#include #include #include "src/engine/view/scene/robotItem.h" @@ -94,7 +94,9 @@ QWidget *RobotItemPopup::initSetStartButton() QAbstractButton *RobotItemPopup::initButton(const QString &icon, const QString &toolTip) { - QPushButton * const result = new QPushButton(QIcon(icon), QString(), this); + QPushButton * const result = new QPushButton( + graphicsUtils::AbstractItem::loadThemedIcon(icon, Qt::red), QString(), this + ); result->setToolTip(toolTip); result->setFlat(true); result->setFixedSize(24, 24); diff --git a/plugins/robots/common/twoDModel/src/engine/view/twoDModelWidget.cpp b/plugins/robots/common/twoDModel/src/engine/view/twoDModelWidget.cpp index 7070dd8fa4..0d2f15f2ca 100644 --- a/plugins/robots/common/twoDModel/src/engine/view/twoDModelWidget.cpp +++ b/plugins/robots/common/twoDModel/src/engine/view/twoDModelWidget.cpp @@ -223,6 +223,12 @@ void TwoDModelWidget::initWidget() }; toggleRulers(); + mUi->speedUpButton->setIcon(AbstractItem::loadTextColorIcon(":/icons/2d_plus.svg")); + mUi->speedDownButton->setIcon(AbstractItem::loadTextColorIcon(":/icons/2d_minus.svg")); + mUi->initialStateButton->setIcon(AbstractItem::loadTextColorIcon(":/icons/2d_robot_back.png")); + mUi->trainingModeButton->setIcon(AbstractItem::loadTextColorIcon(":/icons/2d_training.svg")); + mUi->toggleDetailsButton->setIcon(AbstractItem::loadTextColorIcon(":/icons/2d_left.png")); + connect(mUi->gridParametersBox, &twoDModel::view::GridParameters::parametersChanged , &*mScene, [&]() { mScene->update(); }); connect(mUi->gridParametersBox, &GridParameters::parametersChanged, this, toggleRulers); diff --git a/plugins/robots/interpreters/interpreterCore/src/managers/actionsManager.cpp b/plugins/robots/interpreters/interpreterCore/src/managers/actionsManager.cpp index 420b59eb4e..b34b777b66 100644 --- a/plugins/robots/interpreters/interpreterCore/src/managers/actionsManager.cpp +++ b/plugins/robots/interpreters/interpreterCore/src/managers/actionsManager.cpp @@ -15,9 +15,11 @@ #include "interpreterCore/managers/actionsManager.h" #include - +#include +#include #include #include +#include using namespace interpreterCore; @@ -32,8 +34,14 @@ ActionsManager::ActionsManager(KitPluginManager &kitPluginManager, RobotModelMan , mConnectToRobotAction(new QAction(QIcon(":/icons/robots_connect.svg"), QObject::tr("Connect to robot"), this)) , mRobotSettingsAction(QIcon(":/icons/robots_settings.png"), QObject::tr("Robot settings"), this) , mExportExerciseAction(QIcon(), QObject::tr("Save as task..."), this) - , mDebugModeAction(new QAction(QIcon(":/icons/main_tabbar_debug.svg"), QObject::tr("Debug"), this)) - , mEditModeAction(new QAction(QIcon(":/icons/main_tabbar_edit.svg"), QObject::tr("Edit"), this)) + , mDebugModeAction(new QAction( + graphicsUtils::AbstractItem::loadTextColorIcon(":/icons/main_tabbar_debug.svg"), + QObject::tr("Debug"), + this)) + , mEditModeAction(new QAction( + graphicsUtils::AbstractItem::loadTextColorIcon(":/icons/main_tabbar_edit.svg"), + QObject::tr("Edit"), + this)) , mHomeAction(new QAction(QIcon(":/icons/home.svg"), tr("To main page"), this)) , mSeparator1(this) , mSeparator2(this) diff --git a/qrgui/brandManager/brandManager.pro b/qrgui/brandManager/brandManager.pro index 2d45cc9ffe..5f0065fbe6 100644 --- a/qrgui/brandManager/brandManager.pro +++ b/qrgui/brandManager/brandManager.pro @@ -26,6 +26,7 @@ HEADERS += \ SOURCES += \ $$PWD/brandManager.cpp \ + $$PWD/styles.cpp \ RESOURCES += \ $$PWD/fonts/fonts.qrc \ @@ -38,3 +39,4 @@ DEFINES += QRGUI_BRAND_MANAGER_LIBRARY links(qrkernel qrutils qrgui-plugin-manager) includes(qrgui) +copyToDestdir(styles/palettes, now) diff --git a/qrgui/brandManager/styles.cpp b/qrgui/brandManager/styles.cpp new file mode 100644 index 0000000000..30925ad070 --- /dev/null +++ b/qrgui/brandManager/styles.cpp @@ -0,0 +1,64 @@ +/* Copyright 2024 CyberTech Labs Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + + +#include "styles.h" + +#include +#include +#include +#include + +using namespace qReal; + +QPalette Styles::loadPalette(const QString& pathToPalette) const { + QSettings settings(pathToPalette, QSettings::IniFormat); + QPalette palette; + + static QMap colorRoles = { + {"Window", QPalette::Window}, + {"WindowText", QPalette::WindowText}, + {"Base", QPalette::Base}, + {"AlternateBase", QPalette::AlternateBase}, + {"ToolTipBase", QPalette::ToolTipBase}, + {"ToolTipText", QPalette::ToolTipText}, + {"Text", QPalette::Text}, + {"Dark", QPalette::Dark}, + {"Shadow", QPalette::Shadow}, + {"Button", QPalette::Button}, + {"ButtonText", QPalette::ButtonText}, + {"BrightText", QPalette::BrightText}, + {"Link", QPalette::Link}, + {"Highlight", QPalette::Highlight}, + {"HighlightedText", QPalette::HighlightedText} + }; + + for (const auto &group : {"PaletteActive", "PaletteDisabled"}) { + QPalette::ColorGroup colorGroup = (QString(group) == "PaletteDisabled") ? QPalette::Disabled : QPalette::Active; + + for (auto it = colorRoles.begin(); it != colorRoles.end(); ++it) { + QStringList rgb = settings.value(QString(group) + "/" + it.key()).toStringList(); + if (!rgb.isEmpty()) { + QColor color(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt()); + if (colorGroup == QPalette::Disabled) { + palette.setColor(colorGroup, it.value(), color); + } else { + palette.setColor(it.value(), color); + } + } + } + } + + return palette; +} diff --git a/qrgui/brandManager/styles.h b/qrgui/brandManager/styles.h index a38f95cec9..c77babcef5 100644 --- a/qrgui/brandManager/styles.h +++ b/qrgui/brandManager/styles.h @@ -15,6 +15,7 @@ #pragma once #include +#include #include #include "fonts.h" @@ -31,65 +32,76 @@ class Styles { } + virtual ~Styles() = default; /// Returns json stylesheet for start tab background virtual QString startTabBackgroundStyle() const { - return utils::InFile::readAll(startTabBackgroundStylePath()); + return loadSystemPallete(utils::InFile::readAll(startTabBackgroundStylePath())); } /// Returns json stylesheet for start tab substrate background virtual QString startTabSubstrateBackgroundStyle() const { - return utils::InFile::readAll(startTabSubstrateBackgroundStylePath()); + return loadSystemPallete(utils::InFile::readAll(startTabSubstrateBackgroundStylePath())); } /// Returns json stylesheet for start tab header background virtual QString startTabHeaderBackgroundStyle() const { - return utils::InFile::readAll(startTabHeaderBackgroundStylePath()); + return loadSystemPallete(utils::InFile::readAll(startTabHeaderBackgroundStylePath())); } /// Returns json stylesheet for recent projects section background on start tab virtual QString startTabRecentProjectsBackgroundStyle() const { - return utils::InFile::readAll(startTabRecentProjectsBackgroundStylePath()); + return loadSystemPallete(utils::InFile::readAll(startTabRecentProjectsBackgroundStylePath())); } /// Returns json stylesheet for projects management section background on start tab virtual QString startTabProjectsManagementBackgroundStyle() const { - return utils::InFile::readAll(startTabProjectsManagementBackgroundStylePath()); + return loadSystemPallete(utils::InFile::readAll(startTabProjectsManagementBackgroundStylePath())); } /// Returns json stylesheet for command buttons on start tab virtual QString startTabButtonStyle() const { - return utils::InFile::readAll(startTabButtonStylePath()) - .replace("@@FONT@@", mFonts.commandButtonsFont()); + return loadSystemPallete(utils::InFile::readAll(startTabButtonStylePath())); } /// Returns json stylesheet for styled text on start tab of level 1 heading virtual QString startTabLabelLevel1Style() const { - return utils::InFile::readAll(startTabLabelLevel1StylePath()) - .replace("@@FONT@@", mFonts.styledTextFont()); + return loadSystemPallete(utils::InFile::readAll(startTabLabelLevel1StylePath())); } /// Returns json stylesheet for styled text on start tab of level 2 heading virtual QString startTabLabelLevel2Style() const { - return utils::InFile::readAll(startTabLabelLevel2StylePath()) - .replace("@@FONT@@", mFonts.styledTextFont()); + return loadSystemPallete(utils::InFile::readAll(startTabLabelLevel2StylePath())); } virtual QString splashscreenStyle() const { - return utils::InFile::readAll(splashscreenStylePath()); + return loadSystemPallete(utils::InFile::readAll(splashscreenStylePath())); } + QPalette loadPalette(const QString& pathToPalette) const; + protected: + QString loadSystemPallete(QString style) const { + auto systemPalette(QApplication::palette()); + return style + .replace("@@Window@@", systemPalette.color(QPalette::Window).name()) + .replace("@@Base@@", systemPalette.color(QPalette::Base).name()) + .replace("@@Font@@", mFonts.commandButtonsFont()) + .replace("@@Light@@", systemPalette.color(QPalette::Light).name()) + .replace("@@Highlight@@", systemPalette.color(QPalette::Highlight).name()) + .replace("@@Text@@", systemPalette.color(QPalette::Text).name()); + } + /// Returns a path to a file with json stylesheet for start tab background virtual QString startTabBackgroundStylePath() const { diff --git a/qrgui/brandManager/styles/palettes/darkWindowsPalette.ini b/qrgui/brandManager/styles/palettes/darkWindowsPalette.ini new file mode 100644 index 0000000000..a5ede30e61 --- /dev/null +++ b/qrgui/brandManager/styles/palettes/darkWindowsPalette.ini @@ -0,0 +1,23 @@ +[PaletteActive] +Window=56,56,56 +WindowText=255,255,255 +Base=42,42,42 +AlternateBase=66,66,66 +ToolTipBase=255,255,255 +ToolTipText=255,255,255 +Text=255,255,255 +Dark=35,35,35 +Shadow=20,20,20 +Button=53,53,53 +ButtonText=255,255,255 +BrightText=255,0,0 +Link=42,130,218 +Highlight=42,130,218 +HighlightedText=255,255,255 + +[PaletteDisabled] +WindowText=127,127,127 +Text=127,127,127 +ButtonText=127,127,127 +Highlight=80,80,80 +HighlightedText=127,127,127 \ No newline at end of file diff --git a/qrgui/brandManager/styles/splashscreen/splashscreen.css b/qrgui/brandManager/styles/splashscreen/splashscreen.css index c4a81f6396..66f985df7a 100644 --- a/qrgui/brandManager/styles/splashscreen/splashscreen.css +++ b/qrgui/brandManager/styles/splashscreen/splashscreen.css @@ -1,3 +1,3 @@ QProgressBar::chunk { - background-color: #001A42; + background-color: #084200; } diff --git a/qrgui/brandManager/styles/startTab/background.css b/qrgui/brandManager/styles/startTab/background.css index 93c36b8b72..b1f5a10d1b 100644 --- a/qrgui/brandManager/styles/startTab/background.css +++ b/qrgui/brandManager/styles/startTab/background.css @@ -1 +1 @@ -background-color: white; +background-color: @@Base@@; diff --git a/qrgui/brandManager/styles/startTab/button.css b/qrgui/brandManager/styles/startTab/button.css index a05a5c2e92..d673b6ca63 100644 --- a/qrgui/brandManager/styles/startTab/button.css +++ b/qrgui/brandManager/styles/startTab/button.css @@ -1,7 +1,7 @@ QLabel { background-color: transparent; font-family: "Segoe UI"; - color: black; + color: @@Text@@; font: 20px; text-align: left; } @@ -12,8 +12,8 @@ QLabel#withoutIcon { QPushButton { border-style: solid; - border-color: rgb(236, 236, 236); - background-color: rgb(236, 236, 236); + border-color: @@Window@@; + background-color: @@Window@@; } QPushButton#withIcon { @@ -21,5 +21,5 @@ QPushButton#withIcon { } QPushButton:hover, QPushButton:pressed { - background-color: rgb(216, 216, 216); + background-color: @@Highlight@@; } diff --git a/qrgui/brandManager/styles/startTab/header.css b/qrgui/brandManager/styles/startTab/header.css index c49d3c7df1..93c5f1cf94 100644 --- a/qrgui/brandManager/styles/startTab/header.css +++ b/qrgui/brandManager/styles/startTab/header.css @@ -1,8 +1,8 @@ * { - background-color: rgb(255, 255, 255); + background-color: @@Window@@; } QWidget#header { border-bottom: 3px solid; - border-bottom-color: rgb(236, 236, 236); + border-bottom-color: @@Window@@; } diff --git a/qrgui/brandManager/styles/startTab/labelLevel1.css b/qrgui/brandManager/styles/startTab/labelLevel1.css index 4e276e2aea..04cc6e924e 100644 --- a/qrgui/brandManager/styles/startTab/labelLevel1.css +++ b/qrgui/brandManager/styles/startTab/labelLevel1.css @@ -1,4 +1,4 @@ font-family: "Segoe UI"; font: 35px; text-transform: uppercase; -color: black; +color: @@Text@@; diff --git a/qrgui/brandManager/styles/startTab/labelLevel2.css b/qrgui/brandManager/styles/startTab/labelLevel2.css index 7d98df5faf..51b035ad95 100644 --- a/qrgui/brandManager/styles/startTab/labelLevel2.css +++ b/qrgui/brandManager/styles/startTab/labelLevel2.css @@ -1,6 +1,6 @@ font-family: "Segoe UI"; font: bold 24px; text-transform: uppercase; -color: black; +color: @@Text@@; margin-left: 10px; margin-top: 20px; diff --git a/qrgui/brandManager/styles/startTab/projectsManagementBackground.css b/qrgui/brandManager/styles/startTab/projectsManagementBackground.css index 44ad319756..5ad808cf40 100644 --- a/qrgui/brandManager/styles/startTab/projectsManagementBackground.css +++ b/qrgui/brandManager/styles/startTab/projectsManagementBackground.css @@ -1 +1 @@ -background-color: rgb(236, 236, 236); +background-color: @@Window@@; diff --git a/qrgui/brandManager/styles/startTab/recentProjectsBackground.css b/qrgui/brandManager/styles/startTab/recentProjectsBackground.css index 44ad319756..5ad808cf40 100644 --- a/qrgui/brandManager/styles/startTab/recentProjectsBackground.css +++ b/qrgui/brandManager/styles/startTab/recentProjectsBackground.css @@ -1 +1 @@ -background-color: rgb(236, 236, 236); +background-color: @@Window@@; diff --git a/qrgui/brandManager/styles/startTab/substrate.css b/qrgui/brandManager/styles/startTab/substrate.css index 23f7655a18..b1f5a10d1b 100644 --- a/qrgui/brandManager/styles/startTab/substrate.css +++ b/qrgui/brandManager/styles/startTab/substrate.css @@ -1 +1 @@ -background-color: rgb(255, 255, 255); +background-color: @@Base@@; diff --git a/qrgui/brandManager/styles/styles.qrc b/qrgui/brandManager/styles/styles.qrc index 09e289797d..f203e6e93f 100644 --- a/qrgui/brandManager/styles/styles.qrc +++ b/qrgui/brandManager/styles/styles.qrc @@ -9,5 +9,6 @@ startTab/projectsManagementBackground.css startTab/recentProjectsBackground.css startTab/substrate.css + palettes/darkWindowsPalette.ini diff --git a/qrgui/editor/edgeElement.cpp b/qrgui/editor/edgeElement.cpp index 16fbffb948..18eb23e182 100644 --- a/qrgui/editor/edgeElement.cpp +++ b/qrgui/editor/edgeElement.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -48,7 +49,7 @@ EdgeElement::EdgeElement(const EdgeElementType &type, const Id &id, const models : Element(type, id, models) , mPenStyle(Qt::SolidLine) , mPenWidth(1) - , mPenColor(Qt::black) + , mPenColor(QApplication::palette().color(QPalette::Text)) , mType(type) , mSrc(nullptr) , mDst(nullptr) @@ -66,7 +67,7 @@ EdgeElement::EdgeElement(const EdgeElementType &type, const Id &id, const models { mPenStyle = mType.penStyle(); mPenWidth = mType.penWidth(); - mPenColor = mType.penColor(); + // mPenColor = mType.penColor(); setZValue(100); setFlag(ItemIsMovable, true); // if flag is true then draws strangely... diff --git a/qrgui/editor/editorViewScene.cpp b/qrgui/editor/editorViewScene.cpp index 5cf4831a11..1d29fced29 100644 --- a/qrgui/editor/editorViewScene.cpp +++ b/qrgui/editor/editorViewScene.cpp @@ -1254,7 +1254,7 @@ void EditorViewScene::drawBackground(QPainter *painter, const QRectF &rect) { if (mNeedDrawGrid) { mWidthOfGrid = SettingsManager::value("GridWidth").toDouble() / 100; - painter->setPen(QPen(Qt::black, mWidthOfGrid)); + painter->setPen(QPen(QApplication::palette().color(QPalette::Text), mWidthOfGrid)); const int indexGrid = SettingsManager::value("IndexGrid").toInt(); mGridDrawer.drawGrid(painter, rect, indexGrid); diff --git a/qrgui/editor/labels/label.cpp b/qrgui/editor/labels/label.cpp index b9a7abc340..a62d354d92 100644 --- a/qrgui/editor/labels/label.cpp +++ b/qrgui/editor/labels/label.cpp @@ -56,8 +56,8 @@ const LabelProperties &Label::info() const void Label::init() { QGraphicsTextItem::setFlags(ItemIsSelectable); + QGraphicsTextItem::setDefaultTextColor(Qt::black); connect(document(), &QTextDocument::contentsChanged, this, &Label::saveToRepo); - reinitFont(); setRotation(mProperties->rotation()); if (!mProperties->isStatic()) { @@ -471,6 +471,7 @@ void Label::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi // Default dashed frame is drawn arround the whole bounding rect (arround prefix and suffix too). Disabling it. const_cast(option)->state &= ~QStyle::State_Selected & ~QStyle::State_HasFocus; + QGraphicsTextItem::paint(painter, option, widget); } diff --git a/qrgui/hotKeyManager/hotKeyManagerPage.cpp b/qrgui/hotKeyManager/hotKeyManagerPage.cpp index 56f28920a0..2bbd52d82e 100644 --- a/qrgui/hotKeyManager/hotKeyManagerPage.cpp +++ b/qrgui/hotKeyManager/hotKeyManagerPage.cpp @@ -90,7 +90,6 @@ void PreferencesHotKeyManagerPage::resetShortcuts() mCurrentItem->setText(""); mUi->shortcutLineEdit->setText(""); - setTextColor(Qt::black); } } @@ -129,7 +128,7 @@ void PreferencesHotKeyManagerPage::loadHotKeys() int j = 0; for (const QString &sequence : sequences) { mUi->hotKeysTable->item(k, 2 + j)->setText(sequence); - mUi->hotKeysTable->item(k, 2 + j)->setForeground(Qt::black); + mUi->hotKeysTable->item(k, 2 + j)->setForeground(QApplication::palette().color(QPalette::Text)); if (++j >= maxShortcuts) { break; @@ -162,20 +161,18 @@ void PreferencesHotKeyManagerPage::activateShortcutLineEdit(const int row, const // Columns with shortcuts start from index 2 if (column > 1) { if (mCurrentItem) { - mCurrentItem->setBackground(Qt::white); + mCurrentItem->setBackground(QApplication::palette().color(QPalette::Base)); } mCurrentId = mUi->hotKeysTable->item(row, 0)->text(); mCurrentItem = mUi->hotKeysTable->item(row, column); - mCurrentItem->setBackground(Qt::lightGray); + mCurrentItem->setBackground(QApplication::palette().color(QPalette::Highlight)); mUi->shortcutLineEdit->setText(mCurrentItem->text()); mUi->shortcutLineEdit->setEnabled(true); - setTextColor(mCurrentItem->foreground().color()); - if (HotKeyManager::setShortcut(mCurrentId, mCurrentItem->text())) { - setTextColor(Qt::black); + setTextColor(QApplication::palette().color(QPalette::Text)); } } else { mCurrentId = ""; @@ -194,7 +191,7 @@ void PreferencesHotKeyManagerPage::newKey(const int key) if (!mCurrentId.isEmpty()) { if (mCurrentItem->text().isEmpty()) { if (HotKeyManager::setShortcut(mCurrentId, QKeySequence(mCurrentModifiers + key))) { - setTextColor(Qt::black); + setTextColor(QApplication::palette().color(QPalette::Text)); } else { setTextColor(Qt::red); } @@ -214,7 +211,7 @@ void PreferencesHotKeyManagerPage::newKey(const int key) } if (HotKeyManager::setShortcut(mCurrentId, QKeySequence(shortcut))) { - setTextColor(Qt::black); + setTextColor(QApplication::palette().color(QPalette::Text)); mCurrentItem->setText(shortcut); mUi->shortcutLineEdit->setText(mCurrentItem->text()); } else { diff --git a/qrgui/mainWindow/mainWindow.cpp b/qrgui/mainWindow/mainWindow.cpp index c84c4b02f0..ccaf483f8a 100644 --- a/qrgui/mainWindow/mainWindow.cpp +++ b/qrgui/mainWindow/mainWindow.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -115,6 +116,7 @@ MainWindow::MainWindow(const QString &fileToOpen) , mInitialFileToOpen(fileToOpen) { QLOG_INFO() << "MainWindow: screen DPI is" << logicalDpiX(); + initPalette(); mUi->setupUi(this); mUi->paletteTree->initMainWindow(this); setWindowTitle("QReal"); @@ -643,6 +645,36 @@ void MainWindow::setReference(const QStringList &data, const QPersistentModelInd } } +bool MainWindow::windowsDarkThemeAvailiable() +{ + if (QOperatingSystemVersion::current().majorVersion() == 10) + { + return QOperatingSystemVersion::current().microVersion() >= 17763; + } + return QOperatingSystemVersion::current().majorVersion() > 10; +} + +bool MainWindow::windowsIsInDarkTheme() +{ + QSettings settings( + "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize" + , QSettings::NativeFormat); + return settings.value("AppsUseLightTheme", 1).toInt() == 0; +} + +void MainWindow::initPalette() { + if (QSysInfo::productType() != "windows") { + return; + } + if (!windowsDarkThemeAvailiable() || !windowsIsInDarkTheme()) { + return; + } + QApplication::setPalette(BrandManager::styles()->loadPalette( + QCoreApplication::applicationDirPath() + + "/palettes/darkWindowsPalette.ini") + ); +} + void MainWindow::setData(const QString &data, const QPersistentModelIndex &index, const int &role) { // const_cast here is ok, since we need to set data in a correct model, and diff --git a/qrgui/mainWindow/mainWindow.h b/qrgui/mainWindow/mainWindow.h index 75ced6cba7..bc5bbe5b68 100644 --- a/qrgui/mainWindow/mainWindow.h +++ b/qrgui/mainWindow/mainWindow.h @@ -306,6 +306,10 @@ private slots: void switchToTab(int index); int getTabIndex(const QModelIndex &index); + bool windowsDarkThemeAvailiable(); + bool windowsIsInDarkTheme(); + void initPalette(); + void initGridProperties(); void clickErrorListWidget(); diff --git a/qrgui/mainWindow/startWidget/circleWidget.cpp b/qrgui/mainWindow/startWidget/circleWidget.cpp index dd9f4ce18f..2af26df6b6 100644 --- a/qrgui/mainWindow/startWidget/circleWidget.cpp +++ b/qrgui/mainWindow/startWidget/circleWidget.cpp @@ -71,8 +71,8 @@ void CircleWidget::paintEvent(QPaintEvent *event) QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); - const QColor backgroundColor = Qt::white; - QPen borderPen(property("enabled").toBool() ? palette().foreground().color() : backgroundColor); + const QColor backgroundColor = palette().color(QPalette::Light); + QPen borderPen(property("enabled").toBool() ? palette().highlight().color() : backgroundColor); borderPen.setWidth(3); const QBrush backgroundBrush(backgroundColor); painter.setBrush(backgroundBrush); diff --git a/qrgui/plugins/pluginManager/sdfRenderer.cpp b/qrgui/plugins/pluginManager/sdfRenderer.cpp index 0f7351604b..4bacf37033 100644 --- a/qrgui/plugins/pluginManager/sdfRenderer.cpp +++ b/qrgui/plugins/pluginManager/sdfRenderer.cpp @@ -112,6 +112,7 @@ void SdfRenderer::render(QPainter *painter, const QRectF &bounds, bool isIcon) mStartX = static_cast(bounds.x()); mStartY = static_cast(bounds.y()); this->painter = painter; + QDomElement docElem = doc.documentElement(); QDomNode node = docElem.firstChild(); while(!node.isNull()) @@ -821,6 +822,7 @@ void SdfIconEngineV2::paint(QPainter *painter, const QRect &rect, QIcon::Mode mo Q_UNUSED(mode) Q_UNUSED(state) painter->eraseRect(rect); + int rh = rect.height(); int rw = rect.width(); @@ -839,6 +841,11 @@ void SdfIconEngineV2::paint(QPainter *painter, const QRect &rect, QIcon::Mode mo resRect.setTop(rect.top() + (rh - rw * ph / pw) / 2); resRect.setBottom(rect.bottom() - (rh - rw * ph / pw) / 2); } + + QPixmap image(rh, rw); + image.fill(QApplication::palette().color(QPalette::Base)); + painter->drawPixmap(0, 0, image); + painter->setRenderHint(QPainter::Antialiasing, true); mRenderer.render(painter, resRect, true); } diff --git a/qrtranslations/fr/plugins/robots/interpreterCore_fr.ts b/qrtranslations/fr/plugins/robots/interpreterCore_fr.ts index 2b64f8bd9e..153ce39061 100644 --- a/qrtranslations/fr/plugins/robots/interpreterCore_fr.ts +++ b/qrtranslations/fr/plugins/robots/interpreterCore_fr.ts @@ -163,7 +163,7 @@ Conflit de configuration des capteurs, verifiez que les ports des capteurs soient utilisés de manière consistente dans le programme - + Run Executer @@ -188,17 +188,17 @@ Enregistrer comme une tache... - + Debug - + Edit - + Switch to debug mode Passer en mode de débogage diff --git a/qrtranslations/fr/plugins/robots/twoDModel_fr.ts b/qrtranslations/fr/plugins/robots/twoDModel_fr.ts index d2a9c2fa65..1195f67ab3 100644 --- a/qrtranslations/fr/plugins/robots/twoDModel_fr.ts +++ b/qrtranslations/fr/plugins/robots/twoDModel_fr.ts @@ -511,7 +511,7 @@ twoDModel::view::ActionsBox - + Hand dragging mode Le mode de glissement manuel @@ -536,12 +536,12 @@ - + Clear items Tout effacer - + Clear floor Effacer le sol des traces du robot @@ -679,7 +679,7 @@ - + Marker thickness Épaisseur du marqueur @@ -728,7 +728,7 @@ twoDModel::view::TwoDModelWidget - + Warning Attention diff --git a/qrtranslations/fr/qrgui_editor_fr.ts b/qrtranslations/fr/qrgui_editor_fr.ts index 452f28f960..a405a2bcfc 100644 --- a/qrtranslations/fr/qrgui_editor_fr.ts +++ b/qrtranslations/fr/qrgui_editor_fr.ts @@ -163,7 +163,7 @@ qReal::gui::editor::EdgeElement - + Reverse Retourner diff --git a/qrtranslations/fr/qrgui_hotKeyManager_fr.ts b/qrtranslations/fr/qrgui_hotKeyManager_fr.ts index c59dfb3f95..965464503c 100644 --- a/qrtranslations/fr/qrgui_hotKeyManager_fr.ts +++ b/qrtranslations/fr/qrgui_hotKeyManager_fr.ts @@ -4,7 +4,7 @@ PreferencesHotKeyManagerPage - + Question Question diff --git a/qrtranslations/fr/qrgui_mainWindow_fr.ts b/qrtranslations/fr/qrgui_mainWindow_fr.ts index c8b1122d95..d9098476d6 100644 --- a/qrtranslations/fr/qrgui_mainWindow_fr.ts +++ b/qrtranslations/fr/qrgui_mainWindow_fr.ts @@ -708,7 +708,7 @@ qReal::MainWindow - + Could not save file, try to save it to another place @@ -729,7 +729,7 @@ WARNING: The settings will be restored after application restart - + Error Erreur diff --git a/qrtranslations/fr/qrutils_fr.ts b/qrtranslations/fr/qrutils_fr.ts index 0ac115c262..5c5cdc9695 100644 --- a/qrtranslations/fr/qrutils_fr.ts +++ b/qrtranslations/fr/qrutils_fr.ts @@ -88,7 +88,7 @@ Division entière par zéro - + Remove Supprimer diff --git a/qrtranslations/ru/plugins/robots/interpreterCore_ru.ts b/qrtranslations/ru/plugins/robots/interpreterCore_ru.ts index 6b8c26c7f4..d4bcfe1cd2 100644 --- a/qrtranslations/ru/plugins/robots/interpreterCore_ru.ts +++ b/qrtranslations/ru/plugins/robots/interpreterCore_ru.ts @@ -114,7 +114,7 @@ time - + Run Выполнить @@ -134,17 +134,17 @@ Сохранить как упражнение... - + Debug Отладка - + Edit Редактор - + Switch to debug mode Переключиться в режим отладки @@ -164,7 +164,7 @@ Остановить интерпретацию - + Robot settings Настройки @@ -192,7 +192,7 @@ interpreterCore::ActionsManager - + To main page На главную diff --git a/qrtranslations/ru/plugins/robots/twoDModel_ru.ts b/qrtranslations/ru/plugins/robots/twoDModel_ru.ts index 14ba892480..010349bd4e 100644 --- a/qrtranslations/ru/plugins/robots/twoDModel_ru.ts +++ b/qrtranslations/ru/plugins/robots/twoDModel_ru.ts @@ -787,7 +787,7 @@ twoDModel::view::ActionsBox - + Hand dragging mode Режим таскания сцены @@ -816,12 +816,12 @@ Установить фон... - + Clear items Очистить всё - + Clear floor Очистить пол от следов робота @@ -1018,7 +1018,7 @@ Передвинуть стартовое положение робота сюда - + Marker thickness Толщина маркера @@ -1071,7 +1071,7 @@ twoDModel::view::TwoDModelWidget - + Warning Предупреждение diff --git a/qrtranslations/ru/qrgui_editor_ru.ts b/qrtranslations/ru/qrgui_editor_ru.ts index 541bd5b2a1..cf2c99e700 100644 --- a/qrtranslations/ru/qrgui_editor_ru.ts +++ b/qrtranslations/ru/qrgui_editor_ru.ts @@ -167,7 +167,7 @@ qReal::gui::editor::EdgeElement - + Reverse Развернуть diff --git a/qrtranslations/ru/qrgui_hotKeyManager_ru.ts b/qrtranslations/ru/qrgui_hotKeyManager_ru.ts index 9170dfc8f8..4ca43dcf6d 100644 --- a/qrtranslations/ru/qrgui_hotKeyManager_ru.ts +++ b/qrtranslations/ru/qrgui_hotKeyManager_ru.ts @@ -4,7 +4,7 @@ PreferencesHotKeyManagerPage - + Question Вопрос diff --git a/qrtranslations/ru/qrgui_mainWindow_ru.ts b/qrtranslations/ru/qrgui_mainWindow_ru.ts index 0812c9fe04..398cfd69fe 100644 --- a/qrtranslations/ru/qrgui_mainWindow_ru.ts +++ b/qrtranslations/ru/qrgui_mainWindow_ru.ts @@ -735,7 +735,7 @@ О QReal - + Error Ошибка @@ -788,7 +788,7 @@ Создать диаграмму - + Restore default settings Восстановить настройки по-умолчанию @@ -807,7 +807,7 @@ WARNING: The settings will be restored after application restart Не удалось сохранить файл, попробуйте сохранить его в другое место - + Undo Отменить diff --git a/qrtranslations/ru/qrutils_ru.ts b/qrtranslations/ru/qrutils_ru.ts index d565092af3..b859c89e8b 100644 --- a/qrtranslations/ru/qrutils_ru.ts +++ b/qrtranslations/ru/qrutils_ru.ts @@ -92,7 +92,7 @@ Целичисленное деление на ноль - + Remove Удалить diff --git a/qrutils/graphicsUtils/abstractItem.cpp b/qrutils/graphicsUtils/abstractItem.cpp index 0f2d9ef3d7..c5172d2e1e 100644 --- a/qrutils/graphicsUtils/abstractItem.cpp +++ b/qrutils/graphicsUtils/abstractItem.cpp @@ -21,6 +21,7 @@ #include #include #include +#include using namespace graphicsUtils; @@ -483,6 +484,20 @@ QStringList AbstractItem::getBrushStyleList() return { "None", "Solid" }; } +QIcon AbstractItem::loadThemedIcon(const QString& path, const QColor& color) { + QPixmap image(path); + QPainter pt(&image); + pt.setCompositionMode(QPainter::CompositionMode_SourceIn); + pt.fillRect(image.rect(), color); + pt.end(); + return QIcon(image); +} + +QIcon AbstractItem::loadTextColorIcon(const QString& path) { + auto text_color = QApplication::palette().color(QPalette::Text); + return loadThemedIcon(path, text_color); +} + void AbstractItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event) { // When selecting a robot item on the scene than display widget may appear. diff --git a/qrutils/graphicsUtils/abstractItem.h b/qrutils/graphicsUtils/abstractItem.h index a92242f2a3..cb364fc6c8 100644 --- a/qrutils/graphicsUtils/abstractItem.h +++ b/qrutils/graphicsUtils/abstractItem.h @@ -72,6 +72,9 @@ class QRUTILS_EXPORT AbstractItem : public QGraphicsObject static QStringList getPenStyleList(); static QStringList getBrushStyleList(); + static QIcon loadThemedIcon(const QString& path, const QColor& color); + static QIcon loadTextColorIcon(const QString& path); + QPen pen() const; QBrush brush() const; void setBrush(const QBrush &brush); diff --git a/qrutils/widgets/searchLineEdit.cpp b/qrutils/widgets/searchLineEdit.cpp index fc655ede3c..482d8f49fc 100644 --- a/qrutils/widgets/searchLineEdit.cpp +++ b/qrutils/widgets/searchLineEdit.cpp @@ -62,9 +62,10 @@ SearchLineEdit::SearchLineEdit(QWidget *parent, bool borderEnabled) void SearchLineEdit::setBorderEnabled(bool enabled) { if (enabled) { - setStyleSheet("QFrame { background: white; border: 1px solid black; border-radius: 2px; }"); + setStyleSheet(QString("QFrame { background: %1; border: 1px solid %2; border-radius: 2px; }") + .arg(palette().color(QPalette::Light).name(), palette().color(QPalette::Dark).name())); } else { - setStyleSheet("QFrame { background: white; }"); + setStyleSheet(QString("QFrame { background: %1; }").arg(palette().color(QPalette::Light).name())); } }