mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
render deck browser properly with large fonts
This commit is contained in:
parent
7ae0211d22
commit
5d0e64b3a3
2 changed files with 39 additions and 92 deletions
|
@ -981,6 +981,11 @@ your deck."""))
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def setupDeckBrowser(self):
|
def setupDeckBrowser(self):
|
||||||
|
self.decksScrollArea = QScrollArea()
|
||||||
|
self.decksScrollArea.setFrameStyle(QFrame.NoFrame)
|
||||||
|
self.decksScrollArea.setWidgetResizable(True)
|
||||||
|
self.mainWin.verticalLayout_14.insertWidget(2, self.decksScrollArea)
|
||||||
|
self.decksFrame = QFrame()
|
||||||
self.connect(self.mainWin.downloadDeckButton,
|
self.connect(self.mainWin.downloadDeckButton,
|
||||||
SIGNAL("clicked()"),
|
SIGNAL("clicked()"),
|
||||||
self.onGetSharedDeck)
|
self.onGetSharedDeck)
|
||||||
|
@ -1052,11 +1057,10 @@ your deck."""))
|
||||||
def showDeckBrowser(self):
|
def showDeckBrowser(self):
|
||||||
import sip
|
import sip
|
||||||
focusButton = None
|
focusButton = None
|
||||||
self.switchToDecksScreen()
|
|
||||||
# remove all widgets from layout & layout itself
|
# remove all widgets from layout & layout itself
|
||||||
if self.mainWin.decksFrame.layout():
|
if self.decksFrame.layout():
|
||||||
while 1:
|
while 1:
|
||||||
obj = self.mainWin.decksFrame.layout().takeAt(0)
|
obj = self.decksFrame.layout().takeAt(0)
|
||||||
if not obj:
|
if not obj:
|
||||||
break
|
break
|
||||||
if "QLabel" in repr(obj.widget()):
|
if "QLabel" in repr(obj.widget()):
|
||||||
|
@ -1065,9 +1069,10 @@ your deck."""))
|
||||||
if obj.widget():
|
if obj.widget():
|
||||||
obj.widget().deleteLater()
|
obj.widget().deleteLater()
|
||||||
sip.delete(obj)
|
sip.delete(obj)
|
||||||
sip.delete(self.mainWin.decksFrame.layout())
|
sip.delete(self.decksFrame.layout())
|
||||||
# build new layout
|
# build new layout
|
||||||
layout = QGridLayout()
|
layout = QGridLayout()
|
||||||
|
self.decksFrame.setLayout(layout)
|
||||||
if sys.platform.startswith("darwin"):
|
if sys.platform.startswith("darwin"):
|
||||||
layout.setSpacing(6)
|
layout.setSpacing(6)
|
||||||
else:
|
else:
|
||||||
|
@ -1083,9 +1088,11 @@ your deck."""))
|
||||||
l = QLabel(_("<b>Due<br>Today</b>"))
|
l = QLabel(_("<b>Due<br>Today</b>"))
|
||||||
l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
||||||
layout.addWidget(l, 0, 1)
|
layout.addWidget(l, 0, 1)
|
||||||
|
layout.setColumnMinimumWidth(2, 10)
|
||||||
l = QLabel(_("<b>New<br>Today</b>"))
|
l = QLabel(_("<b>New<br>Today</b>"))
|
||||||
l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
||||||
layout.addWidget(l, 0, 2)
|
layout.addWidget(l, 0, 3)
|
||||||
|
layout.setColumnMinimumWidth(4, 10)
|
||||||
for c, deck in enumerate(self.browserDecks):
|
for c, deck in enumerate(self.browserDecks):
|
||||||
# name
|
# name
|
||||||
n = deck['name']
|
n = deck['name']
|
||||||
|
@ -1104,7 +1111,6 @@ your deck."""))
|
||||||
else:
|
else:
|
||||||
s = ""
|
s = ""
|
||||||
l = QLabel(s)
|
l = QLabel(s)
|
||||||
l.setMinimumWidth(50)
|
|
||||||
l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
||||||
layout.addWidget(l, c+1, 1)
|
layout.addWidget(l, c+1, 1)
|
||||||
# new
|
# new
|
||||||
|
@ -1113,10 +1119,8 @@ your deck."""))
|
||||||
else:
|
else:
|
||||||
s = ""
|
s = ""
|
||||||
l = QLabel(s)
|
l = QLabel(s)
|
||||||
l.setMargin(10)
|
|
||||||
l.setMinimumWidth(50)
|
|
||||||
l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
||||||
layout.addWidget(l, c+1, 2)
|
layout.addWidget(l, c+1, 3)
|
||||||
# open
|
# open
|
||||||
openButton = QPushButton(_("Open"))
|
openButton = QPushButton(_("Open"))
|
||||||
if c < 9:
|
if c < 9:
|
||||||
|
@ -1131,7 +1135,7 @@ your deck."""))
|
||||||
openButton.setToolTip(_("Open this deck%s") % extra)
|
openButton.setToolTip(_("Open this deck%s") % extra)
|
||||||
self.connect(openButton, SIGNAL("clicked()"),
|
self.connect(openButton, SIGNAL("clicked()"),
|
||||||
lambda d=deck['path']: self.loadDeck(d))
|
lambda d=deck['path']: self.loadDeck(d))
|
||||||
layout.addWidget(openButton, c+1, 3)
|
layout.addWidget(openButton, c+1, 5)
|
||||||
if c == 0:
|
if c == 0:
|
||||||
focusButton = openButton
|
focusButton = openButton
|
||||||
# more
|
# more
|
||||||
|
@ -1149,17 +1153,17 @@ your deck."""))
|
||||||
_("Forget removes the deck from the list without deleting."))
|
_("Forget removes the deck from the list without deleting."))
|
||||||
self.connect(moreButton, SIGNAL("currentIndexChanged(int)"),
|
self.connect(moreButton, SIGNAL("currentIndexChanged(int)"),
|
||||||
lambda idx, c=c: self.onDeckBrowserMore(idx, c))
|
lambda idx, c=c: self.onDeckBrowserMore(idx, c))
|
||||||
layout.addWidget(moreButton, c+1, 4)
|
layout.addWidget(moreButton, c+1, 6)
|
||||||
refresh = QPushButton(_("Refresh"))
|
refresh = QPushButton(_("Refresh"))
|
||||||
refresh.setToolTip(_("Check due counts again (Ctrl+Shift+r)"))
|
refresh.setToolTip(_("Check due counts again (Ctrl+Shift+r)"))
|
||||||
refresh.setShortcut(_("Ctrl+Shift+r"))
|
refresh.setShortcut(_("Ctrl+Shift+r"))
|
||||||
self.connect(refresh, SIGNAL("clicked()"),
|
self.connect(refresh, SIGNAL("clicked()"),
|
||||||
self.forceBrowserRefresh)
|
self.forceBrowserRefresh)
|
||||||
layout.addWidget(refresh, c+2, 3)
|
layout.addWidget(refresh, c+2, 5)
|
||||||
# make sure top labels don't expand
|
# make sure top labels don't expand
|
||||||
layout.addItem(QSpacerItem(1,1, QSizePolicy.Expanding,
|
layout.addItem(QSpacerItem(1,1, QSizePolicy.Expanding,
|
||||||
QSizePolicy.Expanding),
|
QSizePolicy.Expanding),
|
||||||
c+3, 4)
|
c+3, 5)
|
||||||
else:
|
else:
|
||||||
l = QLabel(_("""\
|
l = QLabel(_("""\
|
||||||
<br>
|
<br>
|
||||||
|
@ -1171,9 +1175,11 @@ later by clicking on the left-pointing arrow on the toolbar.
|
||||||
"""))
|
"""))
|
||||||
l.setWordWrap(True)
|
l.setWordWrap(True)
|
||||||
layout.addWidget(l, 0, 0)
|
layout.addWidget(l, 0, 0)
|
||||||
self.mainWin.decksFrame.setLayout(layout)
|
self.decksScrollArea.setWidget(self.decksFrame)
|
||||||
if focusButton:
|
if focusButton:
|
||||||
focusButton.setFocus()
|
focusButton.setFocus()
|
||||||
|
# do this last
|
||||||
|
self.switchToDecksScreen()
|
||||||
|
|
||||||
def onDeckBrowserMore(self, idx, c):
|
def onDeckBrowserMore(self, idx, c):
|
||||||
if idx == 0:
|
if idx == 0:
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>715</width>
|
<width>689</width>
|
||||||
<height>499</height>
|
<height>655</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -1095,7 +1095,7 @@
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>20</height>
|
<height>10</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
@ -1107,9 +1107,12 @@
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>1</width>
|
<width>10</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
@ -1118,21 +1121,15 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="deckBrowserOuterFrame">
|
<widget class="QFrame" name="deckBrowserOuterFrame">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
<horstretch>10</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>10</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>200</width>
|
||||||
<height>250</height>
|
<height>200</height>
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>450</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
|
@ -1161,65 +1158,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QScrollArea" name="decksScrollArea">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="horizontalScrollBarPolicy">
|
|
||||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
|
||||||
</property>
|
|
||||||
<property name="widgetResizable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>392</width>
|
|
||||||
<height>183</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_18">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QFrame" name="decksFrame">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_4">
|
<widget class="Line" name="line_4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -1304,9 +1242,12 @@
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>1</width>
|
<width>10</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
@ -1325,7 +1266,7 @@
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>20</height>
|
<height>10</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
@ -1531,8 +1472,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>715</width>
|
<width>689</width>
|
||||||
<height>23</height>
|
<height>36</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuHelp">
|
<widget class="QMenu" name="menuHelp">
|
||||||
|
|
Loading…
Reference in a new issue