summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qlabel.cpp27
-rw-r--r--src/gui/widgets/qlabel_p.h1
-rw-r--r--src/gui/widgets/qmenu_symbian.cpp8
-rw-r--r--src/gui/widgets/qsplashscreen.cpp7
4 files changed, 28 insertions, 15 deletions
diff --git a/src/gui/widgets/qlabel.cpp b/src/gui/widgets/qlabel.cpp
index bdbd0b0..42be03b 100644
--- a/src/gui/widgets/qlabel.cpp
+++ b/src/gui/widgets/qlabel.cpp
@@ -635,7 +635,7 @@ QSize QLabelPrivate::sizeForWidth(int w) const
br = movie->currentPixmap().rect();
#endif
else if (isTextLabel) {
- int align = QStyle::visualAlignment(q->layoutDirection(), QFlag(this->align));
+ int align = QStyle::visualAlignment(textDirection(), QFlag(this->align));
// Add indentation
int m = indent;
@@ -1059,7 +1059,8 @@ void QLabel::paintEvent(QPaintEvent *)
drawFrame(&painter);
QRect cr = contentsRect();
cr.adjust(d->margin, d->margin, -d->margin, -d->margin);
- int align = QStyle::visualAlignment(layoutDirection(), QFlag(d->align));
+ int align = QStyle::visualAlignment(d->isTextLabel ? d->textDirection()
+ : layoutDirection(), QFlag(d->align));
#ifndef QT_NO_MOVIE
if (d->movie) {
@@ -1119,7 +1120,8 @@ void QLabel::paintEvent(QPaintEvent *)
d->control->drawContents(&painter, QRectF(), this);
painter.restore();
} else {
- int flags = align;
+ int flags = align | (d->textDirection() == Qt::LeftToRight ? Qt::TextForceLeftToRight
+ : Qt::TextForceRightToLeft);
if (d->hasShortcut) {
flags |= Qt::TextShowMnemonic;
if (!style->styleHint(QStyle::SH_UnderlineShortcut, &opt, this))
@@ -1447,10 +1449,6 @@ void QLabel::changeEvent(QEvent *ev)
d->control->setPalette(palette());
} else if (ev->type() == QEvent::ContentsRectChange) {
d->updateLabel();
- } else if (ev->type() == QEvent::LayoutDirectionChange) {
- if (d->isTextLabel && d->control) {
- d->sendControlEvent(ev);
- }
}
QFrame::changeEvent(ev);
}
@@ -1486,6 +1484,15 @@ void QLabel::setScaledContents(bool enable)
update(contentsRect());
}
+Qt::LayoutDirection QLabelPrivate::textDirection() const
+{
+ if (control) {
+ QTextOption opt = control->document()->defaultTextOption();
+ return opt.textDirection();
+ }
+
+ return text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
+}
/*!
\fn void QLabel::setAlignment(Qt::AlignmentFlag flag)
@@ -1503,7 +1510,8 @@ QRect QLabelPrivate::documentRect() const
Q_ASSERT_X(isTextLabel, "documentRect", "document rect called for label that is not a text label!");
QRect cr = q->contentsRect();
cr.adjust(margin, margin, -margin, -margin);
- const int align = QStyle::visualAlignment(q->layoutDirection(), QFlag(this->align));
+ const int align = QStyle::visualAlignment(isTextLabel ? textDirection()
+ : q->layoutDirection(), QFlag(this->align));
int m = indent;
if (m < 0 && q->frameWidth()) // no indent, but we do have a frame
m = q->fontMetrics().width(QLatin1Char('x')) / 2 - margin;
@@ -1564,7 +1572,6 @@ void QLabelPrivate::ensureTextLayouted() const
if (!textLayoutDirty)
return;
ensureTextPopulated();
- Q_Q(const QLabel);
if (control) {
QTextDocument *doc = control->document();
QTextOption opt = doc->defaultTextOption();
@@ -1576,8 +1583,6 @@ void QLabelPrivate::ensureTextLayouted() const
else
opt.setWrapMode(QTextOption::ManualWrap);
- opt.setTextDirection(q->layoutDirection());
-
doc->setDefaultTextOption(opt);
QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
diff --git a/src/gui/widgets/qlabel_p.h b/src/gui/widgets/qlabel_p.h
index fba7224..83624c7 100644
--- a/src/gui/widgets/qlabel_p.h
+++ b/src/gui/widgets/qlabel_p.h
@@ -132,6 +132,7 @@ public:
QRectF layoutRect() const;
QRect documentRect() const;
QPoint layoutPoint(const QPoint& p) const;
+ Qt::LayoutDirection textDirection() const;
#ifndef QT_NO_CONTEXTMENU
QMenu *createStandardContextMenu(const QPoint &pos);
#endif
diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp
index ab2bdea..83ba15a 100644
--- a/src/gui/widgets/qmenu_symbian.cpp
+++ b/src/gui/widgets/qmenu_symbian.cpp
@@ -168,11 +168,11 @@ static void qt_symbian_insert_action(QSymbianMenuAction* action, QList<SymbianMe
if (action->action->menu()->actions().size() > 0) {
for (int c2= 0; c2 < action->action->menu()->actions().size(); ++c2) {
- QSymbianMenuAction *symbianAction2 = new QSymbianMenuAction;
+ QScopedPointer<QSymbianMenuAction> symbianAction2(new QSymbianMenuAction);
symbianAction2->action = action->action->menu()->actions().at(c2);
QMenu * menu = symbianAction2->action->menu();
symbianAction2->command = qt_symbian_menu_static_cmd_id++;
- qt_symbian_insert_action(symbianAction2, &(menuItem->children));
+ qt_symbian_insert_action(symbianAction2.data(), &(menuItem->children));
}
}
@@ -432,11 +432,11 @@ void QMenuBarPrivate::QSymbianMenuBarPrivate::removeAction(QSymbianMenuAction *a
void QMenuBarPrivate::QSymbianMenuBarPrivate::insertNativeMenuItems(const QList<QAction*> &actions)
{
for (int i = 0; i <actions.size(); ++i) {
- QSymbianMenuAction *symbianActionTopLevel = new QSymbianMenuAction;
+ QScopedPointer<QSymbianMenuAction> symbianActionTopLevel(new QSymbianMenuAction);
symbianActionTopLevel->action = actions.at(i);
symbianActionTopLevel->parent = 0;
symbianActionTopLevel->command = qt_symbian_menu_static_cmd_id++;
- qt_symbian_insert_action(symbianActionTopLevel, &symbianMenus);
+ qt_symbian_insert_action(symbianActionTopLevel.data(), &symbianMenus);
}
}
diff --git a/src/gui/widgets/qsplashscreen.cpp b/src/gui/widgets/qsplashscreen.cpp
index 8be0cf8..d1fb686 100644
--- a/src/gui/widgets/qsplashscreen.cpp
+++ b/src/gui/widgets/qsplashscreen.cpp
@@ -186,6 +186,13 @@ void QSplashScreen::repaint()
Draws the \a message text onto the splash screen with color \a
color and aligns the text according to the flags in \a alignment.
+ To make sure the splash screen is repainted immediately, you can
+ call \l{QCoreApplication}'s
+ \l{QCoreApplication::}{processEvents()} after the call to
+ showMessage(). You usually want this to make sure that the message
+ is kept up to date with what your application is doing (e.g.,
+ loading files).
+
\sa Qt::Alignment, clearMessage()
*/
void QSplashScreen::showMessage(const QString &message, int alignment,