Cheatsheet improvements

This commit is contained in:
Olivier Keshavjee 2016-02-08 10:52:25 +01:00
parent c7a4ae6072
commit 4d7d54aef8
3 changed files with 13 additions and 3 deletions

View file

@ -10,6 +10,7 @@ from manuskript.functions import lightBlue
from manuskript.functions import mainWindow
from manuskript.ui.cheatSheet_ui import Ui_cheatSheet
from manuskript.models import references as Ref
from manuskript.ui.editors.completer import completer
class cheatSheet(QWidget, Ui_cheatSheet):
@ -21,11 +22,13 @@ class cheatSheet(QWidget, Ui_cheatSheet):
self.splitter.setStretchFactor(0, 5)
self.splitter.setStretchFactor(1, 70)
self.txtFilter.textChanged.connect(self.textChanged)
self.txtFilter.textChanged.connect(self.updateListFromData)
self.txtFilter.returnPressed.connect(self.showInfos)
self.listDelegate = listCompleterDelegate(self)
self.list.setItemDelegate(self.listDelegate)
self.list.itemActivated.connect(self.showInfos)
self.list.hide()
self.list.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.view.linkActivated.connect(self.openLink)
self.view.linkHovered.connect(self.linkHovered)
@ -59,6 +62,12 @@ class cheatSheet(QWidget, Ui_cheatSheet):
self.populate()
def textChanged(self, text):
if not text:
self.list.hide()
else:
self.list.show()
def populate(self):
if self.persoModel:
d = []
@ -128,6 +137,7 @@ class cheatSheet(QWidget, Ui_cheatSheet):
self.list.setCurrentRow(1)
def showInfos(self):
self.list.hide()
i = self.list.currentItem()
ref = i.data(Qt.UserRole)
if ref:

View file

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'manuskript/ui/cheatSheet_ui.ui'
#
# Created: Mon Feb 8 10:28:58 2016
# Created: Mon Feb 8 10:48:00 2016
# by: PyQt5 UI code generator 5.2.1
#
# WARNING! All changes made in this file will be lost!
@ -74,5 +74,5 @@ class Ui_cheatSheet(object):
def retranslateUi(self, cheatSheet):
_translate = QtCore.QCoreApplication.translate
cheatSheet.setWindowTitle(_translate("cheatSheet", "Form"))
self.txtFilter.setPlaceholderText(_translate("cheatSheet", "Filter"))
self.txtFilter.setPlaceholderText(_translate("cheatSheet", "Filter (type the name of anything in your project)"))

View file

@ -35,7 +35,7 @@
<bool>false</bool>
</property>
<property name="placeholderText">
<string>Filter</string>
<string>Filter (type the name of anything in your project)</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>