summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorJanne Koskinen <janne.p.koskinen@digia.com>2009-06-15 15:08:43 (GMT)
committerJanne Koskinen <janne.p.koskinen@digia.com>2009-06-15 15:08:43 (GMT)
commit7a42405649aeea3e709231464d450b5da521e5cb (patch)
treec8a0bc351478ee24a29e2a436fe498213598a5ae /src/gui
parentba1491c5942239f9e0f3f283114f9ed91f43f02b (diff)
parent08ae7ee1fb930e7d4b4039e2294cba69f9380964 (diff)
downloadQt-7a42405649aeea3e709231464d450b5da521e5cb.zip
Qt-7a42405649aeea3e709231464d450b5da521e5cb.tar.gz
Qt-7a42405649aeea3e709231464d450b5da521e5cb.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
Conflicts: src/corelib/tools/qringbuffer_p.h
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/dialogs/dialogs.pri1
-rw-r--r--src/gui/dialogs/qcolordialog.cpp2
-rw-r--r--src/gui/dialogs/qdialog.cpp10
-rw-r--r--src/gui/dialogs/qfiledialog.cpp71
-rw-r--r--src/gui/dialogs/qfiledialog_p.h55
-rw-r--r--src/gui/dialogs/qfileinfogatherer.cpp28
-rw-r--r--src/gui/dialogs/qfilesystemmodel.cpp11
-rw-r--r--src/gui/dialogs/qfilesystemmodel_p.h25
-rw-r--r--src/gui/dialogs/qfontdialog.cpp10
-rw-r--r--src/gui/dialogs/qfontdialog_mac.mm40
-rw-r--r--src/gui/dialogs/qfscompleter_p.h81
-rw-r--r--src/gui/dialogs/qinputdialog.cpp12
-rw-r--r--src/gui/dialogs/qmessagebox.cpp15
-rw-r--r--src/gui/dialogs/qpagesetupdialog.cpp6
-rw-r--r--src/gui/dialogs/qpagesetupdialog_mac.mm3
-rw-r--r--src/gui/dialogs/qpagesetupdialog_win.cpp2
-rw-r--r--src/gui/dialogs/qprintdialog_unix.cpp4
-rw-r--r--src/gui/dialogs/qprintpreviewdialog.cpp13
-rw-r--r--src/gui/dialogs/qprintpreviewdialog.h2
-rw-r--r--src/gui/dialogs/qwizard.cpp4
-rw-r--r--src/gui/dialogs/qwizard_win.cpp5
-rw-r--r--src/gui/dialogs/qwizard_win_p.h2
-rw-r--r--src/gui/embedded/qkbdtty_qws.cpp4
-rw-r--r--src/gui/embedded/qscreen_qws.cpp2
-rw-r--r--src/gui/embedded/qsoundqss_qws.cpp36
-rw-r--r--src/gui/embedded/qwindowsystem_qws.cpp44
-rw-r--r--src/gui/embedded/qwscursor_qws.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp139
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h3
-rw-r--r--src/gui/graphicsview/qgraphicslayoutitem.cpp3
-rw-r--r--src/gui/graphicsview/qgraphicslayoutitem.h3
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.h2
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp10
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.cpp15
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.h3
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp17
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicswidget.h2
-rw-r--r--src/gui/gui.pro5
-rw-r--r--src/gui/image/qicon.cpp11
-rw-r--r--src/gui/image/qimage.cpp19
-rw-r--r--src/gui/image/qimageiohandler.cpp1
-rw-r--r--src/gui/image/qimageiohandler.h3
-rw-r--r--src/gui/image/qpicture.cpp17
-rw-r--r--src/gui/image/qpicture.h4
-rw-r--r--src/gui/image/qpicture_p.h2
-rw-r--r--src/gui/image/qpixmap.cpp97
-rw-r--r--src/gui/image/qpixmap.h9
-rw-r--r--src/gui/image/qpixmap_qws.cpp14
-rw-r--r--src/gui/image/qpixmap_s60.cpp173
-rw-r--r--src/gui/image/qpixmap_win.cpp45
-rw-r--r--src/gui/image/qpixmap_x11.cpp28
-rw-r--r--src/gui/image/qpixmapcache.cpp7
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_p.h34
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp125
-rw-r--r--src/gui/inputmethod/qwininputcontext_win.cpp7
-rw-r--r--src/gui/inputmethod/qximinputcontext_x11.cpp2
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp17
-rw-r--r--src/gui/itemviews/qabstractitemview_p.h2
-rw-r--r--src/gui/itemviews/qfileiconprovider.cpp1
-rw-r--r--src/gui/itemviews/qfileiconprovider.h5
-rw-r--r--src/gui/itemviews/qheaderview.cpp4
-rw-r--r--src/gui/itemviews/qitemdelegate.cpp5
-rw-r--r--src/gui/itemviews/qlistwidget.cpp2
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.cpp3
-rw-r--r--src/gui/itemviews/qstandarditemmodel.cpp2
-rw-r--r--src/gui/itemviews/qstandarditemmodel.h2
-rw-r--r--src/gui/itemviews/qstyleditemdelegate.cpp3
-rw-r--r--src/gui/itemviews/qtreeview.cpp8
-rw-r--r--src/gui/itemviews/qtreewidget.cpp2
-rw-r--r--src/gui/itemviews/qtreewidgetitemiterator.cpp3
-rw-r--r--src/gui/itemviews/qtreewidgetitemiterator.h3
-rw-r--r--src/gui/kernel/qaction.cpp29
-rw-r--r--src/gui/kernel/qaction.h10
-rw-r--r--src/gui/kernel/qaction_p.h1
-rw-r--r--src/gui/kernel/qapplication.cpp14
-rw-r--r--src/gui/kernel/qapplication.h3
-rw-r--r--src/gui/kernel/qapplication_p.h2
-rw-r--r--src/gui/kernel/qapplication_qws.cpp27
-rw-r--r--src/gui/kernel/qapplication_s60.cpp151
-rw-r--r--src/gui/kernel/qapplication_win.cpp29
-rw-r--r--src/gui/kernel/qapplication_x11.cpp8
-rw-r--r--src/gui/kernel/qclipboard.cpp2
-rw-r--r--src/gui/kernel/qclipboard_s60.cpp32
-rw-r--r--src/gui/kernel/qcocoaapplicationdelegate_mac.mm2
-rw-r--r--src/gui/kernel/qcocoapanel_mac.mm11
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm28
-rw-r--r--src/gui/kernel/qcocoaview_mac_p.h1
-rw-r--r--src/gui/kernel/qcocoawindow_mac.mm13
-rw-r--r--src/gui/kernel/qcursor.cpp4
-rw-r--r--src/gui/kernel/qcursor_qws.cpp6
-rw-r--r--src/gui/kernel/qcursor_s60.cpp32
-rw-r--r--src/gui/kernel/qdesktopwidget_s60.cpp95
-rw-r--r--src/gui/kernel/qdnd_s60.cpp32
-rw-r--r--src/gui/kernel/qevent.cpp11
-rw-r--r--src/gui/kernel/qevent.h3
-rw-r--r--src/gui/kernel/qeventdispatcher_s60.cpp56
-rw-r--r--src/gui/kernel/qeventdispatcher_s60_p.h32
-rw-r--r--src/gui/kernel/qkeymapper_s60.cpp32
-rw-r--r--src/gui/kernel/qkeysequence.cpp2
-rw-r--r--src/gui/kernel/qshortcutmap.cpp5
-rw-r--r--src/gui/kernel/qshortcutmap_p.h3
-rw-r--r--src/gui/kernel/qsound_s60.cpp39
-rw-r--r--src/gui/kernel/qt_s60_p.h98
-rw-r--r--src/gui/kernel/qwidget.cpp196
-rw-r--r--src/gui/kernel/qwidget.h4
-rw-r--r--src/gui/kernel/qwidget_mac.mm10
-rw-r--r--src/gui/kernel/qwidget_p.h5
-rw-r--r--src/gui/kernel/qwidget_qws.cpp3
-rw-r--r--src/gui/kernel/qwidget_s60.cpp94
-rw-r--r--src/gui/kernel/qwidget_x11.cpp3
-rw-r--r--src/gui/painting/painting.pri3
-rw-r--r--src/gui/painting/qbrush.cpp113
-rw-r--r--src/gui/painting/qbrush.h6
-rw-r--r--src/gui/painting/qcolor.cpp8
-rw-r--r--src/gui/painting/qcolormap_s60.cpp108
-rw-r--r--src/gui/painting/qcolormap_x11.cpp4
-rw-r--r--src/gui/painting/qdrawhelper.cpp4
-rw-r--r--src/gui/painting/qpaintdevice_s60.cpp32
-rw-r--r--src/gui/painting/qpaintengine.cpp1
-rw-r--r--src/gui/painting/qpaintengine.h3
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp187
-rw-r--r--src/gui/painting/qpaintengine_x11.cpp17
-rw-r--r--src/gui/painting/qpainter.cpp61
-rw-r--r--src/gui/painting/qpainter.h5
-rw-r--r--src/gui/painting/qpainterpath.cpp49
-rw-r--r--src/gui/painting/qpainterpath.h9
-rw-r--r--src/gui/painting/qprinter.cpp33
-rw-r--r--src/gui/painting/qprinter.h5
-rw-r--r--src/gui/painting/qprinterinfo.h3
-rw-r--r--src/gui/painting/qprinterinfo_mac.cpp32
-rw-r--r--src/gui/painting/qprinterinfo_unix.cpp33
-rw-r--r--src/gui/painting/qprinterinfo_win.cpp30
-rw-r--r--src/gui/painting/qrasterizer.cpp7
-rw-r--r--src/gui/painting/qregion.cpp160
-rw-r--r--src/gui/painting/qregion_s60.cpp32
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp8
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp4
-rw-r--r--src/gui/painting/qwindowsurface_raster_p.h2
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp32
-rw-r--r--src/gui/painting/qwindowsurface_s60_p.h32
-rw-r--r--src/gui/styles/gtksymbols.cpp27
-rw-r--r--src/gui/styles/qcommonstyle.cpp2
-rw-r--r--src/gui/styles/qgtkstyle.cpp78
-rw-r--r--src/gui/styles/qmacstyle_mac.mm161
-rw-r--r--src/gui/styles/qmotifstyle.cpp5
-rw-r--r--src/gui/styles/qs60style.cpp1725
-rw-r--r--src/gui/styles/qs60style.h40
-rw-r--r--src/gui/styles/qs60style_p.h122
-rw-r--r--src/gui/styles/qs60style_s60.cpp (renamed from src/gui/styles/qs60style_symbian.cpp)840
-rw-r--r--src/gui/styles/qs60style_simulated.cpp221
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp9
-rw-r--r--src/gui/styles/styles.pri3
-rw-r--r--src/gui/text/qcssparser.cpp19
-rw-r--r--src/gui/text/qfont.cpp83
-rw-r--r--src/gui/text/qfont.h3
-rw-r--r--src/gui/text/qfont_s60.cpp32
-rw-r--r--src/gui/text/qfont_x11.cpp11
-rw-r--r--src/gui/text/qfontdatabase.cpp43
-rw-r--r--src/gui/text/qfontdatabase_mac.cpp9
-rw-r--r--src/gui/text/qfontdatabase_qws.cpp81
-rw-r--r--src/gui/text/qfontdatabase_s60.cpp76
-rw-r--r--src/gui/text/qfontdatabase_x11.cpp2
-rw-r--r--src/gui/text/qfontengine.cpp22
-rw-r--r--src/gui/text/qfontengine_ft.cpp84
-rw-r--r--src/gui/text/qfontengine_ft_p.h1
-rw-r--r--src/gui/text/qfontengine_mac.mm4
-rw-r--r--src/gui/text/qfontengine_qpf.cpp31
-rw-r--r--src/gui/text/qfontengine_qpf_p.h1
-rw-r--r--src/gui/text/qfontengine_s60.cpp59
-rw-r--r--src/gui/text/qfontengine_s60_p.h32
-rw-r--r--src/gui/text/qfontengine_win.cpp30
-rw-r--r--src/gui/text/qfontengine_win_p.h3
-rw-r--r--src/gui/text/qfontmetrics.cpp20
-rw-r--r--src/gui/text/qfragmentmap_p.h8
-rw-r--r--src/gui/text/qtextcontrol.cpp32
-rw-r--r--src/gui/text/qtextengine.cpp50
-rw-r--r--src/gui/text/qtextformat.cpp2
-rw-r--r--src/gui/text/qtextlayout.cpp2
-rw-r--r--src/gui/text/qtextoption.cpp10
-rw-r--r--src/gui/text/qtexttable.cpp15
-rw-r--r--src/gui/text/qzip.cpp10
-rw-r--r--src/gui/util/qdesktopservices_s60.cpp133
-rw-r--r--src/gui/util/qundostack.cpp2
-rw-r--r--src/gui/util/util.pri5
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp23
-rw-r--r--src/gui/widgets/qabstractscrollarea_p.h2
-rw-r--r--src/gui/widgets/qabstractspinbox.cpp13
-rw-r--r--src/gui/widgets/qabstractspinbox.h2
-rw-r--r--src/gui/widgets/qactiontokeyeventmapper.cpp103
-rw-r--r--src/gui/widgets/qactiontokeyeventmapper_p.h81
-rw-r--r--src/gui/widgets/qcalendarwidget.cpp2
-rw-r--r--src/gui/widgets/qcombobox.cpp30
-rw-r--r--src/gui/widgets/qcombobox_p.h6
-rw-r--r--src/gui/widgets/qdatetimeedit.cpp1
-rw-r--r--src/gui/widgets/qlcdnumber.cpp2
-rw-r--r--src/gui/widgets/qlineedit.cpp51
-rw-r--r--src/gui/widgets/qmacnativewidget_mac.h2
-rw-r--r--src/gui/widgets/qmainwindow.cpp5
-rw-r--r--src/gui/widgets/qmdiarea.cpp2
-rw-r--r--src/gui/widgets/qmenu.cpp14
-rw-r--r--src/gui/widgets/qmenu.h3
-rw-r--r--src/gui/widgets/qmenu_mac.mm52
-rw-r--r--src/gui/widgets/qmenu_p.h3
-rw-r--r--src/gui/widgets/qmenu_symbian.cpp151
-rw-r--r--src/gui/widgets/qmenubar.cpp2
-rw-r--r--src/gui/widgets/qmenubar.h4
-rw-r--r--src/gui/widgets/qmenubar_p.h3
-rw-r--r--src/gui/widgets/qmenudata.h2
-rw-r--r--src/gui/widgets/qplaintextedit.cpp20
-rw-r--r--src/gui/widgets/qplaintextedit_p.h6
-rw-r--r--src/gui/widgets/qprintpreviewwidget.cpp13
-rw-r--r--src/gui/widgets/qprintpreviewwidget.h2
-rw-r--r--src/gui/widgets/qprogressbar.cpp2
-rw-r--r--src/gui/widgets/qscrollarea.cpp2
-rw-r--r--src/gui/widgets/qspinbox.cpp9
-rw-r--r--src/gui/widgets/qsplitter.cpp2
-rw-r--r--src/gui/widgets/qtabbar.cpp11
-rw-r--r--src/gui/widgets/qtabwidget.cpp2
-rw-r--r--src/gui/widgets/qtextedit.cpp17
-rw-r--r--src/gui/widgets/qtextedit_p.h1
-rw-r--r--src/gui/widgets/qtoolbox.cpp2
-rw-r--r--src/gui/widgets/widgets.pri8
223 files changed, 5464 insertions, 2851 deletions
diff --git a/src/gui/dialogs/dialogs.pri b/src/gui/dialogs/dialogs.pri
index 92347a7..b9fad41 100644
--- a/src/gui/dialogs/dialogs.pri
+++ b/src/gui/dialogs/dialogs.pri
@@ -7,6 +7,7 @@ HEADERS += \
dialogs/qabstractpagesetupdialog_p.h \
dialogs/qcolordialog.h \
dialogs/qcolordialog_p.h \
+ dialogs/qfscompleter_p.h \
dialogs/qdialog.h \
dialogs/qdialog_p.h \
dialogs/qerrormessage.h \
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index 3aa04f6..4702d14 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -1749,7 +1749,7 @@ void QColorDialog::setVisible(bool visible)
\overload
\since 4.5
- Opens the dialog and connects its accepted() signal to the slot specified
+ Opens the dialog and connects its colorSelected() signal to the slot specified
by \a receiver and \a member.
The signal will be disconnected from the slot when the dialog is closed.
diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp
index ef562f4..cecbb87 100644
--- a/src/gui/dialogs/qdialog.cpp
+++ b/src/gui/dialogs/qdialog.cpp
@@ -296,9 +296,13 @@ QDialog::QDialog(QDialogPrivate &dd, QWidget *parent, Qt::WindowFlags f)
QDialog::~QDialog()
{
- // Need to hide() here, as our (to-be) overridden hide()
- // will not be called in ~QWidget.
- hide();
+ QT_TRY {
+ // Need to hide() here, as our (to-be) overridden hide()
+ // will not be called in ~QWidget.
+ hide();
+ } QT_CATCH(...) {
+ // we're in the destructor - just swallow the exception
+ }
}
/*!
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index 789b364..9768162 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -356,7 +356,6 @@ QFileDialog::~QFileDialog()
settings.beginGroup(QLatin1String("Qt"));
settings.setValue(QLatin1String("filedialog"), saveState());
#endif
- delete d->qFileDialogUi;
d->deleteNativeDialog_sys();
}
@@ -488,6 +487,38 @@ void QFileDialog::changeEvent(QEvent *e)
QDialog::changeEvent(e);
}
+QFileDialogPrivate::QFileDialogPrivate()
+ :
+#ifndef QT_NO_PROXYMODEL
+ proxyModel(0),
+#endif
+ model(0),
+ fileMode(QFileDialog::AnyFile),
+ acceptMode(QFileDialog::AcceptOpen),
+ currentHistoryLocation(-1),
+ renameAction(0),
+ deleteAction(0),
+ showHiddenAction(0),
+ useDefaultCaption(true),
+ defaultFileTypes(true),
+ fileNameLabelExplicitlySat(false),
+ nativeDialogInUse(false),
+#ifdef Q_WS_MAC
+ mDelegate(0),
+#ifndef QT_MAC_USE_COCOA
+ mDialog(0),
+ mDialogStarted(false),
+ mDialogClosed(true),
+#endif
+#endif
+ qFileDialogUi(0)
+{
+}
+
+QFileDialogPrivate::~QFileDialogPrivate()
+{
+}
+
void QFileDialogPrivate::retranslateWindowTitle()
{
Q_Q(QFileDialog);
@@ -568,8 +599,9 @@ bool QFileDialogPrivate::canBeNativeDialog()
}
/*!
- Sets the given \a option to be enabled if \a on is true;
- otherwise, clears the given \a option.
+ \since 4.5
+ Sets the given \a option to be enabled if \a on is true; otherwise,
+ clears the given \a option.
\sa options, testOption()
*/
@@ -640,8 +672,9 @@ QFileDialog::Options QFileDialog::options() const
\since 4.5
- Opens the dialog and connects its accepted() signal to the slot specified
- by \a receiver and \a member.
+ This function connects one of its signals to the slot specified by \a receiver
+ and \a member. The specific signal depends is filesSelected() if fileMode is
+ ExistingFiles and fileSelected() if fileMode is anything else.
The signal will be disconnected from the slot when the dialog is closed.
*/
@@ -779,6 +812,7 @@ void QFileDialog::selectFile(const QString &filename)
}
QModelIndex index = d->model->index(filename);
+ QString file;
if (!index.isValid()) {
// save as dialog where we want to input a default value
QString text = filename;
@@ -793,13 +827,13 @@ void QFileDialog::selectFile(const QString &filename)
)
text = text.remove(0,1);
}
- if (!isVisible() || !d->lineEdit()->hasFocus())
- d->lineEdit()->setText(text);
+ file = text;
} else {
- d->qFileDialogUi->listView->selectionModel()->clear();
- if (!isVisible() || !d->lineEdit()->hasFocus())
- d->lineEdit()->setText(index.data().toString());
+ file = index.data().toString();
}
+ d->qFileDialogUi->listView->selectionModel()->clear();
+ if (!isVisible() || !d->lineEdit()->hasFocus())
+ d->lineEdit()->setText(file);
}
/**
@@ -2110,6 +2144,7 @@ void QFileDialogPrivate::createWidgets()
#else
model->setNameFilterDisables(false);
#endif
+ model->d_func()->disableRecursiveSort = true;
QFileDialog::connect(model, SIGNAL(fileRenamed(const QString &, const QString &, const QString &)), q, SLOT(_q_fileRenamed(const QString &, const QString &, const QString &)));
QFileDialog::connect(model, SIGNAL(rootPathChanged(const QString &)),
q, SLOT(_q_pathChanged(const QString &)));
@@ -2117,7 +2152,7 @@ void QFileDialogPrivate::createWidgets()
q, SLOT(_q_rowsInserted(const QModelIndex &)));
model->setReadOnly(false);
- qFileDialogUi = new Ui_QFileDialog();
+ qFileDialogUi.reset(new Ui_QFileDialog());
qFileDialogUi->setupUi(q);
QList<QUrl> initialBookmarks;
@@ -2143,7 +2178,7 @@ void QFileDialogPrivate::createWidgets()
qFileDialogUi->fileNameLabel->setBuddy(qFileDialogUi->fileNameEdit);
#endif
#ifndef QT_NO_COMPLETER
- completer = new QFSCompletor(model, q);
+ completer = new QFSCompleter(model, q);
qFileDialogUi->fileNameEdit->setCompleter(completer);
QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)),
q, SLOT(_q_autoCompleteFileName(QString)));
@@ -2201,9 +2236,9 @@ void QFileDialogPrivate::createWidgets()
treeHeader->addAction(showHeader);
}
- QItemSelectionModel *selModel = qFileDialogUi->treeView->selectionModel();
+ QScopedPointer<QItemSelectionModel> selModel(qFileDialogUi->treeView->selectionModel());
qFileDialogUi->treeView->setSelectionModel(qFileDialogUi->listView->selectionModel());
- delete selModel;
+
QObject::connect(qFileDialogUi->treeView, SIGNAL(activated(QModelIndex)),
q, SLOT(_q_enterDirectory(QModelIndex)));
QObject::connect(qFileDialogUi->treeView, SIGNAL(customContextMenuRequested(QPoint)),
@@ -2285,9 +2320,9 @@ void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel)
connect(d->model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
this, SLOT(_q_rowsInserted(const QModelIndex &)));
}
- QItemSelectionModel *selModel = d->qFileDialogUi->treeView->selectionModel();
+ QScopedPointer<QItemSelectionModel> selModel(d->qFileDialogUi->treeView->selectionModel());
d->qFileDialogUi->treeView->setSelectionModel(d->qFileDialogUi->listView->selectionModel());
- delete selModel;
+
d->setRootIndex(idx);
// reconnect selection
@@ -3168,7 +3203,7 @@ void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e)
#ifndef QT_NO_COMPLETER
-QString QFSCompletor::pathFromIndex(const QModelIndex &index) const
+QString QFSCompleter::pathFromIndex(const QModelIndex &index) const
{
const QFileSystemModel *dirModel;
if (proxyModel)
@@ -3183,7 +3218,7 @@ QString QFSCompletor::pathFromIndex(const QModelIndex &index) const
return index.data(QFileSystemModel::FilePathRole).toString();
}
-QStringList QFSCompletor::splitPath(const QString &path) const
+QStringList QFSCompleter::splitPath(const QString &path) const
{
if (path.isEmpty())
return QStringList(completionPrefix());
diff --git a/src/gui/dialogs/qfiledialog_p.h b/src/gui/dialogs/qfiledialog_p.h
index de7e332..3195583 100644
--- a/src/gui/dialogs/qfiledialog_p.h
+++ b/src/gui/dialogs/qfiledialog_p.h
@@ -76,6 +76,7 @@
#include <qtimeline.h>
#include <qdebug.h>
#include "qsidebar_p.h"
+#include "qfscompleter_p.h"
#if defined (Q_OS_UNIX)
#include <unistd.h>
@@ -91,25 +92,6 @@ class QCompleter;
class QHBoxLayout;
class Ui_QFileDialog;
-#ifndef QT_NO_COMPLETER
-/*!
- QCompleter that can deal with QFileSystemModel
- */
-class QFSCompletor : public QCompleter {
-public:
- QFSCompletor(QFileSystemModel *model, QObject *parent = 0) : QCompleter(model, parent), proxyModel(0), sourceModel(model)
- {
-#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
- setCaseSensitivity(Qt::CaseInsensitive);
-#endif
- }
- QString pathFromIndex(const QModelIndex &index) const;
- QStringList splitPath(const QString& path) const;
-
- QAbstractProxyModel *proxyModel;
- QFileSystemModel *sourceModel;
-};
-#endif // QT_NO_COMPLETER
struct QFileDialogArgs
{
@@ -131,31 +113,7 @@ class Q_AUTOTEST_EXPORT QFileDialogPrivate : public QDialogPrivate
Q_DECLARE_PUBLIC(QFileDialog)
public:
- QFileDialogPrivate() :
-#ifndef QT_NO_PROXYMODEL
- proxyModel(0),
-#endif
- model(0),
- fileMode(QFileDialog::AnyFile),
- acceptMode(QFileDialog::AcceptOpen),
- currentHistoryLocation(-1),
- renameAction(0),
- deleteAction(0),
- showHiddenAction(0),
- useDefaultCaption(true),
- defaultFileTypes(true),
- fileNameLabelExplicitlySat(false),
- nativeDialogInUse(false),
-#ifdef Q_WS_MAC
- mDelegate(0),
-#ifndef QT_MAC_USE_COCOA
- mDialog(0),
- mDialogStarted(false),
- mDialogClosed(true),
-#endif
-#endif
- qFileDialogUi(0)
- {}
+ QFileDialogPrivate();
void createToolButtons();
void createMenuActions();
@@ -275,7 +233,7 @@ public:
// data
QStringList watching;
QFileSystemModel *model;
- QFSCompletor *completer;
+ QFSCompleter *completer;
QFileDialog::FileMode fileMode;
QFileDialog::AcceptMode acceptMode;
@@ -357,7 +315,7 @@ public:
void mac_nativeDialogModalHelp();
#endif
- Ui_QFileDialog *qFileDialogUi;
+ QScopedPointer<Ui_QFileDialog> qFileDialogUi;
QString acceptLabel;
@@ -366,6 +324,11 @@ public:
QByteArray signalToDisconnectOnClose;
QFileDialog::Options opts;
+
+ ~QFileDialogPrivate();
+
+private:
+ Q_DISABLE_COPY(QFileDialogPrivate)
};
class QFileDialogLineEdit : public QLineEdit
diff --git a/src/gui/dialogs/qfileinfogatherer.cpp b/src/gui/dialogs/qfileinfogatherer.cpp
index a2abe54..119164d 100644
--- a/src/gui/dialogs/qfileinfogatherer.cpp
+++ b/src/gui/dialogs/qfileinfogatherer.cpp
@@ -83,10 +83,10 @@ QFileInfoGatherer::QFileInfoGatherer(QObject *parent)
*/
QFileInfoGatherer::~QFileInfoGatherer()
{
- mutex.lock();
+ QMutexLocker locker(&mutex);
abort = true;
condition.wakeOne();
- mutex.unlock();
+ locker.unlock();
wait();
}
@@ -94,9 +94,8 @@ void QFileInfoGatherer::setResolveSymlinks(bool enable)
{
Q_UNUSED(enable);
#ifdef Q_OS_WIN
- mutex.lock();
+ QMutexLocker locker(&mutex);
m_resolveSymlinks = enable;
- mutex.unlock();
#endif
}
@@ -107,9 +106,8 @@ bool QFileInfoGatherer::resolveSymlinks() const
void QFileInfoGatherer::setIconProvider(QFileIconProvider *provider)
{
- mutex.lock();
+ QMutexLocker locker(&mutex);
m_iconProvider = provider;
- mutex.unlock();
}
QFileIconProvider *QFileInfoGatherer::iconProvider() const
@@ -124,12 +122,11 @@ QFileIconProvider *QFileInfoGatherer::iconProvider() const
*/
void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStringList &files)
{
- mutex.lock();
+ QMutexLocker locker(&mutex);
// See if we already have this dir/file in our que
int loc = this->path.lastIndexOf(path);
while (loc > 0) {
if (this->files.at(loc) == files) {
- mutex.unlock();
return;
}
loc = this->path.lastIndexOf(path, loc - 1);
@@ -137,7 +134,6 @@ void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStr
this->path.push(path);
this->files.push(files);
condition.wakeAll();
- mutex.unlock();
}
/*!
@@ -160,10 +156,9 @@ void QFileInfoGatherer::updateFile(const QString &filePath)
void QFileInfoGatherer::clear()
{
#ifndef QT_NO_FILESYSTEMWATCHER
- mutex.lock();
+ QMutexLocker locker(&mutex);
watcher->removePaths(watcher->files());
watcher->removePaths(watcher->directories());
- mutex.unlock();
#endif
}
@@ -175,9 +170,8 @@ void QFileInfoGatherer::clear()
void QFileInfoGatherer::removePath(const QString &path)
{
#ifndef QT_NO_FILESYSTEMWATCHER
- mutex.lock();
+ QMutexLocker locker(&mutex);
watcher->removePath(path);
- mutex.unlock();
#endif
}
@@ -198,9 +192,8 @@ void QFileInfoGatherer::run()
{
forever {
bool updateFiles = false;
- mutex.lock();
+ QMutexLocker locker(&mutex);
if (abort) {
- mutex.unlock();
return;
}
if (this->path.isEmpty())
@@ -214,8 +207,9 @@ void QFileInfoGatherer::run()
this->files.pop_front();
updateFiles = true;
}
- mutex.unlock();
- if (updateFiles) getFileInfos(path, list);
+ locker.unlock();
+ if (updateFiles)
+ getFileInfos(path, list);
}
}
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp
index 49a3f2e..44adc75 100644
--- a/src/gui/dialogs/qfilesystemmodel.cpp
+++ b/src/gui/dialogs/qfilesystemmodel.cpp
@@ -1095,6 +1095,7 @@ private:
*/
void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent)
{
+ Q_Q(QFileSystemModel);
QFileSystemModelPrivate::QFileSystemNode *indexNode = node(parent);
if (indexNode->children.count() == 0)
return;
@@ -1118,6 +1119,16 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent
indexNode->visibleChildren.append(values.at(i).first->fileName);
values.at(i).first->isVisible = true;
}
+
+ if (!disableRecursiveSort) {
+ for (int i = 0; i < q->rowCount(parent); ++i) {
+ const QModelIndex childIndex = q->index(i, 0, parent);
+ QFileSystemModelPrivate::QFileSystemNode *indexNode = node(childIndex);
+ //Only do a recursive sort on visible nodes
+ if (indexNode->isVisible)
+ sortChildren(column, childIndex);
+ }
+ }
}
/*!
diff --git a/src/gui/dialogs/qfilesystemmodel_p.h b/src/gui/dialogs/qfilesystemmodel_p.h
index 0a1265a..af4fada 100644
--- a/src/gui/dialogs/qfilesystemmodel_p.h
+++ b/src/gui/dialogs/qfilesystemmodel_p.h
@@ -164,9 +164,12 @@ public:
QHash<QString, QFileSystemNode *>::const_iterator iterator;
for(iterator = children.constBegin() ; iterator != children.constEnd() ; ++iterator) {
//On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/)
- if (!path.isEmpty())
- iterator.value()->updateIcon(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
- else
+ if (!path.isEmpty()) {
+ if (path.endsWith(QLatin1Char('/')))
+ iterator.value()->updateIcon(iconProvider, path + iterator.value()->fileName);
+ else
+ iterator.value()->updateIcon(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
+ } else
iterator.value()->updateIcon(iconProvider, iterator.value()->fileName);
}
}
@@ -177,9 +180,12 @@ public:
QHash<QString, QFileSystemNode *>::const_iterator iterator;
for(iterator = children.constBegin() ; iterator != children.constEnd() ; ++iterator) {
//On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/)
- if (!path.isEmpty())
- iterator.value()->retranslateStrings(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
- else
+ if (!path.isEmpty()) {
+ if (path.endsWith(QLatin1Char('/')))
+ iterator.value()->retranslateStrings(iconProvider, path + iterator.value()->fileName);
+ else
+ iterator.value()->retranslateStrings(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
+ } else
iterator.value()->retranslateStrings(iconProvider, iterator.value()->fileName);
}
}
@@ -202,7 +208,8 @@ public:
readOnly(true),
setRootPath(false),
filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs),
- nameFilterDisables(true) // false on windows, true on mac and unix
+ nameFilterDisables(true), // false on windows, true on mac and unix
+ disableRecursiveSort(false)
{
delayedSortTimer.setSingleShot(true);
}
@@ -288,6 +295,10 @@ public:
QDir::Filters filters;
QHash<const QFileSystemNode*, bool> bypassFilters;
bool nameFilterDisables;
+ //This flag is an optimization for the QFileDialog
+ //It enable a sort which is not recursive, it means
+ //we sort only what we see.
+ bool disableRecursiveSort;
#ifndef QT_NO_REGEXP
QList<QRegExp> nameFilters;
#endif
diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp
index 4c5bf4f..9ea06ac 100644
--- a/src/gui/dialogs/qfontdialog.cpp
+++ b/src/gui/dialogs/qfontdialog.cpp
@@ -337,6 +337,14 @@ void QFontDialogPrivate::init()
QFontDialog::~QFontDialog()
{
+#ifdef Q_WS_MAC
+ Q_D(QFontDialog);
+ if (d->delegate) {
+ QFontDialogPrivate::closeCocoaFontPanel(d->delegate);
+ QFontDialogPrivate::sharedFontPanelAvailable = true;
+ return;
+ }
+#endif
}
/*!
@@ -932,7 +940,7 @@ bool QFontDialogPrivate::sharedFontPanelAvailable = true;
\since 4.5
\overload
- Opens the dialog and connects its accepted() signal to the slot specified
+ Opens the dialog and connects its fontSelected() signal to the slot specified
by \a receiver and \a member.
The signal will be disconnected from the slot when the dialog is closed.
diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm
index 50917a1..3be53db 100644
--- a/src/gui/dialogs/qfontdialog_mac.mm
+++ b/src/gui/dialogs/qfontdialog_mac.mm
@@ -47,6 +47,7 @@
#include <private/qapplication_p.h>
#include <private/qfont_p.h>
#include <private/qfontengine_p.h>
+#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qt_mac_p.h>
#include <qdebug.h>
#import <AppKit/AppKit.h>
@@ -123,16 +124,16 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
QFont newFont;
if (cocoaFont) {
int pSize = qRound([cocoaFont pointSize]);
- QString family(QCFString::toQString(reinterpret_cast<CFStringRef>([cocoaFont familyName])));
- QString typeface(QCFString::toQString(reinterpret_cast<CFStringRef>([cocoaFont fontName])));
-// qDebug() << "original family" << family << "typeface" << typeface << "psize" << pSize;
+ QString family(qt_mac_NSStringToQString([cocoaFont familyName]));
+ QString typeface(qt_mac_NSStringToQString([cocoaFont fontName]));
+
int hyphenPos = typeface.indexOf(QLatin1Char('-'));
if (hyphenPos != -1) {
typeface.remove(0, hyphenPos + 1);
} else {
typeface = QLatin1String("Normal");
}
-// qDebug() << " massaged family" << family << "typeface" << typeface << "psize" << pSize;
+
newFont = QFontDatabase().font(family, typeface, pSize);
newFont.setUnderline(resolveFont.underline());
newFont.setStrikeOut(resolveFont.strikeOut());
@@ -566,6 +567,7 @@ void *QFontDialogPrivate::openCocoaFontPanel(const QFont &initial,
void QFontDialogPrivate::closeCocoaFontPanel(void *delegate)
{
+ QMacCocoaAutoReleasePool pool;
QCocoaFontPanelDelegate *theDelegate = static_cast<QCocoaFontPanelDelegate *>(delegate);
NSWindow *ourPanel = [theDelegate actualPanel];
[ourPanel close];
@@ -597,15 +599,37 @@ QFont QFontDialogPrivate::execCocoaFontPanel(bool *ok, const QFont &initial,
}
}
-void QFontDialogPrivate::setFont(void * delegate, const QFont &font)
+void QFontDialogPrivate::setFont(void *delegate, const QFont &font)
{
+ QMacCocoaAutoReleasePool pool;
QFontEngine *fe = font.d->engineForScript(QUnicodeTables::Common);
+ NSFontManager *mgr = [NSFontManager sharedFontManager];
+ NSFont *nsFont = 0;
+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if (qstrcmp(fe->name(), "CoreText") == 0) {
- const NSFont *nsFont = reinterpret_cast<const NSFont *>(static_cast<QCoreTextFontEngineMulti *>(fe)->ctfont);
- [[NSFontManager sharedFontManager] setSelectedFont:nsFont isMultiple:NO];
- }
+ nsFont = reinterpret_cast<const NSFont *>(static_cast<QCoreTextFontEngineMulti *>(fe)->ctfont);
+ } else
#endif
+ {
+ int weight = 5;
+ NSFontTraitMask mask = 0;
+ if (font.style() == QFont::StyleItalic) {
+ mask |= NSItalicFontMask;
+ }
+ if (font.weight() == QFont::Bold) {
+ weight = 9;
+ mask |= NSBoldFontMask;
+ }
+
+ NSFontManager *mgr = [NSFontManager sharedFontManager];
+ nsFont = [mgr fontWithFamily:qt_mac_QStringToNSString(font.family())
+ traits:mask
+ weight:weight
+ size:font.pointSize()];
+ }
+
+ [mgr setSelectedFont:nsFont isMultiple:NO];
[static_cast<QCocoaFontPanelDelegate *>(delegate) setQtFont:font];
}
diff --git a/src/gui/dialogs/qfscompleter_p.h b/src/gui/dialogs/qfscompleter_p.h
new file mode 100644
index 0000000..37d9c74
--- /dev/null
+++ b/src/gui/dialogs/qfscompleter_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui 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 QCOMPLETOR_P_H
+#define QCOMPLETOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qcompleter.h"
+#include <QtGui/qfilesystemmodel.h>
+
+#ifndef QT_NO_COMPLETER
+/*!
+ QCompleter that can deal with QFileSystemModel
+ */
+class QFSCompleter : public QCompleter {
+public:
+ QFSCompleter(QFileSystemModel *model, QObject *parent = 0)
+ : QCompleter(model, parent), proxyModel(0), sourceModel(model)
+ {
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ setCaseSensitivity(Qt::CaseInsensitive);
+#endif
+ }
+ QString pathFromIndex(const QModelIndex &index) const;
+ QStringList splitPath(const QString& path) const;
+
+ QAbstractProxyModel *proxyModel;
+ QFileSystemModel *sourceModel;
+};
+#endif // QT_NO_COMPLETER
+
+#endif // QCOMPLETOR_P_H
+
diff --git a/src/gui/dialogs/qinputdialog.cpp b/src/gui/dialogs/qinputdialog.cpp
index 78d99e3..8754324 100644
--- a/src/gui/dialogs/qinputdialog.cpp
+++ b/src/gui/dialogs/qinputdialog.cpp
@@ -1020,8 +1020,16 @@ QString QInputDialog::cancelButtonText() const
\since 4.5
\overload
- Opens the dialog and connects its accepted() signal to the slot specified
- by \a receiver and \a member.
+ This function connects one of its signals to the slot specified by \a receiver
+ and \a member. The specific signal depends on the arguments that are specified
+ in \a member. These are:
+
+ \list
+ \o textValueSelected() if \a member has a QString for its first argument.
+ \o intValueSelected() if \a member has an int for its first argument.
+ \o doubleValueSelected() if \a member has a double for its first argument.
+ \o accepted() if \a member has NO arguments.
+ \endlist
The signal will be disconnected from the slot when the dialog is closed.
*/
diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp
index 15a99af..00baf01 100644
--- a/src/gui/dialogs/qmessagebox.cpp
+++ b/src/gui/dialogs/qmessagebox.cpp
@@ -706,15 +706,10 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
Constructs a message box with no text and no buttons. \a parent is
passed to the QDialog constructor.
- If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
- {application modal} dialog box. If \a parent is a widget, the
- message box is \l{Qt::WindowModal} {window modal} relative to \a
- parent.
-
- On Mac OS X, if \a parent is not 0 and you want your message box
- to appear as a Qt::Sheet of that parent, set the message box's
- \l{setWindowModality()} {window modality} to Qt::WindowModal
- (default). Otherwise, the message box will be a standard dialog.
+ On Mac OS X, if you want your message box to appear
+ as a Qt::Sheet of its \a parent, set the message box's
+ \l{setWindowModality()} {window modality} to Qt::WindowModal or use open().
+ Otherwise, the message box will be a standard dialog.
*/
QMessageBox::QMessageBox(QWidget *parent)
@@ -1728,7 +1723,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title)
QMessageBox *msgBox = new QMessageBox(parent);
msgBox->setAttribute(Qt::WA_DeleteOnClose);
msgBox->setWindowTitle(title.isEmpty() ? tr("About Qt") : title);
- msgBox->setText(translatedTextAboutQt);
+ msgBox->setInformativeText(translatedTextAboutQt);
QPixmap pm(QLatin1String(":/trolltech/qmessagebox/images/qtlogo-64.png"));
if (!pm.isNull())
diff --git a/src/gui/dialogs/qpagesetupdialog.cpp b/src/gui/dialogs/qpagesetupdialog.cpp
index 63775d2..682071a 100644
--- a/src/gui/dialogs/qpagesetupdialog.cpp
+++ b/src/gui/dialogs/qpagesetupdialog.cpp
@@ -180,6 +180,12 @@ void QPageSetupDialog::open(QObject *receiver, const char *member)
QDialog::open();
}
+#if defined(Q_WS_MAC) || defined(Q_OS_WIN)
+/*! \fn void QPageSetupDialog::setVisible(bool visible)
+ \reimp
+*/
+#endif
+
QT_END_NAMESPACE
#endif
diff --git a/src/gui/dialogs/qpagesetupdialog_mac.mm b/src/gui/dialogs/qpagesetupdialog_mac.mm
index 401d95f..24aef34 100644
--- a/src/gui/dialogs/qpagesetupdialog_mac.mm
+++ b/src/gui/dialogs/qpagesetupdialog_mac.mm
@@ -251,9 +251,6 @@ QPageSetupDialog::QPageSetupDialog(QWidget *parent)
d->ep = static_cast<QMacPrintEngine *>(d->printer->paintEngine())->d_func();
}
-/*!
- \reimp
-*/
void QPageSetupDialog::setVisible(bool visible)
{
Q_D(QPageSetupDialog);
diff --git a/src/gui/dialogs/qpagesetupdialog_win.cpp b/src/gui/dialogs/qpagesetupdialog_win.cpp
index 4bb571c..bdce8ab 100644
--- a/src/gui/dialogs/qpagesetupdialog_win.cpp
+++ b/src/gui/dialogs/qpagesetupdialog_win.cpp
@@ -71,7 +71,7 @@ int QPageSetupDialog::exec()
return Rejected;
QWin32PrintEngine *engine = static_cast<QWin32PrintEngine*>(d->printer->paintEngine());
- QWin32PrintEnginePrivate *ep = static_cast<QWin32PrintEnginePrivate *>(engine->d_ptr);
+ QWin32PrintEnginePrivate *ep = static_cast<QWin32PrintEnginePrivate *>(engine->d_ptr.data());
PAGESETUPDLG psd;
memset(&psd, 0, sizeof(PAGESETUPDLG));
diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp
index 87a4e65..17d0047 100644
--- a/src/gui/dialogs/qprintdialog_unix.cpp
+++ b/src/gui/dialogs/qprintdialog_unix.cpp
@@ -44,7 +44,6 @@
#ifndef QT_NO_PRINTDIALOG
#include "private/qabstractprintdialog_p.h"
-#include "qfiledialog_p.h"
#include <QtGui/qmessagebox.h>
#include "qprintdialog.h"
#include "qfiledialog.h"
@@ -55,6 +54,7 @@
#include <QtGui/qdialogbuttonbox.h>
+#include "qfscompleter_p.h"
#include "ui_qprintpropertieswidget.h"
#include "ui_qprintsettingsoutput.h"
#include "ui_qprintwidget.h"
@@ -696,7 +696,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p)
QFileSystemModel *fsm = new QFileSystemModel(widget.filename);
fsm->setRootPath(QDir::homePath());
#if !defined(QT_NO_COMPLETER) && !defined(QT_NO_FILEDIALOG)
- widget.filename->setCompleter(new QFSCompletor(fsm, widget.filename));
+ widget.filename->setCompleter(new QFSCompleter(fsm, widget.filename));
#endif
#endif
_q_printerChanged(currentPrinterIndex);
diff --git a/src/gui/dialogs/qprintpreviewdialog.cpp b/src/gui/dialogs/qprintpreviewdialog.cpp
index c00bd14..61949d8 100644
--- a/src/gui/dialogs/qprintpreviewdialog.cpp
+++ b/src/gui/dialogs/qprintpreviewdialog.cpp
@@ -42,6 +42,7 @@
#include "qprintpreviewdialog.h"
#include "qprintpreviewwidget.h"
#include <private/qprinter_p.h>
+#include "private/qdialog_p.h"
#include <QtGui/qaction.h>
#include <QtGui/qboxlayout.h>
@@ -128,12 +129,12 @@ private:
};
} // anonymous namespace
-class QPrintPreviewDialogPrivate
+class QPrintPreviewDialogPrivate : public QDialogPrivate
{
Q_DECLARE_PUBLIC(QPrintPreviewDialog)
public:
- QPrintPreviewDialogPrivate(QPrintPreviewDialog *q)
- : q_ptr(q), printDialog(0), ownPrinter(false),
+ QPrintPreviewDialogPrivate()
+ : printDialog(0), ownPrinter(false),
initialized(false) {}
// private slots
@@ -158,7 +159,6 @@ public:
void updatePageNumLabel();
void updateZoomFactor();
- QPrintPreviewDialog *q_ptr;
QPrintDialog *printDialog;
QPrintPreviewWidget *preview;
QPrinter *printer;
@@ -680,7 +680,7 @@ void QPrintPreviewDialogPrivate::_q_zoomFactorChanged()
\sa QWidget::setWindowFlags()
*/
QPrintPreviewDialog::QPrintPreviewDialog(QPrinter* printer, QWidget *parent, Qt::WindowFlags flags)
- : QDialog(parent, flags), d_ptr(new QPrintPreviewDialogPrivate(this))
+ : QDialog(*new QPrintPreviewDialogPrivate, parent, flags)
{
Q_D(QPrintPreviewDialog);
d->init(printer);
@@ -694,7 +694,7 @@ QPrintPreviewDialog::QPrintPreviewDialog(QPrinter* printer, QWidget *parent, Qt:
system default printer.
*/
QPrintPreviewDialog::QPrintPreviewDialog(QWidget *parent, Qt::WindowFlags f)
- : QDialog(parent, f), d_ptr(new QPrintPreviewDialogPrivate(this))
+ : QDialog(*new QPrintPreviewDialogPrivate, parent, f)
{
Q_D(QPrintPreviewDialog);
d->init();
@@ -709,7 +709,6 @@ QPrintPreviewDialog::~QPrintPreviewDialog()
if (d->ownPrinter)
delete d->printer;
delete d->printDialog;
- delete d_ptr;
}
/*!
diff --git a/src/gui/dialogs/qprintpreviewdialog.h b/src/gui/dialogs/qprintpreviewdialog.h
index c3a4d57..49262db 100644
--- a/src/gui/dialogs/qprintpreviewdialog.h
+++ b/src/gui/dialogs/qprintpreviewdialog.h
@@ -94,7 +94,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_previewChanged())
Q_PRIVATE_SLOT(d_func(), void _q_zoomFactorChanged())
- QPrintPreviewDialogPrivate *d_ptr;
+ void *dummy; // ### Qt 5 - remove me
};
diff --git a/src/gui/dialogs/qwizard.cpp b/src/gui/dialogs/qwizard.cpp
index 32395c4..298f23f 100644
--- a/src/gui/dialogs/qwizard.cpp
+++ b/src/gui/dialogs/qwizard.cpp
@@ -1465,7 +1465,7 @@ void QWizardPrivate::handleAeroStyleChange()
return; // prevent recursion
inHandleAeroStyleChange = true;
- vistaHelper->backButton()->disconnect();
+ vistaHelper->disconnectBackButton();
q->removeEventFilter(vistaHelper);
if (isVistaThemeEnabled()) {
@@ -1491,7 +1491,7 @@ void QWizardPrivate::handleAeroStyleChange()
q->setMouseTracking(true); // ### original value possibly different
q->unsetCursor(); // ### ditto
antiFlickerWidget->move(0, 0);
- vistaHelper->backButton()->hide();
+ vistaHelper->hideBackButton();
vistaHelper->setTitleBarIconAndCaptionVisible(true);
}
diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp
index 64696de..8aad4af 100644
--- a/src/gui/dialogs/qwizard_win.cpp
+++ b/src/gui/dialogs/qwizard_win.cpp
@@ -239,9 +239,11 @@ void QVistaBackButton::paintEvent(QPaintEvent *)
QVistaHelper::QVistaHelper(QWizard *wizard)
: pressed(false)
, wizard(wizard)
+ , backButton_(0)
{
is_vista = resolveSymbols();
- backButton_ = new QVistaBackButton(wizard);
+ if (is_vista)
+ backButton_ = new QVistaBackButton(wizard);
}
QVistaHelper::~QVistaHelper()
@@ -310,6 +312,7 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
QRect(0, 0, wizard->width(), titleBarSize() + topOffset()),
painter->paintEngine()->getDC());
+ Q_ASSERT(backButton_);
const int btnTop = backButton_->mapToParent(QPoint()).y();
const int btnHeight = backButton_->size().height();
const int verticalCenter = (btnTop + btnHeight / 2);
diff --git a/src/gui/dialogs/qwizard_win_p.h b/src/gui/dialogs/qwizard_win_p.h
index cbb3b17..148be26 100644
--- a/src/gui/dialogs/qwizard_win_p.h
+++ b/src/gui/dialogs/qwizard_win_p.h
@@ -94,6 +94,8 @@ public:
void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *event);
QVistaBackButton *backButton() const { return backButton_; }
+ void disconnectBackButton() { if (backButton_) backButton_->disconnect(); }
+ void hideBackButton() { if (backButton_) backButton_->hide(); }
void setWindowPosHack();
QColor basicWindowFrameColor();
enum VistaState { VistaAero, VistaBasic, Classic, Dirty };
diff --git a/src/gui/embedded/qkbdtty_qws.cpp b/src/gui/embedded/qkbdtty_qws.cpp
index b588e55..7c162bc 100644
--- a/src/gui/embedded/qkbdtty_qws.cpp
+++ b/src/gui/embedded/qkbdtty_qws.cpp
@@ -97,6 +97,7 @@ private slots:
private:
QWSPC101KeyboardHandler *handler;
struct termios origTermData;
+ int originalKbdMode;
};
QWSTtyKeyboardHandler::QWSTtyKeyboardHandler(const QString &device)
@@ -156,6 +157,7 @@ QWSTtyKbPrivate::QWSTtyKbPrivate(QWSPC101KeyboardHandler *h, const QString &devi
tcgetattr(kbdFD, &termdata);
#if defined(Q_OS_LINUX)
+ ioctl(kbdFD, KDGKBMODE, &originalKbdMode);
# ifdef QT_QWS_USE_KEYCODES
ioctl(kbdFD, KDSKBMODE, K_MEDIUMRAW);
# else
@@ -202,7 +204,7 @@ QWSTtyKbPrivate::~QWSTtyKbPrivate()
{
if (kbdFD >= 0) {
#if defined(Q_OS_LINUX)
- ioctl(kbdFD, KDSKBMODE, K_XLATE);
+ ioctl(kbdFD, KDSKBMODE, originalKbdMode);
#endif
tcsetattr(kbdFD, TCSANOW, &origTermData);
::close(kbdFD);
diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp
index 6741f2c..39a74d5 100644
--- a/src/gui/embedded/qscreen_qws.cpp
+++ b/src/gui/embedded/qscreen_qws.cpp
@@ -1394,7 +1394,7 @@ QImage::Format QScreenPrivate::preferredImageFormat() const
altered. Note that the default implementations of these functions
do nothing.
- Reimplement the the mapFromDevice() and mapToDevice() functions to
+ Reimplement the mapFromDevice() and mapToDevice() functions to
map objects from the framebuffer coordinate system to the
coordinate space used by the application, and vice versa. Be aware
that the default implementations simply return the given objects
diff --git a/src/gui/embedded/qsoundqss_qws.cpp b/src/gui/embedded/qsoundqss_qws.cpp
index 283bbd3..ed988ca 100644
--- a/src/gui/embedded/qsoundqss_qws.cpp
+++ b/src/gui/embedded/qsoundqss_qws.cpp
@@ -1036,24 +1036,28 @@ void QWSSoundServerPrivate::stopFile(int wid, int sid)
void QWSSoundServerPrivate::stopAll(int wid)
{
QWSSoundServerProvider *bucket;
- QList<QWSSoundServerProvider*>::Iterator it = active.begin();
- while (it != active.end()) {
- bucket = *it;
- if (bucket->groupId() == wid) {
- it = active.erase(it);
- delete bucket;
- } else {
- ++it;
+ if (!active.isEmpty()) {
+ QList<QWSSoundServerProvider*>::Iterator it = active.begin();
+ while (it != active.end()) {
+ bucket = *it;
+ if (bucket->groupId() == wid) {
+ it = active.erase(it);
+ delete bucket;
+ } else {
+ ++it;
+ }
}
}
- it = inactive.begin();
- while (it != inactive.end()) {
- bucket = *it;
- if (bucket->groupId() == wid) {
- it = inactive.erase(it);
- delete bucket;
- } else {
- ++it;
+ if (!inactive.isEmpty()) {
+ QList<QWSSoundServerProvider*>::Iterator it = inactive.begin();
+ while (it != inactive.end()) {
+ bucket = *it;
+ if (bucket->groupId() == wid) {
+ it = inactive.erase(it);
+ delete bucket;
+ } else {
+ ++it;
+ }
}
}
}
diff --git a/src/gui/embedded/qwindowsystem_qws.cpp b/src/gui/embedded/qwindowsystem_qws.cpp
index fdcd193..e3d56ad 100644
--- a/src/gui/embedded/qwindowsystem_qws.cpp
+++ b/src/gui/embedded/qwindowsystem_qws.cpp
@@ -1304,7 +1304,13 @@ QWSServer::QWSServer(int flags, QObject *parent) :
QObject(*new QWSServerPrivate, parent)
{
Q_D(QWSServer);
- d->initServer(flags);
+ QT_TRY {
+ d->initServer(flags);
+ } QT_CATCH(...) {
+ qwsServer = 0;
+ qwsServerPrivate = 0;
+ QT_RETHROW;
+ }
}
#ifdef QT3_SUPPORT
@@ -1750,21 +1756,23 @@ void QWSServerPrivate::cleanupFonts(bool force)
#if defined(QWS_DEBUG_FONTCLEANUP)
qDebug() << "cleanupFonts()";
#endif
- QMap<QByteArray, int>::Iterator it = fontReferenceCount.begin();
- while (it != fontReferenceCount.end()) {
- if (it.value() && !force) {
- ++it;
- continue;
- }
+ if (!fontReferenceCount.isEmpty()) {
+ QMap<QByteArray, int>::Iterator it = fontReferenceCount.begin();
+ while (it != fontReferenceCount.end()) {
+ if (it.value() && !force) {
+ ++it;
+ continue;
+ }
- const QByteArray &fontName = it.key();
+ const QByteArray &fontName = it.key();
#if defined(QWS_DEBUG_FONTCLEANUP)
- qDebug() << "removing unused font file" << fontName;
+ qDebug() << "removing unused font file" << fontName;
#endif
- QFile::remove(QFile::decodeName(fontName));
- sendFontRemovedEvent(fontName);
+ QFile::remove(QFile::decodeName(fontName));
+ sendFontRemovedEvent(fontName);
- it = fontReferenceCount.erase(it);
+ it = fontReferenceCount.erase(it);
+ }
}
if (crashedClientIds.isEmpty())
@@ -3966,7 +3974,8 @@ void QWSServerPrivate::openDisplay()
void QWSServerPrivate::closeDisplay()
{
- qt_screen->shutdownDevice();
+ if (qt_screen)
+ qt_screen->shutdownDevice();
}
/*!
@@ -4065,9 +4074,14 @@ void QWSServer::startup(int flags)
void QWSServer::closedown()
{
- unlink(qws_qtePipeFilename().toLatin1().constData());
- delete qwsServer;
+ QScopedPointer<QWSServer> server(qwsServer);
qwsServer = 0;
+ QT_TRY {
+ unlink(qws_qtePipeFilename().toLatin1().constData());
+ } QT_CATCH(const std::bad_alloc &) {
+ // ### TODO - what to do when we run out of memory
+ // when calling toLatin1?
+ }
}
void QWSServerPrivate::emergency_cleanup()
diff --git a/src/gui/embedded/qwscursor_qws.cpp b/src/gui/embedded/qwscursor_qws.cpp
index 3a5bd2c..b25e9b1 100644
--- a/src/gui/embedded/qwscursor_qws.cpp
+++ b/src/gui/embedded/qwscursor_qws.cpp
@@ -531,7 +531,7 @@ void QWSCursor::set(const uchar *data, const uchar *mask,
cursor = QImage(width,height, QImage::Format_Indexed8);
- if (!width || !height || !data || !mask)
+ if (!width || !height || !data || !mask || cursor.isNull())
return;
cursor.setNumColors(3);
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 4908296..596326b 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -515,6 +515,7 @@
#include <QtGui/qpixmapcache.h>
#include <QtGui/qstyleoption.h>
#include <QtGui/qevent.h>
+#include <QInputContext>
#include <private/qgraphicsitem_p.h>
#include <private/qgraphicswidget_p.h>
@@ -874,8 +875,6 @@ QGraphicsItem::~QGraphicsItem()
if (d_ptr->scene)
d_ptr->scene->d_func()->_q_removeItemLater(this);
- delete d_ptr;
-
qt_dataStore()->data.remove(this);
}
@@ -1522,6 +1521,10 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
if (visible == quint32(newVisible))
return;
+ // Don't show child if parent is not visible
+ if (parent && newVisible && !parent->d_ptr->visible)
+ return;
+
// Modify the property.
const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange,
quint32(newVisible)));
@@ -2727,7 +2730,7 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
QTransform x;
const QGraphicsItem *p = child;
do {
- const QGraphicsItemPrivate *pd = p->d_ptr;
+ const QGraphicsItemPrivate *pd = p->d_ptr.data();
if (pd->hasTransform)
x *= p->transform();
if (!pd->pos.isNull())
@@ -3065,7 +3068,7 @@ QRectF QGraphicsItem::sceneBoundingRect() const
const QGraphicsItem *parentItem = this;
const QGraphicsItemPrivate *itemd;
do {
- itemd = parentItem->d_ptr;
+ itemd = parentItem->d_ptr.data();
if (itemd->hasTransform)
break;
offset += itemd->pos;
@@ -7605,7 +7608,7 @@ class QGraphicsTextItemPrivate
{
public:
QGraphicsTextItemPrivate()
- : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false)
+ : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0)
{ }
mutable QTextControl *control;
@@ -7626,6 +7629,8 @@ public:
bool useDefaultImpl;
bool tabChangesFocus;
+ uint clickCausedFocus : 1;
+
QGraphicsTextItem *qq;
};
@@ -7952,7 +7957,13 @@ void QGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
dd->useDefaultImpl = false;
return;
}
+
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -7964,7 +7975,13 @@ void QGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QGraphicsItem::mouseMoveEvent(event);
return;
}
+
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -7984,7 +8001,23 @@ void QGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
return;
}
+
+ if (event->button() == Qt::LeftButton && qApp->autoSipEnabled()
+ && (!dd->clickCausedFocus || qApp->autoSipOnMouseFocus())) {
+ QEvent _event(QEvent::RequestSoftwareInputPanel);
+ QApplication::sendEvent(event->widget(), &_event);
+ } else {
+ QGraphicsItem::mouseReleaseEvent(event);
+ }
+ dd->clickCausedFocus = 0;
+
dd->sendControlEvent(event);
+
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8003,6 +8036,11 @@ void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
}
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8011,6 +8049,11 @@ void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8019,6 +8062,18 @@ void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
void QGraphicsTextItem::keyPressEvent(QKeyEvent *event)
{
dd->sendControlEvent(event);
+ QList<QGraphicsView *> views = scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ Q_ASSERT(view->viewport());
+ if(view->viewport()->hasFocus()) {
+ QInputContext *qic = view->viewport()->inputContext();
+ if(qic){
+ qic->update();
+ }
+ break;
+ }
+ }
}
/*!
@@ -8027,6 +8082,18 @@ void QGraphicsTextItem::keyPressEvent(QKeyEvent *event)
void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event)
{
dd->sendControlEvent(event);
+ QList<QGraphicsView *> views = scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ Q_ASSERT(view->viewport());
+ if(view->viewport()->hasFocus()) {
+ QInputContext *qic = view->viewport()->inputContext();
+ if(qic){
+ qic->update();
+ }
+ break;
+ }
+ }
}
/*!
@@ -8035,7 +8102,22 @@ void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event)
void QGraphicsTextItem::focusInEvent(QFocusEvent *event)
{
dd->sendControlEvent(event);
+ if (event->reason() == Qt::MouseFocusReason) {
+ dd->clickCausedFocus = 1;
+ }
update();
+ QList<QGraphicsView *> views = scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ Q_ASSERT(view->viewport());
+ if(view->viewport()->hasFocus()) {
+ QInputContext *qic = view->viewport()->inputContext();
+ if(qic){
+ qic->reset();
+ }
+ break;
+ }
+ }
}
/*!
@@ -8045,6 +8127,18 @@ void QGraphicsTextItem::focusOutEvent(QFocusEvent *event)
{
dd->sendControlEvent(event);
update();
+ QList<QGraphicsView *> views = scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ Q_ASSERT(view->viewport());
+ if(view->viewport()->hasFocus()) {
+ QInputContext *qic = view->viewport()->inputContext();
+ if(qic){
+ qic->reset();
+ }
+ break;
+ }
+ }
}
/*!
@@ -8053,6 +8147,11 @@ void QGraphicsTextItem::focusOutEvent(QFocusEvent *event)
void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8061,6 +8160,11 @@ void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8069,6 +8173,11 @@ void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8077,6 +8186,11 @@ void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
void QGraphicsTextItem::dropEvent(QGraphicsSceneDragDropEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8093,6 +8207,11 @@ void QGraphicsTextItem::inputMethodEvent(QInputMethodEvent *event)
void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8101,6 +8220,11 @@ void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8109,6 +8233,11 @@ void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index b98882d..25678a6 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -46,6 +46,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qvariant.h>
#include <QtCore/qrect.h>
+#include <QtCore/qscopedpointer.h>
#include <QtGui/qpainterpath.h>
#include <QtGui/qpixmap.h>
@@ -380,7 +381,7 @@ protected:
protected:
QGraphicsItem(QGraphicsItemPrivate &dd,
QGraphicsItem *parent, QGraphicsScene *scene);
- QGraphicsItemPrivate *d_ptr;
+ QScopedPointer<QGraphicsItemPrivate> d_ptr;
void addToIndex();
void removeFromIndex();
diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp
index eaa97ff..c291763 100644
--- a/src/gui/graphicsview/qgraphicslayoutitem.cpp
+++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp
@@ -255,7 +255,7 @@ QGraphicsItem *QGraphicsLayoutItemPrivate::parentItem() const
passing a QGraphicsLayoutItem pointer to QGraphicsLayoutItem's
protected constructor, or by calling setParentLayoutItem(). The
parentLayoutItem() function returns a pointer to the item's layoutItem
- parent. If the item's parent is 0 or if the the parent does not inherit
+ parent. If the item's parent is 0 or if the parent does not inherit
from QGraphicsItem, the parentLayoutItem() function then returns 0.
isLayout() returns true if the QGraphicsLayoutItem subclass is itself a
layout, or false otherwise.
@@ -307,7 +307,6 @@ QGraphicsLayoutItem::~QGraphicsLayoutItem()
}
}
}
- delete d_ptr;
}
/*!
diff --git a/src/gui/graphicsview/qgraphicslayoutitem.h b/src/gui/graphicsview/qgraphicslayoutitem.h
index 31f5d90..d667c4f 100644
--- a/src/gui/graphicsview/qgraphicslayoutitem.h
+++ b/src/gui/graphicsview/qgraphicslayoutitem.h
@@ -42,6 +42,7 @@
#ifndef QGRAPHICSLAYOUTITEM_H
#define QGRAPHICSLAYOUTITEM_H
+#include <QtCore/qscopedpointer.h>
#include <QtGui/qsizepolicy.h>
#include <QtGui/qevent.h>
@@ -112,7 +113,7 @@ protected:
QGraphicsLayoutItem(QGraphicsLayoutItemPrivate &dd);
virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const = 0;
- QGraphicsLayoutItemPrivate *d_ptr;
+ QScopedPointer<QGraphicsLayoutItemPrivate> d_ptr;
private:
QSizeF *effectiveSizeHints(const QSizeF &constraint) const;
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.h b/src/gui/graphicsview/qgraphicsproxywidget.h
index b2c3c8f..f006319 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget.h
+++ b/src/gui/graphicsview/qgraphicsproxywidget.h
@@ -127,7 +127,7 @@ protected Q_SLOTS:
private:
Q_DISABLE_COPY(QGraphicsProxyWidget)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QGraphicsProxyWidget)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsProxyWidget)
Q_PRIVATE_SLOT(d_func(), void _q_removeWidgetSlot())
friend class QWidget;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index b89e352..5114351 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -1824,8 +1824,8 @@ void QGraphicsScenePrivate::invalidateSortCache()
inline bool qt_closestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2)
{
// Return true if sibling item1 is on top of item2.
- const QGraphicsItemPrivate *d1 = item1->d_ptr;
- const QGraphicsItemPrivate *d2 = item2->d_ptr;
+ const QGraphicsItemPrivate *d1 = item1->d_ptr.data();
+ const QGraphicsItemPrivate *d2 = item2->d_ptr.data();
bool f1 = d1->flags & QGraphicsItem::ItemStacksBehindParent;
bool f2 = d2->flags & QGraphicsItem::ItemStacksBehindParent;
if (f1 != f2) return f2;
@@ -1852,8 +1852,8 @@ inline bool qt_closestItemFirst(const QGraphicsItem *item1, const QGraphicsItem
bool QGraphicsScenePrivate::closestItemFirst_withoutCache(const QGraphicsItem *item1, const QGraphicsItem *item2)
{
// Siblings? Just check their z-values.
- const QGraphicsItemPrivate *d1 = item1->d_ptr;
- const QGraphicsItemPrivate *d2 = item2->d_ptr;
+ const QGraphicsItemPrivate *d1 = item1->d_ptr.data();
+ const QGraphicsItemPrivate *d2 = item2->d_ptr.data();
if (d1->parent == d2->parent)
return qt_closestLeaf(item1, item2);
@@ -4687,7 +4687,7 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
const QStyleOptionGraphicsItem *option, QWidget *widget,
bool painterStateProtection)
{
- QGraphicsItemPrivate *itemd = item->d_ptr;
+ QGraphicsItemPrivate *itemd = item->d_ptr.data();
QGraphicsItem::CacheMode cacheMode = QGraphicsItem::CacheMode(itemd->cacheMode);
// Render directly, using no cache.
diff --git a/src/gui/graphicsview/qgraphicssceneevent.cpp b/src/gui/graphicsview/qgraphicssceneevent.cpp
index b819c2c..ad57aac 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.cpp
+++ b/src/gui/graphicsview/qgraphicssceneevent.cpp
@@ -313,7 +313,6 @@ QGraphicsSceneEvent::QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type ty
*/
QGraphicsSceneEvent::~QGraphicsSceneEvent()
{
- delete d_ptr;
}
/*!
@@ -844,7 +843,7 @@ QGraphicsSceneContextMenuEvent::~QGraphicsSceneContextMenuEvent()
/*!
Returns the position of the mouse cursor in item coordinates at the moment
- the the context menu was requested.
+ the context menu was requested.
\sa scenePos(), screenPos()
*/
@@ -992,7 +991,7 @@ QGraphicsSceneHoverEvent::~QGraphicsSceneHoverEvent()
/*!
Returns the position of the mouse cursor in item coordinates at the moment
- the the hover event was sent.
+ the hover event was sent.
\sa scenePos(), screenPos()
*/
@@ -1017,7 +1016,7 @@ void QGraphicsSceneHoverEvent::setPos(const QPointF &pos)
/*!
Returns the position of the mouse cursor in scene coordinates at the
- moment the the hover event was sent.
+ moment the hover event was sent.
\sa pos(), screenPos()
*/
@@ -1042,7 +1041,7 @@ void QGraphicsSceneHoverEvent::setScenePos(const QPointF &pos)
/*!
Returns the position of the mouse cursor in screen coordinates at the
- moment the the hover event was sent.
+ moment the hover event was sent.
\sa pos(), scenePos()
*/
@@ -1138,7 +1137,7 @@ void QGraphicsSceneHoverEvent::setLastScreenPos(const QPoint &pos)
/*!
\since 4.4
- Returns the keyboard modifiers at the moment the the hover event was sent.
+ Returns the keyboard modifiers at the moment the hover event was sent.
*/
Qt::KeyboardModifiers QGraphicsSceneHoverEvent::modifiers() const
{
@@ -1184,7 +1183,7 @@ QGraphicsSceneHelpEvent::~QGraphicsSceneHelpEvent()
/*!
Returns the position of the mouse cursor in scene coordinates at the
- moment the the help event was sent.
+ moment the help event was sent.
\sa screenPos()
*/
@@ -1209,7 +1208,7 @@ void QGraphicsSceneHelpEvent::setScenePos(const QPointF &pos)
/*!
Returns the position of the mouse cursor in screen coordinates at the
- moment the the help event was sent.
+ moment the help event was sent.
\sa scenePos()
*/
diff --git a/src/gui/graphicsview/qgraphicssceneevent.h b/src/gui/graphicsview/qgraphicssceneevent.h
index be50e96..4ebe3df 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.h
+++ b/src/gui/graphicsview/qgraphicssceneevent.h
@@ -44,6 +44,7 @@
#include <QtCore/qcoreevent.h>
#include <QtCore/qpoint.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -70,7 +71,7 @@ public:
protected:
QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type type = None);
- QGraphicsSceneEventPrivate *d_ptr;
+ QScopedPointer<QGraphicsSceneEventPrivate> d_ptr;
Q_DECLARE_PRIVATE(QGraphicsSceneEvent)
};
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index a795fb4..96e9a96 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -753,7 +753,7 @@ QRect QGraphicsViewPrivate::mapToViewRect(const QGraphicsItem *item, const QRect
const QGraphicsItem *parentItem = item;
const QGraphicsItemPrivate *itemd;
do {
- itemd = parentItem->d_ptr;
+ itemd = parentItem->d_ptr.data();
if (itemd->hasTransform)
break;
offset += itemd->pos;
@@ -1195,6 +1195,11 @@ QGraphicsView::QGraphicsView(QWidget *parent)
// using a simple reference count. The same goes for acceptDrops and mouse
// tracking.
setAttribute(Qt::WA_InputMethodEnabled);
+
+ // viewport part of the graphics view has to be enabled
+ // as well, because when events come this widget is asked
+ // for input context and so on
+ viewport()->setAttribute(Qt::WA_InputMethodEnabled);
}
/*!
@@ -1209,6 +1214,11 @@ QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent)
setAcceptDrops(true);
setBackgroundRole(QPalette::Base);
setAttribute(Qt::WA_InputMethodEnabled);
+
+ // viewport part of the graphics view has to be enabled
+ // as well, because when events come this widget is asked
+ // for input context and so on
+ viewport()->setAttribute(Qt::WA_InputMethodEnabled);
}
/*!
@@ -1221,6 +1231,11 @@ QGraphicsView::QGraphicsView(QGraphicsViewPrivate &dd, QWidget *parent)
setAcceptDrops(true);
setBackgroundRole(QPalette::Base);
setAttribute(Qt::WA_InputMethodEnabled);
+
+ // viewport part of the graphics view has to be enabled
+ // as well, because when events come this widget is asked
+ // for input context and so on
+ viewport()->setAttribute(Qt::WA_InputMethodEnabled);
}
/*!
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 7f02fb9..aa2b9bf 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -366,7 +366,7 @@ void QGraphicsWidget::resize(const QSizeF &size)
void QGraphicsWidget::setGeometry(const QRectF &rect)
{
QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
- QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr;
+ QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr.data();
QRectF newGeom;
QPointF oldPos = d->geom.topLeft();
if (!wd->inSetPos) {
@@ -1887,8 +1887,10 @@ void QGraphicsWidget::insertAction(QAction *before, QAction *action)
}
d->actions.insert(pos, action);
- QActionPrivate *apriv = action->d_func();
- apriv->graphicsWidgets.append(this);
+ if (index == -1) {
+ QActionPrivate *apriv = action->d_func();
+ apriv->graphicsWidgets.append(this);
+ }
QActionEvent e(QEvent::ActionAdded, action, before);
QApplication::sendEvent(this, &e);
diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h
index 34f1c5f..49de542 100644
--- a/src/gui/graphicsview/qgraphicswidget.h
+++ b/src/gui/graphicsview/qgraphicswidget.h
@@ -225,7 +225,7 @@ protected:
private:
Q_DISABLE_COPY(QGraphicsWidget)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QGraphicsWidget)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsWidget)
friend class QGraphicsScene;
friend class QGraphicsScenePrivate;
friend class QGraphicsView;
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index d3b7388..30aaa51 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -42,4 +42,7 @@ QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtGui.dynlist
DEFINES += Q_INTERNAL_QAPP_SRC
-symbian:TARGET.UID3=0x2001B2DD \ No newline at end of file
+symbian:TARGET.UID3=0x2001B2DD
+
+# ro-section in gui can exceed default allocated space, so more rw-section little further
+symbian-sbsv2: MMP_RULES += "LINKEROPTION armcc --rw-base 0x800000" \ No newline at end of file
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 53430ab..0799ea7 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -428,10 +428,13 @@ bool QPixmapIconEngine::read(QDataStream &in)
in >> sz;
in >> mode;
in >> state;
- if (pm.isNull())
+ if (pm.isNull()) {
addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
- else
- addPixmap(pm, QIcon::Mode(mode), QIcon::State(state));
+ } else {
+ QPixmapIconEngineEntry pe(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
+ pe.pixmap = pm;
+ pixmaps += pe;
+ }
}
return true;
}
@@ -922,7 +925,7 @@ QList<QSize> QIcon::availableSizes(Mode mode, State state) const
\relates QIcon
\since 4.2
- Writes the given \a icon to the the given \a stream as a PNG
+ Writes the given \a icon to the given \a stream as a PNG
image. If the icon contains more than one image, all images will
be written to the stream. Note that writing the stream to a file
will not produce a valid image file.
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index c7a20db..34ad99c 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -185,6 +185,13 @@ static int depthForFormat(QImage::Format format)
return depth;
}
+/*! \fn QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors)
+
+ \internal
+
+ Creates a new image data.
+ Returns 0 if invalid parameters are give or anything else failed.
+*/
QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors)
{
if (!size.isValid() || numColors < 0 || format == QImage::Format_Invalid)
@@ -223,7 +230,7 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu
|| INT_MAX/sizeof(uchar *) < uint(height))
return 0;
- QImageData *d = new QImageData;
+ QScopedPointer<QImageData> d(new QImageData);
d->colortable.resize(numColors);
if (depth == 1) {
d->colortable[0] = QColor(Qt::black).rgba();
@@ -246,12 +253,11 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu
d->data = (uchar *)malloc(d->nbytes);
if (!d->data) {
- delete d;
return 0;
}
d->ref.ref();
- return d;
+ return d.take();
}
@@ -1621,6 +1627,7 @@ int QImage::numColors() const
/*!
Returns a pointer to the scanline pointer table. This is the
beginning of the data block for the image.
+ Returns 0 in case of an error.
Use the bits() or scanLine() function instead.
*/
@@ -1636,6 +1643,8 @@ uchar **QImage::jumpTable()
if (!d->jumptable) {
d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *));
+ if (!d->jumptable)
+ return 0;
uchar *data = d->data;
int height = d->height;
uchar **p = d->jumptable;
@@ -1656,6 +1665,8 @@ const uchar * const *QImage::jumpTable() const
return 0;
if (!d->jumptable) {
d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *));
+ if (!d->jumptable)
+ return 0;
uchar *data = d->data;
int height = d->height;
uchar **p = d->jumptable;
@@ -4996,7 +5007,7 @@ QPoint QImage::offset() const
/*!
\fn void QImage::setOffset(const QPoint& offset)
- Sets the the number of pixels by which the image is intended to be
+ Sets the number of pixels by which the image is intended to be
offset by when positioning relative to other images, to \a offset.
\sa offset(), {QImage#Image Information}{Image Information}
diff --git a/src/gui/image/qimageiohandler.cpp b/src/gui/image/qimageiohandler.cpp
index a47c69e..f432f87 100644
--- a/src/gui/image/qimageiohandler.cpp
+++ b/src/gui/image/qimageiohandler.cpp
@@ -272,7 +272,6 @@ QImageIOHandler::QImageIOHandler(QImageIOHandlerPrivate &dd)
*/
QImageIOHandler::~QImageIOHandler()
{
- delete d_ptr;
}
/*!
diff --git a/src/gui/image/qimageiohandler.h b/src/gui/image/qimageiohandler.h
index 3b654f3..34de715 100644
--- a/src/gui/image/qimageiohandler.h
+++ b/src/gui/image/qimageiohandler.h
@@ -44,6 +44,7 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -109,7 +110,7 @@ public:
protected:
QImageIOHandler(QImageIOHandlerPrivate &dd);
- QImageIOHandlerPrivate *d_ptr;
+ QScopedPointer<QImageIOHandlerPrivate> d_ptr;
private:
Q_DISABLE_COPY(QImageIOHandler)
};
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index 92023e0..8528173 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -132,7 +132,6 @@ QPicture::QPicture(int formatVersion)
{
Q_D(QPicture);
d_ptr->q_ptr = this;
- d->paintEngine = 0;
if (formatVersion == 0)
qWarning("QPicture: invalid format version 0");
@@ -155,7 +154,7 @@ QPicture::QPicture(int formatVersion)
*/
QPicture::QPicture(const QPicture &pic)
- : QPaintDevice(), d_ptr(pic.d_ptr)
+ : QPaintDevice(), d_ptr(pic.d_ptr.data())
{
d_func()->ref.ref();
}
@@ -173,10 +172,6 @@ QPicture::QPicture(QPicturePrivate &dptr)
*/
QPicture::~QPicture()
{
- if (!d_func()->ref.deref()) {
- delete d_func()->paintEngine;
- delete d_func();
- }
}
/*!
@@ -1030,9 +1025,7 @@ void QPicture::detach_helper()
x->formatMinor = d->formatMinor;
x->brect = d->brect;
x->override_rect = d->override_rect;
- if (!d->ref.deref())
- delete d;
- d_ptr = x;
+ d_ptr.reset(x);
}
/*!
@@ -1041,7 +1034,7 @@ void QPicture::detach_helper()
*/
QPicture& QPicture::operator=(const QPicture &p)
{
- qAtomicAssign<QPicturePrivate>(d_ptr, p.d_ptr);
+ d_ptr.assign(p.d_ptr.data());
return *this;
}
@@ -1135,8 +1128,8 @@ bool QPicturePrivate::checkFormat()
QPaintEngine *QPicture::paintEngine() const
{
if (!d_func()->paintEngine)
- const_cast<QPicture*>(this)->d_func()->paintEngine = new QPicturePaintEngine;
- return d_func()->paintEngine;
+ const_cast<QPicture*>(this)->d_func()->paintEngine.reset(new QPicturePaintEngine);
+ return d_func()->paintEngine.data();
}
/*****************************************************************************
diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h
index fe86e8d..7de1f79 100644
--- a/src/gui/image/qpicture.h
+++ b/src/gui/image/qpicture.h
@@ -106,7 +106,7 @@ private:
bool exec(QPainter *p, QDataStream &ds, int i);
void detach_helper();
- QPicturePrivate *d_ptr;
+ QScopedSharedPointer<QPicturePrivate> d_ptr;
friend class QPicturePaintEngine;
friend class Q3Picture;
friend class QAlphaPaintEngine;
@@ -114,7 +114,7 @@ private:
public:
typedef QPicturePrivate* DataPtr;
- inline DataPtr &data_ptr() { return d_ptr; }
+ inline DataPtr &data_ptr() { return d_ptr.data_ptr(); }
};
Q_DECLARE_SHARED(QPicture)
diff --git a/src/gui/image/qpicture_p.h b/src/gui/image/qpicture_p.h
index a3fd34f..e0c3117 100644
--- a/src/gui/image/qpicture_p.h
+++ b/src/gui/image/qpicture_p.h
@@ -156,7 +156,7 @@ public:
int formatMinor;
QRect brect;
QRect override_rect;
- QPaintEngine *paintEngine;
+ QScopedPointer<QPaintEngine> paintEngine;
bool in_memory_only;
QList<QImage> image_list;
QList<QPixmap> pixmap_list;
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 82be1b9..f85e21a 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -1236,7 +1236,7 @@ bool QPixmap::convertFromImage(const QImage &image, ColorMode mode)
/*!
\relates QPixmap
- Writes the given \a pixmap to the the given \a stream as a PNG
+ Writes the given \a pixmap to the given \a stream as a PNG
image. Note that writing the stream to a file will not produce a
valid image file.
@@ -2021,4 +2021,99 @@ QPixmapData* QPixmap::pixmapData() const
return data;
}
+/*!
+ \enum QPixmap::HBitmapFormat
+
+ \bold{Win32 only:} This enum defines how the conversion between \c
+ HBITMAP and QPixmap is performed.
+
+ \warning This enum is only available on Windows.
+
+ \value NoAlpha The alpha channel is ignored and always treated as
+ being set to fully opaque. This is preferred if the \c HBITMAP is
+ used with standard GDI calls, such as \c BitBlt().
+
+ \value PremultipliedAlpha The \c HBITMAP is treated as having an
+ alpha channel and premultiplied colors. This is preferred if the
+ \c HBITMAP is accessed through the \c AlphaBlend() GDI function.
+
+ \value Alpha The \c HBITMAP is treated as having a plain alpha
+ channel. This is the preferred format if the \c HBITMAP is going
+ to be used as an application icon or systray icon.
+
+ \sa fromWinHBITMAP(), toWinHBITMAP()
+*/
+
+/*! \fn HBITMAP QPixmap::toWinHBITMAP(HBitmapFormat format) const
+ \bold{Win32 only:} Creates a \c HBITMAP equivalent to the QPixmap,
+ based on the given \a format. Returns the \c HBITMAP handle.
+
+ It is the caller's responsibility to free the \c HBITMAP data
+ after use.
+
+ \warning This function is only available on Windows.
+
+ \sa fromWinHBITMAP()
+*/
+
+/*! \fn QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
+ \bold{Win32 only:} Returns a QPixmap that is equivalent to the
+ given \a bitmap. The conversion is based on the specified \a
+ format.
+
+ \warning This function is only available on Windows.
+
+ \sa toWinHBITMAP(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
+
+*/
+
+/*! \fn const QX11Info &QPixmap::x11Info() const
+ \bold{X11 only:} Returns information about the configuration of
+ the X display used to display the widget.
+
+ \warning This function is only available on X11.
+
+ \sa {QPixmap#Pixmap Information}{Pixmap Information}
+*/
+
+/*! \fn Qt::HANDLE QPixmap::x11PictureHandle() const
+ \bold{X11 only:} Returns the X11 Picture handle of the pixmap for
+ XRender support.
+
+ This function will return 0 if XRender support is not compiled
+ into Qt, if the XRender extension is not supported on the X11
+ display, or if the handle could not be created. Use of this
+ function is not portable.
+
+ \warning This function is only available on X11.
+
+ \sa {QPixmap#Pixmap Information}{Pixmap Information}
+*/
+
+/*! \fn int QPixmap::x11SetDefaultScreen(int screen)
+ \internal
+*/
+
+/*! \fn void QPixmap::x11SetScreen(int screen)
+ \internal
+*/
+
+/*! \fn QRgb* QPixmap::clut() const
+ \internal
+*/
+
+/*! \fn int QPixmap::numCols() const
+ \internal
+*/
+
+/*! \fn const uchar* QPixmap::qwsBits() const
+ \internal
+ \since 4.1
+*/
+
+/*! \fn int QPixmap::qwsBytesPerLine() const
+ \internal
+ \since 4.1
+*/
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h
index 1863273..9ef5347 100644
--- a/src/gui/image/qpixmap.h
+++ b/src/gui/image/qpixmap.h
@@ -62,6 +62,10 @@ class QX11Info;
class QPixmapData;
+#if defined(Q_OS_SYMBIAN)
+class CFbsBitmap;
+#endif
+
class Q_GUI_EXPORT QPixmap : public QPaintDevice
{
public:
@@ -152,6 +156,11 @@ public:
static QPixmap fromMacCGImageRef(CGImageRef image);
#endif
+#if defined(Q_OS_SYMBIAN)
+ CFbsBitmap *toSymbianCFbsBitmap() const;
+ static QPixmap fromSymbianCFbsBitmap(CFbsBitmap *bitmap);
+#endif
+
inline QPixmap copy(int x, int y, int width, int height) const;
QPixmap copy(const QRect &rect = QRect()) const;
diff --git a/src/gui/image/qpixmap_qws.cpp b/src/gui/image/qpixmap_qws.cpp
index 6cc7981..7e383ab 100644
--- a/src/gui/image/qpixmap_qws.cpp
+++ b/src/gui/image/qpixmap_qws.cpp
@@ -109,9 +109,6 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
return QPixmap::fromImage(img);
}
-/*!
- \internal
-*/
QRgb* QPixmap::clut() const
{
if (data->classId() == QPixmapData::RasterClass) {
@@ -122,9 +119,6 @@ QRgb* QPixmap::clut() const
return 0;
}
-/*!
- \internal
-*/
int QPixmap::numCols() const
{
if (data->classId() == QPixmapData::RasterClass) {
@@ -135,10 +129,6 @@ int QPixmap::numCols() const
return 0;
}
-/*!
- \internal
- \since 4.1
-*/
const uchar* QPixmap::qwsBits() const
{
if (data->classId() == QPixmapData::RasterClass) {
@@ -149,10 +139,6 @@ const uchar* QPixmap::qwsBits() const
return 0;
}
-/*!
- \internal
- \since 4.1
-*/
int QPixmap::qwsBytesPerLine() const
{
if (data->classId() == QPixmapData::RasterClass) {
diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp
index 625988a..132e26e 100644
--- a/src/gui/image/qpixmap_s60.cpp
+++ b/src/gui/image/qpixmap_s60.cpp
@@ -5,9 +5,40 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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 <exception>
#include <w32std.h>
#include <fbs.h>
@@ -61,14 +92,142 @@ QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h )
return QPixmap();
}
- QImage::Format format = qt_TDisplayMode2Format( displayMode );
- int bytesPerLine = CFbsBitmap::ScanLineLength(temporary->SizeInPixels().iWidth,displayMode);
- temporary->LockHeap();
- QImage image = QImage((uchar*)temporary->DataAddress(), srcRect.Width(), srcRect.Height(), bytesPerLine, format);
- QPixmap pixmap = QPixmap::fromImage(image.copy());
- temporary->UnlockHeap();
+ QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(temporary);
CBase::Delete(temporary);
return pixmap;
+}
+
+/*!
+\since 4.6
+
+Returns a \c CFbsBitmap that is equivalent to the QPixmap by copying the data.
+
+It is the caller's responsibility to delete the \c CFbsBitmap after use.
+
+\warning This function is only available on Symbian OS.
+
+\sa fromSymbianCFbsBitmap()
+*/
+
+CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const
+{
+ if (isNull())
+ return 0;
+
+ TDisplayMode mode;
+ const QImage img = toImage();
+ QImage::Format destFormat = img.format();
+ switch (img.format()) {
+ case QImage::Format_Mono:
+ destFormat = QImage::Format_MonoLSB;
+ // Fall through intended
+ case QImage::Format_MonoLSB:
+ mode = EGray2;
+ break;
+ case QImage::Format_Indexed8:
+ if (img.isGrayscale())
+ mode = EGray256;
+ else
+ mode = EColor256;
+ break;
+ case QImage::Format_RGB32:
+ mode = EColor16MU;
+ break;
+ case QImage::Format_ARGB6666_Premultiplied:
+ case QImage::Format_ARGB8565_Premultiplied:
+ case QImage::Format_ARGB8555_Premultiplied:
+ destFormat = QImage::Format_ARGB32_Premultiplied;
+ // Fall through intended
+ case QImage::Format_ARGB32_Premultiplied:
+#if !defined(__SERIES60_31__) && !defined(__S60_32__)
+ // ### TODO: Add runtime detection as well?
+ mode = EColor16MAP;
+ break;
+#endif
+ destFormat = QImage::Format_ARGB32;
+ // Fall through intended
+ case QImage::Format_ARGB32:
+ mode = EColor16MA;
+ break;
+ case QImage::Format_RGB555:
+ destFormat = QImage::Format_RGB16;
+ // Fall through intended
+ case QImage::Format_RGB16:
+ mode = EColor64K;
+ break;
+ case QImage::Format_RGB666:
+ destFormat = QImage::Format_RGB888;
+ // Fall through intended
+ case QImage::Format_RGB888:
+ mode = EColor16M;
+ break;
+ case QImage::Format_RGB444:
+ mode = EColor4K;
+ break;
+ case QImage::Format_Invalid:
+ return 0;
+ default:
+ qWarning("Image format not supported: %d", img.format());
+ return 0;
+ }
+
+ CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
+ TSize size(width(), height());
+ if (bitmap->Create(size, mode) != KErrNone) {
+ CBase::Delete(bitmap);
+ return 0;
+ }
+
+ const QImage converted = img.convertToFormat(destFormat);
+
+ bitmap->LockHeap();
+ const uchar *sptr = converted.bits();
+ uchar *dptr = (uchar*)bitmap->DataAddress();
+ Mem::Copy(dptr, sptr, converted.numBytes());
+ bitmap->UnlockHeap();
+ return bitmap;
+}
+
+/*!
+\since 4.6
+
+Returns a QPixmap that is equivalent to the \c CFbsBitmap by copying the data.
+If the CFbsBitmap is not valid or is compressed in memory, this function will
+return a null QPixmap.
+
+\warning This function is only available on Symbian OS.
+
+\sa toSymbianCFbsBitmap(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
+*/
+QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap)
+{
+ int width = bitmap->SizeInPixels().iWidth;
+ int height = bitmap->SizeInPixels().iHeight;
+
+ if (!bitmap || width <= 0 || height <= 0 || bitmap->IsCompressedInRAM())
+ return QPixmap();
+
+ TDisplayMode displayMode = bitmap->DisplayMode();
+ QImage::Format format = qt_TDisplayMode2Format(displayMode);
+ int bytesPerLine = CFbsBitmap::ScanLineLength(width, displayMode);
+ bitmap->LockHeap();
+ QImage image = QImage((const uchar*)bitmap->DataAddress(), width, height, bytesPerLine, format);
+ if (displayMode == EGray2) {
+ image.setNumColors(2);
+ image.setColor(0, QColor(Qt::color0).rgba());
+ image.setColor(1, QColor(Qt::color1).rgba());
+ } else if (displayMode == EGray256) {
+ for (int i=0; i < 256; ++i)
+ image.setColor(i, qRgb(i, i, i));
+ }else if (displayMode == EColor256) {
+ const TColor256Util *palette = TColor256Util::Default();
+ for (int i=0; i < 256; ++i)
+ image.setColor(i, (QRgb)(palette->Color256(i).Value()));
+ }
+ QPixmap pixmap = QPixmap::fromImage(image.copy());
+ bitmap->UnlockHeap();
+ return pixmap;
}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
index cbe9004..6a8b38a 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/gui/image/qpixmap_win.cpp
@@ -119,42 +119,6 @@ QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h )
return pixmap;
}
-
-
-/*!
- \enum QPixmap::HBitmapFormat
-
- This enum defines how the conversion between \c HBITMAP
- and QPixmap is performed.
-
- \warning This enum is only available on Windows.
-
- \value NoAlpha The alpha channel is ignored and always treated as
- being set to fully opaque. This is preferred if the \c HBITMAP is
- used with standard GDI calls, such as \c BitBlt().
-
- \value PremultipliedAlpha The \c HBITMAP is treated as having an
- alpha channel and premultiplied colors. This is preferred if the
- \c HBITMAP is accessed through the \c AlphaBlend() GDI function.
-
- \value Alpha The \c HBITMAP is treated as having a plain alpha
- channel. This is the preferred format if the \c HBITMAP is going
- to be used as an application icon or systray icon.
-
- \sa fromWinHBITMAP(), toWinHBITMAP()
-*/
-
-/*!
- Creates a \c HBITMAP equivalent to the QPixmap, based on the given
- \a format. Returns the \c HBITMAP handle.
-
- It is the caller's responsibility to free the \c HBITMAP data
- after use.
-
- \warning This function is only available on Windows.
-
- \sa fromWinHBITMAP()
-*/
HBITMAP QPixmap::toWinHBITMAP(HBitmapFormat format) const
{
HBITMAP bitmap = 0;
@@ -209,15 +173,6 @@ HBITMAP QPixmap::toWinHBITMAP(HBitmapFormat format) const
return bitmap;
}
-/*!
- Returns a QPixmap that is equivalent to the given \a bitmap. The
- conversion is based on the specified \a format.
-
- \warning This function is only available on Windows.
-
- \sa toWinHBITMAP(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
-
-*/
QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
{
// Verify size
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp
index 38916c7..d2e8d84 100644
--- a/src/gui/image/qpixmap_x11.cpp
+++ b/src/gui/image/qpixmap_x11.cpp
@@ -1914,9 +1914,6 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform,
}
}
-/*!
- \internal
-*/
int QPixmap::x11SetDefaultScreen(int screen)
{
int old = defaultScreen;
@@ -1924,9 +1921,6 @@ int QPixmap::x11SetDefaultScreen(int screen)
return old;
}
-/*!
- \internal
-*/
void QPixmap::x11SetScreen(int screen)
{
if (paintingActive()) {
@@ -2034,14 +2028,6 @@ bool QX11PixmapData::hasAlphaChannel() const
return d == 32;
}
-/*!
- Returns information about the configuration of the X display used to display
- the widget.
-
- \warning This function is only available on X11.
-
- \sa {QPixmap#Pixmap Information}{Pixmap Information}
-*/
const QX11Info &QPixmap::x11Info() const
{
if (data->classId() == QPixmapData::X11Class)
@@ -2098,20 +2084,6 @@ QPaintEngine* QX11PixmapData::paintEngine() const
return that->pengine;
}
-/*!
- Returns the X11 Picture handle of the pixmap for XRender
- support.
-
- This function will return 0 if XRender support is not compiled
- into Qt, if the XRender extension is not supported on the X11
- display, or if the handle could not be created. Use of this
- function is not portable.
-
- \warning This function is only available on X11.
-
- \sa {QPixmap#Pixmap Information}{Pixmap Information}
-*/
-
Qt::HANDLE QPixmap::x11PictureHandle() const
{
#ifndef QT_NO_XRENDER
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index c9973d0..4f71e09 100644
--- a/src/gui/image/qpixmapcache.cpp
+++ b/src/gui/image/qpixmapcache.cpp
@@ -323,7 +323,12 @@ void QPixmapCache::remove(const QString &key)
void QPixmapCache::clear()
{
- pm_cache()->clear();
+ QT_TRY {
+ pm_cache()->clear();
+ } QT_CATCH(const std::bad_alloc &) {
+ // if we ran out of memory during pm_cache(), it's no leak,
+ // so just ignore it.
+ }
}
QT_END_NAMESPACE
diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h
index 50f8a12..b33489e 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_p.h
+++ b/src/gui/inputmethod/qcoefepinputcontext_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
@@ -62,7 +92,7 @@ public:
TCoeInputCapabilities inputCapabilities();
private:
- void commitCurrentString();
+ void commitCurrentString(bool triggeredBySymbian);
void updateHints();
void applyHints(Qt::InputMethodHints hints);
void applyFormat(QList<QInputMethodEvent::Attribute> *attributes);
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index 8612e55..7d79422 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
@@ -58,10 +88,9 @@ QCoeFepInputContext::~QCoeFepInputContext()
// This is to make sure that the FEP manager "forgets" about us,
// otherwise we may get callbacks even after we're destroyed.
- // The call is asynchronous though, so we must spin the event loop
- // to make sure it gets detected.
- CCoeEnv::Static()->InputCapabilitiesChanged();
- QApplication::processEvents();
+ // The call below is essentially equivalent to InputCapabilitiesChanged(),
+ // but is synchronous, rather than asynchronous.
+ CCoeEnv::Static()->SyncNotifyFocusObserversOfChangeInFocus();
if (m_fepState)
delete m_fepState;
@@ -89,9 +118,7 @@ void QCoeFepInputContext::update()
void QCoeFepInputContext::setFocusWidget(QWidget *w)
{
- commitCurrentString();
-
- CCoeEnv::Static()->Fep()->CancelTransaction();
+ commitCurrentString(false);
QInputContext::setFocusWidget(w);
@@ -258,56 +285,17 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event)
void QCoeFepInputContext::mouseHandler( int x, QMouseEvent *event)
{
Q_ASSERT(m_isEditing);
+ Q_ASSERT(focusWidget());
- if (!m_pointerHandler) {
- QInputContext::mouseHandler(x, event);
- }
-
- TPointerEvent::TType type;
- TUint modifiers = 0;
-
- if (event->type() == QEvent::MouseButtonPress) {
- if (event->button() == Qt::LeftButton) {
- type = TPointerEvent::EButton1Down;
- } else if (event->button() == Qt::RightButton) {
- type = TPointerEvent::EButton3Down;
- } else if (event->button() == Qt::MidButton) {
- type = TPointerEvent::EButton2Down;
- } else {
- return;
- }
- } else if (event->type() == QEvent::MouseButtonRelease) {
- if (event->button() == Qt::LeftButton) {
- type = TPointerEvent::EButton1Up;
- } else if (event->button() == Qt::RightButton) {
- type = TPointerEvent::EButton3Up;
- } else if (event->button() == Qt::MidButton) {
- type = TPointerEvent::EButton2Up;
- } else {
- return;
- }
- } else if (event->type() == QEvent::MouseMove) {
- type = TPointerEvent::EMove;
- } else if (event->type() == QEvent::DragMove) {
- type = TPointerEvent::EDrag;
- } else {
- return;
- }
+ if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::LeftButton) {
+ commitCurrentString(false);
+ int pos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt();
- if (event->modifiers() & Qt::ShiftModifier) {
- modifiers |= EModifierShift;
- }
- if (event->modifiers() & Qt::AltModifier) {
- modifiers |= EModifierAlt;
- }
- if (event->modifiers() & Qt::ControlModifier) {
- modifiers |= EModifierCtrl;
- }
- if (event->modifiers() & Qt::KeypadModifier) {
- modifiers |= EModifierKeypad;
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, pos + x, 0, QVariant());
+ QInputMethodEvent event("", attributes);
+ sendEvent(event);
}
-
- m_pointerHandler->HandlePointerEventInInlineTextL(type, modifiers, x);
}
TCoeInputCapabilities QCoeFepInputContext::inputCapabilities()
@@ -341,6 +329,8 @@ void QCoeFepInputContext::updateHints()
m_lastImHints = hints;
applyHints(hints);
}
+ } else {
+ CCoeEnv::Static()->InputCapabilitiesChanged();
}
}
@@ -606,13 +596,13 @@ void QCoeFepInputContext::SetCursorSelectionForFepL(const TCursorSelection& aCur
if (!w)
return;
- int pos = w->inputMethodQuery(Qt::ImCursorPosition).toInt() + aCursorSelection.iCursorPos + 1;
+ int pos = aCursorSelection.iAnchorPos;
+ int length = aCursorSelection.iCursorPos - pos;
QList<QInputMethodEvent::Attribute> attributes;
- attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, pos, 1, QVariant());
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, pos, length, QVariant());
QInputMethodEvent event(m_preeditString, attributes);
- // ### FIXME Sets preeditcursor and not cursor. Probably needs new API.
- //sendEvent(event);
+ sendEvent(event);
}
void QCoeFepInputContext::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const
@@ -621,9 +611,8 @@ void QCoeFepInputContext::GetCursorSelectionForFep(TCursorSelection& aCursorSele
if (!w)
return;
- QVariant cursorVar = w->inputMethodQuery(Qt::ImCursorPosition);
- int cursor = cursorVar.toInt() + m_preeditString.size();
- int anchor = cursor - w->inputMethodQuery(Qt::ImCurrentSelection).toString().size();
+ int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt() + m_preeditString.size();
+ int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt() + m_preeditString.size();
aCursorSelection.iAnchorPos = anchor;
aCursorSelection.iCursorPos = cursor;
}
@@ -679,12 +668,10 @@ void QCoeFepInputContext::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLin
void QCoeFepInputContext::DoCommitFepInlineEditL()
{
- commitCurrentString();
-
- m_isEditing = false;
+ commitCurrentString(true);
}
-void QCoeFepInputContext::commitCurrentString()
+void QCoeFepInputContext::commitCurrentString(bool triggeredBySymbian)
{
if (m_preeditString.size() == 0) {
return;
@@ -695,6 +682,12 @@ void QCoeFepInputContext::commitCurrentString()
event.setCommitString(m_preeditString, 0, 0);//m_preeditString.size());
m_preeditString.clear();
sendEvent(event);
+
+ m_isEditing = false;
+
+ if (!triggeredBySymbian) {
+ CCoeEnv::Static()->Fep()->CancelTransaction();
+ }
}
MCoeFepAwareTextEditor_Extension1* QCoeFepInputContext::Extension1(TBool& aSetToTrue)
diff --git a/src/gui/inputmethod/qwininputcontext_win.cpp b/src/gui/inputmethod/qwininputcontext_win.cpp
index e3e8aa4..d670f5a 100644
--- a/src/gui/inputmethod/qwininputcontext_win.cpp
+++ b/src/gui/inputmethod/qwininputcontext_win.cpp
@@ -759,7 +759,12 @@ void QInputContextPrivate::updateImeStatus(QWidget *w, bool hasFocus)
{
if (!w)
return;
- bool e = w->testAttribute(Qt::WA_InputMethodEnabled) && w->isEnabled();
+ // It's always the proxy that carries the hints.
+ QWidget *focusProxyWidget = w->focusProxy();
+ if (!focusProxyWidget)
+ focusProxyWidget = w;
+ bool e = w->testAttribute(Qt::WA_InputMethodEnabled) && w->isEnabled()
+ && !(focusProxyWidget->inputMethodHints() & Qt::ImhExclusiveInputMask);
bool hasIme = e && hasFocus;
#ifdef Q_IME_DEBUG
qDebug("%s HasFocus = %d hasIme = %d e = %d ", w->className(), hasFocus, hasIme, e);
diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/gui/inputmethod/qximinputcontext_x11.cpp
index c320fb4..60ea15b 100644
--- a/src/gui/inputmethod/qximinputcontext_x11.cpp
+++ b/src/gui/inputmethod/qximinputcontext_x11.cpp
@@ -610,7 +610,7 @@ void QXIMInputContext::setFocusWidget(QWidget *w)
QInputContext::setFocusWidget(w);
- if (!w)
+ if (!w || w->inputMethodHints() & Qt::ImhExclusiveInputMask)
return;
ICData *data = ximData.value(w->effectiveWinId());
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index d1f3791..2576724 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -61,6 +61,7 @@
#ifndef QT_NO_ACCESSIBILITY
#include <qaccessible.h>
#endif
+#include <private/qactiontokeyeventmapper_p.h>
QT_BEGIN_NAMESPACE
@@ -1338,7 +1339,7 @@ QSize QAbstractItemView::iconSize() const
/*!
\property QAbstractItemView::textElideMode
- \brief the the position of the "..." in elided text.
+ \brief the position of the "..." in elided text.
The default value for all item views is Qt::ElideRight.
*/
@@ -2003,16 +2004,18 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
if (QApplication::keypadNavigationEnabled()) {
if (!hasEditFocus()) {
setEditFocus(true);
+ QActionToKeyEventMapper::addSoftKey(QAction::BackSoftKey, Qt::Key_Back, this);
return;
}
}
break;
case Qt::Key_Back:
- case Qt::Key_Context2: // TODO: aportale, remove KEYPAD_NAVIGATION_HACK when softkey support is there
- if (QApplication::keypadNavigationEnabled() && hasEditFocus())
+ if (QApplication::keypadNavigationEnabled() && hasEditFocus()) {
+ QActionToKeyEventMapper::removeSoftkey(this);
setEditFocus(false);
- else
+ } else {
event->ignore();
+ }
return;
default:
if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
@@ -3221,9 +3224,9 @@ QStyleOptionViewItem QAbstractItemView::viewOptions() const
option.state &= ~QStyle::State_MouseOver;
option.font = font();
-#ifdef Q_WS_WIN
- // Note this is currently required on Windows
- // do give non-focused item views inactive appearance
+#ifndef Q_WS_MAC
+ // On mac the focus appearance follows window activation
+ // not widget activation
if (!hasFocus())
option.state &= ~QStyle::State_Active;
#endif
diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h
index 16bd1ab..c4bf4db 100644
--- a/src/gui/itemviews/qabstractitemview_p.h
+++ b/src/gui/itemviews/qabstractitemview_p.h
@@ -304,7 +304,7 @@ public:
*/
inline bool isPersistent(const QModelIndex &index) const
{
- return static_cast<QAbstractItemModelPrivate *>(model->d_ptr)->persistent.indexes.contains(index);
+ return static_cast<QAbstractItemModelPrivate *>(model->d_ptr.data())->persistent.indexes.contains(index);
}
QModelIndexList selectedDraggableIndexes() const;
diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp
index ac62551..af4d42a 100644
--- a/src/gui/itemviews/qfileiconprovider.cpp
+++ b/src/gui/itemviews/qfileiconprovider.cpp
@@ -180,7 +180,6 @@ QFileIconProvider::QFileIconProvider()
QFileIconProvider::~QFileIconProvider()
{
- delete d_ptr;
}
/*!
diff --git a/src/gui/itemviews/qfileiconprovider.h b/src/gui/itemviews/qfileiconprovider.h
index 7928552..a6152ea 100644
--- a/src/gui/itemviews/qfileiconprovider.h
+++ b/src/gui/itemviews/qfileiconprovider.h
@@ -42,8 +42,9 @@
#ifndef QFILEICONPROVIDER_H
#define QFILEICONPROVIDER_H
-#include <QtGui/qicon.h>
#include <QtCore/qfileinfo.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtGui/qicon.h>
QT_BEGIN_HEADER
@@ -67,7 +68,7 @@ public:
private:
Q_DECLARE_PRIVATE(QFileIconProvider)
- QFileIconProviderPrivate *d_ptr;
+ QScopedPointer<QFileIconProviderPrivate> d_ptr;
Q_DISABLE_COPY(QFileIconProvider)
};
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index d373163..f888f5f 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1267,8 +1267,10 @@ void QHeaderView::setSortIndicator(int logicalIndex, Qt::SortOrder order)
d->sortIndicatorSection = logicalIndex;
d->sortIndicatorOrder = order;
- if (logicalIndex >= d->sectionCount)
+ if (logicalIndex >= d->sectionCount) {
+ emit sortIndicatorChanged(logicalIndex, order);
return; // nothing to do
+ }
if (old != logicalIndex
&& ((logicalIndex >= 0 && resizeMode(logicalIndex) == ResizeToContents)
diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp
index 147f523..fda6255 100644
--- a/src/gui/itemviews/qitemdelegate.cpp
+++ b/src/gui/itemviews/qitemdelegate.cpp
@@ -47,6 +47,7 @@
#include <qbrush.h>
#include <qlineedit.h>
#include <qtextedit.h>
+#include <qplaintextedit.h>
#include <qpainter.h>
#include <qpalette.h>
#include <qpoint.h>
@@ -218,7 +219,7 @@ QSizeF QItemDelegatePrivate::doTextLayout(int lineWidth) const
editor widget, which is a widget that is placed on top of the view
while editing takes place. Editors are created with a
QItemEditorFactory; a default static instance provided by
- QItemEditorFactory is installed on all item delagates. You can set
+ QItemEditorFactory is installed on all item delegates. You can set
a custom factory using setItemEditorFactory() or set a new default
factory with QItemEditorFactory::setDefaultFactory(). It is the
data stored in the item model with the Qt::EditRole that is edited.
@@ -1194,7 +1195,7 @@ bool QItemDelegate::eventFilter(QObject *object, QEvent *event)
case Qt::Key_Enter:
case Qt::Key_Return:
#ifndef QT_NO_TEXTEDIT
- if (qobject_cast<QTextEdit*>(editor))
+ if (qobject_cast<QTextEdit *>(editor) || qobject_cast<QPlainTextEdit *>(editor))
return false; // don't filter enter key events for QTextEdit
// We want the editor to be able to process the key press
// before committing the data (e.g. so it can do
diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp
index 7a366d1..bf3b43c 100644
--- a/src/gui/itemviews/qlistwidget.cpp
+++ b/src/gui/itemviews/qlistwidget.cpp
@@ -1158,7 +1158,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
/*!
\fn void QListWidget::addItem(QListWidgetItem *item)
- Inserts the \a item at the the end of the list widget.
+ Inserts the \a item at the end of the list widget.
\warning A QListWidgetItem can only be added to a
QListWidget once. Adding the same QListWidgetItem multiple
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp
index 43feda8..92dfd19 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/gui/itemviews/qsortfilterproxymodel.cpp
@@ -1518,7 +1518,8 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
d->clear_mapping();
reset();
- d->update_source_sort_column();
+ if (d->update_source_sort_column() && d->dynamic_sortfilter)
+ d->sort();
}
/*!
diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp
index 61e410d..4ec00bb 100644
--- a/src/gui/itemviews/qstandarditemmodel.cpp
+++ b/src/gui/itemviews/qstandarditemmodel.cpp
@@ -778,8 +778,6 @@ QStandardItem &QStandardItem::operator=(const QStandardItem &other)
*/
QStandardItem::~QStandardItem()
{
- Q_D(QStandardItem);
- delete d;
}
/*!
diff --git a/src/gui/itemviews/qstandarditemmodel.h b/src/gui/itemviews/qstandarditemmodel.h
index f24f0ab..66d7576 100644
--- a/src/gui/itemviews/qstandarditemmodel.h
+++ b/src/gui/itemviews/qstandarditemmodel.h
@@ -240,7 +240,7 @@ protected:
QStandardItem(const QStandardItem &other);
QStandardItem(QStandardItemPrivate &dd);
QStandardItem &operator=(const QStandardItem &other);
- QStandardItemPrivate *d_ptr;
+ QScopedPointer<QStandardItemPrivate> d_ptr;
void emitDataChanged();
diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp
index 4dc54a1..b75f151 100644
--- a/src/gui/itemviews/qstyleditemdelegate.cpp
+++ b/src/gui/itemviews/qstyleditemdelegate.cpp
@@ -47,6 +47,7 @@
#include <qbrush.h>
#include <qlineedit.h>
#include <qtextedit.h>
+#include <qplaintextedit.h>
#include <qpainter.h>
#include <qpalette.h>
#include <qpoint.h>
@@ -646,7 +647,7 @@ bool QStyledItemDelegate::eventFilter(QObject *object, QEvent *event)
case Qt::Key_Enter:
case Qt::Key_Return:
#ifndef QT_NO_TEXTEDIT
- if (qobject_cast<QTextEdit*>(editor))
+ if (qobject_cast<QTextEdit *>(editor) || qobject_cast<QPlainTextEdit *>(editor))
return false; // don't filter enter key events for QTextEdit
// We want the editor to be able to process the key press
// before committing the data (e.g. so it can do
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 62c1277..1070648 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -246,7 +246,7 @@ void QTreeView::setModel(QAbstractItemModel *model)
connect(d->model, SIGNAL(modelAboutToBeReset()), SLOT(_q_modelAboutToBeReset()));
if (d->sortingEnabled)
- sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
+ d->_q_sortIndicatorChanged(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
}
/*!
@@ -846,17 +846,19 @@ void QTreeView::setExpanded(const QModelIndex &index, bool expanded)
void QTreeView::setSortingEnabled(bool enable)
{
Q_D(QTreeView);
- d->sortingEnabled = enable;
header()->setSortIndicatorShown(enable);
header()->setClickable(enable);
if (enable) {
+ //sortByColumn has to be called before we connect or set the sortingEnabled flag
+ // because otherwise it will not call sort on the model.
+ sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
this, SLOT(_q_sortIndicatorChanged(int, Qt::SortOrder)));
- sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
} else {
disconnect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
this, SLOT(_q_sortIndicatorChanged(int, Qt::SortOrder)));
}
+ d->sortingEnabled = enable;
}
bool QTreeView::isSortingEnabled() const
diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp
index 6103225..0f2a27c 100644
--- a/src/gui/itemviews/qtreewidget.cpp
+++ b/src/gui/itemviews/qtreewidget.cpp
@@ -853,7 +853,7 @@ void QTreeModel::sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortO
items->replace(r, item);
for (int c = 0; c < colCount; ++c) {
QModelIndex from = createIndex(oldRow, c, item);
- if (static_cast<QAbstractItemModelPrivate *>(d_ptr)->persistent.indexes.contains(from)) {
+ if (static_cast<QAbstractItemModelPrivate *>(d_ptr.data())->persistent.indexes.contains(from)) {
QModelIndex to = createIndex(r, c, item);
fromList << from;
toList << to;
diff --git a/src/gui/itemviews/qtreewidgetitemiterator.cpp b/src/gui/itemviews/qtreewidgetitemiterator.cpp
index 3e30e03..7e167b9 100644
--- a/src/gui/itemviews/qtreewidgetitemiterator.cpp
+++ b/src/gui/itemviews/qtreewidgetitemiterator.cpp
@@ -97,7 +97,7 @@ QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidget *widget, IteratorFl
Q_ASSERT(widget);
QTreeModel *model = qobject_cast<QTreeModel*>(widget->model());
Q_ASSERT(model);
- d_ptr = new QTreeWidgetItemIteratorPrivate(this, model);
+ d_ptr.reset(new QTreeWidgetItemIteratorPrivate(this, model));
model->iterators.append(this);
if (!model->rootItem->children.isEmpty()) current = model->rootItem->children.first();
if (current && !matchesFlags(current))
@@ -150,7 +150,6 @@ QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidgetItem *item, Iterator
QTreeWidgetItemIterator::~QTreeWidgetItemIterator()
{
d_func()->m_model->iterators.removeAll(this);
- delete d_ptr;
}
/*!
diff --git a/src/gui/itemviews/qtreewidgetitemiterator.h b/src/gui/itemviews/qtreewidgetitemiterator.h
index 8a76c69..535339d 100644
--- a/src/gui/itemviews/qtreewidgetitemiterator.h
+++ b/src/gui/itemviews/qtreewidgetitemiterator.h
@@ -43,6 +43,7 @@
#define QTREEWIDGETITEMITERATOR_H
#include <QtCore/qglobal.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -105,7 +106,7 @@ public:
private:
bool matchesFlags(const QTreeWidgetItem *item) const;
- QTreeWidgetItemIteratorPrivate *d_ptr;
+ QScopedPointer<QTreeWidgetItemIteratorPrivate> d_ptr;
QTreeWidgetItem *current;
IteratorFlags flags;
Q_DECLARE_PRIVATE(QTreeWidgetItemIterator)
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp
index abb17d7..b1db8d6 100644
--- a/src/gui/kernel/qaction.cpp
+++ b/src/gui/kernel/qaction.cpp
@@ -81,7 +81,8 @@ static QString qt_strippedText(QString s)
QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0),
visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false),
- menuRole(QAction::TextHeuristicRole), iconVisibleInMenu(-1)
+ menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::OptionsSoftKey),
+ iconVisibleInMenu(-1)
{
#ifdef QT3_SUPPORT
static int qt_static_action_id = -1;
@@ -1348,6 +1349,32 @@ QAction::MenuRole QAction::menuRole() const
}
/*!
+ \property QAction::softKeyRole
+ \brief the action's softkey role
+ \since 4.6
+
+ This indicates what softkey action this action is. Usually used on mobile
+ platforms to map QActions to hardware keys.
+
+ The softkey role can be changed any time.
+*/
+void QAction::setSoftKeyRole(SoftKeyRole softKeyRole)
+{
+ Q_D(QAction);
+ if (d->softKeyRole == softKeyRole)
+ return;
+
+ d->softKeyRole = softKeyRole;
+ d->sendDataChanged();
+}
+
+QAction::SoftKeyRole QAction::softKeyRole() const
+{
+ Q_D(const QAction);
+ return d->softKeyRole;
+}
+
+/*!
\property QAction::iconVisibleInMenu
\brief Whether or not an action should show an icon in a menu
\since 4.4
diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h
index d7bf8c3..dfa4933 100644
--- a/src/gui/kernel/qaction.h
+++ b/src/gui/kernel/qaction.h
@@ -67,6 +67,7 @@ class Q_GUI_EXPORT QAction : public QObject
Q_DECLARE_PRIVATE(QAction)
Q_ENUMS(MenuRole)
+ Q_ENUMS(SoftKeyRole)
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
@@ -84,11 +85,17 @@ class Q_GUI_EXPORT QAction : public QObject
#endif
Q_PROPERTY(bool visible READ isVisible WRITE setVisible)
Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole)
+ Q_PROPERTY(SoftKeyRole softKeyRole READ softKeyRole WRITE setSoftKeyRole)
Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu)
public:
enum MenuRole { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole,
AboutRole, PreferencesRole, QuitRole };
+ enum SoftKeyRole { OptionsSoftKey, SelectSoftKey, BackSoftKey, NextSoftKey, PreviousSoftKey,
+ OkSoftKey, CancelSoftKey, EditSoftKey, ViewSoftKey, BackSpaceSoftKey,
+ EndEditSoftKey, RevertEditSoftKey, DeselectSoftKey, FinishSoftKey,
+ MenuSoftKey, ContextMenuSoftKey, ExitSoftKey, Key1SoftKey, Key2SoftKey,
+ Key3SoftKey, Key4SoftKey, CustomSoftKey };
explicit QAction(QObject* parent);
QAction(const QString &text, QObject* parent);
QAction(const QIcon &icon, const QString &text, QObject* parent);
@@ -168,6 +175,9 @@ public:
void setMenuRole(MenuRole menuRole);
MenuRole menuRole() const;
+ void setSoftKeyRole(SoftKeyRole softKeyRole);
+ SoftKeyRole softKeyRole() const;
+
void setIconVisibleInMenu(bool visible);
bool isIconVisibleInMenu() const;
diff --git a/src/gui/kernel/qaction_p.h b/src/gui/kernel/qaction_p.h
index 0617ef5..6051d9a 100644
--- a/src/gui/kernel/qaction_p.h
+++ b/src/gui/kernel/qaction_p.h
@@ -102,6 +102,7 @@ public:
uint separator : 1;
uint fontSet : 1;
QAction::MenuRole menuRole;
+ QAction::SoftKeyRole softKeyRole;
int iconVisibleInMenu : 3; // Only has values -1, 0, and 1
QList<QWidget *> widgets;
#ifndef QT_NO_GRAPHICSVIEW
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index fb002a3..aa6d21e 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -1006,7 +1006,8 @@ QApplication::~QApplication()
if (QWidgetPrivate::mapper) {
QWidgetMapper * myMapper = QWidgetPrivate::mapper;
QWidgetPrivate::mapper = 0;
- for (QWidgetMapper::Iterator it = myMapper->begin(); it != myMapper->end(); ++it) {
+ for (QWidgetMapper::ConstIterator it = myMapper->constBegin();
+ it != myMapper->constEnd(); ++it) {
register QWidget *w = *it;
if (!w->parent()) // window
w->destroy(true, true);
@@ -1018,7 +1019,7 @@ QApplication::~QApplication()
if (QWidgetPrivate::uncreatedWidgets) {
QWidgetSet *mySet = QWidgetPrivate::uncreatedWidgets;
QWidgetPrivate::uncreatedWidgets = 0;
- for (QWidgetSet::Iterator it = mySet->begin(); it != mySet->end(); ++it) {
+ for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) {
register QWidget *w = *it;
if (!w->parent()) // window
w->destroy(true, true);
@@ -4764,7 +4765,7 @@ void QApplicationPrivate::emitLastWindowClosed()
If \a enable is true, Qt::Key_Up and Qt::Key_Down are used to change focus.
- This feature is available in Qt for Embedded Linux only.
+ This feature is available in Qt for Embedded Linux and Symbian only.
\sa keypadNavigationEnabled()
*/
@@ -4775,9 +4776,9 @@ void QApplication::setKeypadNavigationEnabled(bool enable)
/*!
Returns true if Qt is set to use keypad navigation; otherwise returns
- false. The default is false.
+ false. The default value is true on Symbian, but false on other platforms.
- This feature is available in Qt for Embedded Linux only.
+ This feature is available in Qt for Embedded Linux and Symbian only.
\sa setKeypadNavigationEnabled()
*/
@@ -4993,8 +4994,7 @@ void QApplication::setInputContext(QInputContext *inputContext)
qWarning("QApplication::setInputContext: called with 0 input context");
return;
}
- if (d->inputContext)
- delete d->inputContext;
+ delete d->inputContext;
d->inputContext = inputContext;
}
diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h
index ca0eb98..e1b8b26 100644
--- a/src/gui/kernel/qapplication.h
+++ b/src/gui/kernel/qapplication.h
@@ -233,7 +233,8 @@ public:
#if defined(Q_WS_S60)
int s60ProcessEvent(TWsEvent *event);
virtual bool s60EventFilter(TWsEvent *aEvent);
- void s60HandleCommandL(int command);
+ void symbianHandleCommand(int command);
+ void symbianResourceChange(int type);
#endif
#if defined(Q_WS_QWS)
virtual bool qwsEventFilter(QWSEvent *);
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index a6fc602..35a532a 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -100,6 +100,7 @@ extern QSysInfo::MacVersion qt_macver;
#if defined(Q_WS_QWS)
class QWSManager;
class QDirectPainter;
+struct QWSServerCleaner { ~QWSServerCleaner(); };
#endif
#ifndef QT_NO_TABLET
@@ -382,6 +383,7 @@ public:
#ifdef Q_WS_QWS
QPointer<QWSManager> last_manager;
+ QWSServerCleaner qwsServerCleaner;
# ifndef QT_NO_DIRECTPAINTER
QMap<WId, QDirectPainter *> *directPainters;
# endif
diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp
index 018440f..aeebde4 100644
--- a/src/gui/kernel/qapplication_qws.cpp
+++ b/src/gui/kernel/qapplication_qws.cpp
@@ -159,6 +159,8 @@ bool qws_overrideCursor = false;
#ifndef QT_NO_QWS_MANAGER
#include "qdecorationfactory_qws.h"
+extern Q_GUI_EXPORT QWSServer *qwsServer;
+
QT_BEGIN_NAMESPACE
QT_USE_NAMESPACE
@@ -485,8 +487,13 @@ QList<QWSCommand*> *qt_get_server_queue()
void qt_server_enqueue(const QWSCommand *command)
{
QWSCommand *copy = QWSCommand::factory(command->type);
- copy->copyFrom(command);
- outgoing.append(copy);
+ QT_TRY {
+ copy->copyFrom(command);
+ outgoing.append(copy);
+ } QT_CATCH(...) {
+ delete copy;
+ QT_RETHROW;
+ }
}
QWSDisplay::Data::Data(QObject* parent, bool singleProcess)
@@ -2295,7 +2302,7 @@ void qt_init(QApplicationPrivate *priv, int type)
qws_decoration = QApplication::qwsSetDecoration(decoration);
#endif // QT_NO_QWS_MANAGER
#ifndef QT_NO_QWS_INPUTMETHODS
- qApp->setInputContext(new QWSInputContext);
+ qApp->setInputContext(new QWSInputContext(qApp));
#endif
}
@@ -3542,10 +3549,10 @@ bool QETWidget::translateKeyEvent(const QWSKeyEvent *event, bool grab) /* grab i
#if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT)
if (type == QEvent::KeyPress && !grab
- && static_cast<QApplicationPrivate*>(qApp->d_ptr)->use_compat()) {
+ && static_cast<QApplicationPrivate*>(qApp->d_ptr.data())->use_compat()) {
// send accel events if the keyboard is not grabbed
QKeyEvent a(type, code, state, text, autor, int(text.length()));
- if (static_cast<QApplicationPrivate*>(qApp->d_ptr)->qt_tryAccelEvent(this, &a))
+ if (static_cast<QApplicationPrivate*>(qApp->d_ptr.data())->qt_tryAccelEvent(this, &a))
return true;
}
#else
@@ -3745,4 +3752,14 @@ void QApplication::setArgs(int c, char **v)
d->argv = v;
}
+/* \internal
+ This is used to clean up the qws server
+ in case the QApplication constructor threw an exception
+ */
+QWSServerCleaner::~QWSServerCleaner()
+{
+ if (qwsServer && qws_single_process)
+ QWSServer::closedown();
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index dd51fcd..4c008fb 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
@@ -14,6 +44,7 @@
#include "qevent.h"
#include "qeventdispatcher_s60_p.h"
#include "qwidget.h"
+#include "qdesktopwidget.h"
#include "private/qbackingstore_p.h"
#include "qt_s60_p.h"
#include "private/qevent_p.h"
@@ -27,7 +58,7 @@
#endif
#include "private/qwindowsurface_s60_p.h"
#include "qpaintengine.h"
-#include "qmenubar.h"
+#include "private/qmenubar_p.h"
#include "apgwgnam.h" // For CApaWindowGroupName
#include <MdaAudioTonePlayer.h> // For CMdaAudioToneUtility
@@ -49,6 +80,8 @@ static bool appNoGrab = false; // Grabbing enabled
Q_GUI_EXPORT QS60Data *qt_s60Data = 0;
extern bool qt_sendSpontaneousEvent(QObject*,QEvent*);
+extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
+
QWidget *qt_button_down = 0; // widget got last button-down
bool qt_nograb() // application no-grab option
@@ -201,7 +234,7 @@ static void mapS60MouseEventTypeToQt(QEvent::Type *type, Qt::MouseButton *button
*type = QEvent::MouseButtonDblClick;
}
- if (*type == QEvent::MouseButtonPress)
+ if (*type == QEvent::MouseButtonPress || *type == QEvent::MouseButtonDblClick)
QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons | (*button);
else if (*type == QEvent::MouseButtonRelease)
QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons &(~(*button));
@@ -310,7 +343,7 @@ void QSymbianControl::HandleLongTapEventL( const TPoint& aPenEventLocation, cons
QMouseEvent mEvent(QEvent::MouseButtonPress, alienWidget->mapFrom(qwidget, widgetPos), globalPos,
Qt::RightButton, QApplicationPrivate::mouse_buttons, Qt::NoModifier);
sendMouseEvent(alienWidget, &mEvent);
- m_previousEventLongTap = true;
+ m_previousEventLongTap = false;
}
void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent)
@@ -339,7 +372,7 @@ void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent)
TPoint controlScreenPos = PositionRelativeToScreen();
QPoint globalPos = QPoint(controlScreenPos.iX, controlScreenPos.iY) + widgetPos;
- if (type == QEvent::MouseButtonPress)
+ if (type == QEvent::MouseButtonPress || type == QEvent::MouseButtonDblClick)
{
// get the button press target
alienWidget = qwidget->childAt(widgetPos);
@@ -359,7 +392,7 @@ void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent)
alienWidget = S60->mousePressTarget;
if (alienWidget != S60->lastPointerEventTarget)
- if (type == QEvent::MouseButtonPress || type == QEvent::MouseMove)
+ if (type == QEvent::MouseButtonPress || type == QEvent::MouseButtonDblClick || type == QEvent::MouseMove)
{
//moved to another widget, create enter and leave events
if (S60->lastPointerEventTarget)
@@ -408,6 +441,13 @@ void QSymbianControl::sendMouseEvent(QWidget *widget, QMouseEvent *mEvent)
TKeyResponse QSymbianControl::OfferKeyEventL(const TKeyEvent& keyEvent, TEventCode type)
{
+ TKeyResponse r = EKeyWasNotConsumed;
+ QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(r = OfferKeyEvent(keyEvent, type));
+ return r;
+}
+
+TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCode type)
+{
switch (type) {
//case EEventKeyDown: // <-- Intentionally left out. See below.
case EEventKeyUp:
@@ -521,7 +561,14 @@ TKeyResponse QSymbianControl::sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent)
#ifndef QT_NO_IM
TCoeInputCapabilities QSymbianControl::InputCapabilities() const
{
- QWidget *w = qwidget->focusWidget();
+ QWidget *w = 0;
+
+ if(qwidget->hasFocus()) {
+ w = qwidget;
+ } else {
+ w = qwidget->focusWidget();
+ }
+
QCoeFepInputContext *ic;
if (w && w->isEnabled() && w->testAttribute(Qt::WA_InputMethodEnabled)
&& (ic = qobject_cast<QCoeFepInputContext *>(w->inputContext()))) {
@@ -639,21 +686,7 @@ void QSymbianControl::HandleResourceChange(int resourceType)
// font change event
break;
case KEikDynamicLayoutVariantSwitch:
- {
-#ifndef QT_NO_STYLE_S60
- QS60Style *s60Style = 0;
-
-#ifndef QT_NO_STYLE_STYLESHEET
- QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle*>(QApplication::style());
- if (proxy)
- s60Style = qobject_cast<QS60Style*>(proxy->baseStyle());
- else
-#endif
- s60Style = qobject_cast<QS60Style*>(QApplication::style());
-
- if (s60Style)
- s60Style->handleDynamicLayoutVariantSwitch();
-#endif
+ {
if (qwidget->isFullScreen()) {
SetExtentToWholeScreen();
} else if (qwidget->isMaximized()) {
@@ -662,12 +695,6 @@ void QSymbianControl::HandleResourceChange(int resourceType)
}
break;
}
-#ifndef QT_NO_STYLE_S60
- case KAknsMessageSkinChange:
- if (QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style()))
- s60Style->handleSkinChange();
- break;
-#endif
default:
break;
}
@@ -988,6 +1015,13 @@ int QApplication::s60ProcessEvent(TWsEvent *event)
case EEventScreenDeviceChanged:
if (S60)
S60->updateScreenSize();
+ if (qt_desktopWidget) {
+ QSize oldSize = qt_desktopWidget->size();
+ qt_desktopWidget->data->crect.setWidth(S60->screenWidthInPixels);
+ qt_desktopWidget->data->crect.setHeight(S60->screenHeightInPixels);
+ QResizeEvent e(qt_desktopWidget->size(), oldSize);
+ QApplication::sendEvent(qt_desktopWidget, &e);
+ }
return 0; // Propagate to CONE
case EEventWindowVisibilityChanged:
if (controlInMap) {
@@ -1001,6 +1035,7 @@ int QApplication::s60ProcessEvent(TWsEvent *event)
} else if ((visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible)
&& !w->d_func()->maybeBackingStore()) {
w->d_func()->topData()->backingStore = new QWidgetBackingStore(w);
+ w->update();
}
return 1;
}
@@ -1020,17 +1055,67 @@ bool QApplication::s60EventFilter(TWsEvent *aEvent)
return false;
}
-void QApplication::s60HandleCommandL(int command)
+/*!
+ Handles commands which are typically handled by CAknAppUi::HandleCommandL()
+ Qts Ui integration into Symbian is partially achieved by deriving from CAknAppUi.
+ Currently, exit, menu and softkey commands are handled
+
+ \sa s60EventFilter(), s60ProcessEvent()
+*/
+void QApplication::symbianHandleCommand(int command)
{
switch (command) {
case EEikCmdExit:
- case EAknSoftkeyBack:
case EAknSoftkeyExit:
- qApp->exit();
+ exit();
+ break;
+ default:
+ if (command >= SOFTKEYSTART && command <= SOFTKEYEND) {
+ int index= command-SOFTKEYSTART;
+ QWidget* focused = QApplication::focusWidget();
+ const QList<QAction*>& softKeys = focused->softKeys();
+ Q_ASSERT(index<softKeys.count());
+ softKeys.at(index)->activate(QAction::Trigger);
+ }
+ else
+ QMenuBarPrivate::symbianCommands(command);
+ break;
+ }
+}
+
+void QApplication::symbianResourceChange(int type)
+{
+ switch (type) {
+ case KEikDynamicLayoutVariantSwitch:
+ {
+ if (S60)
+ S60->updateScreenSize();
+
+#ifndef QT_NO_STYLE_S60
+ QS60Style *s60Style = 0;
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle*>(QApplication::style());
+ if (proxy)
+ s60Style = qobject_cast<QS60Style*>(proxy->baseStyle());
+ else
+#endif
+ s60Style = qobject_cast<QS60Style*>(QApplication::style());
+
+ if (s60Style)
+ s60Style->handleDynamicLayoutVariantSwitch();
+#endif
+ }
break;
+
+#ifndef QT_NO_STYLE_S60
+ case KAknsMessageSkinChange:
+ if (QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style()))
+ s60Style->handleSkinChange();
+ break;
+#endif
+
default:
- // For now assume all unknown menu items are Qt menu items
- QMenuBar::symbianCommands(command);
break;
}
}
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index f14ad6f..239ee14 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -1675,20 +1675,23 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
// send the context menu event is a different one
if (!alienWidget->testAttribute(Qt::WA_NativeWindow) && !alienWidget->testAttribute(Qt::WA_PaintOnScreen)) {
alienWidget = QApplication::widgetAt(globalPos);
- pos = alienWidget->mapFromGlobal(globalPos);
+ if (alienWidget)
+ pos = alienWidget->mapFromGlobal(globalPos);
}
- SHRGINFO shrg;
- shrg.cbSize = sizeof(shrg);
- shrg.hwndClient = hwnd;
- shrg.ptDown.x = GET_X_LPARAM(lParam);
- shrg.ptDown.y = GET_Y_LPARAM(lParam);
- shrg.dwFlags = SHRG_RETURNCMD | SHRG_NOANIMATION;
- resolveAygLibs();
- if (ptrRecognizeGesture && (ptrRecognizeGesture(&shrg) == GN_CONTEXTMENU)) {
- if (qApp->activePopupWidget())
- qApp->activePopupWidget()->close();
- QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos);
- result = qt_sendSpontaneousEvent(alienWidget, &e);
+ if (alienWidget) {
+ SHRGINFO shrg;
+ shrg.cbSize = sizeof(shrg);
+ shrg.hwndClient = hwnd;
+ shrg.ptDown.x = GET_X_LPARAM(lParam);
+ shrg.ptDown.y = GET_Y_LPARAM(lParam);
+ shrg.dwFlags = SHRG_RETURNCMD | SHRG_NOANIMATION;
+ resolveAygLibs();
+ if (ptrRecognizeGesture && (ptrRecognizeGesture(&shrg) == GN_CONTEXTMENU)) {
+ if (qApp->activePopupWidget())
+ qApp->activePopupWidget()->close();
+ QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos);
+ result = qt_sendSpontaneousEvent(alienWidget, &e);
+ }
}
}
}
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index a3c9406..12155f0 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -2955,10 +2955,10 @@ QWidget *QApplication::topLevelAt(const QPoint &p)
Window wid = widget->internalWinId();
while (ctarget && !w) {
X11->ignoreBadwindow();
- XTranslateCoordinates(X11->display,
- QX11Info::appRootWindow(screen),
- ctarget, x, y, &unused, &unused, &ctarget);
- if (X11->badwindow())
+ if (!XTranslateCoordinates(X11->display,
+ QX11Info::appRootWindow(screen),
+ ctarget, x, y, &unused, &unused, &ctarget)
+ || X11->badwindow())
break;
if (ctarget == wid) {
// Found!
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
index 917b5d5..bab3449 100644
--- a/src/gui/kernel/qclipboard.cpp
+++ b/src/gui/kernel/qclipboard.cpp
@@ -466,7 +466,7 @@ void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode)
The \a mode argument is used to control which part of the system
clipboard is used. If \a mode is QClipboard::Clipboard, this
- function clears the the global clipboard contents. If \a mode is
+ function clears the global clipboard contents. If \a mode is
QClipboard::Selection, this function clears the global mouse
selection contents. If \a mode is QClipboard::FindBuffer, this
function clears the search string buffer.
diff --git a/src/gui/kernel/qclipboard_s60.cpp b/src/gui/kernel/qclipboard_s60.cpp
index ec595b5..f89f3e5 100644
--- a/src/gui/kernel/qclipboard_s60.cpp
+++ b/src/gui/kernel/qclipboard_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
index 9a24645..2ca6a3d 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
@@ -90,6 +90,7 @@
QT_BEGIN_NAMESPACE
extern void onApplicationChangedActivation(bool); // qapplication_mac.mm
+extern void qt_release_apple_event_handler(); //qapplication_mac.mm
QT_END_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QDesktopWidgetImplementation)
@@ -207,7 +208,6 @@ static void cleanupCocoaApplicationDelegate()
{
Q_UNUSED(aNotification);
inLaunch = false;
- extern void qt_release_apple_event_handler(); //qapplication_mac.mm
qt_release_apple_event_handler();
}
diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm
index c69826f..b2941fe 100644
--- a/src/gui/kernel/qcocoapanel_mac.mm
+++ b/src/gui/kernel/qcocoapanel_mac.mm
@@ -107,9 +107,16 @@ QT_USE_NAMESPACE
- (void)sendEvent:(NSEvent *)event
{
- [self retain];
-
QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
+
+ // Cocoa can hold onto the window after we've disavowed its knowledge. So,
+ // if we get sent an event afterwards just have it go through the super's
+ // version and don't do any stuff with Qt.
+ if (!widget) {
+ [super sendEvent:event];
+ return;
+ }
+ [self retain];
QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget));
Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]);
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 4ceae3f..f1a7f39 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -789,10 +789,22 @@ extern "C" {
bool wheelOK = false;
Qt::KeyboardModifiers keyMods = qt_cocoaModifiers2QtModifiers([theEvent modifierFlags]);
+ QWidget *widgetToGetMouse = qwidget;
+ if (widgetToGetMouse->testAttribute(Qt::WA_TransparentForMouseEvents)) {
+ // Simulate passing the event through since Cocoa doesn't do that for us.
+ // Start by building a tree up.
+ NSView *candidateView = [self viewUnderTransparentForMouseView:self
+ widget:widgetToGetMouse
+ withWindowPoint:windowPoint];
+ if (candidateView != nil) {
+ widgetToGetMouse = QWidget::find(WId(candidateView));
+ }
+ }
+
// Mouse wheel deltas seem to tick in at increments of 0.1. Qt widgets
- // expect the delta to be a multiple of 120.
+ // expect the delta to be a multiple of 120.
const int ScrollFactor = 10 * 120;
- // The qMax(...) factor reduces the
+ // The qMax(...) factor reduces the
// acceleration for large wheel deltas.
int deltaX = [theEvent deltaX] * ScrollFactor * qMax(0.6, 1.1 - qAbs([theEvent deltaX]));
int deltaY = [theEvent deltaY] * ScrollFactor * qMax(0.6, 1.1 - qAbs([theEvent deltaY]));
@@ -800,10 +812,10 @@ extern "C" {
if (deltaX != 0) {
QWheelEvent qwe(qlocal, qglobal, deltaX, buttons, keyMods, Qt::Horizontal);
- qt_sendSpontaneousEvent(qwidget, &qwe);
+ qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
wheelOK = qwe.isAccepted();
if (!wheelOK && QApplicationPrivate::focus_widget
- && QApplicationPrivate::focus_widget != qwidget) {
+ && QApplicationPrivate::focus_widget != widgetToGetMouse) {
QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal,
deltaX, buttons, keyMods, Qt::Horizontal);
qt_sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
@@ -813,10 +825,10 @@ extern "C" {
if (deltaY) {
QWheelEvent qwe(qlocal, qglobal, deltaY, buttons, keyMods, Qt::Vertical);
- qt_sendSpontaneousEvent(qwidget, &qwe);
+ qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
wheelOK = qwe.isAccepted();
if (!wheelOK && QApplicationPrivate::focus_widget
- && QApplicationPrivate::focus_widget != qwidget) {
+ && QApplicationPrivate::focus_widget != widgetToGetMouse) {
QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal,
deltaY, buttons, keyMods, Qt::Vertical);
qt_sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
@@ -828,10 +840,10 @@ extern "C" {
// Qt doesn't explicitly support wheels with a Z component. In a misguided attempt to
// try to be ahead of the pack, I'm adding this extra value.
QWheelEvent qwe(qlocal, qglobal, deltaZ, buttons, keyMods, (Qt::Orientation)3);
- qt_sendSpontaneousEvent(qwidget, &qwe);
+ qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
wheelOK = qwe.isAccepted();
if (!wheelOK && QApplicationPrivate::focus_widget
- && QApplicationPrivate::focus_widget != qwidget) {
+ && QApplicationPrivate::focus_widget != widgetToGetMouse) {
QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal,
deltaZ, buttons, keyMods, (Qt::Orientation)3);
qt_sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h
index 983c762..527b1a6 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/gui/kernel/qcocoaview_mac_p.h
@@ -59,6 +59,7 @@ QT_FORWARD_DECLARE_CLASS(QWidgetPrivate);
QT_FORWARD_DECLARE_CLASS(QWidget);
QT_FORWARD_DECLARE_CLASS(QEvent);
QT_FORWARD_DECLARE_CLASS(QCocoaDropData);
+QT_FORWARD_DECLARE_CLASS(QStringList);
QT_BEGIN_NAMESPACE
struct DnDParams
diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm
index 89f481f..8e62f02 100644
--- a/src/gui/kernel/qcocoawindow_mac.mm
+++ b/src/gui/kernel/qcocoawindow_mac.mm
@@ -128,12 +128,19 @@ QT_USE_NAMESPACE
- (void)sendEvent:(NSEvent *)event
{
- [self retain];
-
QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
+
+ // Cocoa can hold onto the window after we've disavowed its knowledge. So,
+ // if we get sent an event afterwards just have it go through the super's
+ // version and don't do any stuff with Qt.
+ if (!widget) {
+ [super sendEvent:event];
+ return;
+ }
+
+ [self retain];
QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget));
Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]);
-
// sometimes need to redirect mouse events to the popup.
QWidget *popup = qAppInstance()->activePopupWidget();
if (popup && popup != widget) {
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp
index c24abc4..21a4287 100644
--- a/src/gui/kernel/qcursor.cpp
+++ b/src/gui/kernel/qcursor.cpp
@@ -375,7 +375,9 @@ void QCursorData::cleanup()
return;
for (int shape = 0; shape <= Qt::LastCursor; ++shape) {
- delete qt_cursorTable[shape];
+ // In case someone has a static QCursor defined with this shape
+ if (!qt_cursorTable[shape]->ref.deref())
+ delete qt_cursorTable[shape];
qt_cursorTable[shape] = 0;
}
QCursorData::initialized = false;
diff --git a/src/gui/kernel/qcursor_qws.cpp b/src/gui/kernel/qcursor_qws.cpp
index 097b982..99800a8 100644
--- a/src/gui/kernel/qcursor_qws.cpp
+++ b/src/gui/kernel/qcursor_qws.cpp
@@ -66,7 +66,11 @@ QCursorData::~QCursorData()
{
delete bm;
delete bmm;
- QPaintDevice::qwsDisplay()->destroyCursor(id);
+ QT_TRY {
+ QPaintDevice::qwsDisplay()->destroyCursor(id);
+ } QT_CATCH(const std::bad_alloc &) {
+ // do nothing.
+ }
}
diff --git a/src/gui/kernel/qcursor_s60.cpp b/src/gui/kernel/qcursor_s60.cpp
index 4d3f067..a281130 100644
--- a/src/gui/kernel/qcursor_s60.cpp
+++ b/src/gui/kernel/qcursor_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
diff --git a/src/gui/kernel/qdesktopwidget_s60.cpp b/src/gui/kernel/qdesktopwidget_s60.cpp
index 029892e..eefd0ef 100644
--- a/src/gui/kernel/qdesktopwidget_s60.cpp
+++ b/src/gui/kernel/qdesktopwidget_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
@@ -32,34 +62,58 @@ public:
static int screenCount;
static int primaryScreen;
+
+ static QVector<QRect> *rects;
+ static QVector<QRect> *workrects;
+
+ static int refcount;
};
int QDesktopWidgetPrivate::screenCount = 1;
int QDesktopWidgetPrivate::primaryScreen = 0;
+QVector<QRect> *QDesktopWidgetPrivate::rects = 0;
+QVector<QRect> *QDesktopWidgetPrivate::workrects = 0;
+int QDesktopWidgetPrivate::refcount = 0;
QDesktopWidgetPrivate::QDesktopWidgetPrivate()
{
+ ++refcount;
}
QDesktopWidgetPrivate::~QDesktopWidgetPrivate()
{
+ if (!--refcount)
+ cleanup();
}
void QDesktopWidgetPrivate::init(QDesktopWidget *that)
{
- TInt screenCount=0;
- TInt result=0;
+ int screenCount=0;
+
+ if (HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount) == KErrNone)
+ QDesktopWidgetPrivate::screenCount = screenCount;
+ else
+ QDesktopWidgetPrivate::screenCount = 0;
+
+ rects = new QVector<QRect>();
+ workrects = new QVector<QRect>();
- result = HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount);
- QDesktopWidgetPrivate::screenCount = screenCount;
- if( result != KErrNone)
- {
- // ### What to do if no screens found?
- }
+ rects->resize(QDesktopWidgetPrivate::screenCount);
+ workrects->resize(QDesktopWidgetPrivate::screenCount);
+
+ // ### TODO: Implement proper multi-display support
+ rects->resize(1);
+ rects->replace(0, that->rect());
+ workrects->resize(1);
+ workrects->replace(0, that->rect());
}
void QDesktopWidgetPrivate::cleanup()
{
+ delete rects;
+ rects = 0;
+ delete workrects;
+ workrects = 0;
}
@@ -120,6 +174,29 @@ int QDesktopWidget::screenNumber(const QPoint &point) const
void QDesktopWidget::resizeEvent(QResizeEvent *)
{
+ Q_D(QDesktopWidget);
+ QVector<QRect> oldrects;
+ oldrects = *d->rects;
+ QVector<QRect> oldworkrects;
+ oldworkrects = *d->workrects;
+ int oldscreencount = d->screenCount;
+
+ QDesktopWidgetPrivate::cleanup();
+ QDesktopWidgetPrivate::init(this);
+
+ for (int i = 0; i < qMin(oldscreencount, d->screenCount); ++i) {
+ QRect oldrect = oldrects[i];
+ QRect newrect = d->rects->at(i);
+ if (oldrect != newrect)
+ emit resized(i);
+ }
+
+ for (int j = 0; j < qMin(oldscreencount, d->screenCount); ++j) {
+ QRect oldrect = oldworkrects[j];
+ QRect newrect = d->workrects->at(j);
+ if (oldrect != newrect)
+ emit workAreaResized(j);
+ }
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdnd_s60.cpp b/src/gui/kernel/qdnd_s60.cpp
index 09605be..c459f8f 100644
--- a/src/gui/kernel/qdnd_s60.cpp
+++ b/src/gui/kernel/qdnd_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 2aed287..ba85eea 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -1665,6 +1665,17 @@ Qt::ButtonState QContextMenuEvent::state() const
several are specified for any character in the string the behaviour
is undefined.
+ \value Selection
+ If set, the edit cursor should be moved to the specified position
+ in the editor text contents. In contrast with \c Cursor, this
+ attribute does not work on the preedit text, but on the surrounding
+ text. The cursor will be moved after the commit string has been
+ committed, and the preedit string will be located at the new edit
+ position.
+ The start position specifies the new position and the length
+ variable can be used to set a selection starting from that point.
+ The value is unused.
+
\sa Attribute
*/
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 2724315..7696d05 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -424,7 +424,8 @@ public:
TextFormat,
Cursor,
Language,
- Ruby
+ Ruby,
+ Selection
};
class Attribute {
public:
diff --git a/src/gui/kernel/qeventdispatcher_s60.cpp b/src/gui/kernel/qeventdispatcher_s60.cpp
index 862f4ef..fcf572e 100644
--- a/src/gui/kernel/qeventdispatcher_s60.cpp
+++ b/src/gui/kernel/qeventdispatcher_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
@@ -32,18 +62,22 @@ bool QEventDispatcherS60::processEvents ( QEventLoop::ProcessEventsFlags flags )
{
bool ret = false;
- bool oldNoInputEventsValue = m_noInputEvents;
- if (flags & QEventLoop::ExcludeUserInputEvents) {
- m_noInputEvents = true;
- } else {
- m_noInputEvents = false;
- ret = sendDeferredInputEvents() || ret;
+ QT_TRY {
+ bool oldNoInputEventsValue = m_noInputEvents;
+ if (flags & QEventLoop::ExcludeUserInputEvents) {
+ m_noInputEvents = true;
+ } else {
+ m_noInputEvents = false;
+ ret = sendDeferredInputEvents() || ret;
+ }
+
+ ret = QEventDispatcherSymbian::processEvents(flags) || ret;
+
+ m_noInputEvents = oldNoInputEventsValue;
+ } QT_CATCH (const std::exception& ex) {
+ CActiveScheduler::Current()->Error(qt_translateExceptionToSymbianError(ex));
}
- ret = QEventDispatcherSymbian::processEvents(flags) || ret;
-
- m_noInputEvents = oldNoInputEventsValue;
-
return ret;
}
diff --git a/src/gui/kernel/qeventdispatcher_s60_p.h b/src/gui/kernel/qeventdispatcher_s60_p.h
index fec8773..e42af95 100644
--- a/src/gui/kernel/qeventdispatcher_s60_p.h
+++ b/src/gui/kernel/qeventdispatcher_s60_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
diff --git a/src/gui/kernel/qkeymapper_s60.cpp b/src/gui/kernel/qkeymapper_s60.cpp
index 2919551..bb074c1 100644
--- a/src/gui/kernel/qkeymapper_s60.cpp
+++ b/src/gui/kernel/qkeymapper_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 352d26a..3bcf9e3 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -629,8 +629,6 @@ const uint QKeySequencePrivate::numberOfKeyBindings = sizeof(QKeySequencePrivate
This enum represent standard key bindings. They can be used to
assign platform dependent keyboard shortcuts to a QAction.
- QKeyEvent also provides the function QKeyEvent::standardKey() to
- query if it matches an existing key binding.
Note that the key bindings are platform dependent. The currently
bound shortcuts can be queried using keyBindings().
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp
index 86894b4..7a19252 100644
--- a/src/gui/kernel/qshortcutmap.cpp
+++ b/src/gui/kernel/qshortcutmap.cpp
@@ -148,9 +148,8 @@ public:
QShortcutMap constructor.
*/
QShortcutMap::QShortcutMap()
+ : d_ptr(new QShortcutMapPrivate(this))
{
- d_ptr = new QShortcutMapPrivate(this);
- Q_ASSERT(d_ptr != 0);
resetState();
}
@@ -159,8 +158,6 @@ QShortcutMap::QShortcutMap()
*/
QShortcutMap::~QShortcutMap()
{
- delete d_ptr;
- d_ptr = 0;
}
/*! \internal
diff --git a/src/gui/kernel/qshortcutmap_p.h b/src/gui/kernel/qshortcutmap_p.h
index 3fe9546..28ee1f0 100644
--- a/src/gui/kernel/qshortcutmap_p.h
+++ b/src/gui/kernel/qshortcutmap_p.h
@@ -55,6 +55,7 @@
#include "QtGui/qkeysequence.h"
#include "QtCore/qvector.h"
+#include "QtCore/qscopedpointer.h"
QT_BEGIN_NAMESPACE
@@ -104,7 +105,7 @@ private:
#ifndef QT_NO_ACTION
bool correctContext(Qt::ShortcutContext context,QAction *a, QWidget *active_window) const;
#endif
- QShortcutMapPrivate *d_ptr;
+ QScopedPointer<QShortcutMapPrivate> d_ptr;
QKeySequence::SequenceMatch find(QKeyEvent *e);
QKeySequence::SequenceMatch matches(const QKeySequence &seq1, const QKeySequence &seq2) const;
diff --git a/src/gui/kernel/qsound_s60.cpp b/src/gui/kernel/qsound_s60.cpp
index 2ac7e26..00fc2fe 100644
--- a/src/gui/kernel/qsound_s60.cpp
+++ b/src/gui/kernel/qsound_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
@@ -116,10 +146,11 @@ QAuServer* qt_new_audio_server()
QAuBucketS60::QAuBucketS60( QAuServerS60 *server, QSound *sound )
: m_sound( sound ), m_server( server ), m_prepared(false), m_playCalled(false)
{
+ QString filepath = QFileInfo( m_sound->fileName() ).absoluteFilePath();
+ filepath = QDir::toNativeSeparators(filepath);
+ TPtrC filepathPtr(qt_QString2TPtrC(filepath));
TRAPD(err, m_playUtility = CMdaAudioPlayerUtility::NewL(*this);
- QString filepath = QFileInfo( m_sound->fileName() ).absoluteFilePath();
- filepath = QDir::toNativeSeparators(filepath);
- m_playUtility->OpenFileL(qt_QString2TPtrC(filepath)));
+ m_playUtility->OpenFileL(filepathPtr));
if(err){
m_server->playCompleted(this, err);
}
diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h
index 4eac35e..2d47a14 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/gui/kernel/qt_s60_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
@@ -117,6 +147,7 @@ protected:
void FocusChanged(TDrawNow aDrawNow);
private:
+ TKeyResponse OfferKeyEvent(const TKeyEvent& aKeyEvent,TEventCode aType);
TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent);
void sendMouseEvent(QWidget *widget, QMouseEvent *mEvent);
void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation );
@@ -212,37 +243,40 @@ static inline QFont qt_TFontSpec2QFontL(const TFontSpec &fontSpec)
static inline QImage::Format qt_TDisplayMode2Format(TDisplayMode mode)
{
- QImage::Format format;
- switch(mode) {
- case EColor256:
- // TODO: is the correct?
- format = QImage::Format_Indexed8;
- break;
- case EColor4K:
- format = QImage::Format_RGB444;
- break;
- case EColor64K:
- format = QImage::Format_RGB16;
- break;
- case EColor16M:
- format = QImage::Format_RGB666;
- break;
- case EColor16MU:
- format = QImage::Format_RGB32;
- break;
- case EColor16MA:
- format = QImage::Format_ARGB32;
- break;
-#ifdef __S60_50__
- case EColor16MAP:
- format = QImage::Format_ARGB32_Premultiplied;
- break;
-#endif
- default:
- qFatal("Screen format not supported");
- break;
- }
- return format;
+ QImage::Format format;
+ switch(mode) {
+ case EGray2:
+ format = QImage::Format_MonoLSB;
+ break;
+ case EColor256:
+ case EGray256:
+ format = QImage::Format_Indexed8;
+ break;
+ case EColor4K:
+ format = QImage::Format_RGB444;
+ break;
+ case EColor64K:
+ format = QImage::Format_RGB16;
+ break;
+ case EColor16M:
+ format = QImage::Format_RGB666;
+ break;
+ case EColor16MU:
+ format = QImage::Format_RGB32;
+ break;
+ case EColor16MA:
+ format = QImage::Format_ARGB32;
+ break;
+#if !defined(__SERIES60_31__) && !defined(__S60_32__)
+ case EColor16MAP:
+ format = QImage::Format_ARGB32_Premultiplied;
+ break;
+#endif
+ default:
+ format = QImage::Format_Invalid;
+ break;
+ }
+ return format;
}
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 06f618d..a83a79f 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -172,7 +172,8 @@ extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp
extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
QWidgetPrivate::QWidgetPrivate(int version) :
- QObjectPrivate(version), extra(0), focus_child(0)
+ QObjectPrivate(version), extra(0),
+ focus_next(0), focus_prev(0), focus_child(0)
,layout(0), widgetItem(0)
,leftmargin(0), topmargin(0), rightmargin(0), bottommargin(0)
,leftLayoutItemMargin(0), topLayoutItemMargin(0), rightLayoutItemMargin(0)
@@ -884,6 +885,30 @@ void QWidget::setAutoFillBackground(bool enabled)
\endlist
\sa QEvent, QPainter, QGridLayout, QBoxLayout
+
+ \section1 SoftKeys
+ \since 4.6
+ \preliminary
+
+ Softkeys API is a platform independent way of mapping actions to (hardware)keys
+ and toolbars provided by the underlying platform.
+
+ There are three major use cases supported. First one is a mobile device
+ with keypad navigation and no touch ui. Second use case is a mobile
+ device with touch ui. Third use case is desktop. For now the softkey API is
+ only implemented for Series60.
+
+ QActions are set to widget(s) via softkey API. Actions in focused widget are
+ mapped to native toolbar or hardware keys. Even though the API allows to set
+ any amount of widgets there might be physical restrictions to amount of
+ softkeys that can be used by the device.
+
+ \o Series60: For series60 menu button is automatically mapped to left
+ soft key if there is QMainWindow with QMenuBar in widgets parent hierarchy.
+
+ \sa softKeys()
+ \sa setSoftKey()
+
*/
QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid
@@ -927,6 +952,23 @@ QRegion qt_dirtyRegion(QWidget *widget)
\endlist
*/
+struct QWidgetExceptionCleaner
+{
+ /* this cleans up when the constructor throws an exception */
+ static inline void cleanup(QWidget *that, QWidgetPrivate *d)
+ {
+#ifndef QT_NO_EXCEPTIONS
+ QWidgetPrivate::uncreatedWidgets->remove(that);
+ if (d->focus_next != that) {
+ if (d->focus_next)
+ d->focus_next->d_func()->focus_prev = d->focus_prev;
+ if (d->focus_prev)
+ d->focus_prev->d_func()->focus_next = d->focus_next;
+ }
+#endif
+ }
+};
+
/*!
Constructs a widget which is a child of \a parent, with widget
flags set to \a f.
@@ -956,7 +998,12 @@ QRegion qt_dirtyRegion(QWidget *widget)
QWidget::QWidget(QWidget *parent, Qt::WindowFlags f)
: QObject(*new QWidgetPrivate, 0), QPaintDevice()
{
- d_func()->init(parent, f);
+ QT_TRY {
+ d_func()->init(parent, f);
+ } QT_CATCH(...) {
+ QWidgetExceptionCleaner::cleanup(this, d_func());
+ QT_RETHROW;
+ }
}
#ifdef QT3_SUPPORT
@@ -967,8 +1014,13 @@ QWidget::QWidget(QWidget *parent, Qt::WindowFlags f)
QWidget::QWidget(QWidget *parent, const char *name, Qt::WindowFlags f)
: QObject(*new QWidgetPrivate, 0), QPaintDevice()
{
- d_func()->init(parent , f);
- setObjectName(QString::fromAscii(name));
+ QT_TRY {
+ d_func()->init(parent , f);
+ setObjectName(QString::fromAscii(name));
+ } QT_CATCH(...) {
+ QWidgetExceptionCleaner::cleanup(this, d_func());
+ QT_RETHROW;
+ }
}
#endif
@@ -977,7 +1029,13 @@ QWidget::QWidget(QWidget *parent, const char *name, Qt::WindowFlags f)
QWidget::QWidget(QWidgetPrivate &dd, QWidget* parent, Qt::WindowFlags f)
: QObject(dd, 0), QPaintDevice()
{
- d_func()->init(parent, f);
+ Q_D(QWidget);
+ QT_TRY {
+ d->init(parent, f);
+ } QT_CATCH(...) {
+ QWidgetExceptionCleaner::cleanup(this, d_func());
+ QT_RETHROW;
+ }
}
/*!
@@ -2046,17 +2104,20 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QPoin
// Defined in qmacstyle_mac.cpp
extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, const QBrush &brush);
qt_mac_fill_background(painter, rgn, offset, brush);
-#elif defined(Q_WS_S60)
- // Defined in qs60style_symbian.cpp
- extern void qt_s60_fill_background(QPainter *painter, const QRegion &rgn,
- const QPoint &offset, const QBrush &brush);
- qt_s60_fill_background(painter, rgn, offset, brush);
#else
- const QRegion translated = rgn.translated(offset);
- const QRect rect(translated.boundingRect());
- painter->setClipRegion(translated);
- painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
-#endif
+#if !defined(QT_NO_STYLE_S60)
+ // Defined in qs60style.cpp
+ extern bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn,
+ const QPoint &offset, const QBrush &brush);
+ if (!qt_s60_fill_background(painter, rgn, offset, brush))
+#endif // !defined(QT_NO_STYLE_S60)
+ {
+ const QRegion translated = rgn.translated(offset);
+ const QRect rect(translated.boundingRect());
+ painter->setClipRegion(translated);
+ painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
+ }
+#endif // Q_WS_MAC
} else {
const QVector<QRect> &rects = rgn.rects();
for (int i = 0; i < rects.size(); ++i)
@@ -2361,13 +2422,26 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool
)
{
Q_Q(QWidget);
- createExtra();
-
QStyle *oldStyle = q->style();
#ifndef QT_NO_STYLE_STYLESHEET
- QStyle *origStyle = extra->style;
+ QStyle *origStyle = 0;
+#endif
+
+#ifdef Q_WS_MAC
+ // the metalhack boolean allows Qt/Mac to do a proper re-polish depending
+ // on how the Qt::WA_MacBrushedMetal attribute is set. It is only ever
+ // set when changing that attribute and passes the widget's CURRENT style.
+ // therefore no need to do a reassignment.
+ if (!metalHack)
+#endif
+ {
+ createExtra();
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ origStyle = extra->style;
#endif
- extra->style = newStyle;
+ extra->style = newStyle;
+ }
// repolish
if (q->windowType() != Qt::Desktop) {
@@ -4864,6 +4938,13 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
d->extra->inRenderWithPainter = false;
}
+#if !defined(Q_WS_S60)
+void QWidgetPrivate::setSoftKeys_sys(const QList<QAction*> &softkeys)
+{
+ Q_UNUSED(softkeys)
+}
+#endif // !defined(Q_WS_S60)
+
bool QWidgetPrivate::isAboutToShow() const
{
if (data.in_show)
@@ -5052,7 +5133,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
#ifndef QT_NO_SCROLLAREA
QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(q->parent());
if (scrollArea && scrollArea->viewport() == q) {
- QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr;
+ QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr.data();
QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate);
scrollAreaOffset = priv->contentsOffset();
p.translate(-scrollAreaOffset);
@@ -5699,9 +5780,12 @@ bool QWidget::hasFocus() const
void QWidget::setFocus(Qt::FocusReason reason)
{
+ Q_D(QWidget);
+ d->setSoftKeys_sys(softKeys());
+
if (!isEnabled())
return;
-
+
QWidget *f = this;
while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
f = f->d_func()->extra->focus_proxy;
@@ -5809,8 +5893,9 @@ void QWidget::setFocus(Qt::FocusReason reason)
void QWidget::clearFocus()
{
QWidget *w = this;
- while (w && w->d_func()->focus_child == this) {
- w->d_func()->focus_child = 0;
+ while (w) {
+ if (w->d_func()->focus_child == this)
+ w->d_func()->focus_child = 0;
w = w->parentWidget();
}
#ifndef QT_NO_GRAPHICSVIEW
@@ -6287,7 +6372,7 @@ QByteArray QWidget::saveGeometry() const
returns false.
If the restored geometry is off-screen, it will be modified to be
- inside the the available screen geometry.
+ inside the available screen geometry.
To restore geometry saved using QSettings, you can use code like
this:
@@ -8484,6 +8569,9 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const
return QRect(width()/2, 0, 1, height());
case Qt::ImFont:
return font();
+ case Qt::ImAnchorPosition:
+ // Fallback.
+ return inputMethodQuery(Qt::ImCursorPosition);
default:
return QVariant();
}
@@ -11490,6 +11578,66 @@ void QWidget::clearMask()
setMask(QRegion());
}
+/*!
+ \preliminary
+ \since 4.6
+
+ Returns the (possibly empty) list of this widget's softkeys.
+ Returned list cannot be changed. Softkeys should be added
+ and removed via method called setSoftKeys
+
+ \sa setSoftKey(), setSoftKeys()
+*/
+const QList<QAction*>& QWidget::softKeys() const
+{
+ Q_D(const QWidget);
+ if( d->softKeys.count() > 0)
+ return d->softKeys;
+ if (isWindow() || !parentWidget())
+ return d->softKeys;
+
+ return parentWidget()->softKeys();
+}
+
+/*!
+ \preliminary
+ \since 4.6
+
+ Sets the softkey \a softkey to this widget's list of softkeys,
+ Setting 0 as softkey will clear all the existing softkeys set
+ to the widget
+ A QWidget can have 0 or more softkeys
+
+ \sa softKeys(), setSoftKeys()
+*/
+void QWidget::setSoftKey(QAction *softKey)
+{
+ Q_D(QWidget);
+ qDeleteAll(d->softKeys);
+ d->softKeys.clear();
+ if (softKey)
+ d->softKeys.append(softKey);
+ if (QApplication::focusWidget() == this)
+ d->setSoftKeys_sys(this->softKeys());
+}
+
+/*!
+ Sets the list of softkeys \a softkeys to this widget's list of softkeys,
+ A QWidget can have 0 or more softkeys
+
+ \sa softKeys(), setSoftKey()
+*/
+void QWidget::setSoftKeys(const QList<QAction*> &softKeys)
+{
+ Q_D(QWidget);
+ qDeleteAll(d->softKeys);
+ d->softKeys.clear();
+ d->softKeys = softKeys;
+
+ if ((QApplication::focusWidget() == this) || (QApplication::focusWidget()==0))
+ d->setSoftKeys_sys(this->softKeys());
+}
+
/*! \fn const QX11Info &QWidget::x11Info() const
Returns information about the configuration of the X display used to display
the widget.
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index 0dd470d..1edd466 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -554,6 +554,9 @@ public:
void removeAction(QAction *action);
QList<QAction*> actions() const;
#endif
+ const QList<QAction*>& softKeys() const;
+ void setSoftKey(QAction *softKey);
+ void setSoftKeys(const QList<QAction*> &softKeys);
QWidget *parentWidget() const;
@@ -728,6 +731,7 @@ private:
friend class QGraphicsProxyWidget;
friend class QGraphicsProxyWidgetPrivate;
friend class QStyleSheetStyle;
+ friend struct QWidgetExceptionCleaner;
#ifdef Q_WS_MAC
friend class QCoreGraphicsPaintEnginePrivate;
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index f863428..e2197c6 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -1215,7 +1215,7 @@ OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event,
QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(widget->parent());
QPoint scrollAreaOffset;
if (scrollArea && scrollArea->viewport() == widget) {
- QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(static_cast<QWidget *>(scrollArea)->d_ptr);
+ QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(static_cast<QWidget *>(scrollArea)->d_ptr.data());
scrollAreaOffset = priv->contentsOffset();
p.translate(-scrollAreaOffset);
}
@@ -3600,11 +3600,15 @@ void QWidgetPrivate::raise_sys()
}
} else {
// Cocoa doesn't really have an idea of Z-ordering, but you can
- // fake it by changing the order of it.
+ // fake it by changing the order of it. But beware, removing an
+ // NSView will also remove it as the first responder. So we re-set
+ // the first responder just in case:
NSView *view = qt_mac_nativeview_for(q);
NSView *parentView = [view superview];
+ NSResponder *firstResponder = [[view window] firstResponder];
[view removeFromSuperview];
[parentView addSubview:view];
+ [[view window] makeFirstResponder:firstResponder];
}
#else
if(q->isWindow()) {
@@ -3642,6 +3646,7 @@ void QWidgetPrivate::lower_sys()
NSArray *tmpViews = [parentView subviews];
NSMutableArray *subviews = [[NSMutableArray alloc] initWithCapacity:[tmpViews count]];
[subviews addObjectsFromArray:tmpViews];
+ NSResponder *firstResponder = [[myview window] firstResponder];
// Implicit assumption that myViewIndex is included in subviews, that's why I'm not checking
// myViewIndex.
NSUInteger index = 0;
@@ -3661,6 +3666,7 @@ void QWidgetPrivate::lower_sys()
for (NSView *subview in subviews)
[parentView addSubview:subview];
[subviews release];
+ [[myview window] makeFirstResponder:firstResponder];
}
#else
if(q->isWindow()) {
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index d5f1b98..084439c 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -84,6 +84,9 @@ class RDrawableWindow;
class CCoeControl;
class CAknTitlePane;
class CAknContextPane;
+// The following 2 defines may only be needed for s60. To be seen.
+const int SOFTKEYSTART=5000;
+const int SOFTKEYEND=5004;
#endif
QT_BEGIN_NAMESPACE
@@ -224,6 +227,7 @@ public:
explicit QWidgetPrivate(int version = QObjectPrivateVersion);
~QWidgetPrivate();
+ void setSoftKeys_sys(const QList<QAction*> &softkeys);
QWExtra *extraData() const;
QTLWExtra *topData() const;
QTLWExtra *maybeTopData() const;
@@ -511,6 +515,7 @@ public:
#ifndef QT_NO_ACTION
QList<QAction*> actions;
#endif
+ QList<QAction*> softKeys;
QLayout *layout;
QWidgetItemV2 *widgetItem;
#if !defined(QT_NO_IM)
diff --git a/src/gui/kernel/qwidget_qws.cpp b/src/gui/kernel/qwidget_qws.cpp
index 1445f57..0073d3f 100644
--- a/src/gui/kernel/qwidget_qws.cpp
+++ b/src/gui/kernel/qwidget_qws.cpp
@@ -652,7 +652,8 @@ void QWidgetPrivate::hide_sys()
q->releaseMouse();
// requestWindowRegion(QRegion());
- extra->topextra->backingStore->releaseBuffer();
+ if (extra->topextra->backingStore)
+ extra->topextra->backingStore->releaseBuffer();
QWidget::qwsDisplay()->requestFocus(data.winid,false);
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index 5c3055d..bc69d6d 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
@@ -22,6 +52,8 @@
#include <qinputcontext.h>
+#include <aknappui.h>
+
QT_BEGIN_NAMESPACE
extern bool qt_nograb();
@@ -29,6 +61,56 @@ extern bool qt_nograb();
QWidget *QWidgetPrivate::mouseGrabber = 0;
QWidget *QWidgetPrivate::keyboardGrabber = 0;
+static bool isEqual(const QList<QAction*>& a, const QList<QAction*>& b)
+{
+ if ( a.count() != b.count())
+ return false;
+ int index=0;
+ while (index<a.count()) {
+ if (a.at(index)->softKeyRole() != b.at(index)->softKeyRole())
+ return false;
+ if (a.at(index)->text().compare(b.at(index)->text())!=0)
+ return false;
+ index++;
+ }
+ return true;
+}
+
+
+void QWidgetPrivate::setSoftKeys_sys(const QList<QAction*> &softkeys)
+{
+ Q_Q(QWidget);
+ if (QApplication::focusWidget() && q!=QApplication::focusWidget()) {
+ QList<QAction *> old = QApplication::focusWidget()->softKeys();
+ if (isEqual(old, softkeys ))
+ return;
+ }
+ CCoeAppUi* appui = CEikonEnv::Static()->AppUi();
+ CAknAppUi* aknAppUi = static_cast <CAknAppUi*>(appui);
+ CEikButtonGroupContainer* nativeContainer = aknAppUi->Cba();
+ nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS);
+
+ int placeInScreen=0;
+ for (int index = 0; index < softkeys.count(); index++) {
+ const QAction* softKeyAction = softkeys.at(index);
+ if (softKeyAction->softKeyRole() != QAction::ContextMenuSoftKey) {
+
+ HBufC* text = qt_QString2HBufC(softKeyAction->text());
+ CleanupStack::PushL(text);
+ if (softKeyAction->softKeyRole() == QAction::MenuSoftKey) {
+ nativeContainer->SetCommandL(placeInScreen, EAknSoftkeyOptions, *text);
+ } else {
+ nativeContainer->SetCommandL(placeInScreen, SOFTKEYSTART + index, *text);
+ }
+ CleanupStack::PopAndDestroy();
+ placeInScreen++;
+ }
+ if (placeInScreen==1)
+ placeInScreen=2;
+ }
+ nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation
+}
+
void QWidgetPrivate::setWSGeometry(bool dontShow)
{
@@ -289,7 +371,8 @@ void QWidgetPrivate::hide_sys()
deactivateWidgetCleanup();
WId id = q->internalWinId();
if (q->isWindow() && id) {
- id->SetFocus(false);
+ if(id->IsFocused()) // Avoid unnecessry calls to FocusChanged()
+ id->SetFocus(false);
id->MakeVisible(false);
id->ControlEnv()->AppUi()->RemoveFromStack(id);
if (QWidgetBackingStore *bs = maybeBackingStore())
@@ -305,7 +388,8 @@ void QWidgetPrivate::setFocus_sys()
{
Q_Q(QWidget);
if (q->testAttribute(Qt::WA_WState_Created) && q->window()->windowType() != Qt::Popup)
- q->effectiveWinId()->SetFocus(true);
+ if(!q->effectiveWinId()->IsFocused()) // Avoid unnecessry calls to FocusChanged()
+ q->effectiveWinId()->SetFocus(true);
}
void QWidgetPrivate::raise_sys()
@@ -892,7 +976,8 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
releaseKeyboard();
if (destroyWindow && !(windowType() == Qt::Desktop) && internalWinId()) {
WId id = internalWinId();
- id->SetFocus(false);
+ if(id->IsFocused()) // Avoid unnecessry calls to FocusChanged()
+ id->SetFocus(false);
id->ControlEnv()->AppUi()->RemoveFromStack(id);
CBase::Delete(id);
@@ -973,5 +1058,4 @@ void QWidget::activateWindow()
rw->SetOrdinalPosition(0);
}
}
-
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index 6202b35..6250fb77 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -1509,7 +1509,6 @@ QWidget *QWidget::keyboardGrabber()
void QWidget::activateWindow()
{
- Q_D(QWidget);
QWidget *tlw = window();
if (tlw->isVisible() && !tlw->d_func()->topData()->embedded && !X11->deferred_map.contains(tlw)) {
if (X11->userTime == 0)
@@ -2487,6 +2486,8 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
QRect sr = valid_rect ? r : clipRect();
if (just_update)
q->update();
+ else if (!valid_rect)
+ dirty.translate(dx, dy);
int x1, y1, x2, y2, w = sr.width(), h = sr.height();
if (dx > 0) {
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 33d53e4..693e506 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -190,7 +190,8 @@ embedded {
symbian {
SOURCES += \
painting/qpaintdevice_s60.cpp \
- painting/qregion_s60.cpp
+ painting/qregion_s60.cpp \
+ painting/qcolormap_s60.cpp
}
x11|embedded {
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 854d0aa..c22791a 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -221,7 +221,7 @@ bool qHasPixmapTexture(const QBrush& brush)
{
if (brush.style() != Qt::TexturePattern)
return false;
- QTexturedBrushData *tx_data = static_cast<QTexturedBrushData *>(brush.d);
+ QTexturedBrushData *tx_data = static_cast<QTexturedBrushData *>(brush.d.data());
return tx_data->m_has_pixmap_texture;
}
@@ -230,6 +230,37 @@ struct QGradientBrushData : public QBrushData
QGradient gradient;
};
+struct QBrushDataPointerHandler
+{
+ static inline void deleteData(QBrushData *d)
+ {
+ switch (d->style) {
+ case Qt::TexturePattern:
+ delete static_cast<QTexturedBrushData*>(d);
+ break;
+ case Qt::LinearGradientPattern:
+ case Qt::RadialGradientPattern:
+ case Qt::ConicalGradientPattern:
+ delete static_cast<QGradientBrushData*>(d);
+ break;
+ default:
+ delete d;
+ }
+ }
+
+ static inline void cleanup(QBrushData *d)
+ {
+ if (d && !d->ref.deref()) {
+ deleteData(d);
+ }
+ }
+
+ static inline void reset(QBrushData *&d, QBrushData *other)
+ {
+ cleanup(d);
+ d = other;
+ }
+};
/*!
\class QBrush
@@ -364,20 +395,20 @@ void QBrush::init(const QColor &color, Qt::BrushStyle style)
{
switch(style) {
case Qt::NoBrush:
- d = nullBrushInstance();
+ d.data_ptr() = nullBrushInstance();
d->ref.ref();
if (d->color != color) setColor(color);
return;
case Qt::TexturePattern:
- d = new QTexturedBrushData;
+ d.data_ptr() = new QTexturedBrushData;
break;
case Qt::LinearGradientPattern:
case Qt::RadialGradientPattern:
case Qt::ConicalGradientPattern:
- d = new QGradientBrushData;
+ d.data_ptr() = new QGradientBrushData;
break;
default:
- d = new QBrushData;
+ d.data_ptr() = new QBrushData;
break;
}
d->ref = 1;
@@ -391,8 +422,8 @@ void QBrush::init(const QColor &color, Qt::BrushStyle style)
*/
QBrush::QBrush()
+ : d(nullBrushInstance())
{
- d = nullBrushInstance();
Q_ASSERT(d);
d->ref.ref();
}
@@ -435,7 +466,7 @@ QBrush::QBrush(Qt::BrushStyle style)
if (qbrush_check_type(style))
init(Qt::black, style);
else {
- d = nullBrushInstance();
+ d.data_ptr() = nullBrushInstance();
d->ref.ref();
}
}
@@ -451,7 +482,7 @@ QBrush::QBrush(const QColor &color, Qt::BrushStyle style)
if (qbrush_check_type(style))
init(color, style);
else {
- d = nullBrushInstance();
+ d.data_ptr() = nullBrushInstance();
d->ref.ref();
}
}
@@ -468,7 +499,7 @@ QBrush::QBrush(Qt::GlobalColor color, Qt::BrushStyle style)
if (qbrush_check_type(style))
init(color, style);
else {
- d = nullBrushInstance();
+ d.data_ptr() = nullBrushInstance();
d->ref.ref();
}
}
@@ -510,8 +541,8 @@ QBrush::QBrush(Qt::GlobalColor color, const QPixmap &pixmap)
*/
QBrush::QBrush(const QBrush &other)
+ : d(other.d.data())
{
- d = other.d;
d->ref.ref();
}
@@ -535,7 +566,7 @@ QBrush::QBrush(const QGradient &gradient)
};
init(QColor(), enum_table[gradient.type()]);
- QGradientBrushData *grad = static_cast<QGradientBrushData *>(d);
+ QGradientBrushData *grad = static_cast<QGradientBrushData *>(d.data());
grad->gradient = gradient;
}
@@ -545,24 +576,11 @@ QBrush::QBrush(const QGradient &gradient)
QBrush::~QBrush()
{
- if (!d->ref.deref())
- cleanUp(d);
}
void QBrush::cleanUp(QBrushData *x)
{
- switch (x->style) {
- case Qt::TexturePattern:
- delete static_cast<QTexturedBrushData*>(x);
- break;
- case Qt::LinearGradientPattern:
- case Qt::RadialGradientPattern:
- case Qt::ConicalGradientPattern:
- delete static_cast<QGradientBrushData*>(x);
- break;
- default:
- delete x;
- }
+ QBrushDataPointerHandler::deleteData(x);
}
@@ -571,38 +589,36 @@ void QBrush::detach(Qt::BrushStyle newStyle)
if (newStyle == d->style && d->ref == 1)
return;
- QBrushData *x;
+ QScopedPointer<QBrushData> x;
switch(newStyle) {
case Qt::TexturePattern: {
QTexturedBrushData *tbd = new QTexturedBrushData;
if (d->style == Qt::TexturePattern) {
- QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d);
+ QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data());
if (data->m_has_pixmap_texture)
tbd->setPixmap(data->pixmap());
else
tbd->setImage(data->image());
}
- x = tbd;
+ x.reset(tbd);
break;
}
case Qt::LinearGradientPattern:
case Qt::RadialGradientPattern:
case Qt::ConicalGradientPattern:
- x = new QGradientBrushData;
- static_cast<QGradientBrushData *>(x)->gradient =
- static_cast<QGradientBrushData *>(d)->gradient;
+ x.reset(new QGradientBrushData);
+ static_cast<QGradientBrushData *>(x.data())->gradient =
+ static_cast<QGradientBrushData *>(d.data())->gradient;
break;
default:
- x = new QBrushData;
+ x.reset(new QBrushData);
break;
}
x->ref = 1;
x->style = newStyle;
x->color = d->color;
x->transform = d->transform;
- if (!d->ref.deref())
- cleanUp(d);
- d = x;
+ d.reset(x.take());
}
@@ -615,10 +631,11 @@ void QBrush::detach(Qt::BrushStyle newStyle)
QBrush &QBrush::operator=(const QBrush &b)
{
+ if (this == &b)
+ return *this;
+
b.d->ref.ref();
- if (!d->ref.deref())
- cleanUp(d);
- d = b.d;
+ d.reset(b.d.data());
return *this;
}
@@ -713,7 +730,7 @@ QPixmap *QBrush::pixmap() const
{
if (d->style != Qt::TexturePattern)
return 0;
- QTexturedBrushData *data = static_cast<QTexturedBrushData*>(d);
+ QTexturedBrushData *data = static_cast<QTexturedBrushData*>(d.data());
QPixmap &pixmap = data->pixmap();
return pixmap.isNull() ? 0 : &pixmap;
}
@@ -730,7 +747,7 @@ QPixmap *QBrush::pixmap() const
QPixmap QBrush::texture() const
{
return d->style == Qt::TexturePattern
- ? ((QTexturedBrushData*) d)->pixmap()
+ ? (static_cast<QTexturedBrushData *>(d.data()))->pixmap()
: QPixmap();
}
@@ -748,7 +765,7 @@ void QBrush::setTexture(const QPixmap &pixmap)
{
if (!pixmap.isNull()) {
detach(Qt::TexturePattern);
- QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d);
+ QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data());
data->setPixmap(pixmap);
} else {
detach(Qt::NoBrush);
@@ -771,7 +788,7 @@ void QBrush::setTexture(const QPixmap &pixmap)
QImage QBrush::textureImage() const
{
return d->style == Qt::TexturePattern
- ? ((QTexturedBrushData *) d)->image()
+ ? (static_cast<QTexturedBrushData *>(d.data()))->image()
: QImage();
}
@@ -796,7 +813,7 @@ void QBrush::setTextureImage(const QImage &image)
{
if (!image.isNull()) {
detach(Qt::TexturePattern);
- QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d);
+ QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data());
data->setImage(image);
} else {
detach(Qt::NoBrush);
@@ -812,7 +829,7 @@ const QGradient *QBrush::gradient() const
if (d->style == Qt::LinearGradientPattern
|| d->style == Qt::RadialGradientPattern
|| d->style == Qt::ConicalGradientPattern) {
- return &static_cast<const QGradientBrushData *>(d)->gradient;
+ return &static_cast<const QGradientBrushData *>(d.data())->gradient;
}
return 0;
}
@@ -923,16 +940,16 @@ bool QBrush::operator==(const QBrush &b) const
if (b.d->style == d->style && b.d->color == d->color) {
switch (d->style) {
case Qt::TexturePattern: {
- QPixmap &us = ((QTexturedBrushData *) d)->pixmap();
- QPixmap &them = ((QTexturedBrushData *) b.d)->pixmap();
+ QPixmap &us = (static_cast<QTexturedBrushData *>(d.data()))->pixmap();
+ QPixmap &them = (static_cast<QTexturedBrushData *>(b.d.data()))->pixmap();
return ((us.isNull() && them.isNull()) || us.cacheKey() == them.cacheKey());
}
case Qt::LinearGradientPattern:
case Qt::RadialGradientPattern:
case Qt::ConicalGradientPattern:
{
- QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d);
- QGradientBrushData *d2 = static_cast<QGradientBrushData *>(b.d);
+ QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d.data());
+ QGradientBrushData *d2 = static_cast<QGradientBrushData *>(b.d.data());
return d1->gradient == d2->gradient;
}
default:
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index d6d0da3..b3aa04d 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -45,6 +45,7 @@
#include <QtCore/qpair.h>
#include <QtCore/qpoint.h>
#include <QtCore/qvector.h>
+#include <QtCore/qscopedpointer.h>
#include <QtGui/qcolor.h>
#include <QtGui/qmatrix.h>
#include <QtGui/qtransform.h>
@@ -61,6 +62,7 @@ struct QBrushData;
class QPixmap;
class QGradient;
class QVariant;
+struct QBrushDataPointerHandler;
class Q_GUI_EXPORT QBrush
{
@@ -126,13 +128,13 @@ private:
friend bool qHasPixmapTexture(const QBrush& brush);
void detach(Qt::BrushStyle newStyle);
void init(const QColor &color, Qt::BrushStyle bs);
- QBrushData *d;
+ QScopedCustomPointer<QBrushData, QBrushDataPointerHandler> d;
void cleanUp(QBrushData *x);
public:
inline bool isDetached() const;
typedef QBrushData * DataPtr;
- inline DataPtr &data_ptr() { return d; }
+ inline DataPtr &data_ptr() { return d.data_ptr(); }
};
inline void QBrush::setColor(Qt::GlobalColor acolor)
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 1723a19..c50004e 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -2241,4 +2241,12 @@ QDataStream &operator>>(QDataStream &stream, QColor &color)
\sa QColor::rgb(), QColor::rgba()
*/
+/*! \fn void QColormap::initialize()
+ \internal
+*/
+
+/*! \fn void QColormap::cleanup()
+ \internal
+*/
+
QT_END_NAMESPACE
diff --git a/src/gui/painting/qcolormap_s60.cpp b/src/gui/painting/qcolormap_s60.cpp
new file mode 100644
index 0000000..1b58598
--- /dev/null
+++ b/src/gui/painting/qcolormap_s60.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui 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 "qcolormap.h"
+#include "qcolor.h"
+
+QT_BEGIN_NAMESPACE
+
+class QColormapPrivate
+{
+public:
+ inline QColormapPrivate()
+ : ref(1)
+ { }
+
+ QAtomicInt ref;
+};
+
+void QColormap::initialize()
+{
+}
+
+void QColormap::cleanup()
+{
+}
+
+QColormap QColormap::instance(int)
+{
+ return QColormap();
+}
+
+QColormap::QColormap() : d(new QColormapPrivate)
+{}
+
+QColormap::QColormap(const QColormap &colormap) :d (colormap.d)
+{ d->ref.ref(); }
+
+QColormap::~QColormap()
+{
+ if (!d->ref.deref())
+ delete d;
+}
+
+QColormap::Mode QColormap::mode() const
+{ return QColormap::Direct; }
+
+int QColormap::depth() const
+{
+ return 32;
+}
+
+int QColormap::size() const
+{
+ return -1;
+}
+
+uint QColormap::pixel(const QColor &color) const
+{ return color.rgba(); }
+
+const QColor QColormap::colorAt(uint pixel) const
+{ return QColor(pixel); }
+
+const QVector<QColor> QColormap::colormap() const
+{ return QVector<QColor>(); }
+
+QColormap &QColormap::operator=(const QColormap &colormap)
+{ qAtomicAssign(d, colormap.d); return *this; }
+
+QT_END_NAMESPACE
+
diff --git a/src/gui/painting/qcolormap_x11.cpp b/src/gui/painting/qcolormap_x11.cpp
index ccf6955..c9186b1 100644
--- a/src/gui/painting/qcolormap_x11.cpp
+++ b/src/gui/painting/qcolormap_x11.cpp
@@ -337,8 +337,6 @@ static void init_direct(QColormapPrivate *d, bool ownColormap)
static QColormap **cmaps = 0;
-/*! \internal
-*/
void QColormap::initialize()
{
Display *display = QX11Info::display();
@@ -578,8 +576,6 @@ void QColormap::initialize()
}
}
-/*! \internal
-*/
void QColormap::cleanup()
{
Display *display = QX11Info::display();
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index ed4dd57..0b5e5bb 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -7426,8 +7426,8 @@ void qt_build_pow_tables() {
}
#else
for (int i=0; i<256; ++i) {
- qt_pow_rgb_gamma[i] = uchar(qRound(pow(i / 255.0, smoothing) * 255));
- qt_pow_rgb_invgamma[i] = uchar(qRound(pow(i / 255.0, 1 / smoothing) * 255));
+ qt_pow_rgb_gamma[i] = uchar(qRound(pow(i / qreal(255), smoothing) * 255));
+ qt_pow_rgb_invgamma[i] = uchar(qRound(pow(i / qreal(255), 1 / smoothing) * 255));
}
#endif
diff --git a/src/gui/painting/qpaintdevice_s60.cpp b/src/gui/painting/qpaintdevice_s60.cpp
index ec1b765..a2c4499 100644
--- a/src/gui/painting/qpaintdevice_s60.cpp
+++ b/src/gui/painting/qpaintdevice_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp
index 7de1ec4..c5be802 100644
--- a/src/gui/painting/qpaintengine.cpp
+++ b/src/gui/painting/qpaintengine.cpp
@@ -713,7 +713,6 @@ QPaintEngine::QPaintEngine(QPaintEnginePrivate &dptr, PaintEngineFeatures caps)
*/
QPaintEngine::~QPaintEngine()
{
- delete d_ptr;
}
/*!
diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h
index 520f71f..6f56adb 100644
--- a/src/gui/painting/qpaintengine.h
+++ b/src/gui/painting/qpaintengine.h
@@ -44,6 +44,7 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qobjectdefs.h>
+#include <QtCore/qscopedpointer.h>
#include <QtGui/qpainter.h>
QT_BEGIN_HEADER
@@ -239,7 +240,7 @@ protected:
uint selfDestruct : 1;
uint extended : 1;
- QPaintEnginePrivate *d_ptr;
+ QScopedPointer<QPaintEnginePrivate> d_ptr;
private:
void setAutoDestruct(bool autoDestr) { selfDestruct = autoDestr; }
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 1192a58..ada3ebf 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -349,6 +349,7 @@ void QRasterPaintEngine::init()
#else
(unsigned char *) malloc(d->rasterPoolSize);
#endif
+ Q_CHECK_PTR(d->rasterPoolBase);
// The antialiasing raster.
d->grayRaster = new QT_FT_Raster;
@@ -1055,7 +1056,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
int d = x + iw - cx2;
iw -= d;
}
- if (iw < 0)
+ if (iw <= 0)
return;
// adapt the y paremeters...
@@ -1072,7 +1073,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
int d = y + ih - cy2;
ih -= d;
}
- if (ih < 0)
+ if (ih <= 0)
return;
// call the blend function...
@@ -3878,11 +3879,7 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r
{
Q_ASSERT(c1->clipSpanHeight == c2->clipSpanHeight && c1->clipSpanHeight == result->clipSpanHeight);
- // ### buffer overflow possible
- const int BUFFER_SIZE = 4096;
- int buffer[BUFFER_SIZE];
- int *b = buffer;
- int bsize = BUFFER_SIZE;
+ QVarLengthArray<short, 4096> buffer;
QClipData::ClipLine *c1ClipLines = const_cast<QClipData *>(c1)->clipLines();
QClipData::ClipLine *c2ClipLines = const_cast<QClipData *>(c2)->clipLines();
@@ -3908,12 +3905,9 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r
// find required length
int max = qMax(c1_spans[c1_count - 1].x + c1_spans[c1_count - 1].len,
- c2_spans[c2_count - 1].x + c2_spans[c2_count - 1].len);
- if (max > bsize) {
- b = (int *)realloc(bsize == BUFFER_SIZE ? 0 : b, max*sizeof(int));
- bsize = max;
- }
- memset(buffer, 0, BUFFER_SIZE * sizeof(int));
+ c2_spans[c2_count - 1].x + c2_spans[c2_count - 1].len);
+ buffer.resize(max);
+ memset(buffer.data(), 0, buffer.size() * sizeof(short));
// Fill with old spans.
for (int i = 0; i < c1_count; ++i) {
@@ -3949,8 +3943,6 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r
result->appendSpan(sx, x - sx, y, coverage);
}
}
- if (b != buffer)
- free(b);
}
void QRasterPaintEnginePrivate::initializeRasterizer(QSpanData *data)
@@ -3967,7 +3959,7 @@ void QRasterPaintEnginePrivate::initializeRasterizer(QSpanData *data)
const QClipData *c = clip();
if (c) {
const QRect r(QPoint(c->xmin, c->ymin),
- QPoint(c->xmax, c->ymax));
+ QPoint(c->xmax, c->ymax));
clipRect = clipRect.intersected(r);
blend = data->blend;
} else {
@@ -4075,6 +4067,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline,
#else
(unsigned char *) malloc(rasterPoolSize);
#endif
+ Q_CHECK_PTR(rasterPoolBase); // note: we just freed the old rasterPoolBase. I hope it's not fatal.
qt_ft_grays_raster.raster_done(*grayRaster);
qt_ft_grays_raster.raster_new(0, grayRaster);
@@ -4310,93 +4303,107 @@ void QClipData::initialize()
return;
m_clipLines = (ClipLine *)calloc(sizeof(ClipLine), clipSpanHeight);
- m_spans = (QSpan *)malloc(clipSpanHeight*sizeof(QSpan));
+ Q_CHECK_PTR(m_clipLines);
+ QT_TRY {
+ m_spans = (QSpan *)malloc(clipSpanHeight*sizeof(QSpan));
+ Q_CHECK_PTR(m_spans);
+
+ QT_TRY {
+ if (hasRectClip) {
+ int y = 0;
+ while (y < ymin) {
+ m_clipLines[y].spans = 0;
+ m_clipLines[y].count = 0;
+ ++y;
+ }
- if (hasRectClip) {
- int y = 0;
- while (y < ymin) {
- m_clipLines[y].spans = 0;
- m_clipLines[y].count = 0;
- ++y;
- }
+ const int len = clipRect.width();
+ count = 0;
+ while (y < ymax) {
+ QSpan *span = m_spans + count;
+ span->x = xmin;
+ span->len = len;
+ span->y = y;
+ span->coverage = 255;
+ ++count;
- const int len = clipRect.width();
- count = 0;
- while (y < ymax) {
- QSpan *span = m_spans + count;
- span->x = xmin;
- span->len = len;
- span->y = y;
- span->coverage = 255;
- ++count;
-
- m_clipLines[y].spans = span;
- m_clipLines[y].count = 1;
- ++y;
- }
+ m_clipLines[y].spans = span;
+ m_clipLines[y].count = 1;
+ ++y;
+ }
- while (y < clipSpanHeight) {
- m_clipLines[y].spans = 0;
- m_clipLines[y].count = 0;
- ++y;
- }
- } else if (hasRegionClip) {
+ while (y < clipSpanHeight) {
+ m_clipLines[y].spans = 0;
+ m_clipLines[y].count = 0;
+ ++y;
+ }
+ } else if (hasRegionClip) {
+
+ const QVector<QRect> rects = clipRegion.rects();
+ const int numRects = rects.size();
+
+ { // resize
+ const int maxSpans = (ymax - ymin) * numRects;
+ if (maxSpans > allocated) {
+ QSpan *newSpans = (QSpan *)realloc(m_spans, maxSpans * sizeof(QSpan));
+ Q_CHECK_PTR(newSpans);
+ m_spans = newSpans;
+ allocated = maxSpans;
+ }
+ }
- const QVector<QRect> rects = clipRegion.rects();
- const int numRects = rects.size();
+ int y = 0;
+ int firstInBand = 0;
+ while (firstInBand < numRects) {
+ const int currMinY = rects.at(firstInBand).y();
+ const int currMaxY = currMinY + rects.at(firstInBand).height();
- { // resize
- const int maxSpans = (ymax - ymin) * numRects;
- if (maxSpans > allocated) {
- m_spans = (QSpan *)realloc(m_spans, maxSpans * sizeof(QSpan));
- allocated = maxSpans;
- }
- }
+ while (y < currMinY) {
+ m_clipLines[y].spans = 0;
+ m_clipLines[y].count = 0;
+ ++y;
+ }
- int y = 0;
- int firstInBand = 0;
- while (firstInBand < numRects) {
- const int currMinY = rects.at(firstInBand).y();
- const int currMaxY = currMinY + rects.at(firstInBand).height();
+ int lastInBand = firstInBand;
+ while (lastInBand + 1 < numRects && rects.at(lastInBand+1).top() == y)
+ ++lastInBand;
- while (y < currMinY) {
- m_clipLines[y].spans = 0;
- m_clipLines[y].count = 0;
- ++y;
- }
+ while (y < currMaxY) {
- int lastInBand = firstInBand;
- while (lastInBand + 1 < numRects && rects.at(lastInBand+1).top() == y)
- ++lastInBand;
+ m_clipLines[y].spans = m_spans + count;
+ m_clipLines[y].count = lastInBand - firstInBand + 1;
- while (y < currMaxY) {
-
- m_clipLines[y].spans = m_spans + count;
- m_clipLines[y].count = lastInBand - firstInBand + 1;
+ for (int r = firstInBand; r <= lastInBand; ++r) {
+ const QRect &currRect = rects.at(r);
+ QSpan *span = m_spans + count;
+ span->x = currRect.x();
+ span->len = currRect.width();
+ span->y = y;
+ span->coverage = 255;
+ ++count;
+ }
+ ++y;
+ }
- for (int r = firstInBand; r <= lastInBand; ++r) {
- const QRect &currRect = rects.at(r);
- QSpan *span = m_spans + count;
- span->x = currRect.x();
- span->len = currRect.width();
- span->y = y;
- span->coverage = 255;
- ++count;
+ firstInBand = lastInBand + 1;
}
- ++y;
- }
- firstInBand = lastInBand + 1;
- }
+ Q_ASSERT(count <= allocated);
- Q_ASSERT(count <= allocated);
+ while (y < clipSpanHeight) {
+ m_clipLines[y].spans = 0;
+ m_clipLines[y].count = 0;
+ ++y;
+ }
- while (y < clipSpanHeight) {
- m_clipLines[y].spans = 0;
- m_clipLines[y].count = 0;
- ++y;
+ }
+ } QT_CATCH(...) {
+ free(m_spans);
+ QT_RETHROW;
}
-
+ } QT_CATCH(...) {
+ free(m_clipLines);
+ QT_RETHROW;
}
}
@@ -4773,8 +4780,10 @@ static void qt_span_clip(int count, const QSpan *spans, void *userData)
&newspans, newClip->allocated - newClip->count);
newClip->count = newspans - newClip->m_spans;
if (spans < end) {
+ QSpan *newSpan = (QSpan *)realloc(newClip->m_spans, newClip->allocated*2*sizeof(QSpan));
+ Q_CHECK_PTR(newSpan);
+ newClip->m_spans = newSpan;
newClip->allocated *= 2;
- newClip->m_spans = (QSpan *)realloc(newClip->m_spans, newClip->allocated*sizeof(QSpan));
}
}
}
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp
index 9cc9683..2e6d593 100644
--- a/src/gui/painting/qpaintengine_x11.cpp
+++ b/src/gui/painting/qpaintengine_x11.cpp
@@ -1826,9 +1826,10 @@ Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const Q
const int h = rect.height();
QImage im;
- if ((QSysInfo::ByteOrder == QSysInfo::BigEndian
- && ((ImageByteOrder(X11->display) == LSBFirst) || bgr_layout))
- || (ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian))
+ int image_byte_order = ImageByteOrder(X11->display);
+ if ((QSysInfo::ByteOrder == QSysInfo::BigEndian && ((image_byte_order == LSBFirst) || bgr_layout))
+ || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)
+ || (image_byte_order == LSBFirst && bgr_layout))
{
im = image.copy(rect);
const int iw = im.bytesPerLine() / 4;
@@ -1836,19 +1837,21 @@ Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const Q
for (int i=0; i < h; i++) {
uint *p = data;
uint *end = p + w;
- if (bgr_layout && ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
+ if (bgr_layout && image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
while (p < end) {
*p = ((*p << 8) & 0xffffff00) | ((*p >> 24) & 0x000000ff);
p++;
}
- } else if ((ImageByteOrder(X11->display) == LSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
- || (ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) {
+ } else if ((image_byte_order == LSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
+ || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) {
while (p < end) {
*p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
| ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);
p++;
}
- } else if (ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+ } else if ((image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
+ || (image_byte_order == LSBFirst && bgr_layout))
+ {
while (p < end) {
*p = ((*p << 16) & 0x00ff0000) | ((*p >> 16) & 0x000000ff)
| ((*p ) & 0xff00ff00);
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index cc48d24..0caf13b 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -83,6 +83,21 @@ static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
bool qt_show_painter_debug_output = true;
#endif
+class QPainterPrivateCleaner
+{
+public:
+ static inline void cleanup(QPainterPrivate *d)
+ {
+ delete d;
+ }
+
+ static inline void reset(QPainterPrivate *&d, QPainterPrivate *other)
+ {
+ delete d;
+ d = other;
+ }
+};
+
extern QPixmap qt_pixmapForBrush(int style, bool invert);
void qt_format_text(const QFont &font,
@@ -259,14 +274,17 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev)
// in 99% of all cases). E.g: A renders B which renders C which renders D.
sp->d_ptr->d_ptrs_size = 4;
sp->d_ptr->d_ptrs = (QPainterPrivate **)malloc(4 * sizeof(QPainterPrivate *));
+ Q_CHECK_PTR(sp->d_ptr->d_ptrs);
} else if (sp->d_ptr->refcount - 1 == sp->d_ptr->d_ptrs_size) {
// However, to support corner cases we grow the array dynamically if needed.
sp->d_ptr->d_ptrs_size <<= 1;
const int newSize = sp->d_ptr->d_ptrs_size * sizeof(QPainterPrivate *);
- sp->d_ptr->d_ptrs = (QPainterPrivate **)realloc(sp->d_ptr->d_ptrs, newSize);
+ QPainterPrivate ** newPointers = (QPainterPrivate **)realloc(sp->d_ptr->d_ptrs, newSize);
+ Q_CHECK_PTR(newPointers);
+ sp->d_ptr->d_ptrs = newPointers;
}
- sp->d_ptr->d_ptrs[++sp->d_ptr->refcount - 2] = q->d_ptr;
- q->d_ptr = sp->d_ptr;
+ sp->d_ptr->d_ptrs[++sp->d_ptr->refcount - 2] = q->d_ptr.data();
+ q->d_ptr.data_ptr() = sp->d_ptr.data();
Q_ASSERT(q->d_ptr->state);
@@ -315,7 +333,7 @@ void QPainterPrivate::detachPainterPrivate(QPainter *q)
d_ptrs[refcount - 1] = 0;
q->restore();
- q->d_ptr = original;
+ q->d_ptr.data_ptr() = original;
if (emulationEngine) {
extended = emulationEngine->real_engine;
@@ -1374,8 +1392,8 @@ void QPainterPrivate::updateState(QPainterState *newState)
*/
QPainter::QPainter()
+ : d_ptr(new QPainterPrivate(this))
{
- d_ptr = new QPainterPrivate(this);
}
/*!
@@ -1407,7 +1425,7 @@ QPainter::QPainter(QPaintDevice *pd)
{
Q_ASSERT(pd != 0);
if (!QPainterPrivate::attachPainterPrivate(this, pd)) {
- d_ptr = new QPainterPrivate(this);
+ d_ptr.reset(new QPainterPrivate(this));
begin(pd);
}
Q_ASSERT(d_ptr);
@@ -1419,11 +1437,14 @@ QPainter::QPainter(QPaintDevice *pd)
QPainter::~QPainter()
{
d_ptr->inDestructor = true;
- if (isActive())
- end();
- else if (d_ptr->refcount > 1)
- d_ptr->detachPainterPrivate(this);
-
+ QT_TRY {
+ if (isActive())
+ end();
+ else if (d_ptr->refcount > 1)
+ d_ptr->detachPainterPrivate(this);
+ } QT_CATCH(...) {
+ // don't throw anything in the destructor.
+ }
if (d_ptr) {
// Make sure we haven't messed things up.
Q_ASSERT(d_ptr->inDestructor);
@@ -1431,7 +1452,6 @@ QPainter::~QPainter()
Q_ASSERT(d_ptr->refcount == 1);
if (d_ptr->d_ptrs)
free(d_ptr->d_ptrs);
- delete d_ptr;
}
}
@@ -7417,8 +7437,21 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset)
void qt_painter_removePaintDevice(QPaintDevice *dev)
{
- QMutexLocker locker(globalRedirectionsMutex());
- if(QPaintDeviceRedirectionList *redirections = globalRedirections()) {
+ QMutex *mutex = 0;
+ QT_TRY {
+ mutex = globalRedirectionsMutex();
+ } QT_CATCH(...) {
+ // ignore the missing mutex, since we could be called from
+ // a destructor, and destructors shall not throw
+ }
+ QMutexLocker locker(mutex);
+ QPaintDeviceRedirectionList *redirections = 0;
+ QT_TRY {
+ redirections = globalRedirections();
+ } QT_CATCH(...) {
+ // do nothing - code below is safe with redirections being 0.
+ }
+ if (redirections) {
for (int i = 0; i < redirections->size(); ) {
if(redirections->at(i) == dev || redirections->at(i).replacement == dev)
redirections->removeAt(i);
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index f3df7a3..d8c6980 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -45,6 +45,7 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qrect.h>
#include <QtCore/qpoint.h>
+#include <QtCore/qscopedpointer.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qimage.h>
#include <QtGui/qtextoption.h>
@@ -78,6 +79,8 @@ class QTextItem;
class QMatrix;
class QTransform;
+class QPainterPrivateCleaner;
+
class Q_GUI_EXPORT QPainter
{
Q_DECLARE_PRIVATE(QPainter)
@@ -497,7 +500,7 @@ private:
Q_DISABLE_COPY(QPainter)
friend class Q3Painter;
- QPainterPrivate *d_ptr;
+ QScopedCustomPointer<QPainterPrivate, QPainterPrivateCleaner> d_ptr;
friend class QFontEngine;
friend class QFontEngineBox;
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index e1f5eea..635218e 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -73,6 +73,24 @@
QT_BEGIN_NAMESPACE
+struct QPainterPathPrivateHandler
+{
+ static inline void cleanup(QPainterPathPrivate *d)
+ {
+ // note - we must up-cast to QPainterPathData since QPainterPathPrivate
+ // has a non-virtual destructor!
+ if (d && !d->ref.deref())
+ delete static_cast<QPainterPathData *>(d);
+ }
+
+ static inline void reset(QPainterPathPrivate *&d, QPainterPathPrivate *other)
+ {
+ QPainterPathPrivate *oldD = d;
+ d = other;
+ cleanup(oldD);
+ }
+};
+
// This value is used to determine the length of control point vectors
// when approximating arc segments as curves. The factor is multiplied
// with the radius of the circle.
@@ -506,10 +524,10 @@ QPainterPath::QPainterPath()
\sa operator=()
*/
QPainterPath::QPainterPath(const QPainterPath &other)
- : d_ptr(other.d_ptr)
+ : d_ptr(other.d_ptr.data())
{
- if (d_func())
- d_func()->ref.ref();
+ if (d_ptr)
+ d_ptr->ref.ref();
}
/*!
@@ -530,9 +548,7 @@ QPainterPath::QPainterPath(const QPointF &startPoint)
void QPainterPath::detach_helper()
{
QPainterPathPrivate *data = new QPainterPathData(*d_func());
- if (d_ptr && !d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = data;
+ d_ptr.reset(data);
}
/*!
@@ -544,9 +560,7 @@ void QPainterPath::ensureData_helper()
data->elements.reserve(16);
QPainterPath::Element e = { 0, 0, QPainterPath::MoveToElement };
data->elements << e;
- if (d_ptr && !d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = data;
+ d_ptr.reset(data);
Q_ASSERT(d_ptr != 0);
}
@@ -563,9 +577,7 @@ QPainterPath &QPainterPath::operator=(const QPainterPath &other)
QPainterPathPrivate *data = other.d_func();
if (data)
data->ref.ref();
- if (d_ptr && !d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = data;
+ d_ptr.reset(data);
}
return *this;
}
@@ -575,8 +587,6 @@ QPainterPath &QPainterPath::operator=(const QPainterPath &other)
*/
QPainterPath::~QPainterPath()
{
- if (d_func() && !d_func()->ref.deref())
- delete d_func();
}
/*!
@@ -1006,7 +1016,7 @@ void QPainterPath::addPolygon(const QPolygonF &polygon)
/*!
\fn void QPainterPath::addEllipse(const QRectF &boundingRectangle)
- Creates an ellipse within the the specified \a boundingRectangle
+ Creates an ellipse within the specified \a boundingRectangle
and adds it to the painter path as a closed subpath.
The ellipse is composed of a clockwise curve, starting and
@@ -2408,7 +2418,6 @@ QPainterPathStroker::QPainterPathStroker()
*/
QPainterPathStroker::~QPainterPathStroker()
{
- delete d_ptr;
}
@@ -2695,7 +2704,7 @@ qreal QPainterPath::length() const
/*!
Returns percentage of the whole path at the specified length \a len.
- Note that similarly to other percent methods, the percentage measurment
+ Note that similarly to other percent methods, the percentage measurement
is not linear with regards to the length, if curves are present
in the path. When curves are present the percentage argument is mapped
to the t parameter of the Bezier equations.
@@ -2812,7 +2821,7 @@ static inline QBezier bezierAtT(const QPainterPath &path, qreal t, qreal *starti
Returns the point at at the percentage \a t of the current path.
The argument \a t has to be between 0 and 1.
- Note that similarly to other percent methods, the percentage measurment
+ Note that similarly to other percent methods, the percentage measurement
is not linear with regards to the length, if curves are present
in the path. When curves are present the percentage argument is mapped
to the t parameter of the Bezier equations.
@@ -2843,7 +2852,7 @@ QPointF QPainterPath::pointAtPercent(qreal t) const
Positive values for the angles mean counter-clockwise while negative values
mean the clockwise direction. Zero degrees is at the 3 o'clock position.
- Note that similarly to the other percent methods, the percentage measurment
+ Note that similarly to the other percent methods, the percentage measurement
is not linear with regards to the length if curves are present
in the path. When curves are present the percentage argument is mapped
to the t parameter of the Bezier equations.
@@ -2875,7 +2884,7 @@ qreal QPainterPath::angleAtPercent(qreal t) const
Returns the slope of the path at the percentage \a t. The
argument \a t has to be between 0 and 1.
- Note that similarly to other percent methods, the percentage measurment
+ Note that similarly to other percent methods, the percentage measurement
is not linear with regards to the length, if curves are present
in the path. When curves are present the percentage argument is mapped
to the t parameter of the Bezier equations.
diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h
index 6cd2af8..e12194e 100644
--- a/src/gui/painting/qpainterpath.h
+++ b/src/gui/painting/qpainterpath.h
@@ -47,6 +47,7 @@
#include <QtCore/qrect.h>
#include <QtCore/qline.h>
#include <QtCore/qvector.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -56,6 +57,7 @@ QT_MODULE(Gui)
class QFont;
class QPainterPathPrivate;
+struct QPainterPathPrivateHandler;
class QPainterPathData;
class QPainterPathStrokerPrivate;
class QPolygonF;
@@ -195,7 +197,7 @@ public:
QPainterPath &operator-=(const QPainterPath &other);
private:
- QPainterPathPrivate *d_ptr;
+ QScopedCustomPointer<QPainterPathPrivate, QPainterPathPrivateHandler> d_ptr;
inline void ensureData() { if (!d_ptr) ensureData_helper(); }
void ensureData_helper();
@@ -205,7 +207,7 @@ private:
void computeBoundingRect() const;
void computeControlPointRect() const;
- QPainterPathData *d_func() const { return reinterpret_cast<QPainterPathData *>(d_ptr); }
+ QPainterPathData *d_func() const { return reinterpret_cast<QPainterPathData *>(d_ptr.data()); }
friend class QPainterPathData;
friend class QPainterPathStroker;
@@ -229,6 +231,7 @@ public:
friend class QPainterPathStrokerPrivate;
friend class QMatrix;
friend class QTransform;
+ friend struct QPainterPathPrivateHandler;
#ifndef QT_NO_DATASTREAM
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &);
@@ -279,7 +282,7 @@ public:
private:
friend class QX11PaintEngine;
- QPainterPathStrokerPrivate *d_ptr;
+ QScopedPointer<QPainterPathStrokerPrivate> d_ptr;
};
inline void QPainterPath::moveTo(qreal x, qreal y)
diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp
index 5090b3a..ba6baa6 100644
--- a/src/gui/painting/qprinter.cpp
+++ b/src/gui/painting/qprinter.cpp
@@ -480,26 +480,26 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke
\value A7 74 x 105 mm
\value A8 52 x 74 mm
\value A9 37 x 52 mm
- \value B0 1030 x 1456 mm
- \value B1 728 x 1030 mm
- \value B10 32 x 45 mm
- \value B2 515 x 728 mm
- \value B3 364 x 515 mm
- \value B4 257 x 364 mm
- \value B5 182 x 257 mm, 7.17 x 10.13 inches
- \value B6 128 x 182 mm
- \value B7 91 x 128 mm
- \value B8 64 x 91 mm
- \value B9 45 x 64 mm
+ \value B0 1000 x 1414 mm
+ \value B1 707 x 1000 mm
+ \value B2 500 x 707 mm
+ \value B3 353 x 500 mm
+ \value B4 250 x 353 mm
+ \value B5 176 x 250 mm, 6.93 x 9.84 inches
+ \value B6 125 x 176 mm
+ \value B7 88 x 125 mm
+ \value B8 62 x 88 mm
+ \value B9 33 x 62 mm
+ \value B10 31 x 44 mm
\value C5E 163 x 229 mm
\value Comm10E 105 x 241 mm, U.S. Common 10 Envelope
\value DLE 110 x 220 mm
- \value Executive 7.5 x 10 inches, 191 x 254 mm
+ \value Executive 7.5 x 10 inches, 190.5 x 254 mm
\value Folio 210 x 330 mm
- \value Ledger 432 x 279 mm
- \value Legal 8.5 x 14 inches, 216 x 356 mm
- \value Letter 8.5 x 11 inches, 216 x 279 mm
- \value Tabloid 279 x 432 mm
+ \value Ledger 431.8 x 279.4 mm
+ \value Legal 8.5 x 14 inches, 215.9 x 355.6 mm
+ \value Letter 8.5 x 11 inches, 215.9 x 279.4 mm
+ \value Tabloid 279.4 x 431.8 mm
\value Custom Unknown, or a user defined size.
With setFullPage(false) (the default), the metrics will be a bit
@@ -712,7 +712,6 @@ QPrinter::~QPrinter()
#ifndef QT_NO_PRINTPREVIEWWIDGET
delete d->previewEngine;
#endif
- delete d;
}
/*!
diff --git a/src/gui/painting/qprinter.h b/src/gui/painting/qprinter.h
index 949c8f9..24e867b 100644
--- a/src/gui/painting/qprinter.h
+++ b/src/gui/painting/qprinter.h
@@ -42,8 +42,9 @@
#ifndef QPRINTER_H
#define QPRINTER_H
-#include <QtGui/qpaintdevice.h>
#include <QtCore/qstring.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtGui/qpaintdevice.h>
QT_BEGIN_HEADER
@@ -288,7 +289,7 @@ private:
Q_DISABLE_COPY(QPrinter)
- QPrinterPrivate *d_ptr;
+ QScopedPointer<QPrinterPrivate> d_ptr;
friend class QPrintDialogPrivate;
friend class QAbstractPrintDialog;
diff --git a/src/gui/painting/qprinterinfo.h b/src/gui/painting/qprinterinfo.h
index b826306..d188d73 100644
--- a/src/gui/painting/qprinterinfo.h
+++ b/src/gui/painting/qprinterinfo.h
@@ -53,6 +53,7 @@ QT_MODULE(Gui)
#ifndef QT_NO_PRINTER
class QPrinterInfoPrivate;
+class QPrinterInfoPrivateCleanup;
class Q_GUI_EXPORT QPrinterInfo
{
Q_DECLARE_PRIVATE(QPrinterInfo)
@@ -76,7 +77,7 @@ public:
private:
QPrinterInfo(const QString& name);
- QPrinterInfoPrivate* d_ptr;
+ QScopedCustomPointer<QPrinterInfoPrivate, QPrinterInfoPrivateCleanup> d_ptr;
};
#endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp
index ecd4b5b..ae689f4 100644
--- a/src/gui/painting/qprinterinfo_mac.cpp
+++ b/src/gui/painting/qprinterinfo_mac.cpp
@@ -65,6 +65,22 @@ private:
static QPrinterInfoPrivate nullQPrinterInfoPrivate;
+class QPrinterInfoPrivateCleanup
+{
+public:
+ static inline void cleanup(QPrinterInfoPrivate *d)
+ {
+ if (d != &nullQPrinterInfoPrivate)
+ delete d;
+ }
+
+ static inline void reset(QPrinterInfoPrivate *&d, QPrinterInfoPrivate *other)
+ {
+ cleanup(d);
+ d = other;
+ }
+};
+
extern QPrinter::PaperSize qSizeFTopaperSize(const QSizeF& size);
/////////////////////////////////////////////////////////////////////////////
@@ -106,8 +122,8 @@ QPrinterInfo QPrinterInfo::defaultPrinter(){
/////////////////////////////////////////////////////////////////////////////
QPrinterInfo::QPrinterInfo(const QPrinter& prn)
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
QList<QPrinterInfo> list = availablePrinters();
for (int c = 0; c < list.size(); ++c) {
if (prn.printerName() == list[c].printerName()) {
@@ -115,39 +131,33 @@ QPrinterInfo::QPrinterInfo(const QPrinter& prn)
return;
}
}
-
- *this = QPrinterInfo();
}
QPrinterInfo::~QPrinterInfo()
{
- if (d_ptr != &nullQPrinterInfoPrivate)
- delete d_ptr;
}
QPrinterInfo::QPrinterInfo()
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
}
QPrinterInfo::QPrinterInfo(const QString& name)
+ : d_ptr(new QPrinterInfoPrivate(name))
{
- d_ptr = new QPrinterInfoPrivate(name);
d_ptr->q_ptr = this;
}
QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
*this = src;
}
QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
{
Q_ASSERT(d_ptr);
- if (d_ptr != &nullQPrinterInfoPrivate)
- delete d_ptr;
- d_ptr = new QPrinterInfoPrivate(*src.d_ptr);
+ d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
d_ptr->q_ptr = this;
return *this;
}
diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp
index 0f33ea7..55e3226 100644
--- a/src/gui/painting/qprinterinfo_unix.cpp
+++ b/src/gui/painting/qprinterinfo_unix.cpp
@@ -82,6 +82,22 @@ private:
static QPrinterInfoPrivate nullQPrinterInfoPrivate;
+class QPrinterInfoPrivateCleanup
+{
+public:
+ static inline void cleanup(QPrinterInfoPrivate *d)
+ {
+ if (d != &nullQPrinterInfoPrivate)
+ delete d;
+ }
+
+ static inline void reset(QPrinterInfoPrivate *&d, QPrinterInfoPrivate *other)
+ {
+ cleanup(d);
+ d = other;
+ }
+};
+
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
@@ -867,19 +883,19 @@ QPrinterInfo QPrinterInfo::defaultPrinter()
}
QPrinterInfo::QPrinterInfo()
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
}
QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
*this = src;
}
QPrinterInfo::QPrinterInfo(const QPrinter& printer)
+ : d_ptr(new QPrinterInfoPrivate(printer.printerName()))
{
- d_ptr = new QPrinterInfoPrivate(printer.printerName());
Q_D(QPrinterInfo);
d->q_ptr = this;
@@ -929,28 +945,23 @@ QPrinterInfo::QPrinterInfo(const QPrinter& printer)
#endif
// Printer not found.
- delete d;
- d_ptr = &nullQPrinterInfoPrivate;
+ d_ptr.reset(&nullQPrinterInfoPrivate);
}
QPrinterInfo::QPrinterInfo(const QString& name)
+ : d_ptr(new QPrinterInfoPrivate(name))
{
- d_ptr = new QPrinterInfoPrivate(name);
d_ptr->q_ptr = this;
}
QPrinterInfo::~QPrinterInfo()
{
- if (d_ptr != &nullQPrinterInfoPrivate)
- delete d_ptr;
}
QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
{
Q_ASSERT(d_ptr);
- if (d_ptr != &nullQPrinterInfoPrivate)
- delete d_ptr;
- d_ptr = new QPrinterInfoPrivate(*src.d_ptr);
+ d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
d_ptr->q_ptr = this;
return *this;
}
diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp
index 7cd3cf3..7607391 100644
--- a/src/gui/painting/qprinterinfo_win.cpp
+++ b/src/gui/painting/qprinterinfo_win.cpp
@@ -69,6 +69,22 @@ private:
static QPrinterInfoPrivate nullQPrinterInfoPrivate;
+class QPrinterInfoPrivateCleanup
+{
+public:
+ static inline void cleanup(QPrinterInfoPrivate *d)
+ {
+ if (d != &nullQPrinterInfoPrivate)
+ delete d;
+ }
+
+ static inline void reset(QPrinterInfoPrivate *&d, QPrinterInfoPrivate *other)
+ {
+ cleanup(d);
+ d = other;
+ }
+};
+
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
@@ -155,25 +171,25 @@ QPrinterInfo QPrinterInfo::defaultPrinter()
/////////////////////////////////////////////////////////////////////////////
QPrinterInfo::QPrinterInfo()
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
}
QPrinterInfo::QPrinterInfo(const QString& name)
+ : d_ptr(new QPrinterInfoPrivate(name))
{
- d_ptr = new QPrinterInfoPrivate(name);
d_ptr->q_ptr = this;
}
QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
*this = src;
}
QPrinterInfo::QPrinterInfo(const QPrinter& prn)
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
QList<QPrinterInfo> list = availablePrinters();
for (int c = 0; c < list.size(); ++c) {
if (prn.printerName() == list[c].printerName()) {
@@ -187,16 +203,12 @@ QPrinterInfo::QPrinterInfo(const QPrinter& prn)
QPrinterInfo::~QPrinterInfo()
{
- if (d_ptr != &nullQPrinterInfoPrivate)
- delete d_ptr;
}
QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
{
Q_ASSERT(d_ptr);
- if (d_ptr != &nullQPrinterInfoPrivate)
- delete d_ptr;
- d_ptr = new QPrinterInfoPrivate(*src.d_ptr);
+ d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
d_ptr->q_ptr = this;
return *this;
}
diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp
index 583885c..3c06bb4 100644
--- a/src/gui/painting/qrasterizer.cpp
+++ b/src/gui/painting/qrasterizer.cpp
@@ -436,8 +436,11 @@ void QScanConverter::end()
inline void QScanConverter::allocate(int size)
{
if (m_alloc < size) {
- m_alloc = qMax(size, 2 * m_alloc);
- m_intersections = (Intersection *)realloc(m_intersections, m_alloc * sizeof(Intersection));
+ int newAlloc = qMax(size, 2 * m_alloc);
+ Intersection *newIntersections = (Intersection *)realloc(m_intersections, newAlloc * sizeof(Intersection));
+ Q_CHECK_PTR(newIntersections);
+ m_alloc = newAlloc;
+ m_intersections = newIntersections;
}
}
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index c88af7c..65964de 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -3167,6 +3167,7 @@ static void InsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, int scanline,
{
tmpSLLBlock =
(ScanLineListBlock *)malloc(sizeof(ScanLineListBlock));
+ Q_CHECK_PTR(tmpSLLBlock);
(*SLLBlock)->next = tmpSLLBlock;
tmpSLLBlock->next = (ScanLineListBlock *)NULL;
*SLLBlock = tmpSLLBlock;
@@ -3553,6 +3554,8 @@ static void PtsToRegion(register int numFullPtBlocks, register int iCurPtBlock,
* Scan converts a polygon by returning a run-length
* encoding of the resultant bitmap -- the run-length
* encoding is in the form of an array of rectangles.
+ *
+ * Can return 0 in case of errors.
*/
static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule)
//Point *Pts; /* the pts */
@@ -3624,75 +3627,28 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule)
}
- if (rule == EvenOddRule) {
- /*
- * for each scanline
- */
- for (y = ET.ymin; y < ET.ymax; ++y) {
-
- /*
- * Add a new edge to the active edge table when we
- * get to the next edge.
- */
- if (pSLL && y == pSLL->scanline) {
- loadAET(&AET, pSLL->edgelist);
- pSLL = pSLL->next;
- }
- pPrevAET = &AET;
- pAET = AET.next;
-
+ QT_TRY {
+ if (rule == EvenOddRule) {
/*
- * for each active edge
+ * for each scanline
*/
- while (pAET) {
- pts->setX(pAET->bres.minor_axis);
- pts->setY(y);
- ++pts;
- ++iPts;
+ for (y = ET.ymin; y < ET.ymax; ++y) {
/*
- * send out the buffer
+ * Add a new edge to the active edge table when we
+ * get to the next edge.
*/
- if (iPts == NUMPTSTOBUFFER) {
- tmpPtBlock = (POINTBLOCK *)malloc(sizeof(POINTBLOCK));
- tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data);
- curPtBlock->next = tmpPtBlock;
- curPtBlock = tmpPtBlock;
- pts = curPtBlock->pts;
- ++numFullPtBlocks;
- iPts = 0;
+ if (pSLL && y == pSLL->scanline) {
+ loadAET(&AET, pSLL->edgelist);
+ pSLL = pSLL->next;
}
- EVALUATEEDGEEVENODD(pAET, pPrevAET, y)
- }
- InsertionSort(&AET);
- }
- } else {
- /*
- * for each scanline
- */
- for (y = ET.ymin; y < ET.ymax; ++y) {
- /*
- * Add a new edge to the active edge table when we
- * get to the next edge.
- */
- if (pSLL && y == pSLL->scanline) {
- loadAET(&AET, pSLL->edgelist);
- computeWAET(&AET);
- pSLL = pSLL->next;
- }
- pPrevAET = &AET;
- pAET = AET.next;
- pWETE = pAET;
+ pPrevAET = &AET;
+ pAET = AET.next;
- /*
- * for each active edge
- */
- while (pAET) {
/*
- * add to the buffer only those edges that
- * are in the Winding active edge table.
+ * for each active edge
*/
- if (pWETE == pAET) {
+ while (pAET) {
pts->setX(pAET->bres.minor_axis);
pts->setY(y);
++pts;
@@ -3702,7 +3658,8 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule)
* send out the buffer
*/
if (iPts == NUMPTSTOBUFFER) {
- tmpPtBlock = static_cast<POINTBLOCK *>(malloc(sizeof(POINTBLOCK)));
+ tmpPtBlock = (POINTBLOCK *)malloc(sizeof(POINTBLOCK));
+ Q_CHECK_PTR(tmpPtBlock);
tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data);
curPtBlock->next = tmpPtBlock;
curPtBlock = tmpPtBlock;
@@ -3710,21 +3667,81 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule)
++numFullPtBlocks;
iPts = 0;
}
- pWETE = pWETE->nextWETE;
+ EVALUATEEDGEEVENODD(pAET, pPrevAET, y)
}
- EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET)
+ InsertionSort(&AET);
}
-
+ } else {
/*
- * recompute the winding active edge table if
- * we just resorted or have exited an edge.
+ * for each scanline
*/
- if (InsertionSort(&AET) || fixWAET) {
- computeWAET(&AET);
- fixWAET = false;
+ for (y = ET.ymin; y < ET.ymax; ++y) {
+ /*
+ * Add a new edge to the active edge table when we
+ * get to the next edge.
+ */
+ if (pSLL && y == pSLL->scanline) {
+ loadAET(&AET, pSLL->edgelist);
+ computeWAET(&AET);
+ pSLL = pSLL->next;
+ }
+ pPrevAET = &AET;
+ pAET = AET.next;
+ pWETE = pAET;
+
+ /*
+ * for each active edge
+ */
+ while (pAET) {
+ /*
+ * add to the buffer only those edges that
+ * are in the Winding active edge table.
+ */
+ if (pWETE == pAET) {
+ pts->setX(pAET->bres.minor_axis);
+ pts->setY(y);
+ ++pts;
+ ++iPts;
+
+ /*
+ * send out the buffer
+ */
+ if (iPts == NUMPTSTOBUFFER) {
+ tmpPtBlock = static_cast<POINTBLOCK *>(malloc(sizeof(POINTBLOCK)));
+ tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data);
+ curPtBlock->next = tmpPtBlock;
+ curPtBlock = tmpPtBlock;
+ pts = curPtBlock->pts;
+ ++numFullPtBlocks;
+ iPts = 0;
+ }
+ pWETE = pWETE->nextWETE;
+ }
+ EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET)
+ }
+
+ /*
+ * recompute the winding active edge table if
+ * we just resorted or have exited an edge.
+ */
+ if (InsertionSort(&AET) || fixWAET) {
+ computeWAET(&AET);
+ fixWAET = false;
+ }
}
}
+ } QT_CATCH(...) {
+ FreeStorage(SLLBlock.next);
+ PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
+ for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
+ tmpPtBlock = curPtBlock->next;
+ free(curPtBlock);
+ curPtBlock = tmpPtBlock;
+ }
+ free(pETEs);
+ return 0; // this function returns 0 in case of an error
}
+
FreeStorage(SLLBlock.next);
PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
@@ -3923,11 +3940,10 @@ QRegion &QRegion::operator=(const QRegion &r)
/*!
\internal
*/
-
QRegion QRegion::copy() const
{
QRegion r;
- QRegionData *x = new QRegionData;
+ QScopedPointer<QRegionData> x(new QRegionData);
x->ref = 1;
#if defined(Q_WS_X11)
x->rgn = 0;
@@ -3941,7 +3957,7 @@ QRegion QRegion::copy() const
x->qt_rgn = new QRegionPrivate;
if (!r.d->ref.deref())
cleanUp(r.d);
- r.d = x;
+ r.d = x.take();
return r;
}
diff --git a/src/gui/painting/qregion_s60.cpp b/src/gui/painting/qregion_s60.cpp
index 4504118..4d96910 100644
--- a/src/gui/painting/qregion_s60.cpp
+++ b/src/gui/painting/qregion_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index 3fd1ffb..89df869 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -92,8 +92,8 @@ void QTextureGlyphCache::populate(const QTextItemInt &ti,
int glyph_height = metrics.height.ceil().toInt();
if (glyph_height == 0 || glyph_width == 0)
continue;
- glyph_width += margin * 2 + 2;
- glyph_height += margin * 2 + 2;
+ glyph_width += margin * 2 + 4;
+ glyph_height += margin * 2 + 4;
// align to 8-bit boundary
if (m_type == QFontEngineGlyphCache::Raster_Mono)
glyph_width = (glyph_width+7)&~7;
@@ -189,7 +189,11 @@ void QImageTextureGlyphCache::createTextureData(int width, int height)
int QImageTextureGlyphCache::glyphMargin() const
{
+#ifdef Q_WS_MAC
return 2;
+#else
+ return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0;
+#endif
}
void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g)
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp
index 110ba2f..97178a6 100644
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ b/src/gui/painting/qwindowsurface_raster.cpp
@@ -115,8 +115,6 @@ QRasterWindowSurface::~QRasterWindowSurface()
#endif
if (d_ptr->image)
delete d_ptr->image;
-
- delete d_ptr;
}
@@ -229,7 +227,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
{
const QImage &src = d->image->image;
br = br.intersected(src.rect());
- if (src.format() != QImage::Format_RGB32) {
+ if (src.format() != QImage::Format_RGB32 || widget->x11Info().depth() < 24) {
QX11PixmapData *data = new QX11PixmapData(QPixmapData::PixmapType);
data->xinfo = widget->x11Info();
data->fromImage(src, Qt::AutoColor);
diff --git a/src/gui/painting/qwindowsurface_raster_p.h b/src/gui/painting/qwindowsurface_raster_p.h
index 2a3535f..c10bec3 100644
--- a/src/gui/painting/qwindowsurface_raster_p.h
+++ b/src/gui/painting/qwindowsurface_raster_p.h
@@ -112,7 +112,7 @@ public:
private:
void prepareBuffer(QImage::Format format, QWidget *widget);
Q_DECLARE_PRIVATE(QRasterWindowSurface)
- QRasterWindowSurfacePrivate *d_ptr;
+ QScopedPointer<QRasterWindowSurfacePrivate> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp
index 2618ce2..2a20b44 100644
--- a/src/gui/painting/qwindowsurface_s60.cpp
+++ b/src/gui/painting/qwindowsurface_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
diff --git a/src/gui/painting/qwindowsurface_s60_p.h b/src/gui/painting/qwindowsurface_s60_p.h
index 7b70fd5..40a866d 100644
--- a/src/gui/painting/qwindowsurface_s60_p.h
+++ b/src/gui/painting/qwindowsurface_s60_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp
index 0842ec7..d8a67c2 100644
--- a/src/gui/styles/gtksymbols.cpp
+++ b/src/gui/styles/gtksymbols.cpp
@@ -633,31 +633,14 @@ GtkStyle* QGtk::gtkStyle(const QString &path)
return 0;
}
-#ifdef Q_OS_LINUX
-QT_END_NAMESPACE
-
-int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
-int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
-
-QT_BEGIN_NAMESPACE
-#endif
-
void QGtk::initGtkWidgets()
{
// From gtkmain.c
-
- uid_t ruid, rgid, euid, egid, suid, sgid;
-
-#ifdef Q_OS_LINUX
- if (getresuid (&ruid, &euid, &suid) != 0 || getresgid (&rgid, &egid, &sgid) != 0)
-#endif
- {
- suid = ruid = getuid ();
- sgid = rgid = getgid ();
- euid = geteuid ();
- egid = getegid ();
- }
- if (ruid != euid || ruid != suid || rgid != egid || rgid != sgid) {
+ uid_t ruid = getuid ();
+ uid_t rgid = getgid ();
+ uid_t euid = geteuid ();
+ uid_t egid = getegid ();
+ if (ruid != euid || rgid != egid) {
qWarning("\nThis process is currently running setuid or setgid.\nGTK+ does not allow this "
"therefore Qt cannot use the GTK+ integration.\nTry launching your app using \'gksudo\', "
"\'kdesudo\' or a similar tool.\n\n"
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 3cae08a..f3d1537 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -1693,7 +1693,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
pr.setHeight(pmSize.height() + 6);
- tr.adjust(0, pr.height(), 0, -3);
+ tr.adjust(0, pr.height() - 1, 0, -3);
pr.translate(shiftX, shiftY);
if (!hasArrow) {
drawItemPixmap(p, pr, Qt::AlignCenter, pm);
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index ca71da2..0e54af8 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -140,10 +140,7 @@ static const char * const dock_widget_restore_xpm[] =
class QGtkStyleFilter : public QObject
{
public:
- QGtkStyleFilter() {
- qApp->installEventFilter(this);
- }
-
+ QGtkStyleFilter() {}
private:
bool eventFilter(QObject *obj, QEvent *e);
};
@@ -167,7 +164,12 @@ class QGtkStylePrivate : public QCleanlooksStylePrivate
public:
QGtkStylePrivate()
: QCleanlooksStylePrivate()
- {}
+ {
+ QGtk::initGtkWidgets();
+ if (QGtk::isThemeAvailable())
+ qApp->installEventFilter(&filter);
+
+ }
QGtkStyleFilter filter;
};
@@ -243,7 +245,6 @@ static QString uniqueName(const QString &key, const QStyleOption *option, const
QGtkStyle::QGtkStyle()
: QCleanlooksStyle(*new QGtkStylePrivate)
{
- QGtk::initGtkWidgets();
}
/*!
@@ -939,10 +940,6 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_FrameLineEdit: {
GtkWidget *gtkEntry = QGtk::gtkWidget(QLS("GtkEntry"));
- if (option->state & State_HasFocus)
- GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
- else
- GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
gboolean interior_focus;
gint focus_line_width;
@@ -956,6 +953,9 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
if (!interior_focus && option->state & State_HasFocus)
rect.adjust(focus_line_width, focus_line_width, -focus_line_width, -focus_line_width);
+
+ if (option->state & State_HasFocus)
+ GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
gtkPainter.paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ?
GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
GTK_SHADOW_IN, gtkEntry->style,
@@ -964,6 +964,9 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
gtkPainter.paintShadow(gtkEntry, "entry", option->rect, option->state & State_Enabled ?
GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
GTK_SHADOW_IN, gtkEntry->style, QLS("GtkEntryShadowIn"));
+
+ if (option->state & State_HasFocus)
+ GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
}
break;
@@ -1049,17 +1052,13 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
gtkPainter.paintBox(gtkButton, "buttondefault", buttonRect, state, GTK_SHADOW_IN,
style, isDefault ? QLS("d") : QString());
- } else
- GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
+ }
bool hasFocus = option->state & State_HasFocus;
if (hasFocus) {
key += QLS("def");
GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_FOCUS);
-
- } else {
- GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_FOCUS);
}
if (!interiorFocus)
@@ -1070,6 +1069,10 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
gtkPainter.paintBox(gtkButton, "button", buttonRect, state, shadow,
style, key);
+ if (isDefault)
+ GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
+ if (hasFocus)
+ GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_FOCUS);
}
break;
@@ -1333,6 +1336,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
GtkWidget *gtkToggleButton = QGtk::gtkWidget(buttonPath);
QGtk::gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
if (gtkToggleButton && (appears_as_list || comboBox->editable)) {
+ if (focus)
+ GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
// Draw the combo box as a line edit with a button next to it
if (comboBox->editable || appears_as_list) {
GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state;
@@ -1346,22 +1351,16 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
else
frameRect.setRight(arrowButtonRect.left());
- // Required for inner blue highlight with clearlooks
- if (focus) {
- GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
- GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
-
- } else {
- GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
- GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
- }
-
// Fill the line edit background
// We could have used flat_box with "entry_bg" but that is probably not worth the overhead
uint resolve_mask = option->palette.resolve();
int xt = gtkEntry->style->xthickness;
int yt = gtkEntry->style->ythickness;
QRect contentRect = frameRect.adjusted(xt, yt, -xt, -yt);
+ // Required for inner blue highlight with clearlooks
+ if (focus)
+ GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
+
if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
p->fillRect(contentRect, option->palette.base().color());
@@ -1375,6 +1374,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
GTK_SHADOW_IN, gtkEntry->style, entryPath +
QString::number(focus) + QString::number(comboBox->editable) +
QString::number(option->direction));
+ if (focus)
+ GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
}
GtkStateType buttonState = GTK_STATE_NORMAL;
@@ -1393,22 +1394,21 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
gtkCachedPainter.paintBox( gtkToggleButton, "button", arrowButtonRect, buttonState,
shadow, gtkToggleButton->style, buttonPath +
QString::number(focus) + QString::number(option->direction));
-
+ if (focus)
+ GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
} else {
// Draw combo box as a button
QRect buttonRect = option->rect;
- if (focus) { // Clearlooks actually check the widget for the default state
+ if (focus) // Clearlooks actually check the widget for the default state
GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
-
- } else {
- GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
- }
-
gtkCachedPainter.paintBox(gtkToggleButton, "button",
buttonRect, state,
shadow, gtkToggleButton->style,
buttonPath + QString::number(focus));
+ if (focus)
+ GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
+
// Draw the separator between label and arrows
QString vSeparatorPath = buttonPath + QLS(".GtkHBox.GtkVSeparator");
@@ -1774,15 +1774,12 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
shadow = GTK_SHADOW_IN;
style = gtkPainter.getStyle(gtkSpinButton);
- if (option->state & State_HasFocus)
- GTK_WIDGET_SET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
- else
- GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
QString key;
-
- if (option->state & State_HasFocus)
+ if (option->state & State_HasFocus) {
key = QLS("f");
+ GTK_WIDGET_SET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
+ }
uint resolve_mask = option->palette.resolve();
@@ -1815,6 +1812,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
else
gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
+
+ if (option->state & State_HasFocus)
+ GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
}
if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) {
@@ -2343,7 +2343,7 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_SizeGrip: {
GtkWidget *gtkStatusbar = QGtk::gtkWidget(QLS("GtkStatusbar.GtkFrame"));
QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbar->style->xthickness, -gtkStatusbar->style->ythickness);
- gtkPainter.paintResizeGrip( gtkStatusbar, "window", gripRect, GTK_STATE_NORMAL,
+ gtkPainter.paintResizeGrip( gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
GTK_SHADOW_OUT, QApplication::isRightToLeft() ?
GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST,
gtkStatusbar->style);
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index 7a870fe..1be3d6e 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -39,6 +39,11 @@
**
****************************************************************************/
+/*
+ Note: The qdoc comments for QMacStyle are contained in
+ .../doc/src/qstyles.qdoc.
+*/
+
#include "qmacstyle_mac.h"
#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
@@ -1988,87 +1993,12 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD
p->drawPixmap(int(macRect.origin.x), int(macRect.origin.y) + finalyoff, width, height, pm);
}
-/*!
- \class QMacStyle
- \brief The QMacStyle class provides a Mac OS X style using the Apple Appearance Manager.
-
- \ingroup appearance
-
- This class is implemented as a wrapper to the HITheme
- APIs, allowing applications to be styled according to the current
- theme in use on Mac OS X. This is done by having primitives
- in QStyle implemented in terms of what Mac OS X would normally theme.
-
- \warning This style is only available on Mac OS X because it relies on the
- HITheme APIs.
-
- There are additional issues that should be taken
- into consideration to make an application compatible with the
- \link http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html
- Apple Human Interface Guidelines \endlink. Some of these issues are outlined
- below.
-
- \list
-
- \i Layout - The restrictions on window layout are such that some
- aspects of layout that are style-dependent cannot be achieved
- using QLayout. Changes are being considered (and feedback would be
- appreciated) to make layouts QStyle-able. Some of the restrictions
- involve horizontal and vertical widget alignment and widget size
- (covered below).
-
- \i Widget size - Mac OS X allows widgets to have specific fixed sizes. Qt
- does not fully implement this behavior so as to maintain cross-platform
- compatibility. As a result some widgets sizes may be inappropriate (and
- subsequently not rendered correctly by the HITheme APIs).The
- QWidget::sizeHint() will return the appropriate size for many
- managed widgets (widgets enumerated in \l QStyle::ContentsType).
-
- \i Effects - QMacStyle uses HITheme for performing most of the drawing, but
- also uses emulation in a few cases where HITheme does not provide the
- required functionality (for example, tab bars on Panther, the toolbar
- separator, etc). We tried to make the emulation as close to the original as
- possible. Please report any issues you see in effects or non-standard
- widgets.
-
- \endlist
-
- There are other issues that need to be considered in the feel of
- your application (including the general color scheme to match the
- Aqua colors). The Guidelines mentioned above will remain current
- with new advances and design suggestions for Mac OS X.
-
- Note that the functions provided by QMacStyle are
- reimplementations of QStyle functions; see QStyle for their
- documentation.
-
- \img qmacstyle.png
- \sa QWindowsXPStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle
-*/
-
-
-/*!
- \enum QMacStyle::WidgetSizePolicy
-
- \value SizeSmall
- \value SizeLarge
- \value SizeMini
- \value SizeDefault
- \omitvalue SizeNone
-*/
-
-/*!
- Constructs a QMacStyle object.
-*/
QMacStyle::QMacStyle()
: QWindowsStyle()
{
d = new QMacStylePrivate(this);
}
-/*!
- Destructs a QMacStyle object.
-*/
QMacStyle::~QMacStyle()
{
delete qt_mac_backgroundPattern;
@@ -2142,7 +2072,6 @@ void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint
}
}
-/*! \reimp */
void QMacStyle::polish(QPalette &pal)
{
if (!qt_mac_backgroundPattern) {
@@ -2166,17 +2095,14 @@ void QMacStyle::polish(QPalette &pal)
}
}
-/*! \reimp */
void QMacStyle::polish(QApplication *)
{
}
-/*! \reimp */
void QMacStyle::unpolish(QApplication *)
{
}
-/*! \reimp */
void QMacStyle::polish(QWidget* w)
{
d->addWidget(w);
@@ -2240,7 +2166,6 @@ void QMacStyle::polish(QWidget* w)
}
}
-/*! \reimp */
void QMacStyle::unpolish(QWidget* w)
{
d->removeWidget(w);
@@ -2271,7 +2196,6 @@ void QMacStyle::unpolish(QWidget* w)
QWindowsStyle::unpolish(w);
}
-/*! \reimp */
int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *widget) const
{
int controlSize = getControlSize(opt, widget);
@@ -2650,7 +2574,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
return ret;
}
-/*! \reimp */
QPalette QMacStyle::standardPalette() const
{
QPalette pal = QWindowsStyle::standardPalette();
@@ -2660,7 +2583,6 @@ QPalette QMacStyle::standardPalette() const
return pal;
}
-/*! \reimp */
int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w,
QStyleHintReturn *hret) const
{
@@ -2955,7 +2877,6 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
return ret;
}
-/*! \reimp */
QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
const QStyleOption *opt) const
{
@@ -2981,7 +2902,6 @@ QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixm
}
-/*! \reimp */
QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
const QWidget *widget) const
{
@@ -3012,31 +2932,7 @@ QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOpt
}
return icon.pixmap(size, size);
}
-/*!
- \enum QMacStyle::FocusRectPolicy
-
- This type is used to signify a widget's focus rectangle policy.
-
- \value FocusEnabled show a focus rectangle when the widget has focus.
- \value FocusDisabled never show a focus rectangle for the widget.
- \value FocusDefault show a focus rectangle when the widget has
- focus and the widget is a QSpinWidget, QDateTimeEdit, QLineEdit,
- QListBox, QListView, editable QTextEdit, or one of their
- subclasses.
-*/
-
-/*!
- \obsolete
- Sets the focus rectangle policy of \a w. The \a policy can be one of
- \l{QMacStyle::FocusRectPolicy}.
-
- This is now simply an interface to the Qt::WA_MacShowFocusRect attribute and the
- FocusDefault value does nothing anymore. If you want to set a widget back
- to its default value, you must save the old value of the attribute before
- you change it.
- \sa focusRectPolicy() QWidget::setAttribute()
-*/
void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy)
{
switch (policy) {
@@ -3049,29 +2945,11 @@ void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy)
}
}
-/*!
- \obsolete
- Returns the focus rectangle policy for the widget \a w.
-
- The focus rectangle policy can be one of \l{QMacStyle::FocusRectPolicy}.
-
- In 4.3 and up this function will simply test for the
- Qt::WA_MacShowFocusRect attribute and will never return
- QMacStyle::FocusDefault.
-
- \sa setFocusRectPolicy(), QWidget::testAttribute()
-*/
QMacStyle::FocusRectPolicy QMacStyle::focusRectPolicy(const QWidget *w)
{
return w->testAttribute(Qt::WA_MacShowFocusRect) ? FocusEnabled : FocusDisabled;
}
-/*!
- \obsolete
-
- Call QWidget::setAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize,
- or Qt::WA_MacNormalSize instead.
-*/
void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy policy)
{
QWidget *wadget = const_cast<QWidget *>(widget);
@@ -3080,12 +2958,6 @@ void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy poli
wadget->setAttribute(Qt::WA_MacMiniSize, policy == SizeMini);
}
-/*!
- \obsolete
-
- Call QWidget::testAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize,
- or Qt::WA_MacNormalSize instead.
-*/
QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget)
{
while (widget) {
@@ -3101,7 +2973,6 @@ QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget)
return SizeDefault;
}
-/*! \reimp */
void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
const QWidget *w) const
{
@@ -3534,7 +3405,6 @@ static inline QPixmap darkenPixmap(const QPixmap &pixmap)
-/*! \reimp */
void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p,
const QWidget *w) const
{
@@ -4558,7 +4428,7 @@ static void setLayoutItemMargins(int left, int top, int right, int bottom, QRect
rect->adjust(left, top, right, bottom);
}
}
-/*! \reimp */
+
QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
const QWidget *widget) const
{
@@ -4852,7 +4722,6 @@ static inline void drawToolbarButtonArrow(const QRect &toolButtonRect, ThemeDraw
HIThemeDrawPopupArrow(&hirect, &padi, cg, kHIThemeOrientationNormal);
}
-/*! \reimp */
void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
const QWidget *widget) const
{
@@ -5235,7 +5104,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
arrowOpt.state = tb->state;
arrowOpt.palette = tb->palette;
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
- } else if (tb->features & QStyleOptionToolButton::HasMenu) {
+ } else if ((tb->features & QStyleOptionToolButton::HasMenu)
+ && (tb->toolButtonStyle != Qt::ToolButtonTextOnly && !tb->icon.isNull())) {
drawToolbarButtonArrow(tb->rect, tds, cg);
}
if (tb->state & State_On) {
@@ -5349,7 +5219,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
}
}
-/*! \reimp */
QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc,
const QStyleOptionComplex *opt,
const QPoint &pt, const QWidget *widget) const
@@ -5480,7 +5349,6 @@ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc,
return sc;
}
-/*! \reimp */
QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
const QWidget *widget) const
{
@@ -5820,7 +5688,6 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
return ret;
}
-/*! \reimp */
QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
const QSize &csz, const QWidget *widget) const
{
@@ -6107,9 +5974,6 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
return sz;
}
-/*!
- \reimp
-*/
void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal,
bool enabled, const QString &text, QPalette::ColorRole textRole) const
{
@@ -6118,9 +5982,6 @@ void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPale
QWindowsStyle::drawItemText(p, r, flags, pal, enabled, text, textRole);
}
-/*!
- \reimp
-*/
bool QMacStyle::event(QEvent *e)
{
if(e->type() == QEvent::FocusIn) {
@@ -6195,9 +6056,6 @@ void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayI
}
}
-/*!
- \internal
-*/
QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt,
const QWidget *widget) const
{
@@ -6311,9 +6169,6 @@ QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const Q
return QWindowsStyle::standardIconImplementation(standardIcon, opt, widget);
}
-/*!
- \internal
-*/
int QMacStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1,
QSizePolicy::ControlType control2,
Qt::Orientation orientation,
diff --git a/src/gui/styles/qmotifstyle.cpp b/src/gui/styles/qmotifstyle.cpp
index 7d4fab8..d19750f 100644
--- a/src/gui/styles/qmotifstyle.cpp
+++ b/src/gui/styles/qmotifstyle.cpp
@@ -298,8 +298,11 @@ void QMotifStyle::unpolish(QWidget* widget)
{
QCommonStyle::unpolish(widget);
#ifndef QT_NO_PROGRESSBAR
- if (qobject_cast<QProgressBar *>(widget))
+ if (qobject_cast<QProgressBar *>(widget)) {
+ Q_D(QMotifStyle);
widget->removeEventFilter(this);
+ d->bars.removeAll(static_cast<QProgressBar*>(widget));
+ }
#endif
}
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index bf73494..c6118d6 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $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$
**
****************************************************************************/
@@ -14,13 +44,12 @@
#include "qapplication.h"
#include "qpainter.h"
#include "qstyleoption.h"
-#include "qresizeevent"
-#include "qpixmapcache"
+#include "qevent.h"
+#include "qpixmapcache.h"
#include "qcalendarwidget.h"
#include "qdial.h"
#include "qdialog.h"
-#include "qerrormessage.h"
#include "qgroupbox.h"
#include "qheaderview.h"
#include "qlist.h"
@@ -28,12 +57,13 @@
#include "qlistview.h"
#include "qmenu.h"
#include "qmenubar.h"
-#include "qmessagebox.h"
#include "qpushbutton.h"
+#include "qscrollarea.h"
#include "qscrollbar.h"
#include "qtabbar.h"
#include "qtablewidget.h"
#include "qtableview.h"
+#include "qtextedit.h"
#include "qtoolbar.h"
#include "qtoolbutton.h"
#include "qtreeview.h"
@@ -41,6 +71,7 @@
#include "private/qtoolbarextension_p.h"
#include "private/qcombobox_p.h"
#include "private/qwidget_p.h"
+#include "private/qapplication_p.h"
#if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN)
@@ -55,7 +86,6 @@ const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFl
static const QByteArray propertyKeyLayouts = "layouts";
static const QByteArray propertyKeyCurrentlayout = "currentlayout";
-#if defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
const layoutHeader QS60StylePrivate::m_layoutHeaders[] = {
// *** generated layout data ***
{240,320,1,14,true,QLatin1String("QVGA Landscape Mirrored")},
@@ -85,15 +115,16 @@ const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = {
{7,0,-909,0,0,2,0,0,-1,20,52,28,19,19,9,258,-909,-909,-909,29,19,6,0,0,32,-909,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,98,35,98,5,5,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1},
{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,-909,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,5,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,8,6,5,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1},
{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,-909,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1}
-
-
// *** End of generated data ***
};
const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0];
-#endif // defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
-bool QS60StylePrivate::m_backgroundValid = false;
+// theme background texture
+QPixmap *QS60StylePrivate::m_background = 0;
+
+// theme palette
+QPalette *QS60StylePrivate::m_themePalette = 0;
const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = {
{SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter},
@@ -109,111 +140,20 @@ const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameEleme
{SE_ToolBarButton, QS60StyleEnums::SP_QsnFrSctrlButtonCenter},
{SE_ToolBarButtonPressed, QS60StyleEnums::SP_QsnFrSctrlButtonCenterPressed},
{SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter},
+ {SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive},
+ {SE_Editor, QS60StyleEnums::SP_QsnFrNotepadCenter},
};
+
static const int frameElementsCount =
int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0]));
-const int KNotFound = -1;
+const int KNotFound = -909;
+const double KTabFontMul = 0.72;
-void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart,
- QPainter *painter, const QRect &rect, SkinElementFlags flags)
+QS60StylePrivate::~QS60StylePrivate()
{
- static const bool doCache =
-#if defined(Q_WS_S60)
- // Freezes on 3.1. Anyways, caching is only really needed on touch UI
- !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
-#else
- true;
-#endif
- const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), flags));
- if (!skinPartPixMap.isNull())
- painter->drawPixmap(rect.topLeft(), skinPartPixMap);
-}
-
-void QS60StylePrivate::drawFrame(SkinFrameElements frameElement, QPainter *painter, const QRect &rect, SkinElementFlags flags)
-{
- static const bool doCache =
-#if defined(Q_WS_S60)
- // Freezes on 3.1. Anyways, caching is only really needed on touch UI
- !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
-#else
- true;
-#endif
- const QPixmap frameElementPixMap((doCache ? cachedFrame : frame)(frameElement, rect.size(), flags));
- if (!frameElementPixMap.isNull())
- painter->drawPixmap(rect.topLeft(), frameElementPixMap);
-}
-
-void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start,
- QS60StyleEnums::SkinParts middle, QS60StyleEnums::SkinParts end,
- Qt::Orientation orientation, QPainter *painter, const QRect &rect,
- SkinElementFlags flags)
-{
- QSize startEndSize(partSize(start, flags));
- startEndSize.scale(rect.size(), Qt::KeepAspectRatio);
-
- QRect startRect = QRect(rect.topLeft(), startEndSize);
- QRect middleRect = rect;
- QRect endRect;
-
- if (orientation == Qt::Horizontal) {
- startRect.setWidth(qMin(rect.width() / 2 - 1, startRect.width()));
- endRect = startRect.translated(rect.width() - startRect.width(), 0);
- middleRect.adjust(startRect.width(), 0, -startRect.width(), 0);
- } else {
- startRect.setHeight(qMin(rect.height() / 2 - 1, startRect.height()));
- endRect = startRect.translated(0, rect.height() - startRect.height());
- middleRect.adjust(0, startRect.height(), 0, -startRect.height());
- }
-
-#if 0
- painter->save();
- painter->setOpacity(.3);
- painter->fillRect(startRect, Qt::red);
- painter->fillRect(middleRect, Qt::green);
- painter->fillRect(endRect, Qt::blue);
- painter->restore();
-#else
- drawPart(start, painter, startRect, flags);
- if (middleRect.isValid())
- drawPart(middle, painter, middleRect, flags);
- drawPart(end, painter, endRect, flags);
-#endif
-}
-
-QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part,
- const QSize &size, SkinElementFlags flags)
-{
- QPixmap result;
- const QString cacheKey =
- QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinElementFlags=%4")
- .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags);
- if (!QPixmapCache::find(cacheKey, result)) {
- result = QS60StylePrivate::part(part, size, flags);
- QPixmapCache::insert(cacheKey, result);
- }
- return result;
-}
-
-QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size, SkinElementFlags flags)
-{
- QPixmap result;
- const QString cacheKey =
- QString::fromLatin1("S60Style: SkinFrameElements=%1 QSize=%2|%3 SkinElementFlags=%4")
- .arg((int)frame).arg(size.width()).arg(size.height()).arg((int)flags);
- if (!QPixmapCache::find(cacheKey, result)) {
- result = QS60StylePrivate::frame(frame, size, flags);
- QPixmapCache::insert(cacheKey, result);
- }
- return result;
-}
-
-void QS60StylePrivate::refreshUI()
-{
- foreach (QWidget *topLevelWidget, QApplication::allWidgets()) {
- topLevelWidget->updateGeometry();
- QCoreApplication::postEvent(topLevelWidget, new QResizeEvent(topLevelWidget->size(), topLevelWidget->size()));
- }
+ clearCaches(); //deletes also background image
+ deleteThemePalette();
}
void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter,
@@ -335,88 +275,33 @@ void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter,
drawRow(QS60StyleEnums::SP_QsnCpScrollHandleTopPressed, QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed,
QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed, Qt::Vertical, painter, rect, flags | SF_PointNorth);
break;
+ case SE_ButtonInactive:
+ drawFrame(SF_ButtonInactive, painter, rect, flags | SF_PointNorth);
+ break;
+ case SE_Editor:
+ drawFrame(SF_Editor, painter, rect, flags | SF_PointNorth);
+ break;
default:
break;
}
}
-QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags)
-{
- QSize result(20, 20);
- switch (part)
- {
- case QS60StyleEnums::SP_QgnGrafBarProgress:
- result.setWidth(pixelMetric(QStyle::PM_ProgressBarChunkWidth));
- break;
- case QS60StyleEnums::SP_QgnGrafTabActiveM:
- case QS60StyleEnums::SP_QgnGrafTabPassiveM:
- case QS60StyleEnums::SP_QgnGrafTabActiveR:
- case QS60StyleEnums::SP_QgnGrafTabPassiveR:
- case QS60StyleEnums::SP_QgnGrafTabPassiveL:
- case QS60StyleEnums::SP_QgnGrafTabActiveL:
- break;
- case QS60StyleEnums::SP_QgnIndiSliderEdit:
- result.scale(pixelMetric(QStyle::PM_SliderLength),
- pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio);
- break;
-
- case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed:
- case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed:
- case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed:
- case QS60StyleEnums::SP_QsnCpScrollBgBottom:
- case QS60StyleEnums::SP_QsnCpScrollBgMiddle:
- case QS60StyleEnums::SP_QsnCpScrollBgTop:
- case QS60StyleEnums::SP_QsnCpScrollHandleBottom:
- case QS60StyleEnums::SP_QsnCpScrollHandleMiddle:
- case QS60StyleEnums::SP_QsnCpScrollHandleTop:
- result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent));
- result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent));
- break;
- default:
- // Generic frame part size gathering.
- for (int i = 0; i < frameElementsCount; ++i)
- {
- switch (m_frameElementsData[i].center - part) {
- case 8: /* CornerTl */
- case 7: /* CornerTr */
- case 6: /* CornerBl */
- case 5: /* CornerBr */
- result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
- // Falltrough intended...
- case 4: /* SideT */
- case 3: /* SideB */
- result.setHeight(pixelMetric(PM_Custom_FrameCornerHeight));
- break;
- case 2: /* SideL */
- case 1: /* SideR */
- result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
- break;
- case 0: /* center */
- default:
- break;
- }
- }
- break;
- }
- if (flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest)) {
- const int temp = result.width();
- result.setWidth(result.height());
- result.setHeight(temp);
- }
- return result;
-}
-
-
void QS60StylePrivate::drawSkinPart(QS60StyleEnums::SkinParts part,
QPainter *painter, const QRect &rect, SkinElementFlags flags)
{
drawPart(part, painter, rect, flags);
}
+short QS60StylePrivate::pixelMetric(int metric)
+{
+ Q_ASSERT(metric < MAX_PIXELMETRICS);
+ const short returnValue = m_pmPointer[metric];
+ return returnValue;
+}
+
void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value)
{
if (name == propertyKeyCurrentlayout) {
-#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
static const QStringList layouts = styleProperty(propertyKeyLayouts).toStringList();
const QString layout = value.toString();
Q_ASSERT(layouts.contains(layout));
@@ -425,23 +310,118 @@ void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value)
QApplication::setLayoutDirection(m_layoutHeaders[layoutIndex].mirroring ? Qt::RightToLeft : Qt::LeftToRight);
clearCaches();
refreshUI();
- return;
-#else
- qFatal("Cannot set static layout. Dynamic layouts are used!");
-#endif
+ }
+}
+
+QVariant QS60StylePrivate::styleProperty(const char *name) const
+{
+ if (name == propertyKeyLayouts) {
+ static QStringList layouts;
+ if (layouts.isEmpty())
+ for (int i = 0; i < m_numberOfLayouts; i++)
+ layouts.append(m_layoutHeaders[i].layoutName);
+ return layouts;
+ }
+ return QVariant();
+}
+
+QColor QS60StylePrivate::stateColor(const QColor &color, const QStyleOption *option)
+{
+ QColor retColor (color);
+ if (option && !(option->state & QStyle::State_Enabled)) {
+ QColor hsvColor = retColor.toHsv();
+ int colorSat = hsvColor.saturation();
+ int colorVal = hsvColor.value();
+ colorSat = (colorSat!=0) ? (colorSat>>1) : 128;
+ colorVal = (colorVal!=0) ? (colorVal>>1) : 128;
+ hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal);
+ retColor = hsvColor.toRgb();
+ }
+ return retColor;
+}
+
+QColor QS60StylePrivate::lighterColor(const QColor &baseColor)
+{
+ QColor result(baseColor);
+ bool modifyColor = false;
+ if (result.saturation() == 0) {
+ result.setHsv(result.hue(), 128, result.value());
+ modifyColor = true;
+ }
+ if (result.value() == 0) {
+ result.setHsv(result.hue(), result.saturation(), 128);
+ modifyColor = true;
+ }
+ if (modifyColor)
+ result = result.lighter(175);
+ else
+ result = result.lighter(225);
+ return result;
+}
+
+bool QS60StylePrivate::drawsOwnThemeBackground(const QWidget *widget)
+{
+ return qobject_cast<const QDialog *> (widget);
+}
+
+QFont QS60StylePrivate::s60Font(
+ QS60StyleEnums::FontCategories fontCategory, int pointSize) const
+{
+ QFont result;
+ int actualPointSize = pointSize;
+ if (actualPointSize <= 0) {
+ const QFont appFont = QApplication::font();
+ actualPointSize = appFont.pointSize();
+ if (actualPointSize <= 0)
+ actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY();
+ }
+ Q_ASSERT(actualPointSize > 0);
+ const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize);
+ if (!m_mappedFontsCache.contains(key)) {
+ result = s60Font_specific(fontCategory, actualPointSize);
+ m_mappedFontsCache.insert(key, result);
+ } else {
+ result = m_mappedFontsCache.value(key);
+ if (result.pointSize() != actualPointSize)
+ result.setPointSize(actualPointSize);
+ }
+ return result;
+}
+
+void QS60StylePrivate::clearCaches(CacheClearReason reason)
+{
+ switch(reason){
+ case CC_LayoutChange:
+ // when layout changes, the colors remain in cache, but graphics and fonts can change
+ m_mappedFontsCache.clear();
+ deleteBackground();
+ QPixmapCache::clear();
+ break;
+ case CC_ThemeChange:
+ m_colorCache.clear();
+ QPixmapCache::clear();
+ deleteBackground();
+ break;
+ case CC_UndefinedChange:
+ default:
+ m_colorCache.clear();
+ m_mappedFontsCache.clear();
+ QPixmapCache::clear();
+ deleteBackground();
+ break;
}
}
// Since S60Style has 'button' and 'tooltip' as a graphic, we don't have any native color which to use
-// for QPalette::Button and QPalette::ToolTipBase. Therefore we need to guesstimate
-// this by calculating average rgb values for button pixels.
+// for QPalette::Button and QPalette::ToolTipBase. Therefore S60Style needs to guesstimate
+// palette colors by calculating average rgb values for button pixels.
// Returns Qt::black if there is an issue with the graphics (image is NULL, or no bits() found).
-QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameElements frame) const
+QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const
{
const bool cachedColorExists = m_colorCache.contains(frame);
if (!cachedColorExists) {
- const int frameCornerWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth);
- const int frameCornerHeight = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight);
+ const int frameCornerWidth = pixelMetric(PM_Custom_FrameCornerWidth);
+ const int frameCornerHeight = pixelMetric(PM_Custom_FrameCornerHeight);
Q_ASSERT(2*frameCornerWidth<32);
Q_ASSERT(2*frameCornerHeight<32);
@@ -453,7 +433,6 @@ QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameEleme
const int pixels = frameImage.numBytes()/sizeof(QRgb);
const int bytesPerLine = frameImage.bytesPerLine();
Q_ASSERT(bytesPerLine);
- const int rows = frameImage.numBytes()/(sizeof(QRgb)*bytesPerLine);
int estimatedRed = 0;
int estimatedGreen = 0;
@@ -494,284 +473,400 @@ QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameEleme
}
-int QS60StylePrivate::focusRectPenWidth()
+void QS60StylePrivate::setThemePalette(QApplication *app) const
{
- return pixelMetric(QS60Style::PM_DefaultFrameWidth);
+ Q_UNUSED(app)
+ QPalette widgetPalette = QPalette(Qt::white);
+ setThemePalette(&widgetPalette);
+ QApplication::setPalette(widgetPalette);
}
-void QS60StylePrivate::setThemePalette(QApplication *app) const
+void QS60StylePrivate::setThemePalette(QStyleOption *option) const
{
- if (!app)
- return;
-
- QPalette widgetPalette = QPalette(Qt::white);
+ setThemePalette(&option->palette);
+}
- // basic colors
- widgetPalette.setColor(QPalette::WindowText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- widgetPalette.setColor(QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- widgetPalette.setColor(QPalette::Text,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- widgetPalette.setColor(QPalette::ToolTipText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 55, 0));
- widgetPalette.setColor(QPalette::BrightText, widgetPalette.color(QPalette::WindowText).lighter());
- widgetPalette.setColor(QPalette::HighlightedText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0));
- widgetPalette.setColor(QPalette::Link,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnHighlightColors, 3, 0));
- widgetPalette.setColor(QPalette::LinkVisited, widgetPalette.color(QPalette::Link).darker());
- widgetPalette.setColor(QPalette::Highlight,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0));
- // set these as transparent so that styled full screen theme background is visible
- widgetPalette.setColor(QPalette::AlternateBase, Qt::transparent);
- widgetPalette.setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture());
- widgetPalette.setColor(QPalette::Base, Qt::transparent);
- // set button and tooltipbase based on pixel colors
- const QColor buttonColor = colorFromFrameGraphics(QS60StylePrivate::SF_ButtonNormal);
- widgetPalette.setColor(QPalette::Button, buttonColor );
- widgetPalette.setColor(QPalette::Light, widgetPalette.color(QPalette::Button).lighter());
- widgetPalette.setColor(QPalette::Dark, widgetPalette.color(QPalette::Button).darker());
- widgetPalette.setColor(QPalette::Midlight, widgetPalette.color(QPalette::Button).lighter(125));
- widgetPalette.setColor(QPalette::Mid, widgetPalette.color(QPalette::Button).darker(150));
- widgetPalette.setColor(QPalette::Shadow, Qt::black);
- QColor toolTipColor = colorFromFrameGraphics(QS60StylePrivate::SF_ToolTip);
- widgetPalette.setColor(QPalette::ToolTipBase, toolTipColor );
-
- app->setPalette(widgetPalette);
+QPalette* QS60StylePrivate::themePalette()
+{
+ return m_themePalette;
}
void QS60StylePrivate::setBackgroundTexture(QApplication *app) const
{
- if (!app)
- return;
- QPalette applicationPalette = app->palette();
- applicationPalette.setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture());
- app->setPalette(applicationPalette);
+ Q_UNUSED(app)
+ QPalette applicationPalette = QApplication::palette();
+ applicationPalette.setBrush(QPalette::Window, backgroundTexture());
+ QApplication::setPalette(applicationPalette);
}
-void QS60Style::polish(QApplication *application)
+void QS60StylePrivate::deleteBackground()
{
- Q_D(const QS60Style);
- originalPalette = application->palette();
- d->setThemePalette(application);
+ if (m_background) {
+ delete m_background;
+ m_background = 0;
+ }
}
-void QS60Style::polish(QWidget *widget)
+int QS60StylePrivate::focusRectPenWidth()
{
- Q_D(const QS60Style);
- QCommonStyle::polish(widget);
+ return pixelMetric(QS60Style::PM_DefaultFrameWidth);
+}
- if (!widget)
- return;
+void QS60StylePrivate::setCurrentLayout(int index)
+{
+ m_pmPointer = data[index];
+}
- if (QS60StylePrivate::isSkinnableDialog(widget)) {
- widget->setAttribute(Qt::WA_StyledBackground);
- } else if (false
-#ifndef QT_NO_MENU
- || qobject_cast<const QMenu *> (widget)
-#endif // QT_NO_MENU
- ) {
- widget->setAttribute(Qt::WA_StyledBackground);
- } else if (false
-#ifndef QT_NO_COMBOBOX
- || qobject_cast<const QComboBoxListView *>(widget)
-#endif //QT_NO_COMBOBOX
- ) {
- widget->setAttribute(Qt::WA_StyledBackground);
- }
+void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart,
+ QPainter *painter, const QRect &rect, SkinElementFlags flags)
+{
+ static const bool doCache =
+#if defined(Q_WS_S60)
+ // Freezes on 3.1. Anyways, caching is only really needed on touch UI
+ !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
+#else
+ true;
+#endif
+ const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), flags));
+ if (!skinPartPixMap.isNull())
+ painter->drawPixmap(rect.topLeft(), skinPartPixMap);
+}
- QPalette widgetPalette = widget->palette();
+void QS60StylePrivate::drawFrame(SkinFrameElements frameElement, QPainter *painter, const QRect &rect, SkinElementFlags flags)
+{
+ static const bool doCache =
+#if defined(Q_WS_S60)
+ // Freezes on 3.1. Anyways, caching is only really needed on touch UI
+ !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
+#else
+ true;
+#endif
+ const QPixmap frameElementPixMap((doCache ? cachedFrame : frame)(frameElement, rect.size(), flags));
+ if (!frameElementPixMap.isNull())
+ painter->drawPixmap(rect.topLeft(), frameElementPixMap);
+}
- // widget specific colors and fonts
- if (qobject_cast<QSlider *>(widget)){
- widgetPalette.setColor(QPalette::All, QPalette::WindowText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0));
- QApplication::setPalette(widgetPalette, "QSlider");
- } else if (qobject_cast<QPushButton *>(widget)){
- const QFont suggestedFont = d->s60Font(
- QS60StyleEnums::FC_Primary, widget->font().pointSizeF());
- widget->setFont(suggestedFont);
- widgetPalette.setColor(QPalette::Active, QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- QApplication::setPalette(widgetPalette, "QPushButton");
- } else if (qobject_cast<QToolButton *>(widget)){
- const QFont suggestedFont = d->s60Font(
- QS60StyleEnums::FC_Primary, widget->font().pointSizeF());
- widget->setFont(suggestedFont);
- widgetPalette.setColor(QPalette::Active, QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- QApplication::setPalette(widgetPalette, "QToolButton");
- } else if (qobject_cast<QHeaderView *>(widget)){
- const QFont suggestedFont = d->s60Font(
- QS60StyleEnums::FC_Secondary, widget->font().pointSizeF());
- widget->setFont(suggestedFont);
- widgetPalette.setColor(QPalette::Active, QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0));
- QHeaderView* header = qobject_cast<QHeaderView *>(widget);
- widgetPalette.setColor(QPalette::Button, Qt::transparent );
- if ( header->viewport() )
- header->viewport()->setPalette(widgetPalette);
- QApplication::setPalette(widgetPalette, "QHeaderView");
- } else if (qobject_cast<QMenuBar *>(widget)){
- widgetPalette.setColor(QPalette::All, QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0));
- QApplication::setPalette(widgetPalette, "QMenuBar");
- } else if (qobject_cast<QTabBar *>(widget)){
- widgetPalette.setColor(QPalette::Active, QPalette::WindowText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0));
- QApplication::setPalette(widgetPalette, "QTabBar");
- } else if (qobject_cast<QTableView *>(widget)){
- widgetPalette.setColor(QPalette::All, QPalette::Text,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0));
- QApplication::setPalette(widgetPalette, "QTableView");
- } else if (qobject_cast<QGroupBox *>(widget)){
- const QFont suggestedFont = d->s60Font(
- QS60StyleEnums::FC_Title, widget->font().pointSizeF());
- widget->setFont(suggestedFont);
- } else if (qobject_cast<QLineEdit *>(widget)) {
- widgetPalette.setColor(QPalette::All, QPalette::HighlightedText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0));
- QApplication::setPalette(widgetPalette, "QLineEdit");
- } else if (qobject_cast<QDial *> (widget)) {
- const QColor color(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- widgetPalette.setColor(QPalette::WindowText, color);
- widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button));
- widgetPalette.setColor(QPalette::Dark, color.darker());
- widgetPalette.setColor(QPalette::Light, color.lighter());
- QApplication::setPalette(widgetPalette, "QDial");
+void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start,
+ QS60StyleEnums::SkinParts middle, QS60StyleEnums::SkinParts end,
+ Qt::Orientation orientation, QPainter *painter, const QRect &rect,
+ SkinElementFlags flags)
+{
+ QSize startEndSize(partSize(start, flags));
+ startEndSize.scale(rect.size(), Qt::KeepAspectRatio);
+
+ QRect startRect = QRect(rect.topLeft(), startEndSize);
+ QRect middleRect = rect;
+ QRect endRect;
+
+ if (orientation == Qt::Horizontal) {
+ startRect.setWidth(qMin(rect.width() >>1 - 1, startRect.width()));
+ endRect = startRect.translated(rect.width() - startRect.width(), 0);
+ middleRect.adjust(startRect.width(), 0, -startRect.width(), 0);
+ if (startRect.bottomRight().x() > endRect.topLeft().x()) {
+ const int overlap = (startRect.bottomRight().x() - endRect.topLeft().x())>>1;
+ startRect.setWidth(startRect.width()-overlap);
+ endRect.adjust(overlap,0,0,0);
+ }
+ } else {
+ startRect.setHeight(qMin(rect.height() >>1 - 1, startRect.height()));
+ endRect = startRect.translated(0, rect.height() - startRect.height());
+ middleRect.adjust(0, startRect.height(), 0, -startRect.height());
+ if (startRect.topRight().y() > endRect.bottomLeft().y()) {
+ const int overlap = (startRect.topRight().y() - endRect.bottomLeft().y())>>1;
+ startRect.setHeight(startRect.height()-overlap);
+ endRect.adjust(0,overlap,0,0);
+ }
}
+
+#if 0
+ painter->save();
+ painter->setOpacity(.3);
+ painter->fillRect(startRect, Qt::red);
+ painter->fillRect(middleRect, Qt::green);
+ painter->fillRect(endRect, Qt::blue);
+ painter->restore();
+#else
+ drawPart(start, painter, startRect, flags);
+ if (middleRect.isValid())
+ drawPart(middle, painter, middleRect, flags);
+ drawPart(end, painter, endRect, flags);
+#endif
}
-void QS60Style::unpolish(QApplication *application)
+QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part,
+ const QSize &size, SkinElementFlags flags)
{
- application->setPalette(originalPalette);
+ QPixmap result;
+ const QString cacheKey =
+ QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4")
+ .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags);
+ if (!QPixmapCache::find(cacheKey, result)) {
+ result = QS60StylePrivate::part(part, size, flags);
+ QPixmapCache::insert(cacheKey, result);
+ }
+ return result;
}
-void QS60Style::unpolish(QWidget *widget)
+QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size, SkinElementFlags flags)
{
- if (QS60StylePrivate::isSkinnableDialog(widget)) {
- widget->setAttribute(Qt::WA_StyledBackground, false);
- } else if (false
-#ifndef QT_NO_MENU
- || qobject_cast<const QMenu *> (widget)
-#endif // QT_NO_MENU
- ) {
- widget->setAttribute(Qt::WA_StyledBackground, false);
- } else if (false
-#ifndef QT_NO_COMBOBOX
- || qobject_cast<const QComboBoxListView *>(widget)
-#endif //QT_NO_COMBOBOX
- ) {
- widget->setAttribute(Qt::WA_StyledBackground, false);
+ QPixmap result;
+ const QString cacheKey =
+ QString::fromLatin1("S60Style: SkinFrameElements=%1 QSize=%2|%3 SkinElementFlags=%4")
+ .arg((int)frame).arg(size.width()).arg(size.height()).arg((int)flags);
+ if (!QPixmapCache::find(cacheKey, result)) {
+ result = QS60StylePrivate::frame(frame, size, flags);
+ QPixmapCache::insert(cacheKey, result);
}
+ return result;
+}
- if (widget) {
- widget->setPalette(QPalette());
- }
+void QS60StylePrivate::refreshUI()
+{
+ QList<QWidget *> widgets = QApplication::allWidgets();
- QCommonStyle::unpolish(widget);
+ for (int i = 0; i < widgets.size(); ++i) {
+ QWidget *widget = widgets.at(i);
+ if (widget == 0)
+ continue;
+
+ if (widget->style()) {
+ widget->style()->polish(widget);
+ QEvent event(QEvent::StyleChange);
+ qApp->sendEvent(widget, &event);
+ }
+ widget->update();
+ widget->updateGeometry();
+ }
}
-QVariant QS60StylePrivate::styleProperty(const char *name) const
+void QS60StylePrivate::setFont(QWidget *widget) const
{
- if (name == propertyKeyLayouts) {
-#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
- static QStringList layouts;
- if (layouts.isEmpty())
- for (int i = 0; i < QS60StylePrivate::m_numberOfLayouts; i++)
- layouts.append(QS60StylePrivate::m_layoutHeaders[i].layoutName);
- return layouts;
-#else
- qFatal("Cannot return list of 'canned' static layouts. Dynamic layouts are used!");
-#endif
+ QS60StyleEnums::FontCategories fontCategory = QS60StyleEnums::FC_Undefined;
+ if (!widget)
+ return;
+ if (qobject_cast<QPushButton *>(widget)){
+ fontCategory = QS60StyleEnums::FC_Primary;
+ } else if (qobject_cast<QToolButton *>(widget)){
+ fontCategory = QS60StyleEnums::FC_Primary;
+ } else if (qobject_cast<QHeaderView *>(widget)){
+ fontCategory = QS60StyleEnums::FC_Secondary;
+ } else if (qobject_cast<QGroupBox *>(widget)){
+ fontCategory = QS60StyleEnums::FC_Title;
+ }
+ if (fontCategory != QS60StyleEnums::FC_Undefined) {
+ const QFont suggestedFont =
+ s60Font(fontCategory, widget->font().pointSizeF());
+ widget->setFont(suggestedFont);
}
- return QVariant();
}
-QFont QS60StylePrivate::s60Font(
- QS60StyleEnums::FontCategories fontCategory, int pointSize) const
+void QS60StylePrivate::setThemePalette(QWidget *widget) const
{
- QFont result;
- int actualPointSize = pointSize;
- if (actualPointSize <= 0) {
- const QFont appFont = QApplication::font();
- actualPointSize = appFont.pointSize();
- if (actualPointSize <= 0)
- actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY();
- }
- Q_ASSERT(actualPointSize > 0);
- const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize);
- if (!m_mappedFontsCache.contains(key)) {
- result = s60Font_specific(fontCategory, actualPointSize);
- m_mappedFontsCache.insert(key, result);
- } else {
- result = m_mappedFontsCache.value(key);
- if (result.pointSize() != actualPointSize)
- result.setPointSize(actualPointSize);
+ if(!widget)
+ return;
+ QPalette widgetPalette = widget->palette();
+
+ //header view and its viewport need to be set 100% transparent button color, since drawing code will
+ //draw transparent theme graphics to table column and row headers.
+ if (qobject_cast<QHeaderView *>(widget)){
+ widgetPalette.setColor(QPalette::Active, QPalette::ButtonText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0));
+ QHeaderView* header = qobject_cast<QHeaderView *>(widget);
+ widgetPalette.setColor(QPalette::Button, Qt::transparent );
+ if ( header->viewport() )
+ header->viewport()->setPalette(widgetPalette);
+ QApplication::setPalette(widgetPalette, "QHeaderView");
}
- return result;
}
-//todo: you could pass a reason to clear cache here, so that we could
-// deduce whether or not the specific cache needs to be cleared
-void QS60StylePrivate::clearCaches()
+void QS60StylePrivate::setThemePalette(QPalette *palette) const
{
- m_colorCache.clear();
- m_mappedFontsCache.clear();
- QPixmapCache::clear();
- m_backgroundValid = false;
+ if (!palette)
+ return;
+
+ // basic colors
+ palette->setColor(QPalette::WindowText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
+ palette->setColor(QPalette::ButtonText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
+ palette->setColor(QPalette::Text,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
+ palette->setColor(QPalette::ToolTipText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 55, 0));
+ palette->setColor(QPalette::BrightText, palette->color(QPalette::WindowText).lighter());
+ palette->setColor(QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0));
+ palette->setColor(QPalette::Link,
+ s60Color(QS60StyleEnums::CL_QsnHighlightColors, 3, 0));
+ palette->setColor(QPalette::LinkVisited, palette->color(QPalette::Link).darker());
+ palette->setColor(QPalette::Highlight,
+ s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0));
+ // set background image as a texture brush
+ palette->setBrush(QPalette::Window, backgroundTexture());
+ // set these as transparent so that styled full screen theme background is visible
+ palette->setColor(QPalette::AlternateBase, Qt::transparent);
+ palette->setBrush(QPalette::Base, Qt::transparent);
+ // set button and tooltipbase based on pixel colors
+ const QColor buttonColor = this->colorFromFrameGraphics(SF_ButtonNormal);
+ palette->setColor(QPalette::Button, buttonColor );
+ const QColor toolTipColor = this->colorFromFrameGraphics(SF_ToolTip);
+ palette->setColor(QPalette::ToolTipBase, toolTipColor );
+ palette->setColor(QPalette::Light, palette->color(QPalette::Button).lighter());
+ palette->setColor(QPalette::Dark, palette->color(QPalette::Button).darker());
+ palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125));
+ palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150));
+ palette->setColor(QPalette::Shadow, Qt::black);
+
+ setThemePaletteHash(palette);
+ storeThemePalette(palette);
}
-QColor QS60StylePrivate::lighterColor(const QColor &baseColor)
+void QS60StylePrivate::deleteThemePalette()
{
- QColor result(baseColor);
- bool modifyColor = false;
- if (result.saturation() == 0) {
- result.setHsv(result.hue(), 128, result.value());
- modifyColor = true;
- }
- if (result.value() == 0) {
- result.setHsv(result.hue(), result.saturation(), 128);
- modifyColor = true;
+ if (m_themePalette) {
+ delete m_themePalette;
+ m_themePalette = 0;
}
- if (modifyColor)
- result = result.lighter(175);
- else
- result = result.lighter(225);
- return result;
}
-bool QS60StylePrivate::isSkinnableDialog(const QWidget *widget)
+void QS60StylePrivate::storeThemePalette(QPalette *palette)
{
- return (qobject_cast<const QMessageBox *> (widget) ||
- qobject_cast<const QErrorMessage *> (widget));
+ deleteThemePalette();
+ //store specified palette for latter use.
+ m_themePalette = new QPalette(*palette);
}
-#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
-void QS60StylePrivate::setCurrentLayout(int index)
+// set widget specific palettes
+void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const
{
- m_pmPointer = data[index];
+ if (!palette)
+ return;
+
+ //store the original palette
+ QPalette widgetPalette = *palette;
+ const QColor mainAreaTextColor =
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0);
+
+ widgetPalette.setColor(QPalette::All, QPalette::WindowText,
+ s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0));
+ QApplication::setPalette(widgetPalette, "QSlider");
+ // return to original palette after each widget
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, mainAreaTextColor);
+ widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, mainAreaTextColor);
+ const QStyleOption opt;
+ widgetPalette.setColor(QPalette::Disabled, QPalette::ButtonText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 6, &opt));
+ QApplication::setPalette(widgetPalette, "QPushButton");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, mainAreaTextColor);
+ widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, mainAreaTextColor);
+ QApplication::setPalette(widgetPalette, "QToolButton");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::Active, QPalette::ButtonText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0));
+ QApplication::setPalette(widgetPalette, "QHeaderView");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::All, QPalette::ButtonText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0));
+ QApplication::setPalette(widgetPalette, "QMenuBar");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::Active, QPalette::WindowText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0));
+ QApplication::setPalette(widgetPalette, "QTabBar");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::All, QPalette::Text,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0));
+ QApplication::setPalette(widgetPalette, "QTableView");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::All, QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0));
+ QApplication::setPalette(widgetPalette, "QLineEdit");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor);
+ widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button));
+ widgetPalette.setColor(QPalette::Dark, mainAreaTextColor.darker());
+ widgetPalette.setColor(QPalette::Light, mainAreaTextColor.lighter());
+ QApplication::setPalette(widgetPalette, "QDial");
+ widgetPalette = *palette;
+
+ widgetPalette.setBrush(QPalette::Window, QBrush());
+ QApplication::setPalette(widgetPalette, "QScrollArea");
+ widgetPalette = *palette;
}
-#endif
-QColor QS60StylePrivate::stateColor(const QColor& color, const QStyleOption *option)
+QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags)
{
- QColor retColor (color);
- if (option && !(option->state & QStyle::State_Enabled)) {
- QColor hsvColor = retColor.toHsv();
- int colorSat = hsvColor.saturation();
- int colorVal = hsvColor.value();
- colorSat = (colorSat!=0) ? (colorSat>>1) : 128;
- colorVal = (colorVal!=0) ? (colorVal>>1) : 128;
- hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal);
- retColor = hsvColor.toRgb();
+ QSize result(20, 20);
+ switch (part)
+ {
+ case QS60StyleEnums::SP_QgnGrafBarProgress:
+ result.setWidth(pixelMetric(QStyle::PM_ProgressBarChunkWidth));
+ break;
+ case QS60StyleEnums::SP_QgnGrafTabActiveM:
+ case QS60StyleEnums::SP_QgnGrafTabPassiveM:
+ case QS60StyleEnums::SP_QgnGrafTabActiveR:
+ case QS60StyleEnums::SP_QgnGrafTabPassiveR:
+ case QS60StyleEnums::SP_QgnGrafTabPassiveL:
+ case QS60StyleEnums::SP_QgnGrafTabActiveL:
+ break;
+ case QS60StyleEnums::SP_QgnIndiSliderEdit:
+ result.scale(pixelMetric(QStyle::PM_SliderLength),
+ pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio);
+ break;
+
+ case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed:
+ case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed:
+ case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed:
+ case QS60StyleEnums::SP_QsnCpScrollBgBottom:
+ case QS60StyleEnums::SP_QsnCpScrollBgMiddle:
+ case QS60StyleEnums::SP_QsnCpScrollBgTop:
+ case QS60StyleEnums::SP_QsnCpScrollHandleBottom:
+ case QS60StyleEnums::SP_QsnCpScrollHandleMiddle:
+ case QS60StyleEnums::SP_QsnCpScrollHandleTop:
+ result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent));
+ result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent));
+ break;
+ default:
+ // Generic frame part size gathering.
+ for (int i = 0; i < frameElementsCount; ++i)
+ {
+ switch (m_frameElementsData[i].center - part) {
+ case 8: /* CornerTl */
+ case 7: /* CornerTr */
+ case 6: /* CornerBl */
+ case 5: /* CornerBr */
+ result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
+ // Falltrough intended...
+ case 4: /* SideT */
+ case 3: /* SideB */
+ result.setHeight(pixelMetric(PM_Custom_FrameCornerHeight));
+ break;
+ case 2: /* SideL */
+ case 1: /* SideR */
+ result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
+ break;
+ case 0: /* center */
+ default:
+ break;
+ }
+ }
+ break;
}
- return retColor;
+ if (flags & (SF_PointEast | SF_PointWest)) {
+ const int temp = result.width();
+ result.setWidth(result.height());
+ result.setHeight(temp);
+ }
+ return result;
}
/*!
@@ -783,14 +878,6 @@ QColor QS60StylePrivate::stateColor(const QColor& color, const QStyleOption *opt
\sa QMacStyle, QWindowsStyle, QWindowsXPStyle, QWindowsVistaStyle, QPlastiqueStyle, QCleanlooksStyle, QMotifStyle
*/
-/*!
- Constructs a QS60Style object.
-*/
-QS60Style::QS60Style()
- : QCommonStyle(*new QS60StylePrivate)
-{
-}
-
QS60Style::~QS60Style()
{
}
@@ -803,8 +890,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled;
SubControls sub = option->subControls;
- Q_D(const QS60Style);
-
switch (control) {
#ifndef QT_NO_SCROLLBAR
case CC_ScrollBar:
@@ -817,18 +902,18 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
const QS60StylePrivate::SkinElements grooveElement =
horizontal ? QS60StylePrivate::SE_ScrollBarGrooveHorizontal : QS60StylePrivate::SE_ScrollBarGrooveVertical;
QS60StylePrivate::drawSkinElement(grooveElement, painter, grooveRect, flags);
-
- QStyle::SubControls subControls = optionSlider->subControls;
-
+
+ const QStyle::SubControls subControls = optionSlider->subControls;
+
// select correct slider (horizontal/vertical/pressed)
const bool sliderPressed = ((optionSlider->state & QStyle::State_Sunken) && (subControls & SC_ScrollBarSlider));
const QS60StylePrivate::SkinElements handleElement =
- horizontal ?
- ( sliderPressed ?
- QS60StylePrivate::SE_ScrollBarHandlePressedHorizontal :
- QS60StylePrivate::SE_ScrollBarHandleHorizontal ) :
- ( sliderPressed ?
- QS60StylePrivate::SE_ScrollBarHandlePressedVertical :
+ horizontal ?
+ ( sliderPressed ?
+ QS60StylePrivate::SE_ScrollBarHandlePressedHorizontal :
+ QS60StylePrivate::SE_ScrollBarHandleHorizontal ) :
+ ( sliderPressed ?
+ QS60StylePrivate::SE_ScrollBarHandlePressedVertical :
QS60StylePrivate::SE_ScrollBarHandleVertical);
QS60StylePrivate::drawSkinElement(handleElement, painter, scrollBarSlider, flags);
}
@@ -870,11 +955,9 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
const QRect cmbxEditField = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget);
const QRect cmbxFrame = subControlRect(CC_ComboBox, option, SC_ComboBoxFrame, widget);
-
const bool direction = cmb->direction == Qt::LeftToRight;
// Button frame
- //todo: why calc rect here for button? Is there no suitable SE_xxx for that?
QStyleOptionFrame buttonOption;
buttonOption.QStyleOption::operator=(*cmb);
const int maxHeight = cmbxFrame.height();
@@ -884,15 +967,15 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
buttonOption.rect = buttonRect;
buttonOption.state = cmb->state & (State_Enabled | State_MouseOver);
drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget);
- // todo: we could draw qgn_prop_set_button skin item here
// draw label background - label itself is drawn separately
const QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_FrameLineEdit;
QS60StylePrivate::drawSkinElement(skinElement, painter, cmbxEditField, flags);
+ // Draw the combobox arrow
if (sub & SC_ComboBoxArrow) {
- // Draw the little arrow
- buttonOption.rect.adjust(1, 1, -1, -1);
+ // Make rect slightly smaller
+ buttonOption.rect.adjust(1, 1, -1, -1);
painter->save();
painter->setPen(option->palette.buttonText().color());
drawPrimitive(PE_IndicatorSpinDown, &buttonOption, painter, widget);
@@ -1032,14 +1115,13 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (spinBox->subControls & SC_SpinBoxUp) {
copy.subControls = SC_SpinBoxUp;
- QPalette pal2 = spinBox->palette;
+ QPalette spinBoxPal = spinBox->palette;
if (!(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
- pal2.setCurrentColorGroup(QPalette::Disabled);
+ spinBoxPal.setCurrentColorGroup(QPalette::Disabled);
copy.state &= ~State_Enabled;
+ copy.palette = spinBoxPal;
}
- copy.palette = pal2;
-
if (spinBox->activeSubControls == SC_SpinBoxUp && (spinBox->state & State_Sunken)) {
copy.state |= State_On;
copy.state |= State_Sunken;
@@ -1047,8 +1129,9 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
copy.state |= State_Raised;
copy.state &= ~State_Sunken;
}
- pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
- : PE_IndicatorSpinUp);
+ pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) ?
+ PE_IndicatorSpinPlus :
+ PE_IndicatorSpinUp;
copy.rect = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxUp, widget);
drawPrimitive(PE_PanelButtonBevel, &copy, painter, widget);
@@ -1059,12 +1142,12 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (spinBox->subControls & SC_SpinBoxDown) {
copy.subControls = SC_SpinBoxDown;
copy.state = spinBox->state;
- QPalette pal2 = spinBox->palette;
+ QPalette spinBoxPal = spinBox->palette;
if (!(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
- pal2.setCurrentColorGroup(QPalette::Disabled);
+ spinBoxPal.setCurrentColorGroup(QPalette::Disabled);
copy.state &= ~State_Enabled;
+ copy.palette = spinBoxPal;
}
- copy.palette = pal2;
if (spinBox->activeSubControls == SC_SpinBoxDown && (spinBox->state & State_Sunken)) {
copy.state |= State_On;
@@ -1073,8 +1156,9 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
copy.state |= State_Raised;
copy.state &= ~State_Sunken;
}
- pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
- : PE_IndicatorSpinDown);
+ pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) ?
+ PE_IndicatorSpinMinus :
+ PE_IndicatorSpinDown;
copy.rect = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxDown, widget);
drawPrimitive(PE_PanelButtonBevel, &copy, painter, widget);
@@ -1134,23 +1218,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
}
break;
#endif //QT_NO_GROUPBOX
-#ifndef QT_NO_DIAL
- case CC_Dial:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- QStyleOptionSlider optionSlider = *slider;
- QCommonStyle::drawComplexControl(control, &optionSlider, painter, widget);
- }
- break;
-#endif //QT_NO_DIAL
-
- //todo: remove non-used complex widgets in final version
- case CC_TitleBar:
-#ifdef QT3_SUPPORT
- case CC_Q3ListView:
-#endif //QT3_SUPPORT
-#ifndef QT_NO_WORKSPACE
- case CC_MdiControls:
-#endif //QT_NO_WORKSPACE
default:
QCommonStyle::drawComplexControl(control, option, painter, widget);
}
@@ -1171,21 +1238,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QStyleOptionButton subopt = *btn;
subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
- if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) {
- if (buttonWidget->isCheckable()) {
- QStyleOptionButton checkopt = subopt;
-
- const int indicatorHeight(pixelMetric(PM_IndicatorHeight));
- const int verticalAdjust = (option->rect.height() - indicatorHeight) >> 1;
-
- checkopt.rect.adjust(pixelMetric(PM_ButtonMargin), verticalAdjust, 0, 0);
- checkopt.rect.setWidth(pixelMetric(PM_IndicatorWidth));
- checkopt.rect.setHeight(indicatorHeight);
-
- drawPrimitive(PE_IndicatorCheckBox, &checkopt, painter, widget);
- }
- }
-
drawControl(CE_PushButtonLabel, &subopt, painter, widget);
if (btn->state & State_HasFocus) {
QStyleOptionFocusRect fropt;
@@ -1197,55 +1249,43 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
break;
case CE_PushButtonBevel:
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- const bool isPressed = option->state & QStyle::State_Sunken;
- if (button->features & QStyleOptionButton::Flat) {
- const QS60StyleEnums::SkinParts skinPart =
- isPressed ? QS60StyleEnums::SP_QsnFrButtonTbCenterPressed : QS60StyleEnums::SP_QsnFrButtonTbCenter;
- QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags);
+ const bool isDisabled = !(option->state & QStyle::State_Enabled);
+ const bool isFlat = button->features & QStyleOptionButton::Flat;
+ QS60StyleEnums::SkinParts skinPart;
+ QS60StylePrivate::SkinElements skinElement;
+ if (!isDisabled) {
+ const bool isPressed = (option->state & QStyle::State_Sunken) ||
+ (option->state & QStyle::State_On);
+ if (isFlat) {
+ skinPart =
+ isPressed ? QS60StyleEnums::SP_QsnFrButtonTbCenterPressed : QS60StyleEnums::SP_QsnFrButtonTbCenter;
+ } else {
+ skinElement =
+ isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal;
+ }
} else {
- const QS60StylePrivate::SkinElements skinElement =
- isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal;
- QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags);
+ if (isFlat)
+ skinPart =QS60StyleEnums::SP_QsnFrButtonCenterInactive;
+ else
+ skinElement = QS60StylePrivate::SE_ButtonInactive;
}
- }
- break;
- case CE_PushButtonLabel:
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- QStyleOptionButton optionButton = *button;
-
- if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) {
- if (buttonWidget->isCheckable()) {
- // space for check box.
- optionButton.rect.adjust(pixelMetric(PM_IndicatorWidth)
- + pixelMetric(PM_ButtonMargin) + pixelMetric(PM_CheckBoxLabelSpacing), 0, 0, 0);
- }
+ if (isFlat)
+ QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags);
+ else
+ QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags);
}
- QCommonStyle::drawControl(element, &optionButton, painter, widget);
- }
- break;
- case CE_CheckBoxLabel:
- if (const QStyleOptionButton *checkBox = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- QStyleOptionButton optionCheckBox = *checkBox;
- QCommonStyle::drawControl(element, &optionCheckBox, painter, widget);
- }
- break;
- case CE_RadioButtonLabel:
- if (const QStyleOptionButton *radioButton = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- QStyleOptionButton optionRadioButton = *radioButton;
- QCommonStyle::drawControl(element, &optionRadioButton, painter, widget);
- }
break;
#ifndef QT_NO_TOOLBUTTON
case CE_ToolButtonLabel:
if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
QStyleOptionToolButton optionToolButton = *toolBtn;
-
- if (!optionToolButton.icon.isNull() && (optionToolButton.state & QStyle::State_Sunken)
+
+ if (!optionToolButton.icon.isNull() && (optionToolButton.state & QStyle::State_Sunken)
&& (optionToolButton.state & State_Enabled)) {
-
+
const QIcon::State state = optionToolButton.state & State_On ? QIcon::On : QIcon::Off;
const QPixmap pm(optionToolButton.icon.pixmap(optionToolButton.rect.size().boundedTo(optionToolButton.iconSize),
- QIcon::Normal, state));
+ QIcon::Normal, state));
optionToolButton.icon = generatedIconPixmap(QIcon::Selected, pm, &optionToolButton);
}
@@ -1253,12 +1293,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
}
break;
#endif //QT_NO_TOOLBUTTON
- case CE_HeaderLabel:
- if (const QStyleOptionHeader *headerLabel = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- QStyleOptionHeader optionHeaderLabel = *headerLabel;
- QCommonStyle::drawControl(element, &optionHeaderLabel, painter, widget);
- }
- break;
#ifndef QT_NO_COMBOBOX
case CE_ComboBoxLabel:
if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
@@ -1330,28 +1364,30 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &voptAdj, widget);
QRect textRect = subElementRect(SE_ItemViewItemText, &voptAdj, widget);
- // draw the background
- const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option);
- const QTableView *table = qobject_cast<const QTableView *>(widget);
- if (table && tableOption) {
- const QModelIndex index = tableOption->index;
- //todo: Draw cell background only once - for the first cell.
- QStyleOptionViewItemV4 voptAdj2 = voptAdj2;
- const QModelIndex indexFirst = table->model()->index(0,0);
- const QModelIndex indexLast = table->model()->index(
- table->model()->rowCount()-1,table->model()->columnCount()-1);
- if (table->viewport())
- voptAdj2.rect = QRect( table->visualRect(indexFirst).topLeft(),
- table->visualRect(indexLast).bottomRight()).intersect(table->viewport()->rect());
- drawPrimitive(PE_PanelItemViewItem, &voptAdj2, painter, widget);
- }
+ // draw themed background for table unless background brush has been defined.
+ if (vopt->backgroundBrush == Qt::NoBrush) {
+ const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option);
+ const QTableView *table = qobject_cast<const QTableView *>(widget);
+ if (table && tableOption) {
+ const QModelIndex index = tableOption->index;
+ //todo: Draw cell background only once - for the first cell.
+ QStyleOptionViewItemV4 voptAdj2 = voptAdj;
+ const QModelIndex indexFirst = table->model()->index(0,0);
+ const QModelIndex indexLast = table->model()->index(
+ table->model()->rowCount()-1,table->model()->columnCount()-1);
+ if (table->viewport())
+ voptAdj2.rect = QRect( table->visualRect(indexFirst).topLeft(),
+ table->visualRect(indexLast).bottomRight()).intersect(table->viewport()->rect());
+ drawPrimitive(PE_PanelItemViewItem, &voptAdj2, painter, widget);
+ }
+ } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget);}
// draw the focus rect
if (isSelected)
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags);
// draw the icon
- const QIcon::Mode mode = !(voptAdj.state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled;
+ const QIcon::Mode mode = (voptAdj.state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled;
const QIcon::State state = voptAdj.state & QStyle::State_Open ? QIcon::On : QIcon::Off;
voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state);
@@ -1361,17 +1397,15 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
listView &&
(listView->selectionMode() == QAbstractItemView::SingleSelection ||
listView->selectionMode() == QAbstractItemView::NoSelection);
- QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget);
- if (voptAdj.state & QStyle::State_Selected &&
- !singleSelection) {
+ const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget);
+ if (voptAdj.state & QStyle::State_Selected && !singleSelection) {
QStyleOptionViewItemV4 option(voptAdj);
option.rect = selectionRect;
// Draw selection mark.
drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, painter, widget);
if ( textRect.right() > selectionRect.left() )
textRect.setRight(selectionRect.left());
- }
- else if (singleSelection &&
+ } else if (singleSelection &&
voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator) {
// draw the check mark
if (selectionRect.isValid()) {
@@ -1400,9 +1434,11 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option);
if (isSelected) {
if (qobject_cast<const QTableView *>(widget) && tableOption)
- voptAdj.palette.setColor(QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
+ voptAdj.palette.setColor(
+ QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
else
- voptAdj.palette.setColor(QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0));
+ voptAdj.palette.setColor(
+ QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0));
}
painter->setPen(voptAdj.palette.text().color());
d->viewItemDrawText(painter, &voptAdj, textRect);
@@ -1454,7 +1490,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
const int tabOverlap =
QS60StylePrivate::pixelMetric(QStyle::PM_TabBarTabOverlap) - borderThickness;
//todo: draw navi wipe behind tabbar - must be drawn with first draw
- //QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, windowRect, flags);
if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive||
skinElement==QS60StylePrivate::SE_TabBarTabEastActive||
@@ -1501,7 +1536,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
}
painter->save();
QFont f = painter->font();
- f.setPointSizeF(f.pointSizeF() * 0.72);
+ f.setPointSizeF(f.pointSizeF() * KTabFontMul);
painter->setFont(f);
if (option->state & QStyle::State_Selected){
@@ -1509,27 +1544,27 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 3, option));
}
- bool verticalTabs = optionTab.shape == QTabBar::RoundedEast
+ const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast
|| optionTab.shape == QTabBar::RoundedWest
|| optionTab.shape == QTabBar::TriangularEast
|| optionTab.shape == QTabBar::TriangularWest;
- bool selected = optionTab.state & State_Selected;
+ const bool selected = optionTab.state & State_Selected;
if (verticalTabs) {
painter->save();
- int newX, newY, newRot;
+ int newX, newY, newRotation;
if (optionTab.shape == QTabBar::RoundedEast || optionTab.shape == QTabBar::TriangularEast) {
newX = tr.width();
newY = tr.y();
- newRot = 90;
+ newRotation = 90;
} else {
newX = 0;
newY = tr.y() + tr.height();
- newRot = -90;
+ newRotation = -90;
}
tr.setRect(0, 0, tr.height(), tr.width());
QTransform m;
m.translate(newX, newY);
- m.rotate(newRot);
+ m.rotate(newRotation);
painter->setTransform(m, true);
}
tr.adjust(0, 0, pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget),
@@ -1551,9 +1586,13 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QPixmap tabIcon = optionTab.icon.pixmap(iconSize,
(optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
if (tab->text.isEmpty())
- painter->drawPixmap(tr.center().x() - (tabIcon.height() >>1), tr.center().y() - (tabIcon.height() >>1), tabIcon);
+ painter->drawPixmap(tr.center().x() - (tabIcon.height() >>1),
+ tr.center().y() - (tabIcon.height() >>1),
+ tabIcon);
else
- painter->drawPixmap(tr.left() + tabOverlap, tr.center().y() - (tabIcon.height() >>1), tabIcon);
+ painter->drawPixmap(tr.left() + tabOverlap,
+ tr.center().y() - (tabIcon.height() >>1),
+ tabIcon);
tr.setLeft(tr.left() + iconSize.width() + 4);
}
@@ -1563,13 +1602,13 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (optionTab.state & State_HasFocus) {
const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth);
- const int x1 = optionTab.rect.left();
- const int x2 = optionTab.rect.right() - 1;
+ const int leftBorder = optionTab.rect.left();
+ const int rightBorder = optionTab.rect.right() - 1;
QStyleOptionFocusRect fropt;
fropt.QStyleOption::operator=(*tab);
- fropt.rect.setRect(x1 + 1 + OFFSET, optionTab.rect.y() + OFFSET,
- x2 - x1 - 2*OFFSET, optionTab.rect.height() - 2*OFFSET);
+ fropt.rect.setRect(leftBorder + 1 + OFFSET, optionTab.rect.y() + OFFSET,
+ rightBorder - leftBorder - 2*OFFSET, optionTab.rect.height() - 2*OFFSET);
drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
}
@@ -1619,31 +1658,12 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
}
break;
#endif // QT_NO_PROGRESSBAR
-#ifndef QT_NO_MENUBAR
- case CE_MenuBarItem:
- if (const QStyleOptionMenuItem *menuBarItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- QStyleOptionMenuItem optionMenuBarItem = *menuBarItem;
- QCommonStyle::drawControl(element, &optionMenuBarItem, painter, widget);
- }
- break;
-#endif //QT_NO_MENUBAR
#ifndef QT_NO_MENU
case CE_MenuItem:
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
QStyleOptionMenuItem optionMenuItem = *menuItem;
- const bool enabled = optionMenuItem.state & State_Enabled;
- const bool checkable = optionMenuItem.checkType != QStyleOptionMenuItem::NotCheckable;
-
- uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip
- | Qt::TextSingleLine | Qt::AlignVCenter;
- if (!styleHint(SH_UnderlineShortcut, menuItem, widget))
- text_flags |= Qt::TextHideMnemonic;
-
- QRect iconRect =
- subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget);
- QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget);
+
bool drawSubMenuIndicator = false;
-
switch(menuItem->menuItemType) {
case QStyleOptionMenuItem::Scroller:
case QStyleOptionMenuItem::Separator:
@@ -1654,20 +1674,29 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
default:
break;
}
+ const bool enabled = optionMenuItem.state & State_Enabled;
+ const bool checkable = optionMenuItem.checkType != QStyleOptionMenuItem::NotCheckable;
+
+ uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip
+ | Qt::TextSingleLine | Qt::AlignVCenter;
+ if (!styleHint(SH_UnderlineShortcut, menuItem, widget))
+ text_flags |= Qt::TextHideMnemonic;
+
+ QRect iconRect =
+ subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget);
+ QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget);
if ((option->state & State_Selected) && (option->state & State_Enabled))
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags);
//todo: move the vertical spacing stuff into subElementRect
const int vSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing);
- QStyleOptionMenuItem optionCheckBox;
if (checkable){
- QRect checkBoxRect = optionMenuItem.rect;
- checkBoxRect.setWidth(pixelMetric(PM_IndicatorWidth));
- checkBoxRect.setHeight(pixelMetric(PM_IndicatorHeight));
+ QStyleOptionMenuItem optionCheckBox;
optionCheckBox.QStyleOption::operator=(*menuItem);
- optionCheckBox.rect = checkBoxRect;
- const int moveByX = checkBoxRect.width()+vSpacing;
+ optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth));
+ optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight));
+ const int moveByX = optionCheckBox.rect.width()+vSpacing;
if (optionMenuItem.direction == Qt::LeftToRight) {
textRect.translate(moveByX,0);
iconRect.translate(moveByX, 0);
@@ -1718,21 +1747,18 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
optionMenuItem.palette.color(QPalette::Disabled, QPalette::Text)));
painter->save();
painter->setOpacity(0.5);
- QCommonStyle::drawItemText(painter, textRect, text_flags,
+ }
+ QCommonStyle::drawItemText(painter, textRect, text_flags,
optionMenuItem.palette, enabled,
optionMenuItem.text, QPalette::Text);
+ if (!enabled)
painter->restore();
- } else {
- QCommonStyle::drawItemText(painter, textRect, text_flags,
- optionMenuItem.palette, enabled,
- optionMenuItem.text, QPalette::Text);
- }
}
break;
+ case CE_MenuEmptyArea:
+ break;
#endif //QT_NO_MENU
- //todo: remove non-used widgets in final version
- case CE_MenuEmptyArea:
#ifndef QT_NO_MENUBAR
case CE_MenuBarEmptyArea:
break;
@@ -1762,19 +1788,20 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
case CE_HeaderEmptyArea:
{
QS60StylePrivate::SkinElementFlags adjFlags = flags;
- QRect mtyRect = option->rect;
+ QRect emptyAreaRect = option->rect;
+ const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth);
if (option->state & QStyle::State_Horizontal) {
- mtyRect.adjust(-2,-2,2,-2);
+ emptyAreaRect.adjust(-frameWidth,-frameWidth,frameWidth,-frameWidth);
} else {
if ( option->direction == Qt::LeftToRight ) {
- mtyRect.adjust(-2,-2,0,2);
+ emptyAreaRect.adjust(-frameWidth,-frameWidth,0,frameWidth);
adjFlags |= QS60StylePrivate::SF_PointWest;
} else {
- mtyRect.adjust(2,2,0,-2);
+ emptyAreaRect.adjust(frameWidth,frameWidth,0,-frameWidth);
adjFlags |= QS60StylePrivate::SF_PointEast;
}
}
- QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, mtyRect, adjFlags);
+ QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, emptyAreaRect, adjFlags);
}
break;
case CE_Header:
@@ -1782,19 +1809,32 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QS60StylePrivate::SkinElementFlags adjFlags = flags;
QRect mtyRect = header->rect;
QRect parentRect = widget->parentWidget()->rect();
+ const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth);
if (header->orientation == Qt::Horizontal) {
- mtyRect.adjust(-2,-2,2,-2);
+ mtyRect.adjust(-frameWidth,-frameWidth,frameWidth,-frameWidth);
} else {
if ( header->direction == Qt::LeftToRight ) {
- mtyRect.adjust(-2,-2,0,2);
+ mtyRect.adjust(-frameWidth,-frameWidth,0,frameWidth);
adjFlags |= QS60StylePrivate::SF_PointWest;
} else {
- mtyRect.adjust(2,2,0,-2);
+ mtyRect.adjust(frameWidth,frameWidth,0,-frameWidth);
adjFlags |= QS60StylePrivate::SF_PointEast;
}
}
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, mtyRect, adjFlags);
- QCommonStyle::drawControl(element, header, painter, widget);
+
+ QRegion clipRegion = painter->clipRegion();
+ painter->setClipRect(option->rect);
+ drawControl(CE_HeaderSection, header, painter, widget);
+ QStyleOptionHeader subopt = *header;
+ subopt.rect = subElementRect(SE_HeaderLabel, header, widget);
+ if (subopt.rect.isValid())
+ drawControl(CE_HeaderLabel, &subopt, painter, widget);
+ if (header->sortIndicator != QStyleOptionHeader::None) {
+ subopt.rect = subElementRect(SE_HeaderArrow, option, widget);
+ drawPrimitive(PE_IndicatorHeaderArrow, &subopt, painter, widget);
+ }
+ painter->setClipRegion(clipRegion);
}
break;
#ifndef QT_NO_TOOLBAR
@@ -1802,6 +1842,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
const QToolBar *tbWidget = qobject_cast<const QToolBar *>(widget);
+ //toolbar within a toolbar, skip
if (!tbWidget || (widget && qobject_cast<QToolBar *>(widget->parentWidget())))
break;
@@ -1839,48 +1880,12 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
}
break;
#endif //QT_NO_TOOLBAR
-
case CE_ShapedFrame:
- case CE_MenuVMargin:
- case CE_MenuHMargin:
-#ifndef QT_NO_MENU
- case CE_MenuScroller:
- case CE_MenuTearoff:
-#endif //QT_NO_MENU
-
- case CE_CheckBox:
- case CE_RadioButton:
-#ifndef QT_NO_TABBAR
- case CE_TabBarTab:
-#endif //QT_NO_TABBAR
-#ifndef QT_NO_PROGRESSBAR
- case CE_ProgressBar:
-#endif // QT_NO_PROGRESSBAR
- case CE_Q3DockWindowEmptyArea:
-#ifndef QT_NO_SIZEGRIP
- case CE_SizeGrip:
-#endif //QT_NO_SIZEGRIP
- case CE_Splitter:
-#ifndef QT_NO_RUBBERBAND
- case CE_RubberBand:
-#endif //QT_NO_RUBBERBAND
-#ifndef QT_NO_DOCKWIDGET
- case CE_DockWidgetTitle:
-#endif //QT_NO_DOCKWIDGET
- case CE_ScrollBarAddLine:
- case CE_ScrollBarSubLine:
- case CE_ScrollBarAddPage:
- case CE_ScrollBarSubPage:
- case CE_ScrollBarSlider:
- case CE_ScrollBarFirst:
- case CE_ScrollBarLast:
- case CE_FocusFrame:
-#ifndef QT_NO_TOOLBOX
- case CE_ToolBoxTab:
- case CE_ToolBoxTabShape:
- case CE_ToolBoxTabLabel:
-#endif //QT_NO_TOOLBOX
- case CE_ColumnViewGrip:
+ if (qobject_cast<const QTextEdit *>(widget))
+ QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags);
+ if (option->state & State_HasFocus)
+ drawPrimitive(PE_FrameFocusRect, option, painter, widget);
+ break;
default:
QCommonStyle::drawControl(element, option, painter, widget);
}
@@ -1919,6 +1924,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
}
break;
case PE_IndicatorViewItemCheck:
+#ifndef QT_NO_ITEMVIEWS
if (const QListView *listItem = (qobject_cast<const QListView *>(widget))) {
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
const bool checkBoxVisible = vopt->features & QStyleOptionViewItemV2::HasCheckIndicator;
@@ -1931,7 +1937,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
} else if (option->state & QStyle::State_Selected) {
QRect tickRect = option->rect;
const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth);
- // adjust tickmark rect to exclude frame border
+ // adjust tickmark rect to exclude frame border
tickRect.adjust(0,-frameBorderWidth,0,-frameBorderWidth);
QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd;
QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect,
@@ -1939,9 +1945,9 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
}
}
}
+#endif //QT_NO_ITEMVIEWS
break;
- case PE_IndicatorRadioButton:
- {
+ case PE_IndicatorRadioButton: {
QRect buttonRect = option->rect;
//there is empty (a. 33%) space in svg graphics for radiobutton
const qreal reduceWidth = (qreal)buttonRect.width()/3.0;
@@ -1964,8 +1970,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_PanelButtonCommand:
case PE_PanelButtonTool:
case PE_PanelButtonBevel:
- case PE_FrameButtonBevel:
- {
+ case PE_FrameButtonBevel: {
const bool isPressed = option->state & QStyle::State_Sunken;
const QS60StylePrivate::SkinElements skinElement =
isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal;
@@ -1976,8 +1981,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_IndicatorArrowDown:
case PE_IndicatorArrowLeft:
case PE_IndicatorArrowRight:
- case PE_IndicatorArrowUp:
- {
+ case PE_IndicatorArrowUp: {
QS60StyleEnums::SkinParts skinPart;
if (element==PE_IndicatorArrowDown)
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowDown;
@@ -1987,7 +1991,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowRight;
else if (element==PE_IndicatorArrowUp)
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowUp;
-
+
QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags);
}
break;
@@ -1997,11 +2001,11 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_IndicatorSpinUp:
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
QStyleOptionSpinBox optionSpinBox = *spinBox;
- const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ?
- QS60StyleEnums::SP_QgnGrafScrollArrowUp :
+ const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ?
+ QS60StyleEnums::SP_QgnGrafScrollArrowUp :
QS60StyleEnums::SP_QgnGrafScrollArrowDown;
const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6;
- optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
+ optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags);
}
#ifndef QT_NO_COMBOBOX
@@ -2010,11 +2014,11 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown;
QStyleOptionFrame comboBox = *cmb;
const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6;
- comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
+ comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags);
}
#endif //QT_NO_COMBOBOX
- break;
+ break;
case PE_IndicatorSpinMinus:
case PE_IndicatorSpinPlus:
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
@@ -2025,15 +2029,27 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
// We want to draw down arrow here for comboboxes as well.
QStyleOptionFrame comboBox = *cmb;
- comboBox.rect.adjust(0,2,0,-2);
+ const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth);
+ comboBox.rect.adjust(0,frameWidth,0,-frameWidth);
QCommonStyle::drawPrimitive(element, &comboBox, painter, widget);
}
#endif //QT_NO_COMBOBOX
break;
#endif //QT_NO_SPINBOX
case PE_FrameFocusRect:
- if (!(widget && qobject_cast<const QCalendarWidget *>(widget->parent())) ||
- qobject_cast<const QComboBoxListView *>(widget)) {
+// Calendar widget and combox both do not use styled itemDelegate
+ if ( widget && (
+#ifndef QT_NO_CALENDARWIDGET
+ (qobject_cast<const QCalendarWidget *>(widget->parent()))
+#else
+ false
+#endif //QT_NO_CALENDARWIDGET
+#ifndef QT_NO_COMBOBOX
+ || (qobject_cast<const QComboBoxListView *>(widget))
+#else
+ || false
+#endif //QT_NO_COMBOBOX
+ )) {
// no focus selection for touch
if (option->state & State_HasFocus && !QS60StylePrivate::isTouchSupported()) {
painter->save();
@@ -2062,11 +2078,16 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
}
break;
case PE_Widget:
- if (QS60StylePrivate::isSkinnableDialog(widget) ||
- qobject_cast<const QComboBoxListView *>(widget) ||
- qobject_cast<const QMenu *> (widget)) {
- QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_OptionsMenu;
- QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags);
+ if (QS60StylePrivate::drawsOwnThemeBackground(widget)
+#ifndef QT_NO_COMBOBOX
+ || qobject_cast<const QComboBoxListView *>(widget)
+#endif //QT_NO_COMBOBOX
+#ifndef QT_NO_MENU
+ || qobject_cast<const QMenu *> (widget)
+#endif //QT_NO_MENU
+ ) {
+ QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_OptionsMenu;
+ QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags);
}
break;
case PE_FrameWindow:
@@ -2132,8 +2153,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
break; //disable frame in menu
case PE_IndicatorBranch:
- {
#if defined(Q_WS_S60)
+ // 3.1 AVKON UI does not have tree view component, use common style for drawing there
if (QSysInfo::s60Version() == QSysInfo::SV_S60_3_1) {
#else
if (true) {
@@ -2157,29 +2178,26 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
drawSkinPart = true;
}
- if ( drawSkinPart ) {
- QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect,
- (flags | QS60StylePrivate::SF_ColorSkinned));
- }
-
+ if ( drawSkinPart )
+ QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags);
+
if (option->state & State_Children) {
- QS60StyleEnums::SkinParts skinPart =
- (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper;
+ QS60StyleEnums::SkinParts skinPart =
+ (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper;
int minDimension = qMin(option->rect.width(), option->rect.height());
const int resizeValue = minDimension >> 1;
minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon.
QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension));
int verticalMagic(0);
// magic values for positioning svg icon.
- if (option->rect.width() <= option->rect.height())
- verticalMagic = 3;
+ if (option->rect.width() <= option->rect.height())
+ verticalMagic = 3;
iconRect.translate(3, verticalMagic - resizeValue);
- QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags);
- }
+ QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags);
+ }
}
- }
- break;
-
+ break;
+
// todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases
case PE_FrameLineEdit:
case PE_IndicatorButtonDropDown:
@@ -2210,18 +2228,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
}
}
-/*!
- \reimp - sets the default colors
-*/
-void QS60Style::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette & palette, bool enabled, const QString &text, QPalette::ColorRole textRole) const
-{
- QPalette override = palette;
- QCommonStyle::drawItemText(painter, rectangle, alignment, override, enabled, text, textRole);
-}
-
-/*!
- \reimp
-*/
+/*! \reimp */
int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
{
int metricValue = QS60StylePrivate::pixelMetric(metric);
@@ -2229,7 +2236,6 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const
metricValue = QCommonStyle::pixelMetric(metric, option, widget);
if (metric == PM_SubMenuOverlap && widget){
- const int widgetWidth = widget->width();
const QMenu *menu = qobject_cast<const QMenu *>(widget);
if (menu && menu->activeAction() && menu->activeAction()->menu()) {
const int menuWidth = menu->activeAction()->menu()->sizeHint().width();
@@ -2238,6 +2244,7 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const
}
return metricValue;
}
+
/*! \reimp */
QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
const QSize &csz, const QWidget *widget) const
@@ -2247,7 +2254,7 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
case CT_PushButton:
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);
if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget)))
- if (buttonWidget->isCheckable())
+ if (buttonWidget->isCheckable())
sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0);
break;
case CT_LineEdit:
@@ -2260,22 +2267,19 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
}
return sz;
}
+
/*! \reimp */
int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *widget,
QStyleHintReturn *hret) const
{
int retValue = -1;
switch (sh) {
- case SH_Table_GridLineColor: {
- QColor lineColor = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors,2,0);
- retValue = lineColor.rgb();
- }
- break;
- case SH_GroupBox_TextLabelColor: {
- QColor groupBoxTxtColor = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors,6,0);
- retValue = groupBoxTxtColor.rgb();
- }
- break;
+ case SH_Table_GridLineColor:
+ retValue = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors,2,0).rgb();
+ break;
+ case SH_GroupBox_TextLabelColor:
+ retValue = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors,6,0).rgb();
+ break;
case SH_ScrollBar_ScrollWhenPointerLeavesControl:
retValue = true;
break;
@@ -2289,10 +2293,39 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
retValue = '*';
break;
case SH_ComboBox_PopupFrameStyle:
- retValue = QFrame::NoFrame;
+ retValue = QFrame::NoFrame | QFrame::Plain;
break;
case SH_Dial_BackgroundRole:
retValue = QPalette::Base;
+ break;
+ case SH_ItemView_ActivateItemOnSingleClick:
+ retValue = true;
+ break;
+ case SH_ProgressDialog_TextLabelAlignment:
+ retValue = (QApplication::layoutDirection() == Qt::LeftToRight) ?
+ Qt::AlignLeft :
+ Qt::AlignRight;
+ break;
+ case SH_Menu_SubMenuPopupDelay:
+ retValue = 300;
+ break;
+ case SH_Menu_Scrollable:
+ retValue = true;
+ break;
+ case SH_Menu_SelectionWrap:
+ retValue = true;
+ break;
+ case SH_ItemView_ShowDecorationSelected:
+ retValue = true;
+ break;
+ case SH_ToolBar_Movable:
+ retValue = false;
+ break;
+ case SH_BlinkCursorWhenTextSelected:
+ retValue = true;
+ break;
+ case SH_UnderlineShortcut:
+ retValue = 0;
default:
break;
}
@@ -2301,10 +2334,7 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
return retValue;
}
-
-/*!
- \reimp
-*/
+/*! \reimp */
QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl scontrol, const QWidget *widget) const
{
QRect ret;
@@ -2324,6 +2354,11 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
sliderlen = (qint64(scrollbarOption->pageStep) * maxlen) / (range + scrollbarOption->pageStep);
int slidermin = pixelMetric(PM_ScrollBarSliderMin, scrollbarOption, widget);
+ if (isHorizontal && slidermin < scrollBarRect.height())
+ slidermin = scrollBarRect.height();
+ else if (!isHorizontal && slidermin < scrollBarRect.width())
+ slidermin = scrollBarRect.width();
+
if (sliderlen < slidermin || range > (INT_MAX>>1))
sliderlen = slidermin;
if (sliderlen > maxlen)
@@ -2339,35 +2374,33 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
scrollbarOption->upsideDown);
switch (scontrol) {
- case SC_ScrollBarSubLine: // top/left button
- case SC_ScrollBarAddLine: // bottom/right button
- break;
- case SC_ScrollBarSubPage: // between top/left button and slider
- if (isHorizontal)
- ret.setRect(0, 0, sliderstart, scrollBarRect.height());
- else
- ret.setRect(0, 0, scrollBarRect.width(), sliderstart);
- break;
- case SC_ScrollBarAddPage: // between bottom/right button and slider
- {
+ case SC_ScrollBarSubPage: // between top/left button and slider
+ if (isHorizontal)
+ ret.setRect(0, 0, sliderstart, scrollBarRect.height());
+ else
+ ret.setRect(0, 0, scrollBarRect.width(), sliderstart);
+ break;
+ case SC_ScrollBarAddPage: { // between bottom/right button and slider
const int addPageLength = sliderstart + sliderlen;
if (isHorizontal)
ret = scrollBarRect.adjusted(addPageLength, 0, 0, 0);
else
ret = scrollBarRect.adjusted(0, addPageLength, 0, 0);
- }
- break;
- case SC_ScrollBarGroove:
- ret = scrollBarRect;
- break;
- case SC_ScrollBarSlider:
- if (scrollbarOption->orientation == Qt::Horizontal)
- ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height());
- else
- ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen);
- break;
- default:
- break;
+ }
+ break;
+ case SC_ScrollBarGroove:
+ ret = scrollBarRect;
+ break;
+ case SC_ScrollBarSlider:
+ if (scrollbarOption->orientation == Qt::Horizontal)
+ ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height());
+ else
+ ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen);
+ break;
+ case SC_ScrollBarSubLine: // top/left button
+ case SC_ScrollBarAddLine: // bottom/right button
+ default:
+ break;
}
ret = visualRect(scrollbarOption->direction, scrollBarRect, ret);
}
@@ -2387,35 +2420,35 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
const int x = spinbox->rect.x() + spinbox->rect.width() - frameThickness - 2*buttonSize.width();
switch (scontrol) {
- case SC_SpinBoxUp:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- return QRect();
- ret = QRect(x, y, buttonWidth, buttonSize.height());
- break;
- case SC_SpinBoxDown:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- return QRect();
- ret = QRect(x+buttonSize.width(), y, buttonWidth, buttonSize.height());
- break;
- case SC_SpinBoxEditField:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- ret = QRect(
- frameThickness,
- frameThickness,
- spinbox->rect.width() - 2*frameThickness,
- spinbox->rect.height() - 2*frameThickness);
- else
- ret = QRect(
- frameThickness,
- frameThickness,
- x - frameThickness,
- spinbox->rect.height() - 2*frameThickness);
- break;
- case SC_SpinBoxFrame:
- ret = spinbox->rect;
- break;
- default:
- break;
+ case SC_SpinBoxUp:
+ if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
+ return QRect();
+ ret = QRect(x, y, buttonWidth, buttonSize.height());
+ break;
+ case SC_SpinBoxDown:
+ if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
+ return QRect();
+ ret = QRect(x+buttonSize.width(), y, buttonWidth, buttonSize.height());
+ break;
+ case SC_SpinBoxEditField:
+ if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
+ ret = QRect(
+ frameThickness,
+ frameThickness,
+ spinbox->rect.width() - 2*frameThickness,
+ spinbox->rect.height() - 2*frameThickness);
+ else
+ ret = QRect(
+ frameThickness,
+ frameThickness,
+ x - frameThickness,
+ spinbox->rect.height() - 2*frameThickness);
+ break;
+ case SC_SpinBoxFrame:
+ ret = spinbox->rect;
+ break;
+ default:
+ break;
}
ret = visualRect(spinbox->direction, spinbox->rect, ret);
}
@@ -2429,7 +2462,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
// lets use spinbox frame here as well, as no combobox specific value available.
const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0;
const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize);
- int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth;
+ const int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth;
const int ypos = cmb->rect.y();
QSize buttonSize;
@@ -2458,26 +2491,26 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
ret = QCommonStyle::subControlRect(control, option, scontrol, widget);
switch (scontrol) {
- case SC_GroupBoxCheckBox: //fallthrough
- case SC_GroupBoxLabel:
- //slightly indent text and boxes, so that dialog border does not mess with them.
- const int horizontalSpacing =
- QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
- const int bottomMargin = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutBottomMargin);
- ret.adjust(2,horizontalSpacing-3,0,0);
- break;
- case SC_GroupBoxFrame: {
- const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget);
- const int tbHeight = textBox.height();
- ret.translate(0, -ret.y());
- // include title to within the groupBox frame
- ret.setHeight(ret.height()+tbHeight);
- if (widget && ret.bottom() > widget->rect().bottom())
- ret.setBottom(widget->rect().bottom());
- }
- break;
- default:
- break;
+ case SC_GroupBoxCheckBox: //fallthrough
+ case SC_GroupBoxLabel: {
+ //slightly indent text and boxes, so that dialog border does not mess with them.
+ const int horizontalSpacing =
+ QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
+ ret.adjust(2,horizontalSpacing-3,0,0);
+ }
+ break;
+ case SC_GroupBoxFrame: {
+ const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget);
+ const int tbHeight = textBox.height();
+ ret.translate(0, -ret.y());
+ // include title to within the groupBox frame
+ ret.setHeight(ret.height()+tbHeight);
+ if (widget && ret.bottom() > widget->rect().bottom())
+ ret.setBottom(widget->rect().bottom());
+ }
+ break;
+ default:
+ break;
}
}
break;
@@ -2494,9 +2527,8 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
case SE_LineEditContents: {
// in S60 the input text box doesn't start from line Edit's TL, but
// a bit indented.
- // todo: Should we NOT do this for combo boxes and spin boxes?
QRect lineEditRect = opt->rect;
- int adjustment = opt->rect.height()>>2;
+ const int adjustment = opt->rect.height()>>2;
lineEditRect.adjust(adjustment,0,0,0);
ret = lineEditRect;
}
@@ -2568,13 +2600,10 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
}
} else if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
- const bool subMenu = menuItem->menuItemType == QStyleOptionMenuItem::SubMenu;
- int indicatorWidth = checkable ?
+ const int indicatorWidth = checkable ?
pixelMetric(PM_ListViewIconSize, opt, widget) :
pixelMetric(PM_SmallIconSize, opt, widget);
ret = menuItem->rect;
- const int verticalSpacing =
- QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing);
if (element == SE_ItemViewItemDecoration) {
if (menuItem->direction == Qt::RightToLeft)
@@ -2591,11 +2620,10 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
// Make room for submenu indicator
if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu){
// submenu indicator is very small, so lets halve the rect
- indicatorWidth = indicatorWidth >> 1;
if (menuItem->direction == Qt::LeftToRight)
- ret.adjust(0,0,-indicatorWidth,0);
+ ret.adjust(0,0,-(indicatorWidth >> 1),0);
else
- ret.adjust(indicatorWidth,0,0,0);
+ ret.adjust((indicatorWidth >> 1),0,0,0);
}
}
}
@@ -2624,11 +2652,15 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
// Move rect and make it slightly smaller, so that
// a) highlight border does not cross the rect
// b) in s60 list checkbox is smaller than normal checkbox
- ret.setRect(opt->rect.left()+3, opt->rect.top() + heightOffset, indicatorWidth-3, indicatorHeight-3);
+ //todo; magic three
+ ret.setRect(opt->rect.left()+3, opt->rect.top() + heightOffset,
+ indicatorWidth-3, indicatorHeight-3);
} else {
ret.setRect(opt->rect.right() - indicatorWidth - spacing, opt->rect.top() + heightOffset,
indicatorWidth, indicatorHeight);
}
+ } else {
+ ret = QCommonStyle::subElementRect(element, opt, widget);
}
break;
case SE_HeaderLabel:
@@ -2658,6 +2690,88 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
return ret;
}
+void QS60Style::polish(QWidget *widget)
+{
+ Q_D(const QS60Style);
+ QCommonStyle::polish(widget);
+
+ if (!widget)
+ return;
+
+ if (false
+#ifndef QT_NO_SCROLLBAR
+ || qobject_cast<QScrollBar *>(widget)
+#endif
+ ) {
+ widget->setAttribute(Qt::WA_OpaquePaintEvent, false);
+ }
+
+ if (QS60StylePrivate::drawsOwnThemeBackground(widget)) {
+ widget->setAttribute(Qt::WA_StyledBackground);
+ } else if (false
+#ifndef QT_NO_MENU
+ || qobject_cast<const QMenu *> (widget)
+#endif // QT_NO_MENU
+ ) {
+ widget->setAttribute(Qt::WA_StyledBackground);
+ } else if (false
+#ifndef QT_NO_COMBOBOX
+ || qobject_cast<const QComboBoxListView *>(widget)
+#endif //QT_NO_COMBOBOX
+ ) {
+ widget->setAttribute(Qt::WA_StyledBackground);
+ }
+ d->setThemePalette(widget);
+ d->setFont(widget);
+}
+
+void QS60Style::unpolish(QWidget *widget)
+{
+ if (false
+ #ifndef QT_NO_SCROLLBAR
+ || qobject_cast<QScrollBar *>(widget)
+ #endif
+ )
+ widget->setAttribute(Qt::WA_OpaquePaintEvent);
+
+ if (QS60StylePrivate::drawsOwnThemeBackground(widget)) {
+ widget->setAttribute(Qt::WA_StyledBackground, false);
+ } else if (false
+#ifndef QT_NO_MENU
+ || qobject_cast<const QMenu *> (widget)
+#endif // QT_NO_MENU
+ ) {
+ widget->setAttribute(Qt::WA_StyledBackground, false);
+ } else if (false
+#ifndef QT_NO_COMBOBOX
+ || qobject_cast<const QComboBoxListView *>(widget)
+#endif //QT_NO_COMBOBOX
+ ) {
+ widget->setAttribute(Qt::WA_StyledBackground, false);
+ }
+
+ if (widget)
+ widget->setPalette(QPalette());
+
+ QCommonStyle::unpolish(widget);
+}
+
+void QS60Style::polish(QApplication *application)
+{
+ Q_D(QS60Style);
+ d->m_originalPalette = application->palette();
+ d->setThemePalette(application);
+}
+
+void QS60Style::unpolish(QApplication *application)
+{
+ Q_UNUSED(application)
+ Q_D(QS60Style);
+ const QPalette newPalette = QApplication::style()->standardPalette();
+ QApplication::setPalette(newPalette);
+ QApplicationPrivate::setSystemPalette(d->m_originalPalette);
+}
+
void QS60Style::setStyleProperty(const char *name, const QVariant &value)
{
Q_D(QS60Style);
@@ -2678,7 +2792,9 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon,
QS60StyleEnums::SkinParts part;
QS60StylePrivate::SkinElementFlags adjustedFlags;
if (option)
- adjustedFlags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled;
+ adjustedFlags = (option->state & State_Enabled) ?
+ QS60StylePrivate::SF_StateEnabled :
+ QS60StylePrivate::SF_StateDisabled;
switch(standardIcon) {
case QStyle::SP_MessageBoxWarning:
@@ -2755,6 +2871,29 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon,
QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap);
}
+extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget);
+
+bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset,
+ const QBrush &brush)
+{
+ const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture());
+ if (backgroundTexture.cacheKey() != brush.texture().cacheKey())
+ return false;
+
+ const QPaintDevice *target = painter->device();
+ if (target->devType() == QInternal::Widget) {
+ const QWidget *widget = static_cast<const QWidget *>(target);
+ const QRegion translated = rgn.translated(offset);
+ const QVector<QRect> &rects = translated.rects();
+ for (int i = 0; i < rects.size(); ++i) {
+ const QRect rect(rects.at(i));
+ painter->drawPixmap(rect.topLeft(), backgroundTexture,
+ rect.translated(qt_s60_fill_background_offset(widget)));
+ }
+ }
+ return true;
+}
+
QT_END_NAMESPACE
#endif // QT_NO_STYLE_S60 || QT_PLUGIN
diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h
index 945e182..d8e9a40 100644
--- a/src/gui/styles/qs60style.h
+++ b/src/gui/styles/qs60style.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $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$
**
****************************************************************************/
@@ -36,7 +66,6 @@ public:
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
- void drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w = 0) const;
int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
@@ -56,22 +85,23 @@ public:
static QStringList colorListKeys();
void setS60Theme(const QHash<QString, QPicture> &parts,
const QHash<QPair<QString , int>, QColor> &colors);
+ bool loadS60ThemeFromBlob(const QString &blobFile);
+ bool saveS60ThemeToBlob(const QString &blobFile) const;
#endif // !Q_WS_S60
#ifdef Q_WS_S60
-public slots:
+public Q_SLOTS:
void handleDynamicLayoutVariantSwitch();
void handleSkinChange();
#endif // Q_WS_S60
-protected slots:
+protected Q_SLOTS:
QIcon standardIconImplementation(
StandardPixmap standardIcon, const QStyleOption * option = 0, const QWidget * widget = 0 ) const;
private:
Q_DISABLE_COPY(QS60Style)
friend class QStyleFactory;
- QPalette originalPalette;
};
#endif // QT_NO_STYLE_S60
diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h
index da34efb..7240978 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/gui/styles/qs60style_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $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$
**
****************************************************************************/
@@ -113,7 +143,7 @@ public:
SP_QgnPropFolderCurrent,
SP_QgnPropFolderSmall,
SP_QgnPropFolderSmallNew,
- SP_QgnPropPhoneMemcLarge,
+ SP_QgnPropPhoneMemcLarge,
SP_QsnCpScrollHandleBottomPressed, //ScrollBar handle, pressed state
SP_QsnCpScrollHandleMiddlePressed,
SP_QsnCpScrollHandleTopPressed,
@@ -231,7 +261,25 @@ public:
SP_QsnFrSctrlButtonSideBPressed,
SP_QsnFrSctrlButtonSideLPressed,
SP_QsnFrSctrlButtonSideRPressed,
- SP_QsnFrSctrlButtonCenterPressed
+ SP_QsnFrSctrlButtonCenterPressed,
+ SP_QsnFrButtonCornerTlInactive, // Inactive button
+ SP_QsnFrButtonCornerTrInactive,
+ SP_QsnFrButtonCornerBlInactive,
+ SP_QsnFrButtonCornerBrInactive,
+ SP_QsnFrButtonSideTInactive,
+ SP_QsnFrButtonSideBInactive,
+ SP_QsnFrButtonSideLInactive,
+ SP_QsnFrButtonSideRInactive,
+ SP_QsnFrButtonCenterInactive,
+ SP_QsnFrNotepadCornerTl,
+ SP_QsnFrNotepadCornerTr,
+ SP_QsnFrNotepadCornerBl,
+ SP_QsnFrNotepadCornerBr,
+ SP_QsnFrNotepadSideT,
+ SP_QsnFrNotepadSideB,
+ SP_QsnFrNotepadSideL,
+ SP_QsnFrNotepadSideR,
+ SP_QsnFrNotepadCenter
};
enum ColorLists {
@@ -292,6 +340,8 @@ public:
SE_PanelBackground,
SE_ScrollBarHandlePressedHorizontal, //only for 5.0+
SE_ScrollBarHandlePressedVertical,
+ SE_ButtonInactive,
+ SE_Editor,
};
enum SkinFrameElements {
@@ -307,7 +357,9 @@ public:
SF_ToolBar,
SF_ToolBarButton,
SF_ToolBarButtonPressed,
- SF_PanelBackground
+ SF_PanelBackground,
+ SF_ButtonInactive,
+ SF_Editor,
};
enum SkinElementFlag {
@@ -320,6 +372,13 @@ public:
SF_StateDisabled = 0x0020,
SF_ColorSkinned = 0x0040,
};
+
+ enum CacheClearReason {
+ CC_UndefinedChange = 0,
+ CC_LayoutChange,
+ CC_ThemeChange
+ };
+
Q_DECLARE_FLAGS(SkinElementFlags, SkinElementFlag)
// draws skin element
@@ -344,27 +403,35 @@ public:
int index, const QStyleOption *option);
// gets state specific color
static QColor stateColor(const QColor &color, const QStyleOption *option);
+ // gets lighter color than base color
static QColor lighterColor(const QColor &baseColor);
- static bool isSkinnableDialog(const QWidget *widget);
- // gets layout
- static const QHash<QStyle::PixelMetric, int> &s60StyleLayout();
+ //deduces if the given widget should have separately themeable background
+ static bool drawsOwnThemeBackground(const QWidget *widget);
QFont s60Font(QS60StyleEnums::FontCategories fontCategory,
int pointSize = -1) const;
- void clearCaches();
- static QPixmap backgroundTexture();
+ // clears all style caches (fonts, colors, pixmaps)
+ void clearCaches(CacheClearReason reason = CC_UndefinedChange);
+
+ // themed main background oprations
+ void setBackgroundTexture(QApplication *application) const;
+ static void deleteBackground();
static bool isTouchSupported();
static bool isToolBarBackground();
// calculates average color based on button skin graphics (minus borders).
- QColor colorFromFrameGraphics(QS60StylePrivate::SkinFrameElements frame) const;
+ QColor colorFromFrameGraphics(SkinFrameElements frame) const;
+
+ //set theme palette for application
void setThemePalette(QApplication *application) const;
- void setBackgroundTexture(QApplication *application) const;
+ //set theme palette for style option
+ void setThemePalette(QStyleOption *option) const;
+ //access to theme palette
+ static QPalette* themePalette();
static int focusRectPenWidth();
-#if defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
static const layoutHeader m_layoutHeaders[];
static const short data[][MAX_PIXELMETRICS];
@@ -374,10 +441,9 @@ public:
static short const *m_pmPointer;
// number of layouts supported by the style
static const int m_numberOfLayouts;
-#endif // defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
mutable QHash<QPair<QS60StyleEnums::FontCategories , int>, QFont> m_mappedFontsCache;
- mutable QHash<QS60StylePrivate::SkinFrameElements, QColor> m_colorCache;
+ mutable QHash<SkinFrameElements, QColor> m_colorCache;
// Has one entry per SkinFrameElements
static const struct frameElementCenter {
@@ -387,6 +453,7 @@ public:
static QPixmap frame(SkinFrameElements frame, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
+ static QPixmap backgroundTexture();
private:
static void drawPart(QS60StyleEnums::SkinParts part, QPainter *painter,
@@ -397,23 +464,36 @@ private:
static void drawFrame(SkinFrameElements frame, QPainter *painter,
const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags);
- static QSize partSize(QS60StyleEnums::SkinParts part,
- SkinElementFlags flags = KDefaultSkinElementFlags);
- static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size,
- SkinElementFlags flags = KDefaultSkinElementFlags);
static QPixmap cachedPart(QS60StyleEnums::SkinParts part, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
static QPixmap cachedFrame(SkinFrameElements frame, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
- static QFont s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize);
-
static void refreshUI();
+ // set S60 font for widget
+ void setFont(QWidget *widget) const;
+ void setThemePalette(QWidget *widget) const;
+ void setThemePalette(QPalette *palette) const;
+ void setThemePaletteHash(QPalette *palette) const;
+ static void storeThemePalette(QPalette *palette);
+ static void deleteThemePalette();
+
+ static QSize partSize(QS60StyleEnums::SkinParts part,
+ SkinElementFlags flags = KDefaultSkinElementFlags);
+ static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size,
+ SkinElementFlags flags = KDefaultSkinElementFlags);
+
+ static QFont s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize);
+
static QSize screenSize();
- static bool m_backgroundValid;
+ // Contains background texture.
+ static QPixmap *m_background;
const static SkinElementFlags KDefaultSkinElementFlags;
+ // defined theme palette
+ static QPalette *m_themePalette;
+ QPalette m_originalPalette;
};
QT_END_NAMESPACE
diff --git a/src/gui/styles/qs60style_symbian.cpp b/src/gui/styles/qs60style_s60.cpp
index 35dfe13..1f02efa 100644
--- a/src/gui/styles/qs60style_symbian.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $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$
**
****************************************************************************/
@@ -47,8 +77,10 @@ enum TSupportRelease {
ES60_3_1 = 0x0001,
ES60_3_2 = 0x0002,
ES60_5_0 = 0x0004,
+ ES60_5_1 = 0x0008,
+ ES60_5_2 = 0x0010,
// Add all new releases here
- ES60_AllReleases = ES60_3_1 | ES60_3_2 | ES60_5_0
+ ES60_AllReleases = ES60_3_1 | ES60_3_2 | ES60_5_0 | ES60_5_1 | ES60_5_2
};
typedef struct {
@@ -59,17 +91,6 @@ typedef struct {
int newMinorSkinId;
} partMapEntry;
-enum TFallbackMbmFile {
- EAvkonMbm = 0,
- ELastMbm
-};
-
-typedef struct {
- const QS60StyleEnums::SkinParts partID;
- TFallbackMbmFile fallbackFileID; //to avoid putting large char strings to table, lets only have a mapping value
- int fallbackGraphicID;
-} fallbackMapEntry;
-
class QS60StyleModeSpecifics
{
public:
@@ -80,6 +101,8 @@ public:
const QSize &size, QS60StylePrivate::SkinElementFlags flags);
static QColor colorValue(const TAknsItemID &colorGroup, int colorIndex);
static QPixmap fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask, QS60StylePrivate::SkinElementFlags flags, QImage::Format format);
+ static bool disabledPartGraphic(QS60StyleEnums::SkinParts &part);
+ static bool disabledFrameGraphic(QS60StylePrivate::SkinFrameElements &frame);
static QPixmap generateMissingThemeGraphic(QS60StyleEnums::SkinParts &part, const QSize &size, QS60StylePrivate::SkinElementFlags flags);
private:
@@ -103,187 +126,209 @@ private:
};
const partMapEntry QS60StyleModeSpecifics::m_partMap[] = {
- /* SP_QgnGrafBarWait */ {KAknsIIDQgnGrafBarWaitAnim, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafBarFrameCenter */ {KAknsIIDQgnGrafBarFrameCenter, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafBarFrameSideL */ {KAknsIIDQgnGrafBarFrameSideL, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafBarFrameSideR */ {KAknsIIDQgnGrafBarFrameSideR, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafBarProgress */ {KAknsIIDQgnGrafBarProgress, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafScrollArrowDown */ {KAknsIIDQgnGrafScrollArrowDown, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafScrollArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafScrollArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafScrollArrowUp */ {KAknsIIDQgnGrafScrollArrowUp, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafTabActiveL */ {KAknsIIDQgnGrafTabActiveL, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafTabActiveM */ {KAknsIIDQgnGrafTabActiveM, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafTabActiveR */ {KAknsIIDQgnGrafTabActiveR, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafTabPassiveL */ {KAknsIIDQgnGrafTabPassiveL, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafTabPassiveM */ {KAknsIIDQgnGrafTabPassiveM, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafTabPassiveR */ {KAknsIIDQgnGrafTabPassiveR, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiCheckboxOff */ {KAknsIIDQgnIndiCheckboxOff, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiCheckboxOn */ {KAknsIIDQgnIndiCheckboxOn, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafBarWait */ {KAknsIIDQgnGrafBarWaitAnim, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafBarFrameCenter */ {KAknsIIDQgnGrafBarFrameCenter, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafBarFrameSideL */ {KAknsIIDQgnGrafBarFrameSideL, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafBarFrameSideR */ {KAknsIIDQgnGrafBarFrameSideR, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafBarProgress */ {KAknsIIDQgnGrafBarProgress, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafScrollArrowDown */ {KAknsIIDQgnGrafScrollArrowDown, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafScrollArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafScrollArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafScrollArrowUp */ {KAknsIIDQgnGrafScrollArrowUp, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafTabActiveL */ {KAknsIIDQgnGrafTabActiveL, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafTabActiveM */ {KAknsIIDQgnGrafTabActiveM, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafTabActiveR */ {KAknsIIDQgnGrafTabActiveR, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafTabPassiveL */ {KAknsIIDQgnGrafTabPassiveL, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafTabPassiveM */ {KAknsIIDQgnGrafTabPassiveM, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafTabPassiveR */ {KAknsIIDQgnGrafTabPassiveR, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiCheckboxOff */ {KAknsIIDQgnIndiCheckboxOff, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiCheckboxOn */ {KAknsIIDQgnIndiCheckboxOn, EDrawIcon, ES60_AllReleases, -1,-1},
// Following 5 items (SP_QgnIndiHlColSuper - SP_QgnIndiHlLineStraight) are available starting from S60 release 3.2.
// In 3.1 CommonStyle drawing is used for these QTreeView elements, since no similar icons in AVKON UI.
- /* SP_QgnIndiHlColSuper */ {KAknsIIDNone, EDrawIcon, ES60_None, EAknsMajorGeneric, 0x17d5 /* KAknsIIDQgnIndiHlColSuper */},
- /* SP_QgnIndiHlExpSuper */ {KAknsIIDNone, EDrawIcon, ES60_None, EAknsMajorGeneric, 0x17d6 /* KAknsIIDQgnIndiHlExpSuper */},
- /* SP_QgnIndiHlLineBranch */ {KAknsIIDNone, EDrawIcon, ES60_None, EAknsMajorGeneric, 0x17d7 /* KAknsIIDQgnIndiHlLineBranch */},
- /* SP_QgnIndiHlLineEnd */ {KAknsIIDNone, EDrawIcon, ES60_None, EAknsMajorGeneric, 0x17d8 /* KAknsIIDQgnIndiHlLineEnd */},
- /* SP_QgnIndiHlLineStraight */ {KAknsIIDNone, EDrawIcon, ES60_None, EAknsMajorGeneric, 0x17d9 /* KAknsIIDQgnIndiHlLineStraight */},
- /* SP_QgnIndiMarkedAdd */ {KAknsIIDQgnIndiMarkedAdd, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiNaviArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiNaviArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiRadiobuttOff */ {KAknsIIDQgnIndiRadiobuttOff, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiRadiobuttOn */ {KAknsIIDQgnIndiRadiobuttOn, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiSliderEdit */ {KAknsIIDQgnIndiSliderEdit, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiSubMenu */ {KAknsIIDQgnIndiSubmenu, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnNoteErased */ {KAknsIIDQgnNoteErased, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnNoteError */ {KAknsIIDQgnNoteError, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnNoteInfo */ {KAknsIIDQgnNoteInfo, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnNoteOk */ {KAknsIIDQgnNoteOk, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnNoteQuery */ {KAknsIIDQgnNoteQuery, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnNoteWarning */ {KAknsIIDQgnNoteWarning, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnPropFileSmall */ {KAknsIIDQgnPropFileSmall, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnPropFolderCurrent */ {KAknsIIDQgnPropFolderCurrent, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnPropFolderSmall */ {KAknsIIDQgnPropFolderSmall, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnPropFolderSmallNew */ {KAknsIIDQgnPropFolderSmallNew, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnPropPhoneMemcLarge */ {KAknsIIDQgnPropPhoneMemcLarge, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiHlColSuper */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d5 /* KAknsIIDQgnIndiHlColSuper */},
+ /* SP_QgnIndiHlExpSuper */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d6 /* KAknsIIDQgnIndiHlExpSuper */},
+ /* SP_QgnIndiHlLineBranch */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d7 /* KAknsIIDQgnIndiHlLineBranch */},
+ /* SP_QgnIndiHlLineEnd */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d8 /* KAknsIIDQgnIndiHlLineEnd */},
+ /* SP_QgnIndiHlLineStraight */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d9 /* KAknsIIDQgnIndiHlLineStraight */},
+ /* SP_QgnIndiMarkedAdd */ {KAknsIIDQgnIndiMarkedAdd, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiNaviArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiNaviArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiRadiobuttOff */ {KAknsIIDQgnIndiRadiobuttOff, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiRadiobuttOn */ {KAknsIIDQgnIndiRadiobuttOn, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiSliderEdit */ {KAknsIIDQgnIndiSliderEdit, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiSubMenu */ {KAknsIIDQgnIndiSubmenu, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnNoteErased */ {KAknsIIDQgnNoteErased, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnNoteError */ {KAknsIIDQgnNoteError, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnNoteInfo */ {KAknsIIDQgnNoteInfo, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnNoteOk */ {KAknsIIDQgnNoteOk, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnNoteQuery */ {KAknsIIDQgnNoteQuery, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnNoteWarning */ {KAknsIIDQgnNoteWarning, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnPropFileSmall */ {KAknsIIDQgnPropFileSmall, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnPropFolderCurrent */ {KAknsIIDQgnPropFolderCurrent, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnPropFolderSmall */ {KAknsIIDQgnPropFolderSmall, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnPropFolderSmallNew */ {KAknsIIDQgnPropFolderSmallNew, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnPropPhoneMemcLarge */ {KAknsIIDQgnPropPhoneMemcLarge, EDrawIcon, ES60_AllReleases, -1,-1},
// 3.1 & 3.2 do not have pressed state for scrollbar, so use normal scrollbar graphics instead.
- /* SP_QsnCpScrollHandleBottomPressed*/ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20f8}, /*KAknsIIDQsnCpScrollHandleBottomPressed*/
- /* SP_QsnCpScrollHandleMiddlePressed*/ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20f9}, /*KAknsIIDQsnCpScrollHandleMiddlePressed*/
- /* SP_QsnCpScrollHandleTopPressed*/ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20fa}, /*KAknsIIDQsnCpScrollHandleTopPressed*/
-
- /* SP_QsnBgScreen */ {KAknsIIDQsnBgScreen, EDrawBackground, ES60_AllReleases, -1,-1},
-
- /* SP_QsnCpScrollBgBottom */ {KAknsIIDQsnCpScrollBgBottom, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QsnCpScrollBgMiddle */ {KAknsIIDQsnCpScrollBgMiddle, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QsnCpScrollBgTop */ {KAknsIIDQsnCpScrollBgTop, EDrawIcon, ES60_AllReleases, -1,-1},
-
- /* SP_QsnCpScrollHandleBottom */ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QsnCpScrollHandleMiddle */ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QsnCpScrollHandleTop */ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrButtonTbCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideT */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideB */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideL */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideR */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCenter */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrButtonTbCornerTlPressed */{KAknsIIDQsnFrButtonTbCornerTlPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCornerTrPressed */{KAknsIIDQsnFrButtonTbCornerTrPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCornerBlPressed */{KAknsIIDQsnFrButtonTbCornerBlPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCornerBrPressed */{KAknsIIDQsnFrButtonTbCornerBrPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideTPressed */ {KAknsIIDQsnFrButtonTbSideTPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideBPressed */ {KAknsIIDQsnFrButtonTbSideBPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideLPressed */ {KAknsIIDQsnFrButtonTbSideLPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideRPressed */ {KAknsIIDQsnFrButtonTbSideRPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCenterPressed */ {KAknsIIDQsnFrButtonTbCenterPressed, EDrawIcon, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrCaleCornerTl */ {KAknsIIDQsnFrCaleCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleCornerTr */ {KAknsIIDQsnFrCaleCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleCornerBl */ {KAknsIIDQsnFrCaleCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleCornerBr */ {KAknsIIDQsnFrCaleCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleGSideT */ {KAknsIIDQsnFrCaleSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleGSideB */ {KAknsIIDQsnFrCaleSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleGSideL */ {KAknsIIDQsnFrCaleSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleGSideR */ {KAknsIIDQsnFrCaleSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleCenter */ {KAknsIIDQsnFrCaleCenter, ENoDraw, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrCaleHeadingCornerTl */ {KAknsIIDQsnFrCaleHeadingCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingCornerTr */ {KAknsIIDQsnFrCaleHeadingCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingCornerBl */ {KAknsIIDQsnFrCaleHeadingCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingCornerBr */ {KAknsIIDQsnFrCaleHeadingCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingSideT */ {KAknsIIDQsnFrCaleHeadingSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingSideB */ {KAknsIIDQsnFrCaleHeadingSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingSideL */ {KAknsIIDQsnFrCaleHeadingSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingSideR */ {KAknsIIDQsnFrCaleHeadingSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingCenter */ {KAknsIIDQsnFrCaleHeadingCenter, ENoDraw, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrInputCornerTl */ {KAknsIIDQsnFrInputCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputCornerTr */ {KAknsIIDQsnFrInputCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputCornerBl */ {KAknsIIDQsnFrInputCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputCornerBr */ {KAknsIIDQsnFrInputCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputSideT */ {KAknsIIDQsnFrInputSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputSideB */ {KAknsIIDQsnFrInputSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputSideL */ {KAknsIIDQsnFrInputSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputSideR */ {KAknsIIDQsnFrInputSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputCenter */ {KAknsIIDQsnFrInputCenter, ENoDraw, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrListCornerTl */ {KAknsIIDQsnFrListCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListCornerTr */ {KAknsIIDQsnFrListCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListCornerBl */ {KAknsIIDQsnFrListCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListCornerBr */ {KAknsIIDQsnFrListCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListSideT */ {KAknsIIDQsnFrListSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListSideB */ {KAknsIIDQsnFrListSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListSideL */ {KAknsIIDQsnFrListSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListSideR */ {KAknsIIDQsnFrListSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListCenter */ {KAknsIIDQsnFrListCenter, ENoDraw, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrPopupCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupCornerTr */ {KAknsIIDQsnFrPopupCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupCornerBl */ {KAknsIIDQsnFrPopupCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupCornerBr */ {KAknsIIDQsnFrPopupCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupSideT */ {KAknsIIDQsnFrPopupSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnCpScrollHandleBottomPressed*/ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20f8}, /*KAknsIIDQsnCpScrollHandleBottomPressed*/
+ /* SP_QsnCpScrollHandleMiddlePressed*/ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20f9}, /*KAknsIIDQsnCpScrollHandleMiddlePressed*/
+ /* SP_QsnCpScrollHandleTopPressed*/ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20fa}, /*KAknsIIDQsnCpScrollHandleTopPressed*/
+
+ /* SP_QsnBgScreen */ {KAknsIIDQsnBgScreen, EDrawBackground, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnCpScrollBgBottom */ {KAknsIIDQsnCpScrollBgBottom, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QsnCpScrollBgMiddle */ {KAknsIIDQsnCpScrollBgMiddle, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QsnCpScrollBgTop */ {KAknsIIDQsnCpScrollBgTop, EDrawIcon, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnCpScrollHandleBottom */ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QsnCpScrollHandleMiddle */ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QsnCpScrollHandleTop */ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrButtonTbCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, //todo: use "normal button" from 5.0 onwards
+ /* SP_QsnFrButtonTbCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideT */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideB */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideL */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideR */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCenter */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrButtonTbCornerTlPressed */{KAknsIIDQsnFrButtonTbCornerTlPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCornerTrPressed */{KAknsIIDQsnFrButtonTbCornerTrPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCornerBlPressed */{KAknsIIDQsnFrButtonTbCornerBlPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCornerBrPressed */{KAknsIIDQsnFrButtonTbCornerBrPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideTPressed */ {KAknsIIDQsnFrButtonTbSideTPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideBPressed */ {KAknsIIDQsnFrButtonTbSideBPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideLPressed */ {KAknsIIDQsnFrButtonTbSideLPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideRPressed */ {KAknsIIDQsnFrButtonTbSideRPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCenterPressed */ {KAknsIIDQsnFrButtonTbCenterPressed, EDrawIcon, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrCaleCornerTl */ {KAknsIIDQsnFrCaleCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleCornerTr */ {KAknsIIDQsnFrCaleCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleCornerBl */ {KAknsIIDQsnFrCaleCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleCornerBr */ {KAknsIIDQsnFrCaleCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleGSideT */ {KAknsIIDQsnFrCaleSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleGSideB */ {KAknsIIDQsnFrCaleSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleGSideL */ {KAknsIIDQsnFrCaleSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleGSideR */ {KAknsIIDQsnFrCaleSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleCenter */ {KAknsIIDQsnFrCaleCenter, ENoDraw, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrCaleHeadingCornerTl */ {KAknsIIDQsnFrCaleHeadingCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingCornerTr */ {KAknsIIDQsnFrCaleHeadingCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingCornerBl */ {KAknsIIDQsnFrCaleHeadingCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingCornerBr */ {KAknsIIDQsnFrCaleHeadingCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingSideT */ {KAknsIIDQsnFrCaleHeadingSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingSideB */ {KAknsIIDQsnFrCaleHeadingSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingSideL */ {KAknsIIDQsnFrCaleHeadingSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingSideR */ {KAknsIIDQsnFrCaleHeadingSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingCenter */ {KAknsIIDQsnFrCaleHeadingCenter, ENoDraw, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrInputCornerTl */ {KAknsIIDQsnFrInputCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputCornerTr */ {KAknsIIDQsnFrInputCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputCornerBl */ {KAknsIIDQsnFrInputCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputCornerBr */ {KAknsIIDQsnFrInputCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputSideT */ {KAknsIIDQsnFrInputSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputSideB */ {KAknsIIDQsnFrInputSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputSideL */ {KAknsIIDQsnFrInputSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputSideR */ {KAknsIIDQsnFrInputSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputCenter */ {KAknsIIDQsnFrInputCenter, ENoDraw, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrListCornerTl */ {KAknsIIDQsnFrListCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListCornerTr */ {KAknsIIDQsnFrListCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListCornerBl */ {KAknsIIDQsnFrListCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListCornerBr */ {KAknsIIDQsnFrListCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListSideT */ {KAknsIIDQsnFrListSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListSideB */ {KAknsIIDQsnFrListSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListSideL */ {KAknsIIDQsnFrListSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListSideR */ {KAknsIIDQsnFrListSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListCenter */ {KAknsIIDQsnFrListCenter, ENoDraw, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrPopupCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupCornerTr */ {KAknsIIDQsnFrPopupCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupCornerBl */ {KAknsIIDQsnFrPopupCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupCornerBr */ {KAknsIIDQsnFrPopupCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupSideT */ {KAknsIIDQsnFrPopupSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_AllReleases, -1,-1},
// ToolTip graphics different in 3.1 vs. 3.2+.
- /* SP_QsnFrPopupPreviewCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c5}, /* KAknsIIDQsnFrPopupPreviewCornerTl */
- /* SP_QsnFrPopupPreviewCornerTr */ {KAknsIIDQsnFrPopupCornerTr, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c6},
- /* SP_QsnFrPopupPreviewCornerBl */ {KAknsIIDQsnFrPopupCornerBl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c3},
- /* SP_QsnFrPopupPreviewCornerBr */ {KAknsIIDQsnFrPopupCornerBr, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c4},
- /* SP_QsnFrPopupPreviewSideT */ {KAknsIIDQsnFrPopupSideT, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19ca},
- /* SP_QsnFrPopupPreviewSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c7},
- /* SP_QsnFrPopupPreviewSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c8},
- /* SP_QsnFrPopupPreviewSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c9},
- /* SP_QsnFrPopupPreviewCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c2},
-
- /* SP_QsnFrSetOptCornerTl */ {KAknsIIDQsnFrSetOptCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptCornerTr */ {KAknsIIDQsnFrSetOptCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptCornerBl */ {KAknsIIDQsnFrSetOptCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptCornerBr */ {KAknsIIDQsnFrSetOptCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptSideT */ {KAknsIIDQsnFrSetOptSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptSideB */ {KAknsIIDQsnFrSetOptSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptSideL */ {KAknsIIDQsnFrSetOptSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptSideR */ {KAknsIIDQsnFrSetOptSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptCenter */ {KAknsIIDQsnFrSetOptCenter, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupPreviewCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c5}, /* KAknsIIDQsnFrPopupPreviewCornerTl */
+ /* SP_QsnFrPopupPreviewCornerTr */ {KAknsIIDQsnFrPopupCornerTr, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c6},
+ /* SP_QsnFrPopupPreviewCornerBl */ {KAknsIIDQsnFrPopupCornerBl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c3},
+ /* SP_QsnFrPopupPreviewCornerBr */ {KAknsIIDQsnFrPopupCornerBr, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c4},
+ /* SP_QsnFrPopupPreviewSideT */ {KAknsIIDQsnFrPopupSideT, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19ca},
+ /* SP_QsnFrPopupPreviewSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c7},
+ /* SP_QsnFrPopupPreviewSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c8},
+ /* SP_QsnFrPopupPreviewSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c9},
+ /* SP_QsnFrPopupPreviewCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c2},
+
+ /* SP_QsnFrSetOptCornerTl */ {KAknsIIDQsnFrSetOptCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptCornerTr */ {KAknsIIDQsnFrSetOptCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptCornerBl */ {KAknsIIDQsnFrSetOptCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptCornerBr */ {KAknsIIDQsnFrSetOptCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptSideT */ {KAknsIIDQsnFrSetOptSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptSideB */ {KAknsIIDQsnFrSetOptSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptSideL */ {KAknsIIDQsnFrSetOptSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptSideR */ {KAknsIIDQsnFrSetOptSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptCenter */ {KAknsIIDQsnFrSetOptCenter, ENoDraw, ES60_AllReleases, -1,-1},
// No toolbar frame for 5.0+ releases.
- /* SP_QsnFrPopupSubCornerTl */ {KAknsIIDQsnFrPopupSubCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubCornerTr */ {KAknsIIDQsnFrPopupSubCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubCornerBl */ {KAknsIIDQsnFrPopupSubCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubCornerBr */ {KAknsIIDQsnFrPopupSubCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubSideT */ {KAknsIIDQsnFrPopupSubSideT, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubSideB */ {KAknsIIDQsnFrPopupSubSideB, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubSideL */ {KAknsIIDQsnFrPopupSubSideL, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubSideR */ {KAknsIIDQsnFrPopupSubSideR, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubCenter */ {KAknsIIDQsnFrPopupCenterSubmenu, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubCornerTl */ {KAknsIIDQsnFrPopupSubCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubCornerTr */ {KAknsIIDQsnFrPopupSubCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubCornerBl */ {KAknsIIDQsnFrPopupSubCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubCornerBr */ {KAknsIIDQsnFrPopupSubCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubSideT */ {KAknsIIDQsnFrPopupSubSideT, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubSideB */ {KAknsIIDQsnFrPopupSubSideB, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubSideL */ {KAknsIIDQsnFrPopupSubSideL, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubSideR */ {KAknsIIDQsnFrPopupSubSideR, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubCenter */ {KAknsIIDQsnFrPopupCenterSubmenu, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
// Toolbar graphics is different in 3.1/3.2 vs. 5.0
- /* SP_QsnFrSctrlButtonCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2301}, /* KAknsIIDQgnFrSctrlButtonCornerTl*/
- /* SP_QsnFrSctrlButtonCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2302},
- /* SP_QsnFrSctrlButtonCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2303},
- /* SP_QsnFrSctrlButtonCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2304},
- /* SP_QsnFrSctrlButtonSideT */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2305},
- /* SP_QsnFrSctrlButtonSideB */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2306},
- /* SP_QsnFrSctrlButtonSideL */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2307},
- /* SP_QsnFrSctrlButtonSideR */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2308},
- /* SP_QsnFrSctrlButtonCenter */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2309}, /*KAknsIIDQgnFrSctrlButtonCenter*/
+ /* SP_QsnFrSctrlButtonCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2301}, /* KAknsIIDQgnFrSctrlButtonCornerTl*/
+ /* SP_QsnFrSctrlButtonCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2302},
+ /* SP_QsnFrSctrlButtonCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2303},
+ /* SP_QsnFrSctrlButtonCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2304},
+ /* SP_QsnFrSctrlButtonSideT */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2305},
+ /* SP_QsnFrSctrlButtonSideB */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2306},
+ /* SP_QsnFrSctrlButtonSideL */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2307},
+ /* SP_QsnFrSctrlButtonSideR */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2308},
+ /* SP_QsnFrSctrlButtonCenter */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2309}, /*KAknsIIDQgnFrSctrlButtonCenter*/
// No pressed state for toolbar button in 3.1/3.2.
- /* SP_QsnFrSctrlButtonCornerTlPressed */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2621}, /*KAknsIIDQsnFrSctrlButtonCornerTlPressed*/
- /* SP_QsnFrSctrlButtonCornerTrPressed */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2622},
- /* SP_QsnFrSctrlButtonCornerBlPressed */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2623},
- /* SP_QsnFrSctrlButtonCornerBrPressed */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2624},
- /* SP_QsnFrSctrlButtonSideTPressed */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2625},
- /* SP_QsnFrSctrlButtonSideBPressed */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2626},
- /* SP_QsnFrSctrlButtonSideLPressed */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2627},
- /* SP_QsnFrSctrlButtonSideRPressed */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2628},
- /* SP_QsnFrSctrlButtonCenterPressed */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2629}
+ /* SP_QsnFrSctrlButtonCornerTlPressed */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2621}, /*KAknsIIDQsnFrSctrlButtonCornerTlPressed*/
+ /* SP_QsnFrSctrlButtonCornerTrPressed */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2622},
+ /* SP_QsnFrSctrlButtonCornerBlPressed */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2623},
+ /* SP_QsnFrSctrlButtonCornerBrPressed */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2624},
+ /* SP_QsnFrSctrlButtonSideTPressed */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2625},
+ /* SP_QsnFrSctrlButtonSideBPressed */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2626},
+ /* SP_QsnFrSctrlButtonSideLPressed */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2627},
+ /* SP_QsnFrSctrlButtonSideRPressed */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2628},
+ /* SP_QsnFrSctrlButtonCenterPressed */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2629},
+
+ // No inactive button graphics in 3.1/3.2
+ /* SP_QsnFrButtonCornerTlInactive */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b1}, /*KAknsIIDQsnFrButtonCornerTlInactive*/
+ /* SP_QsnFrButtonCornerTrInactive */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b2},
+ /* SP_QsnFrButtonCornerBlInactive */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b3},
+ /* SP_QsnFrButtonCornerTrInactive */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b4},
+ /* SP_QsnFrButtonSideTInactive */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b5},
+ /* SP_QsnFrButtonSideBInactive */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b6},
+ /* SP_QsnFrButtonSideLInactive */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b7},
+ /* SP_QsnFrButtonSideRInactive */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b8},
+ /* SP_QsnFrButtonCenterInactive */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b9},
+
+ /*SP_QsnFrNotepadCornerTl */ {KAknsIIDQsnFrNotepadCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadCornerTr */ {KAknsIIDQsnFrNotepadCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadCornerBl */ {KAknsIIDQsnFrNotepadCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadCornerBr */ {KAknsIIDQsnFrNotepadCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadSideT */ {KAknsIIDQsnFrNotepadSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadSideB */ {KAknsIIDQsnFrNotepadSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadSideL */ {KAknsIIDQsnFrNotepadSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadSideR */ {KAknsIIDQsnFrNotepadSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadCenter */ {KAknsIIDQsnFrNotepadCenter, EDrawIcon, ES60_AllReleases, -1,-1}
+
};
QPixmap QS60StyleModeSpecifics::skinnedGraphics(
@@ -323,7 +368,7 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphics(
}
void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &stylepart, TDes& fallbackFileName, TInt& fallbackIndex)
-{
+{
switch(stylepart) {
case QS60StyleEnums::SP_QgnGrafBarWait:
fallbackFileName = KAvkonBitmapFile();
@@ -377,19 +422,19 @@ void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &style
fallbackFileName = KAvkonBitmapFile();
fallbackIndex = EMbmAvkonQgn_indi_checkbox_on;
break;
- case QS60StyleEnums::SP_QgnIndiHlColSuper:
+ case QS60StyleEnums::SP_QgnIndiHlColSuper:
fallbackFileName = KAvkonBitmapFile();
fallbackIndex = 0x4456; /* EMbmAvkonQgn_indi_hl_col_super */
break;
- case QS60StyleEnums::SP_QgnIndiHlExpSuper:
+ case QS60StyleEnums::SP_QgnIndiHlExpSuper:
fallbackFileName = KAvkonBitmapFile();
fallbackIndex = 0x4458; /* EMbmAvkonQgn_indi_hl_exp_super */
break;
- case QS60StyleEnums::SP_QgnIndiHlLineBranch:
+ case QS60StyleEnums::SP_QgnIndiHlLineBranch:
fallbackFileName = KAvkonBitmapFile();
fallbackIndex = 0x445A; /* EMbmAvkonQgn_indi_hl_line_branch */
break;
- case QS60StyleEnums::SP_QgnIndiHlLineEnd:
+ case QS60StyleEnums::SP_QgnIndiHlLineEnd:
fallbackFileName = KAvkonBitmapFile();
fallbackIndex = 0x445C; /* EMbmAvkonQgn_indi_hl_line_end */
break;
@@ -486,8 +531,8 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsL(
TInt fallbackGraphicID = -1;
HBufC* iconFile = HBufC::NewLC( KMaxFileName );
TPtr fileNamePtr = iconFile->Des();
- fallbackInfo(stylepart, fileNamePtr, fallbackGraphicID);
-
+ fallbackInfo(stylepart, fileNamePtr, fallbackGraphicID);
+
TAknsItemID colorGroup = KAknsIIDQsnIconColors;
int colorIndex = 0;
colorGroupAndIndex(stylepart, colorGroup, colorIndex);
@@ -569,26 +614,6 @@ QPixmap QS60StyleModeSpecifics::fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask
return QPixmap::fromImage(iconImage);
}
-QPixmap QS60StylePrivate::backgroundTexture()
-{
- static QPixmap result;
- // Poor mans caching. + Making sure that there is always only one background image in memory at a time
-
-/*
- TODO: 1) Hold the background QPixmap as pointer in a static class member.
- Also add a deleteBackground() function and call that in ~QS60StylePrivate()
- 2) Don't cache the background at all as soon as we have native pixmap support
-*/
-
- if (!m_backgroundValid) {
- result = QPixmap();
- result = part(QS60StyleEnums::SP_QsnBgScreen,
- QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), SkinElementFlags());
- m_backgroundValid = true;
- }
- return result;
-}
-
bool QS60StylePrivate::isTouchSupported()
{
return bool(AknLayoutUtils::PenEnabled());
@@ -599,30 +624,11 @@ bool QS60StylePrivate::isToolBarBackground()
return (QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
}
-void qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset,
- const QBrush &brush)
+QPoint qt_s60_fill_background_offset(const QWidget *targetWidget)
{
- const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture());
- if (backgroundTexture.cacheKey() == brush.texture().cacheKey()) {
- const QPaintDevice *target = painter->device();
- if (target->devType() == QInternal::Widget) {
- const QWidget *widget = static_cast<const QWidget *>(target);
- CCoeControl *control = widget->effectiveWinId();
- TPoint globalPos = control ? control->PositionRelativeToScreen() : TPoint(0,0);
- const QRegion translated = rgn.translated(offset);
- const QVector<QRect> &rects = translated.rects();
- for (int i = 0; i < rects.size(); ++i) {
- const QRect rect(rects.at(i));
- painter->drawPixmap(rect.topLeft(), backgroundTexture,
- rect.translated(globalPos.iX, globalPos.iY));
- }
- }
- } else {
- const QRegion translated = rgn.translated(offset);
- const QRect rect(translated.boundingRect());
- painter->setClipRegion(translated);
- painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
- }
+ CCoeControl *control = targetWidget->effectiveWinId();
+ TPoint globalPos = control ? control->PositionRelativeToScreen() : TPoint(0,0);
+ return QPoint(globalPos.iX, globalPos.iY);
}
QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(
@@ -639,7 +645,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(
Q_ASSERT(drawType != ENoDraw);
const bool rotatedBy90or270 =
(flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest));
- TSize targetSize =
+ const TSize targetSize =
rotatedBy90or270 ? TSize(size.height(), size.width()) : qt_QSize2TSize(size);
MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
@@ -647,65 +653,63 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(
QPixmap result;
switch (drawType) {
- case EDrawIcon:
- {
- TInt fallbackGraphicID = -1;
- HBufC* iconFile = HBufC::NewLC( KMaxFileName );
- TPtr fileNamePtr = iconFile->Des();
- fallbackInfo(part, fileNamePtr, fallbackGraphicID);
-
- CFbsBitmap *icon = 0;
- CFbsBitmap *iconMask = 0;
- const TInt fallbackGraphicsMaskID =
- fallbackGraphicID == KErrNotFound?KErrNotFound:fallbackGraphicID+1; //masks are auto-generated as next in mif files
-// QS60WindowSurface::unlockBitmapHeap();
- AknsUtils::CreateIconLC(skinInstance, skinId, icon, iconMask, fileNamePtr, fallbackGraphicID , fallbackGraphicsMaskID);
- User::LeaveIfError(AknIconUtils::SetSize(icon, targetSize, EAspectRatioNotPreserved));
- User::LeaveIfError(AknIconUtils::SetSize(iconMask, targetSize, EAspectRatioNotPreserved));
- result = fromFbsBitmap(icon, iconMask, flags, qt_TDisplayMode2Format(icon->DisplayMode()));
- CleanupStack::PopAndDestroy(3); // iconMask, icon, iconFile
-// QS60WindowSurface::lockBitmapHeap();
- break;
- }
- case EDrawBackground:
- {
-// QS60WindowSurface::unlockBitmapHeap();
- CFbsBitmap *background = new (ELeave) CFbsBitmap(); //offscreen
- CleanupStack::PushL(background);
- User::LeaveIfError(background->Create(targetSize, EColor16MA));
-
- // todo: push background into CleanupStack
- CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(background);
- CleanupStack::PushL(dev);
- CFbsBitGc* gc = NULL;
- User::LeaveIfError(dev->CreateContext(gc));
- CleanupStack::PushL(gc);
-
- CAknsBasicBackgroundControlContext* bgContext = CAknsBasicBackgroundControlContext::NewL(
- skinId,
- targetSize,
- EFalse);
- CleanupStack::PushL(bgContext);
-
- const TBool drawn = AknsDrawUtils::DrawBackground(
- skinInstance,
- bgContext,
- NULL,
- *gc,
- TPoint(),
- targetSize,
- KAknsDrawParamDefault | KAknsDrawParamRGBOnly);
-
- if (drawn)
- result = fromFbsBitmap(background, NULL, flags, QImage::Format_RGB32);
-
- CleanupStack::PopAndDestroy(4, background); //background, dev, gc, bgContext
-// QS60WindowSurface::lockBitmapHeap();
- break;
- }
+ case EDrawIcon: {
+ TInt fallbackGraphicID = -1;
+ HBufC* iconFile = HBufC::NewLC( KMaxFileName );
+ TPtr fileNamePtr = iconFile->Des();
+ fallbackInfo(part, fileNamePtr, fallbackGraphicID);
+ // todo: could we instead use AknIconUtils::AvkonIconFileName(); to avoid allocating each time?
+
+ CFbsBitmap *icon = 0;
+ CFbsBitmap *iconMask = 0;
+ const TInt fallbackGraphicsMaskID =
+ fallbackGraphicID == KErrNotFound?KErrNotFound:fallbackGraphicID+1; //masks are auto-generated as next in mif files
+ // QS60WindowSurface::unlockBitmapHeap();
+ AknsUtils::CreateIconLC(skinInstance, skinId, icon, iconMask, fileNamePtr, fallbackGraphicID , fallbackGraphicsMaskID);
+ User::LeaveIfError(AknIconUtils::SetSize(icon, targetSize, EAspectRatioNotPreserved));
+ User::LeaveIfError(AknIconUtils::SetSize(iconMask, targetSize, EAspectRatioNotPreserved));
+ result = fromFbsBitmap(icon, iconMask, flags, qt_TDisplayMode2Format(icon->DisplayMode()));
+ CleanupStack::PopAndDestroy(3); // iconMask, icon, iconFile
+ // QS60WindowSurface::lockBitmapHeap();
+ break;
+ }
+ case EDrawBackground: {
+ // QS60WindowSurface::unlockBitmapHeap();
+ CFbsBitmap *background = new (ELeave) CFbsBitmap(); //offscreen
+ CleanupStack::PushL(background);
+ User::LeaveIfError(background->Create(targetSize, EColor16MA));
+
+ CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(background);
+ CleanupStack::PushL(dev);
+ CFbsBitGc* gc = NULL;
+ User::LeaveIfError(dev->CreateContext(gc));
+ CleanupStack::PushL(gc);
+
+ CAknsBasicBackgroundControlContext* bgContext = CAknsBasicBackgroundControlContext::NewL(
+ skinId,
+ targetSize,
+ EFalse);
+ CleanupStack::PushL(bgContext);
+
+ const TBool drawn = AknsDrawUtils::DrawBackground(
+ skinInstance,
+ bgContext,
+ NULL,
+ *gc,
+ TPoint(),
+ targetSize,
+ KAknsDrawParamDefault | KAknsDrawParamRGBOnly);
+
+ if (drawn)
+ result = fromFbsBitmap(background, NULL, flags, QImage::Format_RGB32);
+
+ CleanupStack::PopAndDestroy(4, background); //background, dev, gc, bgContext
+ // QS60WindowSurface::lockBitmapHeap();
+ break;
+ }
}
- return result; // TODO: Let fromFbsBitmap return a QPixmap
+ return result;
}
QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(QS60StylePrivate::SkinFrameElements frameElement,
@@ -716,11 +720,10 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(QS60StylePrivate::SkinFra
const bool rotatedBy90or270 =
(flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest));
- TSize targetSize =
+ const TSize targetSize =
rotatedBy90or270 ? TSize(size.height(), size.width()) : qt_QSize2TSize(size);
MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
-
QPixmap result;
// QS60WindowSurface::unlockBitmapHeap();
@@ -764,7 +767,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(QS60StylePrivate::SkinFra
skinInstance->GetCachedItemData(frameSkinID,EAknsITMaskedBitmap));
if (skinMaskedBmp && skinMaskedBmp->Mask())
maskDepth = skinMaskedBmp->Mask()->DisplayMode();
- }
+ }
if (maskDepth != ENone) {
CFbsBitmap *frameMask = new (ELeave) CFbsBitmap(); //offscreen
CleanupStack::PushL(frameMask);
@@ -792,11 +795,10 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(QS60StylePrivate::SkinFra
result = fromFbsBitmap(frame, frameMask, flags, QImage::Format_ARGB32);
}
CleanupStack::PopAndDestroy(3, frameMask);
- }
}
+ }
CleanupStack::PopAndDestroy(3, frame); //frame, bitmapDev, bitmapGc
-
- return result; // TODO: Let fromFbsBitmap return a QPixmap
+ return result;
}
void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameElements frameElement, TAknsItemID &frameId, TAknsItemID &centerId)
@@ -807,7 +809,7 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme
switch(frameElement) {
case QS60StylePrivate::SF_ToolTip:
- if (QSysInfo::s60Version()==QSysInfo::SV_S60_5_0 || QSysInfo::s60Version()==QSysInfo::SV_S60_3_2) {
+ if (QSysInfo::s60Version()!=QSysInfo::SV_S60_3_1) {
centerId.Set(EAknsMajorGeneric, 0x19c2);
frameId.Set(EAknsMajorSkin, 0x5300);
} else {
@@ -835,17 +837,19 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme
TRect QS60StyleModeSpecifics::innerRectFromElement(QS60StylePrivate::SkinFrameElements frameElement, const TRect &outerRect)
{
- TInt widthShrink = 0;
- TInt heightShrink = 0;
+ TInt widthShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth);
+ TInt heightShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight);
switch(frameElement) {
case QS60StylePrivate::SF_PanelBackground:
// panel should have slightly slimmer border to enable thin line of background graphics between closest component
- widthShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth)-2;
- heightShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight)-2;
+ widthShrink = widthShrink-2;
+ heightShrink = heightShrink-2;
+ break;
+ case QS60StylePrivate::SF_ToolTip:
+ widthShrink = widthShrink>>1;
+ heightShrink = heightShrink>>1;
break;
default:
- widthShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth);
- heightShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight);
break;
}
TRect innerRect(outerRect);
@@ -898,7 +902,7 @@ void QS60StyleModeSpecifics::checkAndUnCompressBitmapL(CFbsBitmap*& aOriginalBit
QFont QS60StylePrivate::s60Font_specific(
QS60StyleEnums::FontCategories fontCategory, int pointSize)
{
- enum TAknFontCategory aknFontCategory = EAknFontCategoryUndefined;
+ TAknFontCategory aknFontCategory = EAknFontCategoryUndefined;
switch (fontCategory) {
case QS60StyleEnums::FC_Primary:
aknFontCategory = EAknFontCategoryPrimary;
@@ -943,12 +947,10 @@ QFont QS60StylePrivate::s60Font_specific(
return result;
}
-#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED
void QS60StylePrivate::setActiveLayout()
{
- //todo: how to find layouts that are of same size (QVGA1 vs. QVGA2)
const QSize activeScreenSize(screenSize());
- int activeLayoutIndex = 0;
+ int activeLayoutIndex = -1;
const bool mirrored = !QApplication::isLeftToRight();
const short screenHeight = (short)activeScreenSize.height();
const short screenWidth = (short)activeScreenSize.width();
@@ -960,35 +962,112 @@ void QS60StylePrivate::setActiveLayout()
break;
}
}
+
+ //not found, lets try without mirroring info
+ if (activeLayoutIndex==-1){
+ for (int i=0; i<m_numberOfLayouts; i++) {
+ if (screenHeight==m_layoutHeaders[i].height &&
+ screenWidth==m_layoutHeaders[i].width) {
+ activeLayoutIndex = i;
+ break;
+ }
+ }
+ }
+
+ //not found, lets try with either of dimensions
+ if (activeLayoutIndex==-1){
+ const QSysInfo::S60Version currentRelease = QSysInfo::s60Version();
+ const bool landscape = screenHeight < screenWidth;
+
+ activeLayoutIndex = (currentRelease == QSysInfo::SV_S60_3_1 || currentRelease == QSysInfo::SV_S60_3_2) ? 0 : 4;
+ activeLayoutIndex += (!landscape) ? 2 : 0;
+ activeLayoutIndex += (!mirrored) ? 1 : 0;
+ }
+
m_pmPointer = data[activeLayoutIndex];
}
-#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED
QS60StylePrivate::QS60StylePrivate()
{
-#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED
// No need to set active layout, if dynamic metrics API is available
setActiveLayout();
-#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED
}
-QS60StylePrivate::~QS60StylePrivate()
+void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value)
{
- m_backgroundValid = false;
+ if (name == QLatin1String("foo")) {
+ // BaR
+ } else {
+ setStyleProperty(name, value);
+ }
}
-short QS60StylePrivate::pixelMetric(int metric)
+QVariant QS60StylePrivate::styleProperty_specific(const char *name) const
{
-#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED
- Q_ASSERT(metric < MAX_PIXELMETRICS);
- const short returnValue = m_pmPointer[metric];
- if (returnValue==-909)
- return -1;
- return returnValue;
-#else
- //todo - call the pixelmetrics API directly
- return 0;
-#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED
+ if (name == QLatin1String("foo"))
+ return QLatin1String("Bar");
+ else
+ return styleProperty(name);
+}
+
+QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list,
+ int index, const QStyleOption *option)
+{
+ static const TAknsItemID *idMap[] = {
+ &KAknsIIDQsnHighlightColors,
+ &KAknsIIDQsnIconColors,
+ &KAknsIIDQsnLineColors,
+ &KAknsIIDQsnOtherColors,
+ &KAknsIIDQsnParentColors,
+ &KAknsIIDQsnTextColors
+ };
+ Q_ASSERT((int)list <= (int)sizeof(idMap)/sizeof(idMap[0]));
+ const QColor color = QS60StyleModeSpecifics::colorValue(*idMap[(int) list], index - 1);
+ return option ? QS60StylePrivate::stateColor(color, option) : color;
+}
+
+// In some cases, the AVKON UI themegraphic is already in 'disabled state'.
+// If so, return true for these parts.
+bool QS60StyleModeSpecifics::disabledPartGraphic(QS60StyleEnums::SkinParts &part)
+{
+ bool disabledGraphic = false;
+ switch(part){
+ // inactive button graphics are available from 5.0 onwards
+ case QS60StyleEnums::SP_QsnFrButtonCornerTlInactive:
+ case QS60StyleEnums::SP_QsnFrButtonCornerTrInactive:
+ case QS60StyleEnums::SP_QsnFrButtonCornerBlInactive:
+ case QS60StyleEnums::SP_QsnFrButtonCornerBrInactive:
+ case QS60StyleEnums::SP_QsnFrButtonSideTInactive:
+ case QS60StyleEnums::SP_QsnFrButtonSideBInactive:
+ case QS60StyleEnums::SP_QsnFrButtonSideLInactive:
+ case QS60StyleEnums::SP_QsnFrButtonSideRInactive:
+ case QS60StyleEnums::SP_QsnFrButtonCenterInactive:
+ if (!(QSysInfo::s60Version()==QSysInfo::SV_S60_3_1 ||
+ QSysInfo::s60Version()==QSysInfo::SV_S60_3_2))
+ disabledGraphic = true;
+ break;
+ default:
+ break;
+ }
+ return disabledGraphic;
+}
+
+// In some cases, the AVKON UI themegraphic is already in 'disabled state'.
+// If so, return true for these frames.
+bool QS60StyleModeSpecifics::disabledFrameGraphic(QS60StylePrivate::SkinFrameElements &frame)
+{
+ bool disabledGraphic = false;
+ switch(frame){
+ // inactive button graphics are available from 5.0 onwards
+ case QS60StylePrivate::SF_ButtonInactive:
+ if (!(QSysInfo::s60Version()==QSysInfo::SV_S60_3_1 ||
+ QSysInfo::s60Version()==QSysInfo::SV_S60_3_2))
+ disabledGraphic = true;
+ break;
+ default:
+ break;
+ }
+ return disabledGraphic;
}
QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::SkinParts &part,
@@ -1002,8 +1081,8 @@ QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::Skin
// AVKON UI has a abnormal handling for scrollbar graphics. It is possible that the root
// skin does not contain mandatory graphics for scrollbar pressed states. Therefore, AVKON UI
// creates dynamically these graphics by modifying the normal state scrollbar graphics slightly.
- // S60Style needs to work similarly. Therefore if skingraphics call provides to be a miss
- // (i.e. result is not valid), style needs to draw normal graphics instead and apply some
+ // S60Style needs to work similarly. Therefore if skingraphics call provides to be a miss
+ // (i.e. result is not valid), style needs to draw normal graphics instead and apply some
// modifications (similar to generatedIconPixmap()) to the result.
case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed:
updatedPart = QS60StyleEnums::SP_QsnCpScrollHandleBottom;
@@ -1021,10 +1100,11 @@ QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::Skin
return QPixmap();
} else {
QPixmap result = skinnedGraphics(updatedPart, size, flags);
- // TODO: fix this
QStyleOption opt;
- // opt.palette = q->standardPalette();
-
+ QPalette *themePalette = QS60StylePrivate::themePalette();
+ if (themePalette)
+ opt.palette = *themePalette;
+
// For now, always generate new icon based on "selected". In the future possibly, expand
// this to consist other possibilities as well.
result = QApplication::style()->generatedIconPixmap(QIcon::Selected, result, &opt);
@@ -1041,16 +1121,17 @@ QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part,
: QS60StyleModeSpecifics::skinnedGraphics(part, size, flags);
QS60WindowSurface::lockBitmapHeap();
- if (flags & SF_StateDisabled) {
- // TODO: fix this
+ if (flags & SF_StateDisabled && !QS60StyleModeSpecifics::disabledPartGraphic(part)) {
QStyleOption opt;
-// opt.palette = q->standardPalette();
+ QPalette *themePalette = QS60StylePrivate::themePalette();
+ if (themePalette)
+ opt.palette = *themePalette;
result = QApplication::style()->generatedIconPixmap(QIcon::Disabled, result, &opt);
}
if (!result)
result = QS60StyleModeSpecifics::generateMissingThemeGraphic(part, size, flags);
-
+
return result;
}
@@ -1060,46 +1141,24 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size, Skin
QPixmap result = QS60StyleModeSpecifics::skinnedGraphics(frame, size, flags);
QS60WindowSurface::lockBitmapHeap();
- if (flags & SF_StateDisabled) {
- // TODO: fix this
+ if (flags & SF_StateDisabled && !QS60StyleModeSpecifics::disabledFrameGraphic(frame)) {
QStyleOption opt;
-// opt.palette = q->standardPalette();
+ QPalette *themePalette = QS60StylePrivate::themePalette();
+ if (themePalette)
+ opt.palette = *themePalette;
result = QApplication::style()->generatedIconPixmap(QIcon::Disabled, result, &opt);
}
return result;
}
-void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value)
+QPixmap QS60StylePrivate::backgroundTexture()
{
- if (name == QLatin1String("foo")) {
- // BaR
- } else {
- setStyleProperty(name, value);
+ if (!m_background) {
+ QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen,
+ QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), SkinElementFlags());
+ m_background = new QPixmap(background);
}
-}
-
-QVariant QS60StylePrivate::styleProperty_specific(const char *name) const
-{
- if (name == QLatin1String("foo"))
- return QLatin1String("Bar");
- else
- return styleProperty(name);
-}
-
-QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list,
- int index, const QStyleOption *option)
-{
- static const TAknsItemID *idMap[] = {
- &KAknsIIDQsnHighlightColors,
- &KAknsIIDQsnIconColors,
- &KAknsIIDQsnLineColors,
- &KAknsIIDQsnOtherColors,
- &KAknsIIDQsnParentColors,
- &KAknsIIDQsnTextColors
- };
- Q_ASSERT((int)list <= (int)sizeof(idMap)/sizeof(idMap[0]));
- const QColor color = QS60StyleModeSpecifics::colorValue(*idMap[(int) list], index - 1);
- return option ? QS60StylePrivate::stateColor(color, option) : color;
+ return *m_background;
}
// If the public SDK returns compressed images, please let us also uncompress those!
@@ -1118,8 +1177,8 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
if (displayMode != aTrgBitmap->DisplayMode())
User::Leave(KErrArgument);
- TSize trgSize = aTrgBitmap->SizeInPixels();
- TSize srcSize = aSrcBitmap->SizeInPixels();
+ const TSize trgSize = aTrgBitmap->SizeInPixels();
+ const TSize srcSize = aSrcBitmap->SizeInPixels();
// calculate the valid drawing area
TRect drawRect = aTrgRect;
@@ -1155,14 +1214,14 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
const TInt drawWidth = drawRect.Width();
const TInt drawHeight = drawRect.Height();
- TRect offsetRect(aTrgRect.iTl, drawRect.iTl);
+ const TRect offsetRect(aTrgRect.iTl, drawRect.iTl);
const TInt yPosOffset = ySkip * offsetRect.Height();
const TInt xPosOffset = xSkip * offsetRect.Width();
if ((displayMode == EGray256) || (displayMode == EColor256)) {
- TInt srcScanLen8 = CFbsBitmap::ScanLineLength(srcSize.iWidth,
+ const TInt srcScanLen8 = CFbsBitmap::ScanLineLength(srcSize.iWidth,
displayMode);
- TInt trgScanLen8 = CFbsBitmap::ScanLineLength(trgSize.iWidth,
+ const TInt trgScanLen8 = CFbsBitmap::ScanLineLength(trgSize.iWidth,
displayMode);
TUint8* trgAddress8 = reinterpret_cast<TUint8*> (trgAddress);
@@ -1172,7 +1231,7 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
trgAddress8 += trgScanLen8 * drawRect.iTl.iY + drawRect.iTl.iX;
for (TInt y = 0; y < drawHeight; y++) {
- TUint8* srcAddress8 = reinterpret_cast<TUint8*> (srcAddress)
+ const TUint8* srcAddress8 = reinterpret_cast<const TUint8*> (srcAddress)
+ (srcScanLen8 * (yPos >> 8));
TInt xPos = xPosOffset;
@@ -1186,9 +1245,9 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
trgAddress8 += trgScanLen8 - drawWidth;
}
} else if (displayMode == EColor4K || displayMode == EColor64K) {
- TInt srcScanLen16 = CFbsBitmap::ScanLineLength(srcSize.iWidth,
+ const TInt srcScanLen16 = CFbsBitmap::ScanLineLength(srcSize.iWidth,
displayMode) >>1;
- TInt trgScanLen16 = CFbsBitmap::ScanLineLength(trgSize.iWidth,
+ const TInt trgScanLen16 = CFbsBitmap::ScanLineLength(trgSize.iWidth,
displayMode) >>1;
TUint16* trgAddress16 = reinterpret_cast<TUint16*> (trgAddress);
@@ -1198,7 +1257,7 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
trgAddress16 += trgScanLen16 * drawRect.iTl.iY + drawRect.iTl.iX;
for (TInt y = 0; y < drawHeight; y++) {
- TUint16* srcAddress16 = reinterpret_cast<TUint16*> (srcAddress)
+ const TUint16* srcAddress16 = reinterpret_cast<const TUint16*> (srcAddress)
+ (srcScanLen16 * (yPos >> 8));
TInt xPos = xPosOffset;
@@ -1212,9 +1271,9 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
trgAddress16 += trgScanLen16 - drawWidth;
}
} else if (displayMode == EColor16MU || displayMode == EColor16MA) {
- TInt srcScanLen32 = CFbsBitmap::ScanLineLength(srcSize.iWidth,
+ const TInt srcScanLen32 = CFbsBitmap::ScanLineLength(srcSize.iWidth,
displayMode) >>2;
- TInt trgScanLen32 = CFbsBitmap::ScanLineLength(trgSize.iWidth,
+ const TInt trgScanLen32 = CFbsBitmap::ScanLineLength(trgSize.iWidth,
displayMode) >>2;
TUint32* trgAddress32 = reinterpret_cast<TUint32*> (trgAddress);
@@ -1224,7 +1283,7 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
trgAddress32 += trgScanLen32 * drawRect.iTl.iY + drawRect.iTl.iX;
for (TInt y = 0; y < drawHeight; y++) {
- TUint32* srcAddress32 = reinterpret_cast<TUint32*> (srcAddress)
+ const TUint32* srcAddress32 = reinterpret_cast<const TUint32*> (srcAddress)
+ (srcScanLen32 * (yPos >> 8));
TInt xPos = xPosOffset;
@@ -1244,8 +1303,8 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
QSize QS60StylePrivate::screenSize()
{
- TSize mySize = QS60Data::screenDevice()->SizeInPixels();
- return QSize(mySize.iWidth, mySize.iHeight);
+ const TSize screenSize = QS60Data::screenDevice()->SizeInPixels();
+ return QSize(screenSize.iWidth, screenSize.iHeight);
}
void QS60StyleModeSpecifics::colorGroupAndIndex(
@@ -1253,30 +1312,34 @@ void QS60StyleModeSpecifics::colorGroupAndIndex(
{
switch(skinID) {
case QS60StyleEnums::SP_QgnIndiSubMenu:
- case QS60StyleEnums::SP_QgnIndiHlColSuper:
- case QS60StyleEnums::SP_QgnIndiHlExpSuper:
- case QS60StyleEnums::SP_QgnIndiHlLineBranch:
- case QS60StyleEnums::SP_QgnIndiHlLineEnd:
- case QS60StyleEnums::SP_QgnIndiHlLineStraight:
+ colorGroup = KAknsIIDQsnIconColors;
+ colorIndex = EAknsCIQsnIconColorsCG1;
+ break;
case QS60StyleEnums::SP_QgnIndiRadiobuttOff:
case QS60StyleEnums::SP_QgnIndiRadiobuttOn:
case QS60StyleEnums::SP_QgnIndiCheckboxOff:
case QS60StyleEnums::SP_QgnIndiCheckboxOn:
colorGroup = KAknsIIDQsnIconColors;
- colorIndex = EAknsCIQsnIconColorsCG1;
+ colorIndex = EAknsCIQsnIconColorsCG14;
break;
default:
break;
}
}
+/*!
+ Constructs a QS60Style object.
+*/
+QS60Style::QS60Style()
+ : QCommonStyle(*new QS60StylePrivate)
+{
+}
+
void QS60Style::handleDynamicLayoutVariantSwitch()
{
Q_D(QS60Style);
- d->clearCaches();
-#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED
+ d->clearCaches(QS60StylePrivate::CC_LayoutChange);
d->setActiveLayout();
-#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED
d->refreshUI();
d->setBackgroundTexture(qApp);
foreach (QWidget *widget, QApplication::allWidgets())
@@ -1286,11 +1349,12 @@ void QS60Style::handleDynamicLayoutVariantSwitch()
void QS60Style::handleSkinChange()
{
Q_D(QS60Style);
- d->clearCaches();
+ d->clearCaches(QS60StylePrivate::CC_ThemeChange);
d->setThemePalette(qApp);
foreach (QWidget *topLevelWidget, QApplication::allWidgets()){
QEvent e(QEvent::StyleChange);
QApplication::sendEvent(topLevelWidget, &e);
+ d->setThemePalette(topLevelWidget);
topLevelWidget->ensurePolished();
}
}
diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp
index 5a88f9a..684f232 100644
--- a/src/gui/styles/qs60style_simulated.cpp
+++ b/src/gui/styles/qs60style_simulated.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $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$
**
****************************************************************************/
@@ -21,11 +51,117 @@
#include "qlayout.h"
#include "qpixmapcache.h"
#include "qmetaobject.h"
+#include "qdebug.h"
+#include "qbuffer.h"
+#include "qdesktopwidget.h"
#if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN)
QT_BEGIN_NAMESPACE
+static const quint32 blobVersion = 1;
+static const int pictureSize = 256;
+
+#if defined(Q_CC_GNU)
+#if __GNUC__ >= 2
+#define __FUNCTION__ __func__
+#endif
+#endif
+
+
+bool saveThemeToBlob(const QString &themeBlob,
+ const QHash<QString, QPicture> &partPictures,
+ const QHash<QPair<QString, int>, QColor> &colors)
+{
+ QFile blob(themeBlob);
+ if (!blob.open(QIODevice::WriteOnly)) {
+ qWarning() << __FUNCTION__ << ": Could not create blob: " << themeBlob;
+ return false;
+ }
+
+ QByteArray data;
+ QBuffer dataBuffer(&data);
+ dataBuffer.open(QIODevice::WriteOnly);
+ QDataStream dataOut(&dataBuffer);
+
+ const int colorsCount = colors.count();
+ dataOut << colorsCount;
+ const QList<QPair<QString, int> > colorKeys = colors.keys();
+ for (int i = 0; i < colorsCount; ++i) {
+ const QPair<QString, int> &key = colorKeys.at(i);
+ dataOut << key;
+ const QColor color = colors.value(key);
+ dataOut << color;
+ }
+
+ const int picturesCount = partPictures.count();
+ dataOut << picturesCount;
+ foreach (const QString &key, partPictures.keys()) {
+ const QPicture picture = partPictures.value(key);
+ dataOut << key;
+ dataOut << picture;
+ }
+
+ QDataStream blobOut(&blob);
+ blobOut << blobVersion;
+ blobOut << qCompress(data);
+ return blobOut.status() == QDataStream::Ok;
+}
+
+bool loadThemeFromBlob(const QString &themeBlob,
+ QHash<QString, QPicture> &partPictures,
+ QHash<QPair<QString, int>, QColor> &colors)
+{
+ QFile blob(themeBlob);
+ if (!blob.open(QIODevice::ReadOnly)) {
+ qWarning() << __FUNCTION__ << ": Could not read blob: " << themeBlob;
+ return false;
+ }
+ QDataStream blobIn(&blob);
+
+ quint32 version;
+ blobIn >> version;
+
+ if (version != blobVersion) {
+ qWarning() << __FUNCTION__ << ": Invalid blob version: " << version << " ...expected: " << blobVersion;
+ return false;
+ }
+
+ QByteArray data;
+ blobIn >> data;
+ data = qUncompress(data);
+ QBuffer dataBuffer(&data);
+ dataBuffer.open(QIODevice::ReadOnly);
+ QDataStream dataIn(&dataBuffer);
+
+ int colorsCount;
+ dataIn >> colorsCount;
+ for (int i = 0; i < colorsCount; ++i) {
+ QPair<QString, int> key;
+ dataIn >> key;
+ QColor value;
+ dataIn >> value;
+ colors.insert(key, value);
+ }
+
+ int picturesCount;
+ dataIn >> picturesCount;
+ for (int i = 0; i < picturesCount; ++i) {
+ QString key;
+ dataIn >> key;
+ QPicture value;
+ dataIn >> value;
+ value.setBoundingRect(QRect(0, 0, pictureSize, pictureSize)); // Bug? The forced bounding rect was not deserialized.
+ partPictures.insert(key, value);
+ }
+
+ if (dataIn.status() != QDataStream::Ok) {
+ qWarning() << __FUNCTION__ << ": Invalid data blob: " << themeBlob;
+ return false;
+ }
+ return true;
+}
+
class QS60StyleModeSpecifics
{
public:
@@ -42,19 +178,6 @@ QS60StylePrivate::QS60StylePrivate()
setCurrentLayout(0);
}
-QS60StylePrivate::~QS60StylePrivate()
-{
-}
-
-short QS60StylePrivate::pixelMetric(int metric)
-{
- Q_ASSERT(metric < MAX_PIXELMETRICS);
- const short returnValue = m_pmPointer[metric];
- if (returnValue==-909)
- return -1;
- return returnValue;
-}
-
QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list,
int index, const QStyleOption *option)
{
@@ -106,9 +229,10 @@ QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part, const QSize &size
QPixmap result = QPixmap::fromImage(partImage);
if (flags & SF_StateDisabled) {
- // TODO: fix this
QStyleOption opt;
-// opt.palette = q->standardPalette();
+ QPalette *themePalette = QS60StylePrivate::themePalette();
+ if (themePalette)
+ opt.palette = *themePalette;
result = QApplication::style()->generatedIconPixmap(QIcon::Disabled, result, &opt);
}
@@ -150,7 +274,8 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size,
const QRect leftRect = rightRect.translated(cornerWidth - rectWidth, 0);
const QRect centerRect = drawOnlyCenter ? rect : rect.adjusted(cornerWidth, cornerWidth, -cornerWidth, -cornerWidth);
- QImage result(size, QImage::Format_ARGB32);
+ QPixmap result(size);
+ result.fill(Qt::transparent);
QPainter painter(&result);
#if 0
@@ -178,7 +303,7 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size,
drawPart(center, &painter, centerRect, flags);
#endif
- return QPixmap::fromImage(result);
+ return result;
}
void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value)
@@ -193,23 +318,15 @@ QVariant QS60StylePrivate::styleProperty_specific(const char *name) const
QPixmap QS60StylePrivate::backgroundTexture()
{
- static QPixmap result;
- // Poor mans caching. + Making sure that there is always only one background image in memory at a time
-
-/*
- TODO: 1) Hold the background QPixmap as pointer in a static class member.
- Also add a deleteBackground() function and call that in ~QS60StylePrivate()
- 2) Don't cache the background at all as soon as we have native pixmap support
-*/
-
- if (!m_backgroundValid) {
- result = QPixmap();
- result = part(QS60StyleEnums::SP_QsnBgScreen, QApplication::activeWindow()->size());
- m_backgroundValid = true;
+ if (!m_background) {
+ const QSize size = QApplication::desktop()->screen()->size();
+ QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, size);
+ m_background = new QPixmap(background);
}
- return result;
+ return *m_background;
}
+
bool QS60StylePrivate::isTouchSupported()
{
#ifdef QT_KEYPAD_NAVIGATION
@@ -224,7 +341,6 @@ bool QS60StylePrivate::isToolBarBackground()
return true;
}
-
QFont QS60StylePrivate::s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize)
{
QFont result;
@@ -244,6 +360,18 @@ QFont QS60StylePrivate::s60Font_specific(QS60StyleEnums::FontCategories fontCate
return result;
}
+/*!
+ Constructs a QS60Style object.
+*/
+QS60Style::QS60Style()
+ : QCommonStyle(*new QS60StylePrivate)
+{
+ // Assume, that the resource system has a ':/s60Stylethemes/Default.blob'
+ const QString defaultBlob = QString::fromLatin1(":/s60Stylethemes/Default.blob");
+ if (QFile::exists(defaultBlob))
+ loadS60ThemeFromBlob(defaultBlob);
+}
+
Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, enumPartKeys, {
const int enumIndex = QS60StyleEnums::staticMetaObject.indexOfEnumerator("SkinParts");
Q_ASSERT(enumIndex >= 0);
@@ -285,8 +413,35 @@ QStringList QS60Style::colorListKeys()
void QS60Style::setS60Theme(const QHash<QString, QPicture> &parts,
const QHash<QPair<QString , int>, QColor> &colors)
{
+ Q_D(QS60Style);
QS60StyleModeSpecifics::m_partPictures = parts;
QS60StyleModeSpecifics::m_colors = colors;
+ d->clearCaches(QS60StylePrivate::CC_ThemeChange);
+ d->setBackgroundTexture(qApp);
+ d->setThemePalette(qApp);
+}
+
+bool QS60Style::loadS60ThemeFromBlob(const QString &blobFile)
+{
+ QHash<QString, QPicture> partPictures;
+ QHash<QPair<QString, int>, QColor> colors;
+
+ if (!loadThemeFromBlob(blobFile, partPictures, colors))
+ return false;
+ setS60Theme(partPictures, colors);
+ return true;
+}
+
+bool QS60Style::saveS60ThemeToBlob(const QString &blobFile) const
+{
+ return saveThemeToBlob(blobFile,
+ QS60StyleModeSpecifics::m_partPictures, QS60StyleModeSpecifics::m_colors);
+}
+
+QPoint qt_s60_fill_background_offset(const QWidget *targetWidget)
+{
+ Q_UNUSED(targetWidget)
+ return QPoint();
}
QT_END_NAMESPACE
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 714b8c5..bd80bb6 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -5252,9 +5252,12 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi
#ifndef QT_NO_COMBOBOX
if (qobject_cast<const QComboBox *>(w)) {
QAbstractItemView *view = qFindChild<QAbstractItemView *>(w);
- QRenderRule subRule = renderRule(view, PseudoElement_None);
- if (subRule.hasBox() || !subRule.hasNativeBorder())
- return QFrame::NoFrame;
+ if (view) {
+ view->ensurePolished();
+ QRenderRule subRule = renderRule(view, PseudoElement_None);
+ if (subRule.hasBox() || !subRule.hasNativeBorder())
+ return QFrame::NoFrame;
+ }
}
#endif // QT_NO_COMBOBOX
break;
diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri
index 9aa170e..050d81d 100644
--- a/src/gui/styles/styles.pri
+++ b/src/gui/styles/styles.pri
@@ -160,9 +160,8 @@ contains( styles, s60 ) {
styles/qs60style.h \
styles/qs60style_p.h
SOURCES += styles/qs60style.cpp
- DEFINES += QT_S60STYLE_LAYOUTDATA_SIMULATED
symbian {
- SOURCES += styles/qs60style_symbian.cpp
+ SOURCES += styles/qs60style_s60.cpp
# TODO: fix the following LIBS hack. Line 1 is for armv5, 2 for winscw
LIBS += aknicon aknskins aknskinsrv fontutils
LIBS += -laknicon -laknskins -laknskinsrv -lfontutils
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 5a97086..0bd2d9a 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -1162,13 +1162,20 @@ static bool setFontWeightFromValue(const Value &value, QFont *font)
return true;
}
-static bool setFontFamilyFromValues(const QVector<Value> &values, QFont *font)
+/** \internal
+ * parse the font family from the values (starting from index \a start)
+ * and set it the \a font
+ * \returns true if a family was extracted.
+ */
+static bool setFontFamilyFromValues(const QVector<Value> &values, QFont *font, int start = 0)
{
QString family;
- for (int i = 0; i < values.count(); ++i) {
+ for (int i = start; i < values.count(); ++i) {
const Value &v = values.at(i);
- if (v.type == Value::TermOperatorComma)
- break;
+ if (v.type == Value::TermOperatorComma) {
+ family += QLatin1Char(',');
+ continue;
+ }
const QString str = v.variant.toString();
if (str.isEmpty())
break;
@@ -1222,9 +1229,7 @@ static void parseShorthandFontProperty(const QVector<Value> &values, QFont *font
}
if (i < values.count()) {
- QString fam = values.at(i).variant.toString();
- if (!fam.isEmpty())
- font->setFamily(fam);
+ setFontFamilyFromValues(values, font, i);
}
}
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 6ee1d03..e324db6 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -173,8 +173,7 @@ Q_GUI_EXPORT int qt_defaultDpiX()
screen = subScreens.at(0);
dpi = qRound(screen->width() / (screen->physicalWidth() / qreal(25.4)));
#elif defined(Q_WS_S60)
- const TReal inchWidth = (TReal)S60->screenWidthInTwips / KTwipsPerInch;
- dpi = S60->screenWidthInPixels / inchWidth;
+ dpi = S60->defaultDpiX;
#endif // Q_WS_X11
return dpi;
@@ -202,8 +201,7 @@ Q_GUI_EXPORT int qt_defaultDpiY()
screen = subScreens.at(0);
dpi = qRound(screen->height() / (screen->physicalHeight() / qreal(25.4)));
#elif defined(Q_WS_S60)
- const TReal inchHeight = (TReal)S60->screenHeightInTwips / KTwipsPerInch;
- dpi = S60->screenHeightInPixels / inchHeight;
+ dpi = S60->defaultDpiY;
#endif // Q_WS_X11
return dpi;
@@ -316,7 +314,7 @@ QFontPrivate *QFontPrivate::smallCapsFontPrivate() const
font.setPointSizeF(pointSize * .7);
else
font.setPixelSize((font.pixelSize() * 7 + 5) / 10);
- scFont = font.d;
+ scFont = font.d.data();
if (scFont != this)
scFont->ref.ref();
return scFont;
@@ -723,12 +721,11 @@ QFont::QFont(const QFont &font, QPaintDevice *pd)
const int screen = 0;
#endif
if (font.d->dpi != dpi || font.d->screen != screen ) {
- d = new QFontPrivate(*font.d);
+ d.reset(new QFontPrivate(*font.d));
d->dpi = dpi;
d->screen = screen;
} else {
- d = font.d;
- d->ref.ref();
+ d.assign(font.d.data());
}
#ifdef Q_WS_WIN
if (pd->devType() == QInternal::Printer && pd->getDC())
@@ -742,8 +739,7 @@ QFont::QFont(const QFont &font, QPaintDevice *pd)
QFont::QFont(QFontPrivate *data)
: resolve_mask(QFont::AllPropertiesResolved)
{
- d = data;
- d->ref.ref();
+ d.assign(data);
}
/*! \internal
@@ -755,13 +751,13 @@ void QFont::detach()
if (d->engineData)
d->engineData->ref.deref();
d->engineData = 0;
- if (d->scFont && d->scFont != d)
+ if (d->scFont && d->scFont != d.data())
d->scFont->ref.deref();
d->scFont = 0;
return;
}
- qAtomicDetach(d);
+ d.detach();
}
/*!
@@ -770,9 +766,9 @@ void QFont::detach()
\sa QApplication::setFont(), QApplication::font()
*/
QFont::QFont()
- :d(QApplication::font().d), resolve_mask(0)
+ :resolve_mask(0)
{
- d->ref.ref();
+ d.assign(QApplication::font().d.data());
}
/*!
@@ -792,13 +788,12 @@ QFont::QFont()
setStyleHint() QApplication::font()
*/
QFont::QFont(const QString &family, int pointSize, int weight, bool italic)
- :d(new QFontPrivate)
{
+ d.reset(new QFontPrivate());
resolve_mask = QFont::FamilyResolved;
if (pointSize <= 0) {
#ifdef Q_WS_S60
- // TODO: What should the default QFont pointSize for Q_WS_S60 be?
pointSize = 7;
#else
pointSize = 12;
@@ -825,8 +820,7 @@ QFont::QFont(const QString &family, int pointSize, int weight, bool italic)
*/
QFont::QFont(const QFont &font)
{
- d = font.d;
- d->ref.ref();
+ d.assign(font.d.data());
resolve_mask = font.resolve_mask;
}
@@ -835,8 +829,6 @@ QFont::QFont(const QFont &font)
*/
QFont::~QFont()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -844,7 +836,7 @@ QFont::~QFont()
*/
QFont &QFont::operator=(const QFont &font)
{
- qAtomicAssign(d, font.d);
+ d.assign(font.d.data());
resolve_mask = font.resolve_mask;
return *this;
}
@@ -1727,7 +1719,7 @@ QFont QFont::resolve(const QFont &other) const
QFont font(*this);
font.detach();
- font.d->resolve(resolve_mask, other.d);
+ font.d->resolve(resolve_mask, other.d.data());
return font;
}
@@ -1911,6 +1903,20 @@ void QFont::insertSubstitutions(const QString &familyName,
}
}
+/*! \fn void QFont::initialize()
+ \internal
+
+ Internal function that initializes the font system. The font cache
+ and font dict do not alloc the keys. The key is a QString which is
+ shared between QFontPrivate and QXFontName.
+*/
+
+/*! \fn void QFont::cleanup()
+ \internal
+
+ Internal function that cleans up the font system.
+*/
+
// ### mark: should be called removeSubstitutions()
/*!
Removes all the substitutions for \a familyName.
@@ -2166,11 +2172,11 @@ QDataStream &operator<<(QDataStream &s, const QFont &font)
s << (quint8) font.d->request.styleStrategy;
s << (quint8) 0
<< (quint8) font.d->request.weight
- << get_font_bits(s.version(), font.d);
+ << get_font_bits(s.version(), font.d.data());
if (s.version() >= QDataStream::Qt_4_3)
s << (quint16)font.d->request.stretch;
if (s.version() >= QDataStream::Qt_4_4)
- s << get_extended_font_bits(font.d);
+ s << get_extended_font_bits(font.d.data());
if (s.version() >= QDataStream::Qt_4_5) {
s << font.d->letterSpacing.value();
s << font.d->wordSpacing.value();
@@ -2189,10 +2195,8 @@ QDataStream &operator<<(QDataStream &s, const QFont &font)
*/
QDataStream &operator>>(QDataStream &s, QFont &font)
{
- if (!font.d->ref.deref())
- delete font.d;
-
- font.d = new QFontPrivate;
+ font.d.assign(0);
+ font.d.reset(new QFontPrivate);
font.resolve_mask = QFont::AllPropertiesResolved;
quint8 styleHint, styleStrategy = QFont::PreferDefault, charSet, weight, bits;
@@ -2233,7 +2237,7 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
font.d->request.styleStrategy = styleStrategy;
font.d->request.weight = weight;
- set_font_bits(s.version(), bits, font.d);
+ set_font_bits(s.version(), bits, font.d.data());
if (s.version() >= QDataStream::Qt_4_3) {
quint16 stretch;
@@ -2244,7 +2248,7 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
if (s.version() >= QDataStream::Qt_4_4) {
quint8 extendedBits;
s >> extendedBits;
- set_extended_font_bits(extendedBits, font.d);
+ set_extended_font_bits(extendedBits, font.d.data());
}
if (s.version() >= QDataStream::Qt_4_5) {
int value;
@@ -2326,7 +2330,7 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
that is not screen-compatible.
*/
QFontInfo::QFontInfo(const QFont &font)
- : d(font.d)
+ : d(font.d.data())
{ d->ref.ref(); }
/*!
@@ -2599,7 +2603,14 @@ QFontCache *QFontCache::instance()
void QFontCache::cleanup()
{
- theFontCache()->setLocalData(0);
+ QThreadStorage<QFontCache *> *cache = 0;
+ QT_TRY {
+ cache = theFontCache();
+ } QT_CATCH (const std::bad_alloc &) {
+ // no cache - just ignore
+ }
+ if (cache && cache->hasLocalData())
+ cache->setLocalData(0);
}
#endif // QT_NO_THREAD
@@ -2612,8 +2623,8 @@ QFontCache::QFontCache()
QFontCache::~QFontCache()
{
{
- EngineDataCache::Iterator it = engineDataCache.begin(),
- end = engineDataCache.end();
+ EngineDataCache::ConstIterator it = engineDataCache.constBegin(),
+ end = engineDataCache.constEnd();
while (it != end) {
if (it.value()->ref == 0)
delete it.value();
@@ -2623,8 +2634,8 @@ QFontCache::~QFontCache()
++it;
}
}
- EngineCache::Iterator it = engineCache.begin(),
- end = engineCache.end();
+ EngineCache::ConstIterator it = engineCache.constBegin(),
+ end = engineCache.constEnd();
while (it != end) {
if (--it.value().data->cache_count == 0) {
if (it.value().data->ref == 0) {
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index eec83b5..a513b7a 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -44,6 +44,7 @@
#include <QtGui/qwindowdefs.h>
#include <QtCore/qstring.h>
+#include <QtCore/qscopedpointer.h>
#if defined(Q_WS_X11) || defined(Q_WS_QWS)
typedef struct FT_FaceRec_* FT_Face;
@@ -312,7 +313,7 @@ private:
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QFont &);
#endif
- QFontPrivate *d;
+ QScopedSharedPointer<QFontPrivate> d;
uint resolve_mask;
};
diff --git a/src/gui/text/qfont_s60.cpp b/src/gui/text/qfont_s60.cpp
index 2606091..533e51f 100644
--- a/src/gui/text/qfont_s60.cpp
+++ b/src/gui/text/qfont_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
diff --git a/src/gui/text/qfont_x11.cpp b/src/gui/text/qfont_x11.cpp
index 710792c..6b0e46c 100644
--- a/src/gui/text/qfont_x11.cpp
+++ b/src/gui/text/qfont_x11.cpp
@@ -129,13 +129,6 @@ Q_GUI_EXPORT void qt_x11_set_fallback_font_family(int script, const QString &fam
int QFontPrivate::defaultEncodingID = -1;
-/*!
- Internal function that initializes the font system.
-
- \internal
- The font cache and font dict do not alloc the keys. The key is a QString
- which is shared between QFontPrivate and QXFontName.
-*/
void QFont::initialize()
{
extern int qt_encoding_id_for_mib(int mib); // from qfontdatabase_x11.cpp
@@ -184,10 +177,6 @@ void QFont::initialize()
QFontPrivate::defaultEncodingID = qt_encoding_id_for_mib(mib);
}
-/*! \internal
-
- Internal function that cleans up the font system.
-*/
void QFont::cleanup()
{
QFontCache::cleanup();
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 1345d21..416017d 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -167,10 +167,13 @@ QtFontEncoding *QtFontSize::encodingID(int id, uint xpoint, uint xres,
if (!add) return 0;
- if (!(count % 4))
- encodings = (QtFontEncoding *)
+ if (!(count % 4)) {
+ QtFontEncoding *newEncodings = (QtFontEncoding *)
realloc(encodings,
(((count+4) >> 2) << 2) * sizeof(QtFontEncoding));
+ Q_CHECK_PTR(newEncodings);
+ encodings = newEncodings;
+ }
encodings[count].encoding = id;
encodings[count].xpoint = xpoint;
encodings[count].xres = xres;
@@ -274,10 +277,13 @@ QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add)
if (!add)
return 0;
- if (!(count % 8))
- pixelSizes = (QtFontSize *)
+ if (!(count % 8)) {
+ QtFontSize *newPixelSizes = (QtFontSize *)
realloc(pixelSizes,
(((count+8) >> 3) << 3) * sizeof(QtFontSize));
+ Q_CHECK_PTR(newPixelSizes);
+ pixelSizes = newPixelSizes;
+ }
pixelSizes[count].pixelSize = size;
#ifdef Q_WS_X11
pixelSizes[count].count = 0;
@@ -328,12 +334,16 @@ QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, bool create)
return 0;
// qDebug("adding key (weight=%d, style=%d, oblique=%d stretch=%d) at %d", key.weight, key.style, key.oblique, key.stretch, pos);
- if (!(count % 8))
- styles = (QtFontStyle **)
+ if (!(count % 8)) {
+ QtFontStyle **newStyles = (QtFontStyle **)
realloc(styles, (((count+8) >> 3) << 3) * sizeof(QtFontStyle *));
+ Q_CHECK_PTR(newStyles);
+ styles = newStyles;
+ }
+ QtFontStyle *style = new QtFontStyle(key);
memmove(styles + pos + 1, styles + pos, (count-pos)*sizeof(QtFontStyle *));
- styles[pos] = new QtFontStyle(key);
+ styles[pos] = style;
count++;
return styles[pos];
}
@@ -438,10 +448,13 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create)
if (!create)
return 0;
- if (!(count % 8))
- foundries = (QtFontFoundry **)
+ if (!(count % 8)) {
+ QtFontFoundry **newFoundries = (QtFontFoundry **)
realloc(foundries,
(((count+8) >> 3) << 3) * sizeof(QtFontFoundry *));
+ Q_CHECK_PTR(newFoundries);
+ foundries = newFoundries;
+ }
foundries[count] = new QtFontFoundry(f);
return foundries[count++];
@@ -684,13 +697,17 @@ QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create)
pos++;
// qDebug("adding family %s at %d total=%d", f.latin1(), pos, count);
- if (!(count % 8))
- families = (QtFontFamily **)
+ if (!(count % 8)) {
+ QtFontFamily **newFamilies = (QtFontFamily **)
realloc(families,
(((count+8) >> 3) << 3) * sizeof(QtFontFamily *));
+ Q_CHECK_PTR(newFamilies);
+ families = newFamilies;
+ }
+ QtFontFamily *family = new QtFontFamily(f);
memmove(families + pos + 1, families + pos, (count-pos)*sizeof(QtFontFamily *));
- families[pos] = new QtFontFamily(f);
+ families[pos] = family;
count++;
return families[pos];
}
@@ -969,6 +986,7 @@ static void getEngineData(const QFontPrivate *d, const QFontCache::Key &key)
d->engineData->ref.ref();
}
}
+#endif
static QStringList familyList(const QFontDef &req)
{
@@ -997,7 +1015,6 @@ static QStringList familyList(const QFontDef &req)
return family_list;
}
-#endif
Q_GLOBAL_STATIC(QFontDatabasePrivate, privateDb)
Q_GLOBAL_STATIC_WITH_ARGS(QMutex, fontDatabaseMutex, (QMutex::Recursive))
diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp
index 80ddbd5..26d8687 100644
--- a/src/gui/text/qfontdatabase_mac.cpp
+++ b/src/gui/text/qfontdatabase_mac.cpp
@@ -281,14 +281,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
}
//find the font
- QStringList family_list = req.family.split(QLatin1Char(','));
- // append the substitute list for each family in family_list
- {
- QStringList subs_list;
- for(QStringList::ConstIterator it = family_list.constBegin(); it != family_list.constEnd(); ++it)
- subs_list += QFont::substitutes(*it);
- family_list += subs_list;
- }
+ QStringList family_list = familyList(req);
const char *stylehint = styleHint(req);
if (stylehint)
diff --git a/src/gui/text/qfontdatabase_qws.cpp b/src/gui/text/qfontdatabase_qws.cpp
index 33b0728..978ff8e 100644
--- a/src/gui/text/qfontdatabase_qws.cpp
+++ b/src/gui/text/qfontdatabase_qws.cpp
@@ -566,8 +566,8 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp,
QFontEngineQPF *fe = new QFontEngineQPF(request, res.data(), res.size());
if (fe->isValid())
return fe;
- qDebug() << "fontengine is not valid! " << size->fileName;
delete fe;
+ qDebug() << "fontengine is not valid! " << size->fileName;
} else {
qDebug() << "Resource not valid" << size->fileName;
}
@@ -577,8 +577,8 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp,
QFontEngineQPF *fe = new QFontEngineQPF(request, f);
if (fe->isValid())
return fe;
- qDebug() << "fontengine is not valid!";
delete fe; // will close f
+ qDebug() << "fontengine is not valid!";
}
#endif
} else
@@ -592,70 +592,67 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp,
static bool dontShareFonts = !qgetenv("QWS_NO_SHARE_FONTS").isEmpty();
bool shareFonts = !dontShareFonts;
- QFontEngine *engine = 0;
+ QScopedPointer<QFontEngine> engine;
#ifndef QT_NO_LIBRARY
QFontEngineFactoryInterface *factory = qobject_cast<QFontEngineFactoryInterface *>(loader()->instance(foundry->name));
- if (factory) {
- QFontEngineInfo info;
- info.setFamily(request.family);
- info.setPixelSize(request.pixelSize);
- info.setStyle(QFont::Style(request.style));
- info.setWeight(request.weight);
- // #### antialiased
-
- QAbstractFontEngine *customEngine = factory->create(info);
- if (customEngine) {
- engine = new QProxyFontEngine(customEngine, def);
-
- if (shareFonts) {
- QVariant hint = customEngine->fontProperty(QAbstractFontEngine::CacheGlyphsHint);
- if (hint.isValid())
- shareFonts = hint.toBool();
- else
- shareFonts = (pixelSize < 64);
- }
+ if (factory) {
+ QFontEngineInfo info;
+ info.setFamily(request.family);
+ info.setPixelSize(request.pixelSize);
+ info.setStyle(QFont::Style(request.style));
+ info.setWeight(request.weight);
+ // #### antialiased
+
+ QAbstractFontEngine *customEngine = factory->create(info);
+ if (customEngine) {
+ engine.reset(new QProxyFontEngine(customEngine, def));
+
+ if (shareFonts) {
+ QVariant hint = customEngine->fontProperty(QAbstractFontEngine::CacheGlyphsHint);
+ if (hint.isValid())
+ shareFonts = hint.toBool();
+ else
+ shareFonts = (pixelSize < 64);
}
+ }
}
#endif // QT_NO_LIBRARY
- if (!engine && !file.isEmpty() && QFile::exists(file) || privateDb()->isApplicationFont(file)) {
+ if ((engine.isNull() && !file.isEmpty() && QFile::exists(file)) || privateDb()->isApplicationFont(file)) {
QFontEngine::FaceId faceId;
faceId.filename = file.toLocal8Bit();
faceId.index = size->fileIndex;
#ifndef QT_NO_FREETYPE
- QFontEngineFT *fte = new QFontEngineFT(def);
+ QScopedPointer<QFontEngineFT> fte(new QFontEngineFT(def));
if (fte->init(faceId, style->antialiased,
style->antialiased ? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono)) {
#ifdef QT_NO_QWS_QPF2
- return fte;
+ return fte.take();
#else
- engine = fte;
// try to distinguish between bdf and ttf fonts we can pre-render
// and don't try to share outline fonts
shareFonts = shareFonts
&& !fte->defaultGlyphs()->outline_drawing
&& !fte->getSfntTable(MAKE_TAG('h', 'e', 'a', 'd')).isEmpty();
+ engine.reset(fte.take());
#endif
- } else {
- delete fte;
}
#endif // QT_NO_FREETYPE
}
- if (engine) {
+ if (!engine.isNull()) {
#if !defined(QT_NO_QWS_QPF2) && !defined(QT_FONTS_ARE_RESOURCES)
if (shareFonts) {
- QFontEngineQPF *fe = new QFontEngineQPF(def, -1, engine);
- engine = 0;
+ QScopedPointer<QFontEngineQPF> fe(new QFontEngineQPF(def, -1, engine.data()));
+ engine.take();
if (fe->isValid())
- return fe;
+ return fe.take();
qWarning("Initializing QFontEngineQPF failed for %s", qPrintable(file));
- engine = fe->takeRenderingEngine();
- delete fe;
+ engine.reset(fe->takeRenderingEngine());
}
#endif
- return engine;
+ return engine.take();
}
} else
{
@@ -682,20 +679,22 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp,
QtFontFamily *family, QtFontFoundry *foundry,
QtFontStyle *style, QtFontSize *size)
{
- QFontEngine *fe = loadSingleEngine(script, fp, request, family, foundry,
- style, size);
- if (fe
+ QScopedPointer<QFontEngine> engine(loadSingleEngine(script, fp, request, family, foundry,
+ style, size));
+ if (!engine.isNull()
&& script == QUnicodeTables::Common
- && !(request.styleStrategy & QFont::NoFontMerging) && !fe->symbol) {
+ && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) {
QStringList fallbacks = privateDb()->fallbackFamilies;
if (family && !family->fallbackFamilies.isEmpty())
fallbacks = family->fallbackFamilies;
- fe = new QFontEngineMultiQWS(fe, script, fallbacks);
+ QFontEngine *fe = new QFontEngineMultiQWS(engine.data(), script, fallbacks);
+ engine.take();
+ engine.reset(fe);
}
- return fe;
+ return engine.take();
}
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp
index 0b4567c..416c3d1 100644
--- a/src/gui/text/qfontdatabase_s60.cpp
+++ b/src/gui/text/qfontdatabase_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
@@ -25,6 +55,39 @@
QT_BEGIN_NAMESPACE
+QFileInfoList alternativeFilePaths(const QString &path, const QStringList &nameFilters,
+ QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort,
+ bool uniqueFileNames = true)
+{
+ QFileInfoList result;
+
+ // Prepare a 'soft to hard' drive list: W:, X: ... A:, Z:
+ QStringList driveStrings;
+ foreach (const QFileInfo &drive, QDir::drives())
+ driveStrings.append(drive.absolutePath());
+ driveStrings.sort();
+ const QString zDriveString("Z:/");
+ driveStrings.removeAll(zDriveString);
+ driveStrings.prepend(zDriveString);
+
+ QStringList uniqueFileNameList;
+ for (int i = driveStrings.count() - 1; i >= 0; --i) {
+ const QDir dirOnDrive(driveStrings.at(i) + path);
+ const QFileInfoList entriesOnDrive = dirOnDrive.entryInfoList(nameFilters, filters, sort);
+ if (uniqueFileNames) {
+ foreach(const QFileInfo &entry, entriesOnDrive) {
+ if (!uniqueFileNameList.contains(entry.fileName())) {
+ uniqueFileNameList.append(entry.fileName());
+ result.append(entry);
+ }
+ }
+ } else {
+ result.append(entriesOnDrive);
+ }
+ }
+ return result;
+}
+
#if defined(QT_NO_FREETYPE)
class QFontDatabaseS60StoreImplementation : public QFontDatabaseS60Store
{
@@ -47,10 +110,13 @@ QFontDatabaseS60StoreImplementation::QFontDatabaseS60StoreImplementation()
m_store = CFontStore::NewL(m_heap);
m_rasterizer = COpenFontRasterizer::NewL(TUid::Uid(0x101F7F5E));
m_store->InstallRasterizerL(m_rasterizer);
- QDir dir(QDesktopServices::storageLocation(QDesktopServices::FontsLocation));
- dir.setNameFilters(QStringList() << QLatin1String("*.ttf") << QLatin1String("*.ccc"));
- for (int i = 0; i < int(dir.count()); ++i) {
- const QString fontFile = QDir::toNativeSeparators(dir.absoluteFilePath(dir[i]));
+
+ QStringList filters;
+ filters.append(QString::fromLatin1("*.ttf"));
+ filters.append(QString::fromLatin1("*.ccc"));
+ const QFileInfoList fontFiles = alternativeFilePaths(QString::fromLatin1("resource\\Fonts"), filters);
+ foreach (const QFileInfo &fontFileInfo, fontFiles) {
+ const QString fontFile = QDir::toNativeSeparators(fontFileInfo.absoluteFilePath());
m_store->AddFileL(qt_QString2TPtrC(fontFile));
}
}
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp
index 15e626e..70e1599 100644
--- a/src/gui/text/qfontdatabase_x11.cpp
+++ b/src/gui/text/qfontdatabase_x11.cpp
@@ -494,7 +494,7 @@ static inline bool isFixedPitch(char **tokens)
Fills in a font definition (QFontDef) from an XLFD (X Logical Font
Description).
- Returns true if the the given xlfd is valid.
+ Returns true if the given xlfd is valid.
*/
bool qt_fillFontDef(const QByteArray &xlfd, QFontDef *fd, int dpi, QtFontDesc *desc)
{
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index c2c23ee..2f96984 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -191,18 +191,20 @@ QFontEngine::QFontEngine()
QFontEngine::~QFontEngine()
{
- for (GlyphPointerHash::iterator it = m_glyphPointerHash.begin(), end = m_glyphPointerHash.end();
- it != end; ++it) {
- for (QList<QFontEngineGlyphCache*>::iterator it2 = it.value().begin(), end2 = it.value().end();
- it2 != end2; ++it2)
- delete *it2;
+ for (GlyphPointerHash::const_iterator it = m_glyphPointerHash.constBegin(),
+ end = m_glyphPointerHash.constEnd(); it != end; ++it) {
+ for (QList<QFontEngineGlyphCache*>::const_iterator it2 = it.value().constBegin(),
+ end2 = it.value().constEnd(); it2 != end2; ++it2) {
+ delete *it2;
+ }
}
m_glyphPointerHash.clear();
- for (GlyphIntHash::iterator it = m_glyphIntHash.begin(), end = m_glyphIntHash.end();
- it != end; ++it) {
- for (QList<QFontEngineGlyphCache*>::iterator it2 = it.value().begin(), end2 = it.value().end();
- it2 != end2; ++it2)
- delete *it2;
+ for (GlyphIntHash::const_iterator it = m_glyphIntHash.constBegin(),
+ end = m_glyphIntHash.constEnd(); it != end; ++it) {
+ for (QList<QFontEngineGlyphCache*>::const_iterator it2 = it.value().constBegin(),
+ end2 = it.value().constEnd(); it2 != end2; ++it2) {
+ delete *it2;
+ }
}
m_glyphIntHash.clear();
qHBFreeFace(hbFace);
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 6f5ee1f..f1dac96 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -193,6 +193,9 @@ HB_Error QFreetypeFace::getPointInOutline(HB_Glyph glyph, int flags, hb_uint32 p
/*
* One font file can contain more than one font (bold/italic for example)
* find the right one and return it.
+ *
+ * Returns the freetype face or 0 in case of an empty file or any other problems
+ * (like not being able to open the file)
*/
QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id)
{
@@ -205,7 +208,7 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id)
QFreetypeFace *freetype = freetypeData->faces.value(face_id, 0);
if (!freetype) {
- freetype = new QFreetypeFace;
+ QScopedPointer<QFreetypeFace> newFreetype(new QFreetypeFace);
FT_Face face;
QFile file(QString::fromUtf8(face_id.filename));
if (face_id.filename.startsWith(":qmemoryfonts/")) {
@@ -214,84 +217,82 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id)
QByteArray idx = face_id.filename;
idx.remove(0, 14); // remove ':qmemoryfonts/'
bool ok = false;
- freetype->fontData = qt_fontdata_from_index(idx.toInt(&ok));
+ newFreetype->fontData = qt_fontdata_from_index(idx.toInt(&ok));
if (!ok)
- freetype->fontData = QByteArray();
+ newFreetype->fontData = QByteArray();
} else if (!(file.fileEngine()->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::LocalDiskFlag)) {
if (!file.open(QIODevice::ReadOnly)) {
- delete freetype;
return 0;
}
- freetype->fontData = file.readAll();
+ newFreetype->fontData = file.readAll();
}
- if (!freetype->fontData.isEmpty()) {
- if (FT_New_Memory_Face(freetypeData->library, (const FT_Byte *)freetype->fontData.constData(), freetype->fontData.size(), face_id.index, &face)) {
- delete freetype;
+ if (!newFreetype->fontData.isEmpty()) {
+ if (FT_New_Memory_Face(freetypeData->library, (const FT_Byte *)newFreetype->fontData.constData(), newFreetype->fontData.size(), face_id.index, &face)) {
return 0;
}
} else if (FT_New_Face(freetypeData->library, face_id.filename, face_id.index, &face)) {
- delete freetype;
return 0;
}
- freetype->face = face;
-
- freetype->hbFace = qHBNewFace(face, hb_getSFntTable);
- freetype->ref = 0;
- freetype->xsize = 0;
- freetype->ysize = 0;
- freetype->matrix.xx = 0x10000;
- freetype->matrix.yy = 0x10000;
- freetype->matrix.xy = 0;
- freetype->matrix.yx = 0;
- freetype->unicode_map = 0;
- freetype->symbol_map = 0;
+ newFreetype->face = face;
+
+ newFreetype->hbFace = qHBNewFace(face, hb_getSFntTable);
+ newFreetype->ref = 0;
+ newFreetype->xsize = 0;
+ newFreetype->ysize = 0;
+ newFreetype->matrix.xx = 0x10000;
+ newFreetype->matrix.yy = 0x10000;
+ newFreetype->matrix.xy = 0;
+ newFreetype->matrix.yx = 0;
+ newFreetype->unicode_map = 0;
+ newFreetype->symbol_map = 0;
#ifndef QT_NO_FONTCONFIG
- freetype->charset = 0;
+ newFreetype->charset = 0;
#endif
- memset(freetype->cmapCache, 0, sizeof(freetype->cmapCache));
+ memset(newFreetype->cmapCache, 0, sizeof(newFreetype->cmapCache));
- for (int i = 0; i < freetype->face->num_charmaps; ++i) {
- FT_CharMap cm = freetype->face->charmaps[i];
+ for (int i = 0; i < newFreetype->face->num_charmaps; ++i) {
+ FT_CharMap cm = newFreetype->face->charmaps[i];
switch(cm->encoding) {
case FT_ENCODING_UNICODE:
- freetype->unicode_map = cm;
+ newFreetype->unicode_map = cm;
break;
case FT_ENCODING_APPLE_ROMAN:
case FT_ENCODING_ADOBE_LATIN_1:
- if (!freetype->unicode_map || freetype->unicode_map->encoding != FT_ENCODING_UNICODE)
- freetype->unicode_map = cm;
+ if (!newFreetype->unicode_map || newFreetype->unicode_map->encoding != FT_ENCODING_UNICODE)
+ newFreetype->unicode_map = cm;
break;
case FT_ENCODING_ADOBE_CUSTOM:
case FT_ENCODING_MS_SYMBOL:
- if (!freetype->symbol_map)
- freetype->symbol_map = cm;
+ if (!newFreetype->symbol_map)
+ newFreetype->symbol_map = cm;
break;
default:
break;
}
}
- if (!FT_IS_SCALABLE(freetype->face) && freetype->face->num_fixed_sizes == 1)
- FT_Set_Char_Size (face, X_SIZE(freetype->face, 0), Y_SIZE(freetype->face, 0), 0, 0);
+ if (!FT_IS_SCALABLE(newFreetype->face) && newFreetype->face->num_fixed_sizes == 1)
+ FT_Set_Char_Size (face, X_SIZE(newFreetype->face, 0), Y_SIZE(newFreetype->face, 0), 0, 0);
# if 0
FcChar8 *name;
FcPatternGetString(pattern, FC_FAMILY, 0, &name);
qDebug("%s: using maps: default: %x unicode: %x, symbol: %x", name,
- freetype->face->charmap ? freetype->face->charmap->encoding : 0,
- freetype->unicode_map ? freetype->unicode_map->encoding : 0,
- freetype->symbol_map ? freetype->symbol_map->encoding : 0);
+ newFreetype->face->charmap ? newFreetype->face->charmap->encoding : 0,
+ newFreetype->unicode_map ? newFreetype->unicode_map->encoding : 0,
+ newFreetype->symbol_map ? newFreetype->symbol_map->encoding : 0);
for (int i = 0; i < 256; i += 8)
qDebug(" %x: %d %d %d %d %d %d %d %d", i,
- FcCharSetHasChar(freetype->charset, i), FcCharSetHasChar(freetype->charset, i),
- FcCharSetHasChar(freetype->charset, i), FcCharSetHasChar(freetype->charset, i),
- FcCharSetHasChar(freetype->charset, i), FcCharSetHasChar(freetype->charset, i),
- FcCharSetHasChar(freetype->charset, i), FcCharSetHasChar(freetype->charset, i));
+ FcCharSetHasChar(newFreetype->charset, i), FcCharSetHasChar(newFreetype->charset, i),
+ FcCharSetHasChar(newFreetype->charset, i), FcCharSetHasChar(newFreetype->charset, i),
+ FcCharSetHasChar(newFreetype->charset, i), FcCharSetHasChar(newFreetype->charset, i),
+ FcCharSetHasChar(newFreetype->charset, i), FcCharSetHasChar(newFreetype->charset, i));
#endif
- FT_Set_Charmap(freetype->face, freetype->unicode_map);
- freetypeData->faces.insert(face_id, freetype);
+ FT_Set_Charmap(newFreetype->face, newFreetype->unicode_map);
+ freetypeData->faces.insert(face_id, newFreetype.data());
+ freetype = newFreetype.take();
}
freetype->ref.ref();
return freetype;
@@ -608,6 +609,7 @@ QFontEngineFT::QFontEngineFT(const QFontDef &fd)
kerning_pairs_loaded = false;
transform = false;
antialias = true;
+ freetype = 0;
default_load_flags = 0;
default_hint_style = HintNone;
subpixelType = Subpixel_None;
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 649d78b..b67895b 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -119,6 +119,7 @@ struct QFreetypeFace
static void addBitmapToPath(FT_GlyphSlot slot, const QFixedPoint &point, QPainterPath *path, bool = false);
private:
+ friend class QScopedPointer<QFreetypeFace>;
QFreetypeFace() : _lock(QMutex::Recursive) {}
~QFreetypeFace() {}
QAtomicInt ref;
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 425cab2..d397e4a 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -553,7 +553,9 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph)
8, im.bytesPerLine(), colorspace,
cgflags);
CGContextSetFontSize(ctx, fontDef.pixelSize);
- CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold && !(fontDef.styleStrategy & QFont::NoAntialias));
+ CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold
+ && !(fontDef.styleStrategy & QFont::NoAntialias));
+ CGContextSetShouldSmoothFonts(ctx, false);
CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp
index e9fcac4..435a102 100644
--- a/src/gui/text/qfontengine_qpf.cpp
+++ b/src/gui/text/qfontengine_qpf.cpp
@@ -325,21 +325,21 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng
fileName.replace(QLatin1Char(' '), QLatin1Char('_'));
fileName.prepend(qws_fontCacheDir());
- const QByteArray encodedName = QFile::encodeName(fileName);
- if (::access(encodedName, F_OK) == 0) {
+ encodedFileName = QFile::encodeName(fileName);
+ if (::access(encodedFileName, F_OK) == 0) {
#if defined(DEBUG_FONTENGINE)
qDebug() << "found existing qpf:" << fileName;
#endif
- if (::access(encodedName, W_OK | R_OK) == 0)
- fd = ::open(encodedName, O_RDWR);
- else if (::access(encodedName, R_OK) == 0)
- fd = ::open(encodedName, O_RDONLY);
+ if (::access(encodedFileName, W_OK | R_OK) == 0)
+ fd = ::open(encodedFileName, O_RDWR);
+ else if (::access(encodedFileName, R_OK) == 0)
+ fd = ::open(encodedFileName, O_RDONLY);
} else {
#if defined(DEBUG_FONTENGINE)
qDebug() << "creating qpf on the fly:" << fileName;
#endif
if (::access(QFile::encodeName(qws_fontCacheDir()), W_OK) == 0) {
- fd = ::open(encodedName, O_RDWR | O_EXCL | O_CREAT, 0644);
+ fd = ::open(encodedFileName, O_RDWR | O_EXCL | O_CREAT, 0644);
QBuffer buffer;
buffer.open(QIODevice::ReadWrite);
@@ -474,15 +474,21 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng
#endif
#if defined(Q_WS_QWS)
if (isValid() && renderingFontEngine)
- qt_fbdpy->sendFontCommand(QWSFontCommand::StartedUsingFont, QFile::encodeName(fileName));
+ qt_fbdpy->sendFontCommand(QWSFontCommand::StartedUsingFont, encodedFileName);
#endif
}
QFontEngineQPF::~QFontEngineQPF()
{
#if defined(Q_WS_QWS)
- if (isValid() && renderingFontEngine)
- qt_fbdpy->sendFontCommand(QWSFontCommand::StoppedUsingFont, QFile::encodeName(fileName));
+ if (isValid() && renderingFontEngine) {
+ QT_TRY {
+ qt_fbdpy->sendFontCommand(QWSFontCommand::StoppedUsingFont, encodedFileName);
+ } QT_CATCH(...) {
+ qDebug("QFontEngineQPF::~QFontEngineQPF: Out of memory");
+ // ignore.
+ }
+ }
#endif
delete renderingFontEngine;
if (fontData)
@@ -1128,6 +1134,11 @@ void QPFGenerator::writeTaggedQFixed(QFontEngineQPF::HeaderTag tag, QFixed value
#endif // QT_NO_QWS_QPF2
+/*
+ Creates a new multi qws engine.
+
+ This function takes ownership of the QFontEngine, increasing it's refcount.
+*/
QFontEngineMultiQWS::QFontEngineMultiQWS(QFontEngine *fe, int _script, const QStringList &fallbacks)
: QFontEngineMulti(fallbacks.size() + 1),
fallbackFamilies(fallbacks), script(_script)
diff --git a/src/gui/text/qfontengine_qpf_p.h b/src/gui/text/qfontengine_qpf_p.h
index a9b87ff..629f5c6 100644
--- a/src/gui/text/qfontengine_qpf_p.h
+++ b/src/gui/text/qfontengine_qpf_p.h
@@ -243,6 +243,7 @@ private:
quint32 glyphDataOffset;
quint32 glyphDataSize;
QString fileName;
+ QByteArray encodedFileName;
bool readOnly;
QFreetypeFace *freetype;
diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp
index eec09f4..2e1abb2 100644
--- a/src/gui/text/qfontengine_s60.cpp
+++ b/src/gui/text/qfontengine_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
@@ -197,27 +227,14 @@ QImage QFontEngineS60::alphaMapForGlyph(glyph_t glyph)
glyph_metrics_t QFontEngineS60::boundingBox(const QGlyphLayout &glyphs)
{
- glyph_metrics_t overall;
- // initialize with line height, we get the same behaviour on all platforms
- overall.y = -ascent();
- overall.height = ascent() + descent() + 1;
-
- QFixed ymax = 0;
- QFixed xmax = 0;
- for (int i = 0; i < glyphs.numGlyphs; i++) {
- const glyph_metrics_t glyphBounds = boundingBox_const(glyphs.glyphs[i]);
- QFixed x = overall.xoff + glyphs.offsets[i].x + glyphBounds.x;
- QFixed y = overall.yoff + glyphs.offsets[i].y - glyphBounds.y;
- overall.x = qMin(overall.x, x);
- overall.y = qMin(overall.y, y);
- xmax = qMax(xmax, x + glyphBounds.width);
- ymax = qMax(ymax, y + glyphBounds.height);
- overall.xoff += glyphBounds.xoff;
- }
- overall.height = qMax(overall.height, ymax - overall.y);
- overall.width = xmax - overall.x;
+ if (glyphs.numGlyphs == 0)
+ return glyph_metrics_t();
+
+ QFixed w = 0;
+ for (int i = 0; i < glyphs.numGlyphs; ++i)
+ w += glyphs.effectiveAdvance(i);
- return overall;
+ return glyph_metrics_t(0, -ascent(), w, ascent()+descent()+1, w, 0);
}
glyph_metrics_t QFontEngineS60::boundingBox_const(glyph_t glyph) const
diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h
index ef4a508..2998de8 100644
--- a/src/gui/text/qfontengine_s60_p.h
+++ b/src/gui/text/qfontengine_s60_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index bf3a176..dc2e1ff 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -1335,7 +1335,7 @@ bool QFontEngineWin::getSfntTableData(uint tag, uchar *buffer, uint *length) con
QNativeImage *QFontEngineWin::drawGDIGlyph(HFONT font, glyph_t glyph, int margin,
- const QTransform &t)
+ const QTransform &t, QImage::Format mask_format)
{
glyph_metrics_t gm = boundingBox(glyph);
@@ -1406,9 +1406,9 @@ QNativeImage *QFontEngineWin::drawGDIGlyph(HFONT font, glyph_t glyph, int margin
#endif
#endif
- QNativeImage *ni = new QNativeImage(iw + 2 * margin + 2,
- ih + 2 * margin + 2,
- QNativeImage::systemFormat(), true);
+ QNativeImage *ni = new QNativeImage(iw + 2 * margin + 4,
+ ih + 2 * margin + 4,
+ mask_format, true);
ni->image.fill(0xffffffff);
HDC hdc = ni->hdc;
@@ -1448,8 +1448,12 @@ QImage QFontEngineWin::alphaMapForGlyph(glyph_t glyph, const QTransform &xform)
lf.lfQuality = ANTIALIASED_QUALITY;
font = CreateFontIndirectW(&lf);
}
+ QImage::Format mask_format = QNativeImage::systemFormat();
+#ifndef Q_OS_WINCE
+ mask_format = QImage::Format_RGB32;
+#endif
- QNativeImage *mask = drawGDIGlyph(font, glyph, 2, xform);
+ QNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format);
if (mask == 0)
return QImage();
@@ -1466,22 +1470,20 @@ QImage QFontEngineWin::alphaMapForGlyph(glyph_t glyph, const QTransform &xform)
// Alpha channel of the ni.image pixels...
for (int y=0; y<mask->height(); ++y) {
uchar *dest = indexed.scanLine(y);
- if (mask->systemFormat() == QImage::Format_RGB16) {
+ if (mask->image.format() == QImage::Format_RGB16) {
const qint16 *src = (qint16 *) ((const QImage &) mask->image).scanLine(y);
- for (int x=0; x<mask->width(); ++x) {
-#ifdef Q_OS_WINCE
+ for (int x=0; x<mask->width(); ++x)
dest[x] = 255 - qGray(src[x]);
-#else
- dest[x] = 255 - (qt_pow_gamma[qGray(src[x])] * 255. / 2047.);
-#endif
- }
} else {
const uint *src = (uint *) ((const QImage &) mask->image).scanLine(y);
for (int x=0; x<mask->width(); ++x) {
#ifdef Q_OS_WINCE
dest[x] = 255 - qGray(src[x]);
#else
- dest[x] = 255 - (qt_pow_gamma[qGray(src[x])] * 255. / 2047.);
+ if (QNativeImage::systemFormat() == QImage::Format_RGB16)
+ dest[x] = 255 - qGray(src[x]);
+ else
+ dest[x] = 255 - (qt_pow_gamma[qGray(src[x])] * 255. / 2047.);
#endif
}
}
@@ -1507,7 +1509,7 @@ QImage QFontEngineWin::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTra
SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &contrast, 0);
SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) 1000, 0);
- QNativeImage *mask = drawGDIGlyph(font, glyph, margin, t);
+ QNativeImage *mask = drawGDIGlyph(font, glyph, margin, t, QImage::Format_RGB32);
SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) contrast, 0);
if (mask == 0)
diff --git a/src/gui/text/qfontengine_win_p.h b/src/gui/text/qfontengine_win_p.h
index 6f37e91..f78bc6a 100644
--- a/src/gui/text/qfontengine_win_p.h
+++ b/src/gui/text/qfontengine_win_p.h
@@ -138,7 +138,8 @@ public:
mutable int designAdvancesSize;
private:
- QNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform);
+ QNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform,
+ QImage::Format mask_format);
};
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 88d0610..991fed7 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -164,7 +164,7 @@ extern int qt_defaultDpi();
metrics that are compatible with a certain paint device.
*/
QFontMetrics::QFontMetrics(const QFont &font)
- : d(font.d)
+ : d(font.d.data())
{
d->ref.ref();
}
@@ -196,7 +196,7 @@ QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice)
d->dpi = dpi;
d->screen = screen;
} else {
- d = font.d;
+ d = font.d.data();
d->ref.ref();
}
@@ -670,8 +670,8 @@ QRect QFontMetrics::boundingRect(const QString &text) const
Returns the rectangle that is covered by ink if character \a ch
were to be drawn at the origin of the coordinate system.
- Note that the bounding rectangle may extend to the left of (0, 0),
- e.g. for italicized fonts, and that the text output may cover \e
+ Note that the bounding rectangle may extend to the left of (0, 0)
+ (e.g., for italicized fonts), and that the text output may cover \e
all pixels in the bounding rectangle. For a space character the rectangle
will usually be empty.
@@ -724,7 +724,7 @@ QRect QFontMetrics::boundingRect(QChar ch) const
\o Qt::AlignCenter (== \c{Qt::AlignHCenter | Qt::AlignVCenter})
\o Qt::TextSingleLine ignores newline characters in the text.
\o Qt::TextExpandTabs expands tabs (see below)
- \o Qt::TextShowMnemonic interprets "&amp;x" as \underline{x}, i.e. underlined.
+ \o Qt::TextShowMnemonic interprets "&x" as \underline{x}; i.e., underlined.
\o Qt::TextWordWrap breaks the text to fit the rectangle.
\endlist
@@ -781,7 +781,7 @@ QRect QFontMetrics::boundingRect(const QRect &rect, int flags, const QString &te
\list
\o Qt::TextSingleLine ignores newline characters.
\o Qt::TextExpandTabs expands tabs (see below)
- \o Qt::TextShowMnemonic interprets "&amp;x" as \underline{x}, i.e. underlined.
+ \o Qt::TextShowMnemonic interprets "&x" as \underline{x}; i.e., underlined.
\o Qt::TextWordBreak breaks the text to fit the rectangle.
\endlist
@@ -1006,7 +1006,7 @@ QFontMetricsF &QFontMetricsF::operator=(const QFontMetrics &other)
metrics that are compatible with a certain paint device.
*/
QFontMetricsF::QFontMetricsF(const QFont &font)
- : d(font.d)
+ : d(font.d.data())
{
d->ref.ref();
}
@@ -1038,7 +1038,7 @@ QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice)
d->dpi = dpi;
d->screen = screen;
} else {
- d = font.d;
+ d = font.d.data();
d->ref.ref();
}
@@ -1500,7 +1500,7 @@ QRectF QFontMetricsF::boundingRect(QChar ch) const
\o Qt::AlignCenter (== \c{Qt::AlignHCenter | Qt::AlignVCenter})
\o Qt::TextSingleLine ignores newline characters in the text.
\o Qt::TextExpandTabs expands tabs (see below)
- \o Qt::TextShowMnemonic interprets "&amp;x" as \underline{x}, i.e. underlined.
+ \o Qt::TextShowMnemonic interprets "&x" as \underline{x}; i.e., underlined.
\o Qt::TextWordWrap breaks the text to fit the rectangle.
\endlist
@@ -1559,7 +1559,7 @@ QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString&
\list
\o Qt::TextSingleLine ignores newline characters.
\o Qt::TextExpandTabs expands tabs (see below)
- \o Qt::TextShowMnemonic interprets "&amp;x" as \underline{x}, i.e. underlined.
+ \o Qt::TextShowMnemonic interprets "&x" as \underline{x}; i.e., underlined.
\o Qt::TextWordBreak breaks the text to fit the rectangle.
\endlist
diff --git a/src/gui/text/qfragmentmap_p.h b/src/gui/text/qfragmentmap_p.h
index 737a717..0f0e0ff 100644
--- a/src/gui/text/qfragmentmap_p.h
+++ b/src/gui/text/qfragmentmap_p.h
@@ -214,6 +214,7 @@ private:
template <class Fragment>
QFragmentMapData<Fragment>::QFragmentMapData()
+ : fragments(0)
{
init();
}
@@ -222,6 +223,7 @@ template <class Fragment>
void QFragmentMapData<Fragment>::init()
{
fragments = (Fragment *)malloc(64*fragmentSize);
+ Q_CHECK_PTR(fragments);
head->tag = (((quint32)'p') << 24) | (((quint32)'m') << 16) | (((quint32)'a') << 8) | 'p'; //TAG('p', 'm', 'a', 'p');
head->root = 0;
head->freelist = 1;
@@ -247,7 +249,9 @@ uint QFragmentMapData<Fragment>::createFragment()
// need to create some free space
uint needed = qAllocMore((freePos+1)*fragmentSize, 0);
Q_ASSERT(needed/fragmentSize > head->allocated);
- fragments = (Fragment *)realloc(fragments, needed);
+ Fragment *newFragments = (Fragment *)realloc(fragments, needed);
+ Q_CHECK_PTR(newFragments);
+ fragments = newFragments;
head->allocated = needed/fragmentSize;
F(freePos).right = 0;
}
@@ -787,6 +791,8 @@ public:
QFragmentMap() {}
~QFragmentMap()
{
+ if (!data.fragments)
+ return; // in case of out-of-memory, we won't have fragments
for (Iterator it = begin(); !it.atEnd(); ++it)
it.value()->free();
}
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index c74af23..69e1ee4 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -1611,6 +1611,9 @@ void QTextControlPrivate::mouseMoveEvent(Qt::MouseButtons buttons, const QPointF
if (cursor.position() != oldCursorPos)
emit q->cursorPositionChanged();
_q_updateCurrentCharFormatAndSelection();
+ if (QInputContext *ic = inputContext()) {
+ ic->update();
+ }
} else {
//emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1)));
if (cursor.position() != oldCursorPos)
@@ -1813,13 +1816,18 @@ bool QTextControlPrivate::dropEvent(const QMimeData *mimeData, const QPointF &po
void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
{
+ Q_Q(QTextControl);
if (!(interactionFlags & Qt::TextEditable) || cursor.isNull()) {
e->ignore();
return;
}
- cursor.beginEditBlock();
+ bool isGettingInput = !e->commitString().isEmpty() || !e->preeditString().isEmpty()
+ || e->replacementLength() > 0;
- cursor.removeSelectedText();
+ if (isGettingInput) {
+ cursor.beginEditBlock();
+ cursor.removeSelectedText();
+ }
// insert commit string
if (!e->commitString().isEmpty() || e->replacementLength()) {
@@ -1829,6 +1837,18 @@ void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
c.insertText(e->commitString());
}
+ for (int i = 0; i < e->attributes().size(); ++i) {
+ const QInputMethodEvent::Attribute &a = e->attributes().at(i);
+ if (a.type == QInputMethodEvent::Selection) {
+ QTextCursor oldCursor = cursor;
+ int blockStart = a.start + cursor.block().position();
+ cursor.setPosition(blockStart, QTextCursor::MoveAnchor);
+ cursor.setPosition(blockStart + a.length, QTextCursor::KeepAnchor);
+ q->ensureCursorVisible();
+ repaintOldAndNewSelection(oldCursor);
+ }
+ }
+
QTextBlock block = cursor.block();
QTextLayout *layout = block.layout();
layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
@@ -1852,7 +1872,9 @@ void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
}
}
layout->setAdditionalFormats(overrides);
- cursor.endEditBlock();
+
+ if (isGettingInput)
+ cursor.endEditBlock();
}
QVariant QTextControl::inputMethodQuery(Qt::InputMethodQuery property) const
@@ -1865,13 +1887,15 @@ QVariant QTextControl::inputMethodQuery(Qt::InputMethodQuery property) const
case Qt::ImFont:
return QVariant(d->cursor.charFormat().font());
case Qt::ImCursorPosition:
- return QVariant(d->cursor.selectionEnd() - block.position());
+ return QVariant(d->cursor.position() - block.position());
case Qt::ImSurroundingText:
return QVariant(block.text());
case Qt::ImCurrentSelection:
return QVariant(d->cursor.selectedText());
case Qt::ImMaximumTextLength:
return QVariant(); // No limit.
+ case Qt::ImAnchorPosition:
+ return QVariant(qBound(0, d->cursor.anchor() - block.position(), block.length()));
default:
return QVariant();
}
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 80a5425..0c55ce5 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1099,6 +1099,16 @@ void QTextEngine::shapeTextWithCE(int item) const
}
#endif
+static inline void moveGlyphData(const QGlyphLayout &destination, const QGlyphLayout &source, int num)
+{
+ if (num > 0 && destination.glyphs != source.glyphs) {
+ memmove(destination.glyphs, source.glyphs, num * sizeof(HB_Glyph));
+ memmove(destination.attributes, source.attributes, num * sizeof(HB_GlyphAttributes));
+ memmove(destination.advances_x, source.advances_x, num * sizeof(HB_Fixed));
+ memmove(destination.offsets, source.offsets, num * sizeof(HB_FixedPoint));
+ }
+}
+
/// take the item from layoutData->items and
void QTextEngine::shapeTextWithHarfbuzz(int item) const
{
@@ -1189,7 +1199,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
- int initial_glyph_pos = 0;
+ int remaining_glyphs = entire_shaper_item.num_glyphs;
int glyph_pos = 0;
// for each item shape using harfbuzz and store the results in our layoutData's glyphs array.
for (int k = 0; k < itemBoundaries.size(); k += 2) { // for the +2, see the comment at the definition of itemBoundaries
@@ -1209,7 +1219,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
QFontEngine *actualFontEngine = font;
uint engineIdx = 0;
if (font->type() == QFontEngine::Multi) {
- engineIdx = uint(initialGlyphs.glyphs[itemBoundaries[k + 1]] >> 24);
+ engineIdx = uint(availableGlyphs(&si).glyphs[glyph_pos] >> 24);
actualFontEngine = static_cast<QFontEngineMulti *>(font)->engine(engineIdx);
}
@@ -1219,16 +1229,18 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
shaper_item.glyphIndicesPresent = true;
+ remaining_glyphs -= shaper_item.initialGlyphCount;
+
do {
- ensureSpace(glyph_pos + shaper_item.num_glyphs);
- initialGlyphs = availableGlyphs(&si).mid(0, entire_shaper_item.num_glyphs);
- shaper_item.num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used - glyph_pos;
+ ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs);
- const QGlyphLayout g = availableGlyphs(&si);
- shaper_item.glyphs = g.glyphs + glyph_pos;
- shaper_item.attributes = g.attributes + glyph_pos;
- shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances_x + glyph_pos);
- shaper_item.offsets = reinterpret_cast<HB_FixedPoint *>(g.offsets + glyph_pos);
+ const QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos);
+ moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs);
+
+ shaper_item.glyphs = g.glyphs;
+ shaper_item.attributes = g.attributes;
+ shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances_x);
+ shaper_item.offsets = reinterpret_cast<HB_FixedPoint *>(g.offsets);
if (shaper_item.glyphIndicesPresent) {
for (hb_uint32 i = 0; i < shaper_item.initialGlyphCount; ++i)
@@ -1241,18 +1253,18 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
} while (!qShapeItem(&shaper_item)); // this does the actual shaping via harfbuzz.
QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos, shaper_item.num_glyphs);
+ moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs);
- for (hb_uint32 i = 0; i < shaper_item.item.length; ++i) {
+ for (hb_uint32 i = 0; i < shaper_item.num_glyphs; ++i)
g.glyphs[i] = g.glyphs[i] | (engineIdx << 24);
+
+ for (hb_uint32 i = 0; i < shaper_item.item.length; ++i)
shaper_item.log_clusters[i] += glyph_pos;
- }
if (kerningEnabled && !shaper_item.kerning_applied)
font->doKerning(&g, option.useDesignMetrics() ? QFlag(QTextEngine::DesignMetrics) : QFlag(0));
glyph_pos += shaper_item.num_glyphs;
-
- initial_glyph_pos += shaper_item.initialGlyphCount;
}
// qDebug(" -> item: script=%d num_glyphs=%d", shaper_item.script, shaper_item.num_glyphs);
@@ -2057,10 +2069,12 @@ void QTextEngine::LayoutData::reallocate(int totalGlyphs)
int newAllocated = space_charAttributes + space_glyphs + space_logClusters;
Q_ASSERT(newAllocated >= allocated);
- void **old_mem = memory;
- memory = (void **)::realloc(memory_on_stack ? 0 : old_mem, newAllocated*sizeof(void *));
- if (memory_on_stack && memory)
- memcpy(memory, old_mem, allocated*sizeof(void *));
+ void **newMem = memory;
+ newMem = (void **)::realloc(memory_on_stack ? 0 : memory, newAllocated*sizeof(void *));
+ Q_CHECK_PTR(newMem);
+ if (memory_on_stack && newMem)
+ memcpy(newMem, memory, allocated*sizeof(void *));
+ memory = newMem;
memory_on_stack = false;
void **m = memory;
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 21bfc4d..38ac4ca 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -1449,7 +1449,7 @@ void QTextCharFormat::setUnderlineStyle(UnderlineStyle style)
/*!
\since 4.5
\fn bool QTextCharFormat::fontKerning() const
- Returns true if the the font kerning is enabled.
+ Returns true if the font kerning is enabled.
\sa setFontKerning()
\sa font()
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index fa624ef..6c67a68 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -367,7 +367,7 @@ QTextLayout::QTextLayout(const QString& text, const QFont &font, QPaintDevice *p
QFont f(font);
if (paintdevice)
f = QFont(font, paintdevice);
- d = new QTextEngine((text.isNull() ? (const QString&)QString::fromLatin1("") : text), f.d);
+ d = new QTextEngine((text.isNull() ? (const QString&)QString::fromLatin1("") : text), f.d.data());
}
/*!
diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp
index e1b9844..0f24d9b 100644
--- a/src/gui/text/qtextoption.cpp
+++ b/src/gui/text/qtextoption.cpp
@@ -117,7 +117,13 @@ QTextOption &QTextOption::operator=(const QTextOption &o)
{
if (this == &o)
return *this;
- delete d; d = 0;
+
+ QTextOptionPrivate* dNew = 0;
+ if (o.d)
+ dNew = new QTextOptionPrivate(*o.d);
+ delete d;
+ d = dNew;
+
align = o.align;
wordWrap = o.wordWrap;
design = o.design;
@@ -125,8 +131,6 @@ QTextOption &QTextOption::operator=(const QTextOption &o)
unused = o.unused;
f = o.f;
tab = o.tab;
- if (o.d)
- d = new QTextOptionPrivate(*o.d);
return *this;
}
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index 48708c9..edba2c4 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -432,6 +432,13 @@ void QTextTablePrivate::fragmentRemoved(const QChar &type, uint fragment)
QTextFramePrivate::fragmentRemoved(type, fragment);
}
+/*!
+ /fn void QTextTablePrivate::update() const
+
+ This function is usually called when the table is "dirty".
+ It seems to update all kind of table information.
+
+*/
void QTextTablePrivate::update() const
{
Q_Q(const QTextTable);
@@ -439,7 +446,9 @@ void QTextTablePrivate::update() const
nRows = (cells.size() + nCols-1)/nCols;
// qDebug(">>>> QTextTablePrivate::update, nRows=%d, nCols=%d", nRows, nCols);
- grid = (int *)realloc(grid, nRows*nCols*sizeof(int));
+ int* newGrid = (int *)realloc(grid, nRows*nCols*sizeof(int));
+ Q_CHECK_PTR(newGrid);
+ grid = newGrid;
memset(grid, 0, nRows*nCols*sizeof(int));
QTextDocumentPrivate *p = pieceTable;
@@ -463,7 +472,9 @@ void QTextTablePrivate::update() const
cellIndices[i] = cell;
if (r + rowspan > nRows) {
- grid = (int *)realloc(grid, sizeof(int)*(r + rowspan)*nCols);
+ newGrid = (int *)realloc(grid, sizeof(int)*(r + rowspan)*nCols);
+ Q_CHECK_PTR(newGrid);
+ grid = newGrid;
memset(grid + (nRows*nCols), 0, sizeof(int)*(r+rowspan-nRows)*nCols);
nRows = r + rowspan;
}
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index c6c2e69..04f081e 100644
--- a/src/gui/text/qzip.cpp
+++ b/src/gui/text/qzip.cpp
@@ -695,7 +695,7 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const
*/
QZipReader::QZipReader(const QString &archive, QIODevice::OpenMode mode)
{
- QFile *f = new QFile(archive);
+ QScopedPointer<QFile> f(new QFile(archive));
f->open(mode);
QZipReader::Status status;
if (f->error() == QFile::NoError)
@@ -711,7 +711,8 @@ QZipReader::QZipReader(const QString &archive, QIODevice::OpenMode mode)
status = FileError;
}
- d = new QZipReaderPrivate(f, /*ownDevice=*/true);
+ d = new QZipReaderPrivate(f.data(), /*ownDevice=*/true);
+ f.take();
d->status = status;
}
@@ -969,7 +970,7 @@ void QZipReader::close()
*/
QZipWriter::QZipWriter(const QString &fileName, QIODevice::OpenMode mode)
{
- QFile *f = new QFile(fileName);
+ QScopedPointer<QFile> f(new QFile(fileName));
f->open(mode);
QZipWriter::Status status;
if (f->error() == QFile::NoError)
@@ -985,7 +986,8 @@ QZipWriter::QZipWriter(const QString &fileName, QIODevice::OpenMode mode)
status = QZipWriter::FileError;
}
- d = new QZipWriterPrivate(f, /*ownDevice=*/true);
+ d = new QZipWriterPrivate(f.data(), /*ownDevice=*/true);
+ f.take();
d->status = status;
}
diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp
index a32a91c..3588ec9 100644
--- a/src/gui/util/qdesktopservices_s60.cpp
+++ b/src/gui/util/qdesktopservices_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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$
**
****************************************************************************/
@@ -24,8 +54,8 @@
#include <eikenv.h> // CEikonEnv
#include <apgcli.h> // RApaLsSession
#include <apgtask.h> // TApaTaskList, TApaTask
-#include <sendui.h> // CSendUi
-#include <cmessagedata.h> // CMessageData
+#include <rsendas.h> // RSendAs
+#include <rsendasmessage.h> // RSendAsMessage
#include <pathinfo.h> // PathInfo
#ifdef USE_DOCUMENTHANDLER
#include <documenthandler.h> // CDocumentHandler
@@ -55,52 +85,57 @@ static void handleMailtoSchemeL(const QUrl &url)
QStringList bccs = bcc.split(",");
- CSendUi* sendUi = CSendUi::NewLC();
-
- // Construct symbian sendUI data holder
- CMessageData* messageData = CMessageData::NewLC();
-
- // Subject
- TPtrC subj( qt_QString2TPtrC(subject) );
- messageData->SetSubjectL( &subj );
-
- // Body
- CParaFormatLayer* paraFormat = CParaFormatLayer::NewL();
- CleanupStack::PushL( paraFormat );
- CCharFormatLayer* charFormat = CCharFormatLayer::NewL();
- CleanupStack::PushL( charFormat );
- CRichText* bodyRichText = CRichText::NewL( paraFormat, charFormat );
- CleanupStack::PushL( bodyRichText );
-
- TPtrC bodyPtr( qt_QString2TPtrC(body) );
- if( bodyPtr.Length() )
- {
- bodyRichText->InsertL( 0, bodyPtr );
- }
- else
- {
- bodyRichText->InsertL( 0, KNullDesC );
- }
-
- messageData->SetBodyTextL( bodyRichText );
-
- // To
- foreach(QString item, recipients)
- messageData->AppendToAddressL(qt_QString2TPtrC(item));
-
- foreach(QString item, tos)
- messageData->AppendToAddressL(qt_QString2TPtrC(item));
-
- // Cc
- foreach(QString item, ccs)
- messageData->AppendCcAddressL(qt_QString2TPtrC(item));
-
- // Bcc
- foreach(QString item, bccs)
- messageData->AppendBccAddressL(qt_QString2TPtrC(item));
-
- sendUi->CreateAndSendMessageL( KUidMsgTypeSMTP, messageData );
- CleanupStack::PopAndDestroy( 5 ); // bodyRichText, charFormat, paraFormat, messageData, sendUi
+ RSendAs sendAs;
+ User::LeaveIfError(sendAs.Connect());
+ CleanupClosePushL(sendAs);
+
+
+ CSendAsAccounts* accounts = CSendAsAccounts::NewL();
+ CleanupStack::PushL(accounts);
+ sendAs.AvailableAccountsL(KUidMsgTypeSMTP, *accounts);
+ TInt count = accounts->Count();
+ CleanupStack::PopAndDestroy(accounts);
+
+ if(!count) {
+ // TODO: we should try to create account if count == 0
+ // CSendUi would provide account creation service for us, but it requires ridicilous
+ // capabilities: LocalServices NetworkServices ReadDeviceData ReadUserData WriteDeviceData WriteUserData
+ User::Leave(KErrNotSupported);
+ } else {
+ RSendAsMessage sendAsMessage;
+ sendAsMessage.CreateL(sendAs, KUidMsgTypeSMTP);
+ CleanupClosePushL(sendAsMessage);
+
+
+ // Subject
+ sendAsMessage.SetSubjectL(qt_QString2TPtrC(subject));
+
+ // Body
+ sendAsMessage.SetBodyTextL(qt_QString2TPtrC(body));
+
+ // To
+ foreach(QString item, recipients)
+ sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo );
+
+ foreach(QString item, tos)
+ sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo );
+
+ // Cc
+ foreach(QString item, ccs)
+ sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientCc );
+
+ // Bcc
+ foreach(QString item, bccs)
+ sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientBcc );
+
+ // send the message
+ sendAsMessage.LaunchEditorAndCloseL();
+
+ // sendAsMessage (already closed)
+ CleanupStack::Pop();
+ }
+ // sendAs
+ CleanupStack::PopAndDestroy();
}
static bool handleMailtoScheme(const QUrl &url)
diff --git a/src/gui/util/qundostack.cpp b/src/gui/util/qundostack.cpp
index 11f65e3..a6b9c23 100644
--- a/src/gui/util/qundostack.cpp
+++ b/src/gui/util/qundostack.cpp
@@ -715,7 +715,7 @@ int QUndoStack::index() const
}
/*!
- Repeatedly calls undo() or redo() until the the current command index reaches
+ Repeatedly calls undo() or redo() until the current command index reaches
\a idx. This function can be used to roll the state of the document forwards
of backwards. indexChanged() is emitted only once.
diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri
index 69c53ae..e628229 100644
--- a/src/gui/util/util.pri
+++ b/src/gui/util/util.pri
@@ -35,11 +35,6 @@ embedded {
util/qsystemtrayicon_qws.cpp
}
-symbian {
- # QDesktopServices uses CSendUi which is located on app layer
- INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
-}
-
!embedded:!x11:mac {
OBJECTIVE_SOURCES += util/qsystemtrayicon_mac.mm
}
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index 9886969..1ff56e8 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -281,8 +281,8 @@ void QAbstractScrollAreaPrivate::init()
scrollBarContainers[Qt::Vertical]->setVisible(false);
QObject::connect(vbar, SIGNAL(valueChanged(int)), q, SLOT(_q_vslide(int)));
QObject::connect(vbar, SIGNAL(rangeChanged(int,int)), q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
- viewportFilter = new QAbstractScrollAreaFilter(this);
- viewport->installEventFilter(viewportFilter);
+ viewportFilter.reset(new QAbstractScrollAreaFilter(this));
+ viewport->installEventFilter(viewportFilter.data());
viewport->setFocusProxy(q);
q->setFocusPolicy(Qt::WheelFocus);
q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
@@ -471,7 +471,12 @@ QAbstractScrollArea::QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget
:QFrame(dd, parent)
{
Q_D(QAbstractScrollArea);
- d->init();
+ QT_TRY {
+ d->init();
+ } QT_CATCH(...) {
+ d->viewportFilter.reset();
+ QT_RETHROW;
+ }
}
/*!
@@ -483,7 +488,12 @@ QAbstractScrollArea::QAbstractScrollArea(QWidget *parent)
:QFrame(*new QAbstractScrollAreaPrivate, parent)
{
Q_D(QAbstractScrollArea);
- d->init();
+ QT_TRY {
+ d->init();
+ } QT_CATCH(...) {
+ d->viewportFilter.reset();
+ QT_RETHROW;
+ }
}
@@ -493,7 +503,8 @@ QAbstractScrollArea::QAbstractScrollArea(QWidget *parent)
QAbstractScrollArea::~QAbstractScrollArea()
{
Q_D(QAbstractScrollArea);
- delete d->viewportFilter;
+ // reset it here, otherwise we'll have a dangling pointer in ~QWidget
+ d->viewportFilter.reset();
}
@@ -517,7 +528,7 @@ void QAbstractScrollArea::setViewport(QWidget *widget)
d->viewport = widget;
d->viewport->setParent(this);
d->viewport->setFocusProxy(this);
- d->viewport->installEventFilter(d->viewportFilter);
+ d->viewport->installEventFilter(d->viewportFilter.data());
d->layoutChildren();
if (isVisible())
d->viewport->show();
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h
index e4c47e9..999bdfc 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/gui/widgets/qabstractscrollarea_p.h
@@ -98,7 +98,7 @@ public:
inline bool viewportEvent(QEvent *event)
{ return q_func()->viewportEvent(event); }
- QObject *viewportFilter;
+ QScopedPointer<QObject> viewportFilter;
};
class QAbstractScrollAreaFilter : public QObject
diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp
index 347f89a..2bf1cda 100644
--- a/src/gui/widgets/qabstractspinbox.cpp
+++ b/src/gui/widgets/qabstractspinbox.cpp
@@ -659,7 +659,6 @@ void QAbstractSpinBox::setLineEdit(QLineEdit *lineEdit)
d->edit->setParent(this);
d->edit->setFrame(false);
- d->edit->setAttribute(Qt::WA_InputMethodEnabled, false);
d->edit->setFocusProxy(this);
d->edit->setAcceptDrops(false);
@@ -690,6 +689,18 @@ void QAbstractSpinBox::interpretText()
d->interpret(EmitIfChanged);
}
+/*
+ Reimplemented in 4.6, so be careful.
+ */
+/*!
+ \reimp
+*/
+QVariant QAbstractSpinBox::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ Q_D(const QAbstractSpinBox);
+ return d->edit->inputMethodQuery(query);
+}
+
/*!
\reimp
*/
diff --git a/src/gui/widgets/qabstractspinbox.h b/src/gui/widgets/qabstractspinbox.h
index 4e7fc3f..aa8905f 100644
--- a/src/gui/widgets/qabstractspinbox.h
+++ b/src/gui/widgets/qabstractspinbox.h
@@ -122,6 +122,8 @@ public:
void interpretText();
bool event(QEvent *event);
+ QVariant inputMethodQuery(Qt::InputMethodQuery) const;
+
virtual QValidator::State validate(QString &input, int &pos) const;
virtual void fixup(QString &input) const;
diff --git a/src/gui/widgets/qactiontokeyeventmapper.cpp b/src/gui/widgets/qactiontokeyeventmapper.cpp
new file mode 100644
index 0000000..280b1c6
--- /dev/null
+++ b/src/gui/widgets/qactiontokeyeventmapper.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui 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 "qapplication.h"
+#include "qevent.h"
+#include "qactiontokeyeventmapper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QActionToKeyEventMapper::QActionToKeyEventMapper(QAction *softKeyAction, Qt::Key key, QObject *parent)
+ : QObject(parent)
+ , m_softKeyAction(softKeyAction)
+ , m_key(key)
+{
+
+}
+
+QString QActionToKeyEventMapper::roleText(QAction::SoftKeyRole role)
+{
+ switch (role) {
+ case QAction::OptionsSoftKey:
+ return QAction::tr("Options");
+ case QAction::SelectSoftKey:
+ return QAction::tr("Select");
+ case QAction::BackSoftKey:
+ return QAction::tr("Back");
+ case QAction::NextSoftKey:
+ return QAction::tr("Next");
+ case QAction::PreviousSoftKey:
+ return QAction::tr("Previous");
+ case QAction::OkSoftKey:
+ return QAction::tr("Ok");
+ case QAction::CancelSoftKey:
+ return QAction::tr("Cancel");
+ case QAction::EditSoftKey:
+ return QAction::tr("Edit");
+ case QAction::ViewSoftKey:
+ return QAction::tr("View");
+ default:
+ return QString();
+ };
+}
+void QActionToKeyEventMapper::addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget)
+{
+ QAction *action = new QAction(actionWidget);
+ action->setSoftKeyRole(standardRole);
+ action->setText(roleText(standardRole));
+ QActionToKeyEventMapper *softKey = new QActionToKeyEventMapper(action, key, actionWidget);
+ connect(action, SIGNAL(triggered()), softKey, SLOT(sendKeyEvent()));
+ connect(action, SIGNAL(destroyed()), softKey, SLOT(deleteLater()));
+ actionWidget->setSoftKey(action);
+}
+
+void QActionToKeyEventMapper::removeSoftkey(QWidget *focussedWidget)
+{
+ focussedWidget->setSoftKey(0);
+}
+
+void QActionToKeyEventMapper::sendKeyEvent()
+{
+ QApplication::postEvent(parent(), new QKeyEvent(QEvent::KeyPress, m_key, Qt::NoModifier));
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/gui/widgets/qactiontokeyeventmapper_p.h b/src/gui/widgets/qactiontokeyeventmapper_p.h
new file mode 100644
index 0000000..c54e612
--- /dev/null
+++ b/src/gui/widgets/qactiontokeyeventmapper_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui 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 QACTIONTOKEYEVENTMAPPER_P_H
+#define QACTIONTOKEYEVENTMAPPER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include "QtGui/qaction.h"
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QActionToKeyEventMapper : public QObject
+{
+ Q_OBJECT
+public:
+ QActionToKeyEventMapper(QAction *softKeyAction, Qt::Key key, QObject *parent);
+ static QString roleText(QAction::SoftKeyRole role);
+ static void addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget);
+ static void removeSoftkey(QWidget *focussedWidget);
+private:
+ QAction *m_softKeyAction;
+ Qt::Key m_key;
+private Q_SLOTS:
+ void sendKeyEvent();
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QACTIONTOKEYEVENTMAPPER_P_H
diff --git a/src/gui/widgets/qcalendarwidget.cpp b/src/gui/widgets/qcalendarwidget.cpp
index 92c12a5..4436c04 100644
--- a/src/gui/widgets/qcalendarwidget.cpp
+++ b/src/gui/widgets/qcalendarwidget.cpp
@@ -2791,7 +2791,7 @@ QTextCharFormat QCalendarWidget::dateTextFormat(const QDate &date) const
void QCalendarWidget::setDateTextFormat(const QDate &date, const QTextCharFormat &format)
{
Q_D(QCalendarWidget);
- if ( date.isNull() && !format.isValid() )
+ if (date.isNull())
d->m_model->m_dateFormats.clear();
else
d->m_model->m_dateFormats[date] = format;
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index e9884bb..a6a5e08 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -63,7 +63,7 @@
#include <private/qabstractitemmodel_p.h>
#include <private/qabstractscrollarea_p.h>
#include <qdebug.h>
-
+#include <private/qactiontokeyeventmapper_p.h>
#ifdef Q_WS_X11
#include <private/qt_x11_p.h>
#endif
@@ -628,6 +628,9 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e)
case Qt::Key_Select:
#endif
if (view->currentIndex().isValid() && (view->currentIndex().flags() & Qt::ItemIsEnabled) ) {
+#ifdef QT_KEYPAD_NAVIGATION
+ QActionToKeyEventMapper::removeSoftkey(this);
+#endif
combo->hidePopup();
emit itemSelected(view->currentIndex());
}
@@ -640,7 +643,7 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e)
case Qt::Key_Escape:
#ifdef QT_KEYPAD_NAVIGATION
case Qt::Key_Back:
- case Qt::Key_Context2: // TODO: aportale, KEYPAD_NAVIGATION_HACK when softkey support is there
+ QActionToKeyEventMapper::removeSoftkey(this);
#endif
combo->hidePopup();
return true;
@@ -948,7 +951,7 @@ QComboBoxPrivateContainer* QComboBoxPrivate::viewContainer()
container = new QComboBoxPrivateContainer(new QComboBoxListView(q), q);
container->itemView()->setModel(model);
container->itemView()->setTextElideMode(Qt::ElideMiddle);
- updateDelegate();
+ updateDelegate(true);
updateLayoutDirection();
QObject::connect(container, SIGNAL(itemSelected(QModelIndex)),
q, SLOT(_q_itemSelected(QModelIndex)));
@@ -1568,15 +1571,25 @@ bool QComboBox::isEditable() const
return d->lineEdit != 0;
}
-void QComboBoxPrivate::updateDelegate()
+/*! \internal
+ update the default delegate
+ depending on the style's SH_ComboBox_Popup hint, we use a different default delegate.
+
+ but we do not change the delegate is the combobox use a custom delegate,
+ unless \a force is set to true.
+ */
+void QComboBoxPrivate::updateDelegate(bool force)
{
Q_Q(QComboBox);
QStyleOptionComboBox opt;
q->initStyleOption(&opt);
- if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q))
- q->setItemDelegate(new QComboMenuDelegate(q->view(), q));
- else
- q->setItemDelegate(new QComboBoxDelegate(q->view(), q));
+ if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) {
+ if (force || qobject_cast<QComboBoxDelegate *>(q->itemDelegate()))
+ q->setItemDelegate(new QComboMenuDelegate(q->view(), q));
+ } else {
+ if (force || qobject_cast<QComboMenuDelegate *>(q->itemDelegate()))
+ q->setItemDelegate(new QComboBoxDelegate(q->view(), q));
+ }
}
QIcon QComboBoxPrivate::itemIcon(const QModelIndex &index) const
@@ -2425,6 +2438,7 @@ void QComboBox::showPopup()
#ifdef QT_KEYPAD_NAVIGATION
if (QApplication::keypadNavigationEnabled())
view()->setEditFocus(true);
+ QActionToKeyEventMapper::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, view());
#endif
}
diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h
index c39a231..a55b439 100644
--- a/src/gui/widgets/qcombobox_p.h
+++ b/src/gui/widgets/qcombobox_p.h
@@ -256,7 +256,7 @@ private:
};
class QComboMenuDelegate : public QAbstractItemDelegate
-{
+{ Q_OBJECT
public:
QComboMenuDelegate(QObject *parent, QComboBox *cmb) : QAbstractItemDelegate(parent), mCombo(cmb) {}
@@ -285,7 +285,7 @@ private:
// Vista does not use the new theme for combo boxes and there might
// be other side effects from using the new class
class QComboBoxDelegate : public QItemDelegate
-{
+{ Q_OBJECT
public:
QComboBoxDelegate(QObject *parent, QComboBox *cmb) : QItemDelegate(parent), mCombo(cmb) {}
@@ -367,7 +367,7 @@ public:
int itemRole() const;
void updateLayoutDirection();
void setCurrentIndex(const QModelIndex &index);
- void updateDelegate();
+ void updateDelegate(bool force = false);
void keyboardSearchString(const QString &text);
void modelChanged();
diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp
index 83bec68..4d34691 100644
--- a/src/gui/widgets/qdatetimeedit.cpp
+++ b/src/gui/widgets/qdatetimeedit.cpp
@@ -2390,6 +2390,7 @@ void QDateTimeEditPrivate::init(const QVariant &var)
q->setCalendarPopup(true);
#endif
updateTimeSpec();
+ q->setInputMethodHints(Qt::ImhPreferNumbers);
setLayoutItemMargins(QStyle::SE_DateTimeEditLayoutItem);
}
diff --git a/src/gui/widgets/qlcdnumber.cpp b/src/gui/widgets/qlcdnumber.cpp
index 0136f1a..af80963 100644
--- a/src/gui/widgets/qlcdnumber.cpp
+++ b/src/gui/widgets/qlcdnumber.cpp
@@ -1271,7 +1271,7 @@ bool QLCDNumber::event(QEvent *e)
/*!
\fn int QLCDNumber::margin() const
- Returns the with of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
Use QWidget::getContentsMargins() instead.
\sa setMargin(), QWidget::getContentsMargins()
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 116d000..a95d2f2 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -2274,8 +2274,16 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e)
}
#endif
- int priorState = d->undoState;
- d->removeSelectedText();
+ int priorState = 0;
+ bool isGettingInput = !e->commitString().isEmpty() || !e->preeditString().isEmpty()
+ || e->replacementLength() > 0;
+ bool cursorPositionChanged = false;
+
+ if (isGettingInput) {
+ // If any text is being input, remove selected text.
+ priorState = d->undoState;
+ d->removeSelectedText();
+ }
int c = d->cursor; // cursor position after insertion of commit string
if (e->replacementStart() <= 0)
@@ -2289,11 +2297,30 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e)
d->selend = d->selstart + e->replacementLength();
d->removeSelectedText();
}
- if (!e->commitString().isEmpty())
+ if (!e->commitString().isEmpty()) {
d->insert(e->commitString());
+ cursorPositionChanged = true;
+ }
d->cursor = qMin(c, d->text.length());
+ for (int i = 0; i < e->attributes().size(); ++i) {
+ const QInputMethodEvent::Attribute &a = e->attributes().at(i);
+ if (a.type == QInputMethodEvent::Selection) {
+ d->cursor = qBound(0, a.start + a.length, d->text.length());
+ if (a.length) {
+ d->selstart = qMax(0, qMin(a.start, d->text.length()));
+ d->selend = d->cursor;
+ if (d->selend < d->selstart) {
+ qSwap(d->selstart, d->selend);
+ }
+ } else {
+ d->selstart = d->selend = 0;
+ }
+ cursorPositionChanged = true;
+ }
+ }
+
d->textLayout.setPreeditArea(d->cursor, e->preeditString());
d->preeditCursor = e->preeditString().length();
d->hideCursor = false;
@@ -2317,9 +2344,12 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e)
d->textLayout.setAdditionalFormats(formats);
d->updateTextLayout();
update();
- if (!e->commitString().isEmpty())
+ if (cursorPositionChanged)
d->emitCursorPositionChanged();
- d->finishChange(priorState);
+
+ if (isGettingInput)
+ d->finishChange(priorState);
+
#ifndef QT_NO_COMPLETER
if (!e->commitString().isEmpty())
d->complete(Qt::Key_unknown);
@@ -2337,13 +2367,20 @@ QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const
case Qt::ImFont:
return font();
case Qt::ImCursorPosition:
- return QVariant((d->selend - d->selstart == 0) ? d->cursor : d->selend);
+ return QVariant(d->cursor);
case Qt::ImSurroundingText:
return QVariant(d->text);
case Qt::ImCurrentSelection:
return QVariant(selectedText());
case Qt::ImMaximumTextLength:
return QVariant(maxLength());
+ case Qt::ImAnchorPosition:
+ if (d->selstart == d->selend)
+ return QVariant(d->cursor);
+ else if (d->selstart == d->cursor)
+ return QVariant(d->selend);
+ else
+ return QVariant(d->selstart);
default:
return QVariant();
}
@@ -3690,7 +3727,7 @@ void QLineEditPrivate::redo() {
/*!
\fn int QLineEdit::margin() const
- Returns the with of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
Use QWidget::getContentsMargins() instead.
\sa setMargin(), QWidget::getContentsMargins()
diff --git a/src/gui/widgets/qmacnativewidget_mac.h b/src/gui/widgets/qmacnativewidget_mac.h
index 4db65e0..d36d74f 100644
--- a/src/gui/widgets/qmacnativewidget_mac.h
+++ b/src/gui/widgets/qmacnativewidget_mac.h
@@ -64,7 +64,7 @@ protected:
bool event(QEvent *ev);
private:
- Q_DECLARE_PRIVATE_D(QWidget::d_ptr, QMacNativeWidget)
+ Q_DECLARE_PRIVATE(QMacNativeWidget)
};
QT_END_NAMESPACE
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index 558ba42..2f3b412 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -481,6 +481,11 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar)
oldMenuBar->deleteLater();
}
d->layout->setMenuBar(menuBar);
+ if (menuBar) {
+ QAction* menu = new QAction(QString::fromLatin1("Menu"), this);
+ menu->setSoftKeyRole(QAction::MenuSoftKey);
+ setSoftKey(menu);
+ }
}
/*!
diff --git a/src/gui/widgets/qmdiarea.cpp b/src/gui/widgets/qmdiarea.cpp
index 598d3b5..6acd977 100644
--- a/src/gui/widgets/qmdiarea.cpp
+++ b/src/gui/widgets/qmdiarea.cpp
@@ -81,7 +81,7 @@
subwindows. This information could be used in a popup menu
containing a list of windows, for example.
- The subwindows are sorted by the the current
+ The subwindows are sorted by the current
\l{QMdiArea::}{WindowOrder}. This is used for the subWindowList()
and for activateNextSubWindow() and acivatePreviousSubWindow().
Also, it is used when cascading or tiling the windows with
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 6be0f19..6d4dcf2 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -60,6 +60,7 @@
#ifndef QT_NO_WHATSTHIS
# include <qwhatsthis.h>
#endif
+#include <private/qactiontokeyeventmapper_p.h>
#include "qmenu_p.h"
#include "qmenubar_p.h"
@@ -578,8 +579,14 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason
//when the action has no QWidget, the QMenu itself should
// get the focus
// Since the menu is a pop-up, it uses the popup reason.
- if (!q->hasFocus())
+ if (!q->hasFocus()) {
q->setFocus(Qt::PopupFocusReason);
+#ifdef QT_KEYPAD_NAVIGATION
+ // TODO: aportale, remove KEYPAD_NAVIGATION_HACK when softkey stack
+ // handles focus related and user related actions separately...
+ QActionToKeyEventMapper::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, q);
+#endif
+ }
}
}
} else { //action is a separator
@@ -1937,6 +1944,9 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
#ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(this, 0, QAccessible::PopupMenuStart);
#endif
+#ifdef QT_KEYPAD_NAVIGATION
+ QActionToKeyEventMapper::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, this);
+#endif
}
/*!
@@ -2587,7 +2597,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
case Qt::Key_Escape:
#ifdef QT_KEYPAD_NAVIGATION
case Qt::Key_Back:
- case Qt::Key_Context2: // TODO: aportale, remove KEYPAD_NAVIGATION_HACK when softkey support is there
+ QActionToKeyEventMapper::removeSoftkey(this);
#endif
key_consumed = true;
if (d->tornoff) {
diff --git a/src/gui/widgets/qmenu.h b/src/gui/widgets/qmenu.h
index 1676eb8..bf1c39f 100644
--- a/src/gui/widgets/qmenu.h
+++ b/src/gui/widgets/qmenu.h
@@ -184,9 +184,6 @@ protected:
#ifdef Q_OS_WINCE
QAction* wceCommands(uint command);
#endif
-#ifdef Q_OS_SYMBIAN
- void symbianCommands(int command);
-#endif
private Q_SLOTS:
void internalSetSloppyAction();
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index ad848c9..2560cfa 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -871,8 +871,6 @@ static NSMenuItem *qt_mac_menu_merge_action(OSMenuRef merge, QMacMenuAction *act
}
}
- if ([ret tag] != 0)
- ret = 0; // already taken
#endif
return ret;
}
@@ -1131,15 +1129,15 @@ QMenuPrivate::QMacMenuPrivate::addAction(QMacMenuAction *action, QMacMenuAction
GetMenuItemAttributes(action->menu, itemCount , &testattr);
if (mergedItems.contains(action->command)
&& (testattr & kMenuItemAttrSeparator)) {
- InsertMenuItemTextWithCFString(action->menu, 0, qMax(itemCount - 1, 0), attr, action->command);
- index = itemCount;
- } else {
- MenuItemIndex tmpIndex;
- AppendMenuItemTextWithCFString(action->menu, 0, attr, action->command, &tmpIndex);
- index = tmpIndex;
- if (mergedItems.contains(action->command))
- AppendMenuItemTextWithCFString(action->menu, 0, kMenuItemAttrSeparator, 0, &tmpIndex);
- }
+ InsertMenuItemTextWithCFString(action->menu, 0, qMax(itemCount - 1, 0), attr, action->command);
+ index = itemCount;
+ } else {
+ MenuItemIndex tmpIndex;
+ AppendMenuItemTextWithCFString(action->menu, 0, attr, action->command, &tmpIndex);
+ index = tmpIndex;
+ if (mergedItems.contains(action->command))
+ AppendMenuItemTextWithCFString(action->menu, 0, kMenuItemAttrSeparator, 0, &tmpIndex);
+ }
#else
[menu addItem:newItem];
#endif
@@ -1477,11 +1475,18 @@ QMenuPrivate::QMacMenuPrivate::removeAction(QMacMenuAction *action)
DeleteMenuItem(action->menu, qt_mac_menu_find_action(action->menu, action));
#else
QMacCocoaAutoReleasePool pool;
- QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
- if (action->menuItem == [loader quitMenuItem] || action->menuItem == [loader preferencesMenuItem])
- [action->menuItem setEnabled:false];
- else
+ if (action->merged) {
+ if (reinterpret_cast<QAction *>([action->menuItem tag]) == action->action) {
+ QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
+ [action->menuItem setEnabled:false];
+ if (action->menuItem != [loader quitMenuItem]
+ && action->menuItem != [loader preferencesMenuItem]) {
+ [[action->menuItem menu] removeItem:action->menuItem];
+ }
+ }
+ } else {
[[action->menuItem menu] removeItem:action->menuItem];
+ }
#endif
actionItems.removeAll(action);
}
@@ -1934,6 +1939,23 @@ bool QMenuBar::macUpdateMenuBar()
[loader ensureAppMenuInMenu:menu];
[NSApp setMainMenu:menu];
syncMenuBarItemsVisiblity(mb->d_func()->mac_menubar);
+
+ if (OSMenuRef tmpMerge = QMenuPrivate::mergeMenuHash.value(menu)) {
+ if (QMenuMergeList *mergeList
+ = QMenuPrivate::mergeMenuItemsHash.value(tmpMerge)) {
+ const int mergeListSize = mergeList->size();
+
+ for (int i = 0; i < mergeListSize; ++i) {
+ const QMenuMergeItem &mergeItem = mergeList->at(i);
+ // Ideally we would call QMenuPrivate::syncAction, but that requires finding
+ // the original QMen and likely doing more work than we need.
+ // For example, enabled is handled below.
+ [mergeItem.menuItem setTag:reinterpret_cast<long>(
+ static_cast<QAction *>(mergeItem.action->action))];
+ [mergeItem.menuItem setHidden:!(mergeItem.action->action->isVisible())];
+ }
+ }
+ }
#endif
QWidget *modalWidget = qApp->activeModalWidget();
if (mb != menubars()->value(modalWidget)) {
diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h
index d47749f..aafc945 100644
--- a/src/gui/widgets/qmenu_p.h
+++ b/src/gui/widgets/qmenu_p.h
@@ -227,7 +227,7 @@ public:
QString searchBuffer;
QBasicTimer searchBufferTimer;
- //passing of mouse events up the parent heirarchy
+ //passing of mouse events up the parent hierarchy
QPointer<QMenu> activeMenu;
bool mouseEventTaken(QMouseEvent *);
@@ -358,7 +358,6 @@ public:
return 0;
}
} *symbian_menu;
- bool symbianCommands(int command);
#endif
QPointer<QWidget> noReplayFor;
};
diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp
index 86affe3..69ce981 100644
--- a/src/gui/widgets/qmenu_symbian.cpp
+++ b/src/gui/widgets/qmenu_symbian.cpp
@@ -4,14 +4,42 @@
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $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 "qmenu.h"
#include "qapplication.h"
-#include "qmainwindow.h"
-#include "qtoolbar.h"
#include "qevent.h"
#include "qstyle.h"
#include "qdebug.h"
@@ -26,12 +54,10 @@
#include <eikbtgpc.h>
#include <QtCore/qlibrary.h>
#include <avkon.rsg>
-
#ifndef QT_NO_MENUBAR
QT_BEGIN_NAMESPACE
-// ### FIX/Document this, we need some safe range of menu id's for Qt that don't clash with AIW ones
typedef QMultiHash<QWidget *, QMenuBarPrivate *> MenuBarHash;
Q_GLOBAL_STATIC(MenuBarHash, menubars)
@@ -48,6 +74,10 @@ struct SymbianMenuItem
static QList<SymbianMenuItem*> symbianMenus;
static QList<QMenuBar*> nativeMenuBars;
static uint qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM;
+static QPointer<QWidget> widgetWithContextMenu;
+static QList<QAction*> contextMenuActionList;
+static QAction contextAction(0);
+static int contexMenuCommand=0;
bool menuExists()
{
@@ -58,6 +88,16 @@ bool menuExists()
return true;
}
+static bool hasContextMenu(QWidget* widget)
+{
+ if (!widget)
+ return false;
+ const Qt::ContextMenuPolicy policy = widget->contextMenuPolicy();
+ if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) {
+ return true;
+ }
+ return false;
+}
// ### FIX THIS, copy/paste of original (faulty) stripped text implementation.
// Implementation should be removed from QAction implementation to some generic place
static QString qt_strippedText_copy_from_qaction(QString s)
@@ -119,14 +159,14 @@ static void qt_symbian_insert_action(QSymbianMenuAction* action, QList<SymbianMe
// ### FIX THIS, the qt_strippedText2 doesn't work perfectly for stripping & marks. Same bug is in QAction
// New really working method is needed in a place where the implementation isn't copy/pasted
QString text = qt_strippedText_copy_from_qaction(action->action->text());
- HBufC* menuItemText = qt_QString2HBufCNewL(text);
+ TPtrC menuItemText(qt_QString2TPtrC(text));
if (action->action->menu()) {
SymbianMenuItem* menuItem = new SymbianMenuItem();
menuItem->menuItemData.iCascadeId = action->command;
menuItem->menuItemData.iCommandId = action->command;
menuItem->menuItemData.iFlags = 0;
- menuItem->menuItemData.iText = *menuItemText;
+ menuItem->menuItemData.iText = menuItemText;
menuItem->action = action->action;
if (action->action->menu()->actions().size() == 0 || !action->action->isEnabled() )
menuItem->menuItemData.iFlags |= EEikMenuItemDimmed;
@@ -147,7 +187,7 @@ static void qt_symbian_insert_action(QSymbianMenuAction* action, QList<SymbianMe
menuItem->menuItemData.iCascadeId = 0;
menuItem->menuItemData.iCommandId = action->command;
menuItem->menuItemData.iFlags = 0;
- menuItem->menuItemData.iText = *menuItemText;
+ menuItem->menuItemData.iText = menuItemText;
menuItem->action = action->action;
if (!action->action->isEnabled()){
menuItem->menuItemData.iFlags += EEikMenuItemDimmed;
@@ -161,7 +201,6 @@ static void qt_symbian_insert_action(QSymbianMenuAction* action, QList<SymbianMe
}
parent->append(menuItem);
}
- delete menuItemText;
}
}
@@ -174,24 +213,18 @@ void deleteAll(QList<SymbianMenuItem*> *items)
}
}
-static void setSoftkeys()
-{
- CEikButtonGroupContainer* cba = CEikonEnv::Static()->AppUiFactory()->Cba();
- if (cba){
- if (menuExists())
- cba->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT);
- else
- cba->SetCommandSetL(R_AVKON_SOFTKEYS_EXIT);
- }
-}
-
static void rebuildMenu()
{
+ widgetWithContextMenu = 0;
QMenuBarPrivate *mb = 0;
- setSoftkeys();
QWidget *w = qApp->activeWindow();
- if (w)
- {
+ QWidget* focusWidget = QApplication::focusWidget();
+ if (focusWidget) {
+ if (hasContextMenu(focusWidget))
+ widgetWithContextMenu = focusWidget;
+ }
+
+ if (w) {
mb = menubars()->value(w);
qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM;
deleteAll( &symbianMenus );
@@ -199,7 +232,7 @@ static void rebuildMenu()
return;
mb->symbian_menubar->rebuild();
}
- }
+}
Q_GUI_EXPORT void qt_symbian_show_toplevel( CEikMenuPane* menuPane)
{
@@ -219,42 +252,23 @@ Q_GUI_EXPORT void qt_symbian_show_submenu( CEikMenuPane* menuPane, int id)
}
}
-void QMenu::symbianCommands(int command)
-{
- Q_D(QMenu);
- d->symbianCommands(command);
-}
-
-void QMenuBar::symbianCommands(int command)
+void QMenuBarPrivate::symbianCommands(int command)
{
+ if (command == contexMenuCommand && !widgetWithContextMenu.isNull()) {
+ QContextMenuEvent* event = new QContextMenuEvent(QContextMenuEvent::Keyboard, QPoint(0,0));
+ QCoreApplication::postEvent(widgetWithContextMenu, event);
+ }
+
int size = nativeMenuBars.size();
for (int i = 0; i < nativeMenuBars.size(); ++i) {
- bool result = nativeMenuBars.at(i)->d_func()->symbianCommands(command);
- if (result)
- return;
- }
-}
-
-bool QMenuBarPrivate::symbianCommands(int command)
-{
SymbianMenuItem* menu = qt_symbian_find_menu_item(command, symbianMenus);
if (!menu)
- return false;
-
- emit q_func()->triggered(menu->action);
- menu->action->activate(QAction::Trigger);
- return true;
-}
-
-bool QMenuPrivate::symbianCommands(int command)
-{
- SymbianMenuItem* menu = qt_symbian_find_menu_item(command, symbianMenus);
- if (!menu)
- return false;
+ continue;
- emit q_func()->triggered(menu->action);
+ emit nativeMenuBars.at(i)->triggered(menu->action);
menu->action->activate(QAction::Trigger);
- return true;
+ break;
+ }
}
void QMenuBarPrivate::symbianCreateMenuBar(QWidget *parent)
@@ -289,7 +303,7 @@ QMenuBarPrivate::QSymbianMenuBarPrivate::~QSymbianMenuBarPrivate()
deleteAll( &symbianMenus );
symbianMenus.clear();
d = 0;
- rebuild();
+ rebuild();
}
QMenuPrivate::QSymbianMenuPrivate::QSymbianMenuPrivate()
@@ -371,22 +385,35 @@ void QMenuBarPrivate::QSymbianMenuBarPrivate::removeAction(QSymbianMenuAction *a
rebuild();
}
-void QMenuBarPrivate::QSymbianMenuBarPrivate::rebuild()
+void QMenuBarPrivate::QSymbianMenuBarPrivate::insertNativeMenuItems(const QList<QAction*> &actions)
{
- setSoftkeys();
- qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM;
- deleteAll( &symbianMenus );
- if (!d)
- return;
- for (int i = 0; i < d->actions.size(); ++i) {
+ for (int i = 0; i <actions.size(); ++i) {
QSymbianMenuAction *symbianActionTopLevel = new QSymbianMenuAction;
- symbianActionTopLevel->action = d->actions.at(i);
+ symbianActionTopLevel->action = actions.at(i);
symbianActionTopLevel->parent = 0;
symbianActionTopLevel->command = qt_symbian_menu_static_cmd_id++;
qt_symbian_insert_action(symbianActionTopLevel, &symbianMenus);
}
}
+
+
+void QMenuBarPrivate::QSymbianMenuBarPrivate::rebuild()
+{
+ contexMenuCommand = 0;
+ qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM;
+ deleteAll( &symbianMenus );
+ if (d)
+ insertNativeMenuItems(d->actions);
+
+ contextMenuActionList.clear();
+ if (widgetWithContextMenu) {
+ contexMenuCommand = qt_symbian_menu_static_cmd_id;
+ contextAction.setText(QMenuBar::tr("Actions"));
+ contextMenuActionList.append(&contextAction);
+ insertNativeMenuItems(contextMenuActionList);
+ }
+}
QT_END_NAMESPACE
#endif //QT_NO_MENUBAR
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index d05323d..fb8a69b 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -2417,7 +2417,7 @@ int QMenuBar::findIdForAction(QAction *act) const
/*!
\fn int QMenuBar::margin() const
- Returns the with of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
Use QWidget::getContentsMargins() instead.
\sa setMargin(), QWidget::getContentsMargins()
diff --git a/src/gui/widgets/qmenubar.h b/src/gui/widgets/qmenubar.h
index 36c983b..42f0c0c 100644
--- a/src/gui/widgets/qmenubar.h
+++ b/src/gui/widgets/qmenubar.h
@@ -118,10 +118,6 @@ public:
static void wceRefresh();
#endif
-#ifdef Q_OS_SYMBIAN
- static void symbianCommands(int command);
-#endif
-
public Q_SLOTS:
virtual void setVisible(bool visible);
diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h
index d562cd9..9e7d511 100644
--- a/src/gui/widgets/qmenubar_p.h
+++ b/src/gui/widgets/qmenubar_p.h
@@ -257,9 +257,10 @@ public:
}
return 0;
}
+ void insertNativeMenuItems(const QList<QAction*> &actions);
} *symbian_menubar;
- bool symbianCommands(int command);
+ static void symbianCommands(int command);
#endif
};
diff --git a/src/gui/widgets/qmenudata.h b/src/gui/widgets/qmenudata.h
index 24d960a..d570f20 100644
--- a/src/gui/widgets/qmenudata.h
+++ b/src/gui/widgets/qmenudata.h
@@ -67,6 +67,8 @@ private:
friend class QMenuBar;
void setId(int);
void setSignalValue(int);
+
+ Q_DISABLE_COPY(QMenuItem);
};
QT_END_NAMESPACE
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index e563fa1..3d2c4f5 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -72,6 +72,11 @@
QT_BEGIN_NAMESPACE
+static inline bool shouldEnableInputMethod(QPlainTextEdit *plaintextedit)
+{
+ return !plaintextedit->isReadOnly();
+}
+
class QPlainTextDocumentLayoutPrivate : public QAbstractTextDocumentLayoutPrivate
{
Q_DECLARE_PUBLIC(QPlainTextDocumentLayout)
@@ -705,7 +710,8 @@ QPlainTextEditPrivate::QPlainTextEditPrivate()
tabChangesFocus(false),
lineWrap(QPlainTextEdit::WidgetWidth),
wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere),
- topLine(0), pageUpDownLastCursorYIsValid(false)
+ clickCausedFocus(0),topLine(0),
+ pageUpDownLastCursorYIsValid(false)
{
showCursorOnInitialShow = true;
backgroundVisible = false;
@@ -1905,6 +1911,13 @@ void QPlainTextEdit::mouseReleaseEvent(QMouseEvent *e)
d->autoScrollTimer.stop();
d->ensureCursorVisible();
}
+
+ if (e->button() == Qt::LeftButton && qApp->autoSipEnabled()
+ && (!d->clickCausedFocus || qApp->autoSipOnMouseFocus())) {
+ QEvent event(QEvent::RequestSoftwareInputPanel);
+ QApplication::sendEvent(this, &event);
+ }
+ d->clickCausedFocus = 0;
}
/*! \reimp
@@ -2038,6 +2051,9 @@ QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const
void QPlainTextEdit::focusInEvent(QFocusEvent *e)
{
Q_D(QPlainTextEdit);
+ if (e->reason() == Qt::MouseFocusReason) {
+ d->clickCausedFocus = 1;
+ }
QAbstractScrollArea::focusInEvent(e);
d->sendControlEvent(e);
}
@@ -2304,7 +2320,7 @@ void QPlainTextEdit::setReadOnly(bool ro)
} else {
flags = Qt::TextEditorInteraction;
}
- setAttribute(Qt::WA_InputMethodEnabled, !ro);
+ setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this));
d->control->setTextInteractionFlags(flags);
}
diff --git a/src/gui/widgets/qplaintextedit_p.h b/src/gui/widgets/qplaintextedit_p.h
index 0739d53..56a3aa9 100644
--- a/src/gui/widgets/qplaintextedit_p.h
+++ b/src/gui/widgets/qplaintextedit_p.h
@@ -91,7 +91,10 @@ public:
return r;
}
inline QRectF cursorRect() { return cursorRect(textCursor()); }
- void ensureCursorVisible() { textEdit->ensureCursorVisible(); }
+ void ensureCursorVisible() {
+ textEdit->ensureCursorVisible();
+ emit microFocusChanged();
+ }
QPlainTextEdit *textEdit;
@@ -148,6 +151,7 @@ public:
uint backgroundVisible : 1;
uint centerOnScroll : 1;
uint inDrag : 1;
+ uint clickCausedFocus : 1;
int topLine;
diff --git a/src/gui/widgets/qprintpreviewwidget.cpp b/src/gui/widgets/qprintpreviewwidget.cpp
index 16334b8..80c1271 100644
--- a/src/gui/widgets/qprintpreviewwidget.cpp
+++ b/src/gui/widgets/qprintpreviewwidget.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qprintpreviewwidget.h"
+#include "private/qwidget_p.h"
#include <private/qprinter_p.h>
#include <QtCore/qmath.h>
@@ -170,12 +171,12 @@ protected:
} // anonymous namespace
-class QPrintPreviewWidgetPrivate
+class QPrintPreviewWidgetPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QPrintPreviewWidget)
public:
- QPrintPreviewWidgetPrivate(QPrintPreviewWidget *q)
- : q_ptr(q), scene(0), curPage(1),
+ QPrintPreviewWidgetPrivate()
+ : scene(0), curPage(1),
viewMode(QPrintPreviewWidget::SinglePageView),
zoomMode(QPrintPreviewWidget::FitInView),
zoomFactor(1), initialized(false), fitting(true)
@@ -194,7 +195,6 @@ public:
void setZoomFactor(qreal zoomFactor);
int calcCurrentPage();
- QPrintPreviewWidget *q_ptr;
GraphicsView *graphicsView;
QGraphicsScene *scene;
@@ -518,7 +518,7 @@ void QPrintPreviewWidgetPrivate::setZoomFactor(qreal _zoomFactor)
\sa QWidget::setWindowFlags()
*/
QPrintPreviewWidget::QPrintPreviewWidget(QPrinter *printer, QWidget *parent, Qt::WindowFlags flags)
- : QWidget(parent, flags), d_ptr(new QPrintPreviewWidgetPrivate(this))
+ : QWidget(*new QPrintPreviewWidgetPrivate, parent, flags)
{
Q_D(QPrintPreviewWidget);
d->printer = printer;
@@ -534,7 +534,7 @@ QPrintPreviewWidget::QPrintPreviewWidget(QPrinter *printer, QWidget *parent, Qt:
preview.
*/
QPrintPreviewWidget::QPrintPreviewWidget(QWidget *parent, Qt::WindowFlags flags)
- : QWidget(parent, flags), d_ptr(new QPrintPreviewWidgetPrivate(this))
+ : QWidget(*new QPrintPreviewWidgetPrivate, parent, flags)
{
Q_D(QPrintPreviewWidget);
d->printer = new QPrinter;
@@ -551,7 +551,6 @@ QPrintPreviewWidget::~QPrintPreviewWidget()
Q_D(QPrintPreviewWidget);
if (d->ownPrinter)
delete d->printer;
- delete d_ptr;
}
/*!
diff --git a/src/gui/widgets/qprintpreviewwidget.h b/src/gui/widgets/qprintpreviewwidget.h
index 27110a4..9f7ea6e 100644
--- a/src/gui/widgets/qprintpreviewwidget.h
+++ b/src/gui/widgets/qprintpreviewwidget.h
@@ -111,7 +111,7 @@ Q_SIGNALS:
void previewChanged();
private:
- QPrintPreviewWidgetPrivate *d_ptr;
+ void *dummy; // ### remove in Qt 5.0
Q_PRIVATE_SLOT(d_func(), void _q_fit())
Q_PRIVATE_SLOT(d_func(), void _q_updateCurrentPage())
};
diff --git a/src/gui/widgets/qprogressbar.cpp b/src/gui/widgets/qprogressbar.cpp
index cdb3836..1a7f878 100644
--- a/src/gui/widgets/qprogressbar.cpp
+++ b/src/gui/widgets/qprogressbar.cpp
@@ -349,6 +349,8 @@ void QProgressBar::setRange(int minimum, int maximum)
\property QProgressBar::textVisible
\brief whether the current completed percentage should be displayed
+ This property may be ignored by the style (e.g., QMacStyle never draws the text).
+
\sa textDirection
*/
void QProgressBar::setTextVisible(bool visible)
diff --git a/src/gui/widgets/qscrollarea.cpp b/src/gui/widgets/qscrollarea.cpp
index 6aca7d3..8b01453 100644
--- a/src/gui/widgets/qscrollarea.cpp
+++ b/src/gui/widgets/qscrollarea.cpp
@@ -127,7 +127,7 @@ QT_BEGIN_NAMESPACE
setting the layout's \l{QLayout::sizeConstraint}{size constraint}
property to one which provides constraints on the minimum and/or
maximum size of the layout (e.g., QLayout::SetMinAndMaxSize) will
- cause the size of the the scroll area to be updated whenever the
+ cause the size of the scroll area to be updated whenever the
contents of the layout changes.
For a complete example using the QScrollArea class, see the \l
diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp
index c691eaf..295bf48 100644
--- a/src/gui/widgets/qspinbox.cpp
+++ b/src/gui/widgets/qspinbox.cpp
@@ -77,6 +77,8 @@ public:
QChar thousand;
inline void init() {
+ Q_Q(QSpinBox);
+ q->setInputMethodHints(Qt::ImhDigitsOnly);
setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem);
}
};
@@ -97,6 +99,11 @@ public:
// variables
int decimals;
QChar delimiter, thousand;
+
+ inline void init() {
+ Q_Q(QDoubleSpinBox);
+ q->setInputMethodHints(Qt::ImhFormattedNumbersOnly);
+ }
};
@@ -592,6 +599,8 @@ void QSpinBox::fixup(QString &input) const
QDoubleSpinBox::QDoubleSpinBox(QWidget *parent)
: QAbstractSpinBox(*new QDoubleSpinBoxPrivate(parent), parent)
{
+ Q_D(QDoubleSpinBox);
+ d->init();
}
/*!
diff --git a/src/gui/widgets/qsplitter.cpp b/src/gui/widgets/qsplitter.cpp
index bf8af35..45e838f 100644
--- a/src/gui/widgets/qsplitter.cpp
+++ b/src/gui/widgets/qsplitter.cpp
@@ -1517,7 +1517,7 @@ void QSplitter::setOpaqueResize(bool on)
/*!
\fn int QSplitter::margin() const
- Returns the with of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
Use QWidget::getContentsMargins() instead.
\sa setMargin(), QWidget::getContentsMargins()
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 69221ba..785d772 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -1536,9 +1536,10 @@ void QTabBar::paintEvent(QPaintEvent *)
}
if (!d->dragInProgress)
p.drawControl(QStyle::CE_TabBarTab, tab);
- else
- d->movingTab->setGeometry(tab.rect);
-
+ else {
+ int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this);
+ d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0));
+ }
}
// Only draw the tear indicator if necessary. Most of the time we don't need too.
@@ -1805,7 +1806,9 @@ void QTabBarPrivate::setupMovableTab()
if (!movingTab)
movingTab = new QWidget(q);
+ int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q);
QRect grabRect = q->tabRect(pressedIndex);
+ grabRect.adjust(-taboverlap, 0, taboverlap, 0);
QPixmap grabImage(grabRect.size());
grabImage.fill(Qt::transparent);
@@ -1813,7 +1816,7 @@ void QTabBarPrivate::setupMovableTab()
QStyleOptionTabV3 tab;
q->initStyleOption(&tab, pressedIndex);
- tab.rect.moveTopLeft(QPoint(0, 0));
+ tab.rect.moveTopLeft(QPoint(taboverlap, 0));
p.drawControl(QStyle::CE_TabBarTab, tab);
p.end();
diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp
index c16e000..43b2f54 100644
--- a/src/gui/widgets/qtabwidget.cpp
+++ b/src/gui/widgets/qtabwidget.cpp
@@ -504,7 +504,7 @@ QIcon QTabWidget::tabIcon(int index) const
}
/*!
- Returns true if the the page at position \a index is enabled; otherwise returns false.
+ Returns true if the page at position \a index is enabled; otherwise returns false.
\sa setTabEnabled(), QWidget::isEnabled()
*/
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index 1c4df93..c1ec5c2 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -74,6 +74,10 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_TEXTEDIT
+static inline bool shouldEnableInputMethod(QTextEdit *textedit)
+{
+ return !textedit->isReadOnly();
+}
class QTextEditControl : public QTextControl
{
@@ -104,7 +108,7 @@ public:
QTextEditPrivate::QTextEditPrivate()
: control(0),
autoFormatting(QTextEdit::AutoNone), tabChangesFocus(false),
- lineWrap(QTextEdit::WidgetWidth), lineWrapColumnOrWidth(0),
+ lineWrap(QTextEdit::WidgetWidth), lineWrapColumnOrWidth(0), clickCausedFocus(0),
wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere), textFormat(Qt::AutoText)
{
ignoreAutomaticScrollbarAdjustment = false;
@@ -1559,6 +1563,12 @@ void QTextEdit::mouseReleaseEvent(QMouseEvent *e)
d->autoScrollTimer.stop();
ensureCursorVisible();
}
+ if (e->button() == Qt::LeftButton && qApp->autoSipEnabled()
+ && (!d->clickCausedFocus || qApp->autoSipOnMouseFocus())) {
+ QEvent event(QEvent::RequestSoftwareInputPanel);
+ QApplication::sendEvent(this, &event);
+ }
+ d->clickCausedFocus = 0;
}
/*! \reimp
@@ -1694,6 +1704,9 @@ QVariant QTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const
void QTextEdit::focusInEvent(QFocusEvent *e)
{
Q_D(QTextEdit);
+ if (e->reason() == Qt::MouseFocusReason) {
+ d->clickCausedFocus = 1;
+ }
QAbstractScrollArea::focusInEvent(e);
d->sendControlEvent(e);
}
@@ -2058,7 +2071,7 @@ void QTextEdit::setReadOnly(bool ro)
} else {
flags = Qt::TextEditorInteraction;
}
- setAttribute(Qt::WA_InputMethodEnabled, !ro);
+ setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this));
d->control->setTextInteractionFlags(flags);
}
diff --git a/src/gui/widgets/qtextedit_p.h b/src/gui/widgets/qtextedit_p.h
index 3c37868..594174a 100644
--- a/src/gui/widgets/qtextedit_p.h
+++ b/src/gui/widgets/qtextedit_p.h
@@ -123,6 +123,7 @@ public:
uint preferRichText : 1;
uint showCursorOnInitialShow : 1;
uint inDrag : 1;
+ uint clickCausedFocus : 1;
// Qt3 COMPAT only, for setText
Qt::TextFormat textFormat;
diff --git a/src/gui/widgets/qtoolbox.cpp b/src/gui/widgets/qtoolbox.cpp
index 81935a5..271130a 100644
--- a/src/gui/widgets/qtoolbox.cpp
+++ b/src/gui/widgets/qtoolbox.cpp
@@ -802,7 +802,7 @@ void QToolBox::itemRemoved(int index)
/*!
\fn int QToolBox::margin() const
- Returns the with of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
Use QWidget::getContentsMargins() instead.
\sa setMargin(), QWidget::getContentsMargins()
diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri
index fc57944..9e226e2 100644
--- a/src/gui/widgets/widgets.pri
+++ b/src/gui/widgets/widgets.pri
@@ -78,8 +78,8 @@ HEADERS += \
widgets/qtoolbararealayout_p.h \
widgets/qplaintextedit.h \
widgets/qplaintextedit_p.h \
- widgets/qprintpreviewwidget.h
-
+ widgets/qprintpreviewwidget.h \
+ widgets/qactiontokeyeventmapper_p.h
SOURCES += \
widgets/qabstractbutton.cpp \
widgets/qabstractslider.cpp \
@@ -138,8 +138,8 @@ SOURCES += \
widgets/qwidgetanimator.cpp \
widgets/qtoolbararealayout.cpp \
widgets/qplaintextedit.cpp \
- widgets/qprintpreviewwidget.cpp
-
+ widgets/qprintpreviewwidget.cpp \
+ widgets/qactiontokeyeventmapper.cpp
!embedded:mac {
HEADERS += widgets/qmacnativewidget_mac.h \