diff --git a/src/resources/themes/v_detorte/v_detorte.qss b/src/resources/themes/v_detorte/v_detorte.qss index 8c814669..290c54aa 100644 --- a/src/resources/themes/v_detorte/v_detorte.qss +++ b/src/resources/themes/v_detorte/v_detorte.qss @@ -572,8 +572,6 @@ QLabel[TagLabel="true"] { padding-left: $5px; padding-right: $5px; color: @tab_indicator_tag_label_fg; - border-top-left-radius: $10px $8px; - border-bottom-left-radius: $10px $8px; background-color: @tab_indicator_tag_label_bg; } diff --git a/src/resources/themes/v_moonlight/v_moonlight.qss b/src/resources/themes/v_moonlight/v_moonlight.qss index 8d09975a..23e02e47 100644 --- a/src/resources/themes/v_moonlight/v_moonlight.qss +++ b/src/resources/themes/v_moonlight/v_moonlight.qss @@ -572,8 +572,6 @@ QLabel[TagLabel="true"] { padding-left: $5px; padding-right: $5px; color: @tab_indicator_tag_label_fg; - border-top-left-radius: $10px $8px; - border-bottom-left-radius: $10px $8px; background-color: @tab_indicator_tag_label_bg; } diff --git a/src/resources/themes/v_native/v_native.qss b/src/resources/themes/v_native/v_native.qss index 43a66ae3..83be9bcf 100644 --- a/src/resources/themes/v_native/v_native.qss +++ b/src/resources/themes/v_native/v_native.qss @@ -415,8 +415,6 @@ QLabel[TagLabel="true"] { padding-left: $5px; padding-right: $5px; color: @tab_indicator_tag_label_fg; - border-top-left-radius: $10px $8px; - border-bottom-left-radius: $10px $8px; background-color: @tab_indicator_tag_label_bg; } diff --git a/src/resources/themes/v_pure/v_pure.qss b/src/resources/themes/v_pure/v_pure.qss index 6791e389..568325dc 100644 --- a/src/resources/themes/v_pure/v_pure.qss +++ b/src/resources/themes/v_pure/v_pure.qss @@ -572,8 +572,6 @@ QLabel[TagLabel="true"] { padding-left: $5px; padding-right: $5px; color: @tab_indicator_tag_label_fg; - border-top-left-radius: $10px $8px; - border-bottom-left-radius: $10px $8px; background-color: @tab_indicator_tag_label_bg; } diff --git a/src/resources/vnote.ini b/src/resources/vnote.ini index 8bd82370..779cc764 100644 --- a/src/resources/vnote.ini +++ b/src/resources/vnote.ini @@ -242,6 +242,13 @@ image_name_prefix= ; 2 - VerticalMode panel_view_state=2 +; Max length of the text to display in tag label +; <= 0 indicates no limit to the length +max_tag_label_length=10 + +; Max number of tag labels to display +max_num_of_tag_labels=3 + [export] ; Path of the wkhtmltopdf tool wkhtmltopdf=wkhtmltopdf diff --git a/src/vconfigmanager.cpp b/src/vconfigmanager.cpp index 946b608e..fb8aa3a7 100644 --- a/src/vconfigmanager.cpp +++ b/src/vconfigmanager.cpp @@ -309,6 +309,12 @@ void VConfigManager::initialize() m_panelViewState = getConfigFromSettings("global", "panel_view_state").toInt(); + + m_maxTagLabelLength = getConfigFromSettings("global", + "max_tag_label_length").toInt(); + + m_maxNumOfTagLabels = getConfigFromSettings("global", + "max_num_of_tag_labels").toInt(); } void VConfigManager::initSettings() diff --git a/src/vconfigmanager.h b/src/vconfigmanager.h index 4ec9ed9f..148086b6 100644 --- a/src/vconfigmanager.h +++ b/src/vconfigmanager.h @@ -201,6 +201,10 @@ public: int getPanelViewState() const; void setPanelViewState(int p_state); + int getMaxTagLabelLength() const; + + int getMaxNumOfTagLabels() const; + bool getFindCaseSensitive() const; void setFindCaseSensitive(bool p_enabled); @@ -947,6 +951,12 @@ private: // State of MainWindow panel view. int m_panelViewState; + // Max length of the tag label text. + int m_maxTagLabelLength; + + // Max number of tag labels to display. + int m_maxNumOfTagLabels; + // The name of the config file in each directory. static const QString c_dirConfigFile; @@ -2475,4 +2485,14 @@ inline void VConfigManager::setPanelViewState(int p_state) m_panelViewState = p_state; setConfigToSettings("global", "panel_view_state", m_panelViewState); } + +inline int VConfigManager::getMaxTagLabelLength() const +{ + return m_maxTagLabelLength; +} + +inline int VConfigManager::getMaxNumOfTagLabels() const +{ + return m_maxNumOfTagLabels; +} #endif // VCONFIGMANAGER_H diff --git a/src/vtaglabel.cpp b/src/vtaglabel.cpp index a822b8ec..44afa631 100644 --- a/src/vtaglabel.cpp +++ b/src/vtaglabel.cpp @@ -3,8 +3,9 @@ #include #include "utils/viconutils.h" +#include "vconfigmanager.h" -#define MAX_DISPLAY_SIZE_PER_LABEL 5 +extern VConfigManager *g_config; VTagLabel::VTagLabel(const QString &p_text, bool p_useFullText, @@ -56,8 +57,9 @@ void VTagLabel::updateLabel() QString tag(m_text); if (!m_useFullText) { - if (tag.size() > MAX_DISPLAY_SIZE_PER_LABEL) { - tag.resize(MAX_DISPLAY_SIZE_PER_LABEL); + int ml = g_config->getMaxTagLabelLength(); + if (ml > 0 && tag.size() > ml) { + tag.resize(ml); tag += QStringLiteral("..."); } } diff --git a/src/vtagpanel.cpp b/src/vtagpanel.cpp index 4dda785a..e5e0cbb8 100644 --- a/src/vtagpanel.cpp +++ b/src/vtagpanel.cpp @@ -10,6 +10,7 @@ #include "vlineedit.h" #include "vmainwindow.h" #include "vnote.h" +#include "vconfigmanager.h" extern VPalette *g_palette; @@ -17,7 +18,7 @@ extern VMainWindow *g_mainWin; extern VNote *g_vnote; -#define MAX_DISPLAY_LABEL 3 +extern VConfigManager *g_config; VTagPanel::VTagPanel(QWidget *parent) : QWidget(parent), @@ -29,7 +30,8 @@ VTagPanel::VTagPanel(QWidget *parent) void VTagPanel::setupUI() { - for (int i = 0; i < MAX_DISPLAY_LABEL; ++i) { + const int maxNum = g_config->getMaxNumOfTagLabels(); + for (int i = 0; i < maxNum; ++i) { VTagLabel *label = new VTagLabel(this); connect(label, &VTagLabel::removalRequested, this, [this](const QString &p_text) { @@ -45,7 +47,7 @@ void VTagPanel::setupUI() this, [this](const QString &p_text) { removeTag(p_text); - if (m_file->getTags().size() <= MAX_DISPLAY_LABEL) { + if (m_file->getTags().size() <= g_config->getMaxNumOfTagLabels()) { // Hide the more panel. m_btn->hidePopupWidget(); m_btn->hide(); @@ -156,7 +158,7 @@ void VTagPanel::updateAllTagsPanel() m_tagsPanel->clear(); const QStringList &tags = m_file->getTags(); - for (int idx = MAX_DISPLAY_LABEL; idx < tags.size(); ++idx) { + for (int idx = g_config->getMaxNumOfTagLabels(); idx < tags.size(); ++idx) { m_tagsPanel->addTag(tags[idx]); } }