[kde-doc-english] [kate] part: add option to hide view scrollbars ondemand

Michal Humpula michal.humpula at seznam.cz
Mon Nov 25 18:17:11 UTC 2013


Git commit 5c4bccf89aa487cb1c62614b5a153fd9db28d90b by Michal Humpula.
Committed on 23/11/2013 at 18:42.
Pushed by michalhumpula into branch 'master'.

add option to hide view scrollbars ondemand

in case she likes the gui minimal, let her choose
between hide always, never and on demand

REVIEW: 114057
GUI: new option in configuration Appearance->Borders->Scrollbars Visibility

M  +18   -0    part/dialogs/bordersappearanceconfigwidget.ui
M  +7    -0    part/dialogs/katedialogs.cpp
M  +26   -0    part/utils/kateconfig.cpp
M  +5    -0    part/utils/kateconfig.h
M  +12   -0    part/view/kateviewinternal.cpp

http://commits.kde.org/kate/5c4bccf89aa487cb1c62614b5a153fd9db28d90b

diff --git a/part/dialogs/bordersappearanceconfigwidget.ui b/part/dialogs/bordersappearanceconfigwidget.ui
index 608ffd1..39ee00d 100644
--- a/part/dialogs/bordersappearanceconfigwidget.ui
+++ b/part/dialogs/bordersappearanceconfigwidget.ui
@@ -149,6 +149,23 @@
         </layout>
        </widget>
       </item>
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <item>
+         <widget class="QLabel" name="lblShowScrollbars">
+          <property name="text">
+           <string>Scrollbars visibility:</string>
+          </property>
+          <property name="buddy">
+           <cstring>cmbShowScrollbars</cstring>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="KComboBox" name="cmbShowScrollbars"/>
+        </item>
+       </layout>
+      </item>
      </layout>
     </widget>
    </item>
@@ -215,6 +232,7 @@
   <tabstop>chkScrollbarMiniMap</tabstop>
   <tabstop>chkScrollbarMiniMapAll</tabstop>
   <tabstop>spBoxMiniMapWidth</tabstop>
+  <tabstop>cmbShowScrollbars</tabstop>
   <tabstop>rbSortBookmarksByCreation</tabstop>
   <tabstop>rbSortBookmarksByPosition</tabstop>
  </tabstops>
diff --git a/part/dialogs/katedialogs.cpp b/part/dialogs/katedialogs.cpp
index 25d6125..7af405f 100644
--- a/part/dialogs/katedialogs.cpp
+++ b/part/dialogs/katedialogs.cpp
@@ -778,6 +778,10 @@ KateViewDefaultsConfig::KateViewDefaultsConfig(QWidget *parent)
   textareaUi->cmbDynamicWordWrapIndicator->addItem( i18n("Follow Line Numbers") );
   textareaUi->cmbDynamicWordWrapIndicator->addItem( i18n("Always On") );
 
+  bordersUi->cmbShowScrollbars->addItem( i18n("When needed") );
+  bordersUi->cmbShowScrollbars->addItem( i18n("Always on") );
+  bordersUi->cmbShowScrollbars->addItem( i18n("Always off") );
+
   // hide power user mode if activated anyway
   if (!KateGlobal::self()->simpleMode ())
     textareaUi->chkDeveloperMode->hide ();
