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
This commit is contained in:
Matthias Metelka 2022-11-05 02:11:32 +01:00 committed by GitHub
parent 96381f3f2c
commit dbd9e71d44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View file

@ -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)

View file

@ -8,6 +8,7 @@
#header {
padding-bottom: 4px;
margin-top: -3px;
}
.tdcenter {

View file

@ -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")});