summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/declarative/calculator/calculator.qml4
-rw-r--r--demos/declarative/flickr/content/ImageDetails.qml2
-rw-r--r--demos/declarative/flickr/flickr.qml2
-rw-r--r--demos/declarative/flickr/flickr2.qml2
-rw-r--r--demos/declarative/samegame/SameGame.qml2
-rw-r--r--demos/declarative/samegame/content/Button.qml2
-rw-r--r--demos/declarative/webbrowser/webbrowser.qml4
-rw-r--r--doc/src/declarative/basictypes.qdoc4
-rw-r--r--doc/src/declarative/qmlforcpp.qdoc2
-rw-r--r--doc/src/declarative/tutorial1.qdoc6
-rw-r--r--doc/src/declarative/tutorial2.qdoc2
-rw-r--r--doc/src/declarative/tutorial3.qdoc2
-rw-r--r--examples/declarative/fillmode/fillmode.qml2
-rw-r--r--examples/declarative/fonts/fonts.qml10
-rw-r--r--examples/declarative/listview/recipes.qml6
-rw-r--r--examples/declarative/loader/Browser.qml2
-rw-r--r--examples/declarative/loader/Button.qml2
-rw-r--r--examples/declarative/minehunt/minehunt.qml2
-rw-r--r--examples/declarative/tutorials/helloworld/t1/tutorial1.qml2
-rw-r--r--examples/declarative/tutorials/helloworld/t2/tutorial2.qml2
-rw-r--r--examples/declarative/tutorials/helloworld/t3/tutorial3.qml2
-rw-r--r--examples/declarative/velocity/Day.qml4
-rw-r--r--examples/declarative/xmldata/yahoonews.qml2
-rw-r--r--src/declarative/fx/qfxlineedit.cpp22
-rw-r--r--src/declarative/fx/qfxlineedit.h6
-rw-r--r--src/declarative/fx/qfxlineedit_p.h4
-rw-r--r--src/declarative/fx/qfxtext.cpp38
-rw-r--r--src/declarative/fx/qfxtext.h11
-rw-r--r--src/declarative/fx/qfxtext_p.h23
-rw-r--r--src/declarative/fx/qfxtextedit.cpp43
-rw-r--r--src/declarative/fx/qfxtextedit.h9
-rw-r--r--src/declarative/fx/qfxtextedit_p.h4
-rw-r--r--src/declarative/util/qmlfont.cpp148
-rw-r--r--src/declarative/util/qmlfont.h93
-rw-r--r--src/declarative/util/util.pri2
35 files changed, 96 insertions, 377 deletions
diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml
index 42e1422..f766a30 100644
--- a/demos/declarative/calculator/calculator.qml
+++ b/demos/declarative/calculator/calculator.qml
@@ -17,7 +17,7 @@ Rect {
Text {
id: CurNum
- font.bold: true; font.size: 16
+ font.bold: true; font.pointSize: 16
color: Palette.text
anchors.right: Container.right
anchors.rightMargin: 5
@@ -27,7 +27,7 @@ Rect {
Text {
id: CurrentOperation
color: Palette.text
- font.bold: true; font.size: 16
+ font.bold: true; font.pointSize: 16
anchors.left: Container.left
anchors.leftMargin: 5
anchors.verticalCenter: Container.verticalCenter
diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml
index 0182d48..09d8f03 100644
--- a/demos/declarative/flickr/content/ImageDetails.qml
+++ b/demos/declarative/flickr/content/ImageDetails.qml
@@ -44,7 +44,7 @@ Flipable {
}
Text { id: TitleText; style: "Raised"; styleColor: "black"; color: "white"; elide: "ElideRight"
- x: 220; y: 30; width: parent.width - 240; text: Container.photoTitle; font.size: 22 }
+ x: 220; y: 30; width: parent.width - 240; text: Container.photoTitle; font.pointSize: 22 }
LikeOMeter { x: 40; y: 250; rating: Container.rating }
diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml
index 8e1e3e8..a8d18fb 100644
--- a/demos/declarative/flickr/flickr.qml
+++ b/demos/declarative/flickr/flickr.qml
@@ -206,6 +206,6 @@ Item {
id: CategoryText; anchors.horizontalCenter: parent.horizontalCenter; y: 15;
text: "Flickr - " +
(FeedModel.tags=="" ? "Uploads from everyone" : "Recent Uploads tagged " + FeedModel.tags)
- font.size: 20; font.bold: true; color: "white"; style: "Raised"; styleColor: "black"
+ font.pointSize: 20; font.bold: true; color: "white"; style: "Raised"; styleColor: "black"
}
}
diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml
index f3b4244..5350a36 100644
--- a/demos/declarative/flickr/flickr2.qml
+++ b/demos/declarative/flickr/flickr2.qml
@@ -256,6 +256,6 @@ Item {
id: CategoryText; anchors.horizontalCenter: parent.horizontalCenter; y: 15;
text: "Flickr - " +
(FeedModel.tags=="" ? "Uploads from everyone" : "Recent Uploads tagged " + FeedModel.tags)
- font.size: 16; font.bold: true; color: "white"; style: "Raised"; styleColor: "black"
+ font.pointSize: 16; font.bold: true; color: "white"; style: "Raised"; styleColor: "black"
}
}
diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml
index e74646d..42c313c 100644
--- a/demos/declarative/samegame/SameGame.qml
+++ b/demos/declarative/samegame/SameGame.qml
@@ -28,7 +28,7 @@ Rect {
anchors.top: gameCanvas.bottom; anchors.topMargin: 4; anchors.left: gameCanvas.left;
}
Text {
- text: "Score: " + gameCanvas.score; width:100; font.size:14
+ text: "Score: " + gameCanvas.score; width:100; font.pointSize:14
anchors.top: gameCanvas.bottom; anchors.topMargin: 4; anchors.right: gameCanvas.right;
}
}
diff --git a/demos/declarative/samegame/content/Button.qml b/demos/declarative/samegame/content/Button.qml
index c7a49f1..e3d0d30 100644
--- a/demos/declarative/samegame/content/Button.qml
+++ b/demos/declarative/samegame/content/Button.qml
@@ -13,6 +13,6 @@ Rect {
MouseRegion { id:mr; anchors.fill: parent; onClicked: page.clicked() }
Text {
id: txtItem; text: page.text; anchors.centerIn: page; color: activePalette.buttonText
- font.size: 14;
+ font.pointSize: 14;
}
}
diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml
index 73fedae..f57b7be 100644
--- a/demos/declarative/webbrowser/webbrowser.qml
+++ b/demos/declarative/webbrowser/webbrowser.qml
@@ -87,7 +87,7 @@ Item {
style: "Raised"
font.family: "Helvetica"
- font.size: 10
+ font.pointSize: 10
font.bold: true
anchors.left: Header.left
@@ -136,7 +136,7 @@ Item {
/*<<<<<<< HEAD:demos/declarative/webbrowser/webbrowser.qml
text: MyWebView.url == '' ? ' ' : MyWebView.url
wrap: false
- font.size: 11
+ font.pointSize: 11
color: "#555555"
focusOnPress: true
=======*/
diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc
index a22af0f..684fd0d 100644
--- a/doc/src/declarative/basictypes.qdoc
+++ b/doc/src/declarative/basictypes.qdoc
@@ -214,12 +214,12 @@
\o string font.family
\o bool font.bold
\o bool font.italic
- \o real font.size
+ \o real font.pointSize
\endlist
Setting a font looks like this:
\code
- Text { font.family: "Helvetica"; font.size: 13; font.bold: true }
+ Text { font.family: "Helvetica"; font.pointSize: 13; font.bold: true }
\endcode
\target basicqmlaction
diff --git a/doc/src/declarative/qmlforcpp.qdoc b/doc/src/declarative/qmlforcpp.qdoc
index 74357bb..53af252 100644
--- a/doc/src/declarative/qmlforcpp.qdoc
+++ b/doc/src/declarative/qmlforcpp.qdoc
@@ -161,7 +161,7 @@
\code
Text {
font.family: "helvetica"
- font.size: 12
+ font.pointSize: 12
font {
bold: true
italic: true
diff --git a/doc/src/declarative/tutorial1.qdoc b/doc/src/declarative/tutorial1.qdoc
index 5c11326..d38dc54 100644
--- a/doc/src/declarative/tutorial1.qdoc
+++ b/doc/src/declarative/tutorial1.qdoc
@@ -18,7 +18,7 @@ Rect {
Text {
id: HelloText
text: "Hello world!"
- font.size: 24
+ font.pointSize: 24
font.bold: true
y: 30
anchors.horizontalCenter: Page.horizontalCenter
@@ -49,7 +49,7 @@ The \l Rect element contains many other properties (such as \c x and \c y), but
Text {
id: HelloText
text: "Hello world!"
- font.size: 24
+ font.pointSize: 24
font.bold: true
y: 30
anchors.horizontalCenter: Page.horizontalCenter
@@ -60,7 +60,7 @@ We add a text element as a child of our root element to display the text 'Hello
The \c y property is used to position the text vertically at 30 pixels from the top of its parent.
-The \c font.size and \c font.bold properties are related to fonts and use the \e 'dot' notation.
+The \c font.pointSize and \c font.bold properties are related to fonts and use the \e 'dot' notation.
The \c anchors.horizontalCenter property refers to the horizontal center of an element. In this case, we specify that our text element should be horizontally centered in the \e Page element.
diff --git a/doc/src/declarative/tutorial2.qdoc b/doc/src/declarative/tutorial2.qdoc
index c22a01a..4be0702 100644
--- a/doc/src/declarative/tutorial2.qdoc
+++ b/doc/src/declarative/tutorial2.qdoc
@@ -41,7 +41,7 @@ Rect {
Text {
id: HelloText
text: "Hello world!"
- font.size: 24
+ font.pointSize: 24
font.bold: true
y: 30
anchors.horizontalCenter: Page.horizontalCenter
diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc
index 9ae56c1..0f9dac2 100644
--- a/doc/src/declarative/tutorial3.qdoc
+++ b/doc/src/declarative/tutorial3.qdoc
@@ -20,7 +20,7 @@ Rect {
Text {
id: HelloText
text: "Hello world!"
- font.size: 24
+ font.pointSize: 24
font.bold: true
y: 30
anchors.horizontalCenter: Page.horizontalCenter
diff --git a/examples/declarative/fillmode/fillmode.qml b/examples/declarative/fillmode/fillmode.qml
index f2a87c8..9e22885 100644
--- a/examples/declarative/fillmode/fillmode.qml
+++ b/examples/declarative/fillmode/fillmode.qml
@@ -28,7 +28,7 @@ Image {
}
Text {
id: Label
- font.size: 24
+ font.pointSize: 24
color: "blue"
style: "Outline"
styleColor: "white"
diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml
index 9fd409a..578cffa 100644
--- a/examples/declarative/fonts/fonts.qml
+++ b/examples/declarative/fonts/fonts.qml
@@ -24,21 +24,21 @@ Rect {
color: Palette.windowText
width: parent.width; elide: "ElideRight"
font.family: "Times"
- font.size: 32
+ font.pointSize: 32
}
Text {
text: myText
color: Palette.windowText
width: parent.width; elide: "ElideRight"
font.family: FixedFont.name
- font.size: 32
+ font.pointSize: 32
}
Text {
text: myText
color: Palette.windowText
width: parent.width; elide: "ElideRight"
font.family: LocalFont.name
- font.size: 32
+ font.pointSize: 32
}
Text {
text: {
@@ -49,7 +49,7 @@ Rect {
color: Palette.windowText
width: parent.width; elide: "ElideRight"
font.family: WebFont.name
- font.size: 32
+ font.pointSize: 32
}
Text {
text: {
@@ -60,7 +60,7 @@ Rect {
color: Palette.windowText
width: parent.width; elide: "ElideRight"
font.family: WebFont2.name
- font.size: 32
+ font.pointSize: 32
}
}
}
diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml
index 7abadd0..b2c17af 100644
--- a/examples/declarative/listview/recipes.qml
+++ b/examples/declarative/listview/recipes.qml
@@ -48,9 +48,9 @@ Rect {
VerticalPositioner {
height: recipePic.height; width: background.width-recipePic.width-20
spacing: 5
- Text { id: name; text: title; font.bold: true; font.size: 16 }
+ Text { id: name; text: title; font.bold: true; font.pointSize: 16 }
Text {
- text: "Ingredients"; font.size: 12; font.bold: true
+ text: "Ingredients"; font.pointSize: 12; font.bold: true
opacity: wrapper.detailsOpacity
}
Text {
@@ -67,7 +67,7 @@ Rect {
opacity: wrapper.detailsOpacity
Text {
id: methodTitle
- text: "Method"; font.size: 12; font.bold: true
+ text: "Method"; font.pointSize: 12; font.bold: true
anchors.top: parent.top
}
Flickable {
diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml
index 96c2a76..1c849b8 100644
--- a/examples/declarative/loader/Browser.qml
+++ b/examples/declarative/loader/Browser.qml
@@ -36,7 +36,7 @@ Rect {
id: NameText
anchors.fill: parent; vAlign: "AlignVCenter"
text: fileName; anchors.leftMargin: 32
- font.size: 10
+ font.pointSize: 10
color: activePalette.windowText
}
MouseRegion {
diff --git a/examples/declarative/loader/Button.qml b/examples/declarative/loader/Button.qml
index 999e180..391a800 100644
--- a/examples/declarative/loader/Button.qml
+++ b/examples/declarative/loader/Button.qml
@@ -12,5 +12,5 @@ Rect {
radius: 4
color: "grey"
MouseRegion { anchors.fill: parent; onClicked: Container.clicked() }
- Text { id: Text; anchors.centerIn:parent; font.size: 10; text: parent.text }
+ Text { id: Text; anchors.centerIn:parent; font.pointSize: 10; text: parent.text }
}
diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml
index 55cf3c2..b3bcaf3 100644
--- a/examples/declarative/minehunt/minehunt.qml
+++ b/examples/declarative/minehunt/minehunt.qml
@@ -148,7 +148,7 @@ Item {
y: 380
Text {
color: "white"
- font.size: 18
+ font.pointSize: 18
x: 20
y: 20
}
diff --git a/examples/declarative/tutorials/helloworld/t1/tutorial1.qml b/examples/declarative/tutorials/helloworld/t1/tutorial1.qml
index f067695..156655a 100644
--- a/examples/declarative/tutorials/helloworld/t1/tutorial1.qml
+++ b/examples/declarative/tutorials/helloworld/t1/tutorial1.qml
@@ -8,7 +8,7 @@ Rect {
Text {
id: HelloText
text: "Hello world!"
- font.size: 24
+ font.pointSize: 24
font.bold: true
y: 30
anchors.horizontalCenter: Page.horizontalCenter
diff --git a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml
index efbdbf1..5619d04 100644
--- a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml
+++ b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml
@@ -8,7 +8,7 @@ Rect {
Text {
id: HelloText
text: "Hello world!"
- font.size: 24
+ font.pointSize: 24
font.bold: true
y: 30
anchors.horizontalCenter: Page.horizontalCenter
diff --git a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml
index 3e93632..ca32709 100644
--- a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml
+++ b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml
@@ -8,7 +8,7 @@ Rect {
Text {
id: HelloText
text: "Hello world!"
- font.size: 24
+ font.pointSize: 24
font.bold: true
y: 30
anchors.horizontalCenter: Page.horizontalCenter
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
index f7a5a47..59a31af 100644
--- a/examples/declarative/velocity/Day.qml
+++ b/examples/declarative/velocity/Day.qml
@@ -18,7 +18,7 @@ Rect {
x: 20
y: 20
height: 40
- font.size: 14
+ font.pointSize: 14
font.bold: true
width: 370
text: day
@@ -50,7 +50,7 @@ Rect {
TextEdit {
id: MyText
smooth: true
- font.size: 28
+ font.pointSize: 28
readOnly: false
x: -104
y: 36
diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml
index c7f0b08..156eb31 100644
--- a/examples/declarative/xmldata/yahoonews.qml
+++ b/examples/declarative/xmldata/yahoonews.qml
@@ -49,7 +49,7 @@ Rect {
text: '<a href=\'' + link + '\'>' + title + '</a>'
font.bold: true
font.family: "Helvetica"
- font.size: 14
+ font.pointSize: 14
onLinkActivated: { print('link clicked: ' + link) }
}
Text {
diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp
index 6f2f079..de850f8 100644
--- a/src/declarative/fx/qfxlineedit.cpp
+++ b/src/declarative/fx/qfxlineedit.cpp
@@ -101,26 +101,25 @@ void QFxLineEdit::setText(const QString &s)
Set the LineEdit's font attributes. \c font.size sets the font's point size.
*/
-QmlFont *QFxLineEdit::font()
+QFont QFxLineEdit::font() const
{
- Q_D(QFxLineEdit);
+ Q_D(const QFxLineEdit);
return d->font;
}
-/*!
-This signal is emitted when the font of the item changes.
-*/
-void QFxLineEdit::fontChanged()
+void QFxLineEdit::setFont(const QFont &font)
{
Q_D(QFxLineEdit);
- d->control->setFont(d->font->font());
+ d->font = font;
+
+ d->control->setFont(d->font);
if(d->cursorItem){
- d->cursorItem->setHeight(QFontMetrics(d->font->font()).height());
+ d->cursorItem->setHeight(QFontMetrics(d->font).height());
moveCursor();
}
//updateSize();
updateAll();//TODO: Only necessary updates
- emit update();
+ update();
}
/*!
@@ -564,9 +563,6 @@ void QFxLineEditPrivate::init()
q, SLOT(updateAll()));
q->connect(control, SIGNAL(selectionChanged()),
q, SLOT(updateAll()));
- if(!font)
- font = new QmlFont();
- q->connect(font, SIGNAL(updated()), q, SLOT(fontChanged()));
q->updateSize();
oldValidity = control->hasAcceptableInput();
lastSelectionStart = 0;
@@ -633,7 +629,7 @@ void QFxLineEdit::updateSize()
Q_D(QFxLineEdit);
setImplicitHeight(d->control->height());
//d->control->width() is max width, not current width
- QFontMetrics fm = QFontMetrics(d->font->font());
+ QFontMetrics fm = QFontMetrics(d->font);
setImplicitWidth(fm.boundingRect(d->control->text()).width()+1);
setContentsSize(QSize(width(), height()));
}
diff --git a/src/declarative/fx/qfxlineedit.h b/src/declarative/fx/qfxlineedit.h
index f78dbfc..0218fb0 100644
--- a/src/declarative/fx/qfxlineedit.h
+++ b/src/declarative/fx/qfxlineedit.h
@@ -64,7 +64,7 @@ class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem
Q_PROPERTY(QColor color READ color WRITE setColor)
Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor)
Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor)
- Q_PROPERTY(QmlFont *font READ font CONSTANT)
+ Q_PROPERTY(QFont font READ font WRITE setFont)
Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign)
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
@@ -98,7 +98,8 @@ public:
QString text() const;
void setText(const QString &);
- QmlFont *font();
+ QFont font() const;
+ void setFont(const QFont &font);
QColor color() const;
void setColor(const QColor &c);
@@ -169,7 +170,6 @@ protected:
private Q_SLOTS:
void updateSize();
- void fontChanged();
void q_textChanged();
void selectionChanged();
void updateAll();
diff --git a/src/declarative/fx/qfxlineedit_p.h b/src/declarative/fx/qfxlineedit_p.h
index a087a32..369669f 100644
--- a/src/declarative/fx/qfxlineedit_p.h
+++ b/src/declarative/fx/qfxlineedit_p.h
@@ -64,7 +64,7 @@ class QFxLineEditPrivate : public QFxPaintedItemPrivate
Q_DECLARE_PUBLIC(QFxLineEdit);
public:
QFxLineEditPrivate() : control(new QLineControl(QString())),
- font(0), color((QRgb)0), style(QFxText::Normal),
+ color((QRgb)0), style(QFxText::Normal),
styleColor((QRgb)0), hAlign(QFxLineEdit::AlignLeft),
hscroll(0), oldScroll(0), focused(false), cursorVisible(false)
{
@@ -79,7 +79,7 @@ public:
QLineControl* control;
- QmlFont *font;
+ QFont font;
QColor color;
QColor highlightColor;
QColor highlightedTextColor;
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index 0315a75..11fef69 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -108,7 +108,6 @@ QFxText::QFxText(QFxItem *parent)
: QFxItem(*(new QFxTextPrivate), parent)
{
Q_D(QFxText);
- d->init();
setAcceptedMouseButtons(Qt::LeftButton);
setFlag(QGraphicsItem::ItemHasNoContents, false);
}
@@ -117,7 +116,6 @@ QFxText::QFxText(QFxTextPrivate &dd, QFxItem *parent)
: QFxItem(dd, parent)
{
Q_D(QFxText);
- d->init();
setAcceptedMouseButtons(Qt::LeftButton);
setFlag(QGraphicsItem::ItemHasNoContents, false);
}
@@ -142,10 +140,20 @@ QFxText::~QFxText()
\brief the font used to display the text.
*/
-QmlFont *QFxText::font()
+QFont QFxText::font() const
+{
+ Q_D(const QFxText);
+ return d->font;
+}
+
+void QFxText::setFont(const QFont &font)
{
Q_D(QFxText);
- return d->font();
+ d->font = font;
+
+ d->imgDirty = true;
+ d->updateSize();
+ update();
}
void QFxText::setText(const QString &n)
@@ -492,15 +500,6 @@ void QFxText::geometryChanged(const QRectF &newGeometry,
QFxItem::geometryChanged(newGeometry, oldGeometry);
}
-
-void QFxText::fontChanged()
-{
- Q_D(QFxText);
- d->imgDirty = true;
- d->updateSize();
- emit update();
-}
-
void QFxTextPrivate::updateSize()
{
Q_Q(QFxText);
@@ -508,8 +507,7 @@ void QFxTextPrivate::updateSize()
if (text.isEmpty()) {
return;
}
- QFont f; if (_font) f = _font->font();
- QFontMetrics fm(f);
+ QFontMetrics fm(font);
int dy = q->height();
QString tmp;
@@ -524,14 +522,14 @@ void QFxTextPrivate::updateSize()
if (singleline && elideMode != Qt::ElideNone && q->widthValid())
tmp = fm.elidedText(tmp,elideMode,q->width()); // XXX still worth layout...?
layout.clearLayout();
- layout.setFont(f);
+ layout.setFont(font);
layout.setText(tmp);
size = setupTextLayout(&layout);
cachedLayoutSize = size;
}
if (richText) {
singleline = false; // richtext can't elide or be optimized for single-line case
- doc->setDefaultFont(f);
+ doc->setDefaultFont(font);
QTextOption option((Qt::Alignment)int(hAlign | vAlign));
if (wrap)
option.setWrapMode(QTextOption::WordWrap);
@@ -622,8 +620,7 @@ QSize QFxTextPrivate::setupTextLayout(QTextLayout *layout)
Q_Q(QFxText);
layout->setCacheEnabled(true);
- QFont f; if (_font) f = _font->font();
- QFontMetrics fm = QFontMetrics(f);
+ QFontMetrics fm = QFontMetrics(font);
int height = 0;
qreal widthUsed = 0;
@@ -657,7 +654,6 @@ QSize QFxTextPrivate::setupTextLayout(QTextLayout *layout)
QPixmap QFxTextPrivate::wrappedTextImage(bool drawStyle)
{
//do layout
- QFont f; if (_font) f = _font->font();
QSize size = cachedLayoutSize;
int x = 0;
@@ -682,7 +678,7 @@ QPixmap QFxTextPrivate::wrappedTextImage(bool drawStyle)
}
else
p.setPen(color);
- p.setFont(f);
+ p.setFont(font);
layout.draw(&p, QPointF(0, 0));
return img;
}
diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h
index 3665ac6..edf6031 100644
--- a/src/declarative/fx/qfxtext.h
+++ b/src/declarative/fx/qfxtext.h
@@ -43,8 +43,6 @@
#define QFXTEXT_H
#include <QtDeclarative/qfxitem.h>
-#include <QtDeclarative/qmlfont.h>
-
QT_BEGIN_HEADER
@@ -61,7 +59,7 @@ class Q_DECLARATIVE_EXPORT QFxText : public QFxItem
Q_ENUMS(TextFormat)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(QmlFont *font READ font CONSTANT)
+ Q_PROPERTY(QFont font READ font WRITE setFont)
Q_PROPERTY(QColor color READ color WRITE setColor)
Q_PROPERTY(TextStyle style READ style WRITE setStyle)
Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor)
@@ -93,7 +91,8 @@ public:
QString text() const;
void setText(const QString &);
- QmlFont *font();
+ QFont font() const;
+ void setFont(const QFont &font);
QColor color() const;
void setColor(const QColor &c);
@@ -129,10 +128,6 @@ Q_SIGNALS:
void textChanged(const QString &text);
void linkActivated(const QString &link);
-private Q_SLOTS:
- //### should be in QFxTextPrivate?
- void fontChanged();
-
protected:
QFxText(QFxTextPrivate &dd, QFxItem *parent);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
diff --git a/src/declarative/fx/qfxtext_p.h b/src/declarative/fx/qfxtext_p.h
index bbb54a3..95b566c 100644
--- a/src/declarative/fx/qfxtext_p.h
+++ b/src/declarative/fx/qfxtext_p.h
@@ -69,22 +69,13 @@ class QFxTextPrivate : public QFxItemPrivate
Q_DECLARE_PUBLIC(QFxText)
public:
QFxTextPrivate()
- : _font(0), color((QRgb)0), style(QFxText::Normal), imgDirty(true),
+ : color((QRgb)0), style(QFxText::Normal), imgDirty(true),
hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop), elideMode(Qt::ElideNone),
dirty(false), wrap(false), richText(false), singleline(false), control(0), doc(0),
format(QFxText::AutoText)
{
}
- ~QFxTextPrivate()
- {
- delete _font;
- }
-
- void init()
- {
- }
-
void updateSize();
void checkImgCache();
@@ -96,17 +87,7 @@ public:
QSize setupTextLayout(QTextLayout *layout);
QString text;
- QmlFont *font()
- {
- if (!_font) {
- Q_Q(QFxText);
- _font = new QmlFont;
- QObject::connect(_font, SIGNAL(updated()), q, SLOT(fontChanged()));
- }
- return _font;
- }
-
- QmlFont *_font;
+ QFont font;
QColor color;
QFxText::TextStyle style;
QColor styleColor;
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index 1391490..628d49b 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -242,10 +242,25 @@ void QFxTextEdit::setTextFormat(TextFormat format)
\brief the text edit's default font
*/
-QmlFont *QFxTextEdit::font()
+QFont QFxTextEdit::font() const
+{
+ Q_D(const QFxTextEdit);
+ return d->font;
+}
+
+void QFxTextEdit::setFont(const QFont &font)
{
Q_D(QFxTextEdit);
- return &(d->font);
+ d->font = font;
+
+ clearCache();
+ d->document->setDefaultFont(d->font);
+ if(d->cursor){
+ d->cursor->setHeight(QFontMetrics(d->font).height());
+ moveCursorDelegate();
+ }
+ updateSize();
+ update();
}
/*!
@@ -532,7 +547,7 @@ void QFxTextEdit::loadCursorDelegate()
d->control->setCursorWidth(0);
dirtyCache(cursorRect());
d->cursor->setParentItem(this);
- d->cursor->setHeight(QFontMetrics(d->font.font()).height());
+ d->cursor->setHeight(QFontMetrics(d->font).height());
moveCursorDelegate();
}else{
qWarning() << QLatin1String("Error loading cursor delegate for TextEdit:") + objectName();
@@ -980,22 +995,6 @@ void QFxTextEdit::drawContents(QPainter *painter, const QRect &bounds)
d->control->drawContents(painter, bounds);
}
-/*!
-This signal is emitted when the font of the item changes.
-*/
-void QFxTextEdit::fontChanged()
-{
- Q_D(QFxTextEdit);
- clearCache();
- d->document->setDefaultFont(d->font.font());
- if(d->cursor){
- d->cursor->setHeight(QFontMetrics(d->font.font()).height());
- moveCursorDelegate();
- }
- updateSize();
- emit update();
-}
-
void QFxTextEdit::updateImgCache(const QRectF &r)
{
dirtyCache(r.toRect());
@@ -1024,8 +1023,6 @@ void QFxTextEditPrivate::init()
q->setFlag(QGraphicsItem::ItemHasNoContents, false);
q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);
- QObject::connect(&font, SIGNAL(updated()), q, SLOT(fontChanged()));
-
control = new QTextControl(q);
QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateImgCache(QRectF)));
@@ -1037,7 +1034,7 @@ void QFxTextEditPrivate::init()
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
document = control->document();
- document->setDefaultFont(font.font());
+ document->setDefaultFont(font);
document->setDocumentMargin(textMargin);
document->setUndoRedoEnabled(false); // flush undo buffer.
document->setUndoRedoEnabled(true);
@@ -1102,7 +1099,7 @@ void QFxTextEdit::updateSize()
{
Q_D(QFxTextEdit);
if (isComponentComplete()) {
- QFontMetrics fm = QFontMetrics(d->font.font());
+ QFontMetrics fm = QFontMetrics(d->font);
int dy = height();
// ### assumes that if the width is set, the text will fill to edges
// ### (unless wrap is false, then clipping will occur)
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index 132b474..f2f163b 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -71,7 +71,7 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem
Q_PROPERTY(QColor color READ color WRITE setColor)
Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor)
Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor)
- Q_PROPERTY(QmlFont * font READ font)
+ Q_PROPERTY(QFont font READ font WRITE setFont)
Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign)
Q_PROPERTY(VAlignment vAlign READ vAlign WRITE setVAlign)
Q_PROPERTY(bool wrap READ wrap WRITE setWrap)
@@ -114,8 +114,8 @@ public:
TextFormat textFormat() const;
void setTextFormat(TextFormat format);
- // leave in, have affect the default text
- QmlFont *font();
+ QFont font() const;
+ void setFont(const QFont &font);
QColor color() const;
void setColor(const QColor &c);
@@ -192,7 +192,6 @@ public Q_SLOTS:
void selectAll();
private Q_SLOTS:
- void fontChanged();
void updateImgCache(const QRectF &rect);
void q_textChanged();
void updateSelectionMarkers();
@@ -223,8 +222,6 @@ protected:
void drawContents(QPainter *, const QRect &);
private:
-
- friend class QmlFont;
Q_DISABLE_COPY(QFxTextEdit)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxTextEdit)
};
diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h
index 45a8a60..fb757de 100644
--- a/src/declarative/fx/qfxtextedit_p.h
+++ b/src/declarative/fx/qfxtextedit_p.h
@@ -68,7 +68,7 @@ class QFxTextEditPrivate : public QFxPaintedItemPrivate
public:
QFxTextEditPrivate()
- : font(0), color("black"), imgDirty(true), hAlign(QFxTextEdit::AlignLeft), vAlign(QFxTextEdit::AlignTop),
+ : color("black"), imgDirty(true), hAlign(QFxTextEdit::AlignLeft), vAlign(QFxTextEdit::AlignTop),
dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(false),
preserveSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
cursorComponent(0), cursor(0), format(QFxTextEdit::AutoText), document(0)
@@ -82,7 +82,7 @@ public:
void updateSelection();
QString text;
- QmlFont font;
+ QFont font;
QColor color;
QColor highlightColor;
QColor highlightedTextColor;
diff --git a/src/declarative/util/qmlfont.cpp b/src/declarative/util/qmlfont.cpp
deleted file mode 100644
index 06e8769..0000000
--- a/src/declarative/util/qmlfont.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "private/qobject_p.h"
-#include "qfont.h"
-#include "qmlfont.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlFontPrivate : public QObjectPrivate
-{
-public:
- QFont font;
-};
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Font,QmlFont)
-
-/*!
- \internal
- \class QmlFont
- \ingroup group_utility
- \brief The QmlFont class provides a font used for drawing text on a QFxView.
-*/
-QmlFont::QmlFont(QObject *parent)
- : QObject(*(new QmlFontPrivate), parent)
-{
-}
-
-QmlFont::~QmlFont()
-{
-}
-
-/*!
- \property QmlFont::family
- \brief the family of the font.
-*/
-QString QmlFont::family() const
-{
- Q_D(const QmlFont);
- return d->font.family();
-}
-
-void QmlFont::setFamily(const QString &family)
-{
- Q_D(QmlFont);
- d->font.setFamily(family);
- emit updated();
-}
-
-/*!
- \property QmlFont::bold
- \brief whether the font should be bold.
-*/
-bool QmlFont::bold() const
-{
- Q_D(const QmlFont);
- return d->font.bold();
-}
-
-void QmlFont::setBold(bool b)
-{
- Q_D(QmlFont);
- d->font.setBold(b);
- emit updated();
-}
-
-/*!
- \property QmlFont::italic
- \brief whether the font should be italic.
-*/
-bool QmlFont::italic() const
-{
- Q_D(const QmlFont);
- return d->font.italic();
-}
-
-void QmlFont::setItalic(bool b)
-{
- Q_D(QmlFont);
- d->font.setItalic(b);
- emit updated();
-}
-
-/*!
- \property QmlFont::size
- \brief the size of the font in points.
-*/
-qreal QmlFont::size() const
-{
- Q_D(const QmlFont);
- return d->font.pointSizeF();
-}
-
-void QmlFont::setSize(qreal size)
-{
- Q_D(QmlFont);
- d->font.setPointSizeF(size);
- emit updated();
-}
-
-/*!
- \brief Returns a QFont representation of the font.
-*/
-QFont QmlFont::font() const
-{
- Q_D(const QmlFont);
- return d->font;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlfont.h b/src/declarative/util/qmlfont.h
deleted file mode 100644
index e85b8d3..0000000
--- a/src/declarative/util/qmlfont.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLFONT_H
-#define QMLFONT_H
-
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qml.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlFontPrivate;
-class Q_DECLARATIVE_EXPORT QmlFont : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlFont)
-
- Q_PROPERTY(QString family READ family WRITE setFamily)
- Q_PROPERTY(bool bold READ bold WRITE setBold)
- Q_PROPERTY(bool italic READ italic WRITE setItalic)
- Q_PROPERTY(qreal size READ size WRITE setSize)
-
-public:
- QmlFont(QObject *parent=0);
- ~QmlFont();
-
- QString family() const;
- void setFamily(const QString &);
-
- bool bold() const;
- void setBold(bool b);
-
- bool italic() const;
- void setItalic(bool b);
-
- qreal size() const;
- void setSize(qreal size);
-
- QFont font() const;
-
-Q_SIGNALS:
- void updated();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlFont)
-
-QT_END_HEADER
-
-#endif // QMLFONT_H
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index 59e3695..9374f00 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -6,7 +6,6 @@ SOURCES += \
util/qmlpackage.cpp \
util/qmlscript.cpp \
util/qmlanimation.cpp \
- util/qmlfont.cpp \
util/qmlpalette.cpp \
util/qmlfollow.cpp \
util/qmlstate.cpp\
@@ -32,7 +31,6 @@ HEADERS += \
util/qmlscript.h \
util/qmlanimation.h \
util/qmlanimation_p.h \
- util/qmlfont.h \
util/qmlpalette.h \
util/qmlfollow.h \
util/qmlstate.h\