Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
ad05cb29
Commit
ad05cb29
authored
Apr 01, 2010
by
Thomas Hartmann
Browse files
QmlDesigner.propertyEditor: eliding for labels
parent
fed082ec
Changes
1
Show whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/components/propertyeditor/basicwidgets.cpp
View file @
ad05cb29
...
...
@@ -640,6 +640,28 @@ private:
QUrl
_url
;
};
class
ElidingLabel
:
public
QLabel
{
Q_OBJECT
public:
ElidingLabel
(
QWidget
*
parent
=
0
)
:
QLabel
(
parent
)
{}
protected:
void
paintEvent
(
QPaintEvent
*
event
)
{
QPainter
p
(
this
);
QFontMetrics
fm
(
font
());
if
(
fm
.
width
(
text
())
>
(
contentsRect
().
width
()
-
6
)
&&
text
().
length
()
>
4
)
{
QString
elided_txt
;
elided_txt
=
this
->
fontMetrics
().
elidedText
(
text
(),
Qt
::
ElideRight
,
rect
().
width
()
-
6
,
Qt
::
TextShowMnemonic
);
p
.
drawText
(
rect
().
adjusted
(
12
,
0
,
0
,
0
),
elided_txt
);
}
else
QLabel
::
paintEvent
(
event
);
}
};
class
QLabelDeclarativeUI
:
public
QObject
{
...
...
@@ -649,7 +671,7 @@ class QLabelDeclarativeUI : public QObject
public:
QLabelDeclarativeUI
(
QObject
*
parent
=
0
)
:
QObject
(
parent
)
{
lb
=
qobject_cast
<
Q
Label
*>
(
parent
);
lb
=
qobject_cast
<
Eliding
Label
*>
(
parent
);
}
private:
QUrl
iconFromFile
()
const
...
...
@@ -680,7 +702,7 @@ private:
}
Q
Label
*
lb
;
Eliding
Label
*
lb
;
QUrl
_url
;
};
...
...
@@ -1411,7 +1433,7 @@ void BasicWidgets::registerDeclarativeTypes()
qmlRegisterExtendedType
<
QTabWidget
,
QTabWidgetDeclarativeUI
>
(
"Bauhaus"
,
1
,
0
,
"QTabWidget"
);
qmlRegisterExtendedType
<
QScrollArea
,
QScrollAreaDeclarativeUI
>
(
"Bauhaus"
,
1
,
0
,
"QScrollArea"
);
qmlRegisterExtendedType
<
QPushButton
,
QPushButtonDeclarativeUI
>
(
"Bauhaus"
,
1
,
0
,
"QPushButton"
);
qmlRegisterExtendedType
<
Q
Label
,
QLabelDeclarativeUI
>
(
"Bauhaus"
,
1
,
0
,
"QLabel"
);
qmlRegisterExtendedType
<
Eliding
Label
,
QLabelDeclarativeUI
>
(
"Bauhaus"
,
1
,
0
,
"QLabel"
);
qmlRegisterExtendedType
<
QToolButton
,
QToolButtonDeclarativeUI
>
(
"Bauhaus"
,
1
,
0
,
"QToolButton"
);
qmlRegisterExtendedType
<
QComboBox
,
QComboBoxDeclarativeUI
>
(
"Bauhaus"
,
1
,
0
,
"QComboBox"
);
qmlRegisterExtendedType
<
QMenu
,
QMenuDeclarativeUI
>
(
"Bauhaus"
,
1
,
0
,
"QMenu"
);
...
...
Write
Preview
Supports
Markdown
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