Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
ac074618
Commit
ac074618
authored
May 29, 2013
by
Dan Pascu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added text eliding using fading colors for labels with long texts
parent
cab1483e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
8 deletions
+37
-8
contacts.py
blink/contacts.py
+1
-2
labels.py
blink/widgets/labels.py
+17
-2
contact.ui
resources/contact.ui
+13
-3
contact_group.ui
resources/contact_group.ui
+6
-1
No files found.
blink/contacts.py
View file @
ac074618
...
@@ -1298,8 +1298,7 @@ class ContactDelegate(QStyledItemDelegate):
...
@@ -1298,8 +1298,7 @@ class ContactDelegate(QStyledItemDelegate):
else
:
else
:
widget
=
self
.
contact_oddline_widget
widget
=
self
.
contact_oddline_widget
item_size
=
option
.
rect
.
size
()
item_size
=
option
.
rect
.
size
()
if
widget
.
size
()
!=
item_size
:
widget
.
setFixedSize
(
item_size
)
widget
.
resize
(
item_size
)
widget
.
init_from_contact
(
contact
)
widget
.
init_from_contact
(
contact
)
painter
.
save
()
painter
.
save
()
...
...
blink/widgets/labels.py
View file @
ac074618
# Copyright (c) 2010 AG Projects. See LICENSE for details.
# Copyright (c) 2010 AG Projects. See LICENSE for details.
#
#
__all__
=
[
'DurationLabel'
,
'IconSelector'
,
'LatencyLabel'
,
'PacketLossLabel'
,
'Status'
,
'StatusLabel'
,
'StreamInfoLabel'
]
__all__
=
[
'DurationLabel'
,
'IconSelector'
,
'LatencyLabel'
,
'PacketLossLabel'
,
'Status'
,
'StatusLabel'
,
'StreamInfoLabel'
,
'ElidedLabel'
]
import
os
import
os
from
datetime
import
timedelta
from
datetime
import
timedelta
from
PyQt4.QtCore
import
Qt
from
PyQt4.QtCore
import
Qt
from
PyQt4.QtGui
import
Q
Color
,
QFileDialog
,
QFontMetrics
,
QLabel
,
QPalette
,
QPixmap
from
PyQt4.QtGui
import
Q
Brush
,
QColor
,
QFileDialog
,
QFontMetrics
,
QLabel
,
QLinearGradient
,
QPalette
,
QPainter
,
QPen
,
QPixmap
from
blink.resources
import
ApplicationData
,
Resources
from
blink.resources
import
ApplicationData
,
Resources
from
blink.widgets.util
import
QtDynamicProperty
from
blink.widgets.util
import
QtDynamicProperty
...
@@ -183,3 +183,18 @@ class StatusLabel(QLabel):
...
@@ -183,3 +183,18 @@ class StatusLabel(QLabel):
del
_get_value
,
_set_value
del
_get_value
,
_set_value
class
ElidedLabel
(
QLabel
):
"""A label that elides the text using a fading gradient"""
def
paintEvent
(
self
,
event
):
painter
=
QPainter
(
self
)
font_metrics
=
QFontMetrics
(
self
.
font
())
if
font_metrics
.
width
(
self
.
text
())
>
self
.
contentsRect
()
.
width
():
label_width
=
self
.
size
()
.
width
()
gradient
=
QLinearGradient
(
0
,
0
,
label_width
,
0
)
gradient
.
setColorAt
(
1
-
50.0
/
label_width
,
self
.
palette
()
.
color
(
self
.
foregroundRole
()))
gradient
.
setColorAt
(
1.0
,
Qt
.
transparent
)
painter
.
setPen
(
QPen
(
QBrush
(
gradient
),
1.0
))
painter
.
drawText
(
self
.
rect
(),
Qt
.
TextSingleLine
|
int
(
self
.
alignment
()),
self
.
text
())
resources/contact.ui
View file @
ac074618
...
@@ -117,8 +117,11 @@
...
@@ -117,8 +117,11 @@
<property
name=
"spacing"
>
<property
name=
"spacing"
>
<number>
0
</number>
<number>
0
</number>
</property>
</property>
<property
name=
"rightMargin"
>
<number>
8
</number>
</property>
<item>
<item>
<widget
class=
"
Q
Label"
name=
"name_label"
>
<widget
class=
"
Elided
Label"
name=
"name_label"
>
<property
name=
"sizePolicy"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Fixed"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<horstretch>
0
</horstretch>
...
@@ -131,7 +134,7 @@
...
@@ -131,7 +134,7 @@
</widget>
</widget>
</item>
</item>
<item>
<item>
<widget
class=
"
Q
Label"
name=
"info_label"
>
<widget
class=
"
Elided
Label"
name=
"info_label"
>
<property
name=
"sizePolicy"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Fixed"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<horstretch>
0
</horstretch>
...
@@ -139,7 +142,7 @@
...
@@ -139,7 +142,7 @@
</sizepolicy>
</sizepolicy>
</property>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
URI
</string>
<string>
Info
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
...
@@ -147,6 +150,13 @@
...
@@ -147,6 +150,13 @@
</item>
</item>
</layout>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>
ElidedLabel
</class>
<extends>
QLabel
</extends>
<header>
blink.widgets.labels
</header>
</customwidget>
</customwidgets>
<resources/>
<resources/>
<connections/>
<connections/>
</ui>
</ui>
resources/contact_group.ui
View file @
ac074618
...
@@ -68,7 +68,7 @@ border-width: 0;
...
@@ -68,7 +68,7 @@ border-width: 0;
<number>
0
</number>
<number>
0
</number>
</property>
</property>
<item>
<item>
<widget
class=
"
Q
Label"
name=
"name_label"
>
<widget
class=
"
Elided
Label"
name=
"name_label"
>
<property
name=
"sizePolicy"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Preferred"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Preferred"
>
<horstretch>
0
</horstretch>
<horstretch>
0
</horstretch>
...
@@ -220,6 +220,11 @@ border-color: #3278c8;
...
@@ -220,6 +220,11 @@ border-color: #3278c8;
<extends>
QLineEdit
</extends>
<extends>
QLineEdit
</extends>
<header>
blink.widgets.lineedit
</header>
<header>
blink.widgets.lineedit
</header>
</customwidget>
</customwidget>
<customwidget>
<class>
ElidedLabel
</class>
<extends>
QLabel
</extends>
<header>
blink.widgets.labels
</header>
</customwidget>
</customwidgets>
</customwidgets>
<resources/>
<resources/>
<connections/>
<connections/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment