On Windows the following attempt gets close: it's all working (ie focussed
and unfocussed and font style) except for selected text not being drawn
in white.
However, it's a backward step for grep results:
- no monospace font for results (though I actually prefer the standard font)
- selected text not drawn in white.
Btw on Vista, the grep results don't render correctly with or without this
patch: selections there are done using a transparent overlay which I can't
yet persuade Qt to render for us. Diff between grep results and repo viewer
seems to be because former uses QTreeView and latter QTableView.
-- George
diff --git a/tortoisehg/hgqt/htmllistview.py b/tortoisehg/hgqt/htmllistview.py
--- a/tortoisehg/hgqt/htmllistview.py
+++ b/tortoisehg/hgqt/htmllistview.py
@@ -94,18 +94,15 @@
if self.cols and index.column() not in self.cols:
return QStyledItemDelegate.paint(self, painter, option, index)
text = index.model().data(index, Qt.DisplayRole).toString()
- palette = QApplication.palette()
+
+ # draw selection
+ option = QStyleOptionViewItemV4(option)
+ self.parent().style().drawControl(QStyle.CE_ItemViewItem, option, painter)
+
+ # draw text
doc = QTextDocument()
- doc.setDefaultFont(option.font)
- doc.setDefaultStyleSheet(qtlib.thgstylesheet)
painter.save()
- if option.state & QStyle.State_Selected:
- doc.setHtml('<font color=%s>%s</font>' % (
- palette.highlightedText().color().name(), text))
- bgcolor = palette.highlight().color()
- painter.fillRect(option.rect, bgcolor)
- else:
- doc.setHtml(text)
+ doc.setHtml(text)
painter.translate(option.rect.topLeft());
painter.setClipRect(option.rect.translated(-option.rect.topLeft()))
doc.drawContents(painter)
If anyone was willing to provide similar screenshots for other
platforms, that'd be much appreciated.
-- George
Looks much better on Linux as well, pushed.
The only side-effect that remains, near as I can tell, is that the
text is slightly lower than the other columns.
--
Steve Borho
On Mac OS X, same remark for the text alignement.
For the font size, it is good.
Screenshot attached
André
> even with my display settings at 125%
Johan - are you using the Win7 equivalent of Vista's DPI Scaling?
http://www.lawfirmsoftware.com/learning_center/howto/change_dpi_settings_vista.htm
More screenshots always welcome. Steve - could you do a Linux one perhaps?
-- George
Thanks for the screenshots guys. I'll keeping thinking/researching on
and off about the alignment and font size and grep problems, but I'm
not going to focus on it right now as it's just too depressing wading
through the Qt docs and code ;-) I hope that's ok.
Johan - are you using the Win7 equivalent of Vista's DPI Scaling?
> even with my display settings at 125%
http://www.lawfirmsoftware.com/learning_center/howto/change_dpi_settings_vista.htm
I think the font of the log column is smaller with 7dd3ffb36a69 compared
to 5592d07c28c3.
See attached screenshot, done with 5592d07c28c3 on Windows 7 (same
Windows install as before).
I do not have a custom DPI text size. In other words: my DPI should be
default (see DPI-Capture.PNG)
Nothing new here, just a couple more data points.
The attached is from xubuntu. Server 2003 looks almost exactly the same.
- selected text not drawn in white.
As a side-effect, tag text on selected row becomes hard to read.
Maybe we need to set foreground-color for it.
- the text is slightly lower than the other columns.
With this patch, log text will be placed *mostly* on the same line.
According to some experiments, there're difference in calculation
of text height between standard QTableView item and QTextDocument.
At least, it depends on font.
It works perfectly on Windows, but isn't on Linux.
Anyway it doesn't make things worse.
Yuya,
This makes hard to read selected tag text. Maybe tag text needs to set
foreground color explicitly.
diff --git a/tortoisehg/hgqt/htmllistview.py b/tortoisehg/hgqt/htmllistview.py
--- a/tortoisehg/hgqt/htmllistview.py
+++ b/tortoisehg/hgqt/htmllistview.py
@@ -107,7 +107,11 @@ class HTMLDelegate(QStyledItemDelegate):
painter.translate(QPointF(
option.rect.left(),
option.rect.top() + (option.rect.height() - doc.size().height()) / 2))
- doc.drawContents(painter)
+ ctx = QAbstractTextDocumentLayout.PaintContext()
+ if option.state & QStyle.State_Selected:
+ ctx.palette.setColor(QPalette.Text,
+ option.palette.color(QPalette.HighlightedText))
+ doc.documentLayout().draw(painter, ctx)
painter.restore()
def sizeHint(self, option, index):
diff --git a/tortoisehg/hgqt/htmllistview.py b/tortoisehg/hgqt/htmllistview.py
--- a/tortoisehg/hgqt/htmllistview.py
+++ b/tortoisehg/hgqt/htmllistview.py
@@ -104,7 +104,9 @@ class HTMLDelegate(QStyledItemDelegate):
painter.save()
doc.setHtml(text)
painter.setClipRect(option.rect)
- painter.translate(option.rect.topLeft())
+ painter.translate(QPointF(
+ option.rect.left(),
+ option.rect.top() + (option.rect.height() - doc.size().height()) / 2))
doc.drawContents(painter)
painter.restore()
Test passed on Mac, so I pushed as 4ccbe35696af and 9354c9fa9b25.
If you found strange behavior, could you report it?, please.
Yuya,
Looks fine on Linux here (Gnome on Ubuntu)
--
Steve Borho
Setting the foreground color of the tag format is trivial, just add
'black' to the log.tag style in qtlib.py (and do the same for
log.patch and log.branch while you are in there).
--
Steve Borho
Thanks. The first problem will be solved by Steve's suggestion.
Maybe I or somebody will post the patch later.
Second one, which Johan pointed out, looks hard. I didn't notice it because
in my environment, background color isn't changed on focus out.
I'd better look through it more deeply.
Ah, got it. 1fd72cc0e735 will fix the latter.
Yuya,
I went ahead and pushed the foreground label colors. Are we happy
with these results now? Looks good on Windows 7 here.
--
Steve Borho
Looks pretty good on Linux/KDE.
Thanks!
Does the attached patch make a difference?
If so, I'll tackle it more seriously.
Yuya,
And thanks from me too. On Vista the log now looks perfect whether selected or
unselected, focused or unfocused.
Unfortunately grep doesn't like right yet - see forthcoming screenshot. The issue is
that the part drawn by the delegate looks like it does in the log, but the part drawn
by the widget is more the native Vista look and feel - the transparent bar with slight
rounding is also used in Explorer for example. There's also an effect of paler
highlighting of the row that the mouse is hovering over.
The reason is that the log is a QTableView, but grep uses QTreeView. The following patch
changes grep to use QTableView. If people are happy with it, I'll tidy it up to size
columns correctly.
There's an unconnected bug with right click | View File - looking at that next.
-- George
On Vista QTreeView renders selections using Vista-style transparent
curved-effect bars. The QItemDelegate we use to draw the Match Text
column can't currently render these bars. So we switch to QTableView
which renders selections more simply.
diff --git a/tortoisehg/hgqt/grep.py b/tortoisehg/hgqt/grep.py
--- a/tortoisehg/hgqt/grep.py
+++ b/tortoisehg/hgqt/grep.py
@@ -119,8 +119,6 @@
mainvbox.addWidget(frame)
tv = MatchTree(repo, self)
- tv.setItemsExpandable(False)
- tv.setRootIsDecorated(False)
tm = MatchModel(self)
tv.setModel(tm)
tv.setColumnHidden(COL_REVISION, True)
@@ -342,14 +340,20 @@
COL_USER = 3 # Hidden if ctx
COL_TEXT = 4
-class MatchTree(QTreeView):
+class MatchTree(QTableView):
def __init__(self, repo, parent=None):
- QTreeView.__init__(self, parent)
+ QTableView.__init__(self, parent)
self.repo = repo
self.delegate = htmllistview.HTMLDelegate(self)
self.setItemDelegateForColumn(COL_TEXT, self.delegate)
- self.setSelectionMode(QTreeView.ExtendedSelection)
+ self.setSelectionMode(QTableView.ExtendedSelection)
+ self.setSelectionBehavior(QAbstractItemView.SelectRows)
self.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.setShowGrid(False)
+ vh = self.verticalHeader()
+ vh.hide()
+ vh.setDefaultSectionSize(20)
+
self.connect(self, SIGNAL('customContextMenuRequested(const QPoint &)'),
self.customContextMenuRequested)
self.pattern = None
@@ -383,17 +387,17 @@
def mousePressEvent(self, event):
self.pressPos = event.pos()
self.pressTime = QTime.currentTime()
- return QTreeView.mousePressEvent(self, event)
+ return QTableView.mousePressEvent(self, event)
def mouseMoveEvent(self, event):
d = event.pos() - self.pressPos
if d.manhattanLength() < QApplication.startDragDistance():
- return QTreeView.mouseMoveEvent(self, event)
+ return QTableView.mouseMoveEvent(self, event)
elapsed = self.pressTime.msecsTo(QTime.currentTime())
if elapsed < QApplication.startDragTime():
- return QTreeView.mouseMoveEvent(self, event)
+ return QTableView.mouseMoveEvent(self, event)
self.dragObject()
- return QTreeView.mouseMoveEvent(self, event)
+ return QTableView.mouseMoveEvent(self, event)
def customContextMenuRequested(self, point):
selrows = []
I'm not wed to a QTreeView by any means, feel free to use another
widget if it works better.
--
Steve Borho
This is an improvement, so pushed.
--
Steve Borho