mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
feature/add_custom_icons (#2145)
* first boold * adj * base spec amendment * add monochrome optional fields to the theme * add monochrome optional fields to the theme * adj default value
This commit is contained in:
parent
29b2093ef0
commit
1318427bb7
@ -86,6 +86,7 @@ Theme::Metadata Theme::readMetadata(const Palette &p_obj)
|
|||||||
data.m_revision = metaObj[QStringLiteral("revision")].toInt();
|
data.m_revision = metaObj[QStringLiteral("revision")].toInt();
|
||||||
data.m_editorHighlightTheme = metaObj[QStringLiteral("editor-highlight-theme")].toString();
|
data.m_editorHighlightTheme = metaObj[QStringLiteral("editor-highlight-theme")].toString();
|
||||||
data.m_markdownEditorHighlightTheme = metaObj[QStringLiteral("markdown-editor-highlight-theme")].toString();
|
data.m_markdownEditorHighlightTheme = metaObj[QStringLiteral("markdown-editor-highlight-theme")].toString();
|
||||||
|
data.m_IconMonochrome = metaObj[QStringLiteral("icon-monochrome")].toBool();
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -408,6 +409,8 @@ QString Theme::getFileName(File p_fileType)
|
|||||||
return QStringLiteral("markdown-editor-highlight.theme");
|
return QStringLiteral("markdown-editor-highlight.theme");
|
||||||
case File::Cover:
|
case File::Cover:
|
||||||
return QStringLiteral("cover.png");
|
return QStringLiteral("cover.png");
|
||||||
|
case File::Icon:
|
||||||
|
return QStringLiteral("icons");
|
||||||
default:
|
default:
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
return "";
|
return "";
|
||||||
@ -438,6 +441,11 @@ QString Theme::getMarkdownEditorHighlightTheme() const
|
|||||||
return getEditorHighlightTheme();
|
return getEditorHighlightTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Theme::getIconMonochrome() const
|
||||||
|
{
|
||||||
|
return m_metadata.m_IconMonochrome;
|
||||||
|
}
|
||||||
|
|
||||||
QString Theme::name() const
|
QString Theme::name() const
|
||||||
{
|
{
|
||||||
return PathUtils::dirName(m_themeFolderPath);
|
return PathUtils::dirName(m_themeFolderPath);
|
||||||
|
@ -28,6 +28,7 @@ namespace vnotex
|
|||||||
EditorHighlightStyle,
|
EditorHighlightStyle,
|
||||||
MarkdownEditorHighlightStyle,
|
MarkdownEditorHighlightStyle,
|
||||||
Cover,
|
Cover,
|
||||||
|
Icon,
|
||||||
Max
|
Max
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,6 +45,8 @@ namespace vnotex
|
|||||||
// Return the file path of the theme or just the theme name.
|
// Return the file path of the theme or just the theme name.
|
||||||
QString getMarkdownEditorHighlightTheme() const;
|
QString getMarkdownEditorHighlightTheme() const;
|
||||||
|
|
||||||
|
bool getIconMonochrome() const;
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
|
||||||
static bool isValidThemeFolder(const QString &p_folder);
|
static bool isValidThemeFolder(const QString &p_folder);
|
||||||
@ -69,6 +72,10 @@ namespace vnotex
|
|||||||
// If not specified, will use m_editorHighlightTheme.
|
// If not specified, will use m_editorHighlightTheme.
|
||||||
// Valid only when KSyntaxCodeBlockHighlighter is used.
|
// Valid only when KSyntaxCodeBlockHighlighter is used.
|
||||||
QString m_markdownEditorHighlightTheme;
|
QString m_markdownEditorHighlightTheme;
|
||||||
|
|
||||||
|
// Whether the icon of the current theme uses monochrome.
|
||||||
|
// Default is monochrome.
|
||||||
|
bool m_IconMonochrome = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QJsonObject Palette;
|
typedef QJsonObject Palette;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <vtextedit/vtexteditor.h>
|
#include <vtextedit/vtexteditor.h>
|
||||||
#include "configmgr.h"
|
#include "configmgr.h"
|
||||||
#include "coreconfig.h"
|
#include "coreconfig.h"
|
||||||
|
#include "theme.h"
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
@ -36,8 +37,14 @@ QString ThemeMgr::getIconFile(const QString &p_icon) const
|
|||||||
return p_icon;
|
return p_icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there is an ICONS folder in the theme configuration, use the custom ICONS from it.
|
||||||
|
QString customIcon = getFile(Theme::File::Icon) + "/" + p_icon;
|
||||||
|
if (QFile::exists(customIcon)) {
|
||||||
|
return customIcon;
|
||||||
|
} else {
|
||||||
return ":/vnotex/data/core/icons/" + p_icon;
|
return ":/vnotex/data/core/icons/" + p_icon;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ThemeMgr::loadAvailableThemes()
|
void ThemeMgr::loadAvailableThemes()
|
||||||
{
|
{
|
||||||
@ -172,6 +179,11 @@ QString ThemeMgr::getMarkdownEditorHighlightTheme() const
|
|||||||
return m_currentTheme->getMarkdownEditorHighlightTheme();
|
return m_currentTheme->getMarkdownEditorHighlightTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ThemeMgr::getIconMonochrome() const
|
||||||
|
{
|
||||||
|
return m_currentTheme->getIconMonochrome();
|
||||||
|
}
|
||||||
|
|
||||||
void ThemeMgr::addSyntaxHighlightingSearchPaths(const QStringList &p_paths)
|
void ThemeMgr::addSyntaxHighlightingSearchPaths(const QStringList &p_paths)
|
||||||
{
|
{
|
||||||
vte::VTextEditor::addSyntaxCustomSearchPaths(p_paths);
|
vte::VTextEditor::addSyntaxCustomSearchPaths(p_paths);
|
||||||
|
@ -49,6 +49,8 @@ namespace vnotex
|
|||||||
|
|
||||||
QString getMarkdownEditorHighlightTheme() const;
|
QString getMarkdownEditorHighlightTheme() const;
|
||||||
|
|
||||||
|
bool getIconMonochrome() const;
|
||||||
|
|
||||||
const QColor &getBaseBackground() const;
|
const QColor &getBaseBackground() const;
|
||||||
void setBaseBackground(const QColor &p_bg);
|
void setBaseBackground(const QColor &p_bg);
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
"markdown-editor-highlight-theme" : "Markdown Breeze Dark",
|
"markdown-editor-highlight-theme" : "Markdown Breeze Dark",
|
||||||
"display_name" : "Moonlight",
|
"display_name" : "Moonlight",
|
||||||
"//comment" : "Display name for different locales",
|
"//comment" : "Display name for different locales",
|
||||||
"display_name_zh_CN" : "月夜"
|
"display_name_zh_CN" : "月夜",
|
||||||
|
"icon-monochrome": true
|
||||||
},
|
},
|
||||||
"palette" : {
|
"palette" : {
|
||||||
"bg1_1" : "#07080d",
|
"bg1_1" : "#07080d",
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
"markdown-editor-highlight-theme" : "Markdown Default",
|
"markdown-editor-highlight-theme" : "Markdown Default",
|
||||||
"display_name" : "Native",
|
"display_name" : "Native",
|
||||||
"//comment" : "Display name for different locales",
|
"//comment" : "Display name for different locales",
|
||||||
"display_name_zh_CN" : "原素"
|
"display_name_zh_CN" : "原素",
|
||||||
|
"icon-monochrome": true
|
||||||
},
|
},
|
||||||
"base" : {
|
"base" : {
|
||||||
"normal" : {
|
"normal" : {
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
"markdown-editor-highlight-theme" : "Markdown Default",
|
"markdown-editor-highlight-theme" : "Markdown Default",
|
||||||
"display_name" : "Pure",
|
"display_name" : "Pure",
|
||||||
"//comment" : "Display name for different locales",
|
"//comment" : "Display name for different locales",
|
||||||
"display_name_zh_CN" : "纯净"
|
"display_name_zh_CN" : "纯净",
|
||||||
|
"icon-monochrome": true
|
||||||
},
|
},
|
||||||
"palette" : {
|
"palette" : {
|
||||||
"bg3_0" : "#bbbbbb",
|
"bg3_0" : "#bbbbbb",
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
"display_name" : "Solarized-dark",
|
"display_name" : "Solarized-dark",
|
||||||
"//comment" : "Display name for different locales",
|
"//comment" : "Display name for different locales",
|
||||||
"display_name_zh_CN" : "Solarized-dark",
|
"display_name_zh_CN" : "Solarized-dark",
|
||||||
"author": "nriver"
|
"author": "nriver",
|
||||||
|
"icon-monochrome": true
|
||||||
},
|
},
|
||||||
"palette" : {
|
"palette" : {
|
||||||
"bg1_1" : "#002b36",
|
"bg1_1" : "#002b36",
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
"display_name" : "Solarized-light",
|
"display_name" : "Solarized-light",
|
||||||
"//comment" : "Display name for different locales",
|
"//comment" : "Display name for different locales",
|
||||||
"display_name_zh_CN" : "Solarized-light",
|
"display_name_zh_CN" : "Solarized-light",
|
||||||
"author": "nriver"
|
"author": "nriver",
|
||||||
|
"icon-monochrome": true
|
||||||
},
|
},
|
||||||
"palette" : {
|
"palette" : {
|
||||||
"bg1_1" : "#FFFFF5",
|
"bg1_1" : "#FFFFF5",
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
"markdown-editor-highlight-theme" : "vscode-dark",
|
"markdown-editor-highlight-theme" : "vscode-dark",
|
||||||
"display_name" : "VSCode-dark",
|
"display_name" : "VSCode-dark",
|
||||||
"//comment" : "Display name for different locales",
|
"//comment" : "Display name for different locales",
|
||||||
"display_name_zh_CN" : "VSCode-深色"
|
"display_name_zh_CN" : "VSCode-深色",
|
||||||
|
"icon-monochrome": true
|
||||||
},
|
},
|
||||||
"palette" : {
|
"palette" : {
|
||||||
"bg1_1" : "#07080d",
|
"bg1_1" : "#07080d",
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <core/vnotex.h>
|
||||||
|
|
||||||
#include "fileutils.h"
|
#include "fileutils.h"
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
@ -19,7 +21,8 @@ QIcon IconUtils::fetchIcon(const QString &p_iconFile,
|
|||||||
qreal p_angle)
|
qreal p_angle)
|
||||||
{
|
{
|
||||||
const auto suffix = QFileInfo(p_iconFile).suffix().toLower().toStdString();
|
const auto suffix = QFileInfo(p_iconFile).suffix().toLower().toStdString();
|
||||||
if (p_overriddenColors.isEmpty() || suffix != "svg") {
|
if ((p_overriddenColors.isEmpty() || suffix != "svg")
|
||||||
|
&& !VNoteX::getInst().getThemeMgr().getIconMonochrome()) {
|
||||||
return QIcon(p_iconFile);
|
return QIcon(p_iconFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +49,9 @@ QIcon IconUtils::fetchIcon(const QString &p_iconFile,
|
|||||||
QIcon IconUtils::fetchIcon(const QString &p_iconFile, const QString &p_overriddenForeground)
|
QIcon IconUtils::fetchIcon(const QString &p_iconFile, const QString &p_overriddenForeground)
|
||||||
{
|
{
|
||||||
QVector<OverriddenColor> colors;
|
QVector<OverriddenColor> colors;
|
||||||
if (!p_overriddenForeground.isEmpty()) {
|
const auto &themeMgr = VNoteX::getInst().getThemeMgr();
|
||||||
|
|
||||||
|
if (!p_overriddenForeground.isEmpty() && themeMgr.getIconMonochrome()) {
|
||||||
colors.push_back(OverriddenColor(p_overriddenForeground, QIcon::Normal, QIcon::Off));
|
colors.push_back(OverriddenColor(p_overriddenForeground, QIcon::Normal, QIcon::Off));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,7 +514,6 @@ const QIcon &DockWidgetHelper::getDockIcon(DockIndex p_dockIndex)
|
|||||||
{
|
{
|
||||||
static const auto fg = VNoteX::getInst().getThemeMgr().paletteColor("widgets#mainwindow#dockwidget_tabbar#icon#fg");
|
static const auto fg = VNoteX::getInst().getThemeMgr().paletteColor("widgets#mainwindow#dockwidget_tabbar#icon#fg");
|
||||||
static const auto selectedFg = VNoteX::getInst().getThemeMgr().paletteColor("widgets#mainwindow#dockwidget_tabbar#icon#selected#fg");
|
static const auto selectedFg = VNoteX::getInst().getThemeMgr().paletteColor("widgets#mainwindow#dockwidget_tabbar#icon#selected#fg");
|
||||||
|
|
||||||
const auto area = m_mainWindow->dockWidgetArea(m_docks[p_dockIndex]);
|
const auto area = m_mainWindow->dockWidgetArea(m_docks[p_dockIndex]);
|
||||||
const int newAngle = rotationAngle(area);
|
const int newAngle = rotationAngle(area);
|
||||||
if (m_dockIcons[p_dockIndex].m_rotationAngle != newAngle && area != Qt::NoDockWidgetArea) {
|
if (m_dockIcons[p_dockIndex].m_rotationAngle != newAngle && area != Qt::NoDockWidgetArea) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user