@@ -811,6 +815,7 @@ KateViewDefaultsConfig::KateViewDefaultsConfig(QWidget *parent)
   connect(bordersUi->chkShowFoldingMarkers, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
   connect(bordersUi->rbSortBookmarksByPosition, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
   connect(bordersUi->rbSortBookmarksByCreation, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
+  connect(bordersUi->cmbShowScrollbars, SIGNAL(activated(int)), this, SLOT(slotChanged()));
 }
 
 KateViewDefaultsConfig::~KateViewDefaultsConfig()
@@ -842,6 +847,7 @@ void KateViewDefaultsConfig::apply ()
   KateViewConfig::global()->setScrollBarMiniMapWidth (bordersUi->spBoxMiniMapWidth->value());
   KateViewConfig::global()->setFoldingBar (bordersUi->chkShowFoldingMarkers->isChecked());
   KateViewConfig::global()->setLineModification(bordersUi->chkShowLineModification->isChecked());
+  KateViewConfig::global()->setShowScrollbars( bordersUi->cmbShowScrollbars->currentIndex() );
 
   KateViewConfig::global()->setBookmarkSort (bordersUi->rbSortBookmarksByPosition->isChecked()?0:1);
   KateRendererConfig::global()->setShowIndentationLines(textareaUi->chkShowIndentationLines->isChecked());
@@ -881,6 +887,7 @@ void KateViewDefaultsConfig::reload ()
   bordersUi->chkShowLineModification->setChecked(KateViewConfig::global()->lineModification());
   bordersUi->rbSortBookmarksByPosition->setChecked(KateViewConfig::global()->bookmarkSort()==0);
   bordersUi->rbSortBookmarksByCreation->setChecked(KateViewConfig::global()->bookmarkSort()==1);
+  bordersUi->cmbShowScrollbars->setCurrentIndex( KateViewConfig::global()->showScrollbars() );
   textareaUi->chkShowIndentationLines->setChecked(KateRendererConfig::global()->showIndentationLines());
   textareaUi->chkShowWholeBracketExpression->setChecked(KateRendererConfig::global()->showWholeBracketExpression());
   textareaUi->chkAnimateBracketMatching->setChecked(KateRendererConfig::global()->animateBracketMatching());
diff --git a/part/utils/kateconfig.cpp b/part/utils/kateconfig.cpp
index 013d08f..e7b6736 100644
--- a/part/utils/kateconfig.cpp
+++ b/part/utils/kateconfig.cpp
@@ -1223,6 +1223,7 @@ namespace
   const char * const KEY_SCROLL_BAR_MINI_MAP = "Scroll Bar Mini Map";
   const char * const KEY_SCROLL_BAR_MINI_MAP_ALL = "Scroll Bar Mini Map All";
   const char * const KEY_SCROLL_BAR_MINI_MAP_WIDTH = "Scroll Bar Mini Map Width";
+  const char * const KEY_SHOW_SCROLLBARS = "Show Scrollbars";
   const char * const KEY_ICON_BAR = "Icon Bar";
   const char * const KEY_FOLDING_BAR = "Folding Bar";
   const char * const KEY_LINE_MODIFICATION = "Line Modification";
@@ -1262,6 +1263,8 @@ void KateViewConfig::readConfig ( const KConfigGroup &config)
 
   setScrollBarMiniMapWidth (config.readEntry( KEY_SCROLL_BAR_MINI_MAP_WIDTH,  60));
 
+  setShowScrollbars (config.readEntry( KEY_SHOW_SCROLLBARS,  1));
+
   setIconBar (config.readEntry( KEY_ICON_BAR, false ));
 
   setFoldingBar (config.readEntry( KEY_FOLDING_BAR, true));
@@ -1322,6 +1325,8 @@ void KateViewConfig::writeConfig (KConfigGroup &config)
 
   config.writeEntry( KEY_SCROLL_BAR_MINI_MAP_WIDTH, scrollBarMiniMapWidth() );
 
+  config.writeEntry( KEY_SHOW_SCROLLBARS, showScrollbars() );
+
   config.writeEntry( KEY_ICON_BAR, iconBar() );
 
   config.writeEntry( KEY_FOLDING_BAR, foldingBar() );
@@ -1549,6 +1554,27 @@ void KateViewConfig::setScrollBarMiniMapWidth (int width)
   configEnd ();
 }
 
+int KateViewConfig::showScrollbars() const
+{
+  if (m_showScrollbarsSet || isGlobal())
+    return m_showScrollbars;
+
+  return s_global->showScrollbars();
+}
+
+void KateViewConfig::setShowScrollbars(int mode)
+{
+  if (m_dynWordWrapIndicatorsSet && m_showScrollbars == mode)
+    return;
+
+  configStart ();
+
+  m_showScrollbarsSet = true;
+  m_showScrollbars = qBound(0, mode, 80);
+
+  configEnd ();
+}
+
 bool KateViewConfig::iconBar () const
 {
   if (m_iconBarSet || isGlobal())
diff --git a/part/utils/kateconfig.h b/part/utils/kateconfig.h
index 3be3a87..2e35edc 100644
--- a/part/utils/kateconfig.h
+++ b/part/utils/kateconfig.h
@@ -442,6 +442,9 @@ class KATEPART_TESTS_EXPORT KateViewConfig : public KateConfig
     int scrollBarMiniMapWidth () const;
     void setScrollBarMiniMapWidth (int width);
 
+    int showScrollbars () const;
+    void setShowScrollbars (int mode);
+
     bool iconBar () const;
     void setIconBar (bool on);
 
@@ -535,6 +538,7 @@ class KATEPART_TESTS_EXPORT KateViewConfig : public KateConfig
     bool m_scrollBarMiniMap;
     bool m_scrollBarMiniMapAll;
     int  m_scrollBarMiniMapWidth;
+    int  m_showScrollbars;
     bool m_iconBar;
     bool m_foldingBar;
     bool m_lineModification;
@@ -564,6 +568,7 @@ class KATEPART_TESTS_EXPORT KateViewConfig : public KateConfig
     bool m_scrollBarMiniMapSet : 1;
     bool m_scrollBarMiniMapAllSet : 1;
     bool m_scrollBarMiniMapWidthSet : 1;
+    bool m_showScrollbarsSet : 1;
     bool m_iconBarSet : 1;
     bool m_foldingBarSet : 1;
     bool m_lineModificationSet : 1;
diff --git a/part/view/kateviewinternal.cpp b/part/view/kateviewinternal.cpp
index e7648ab..285262d 100644
--- a/part/view/kateviewinternal.cpp
+++ b/part/view/kateviewinternal.cpp
@@ -567,6 +567,12 @@ void KateViewInternal::doUpdateView(bool changed, int viewLinesScrolled)
   m_lineScroll->setPageStep(qMax (0, height()) / renderer()->lineHeight());
   m_lineScroll->blockSignals(blocked);
 
+  const int show_scrollbars = view()->config()->showScrollbars();
+
+  bool visible = show_scrollbars == 1 || (show_scrollbars == 0 && maxLineScrollRange != 0);
+  bool visible_dummy = visible;
+  m_lineScroll->setVisible( visible );
+
   if (!m_view->dynWordWrap())
   {
     int max = maxLen(startLine()) - width();
@@ -584,6 +590,10 @@ void KateViewInternal::doUpdateView(bool changed, int viewLinesScrolled)
     // disable scrollbar
     m_columnScroll->setDisabled (max == 0);
 
+    visible = show_scrollbars == 1 || (show_scrollbars == 0 && max != 0);
+    visible_dummy &= visible;
+    m_columnScroll->setVisible( visible );
+
     m_columnScroll->setRange(0, max);
 
     m_columnScroll->setValue(m_startX);
@@ -595,6 +605,8 @@ void KateViewInternal::doUpdateView(bool changed, int viewLinesScrolled)
     m_columnScroll->blockSignals(blocked);
   }
 
+  m_dummy->setVisible( visible_dummy );
+
   if (m_smartDirty)
     m_smartDirty = false;
 


More information about the kde-doc-english mailing list