[qt4] hide text area on heavy file

Related to #109862

The message that informs the user he can force displaying the file data is now really more visible.

How to test

hg --config hgview.maxfilesize=1 qv -I qt

Instead of the text widget that displays the diff you shall see a message with a link to bypass the file size checking.

authorAlain Leufroy <alain@leufroy.fr>
changeset18efa4102cd2
branchdefault
phasedraft
hiddenyes
parent revision#3e69744780c3 [qt4] add an intuitive link to display heavy files
child revision#ee2c0d7d1e05 [qt4] display "maxfilesize" config entry on big file
files modified by this revision
hgviewlib/qt4/hgfileview.py
# HG changeset patch
# User Alain Leufroy <alain@leufroy.fr>
# Date 1370648767 -7200
# Sat Jun 08 01:46:07 2013 +0200
# Node ID 18efa4102cd2d69a5c8f59909d75abaea247c92e
# Parent 3e69744780c3d18e6f016adb20e82f05bf947798
[qt4] hide text area on heavy file

Related to #109862

The message that informs the user he can force displaying the file
data is now really more visible.

.. admonition:: How to test

::

hg --config hgview.maxfilesize=1 qv -I qt

Instead of the text widget that displays the diff you shall see a
message with a link to bypass the file size checking.

diff --git a/hgviewlib/qt4/hgfileview.py b/hgviewlib/qt4/hgfileview.py
@@ -208,30 +208,34 @@
1          QtGui.QFrame.__init__(self, parent)
2          framelayout = QtGui.QVBoxLayout(self)
3          framelayout.setContentsMargins(0,0,0,0)
4          framelayout.setSpacing(0)
5 
6 -        l = QtGui.QHBoxLayout()
7 -        l.setContentsMargins(0,0,0,0)
8 -        l.setSpacing(0)
9 -
10 -        self.topLayout = QtGui.QVBoxLayout()
11 +        self.info_frame = QtGui.QFrame()
12 +        framelayout.addWidget(self.info_frame)
13 +        l = QtGui.QVBoxLayout()
14 +        self.info_frame.setLayout(l)
15          self.filenamelabel = QtGui.QLabel()
16          self.filenamelabel.setWordWrap(True)
17          self.filenamelabel.setTextInteractionFlags(
18              QtCore.Qt.TextSelectableByKeyboard|
19              QtCore.Qt.TextSelectableByMouse|
20              QtCore.Qt.LinksAccessibleByMouse)
21          self.filenamelabel.linkActivated.connect(
22              lambda link: self.displayFile(show_big_file=True))
23          self.execflaglabel = QtGui.QLabel()
24          self.execflaglabel.setWordWrap(True)
25 -        self.topLayout.addWidget(self.filenamelabel)
26 -        self.topLayout.addWidget(self.execflaglabel)
27 +        l.addWidget(self.filenamelabel)
28 +        l.addWidget(self.execflaglabel)
29          self.execflaglabel.hide()
30 -        framelayout.addLayout(self.topLayout)
31 -        framelayout.addLayout(l, 1)
32 +
33 +        self.filedata_frame = QtGui.QFrame()
34 +        framelayout.addWidget(self.filedata_frame)
35 +        l = QtGui.QHBoxLayout()
36 +        l.setContentsMargins(0,0,0,0)
37 +        l.setSpacing(0)
38 +        self.filedata_frame.setLayout(l)
39 
40          self.sci = HgQsci(self)
41          l.addWidget(self.sci, 1)
42 
43          ll = QtGui.QVBoxLayout()
@@ -371,14 +375,20 @@
44          if show_big_file:
45              flag, data = self._model.graph.filedata(filename, self._ctx.rev(), mode, maxfilesize=-1)
46          else:
47              flag, data = self._model.graph.filedata(filename, self._ctx.rev(), mode)
48          if flag == 'file too big':
49 +            self.filedata_frame.hide()
50              self.filenamelabel.setText(
51                  '%s %s' %
52 -                (data, '<a href="show-big-file">Click to display anyway <img src=":/icons/heavy_small.png" width="16" height="16" title="Display heavy file">.</a>'))
53 +                (data,
54 +                 ('<a href="show-big-file">Click to display anyway '
55 +                  '<img src=":/icons/heavy_small.png" '
56 +                  'width="16" height="16">.</a>')))
57              return
58 +        else:
59 +            self.filedata_frame.show()
60          if flag == '-':
61              return
62          if flag == '':
63              return
64