From dbd9e71d4434acd34cce45d362f61c3461c56661 Mon Sep 17 00:00:00 2001 From: Matthias Metelka <62722460+kleinerpirat@users.noreply.github.com> Date: Sat, 5 Nov 2022 02:11:32 +0100 Subject: [PATCH] Adjust QTableWidget stylesheet (#2183) * Center table headers by giving the arrow a negative margin equal to its width. * Prevent overlap with arrow for small headers (largely) I didn't want to go all out and make the right padding equal to the width of the arrow, because it would cut off the text too early on sections that aren't active. * Hide vertical table header on Windows too * Remove margin between toolbars in main view Didn't want to create a separate PR for such a minor change. * Create better borders for QTableWidget * Remove unused import * Improve RTL appearance of table --- qt/aqt/browser/table/table.py | 6 ++---- qt/aqt/data/web/css/toolbar.scss | 1 + qt/aqt/stylesheets.py | 10 ++++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/qt/aqt/browser/table/table.py b/qt/aqt/browser/table/table.py index 6ca9b256a..242f7a027 100644 --- a/qt/aqt/browser/table/table.py +++ b/qt/aqt/browser/table/table.py @@ -11,7 +11,6 @@ from anki.cards import Card, CardId from anki.collection import Collection, Config, OpChanges from anki.consts import * from anki.notes import Note, NoteId -from anki.utils import is_win from aqt import gui_hooks from aqt.browser.table import Columns, ItemId, SearchContext from aqt.browser.table.model import DataModel @@ -367,9 +366,8 @@ class Table: def _setup_headers(self) -> None: vh = self._view.verticalHeader() hh = self._view.horizontalHeader() - if not is_win: - vh.hide() - hh.show() + vh.hide() + hh.show() hh.setHighlightSections(False) hh.setMinimumSectionSize(50) hh.setSectionsMovable(True) diff --git a/qt/aqt/data/web/css/toolbar.scss b/qt/aqt/data/web/css/toolbar.scss index 15bc409e3..301b0ec45 100644 --- a/qt/aqt/data/web/css/toolbar.scss +++ b/qt/aqt/data/web/css/toolbar.scss @@ -8,6 +8,7 @@ #header { padding-bottom: 4px; + margin-top: -3px; } .tdcenter { diff --git a/qt/aqt/stylesheets.py b/qt/aqt/stylesheets.py index ffd0c5b8a..f022a5faa 100644 --- a/qt/aqt/stylesheets.py +++ b/qt/aqt/stylesheets.py @@ -264,6 +264,10 @@ def table_styles(tm: ThemeManager) -> str: return f""" QTableView {{ border-radius: {tm.var(props.BORDER_RADIUS)}; + border-{tm.left()}: 1px solid {tm.var(colors.BORDER_SUBTLE)}; + border-bottom: 1px solid {tm.var(colors.BORDER_SUBTLE)}; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; gridline-color: {tm.var(colors.BORDER_SUBTLE)}; selection-background-color: {tm.var(colors.SELECTED_BG)}; selection-color: {tm.var(colors.SELECTED_FG)}; @@ -272,9 +276,14 @@ QHeaderView {{ background: {tm.var(colors.CANVAS)}; }} QHeaderView::section {{ + padding-{tm.left()}: 0px; + padding-{tm.right()}: 15px; border: 1px solid {tm.var(colors.BORDER_SUBTLE)}; background: {tm.var(colors.BUTTON_BG)}; }} +QHeaderView::section:first {{ + margin-left: -1px; +}} QHeaderView::section:pressed, QHeaderView::section:pressed:!first {{ border: 1px solid {tm.var(colors.BORDER_STRONG)}; @@ -315,6 +324,7 @@ QHeaderView::up-arrow, QHeaderView::down-arrow {{ width: 20px; height: 20px; + margin-{tm.left()}: -20px; }} QHeaderView::up-arrow {{ image: url({tm.themed_icon("mdi:menu-up")});