Commit 066659e1 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Allow configuring sidebar icon size

Since its now like the plasma panel, some people might want
a smaller button, some larger.
parent 64beabdb
Pipeline #198069 passed with stage
in 8 minutes and 7 seconds
......@@ -159,6 +159,22 @@ void KateConfigDialog::addBehaviorPage()
m_showTextForLeftRightSidebars->setChecked(cgGeneral.readEntry("Show text for left and right sidebar", false));
connect(m_showTextForLeftRightSidebars, &QCheckBox::toggled, this, &KateConfigDialog::slotChanged);
vbox->addWidget(m_showTextForLeftRightSidebars);
label = new QLabel(i18n("Icon size for left and right sidebar buttons"), buttonGroup);
m_leftRightSidebarsIconSize = new QSpinBox(buttonGroup);
m_leftRightSidebarsIconSize->setMinimum(16);
m_leftRightSidebarsIconSize->setMaximum(48);
m_leftRightSidebarsIconSize->setValue(cgGeneral.readEntry("Icon size for left and right sidebar buttons", 32));
connect(m_leftRightSidebarsIconSize, &QSpinBox::textChanged, this, &KateConfigDialog::slotChanged);
hlayout = new QHBoxLayout;
hlayout->addWidget(label);
hlayout->addWidget(m_leftRightSidebarsIconSize);
vbox->addLayout(hlayout);
connect(m_showTextForLeftRightSidebars, &QCheckBox::toggled, this, [l = QPointer(label), this](bool v) {
m_leftRightSidebarsIconSize->setEnabled(!v);
l->setEnabled(!v);
});
}
buttonGroup->setLayout(vbox);
......@@ -433,6 +449,9 @@ void KateConfigDialog::slotApply()
if (m_showTextForLeftRightSidebars) {
cg.writeEntry("Show text for left and right sidebar", m_showTextForLeftRightSidebars->isChecked());
}
if (m_leftRightSidebarsIconSize) {
cg.writeEntry("Icon size for left and right sidebar buttons", m_leftRightSidebarsIconSize->value());
}
cg.writeEntry("Restore Window Configuration", sessionConfigUi.restoreVC->isChecked());
......
......@@ -91,6 +91,7 @@ private:
QComboBox *m_mouseForwardActions = nullptr;
QCheckBox *m_modNotifications;
QCheckBox *m_showTextForLeftRightSidebars = nullptr;
QSpinBox *m_leftRightSidebarsIconSize = nullptr;
QComboBox *m_cmbQuickOpenListMode;
QSpinBox *m_tabLimit;
QCheckBox *m_autoHideTabs;
......
......@@ -333,15 +333,29 @@ Sidebar::Sidebar(KMultiTabBar::KMultiTabBarPosition pos, MainWindow *mainwin, QW
void Sidebar::readConfig()
{
bool needsUpdate = false;
// shall we show text for the left and right bars?
KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup cgGeneral = KConfigGroup(config, "General");
const bool showTextForLeftRight = cgGeneral.readEntry("Show text for left and right sidebar", false);
if (showTextForLeftRight != m_showTextForLeftRight) {
m_showTextForLeftRight = showTextForLeftRight;
for (const auto &tabs : m_idToWidget) {
updateButtonStyle(tab(tabs.first));
}
needsUpdate = true;
}
int size = cgGeneral.readEntry("Icon size for left and right sidebar buttons", 32);
if (size != m_leftRightSidebarIconSize) {
m_leftRightSidebarIconSize = size;
needsUpdate = true;
}
if (!needsUpdate) {
return;
}
for (const auto &tabs : m_idToWidget) {
updateButtonStyle(tab(tabs.first));
}
}
......@@ -364,7 +378,7 @@ void Sidebar::updateButtonStyle(KMultiTabBarTab *button)
{
const auto originalText = button->property("kate_original_text").toString();
if (!m_showTextForLeftRight && (position() == KMultiTabBar::Left || position() == KMultiTabBar::Right)) {
const int iconSize = style()->pixelMetric(QStyle::PM_LargeIconSize, nullptr, this);
const int iconSize = m_leftRightSidebarIconSize;
button->setIconSize(QSize(iconSize, iconSize));
button->setText(QString());
button->setToolTip(originalText);
......
......@@ -293,6 +293,8 @@ private:
bool m_showTextForLeftRight = false;
int m_leftRightSidebarIconSize = 32;
Q_SIGNALS:
void sigShowPluginConfigPage(KTextEditor::Plugin *configpageinterface, int id);
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment