Merge pull request #931 from javierrodriguezcuevas/feature/status_widget_options
* status_widget_options: prefs: reword descriptions for status indent and counts status: refactor headers totals doc: added new status options status: refactor option status: fixed code style status: refactor positive condition widget: Added indentation and total options Signed-off-by: David Aguilar <davvid@gmail.com>
This commit is contained in:
@@ -30,6 +30,8 @@ MERGETOOL = 'merge.tool'
|
||||
EXPANDTAB = 'cola.expandtab'
|
||||
SAVEWINDOWSETTINGS = 'cola.savewindowsettings'
|
||||
SORT_BOOKMARKS = 'cola.sortbookmarks'
|
||||
STATUS_INDENT = 'cola.statusindent'
|
||||
STATUS_SHOW_TOTALS = 'cola.statusshowtotals'
|
||||
TABWIDTH = 'cola.tabwidth'
|
||||
TEXTWIDTH = 'cola.textwidth'
|
||||
USER_EMAIL = 'user.email'
|
||||
@@ -70,6 +72,8 @@ class Defaults(object):
|
||||
textwidth = 72
|
||||
theme = 'default'
|
||||
hidpi = hidpi.EChoice.AUTO
|
||||
status_indent = False
|
||||
status_show_totals = False
|
||||
|
||||
|
||||
def blame_viewer(context):
|
||||
@@ -161,6 +165,15 @@ def textwidth(context):
|
||||
return context.cfg.get(TEXTWIDTH, default=Defaults.textwidth)
|
||||
|
||||
|
||||
def status_indent(context):
|
||||
return context.cfg.get(STATUS_INDENT, default=Defaults.status_indent)
|
||||
|
||||
|
||||
def status_show_totals(context):
|
||||
return context.cfg.get(STATUS_SHOW_TOTALS,
|
||||
default=Defaults.status_show_totals)
|
||||
|
||||
|
||||
class PreferencesModel(observable.Observable):
|
||||
message_config_updated = 'config_updated'
|
||||
|
||||
|
||||
@@ -193,6 +193,8 @@ class SettingsFormWidget(FormWidget):
|
||||
self.save_window_settings = qtutils.checkbox()
|
||||
self.check_spelling = qtutils.checkbox()
|
||||
self.expandtab = qtutils.checkbox()
|
||||
self.status_indent = qtutils.checkbox()
|
||||
self.status_show_totals = qtutils.checkbox()
|
||||
|
||||
self.add_row(N_('Fixed-Width Font'), self.fixed_font)
|
||||
self.add_row(N_('Font Size'), self.font_size)
|
||||
@@ -210,6 +212,10 @@ class SettingsFormWidget(FormWidget):
|
||||
'(restart required)'), self.bold_headers)
|
||||
self.add_row(N_('Save GUI Settings'), self.save_window_settings)
|
||||
self.add_row(N_('Check spelling'), self.check_spelling)
|
||||
self.add_row(N_('Indent Status paths '
|
||||
'(restart required)'), self.status_indent)
|
||||
self.add_row(N_('Show file counts in Status titles '
|
||||
'(restart required)'), self.status_show_totals)
|
||||
|
||||
self.set_config({
|
||||
prefs.SAVEWINDOWSETTINGS:
|
||||
@@ -232,6 +238,9 @@ class SettingsFormWidget(FormWidget):
|
||||
(self.keep_merge_backups, Defaults.merge_keep_backup),
|
||||
prefs.MERGETOOL: (self.mergetool, Defaults.mergetool),
|
||||
prefs.SPELL_CHECK: (self.check_spelling, Defaults.spellcheck),
|
||||
prefs.STATUS_INDENT: (self.status_indent, Defaults.status_indent),
|
||||
prefs.STATUS_SHOW_TOTALS:
|
||||
(self.status_show_totals, Defaults.status_show_totals)
|
||||
})
|
||||
|
||||
self.fixed_font.currentFontChanged.connect(self.current_font_changed)
|
||||
|
||||
+11
-6
@@ -120,10 +120,12 @@ class StatusTreeWidget(QtWidgets.QTreeWidget):
|
||||
self.setUniformRowHeights(True)
|
||||
self.setAnimated(True)
|
||||
self.setRootIsDecorated(False)
|
||||
self.setIndentation(0)
|
||||
self.setDragEnabled(True)
|
||||
self.setAutoScroll(False)
|
||||
|
||||
if not prefs.status_indent(context):
|
||||
self.setIndentation(0)
|
||||
|
||||
ok = icons.ok()
|
||||
compare = icons.compare()
|
||||
question = icons.question()
|
||||
@@ -482,25 +484,26 @@ class StatusTreeWidget(QtWidgets.QTreeWidget):
|
||||
|
||||
def _set_staged(self, items):
|
||||
"""Adds items to the 'Staged' subtree."""
|
||||
self._set_subtree(items, self.idx_staged, staged=True,
|
||||
self._set_subtree(items, self.idx_staged, N_('Staged'), staged=True,
|
||||
deleted_set=self.m.staged_deleted)
|
||||
|
||||
def _set_modified(self, items):
|
||||
"""Adds items to the 'Modified' subtree."""
|
||||
self._set_subtree(items, self.idx_modified,
|
||||
self._set_subtree(items, self.idx_modified, N_('Modified'),
|
||||
deleted_set=self.m.unstaged_deleted)
|
||||
|
||||
def _set_unmerged(self, items):
|
||||
"""Adds items to the 'Unmerged' subtree."""
|
||||
deleted_set = set([path for path in items if not core.exists(path)])
|
||||
self._set_subtree(items, self.idx_unmerged,
|
||||
self._set_subtree(items, self.idx_unmerged, N_('Unmerged'),
|
||||
deleted_set=deleted_set)
|
||||
|
||||
def _set_untracked(self, items):
|
||||
"""Adds items to the 'Untracked' subtree."""
|
||||
self._set_subtree(items, self.idx_untracked, untracked=True)
|
||||
self._set_subtree(items, self.idx_untracked, N_('Untracked'),
|
||||
untracked=True)
|
||||
|
||||
def _set_subtree(self, items, idx,
|
||||
def _set_subtree(self, items, idx, parent_title,
|
||||
staged=False,
|
||||
untracked=False,
|
||||
deleted_set=None):
|
||||
@@ -524,6 +527,8 @@ class StatusTreeWidget(QtWidgets.QTreeWidget):
|
||||
parent.addChild(treeitem)
|
||||
self._expand_items(idx, items)
|
||||
self.blockSignals(False)
|
||||
if prefs.status_show_totals(self.context):
|
||||
parent.setText(0, '%s (%s)' % (parent_title, len(items)))
|
||||
|
||||
def _update_column_widths(self):
|
||||
self.resizeColumnToContents(0)
|
||||
|
||||
@@ -590,6 +590,17 @@ cola.signcommits
|
||||
`git cola` will sign commits by default when set `true`. Defaults to `false`.
|
||||
See the section below on setting up GPG for more details.
|
||||
|
||||
cola.statusindent
|
||||
-----------------
|
||||
Set to `true` to indent files in the Status widget. Files in the `Staged`,
|
||||
`Modified`, etc. categories will be grouped in a tree-like structure.
|
||||
Defaults to `false`.
|
||||
|
||||
cola.statusshowtotals
|
||||
---------------------
|
||||
Set to `true` to display files counts in the Status widget's category titles.
|
||||
Defaults to `false`.
|
||||
|
||||
cola.tabwidth
|
||||
-------------
|
||||
The number of columns occupied by a tab character. Defaults to 8.
|
||||
|
||||
Reference in New Issue
Block a user