summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorThomas Zander <t.zander@nokia.com>2010-09-28 11:44:45 (GMT)
committerThomas Zander <t.zander@nokia.com>2010-09-28 11:44:45 (GMT)
commit5c08412285f14d89174aef1190a1de1c35fd62bd (patch)
tree2e9bef2fdf0af18db76b011cd9c4ed4b456f507c /tools
parent2645784f05db7b1e631621c511e94c88fc5cd211 (diff)
parent2868302626b8a31f44df1068514485a89ec27171 (diff)
downloadQt-5c08412285f14d89174aef1190a1de1c35fd62bd.zip
Qt-5c08412285f14d89174aef1190a1de1c35fd62bd.tar.gz
Qt-5c08412285f14d89174aef1190a1de1c35fd62bd.tar.bz2
Merge commit 'origin/master' into fileEnginesOn47
Conflicts: qmake/Makefile.win32 qmake/qmake.pri src/corelib/io/qdir.cpp src/corelib/io/qfileinfo.cpp src/corelib/io/qfileinfo_p.h src/corelib/io/qfsfileengine_win.cpp src/s60installs/bwins/QtGuiu.def src/s60installs/eabi/QtCoreu.def src/s60installs/eabi/QtGuiu.def src/tools/bootstrap/bootstrap.pro tests/auto/qfileinfo/tst_qfileinfo.cpp
Diffstat (limited to 'tools')
-rw-r--r--tools/activeqt/testcon/changeproperties.cpp8
-rw-r--r--tools/assistant/lib/fulltextsearch/qsort_p.h8
-rw-r--r--tools/assistant/lib/qhelpcollectionhandler_p.h3
-rw-r--r--tools/assistant/lib/qhelpengine.h2
-rw-r--r--tools/assistant/lib/qhelpenginecore.cpp2
-rw-r--r--tools/assistant/lib/qhelpenginecore.h2
-rw-r--r--tools/assistant/lib/qhelpsearchengine.h3
-rw-r--r--tools/assistant/lib/qhelpsearchindexreader_clucene.cpp4
-rw-r--r--tools/assistant/lib/qhelpsearchquerywidget.cpp84
-rw-r--r--tools/assistant/lib/qhelpsearchquerywidget.h4
-rw-r--r--tools/assistant/tools/assistant/bookmarkfiltermodel.cpp116
-rw-r--r--tools/assistant/tools/assistant/bookmarkitem.cpp5
-rw-r--r--tools/assistant/tools/assistant/bookmarkitem.h2
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanager.cpp101
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanager.h9
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanagerwidget.h5
-rw-r--r--tools/assistant/tools/assistant/bookmarkmodel.cpp35
-rw-r--r--tools/assistant/tools/assistant/centralwidget.cpp148
-rw-r--r--tools/assistant/tools/assistant/centralwidget.h30
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.cpp6
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.h1
-rw-r--r--tools/assistant/tools/assistant/globalactions.cpp83
-rw-r--r--tools/assistant/tools/assistant/globalactions.h14
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.cpp27
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.h5
-rw-r--r--tools/assistant/tools/assistant/helpviewer.h1
-rw-r--r--tools/assistant/tools/assistant/installdialog.h2
-rw-r--r--tools/assistant/tools/assistant/main.cpp5
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp36
-rw-r--r--tools/assistant/tools/assistant/mainwindow.h2
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.cpp19
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.h3
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.cpp7
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.h2
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.ui20
-rw-r--r--tools/assistant/tools/assistant/remotecontrol.cpp22
-rw-r--r--tools/assistant/tools/assistant/searchwidget.cpp13
-rw-r--r--tools/assistant/tools/assistant/searchwidget.h6
-rw-r--r--tools/assistant/tools/qcollectiongenerator/main.cpp86
-rw-r--r--tools/assistant/tools/qhelpconverter/filespage.cpp4
-rw-r--r--tools/assistant/tools/qhelpconverter/filterpage.cpp4
-rw-r--r--tools/assistant/tools/qhelpconverter/finishpage.cpp3
-rw-r--r--tools/assistant/tools/qhelpconverter/helpwindow.cpp2
-rw-r--r--tools/assistant/tools/qhelpconverter/inputpage.h2
-rw-r--r--tools/assistant/tools/qhelpconverter/main.cpp15
-rw-r--r--tools/assistant/tools/qhelpgenerator/main.cpp42
-rw-r--r--tools/assistant/tools/shared/collectionconfiguration.cpp14
-rw-r--r--tools/assistant/tools/shared/collectionconfiguration.h4
-rw-r--r--tools/assistant/tools/shared/helpgenerator.cpp4
-rw-r--r--tools/configure/configure.pro3
-rw-r--r--tools/configure/configureapp.cpp83
-rw-r--r--tools/configure/environment.cpp7
-rw-r--r--tools/configure/tools.cpp10
-rw-r--r--tools/designer/data/ui4.xsd1
-rw-r--r--tools/designer/src/components/formeditor/formeditor.qrc1
-rw-r--r--tools/designer/src/components/formeditor/formeditor_optionspage.cpp6
-rw-r--r--tools/designer/src/components/formeditor/qdesigner_resource.cpp36
-rw-r--r--tools/designer/src/components/propertyeditor/defs.cpp107
-rw-r--r--tools/designer/src/components/propertyeditor/designerpropertymanager.cpp310
-rw-r--r--tools/designer/src/components/propertyeditor/designerpropertymanager.h3
-rw-r--r--tools/designer/src/components/propertyeditor/propertyeditor.pri4
-rw-r--r--tools/designer/src/components/taskmenu/itemlisteditor.cpp22
-rw-r--r--tools/designer/src/lib/sdk/abstractintegration.cpp51
-rw-r--r--tools/designer/src/lib/sdk/abstractintegration.h10
-rw-r--r--tools/designer/src/lib/shared/actioneditor.cpp3
-rw-r--r--tools/designer/src/lib/shared/actionrepository.cpp6
-rw-r--r--tools/designer/src/lib/shared/iconselector.cpp124
-rw-r--r--tools/designer/src/lib/shared/iconselector_p.h30
-rw-r--r--tools/designer/src/lib/shared/newactiondialog.cpp4
-rw-r--r--tools/designer/src/lib/shared/newactiondialog.ui54
-rw-r--r--tools/designer/src/lib/shared/plugindialog.cpp4
-rw-r--r--tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp12
-rw-r--r--tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h11
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertysheet.cpp4
-rw-r--r--tools/designer/src/lib/shared/qdesigner_utils.cpp232
-rw-r--r--tools/designer/src/lib/shared/qdesigner_utils_p.h24
-rw-r--r--tools/designer/src/lib/uilib/abstractformbuilder.cpp123
-rw-r--r--tools/designer/src/lib/uilib/resourcebuilder.cpp11
-rw-r--r--tools/designer/src/lib/uilib/ui4.cpp11
-rw-r--r--tools/designer/src/lib/uilib/ui4_p.h8
-rw-r--r--tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp4
-rw-r--r--tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp4
-rw-r--r--tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp4
-rw-r--r--tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp4
-rw-r--r--tools/designer/src/plugins/qwebview/qwebview_plugin.cpp4
-rw-r--r--tools/linguist/lconvert/main.cpp21
-rw-r--r--tools/linguist/linguist/mainwindow.cpp11
-rw-r--r--tools/linguist/linguist/phrase.cpp7
-rw-r--r--tools/linguist/linguist/sourcecodeview.cpp2
-rw-r--r--tools/linguist/lrelease/main.cpp52
-rw-r--r--tools/linguist/lupdate/cpp.cpp102
-rw-r--r--tools/linguist/lupdate/java.cpp29
-rw-r--r--tools/linguist/lupdate/main.cpp32
-rw-r--r--tools/linguist/lupdate/merge.cpp18
-rw-r--r--tools/linguist/lupdate/qdeclarative.cpp166
-rw-r--r--tools/linguist/lupdate/qscript.cpp262
-rw-r--r--tools/linguist/lupdate/qscript.g276
-rw-r--r--tools/linguist/lupdate/ui.cpp19
-rw-r--r--tools/linguist/shared/po.cpp30
-rw-r--r--tools/linguist/shared/translator.h4
-rw-r--r--tools/linguist/shared/xliff.cpp17
-rw-r--r--tools/porting/src/errors.cpp6
-rw-r--r--tools/porting/src/errors.h6
-rw-r--r--tools/porting/src/rpp.cpp4
-rw-r--r--tools/porting/src/semantic.cpp4
-rw-r--r--tools/porting/src/tokenengine.h2
-rw-r--r--tools/porting/src/tokenreplacements.cpp8
-rw-r--r--tools/qdoc3/ditaxmlgenerator.cpp10
-rw-r--r--tools/qdoc3/doc/files/qt.qdocconf8
-rw-r--r--tools/qdoc3/htmlgenerator.cpp207
-rw-r--r--tools/qdoc3/htmlgenerator.h1
-rw-r--r--tools/qdoc3/main.cpp2
-rw-r--r--tools/qdoc3/node.cpp23
-rw-r--r--tools/qdoc3/qdoc3.pro1
-rw-r--r--tools/qdoc3/test/assistant.qdocconf2
-rw-r--r--tools/qdoc3/test/designer.qdocconf12
-rw-r--r--tools/qdoc3/test/linguist.qdocconf14
-rw-r--r--tools/qdoc3/test/qdeclarative.qdocconf58
-rw-r--r--tools/qdoc3/test/qmake.qdocconf58
-rw-r--r--tools/qdoc3/test/qt-build-docs.qdocconf1
-rw-r--r--tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf13
-rw-r--r--tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf13
-rw-r--r--tools/qdoc3/test/qt-defines.qdocconf52
-rw-r--r--tools/qdoc3/test/qt-html-templates.qdocconf48
-rw-r--r--tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf9
-rw-r--r--tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf9
-rw-r--r--tools/qdoc3/test/qt.qdocconf8
-rw-r--r--tools/qdoc3/test/qt_ja_JP.qdocconf7
-rw-r--r--tools/qdoc3/test/qt_zh_CN.qdocconf11
-rw-r--r--tools/qdoc3/tree.cpp6
-rw-r--r--tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp133
-rw-r--r--tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h175
-rw-r--r--tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro10
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoliveimage.cpp115
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoliveimage.h106
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoliveimage_p.h63
-rw-r--r--tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp163
-rw-r--r--tools/qmeegographicssystemhelper/qmeegolivepixmap.h98
-rw-r--r--tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h (renamed from tools/designer/src/components/propertyeditor/defs.h)40
-rw-r--r--tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp99
-rw-r--r--tools/qmeegographicssystemhelper/qmeegooverlaywidget.h86
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoruntime.cpp158
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoruntime.h61
-rw-r--r--tools/qml/deviceorientation.cpp5
-rw-r--r--tools/qml/deviceorientation.h3
-rw-r--r--tools/qml/deviceorientation_maemo5.cpp53
-rw-r--r--tools/qml/deviceorientation_symbian.cpp27
-rw-r--r--tools/qml/main.cpp3
-rw-r--r--tools/qml/qml.pro2
-rw-r--r--tools/qml/qmlruntime.cpp24
-rw-r--r--tools/qml/qmlruntime.h1
-rw-r--r--tools/qml/startup/startup.qml88
-rw-r--r--tools/qtconfig/main.cpp14
-rw-r--r--tools/qvfb/main.cpp13
-rw-r--r--tools/qvfb/qvfb.cpp54
-rw-r--r--tools/qvfb/qvfbratedlg.cpp10
-rw-r--r--tools/runonphone/ossignalconverter.cpp1
-rw-r--r--tools/runonphone/ossignalconverter.h2
-rw-r--r--tools/runonphone/runonphone.pro3
-rw-r--r--tools/shared/qtpropertybrowser/qtpropertymanager.cpp44
-rw-r--r--tools/tools.pro4
161 files changed, 4514 insertions, 1155 deletions
diff --git a/tools/activeqt/testcon/changeproperties.cpp b/tools/activeqt/testcon/changeproperties.cpp
index b0609b0..eca1bf9 100644
--- a/tools/activeqt/testcon/changeproperties.cpp
+++ b/tools/activeqt/testcon/changeproperties.cpp
@@ -111,10 +111,10 @@ void ChangeProperties::on_buttonSet_clicked()
value = QVariant::fromValue(col);
} else {
QMessageBox::warning(this, tr("Can't parse input"),
- QString(tr("Failed to create a color from %1\n"
+ tr("Failed to create a color from %1\n"
"The string has to be a valid color name (e.g. 'red')\n"
"or a RGB triple of format '#rrggbb'."
- ).arg(editValue->text())));
+ ).arg(editValue->text()));
}
}
break;
@@ -125,10 +125,10 @@ void ChangeProperties::on_buttonSet_clicked()
value = QVariant::fromValue(fnt);
} else {
QMessageBox::warning(this, tr("Can't parse input"),
- (tr("Failed to create a font from %1\n"
+ tr("Failed to create a font from %1\n"
"The string has to have a format family,<point size> or\n"
"family,pointsize,stylehint,weight,italic,underline,strikeout,fixedpitch,rawmode."
- ).arg(editValue->text())));
+ ).arg(editValue->text()));
}
}
break;
diff --git a/tools/assistant/lib/fulltextsearch/qsort_p.h b/tools/assistant/lib/fulltextsearch/qsort_p.h
index e6f024b..5c75c58 100644
--- a/tools/assistant/lib/fulltextsearch/qsort_p.h
+++ b/tools/assistant/lib/fulltextsearch/qsort_p.h
@@ -64,15 +64,15 @@ private:
class QHELP_EXPORT QCLuceneSort
{
public:
- QCLuceneSort();
- QCLuceneSort(const QStringList &fieldNames);
- QCLuceneSort(const QString &field, bool reverse = false);
+ QCLuceneSort();
+ explicit QCLuceneSort(const QStringList &fieldNames);
+ explicit QCLuceneSort(const QString &field, bool reverse = false);
virtual ~QCLuceneSort();
QString toString() const;
void setSort(const QStringList &fieldNames);
- void setSort(const QString &field, bool reverse = false);
+ void setSort(const QString &field, bool reverse = false);
protected:
friend class QCLuceneHits;
diff --git a/tools/assistant/lib/qhelpcollectionhandler_p.h b/tools/assistant/lib/qhelpcollectionhandler_p.h
index 8efe507..8901b06 100644
--- a/tools/assistant/lib/qhelpcollectionhandler_p.h
+++ b/tools/assistant/lib/qhelpcollectionhandler_p.h
@@ -76,7 +76,8 @@ public:
};
typedef QList<DocInfo> DocInfoList;
- QHelpCollectionHandler(const QString &collectionFile, QObject *parent = 0);
+ explicit QHelpCollectionHandler(const QString &collectionFile,
+ QObject *parent = 0);
~QHelpCollectionHandler();
QString collectionFile() const;
diff --git a/tools/assistant/lib/qhelpengine.h b/tools/assistant/lib/qhelpengine.h
index 2bdb983..3577f4b 100644
--- a/tools/assistant/lib/qhelpengine.h
+++ b/tools/assistant/lib/qhelpengine.h
@@ -62,7 +62,7 @@ class QHELP_EXPORT QHelpEngine : public QHelpEngineCore
Q_OBJECT
public:
- QHelpEngine(const QString &collectionFile, QObject *parent = 0);
+ explicit QHelpEngine(const QString &collectionFile, QObject *parent = 0);
~QHelpEngine();
QHelpContentModel *contentModel() const;
diff --git a/tools/assistant/lib/qhelpenginecore.cpp b/tools/assistant/lib/qhelpenginecore.cpp
index 71306af..d72dfe4 100644
--- a/tools/assistant/lib/qhelpenginecore.cpp
+++ b/tools/assistant/lib/qhelpenginecore.cpp
@@ -706,7 +706,7 @@ QVariant QHelpEngineCore::metaData(const QString &documentationFileName,
}
/*!
- Returns a description of the last error that occured.
+ Returns a description of the last error that occurred.
*/
QString QHelpEngineCore::error() const
{
diff --git a/tools/assistant/lib/qhelpenginecore.h b/tools/assistant/lib/qhelpenginecore.h
index 118c310..db25c0b 100644
--- a/tools/assistant/lib/qhelpenginecore.h
+++ b/tools/assistant/lib/qhelpenginecore.h
@@ -65,7 +65,7 @@ class QHELP_EXPORT QHelpEngineCore : public QObject
Q_PROPERTY(QString currentFilter READ currentFilter WRITE setCurrentFilter)
public:
- QHelpEngineCore(const QString &collectionFile, QObject *parent = 0);
+ explicit QHelpEngineCore(const QString &collectionFile, QObject *parent = 0);
virtual ~QHelpEngineCore();
bool setupData();
diff --git a/tools/assistant/lib/qhelpsearchengine.h b/tools/assistant/lib/qhelpsearchengine.h
index 545360c..0b07920 100644
--- a/tools/assistant/lib/qhelpsearchengine.h
+++ b/tools/assistant/lib/qhelpsearchengine.h
@@ -80,7 +80,8 @@ class QHELP_EXPORT QHelpSearchEngine : public QObject
Q_OBJECT
public:
- QHelpSearchEngine(QHelpEngineCore *helpEngine, QObject *parent = 0);
+ explicit QHelpSearchEngine(QHelpEngineCore *helpEngine,
+ QObject *parent = 0);
~QHelpSearchEngine();
QHelpSearchQueryWidget* queryWidget();
diff --git a/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp b/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp
index c2274c4..75cc2b9 100644
--- a/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp
+++ b/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp
@@ -173,7 +173,7 @@ void QHelpSearchIndexReaderClucene::run()
QCLuceneDocument document;
const QStringList namespaceList = engine.registeredDocumentations();
- foreach (QSharedPointer<QCLuceneHits> hits, cluceneHitsList) {
+ foreach (const QSharedPointer<QCLuceneHits> &hits, cluceneHitsList) {
for (qint32 i = 0; i < hits->length(); i++) {
document = hits->document(i);
const QString path = document.get(PathField);
@@ -415,7 +415,7 @@ bool QHelpSearchIndexReaderClucene::addAttributesQuery(
void QHelpSearchIndexReaderClucene::boostSearchHits(const QHelpEngineCore &engine,
QList<QHelpSearchEngine::SearchHit> &hitList, const QList<QHelpSearchQuery> &queryList)
{
- foreach (const QHelpSearchQuery query, queryList) {
+ foreach (const QHelpSearchQuery &query, queryList) {
if (query.fieldName != QHelpSearchQuery::DEFAULT)
continue;
diff --git a/tools/assistant/lib/qhelpsearchquerywidget.cpp b/tools/assistant/lib/qhelpsearchquerywidget.cpp
index 1634a0d..8e8b278 100644
--- a/tools/assistant/lib/qhelpsearchquerywidget.cpp
+++ b/tools/assistant/lib/qhelpsearchquerywidget.cpp
@@ -215,37 +215,36 @@ private:
queryHist->curQuery += addend;
const QList<QHelpSearchQuery> &query =
- queryHist->queries.at(queryHist->curQuery);
+ queryHist->queries.at(queryHist->curQuery);
foreach (const QHelpSearchQuery &queryPart, query) {
- QLineEdit *lineEdit = 0;
- switch (queryPart.fieldName) {
+ if (QLineEdit *lineEdit = lineEditFor(queryPart.fieldName))
+ lineEdit->setText(queryPart.wordList.join(" "));
+ }
+
+ if (queryHist->curQuery == maxOrMinIndex)
+ thisButton->setEnabled(false);
+ otherButton->setEnabled(true);
+ }
+
+ QLineEdit* lineEditFor(const QHelpSearchQuery::FieldName &fieldName) const
+ {
+ switch (fieldName) {
case QHelpSearchQuery::DEFAULT:
- lineEdit = defaultQuery;
- break;
+ return defaultQuery;
case QHelpSearchQuery::ALL:
- lineEdit = allQuery;
- break;
+ return allQuery;
case QHelpSearchQuery::ATLEAST:
- lineEdit = atLeastQuery;
- break;
+ return atLeastQuery;
case QHelpSearchQuery::FUZZY:
- lineEdit = similarQuery;
- break;
+ return similarQuery;
case QHelpSearchQuery::WITHOUT:
- lineEdit = withoutQuery;
- break;
+ return withoutQuery;
case QHelpSearchQuery::PHRASE:
- lineEdit = exactQuery;
- break;
+ return exactQuery;
default:
Q_ASSERT(0);
- }
- lineEdit->setText(queryPart.wordList.join(" "));
}
-
- if (queryHist->curQuery == maxOrMinIndex)
- thisButton->setEnabled(false);
- otherButton->setEnabled(true);
+ return 0;
}
void enableOrDisableToolButtons()
@@ -512,8 +511,27 @@ QHelpSearchQueryWidget::~QHelpSearchQueryWidget()
}
/*!
+ Expands the search query widget so that the extended search fields are shown.
+*/
+void QHelpSearchQueryWidget::expandExtendedSearch()
+{
+ if (d->simpleSearch)
+ d->showHideAdvancedSearch();
+}
+
+/*!
+ Collapses the search query widget so that only the default search field is
+ shown.
+*/
+void QHelpSearchQueryWidget::collapseExtendedSearch()
+{
+ if (!d->simpleSearch)
+ d->showHideAdvancedSearch();
+}
+
+/*!
Returns a list of queries to use in combination with the search engines
- search(QList<QHelpSearchQuery> &query) function.
+ search(QList<QHelpSearchQuery> &queryList) function.
*/
QList<QHelpSearchQuery> QHelpSearchQueryWidget::query() const
{
@@ -524,6 +542,28 @@ QList<QHelpSearchQuery> QHelpSearchQueryWidget::query() const
}
/*!
+ Sets the QHelpSearchQueryWidget input fields to the values specified by
+ \a queryList search field name. Please note that one has to call the search
+ engine's search(QList<QHelpSearchQuery> &queryList) function to perform the
+ actual search.
+*/
+void QHelpSearchQueryWidget::setQuery(const QList<QHelpSearchQuery> &queryList)
+{
+ QList<QLineEdit *> lineEdits;
+ lineEdits << d->defaultQuery << d->allQuery << d->atLeastQuery
+ << d->similarQuery << d->withoutQuery << d->exactQuery;
+ foreach (QLineEdit *lineEdit, lineEdits)
+ lineEdit->clear();
+
+ const QLatin1String space(" ");
+ foreach (const QHelpSearchQuery &q, queryList) {
+ if (QLineEdit *lineEdit = d->lineEditFor(q.fieldName))
+ lineEdit->setText(lineEdit->text() + q.wordList.join(space) + space);
+ }
+ d->searchRequested();
+}
+
+/*!
\reimp
*/
void QHelpSearchQueryWidget::focusInEvent(QFocusEvent *focusEvent)
diff --git a/tools/assistant/lib/qhelpsearchquerywidget.h b/tools/assistant/lib/qhelpsearchquerywidget.h
index 2afc4b4..f3c290f 100644
--- a/tools/assistant/lib/qhelpsearchquerywidget.h
+++ b/tools/assistant/lib/qhelpsearchquerywidget.h
@@ -68,7 +68,11 @@ public:
QHelpSearchQueryWidget(QWidget *parent = 0);
~QHelpSearchQueryWidget();
+ void expandExtendedSearch();
+ void collapseExtendedSearch();
+
QList<QHelpSearchQuery> query() const;
+ void setQuery(const QList<QHelpSearchQuery> &queryList);
Q_SIGNALS:
void search();
diff --git a/tools/assistant/tools/assistant/bookmarkfiltermodel.cpp b/tools/assistant/tools/assistant/bookmarkfiltermodel.cpp
index 5874493..fe510a5 100644
--- a/tools/assistant/tools/assistant/bookmarkfiltermodel.cpp
+++ b/tools/assistant/tools/assistant/bookmarkfiltermodel.cpp
@@ -50,11 +50,30 @@ BookmarkFilterModel::BookmarkFilterModel(QObject *parent)
{
}
-void
-BookmarkFilterModel::setSourceModel(QAbstractItemModel *_sourceModel)
+void BookmarkFilterModel::setSourceModel(QAbstractItemModel *_sourceModel)
{
beginResetModel();
+ disconnect(sourceModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
+ SLOT(changed(QModelIndex, QModelIndex)));
+
+ disconnect(sourceModel, SIGNAL(rowsInserted(QModelIndex, int, int)),
+ this, SLOT(rowsInserted(QModelIndex, int, int)));
+
+ disconnect(sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)),
+ this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int)));
+ disconnect(sourceModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this,
+ SLOT(rowsRemoved(QModelIndex, int, int)));
+
+ disconnect(sourceModel, SIGNAL(layoutAboutToBeChanged()), this,
+ SLOT(layoutAboutToBeChanged()));
+ disconnect(sourceModel, SIGNAL(layoutChanged()), this,
+ SLOT(layoutChanged()));
+
+ disconnect(sourceModel, SIGNAL(modelAboutToBeReset()), this,
+ SLOT(modelAboutToBeReset()));
+ disconnect(sourceModel, SIGNAL(modelReset()), this, SLOT(modelReset()));
+
QAbstractProxyModel::setSourceModel(sourceModel);
sourceModel = qobject_cast<BookmarkModel*> (_sourceModel);
@@ -79,20 +98,18 @@ BookmarkFilterModel::setSourceModel(QAbstractItemModel *_sourceModel)
connect(sourceModel, SIGNAL(modelReset()), this, SLOT(modelReset()));
if (sourceModel)
- setupCache(sourceModel->index(0, 0, QModelIndex()));
+ setupCache(sourceModel->index(0, 0, QModelIndex()).parent());
endResetModel();
}
-int
-BookmarkFilterModel::rowCount(const QModelIndex &index) const
+int BookmarkFilterModel::rowCount(const QModelIndex &index) const
{
Q_UNUSED(index)
return cache.count();
}
-int
-BookmarkFilterModel::columnCount(const QModelIndex &index) const
+int BookmarkFilterModel::columnCount(const QModelIndex &index) const
{
Q_UNUSED(index)
if (sourceModel)
@@ -100,8 +117,7 @@ BookmarkFilterModel::columnCount(const QModelIndex &index) const
return 0;
}
-QModelIndex
-BookmarkFilterModel::mapToSource(const QModelIndex &proxyIndex) const
+QModelIndex BookmarkFilterModel::mapToSource(const QModelIndex &proxyIndex) const
{
const int row = proxyIndex.row();
if (proxyIndex.isValid() && row >= 0 && row < cache.count())
@@ -109,21 +125,19 @@ BookmarkFilterModel::mapToSource(const QModelIndex &proxyIndex) const
return QModelIndex();
}
-QModelIndex
-BookmarkFilterModel::mapFromSource(const QModelIndex &sourceIndex) const
+QModelIndex BookmarkFilterModel::mapFromSource(const QModelIndex &sourceIndex) const
{
return index(cache.indexOf(sourceIndex), 0, QModelIndex());
}
-QModelIndex
-BookmarkFilterModel::parent(const QModelIndex &child) const
+QModelIndex BookmarkFilterModel::parent(const QModelIndex &child) const
{
Q_UNUSED(child)
return QModelIndex();
}
-QModelIndex
-BookmarkFilterModel::index(int row, int column, const QModelIndex &index) const
+QModelIndex BookmarkFilterModel::index(int row, int column,
+ const QModelIndex &index) const
{
Q_UNUSED(index)
if (row < 0 || column < 0 || cache.count() <= row
@@ -133,32 +147,28 @@ BookmarkFilterModel::index(int row, int column, const QModelIndex &index) const
return createIndex(row, 0);
}
-Qt::DropActions
-BookmarkFilterModel::supportedDropActions () const
+Qt::DropActions BookmarkFilterModel::supportedDropActions () const
{
if (sourceModel)
return sourceModel->supportedDropActions();
return Qt::IgnoreAction;
}
-Qt::ItemFlags
-BookmarkFilterModel::flags(const QModelIndex &index) const
+Qt::ItemFlags BookmarkFilterModel::flags(const QModelIndex &index) const
{
if (sourceModel)
return sourceModel->flags(index);
return Qt::NoItemFlags;
}
-QVariant
-BookmarkFilterModel::data(const QModelIndex &index, int role) const
+QVariant BookmarkFilterModel::data(const QModelIndex &index, int role) const
{
if (sourceModel)
return sourceModel->data(mapToSource(index), role);
return QVariant();
}
-bool
-BookmarkFilterModel::setData(const QModelIndex &index, const QVariant &value,
+bool BookmarkFilterModel::setData(const QModelIndex &index, const QVariant &value,
int role)
{
if (sourceModel)
@@ -166,37 +176,34 @@ BookmarkFilterModel::setData(const QModelIndex &index, const QVariant &value,
return false;
}
-void
-BookmarkFilterModel::filterBookmarks()
+void BookmarkFilterModel::filterBookmarks()
{
if (sourceModel) {
beginResetModel();
hideBookmarks = true;
- setupCache(sourceModel->index(0, 0, QModelIndex()));
+ setupCache(sourceModel->index(0, 0, QModelIndex()).parent());
endResetModel();
}
}
-void
-BookmarkFilterModel::filterBookmarkFolders()
+void BookmarkFilterModel::filterBookmarkFolders()
{
if (sourceModel) {
beginResetModel();
hideBookmarks = false;
- setupCache(sourceModel->index(0, 0, QModelIndex()));
+ setupCache(sourceModel->index(0, 0, QModelIndex()).parent());
endResetModel();
}
}
-void
-BookmarkFilterModel::changed(const QModelIndex &topLeft,
+void BookmarkFilterModel::changed(const QModelIndex &topLeft,
const QModelIndex &bottomRight)
{
emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight));
}
-void
-BookmarkFilterModel::rowsInserted(const QModelIndex &parent, int start, int end)
+void BookmarkFilterModel::rowsInserted(const QModelIndex &parent, int start,
+ int end)
{
if (!sourceModel)
return;
@@ -218,15 +225,16 @@ BookmarkFilterModel::rowsInserted(const QModelIndex &parent, int start, int end)
const bool isFolder = newIndex.data(UserRoleFolder).toBool();
if ((isFolder && hideBookmarks) || (!isFolder && !hideBookmarks)) {
beginInsertRows(mapFromSource(parent), start, end);
- cache.insert(cache.indexOf(cachePrevious) + 1, newIndex);
+ const int index = cache.indexOf(cachePrevious) + 1;
+ if (cache.value(index, QPersistentModelIndex()) != newIndex)
+ cache.insert(index, newIndex);
endInsertRows();
}
}
}
-void
-BookmarkFilterModel::rowsAboutToBeRemoved(const QModelIndex &parent, int start,
- int end)
+void BookmarkFilterModel::rowsAboutToBeRemoved(const QModelIndex &parent,
+ int start, int end)
{
if (!sourceModel)
return;
@@ -240,8 +248,7 @@ BookmarkFilterModel::rowsAboutToBeRemoved(const QModelIndex &parent, int start,
}
}
-void
-BookmarkFilterModel::rowsRemoved(const QModelIndex &/*parent*/, int, int)
+void BookmarkFilterModel::rowsRemoved(const QModelIndex &/*parent*/, int, int)
{
if (cache.contains(indexToRemove)) {
cache.removeAll(indexToRemove);
@@ -249,41 +256,36 @@ BookmarkFilterModel::rowsRemoved(const QModelIndex &/*parent*/, int, int)
}
}
-void
-BookmarkFilterModel::layoutAboutToBeChanged()
+void BookmarkFilterModel::layoutAboutToBeChanged()
{
// TODO: ???
}
-void
-BookmarkFilterModel::layoutChanged()
+void BookmarkFilterModel::layoutChanged()
{
// TODO: ???
}
-void
-BookmarkFilterModel::modelAboutToBeReset()
+void BookmarkFilterModel::modelAboutToBeReset()
{
beginResetModel();
}
-void
-BookmarkFilterModel::modelReset()
+void BookmarkFilterModel::modelReset()
{
if (sourceModel)
- setupCache(sourceModel->index(0, 0, QModelIndex()));
+ setupCache(sourceModel->index(0, 0, QModelIndex()).parent());
endResetModel();
}
-void
-BookmarkFilterModel::setupCache(const QModelIndex &parent)
+void BookmarkFilterModel::setupCache(const QModelIndex &parent)
{
cache.clear();
- collectItems(parent);
+ for (int i = 0; i < sourceModel->rowCount(parent); ++i)
+ collectItems(sourceModel->index(i, 0, parent));
}
-void
-BookmarkFilterModel::collectItems(const QModelIndex &parent)
+void BookmarkFilterModel::collectItems(const QModelIndex &parent)
{
if (parent.isValid()) {
bool isFolder = sourceModel->data(parent, UserRoleFolder).toBool();
@@ -304,14 +306,12 @@ BookmarkTreeModel::BookmarkTreeModel(QObject *parent)
{
}
-int
-BookmarkTreeModel::columnCount(const QModelIndex &parent) const
+int BookmarkTreeModel::columnCount(const QModelIndex &parent) const
{
return qMin(1, QSortFilterProxyModel::columnCount(parent));
}
-bool
-BookmarkTreeModel::filterAcceptsRow(int row, const QModelIndex &parent) const
+bool BookmarkTreeModel::filterAcceptsRow(int row, const QModelIndex &parent) const
{
Q_UNUSED(row)
BookmarkModel *model = qobject_cast<BookmarkModel*> (sourceModel());
@@ -319,4 +319,4 @@ BookmarkTreeModel::filterAcceptsRow(int row, const QModelIndex &parent) const
&& model->data(model->index(row, 0, parent), UserRoleFolder).toBool())
return true;
return false;
-} \ No newline at end of file
+}
diff --git a/tools/assistant/tools/assistant/bookmarkitem.cpp b/tools/assistant/tools/assistant/bookmarkitem.cpp
index 2e81e38..2c92113 100644
--- a/tools/assistant/tools/assistant/bookmarkitem.cpp
+++ b/tools/assistant/tools/assistant/bookmarkitem.cpp
@@ -41,6 +41,7 @@
#include "bookmarkitem.h"
+#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
QT_BEGIN_NAMESPACE
@@ -147,7 +148,9 @@ BookmarkItem::insertChildren(bool isFolder, int position, int count)
for (int row = 0; row < count; ++row) {
m_children.insert(position, new BookmarkItem(DataVector()
- << QObject::tr(isFolder ? "New Folder" : "Untitled")
+ << (isFolder
+ ? QCoreApplication::translate("BookmarkItem", "New Folder")
+ : QCoreApplication::translate("BookmarkItem", "Untitled"))
<< (isFolder ? "Folder" : "about:blank") << false, this));
}
diff --git a/tools/assistant/tools/assistant/bookmarkitem.h b/tools/assistant/tools/assistant/bookmarkitem.h
index 924a762..7c5b8d0 100644
--- a/tools/assistant/tools/assistant/bookmarkitem.h
+++ b/tools/assistant/tools/assistant/bookmarkitem.h
@@ -58,7 +58,7 @@ typedef QVector<QVariant> DataVector;
class BookmarkItem
{
public:
- BookmarkItem(const DataVector &data, BookmarkItem *parent = 0);
+ explicit BookmarkItem(const DataVector &data, BookmarkItem *parent = 0);
~BookmarkItem();
BookmarkItem *parent() const;
diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp
index 65888fe..7a11ffe 100644
--- a/tools/assistant/tools/assistant/bookmarkmanager.cpp
+++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp
@@ -53,6 +53,7 @@
#include <QtGui/QKeyEvent>
#include <QtGui/QMessageBox>
#include <QtGui/QSortFilterProxyModel>
+#include <QtGui/QToolBar>
QT_BEGIN_NAMESPACE
@@ -136,11 +137,18 @@ QWidget* BookmarkManager::bookmarkDockWidget() const
return 0;
}
-void BookmarkManager::takeBookmarksMenu(QMenu* menu)
+void BookmarkManager::setBookmarksMenu(QMenu* menu)
{
TRACE_OBJ
bookmarkMenu = menu;
- refeshBookmarkMenu();
+ refreshBookmarkMenu();
+}
+
+void BookmarkManager::setBookmarksToolbar(QToolBar *toolBar)
+{
+ TRACE_OBJ
+ m_toolBar = toolBar;
+ refreshBookmarkToolBar();
}
// -- public slots
@@ -157,7 +165,10 @@ void BookmarkManager::addBookmark(const QString &title, const QString &url)
BookmarkManager::BookmarkManager()
: typeAndSearch(false)
, bookmarkMenu(0)
+ , m_toolBar(0)
, bookmarkModel(new BookmarkModel)
+ , bookmarkFilterModel(0)
+ , typeAndSearchModel(0)
, bookmarkWidget(new BookmarkWidget)
, bookmarkTreeView(new BookmarkTreeView)
, bookmarkManagerWidget(0)
@@ -186,11 +197,18 @@ BookmarkManager::BookmarkManager()
connect(&HelpEngineWrapper::instance(), SIGNAL(setupFinished()), this,
SLOT(setupFinished()));
connect(bookmarkModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this,
- SLOT(refeshBookmarkMenu()));
+ SLOT(refreshBookmarkMenu()));
+ connect(bookmarkModel, SIGNAL(rowsInserted(QModelIndex, int, int)), this,
+ SLOT(refreshBookmarkMenu()));
+ connect(bookmarkModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
+ SLOT(refreshBookmarkMenu()));
+
+ connect(bookmarkModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this,
+ SLOT(refreshBookmarkToolBar()));
connect(bookmarkModel, SIGNAL(rowsInserted(QModelIndex, int, int)), this,
- SLOT(refeshBookmarkMenu()));
+ SLOT(refreshBookmarkToolBar()));
connect(bookmarkModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
- SLOT(refeshBookmarkMenu()));
+ SLOT(refreshBookmarkToolBar()));
}
BookmarkManager::~BookmarkManager()
@@ -310,17 +328,20 @@ void BookmarkManager::setupFinished()
bookmarkModel->setBookmarks(HelpEngineWrapper::instance().bookmarks());
bookmarkModel->expandFoldersIfNeeeded(bookmarkTreeView);
- refeshBookmarkMenu();
+ refreshBookmarkMenu();
+ refreshBookmarkToolBar();
bookmarkTreeView->hideColumn(1);
bookmarkTreeView->header()->setVisible(false);
bookmarkTreeView->header()->setStretchLastSection(true);
- bookmarkFilterModel = new BookmarkFilterModel(this);
+ if (!bookmarkFilterModel)
+ bookmarkFilterModel = new BookmarkFilterModel(this);
bookmarkFilterModel->setSourceModel(bookmarkModel);
bookmarkFilterModel->filterBookmarkFolders();
- typeAndSearchModel = new QSortFilterProxyModel(this);
+ if (!typeAndSearchModel)
+ typeAndSearchModel = new QSortFilterProxyModel(this);
typeAndSearchModel->setDynamicSortFilter(true);
typeAndSearchModel->setSourceModel(bookmarkFilterModel);
}
@@ -354,7 +375,7 @@ void BookmarkManager::manageBookmarks()
bookmarkManagerWidget->raise();
}
-void BookmarkManager::refeshBookmarkMenu()
+void BookmarkManager::refreshBookmarkMenu()
{
TRACE_OBJ
if (!bookmarkMenu)
@@ -365,11 +386,16 @@ void BookmarkManager::refeshBookmarkMenu()
bookmarkMenu->addAction(tr("Manage Bookmarks..."), this,
SLOT(manageBookmarks()));
bookmarkMenu->addAction(QIcon::fromTheme("bookmark-new"),
- tr("Add Bookmark..."), this, SLOT(addBookmark()),
- QKeySequence(tr("Ctrl+D")));
+ tr("Add Bookmark..."), this, SLOT(addBookmark()), QKeySequence(tr("Ctrl+D")));
+
bookmarkMenu->addSeparator();
- const QModelIndex &root = bookmarkModel->index(0, 0, QModelIndex());
+ QModelIndex root = bookmarkModel->index(0, 0, QModelIndex()).parent();
+ buildBookmarksMenu(bookmarkModel->index(0, 0, root), bookmarkMenu);
+
+ bookmarkMenu->addSeparator();
+
+ root = bookmarkModel->index(1, 0, QModelIndex());
for (int i = 0; i < bookmarkModel->rowCount(root); ++i)
buildBookmarksMenu(bookmarkModel->index(i, 0, root), bookmarkMenu);
@@ -377,6 +403,41 @@ void BookmarkManager::refeshBookmarkMenu()
SLOT(setSourceFromAction(QAction*)));
}
+void BookmarkManager::refreshBookmarkToolBar()
+{
+ TRACE_OBJ
+ if (!m_toolBar)
+ return;
+
+ m_toolBar->clear();
+ m_toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+
+ const QModelIndex &root = bookmarkModel->index(0, 0, QModelIndex());
+ for (int i = 0; i < bookmarkModel->rowCount(root); ++i) {
+ const QModelIndex &index = bookmarkModel->index(i, 0, root);
+ if (index.data(UserRoleFolder).toBool()) {
+ QToolButton *button = new QToolButton(m_toolBar);
+ button->setPopupMode(QToolButton::InstantPopup);
+ button->setText(index.data().toString());
+ QMenu *menu = new QMenu(button);
+ for (int j = 0; j < bookmarkModel->rowCount(index); ++j)
+ buildBookmarksMenu(bookmarkModel->index(j, 0, index), menu);
+ connect(menu, SIGNAL(triggered(QAction*)), this,
+ SLOT(setSourceFromAction(QAction*)));
+ button->setMenu(menu);
+ button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ button->setIcon(qvariant_cast<QIcon>(index.data(Qt::DecorationRole)));
+ QAction *a = m_toolBar->addWidget(button);
+ a->setText(index.data().toString());
+ } else {
+ QAction *action = m_toolBar->addAction(
+ qvariant_cast<QIcon>(index.data(Qt::DecorationRole)),
+ index.data().toString(), this, SLOT(setSourceFromAction()));
+ action->setData(index.data(UserRoleUrl).toString());
+ }
+ }
+}
+
void BookmarkManager::renameBookmark(const QModelIndex &index)
{
// check if we should rename the "Bookmarks Menu", bail
@@ -388,13 +449,21 @@ void BookmarkManager::renameBookmark(const QModelIndex &index)
bookmarkModel->setItemsEditable(false);
}
-void BookmarkManager::setSourceFromAction(QAction *action)
+
+void BookmarkManager::setSourceFromAction()
{
TRACE_OBJ
- const QVariant &data = action->data();
+ setSourceFromAction(qobject_cast<QAction*> (sender()));
+}
- if (data.canConvert<QUrl>())
- emit setSource(data.toUrl());
+void BookmarkManager::setSourceFromAction(QAction *action)
+{
+ TRACE_OBJ
+ if (action) {
+ const QVariant &data = action->data();
+ if (data.canConvert<QUrl>())
+ emit setSource(data.toUrl());
+ }
}
void BookmarkManager::setSourceFromIndex(const QModelIndex &index, bool newTab)
diff --git a/tools/assistant/tools/assistant/bookmarkmanager.h b/tools/assistant/tools/assistant/bookmarkmanager.h
index c26dad8..ae27b59 100644
--- a/tools/assistant/tools/assistant/bookmarkmanager.h
+++ b/tools/assistant/tools/assistant/bookmarkmanager.h
@@ -53,6 +53,7 @@ class BookmarkModel;
class BookmarkFilterModel;
class QKeyEvent;
class QSortFilterProxyModel;
+class QToolBar;
class BookmarkManager : public QObject
{
@@ -67,7 +68,8 @@ public:
static void destroy();
QWidget* bookmarkDockWidget() const;
- void takeBookmarksMenu(QMenu* menu);
+ void setBookmarksMenu(QMenu* menu);
+ void setBookmarksToolbar(QToolBar *toolBar);
public slots:
void addBookmark(const QString &title, const QString &url);
@@ -92,9 +94,11 @@ private slots:
void addBookmark();
void removeBookmark();
void manageBookmarks();
- void refeshBookmarkMenu();
+ void refreshBookmarkMenu();
+ void refreshBookmarkToolBar();
void renameBookmark(const QModelIndex &index);
+ void setSourceFromAction();
void setSourceFromAction(QAction *action);
void setSourceFromIndex(const QModelIndex &index, bool newTab = false);
@@ -110,6 +114,7 @@ private:
static BookmarkManager *bookmarkManager;
QMenu *bookmarkMenu;
+ QToolBar *m_toolBar;
BookmarkModel *bookmarkModel;
BookmarkFilterModel *bookmarkFilterModel;
diff --git a/tools/assistant/tools/assistant/bookmarkmanagerwidget.h b/tools/assistant/tools/assistant/bookmarkmanagerwidget.h
index 94384a6..56433cb 100644
--- a/tools/assistant/tools/assistant/bookmarkmanagerwidget.h
+++ b/tools/assistant/tools/assistant/bookmarkmanagerwidget.h
@@ -57,7 +57,8 @@ class BookmarkManagerWidget : public QWidget
{
Q_OBJECT
public:
- BookmarkManagerWidget(BookmarkModel *bookmarkModel, QWidget *parent = 0);
+ explicit BookmarkManagerWidget(BookmarkModel *bookmarkModel,
+ QWidget *parent = 0);
~BookmarkManagerWidget();
protected:
@@ -99,4 +100,4 @@ private:
QT_END_NAMESPACE
-#endif // BOOKMARKMANAGERWIDGET_H \ No newline at end of file
+#endif // BOOKMARKMANAGERWIDGET_H
diff --git a/tools/assistant/tools/assistant/bookmarkmodel.cpp b/tools/assistant/tools/assistant/bookmarkmodel.cpp
index 4c30b42..320b233 100644
--- a/tools/assistant/tools/assistant/bookmarkmodel.cpp
+++ b/tools/assistant/tools/assistant/bookmarkmodel.cpp
@@ -48,6 +48,7 @@
#include <QtGui/QStyle>
#include <QtGui/QTreeView>
+const quint32 VERSION = 0xe53798;
const QLatin1String MIMETYPE("application/bookmarks.assistant");
BookmarkModel::BookmarkModel()
@@ -68,8 +69,9 @@ BookmarkModel::bookmarks() const
{
QByteArray ba;
QDataStream stream(&ba, QIODevice::WriteOnly);
+ stream << qint32(VERSION);
- const QModelIndex &root = index(0,0, QModelIndex());
+ const QModelIndex &root = index(0,0, QModelIndex()).parent();
for (int i = 0; i < rowCount(root); ++i)
collectItems(index(i, 0, root), 0, &stream);
@@ -87,24 +89,35 @@ BookmarkModel::setBookmarks(const QByteArray &bookmarks)
rootItem = new BookmarkItem(DataVector() << tr("Name") << tr("Address")
<< true);
- BookmarkItem* item = new BookmarkItem(DataVector() << tr("Bookmarks Menu")
- << QLatin1String("Folder") << true);
- rootItem->addChild(item);
QStack<BookmarkItem*> parents;
- parents.push(item);
+ QDataStream stream(bookmarks);
+
+ qint32 version;
+ stream >> version;
+ if (version < VERSION) {
+ stream.device()->seek(0);
+ BookmarkItem* toolbar = new BookmarkItem(DataVector() << tr("Toolbar Menu")
+ << QLatin1String("Folder") << true);
+ rootItem->addChild(toolbar);
+
+ BookmarkItem* menu = new BookmarkItem(DataVector() << tr("Bookmarks Menu")
+ << QLatin1String("Folder") << true);
+ rootItem->addChild(menu);
+ parents.push(menu);
+ } else {
+ parents.push(rootItem);
+ }
qint32 depth;
bool expanded;
QString name, url;
- QDataStream stream(bookmarks);
while (!stream.atEnd()) {
stream >> depth >> name >> url >> expanded;
-
while ((parents.count() - 1) != depth)
parents.pop();
- item = new BookmarkItem(DataVector() << name << url << expanded);
+ BookmarkItem *item = new BookmarkItem(DataVector() << name << url << expanded);
if (url == QLatin1String("Folder")) {
parents.top()->addChild(item);
parents.push(item);
@@ -114,11 +127,7 @@ BookmarkModel::setBookmarks(const QByteArray &bookmarks)
}
cache.clear();
- const QModelIndex &root = index(0,0, QModelIndex());
-
- setupCache(root);
- cache.insert(static_cast<BookmarkItem*> (root.internalPointer()), root);
-
+ setupCache(index(0,0, QModelIndex().parent()));
endResetModel();
}
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp
index b6fa159..a232383 100644
--- a/tools/assistant/tools/assistant/centralwidget.cpp
+++ b/tools/assistant/tools/assistant/centralwidget.cpp
@@ -44,12 +44,14 @@
#include "findwidget.h"
#include "helpenginewrapper.h"
#include "helpviewer.h"
+#include "openpagesmanager.h"
#include "tracer.h"
#include "../shared/collectionconfiguration.h"
#include <QtCore/QTimer>
#include <QtGui/QKeyEvent>
+#include <QtGui/QMenu>
#include <QtGui/QPageSetupDialog>
#include <QtGui/QPrintDialog>
#include <QtGui/QPrintPreviewDialog>
@@ -66,6 +68,124 @@ namespace {
CentralWidget *staticCentralWidget = 0;
}
+// -- TabBar
+
+TabBar::TabBar(QWidget *parent)
+ : QTabBar(parent)
+{
+ TRACE_OBJ
+#ifdef Q_OS_MAC
+ setDocumentMode(true);
+#endif
+ setMovable(true);
+ setShape(QTabBar::RoundedNorth);
+ setContextMenuPolicy(Qt::CustomContextMenu);
+ setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred,
+ QSizePolicy::TabWidget));
+ connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int)));
+ connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(slotTabCloseRequested(int)));
+ connect(this, SIGNAL(customContextMenuRequested(QPoint)), this,
+ SLOT(slotCustomContextMenuRequested(QPoint)));
+}
+
+TabBar::~TabBar()
+{
+ TRACE_OBJ
+}
+
+int TabBar::addNewTab(const QString &title)
+{
+ TRACE_OBJ
+ const int index = addTab(title);
+ setTabsClosable(count() > 1);
+ return index;
+}
+
+void TabBar::setCurrent(HelpViewer *viewer)
+{
+ TRACE_OBJ
+ for (int i = 0; i < count(); ++i) {
+ HelpViewer *data = tabData(i).value<HelpViewer*>();
+ if (data == viewer) {
+ setCurrentIndex(i);
+ break;
+ }
+ }
+}
+
+void TabBar::removeTabAt(HelpViewer *viewer)
+{
+ TRACE_OBJ
+ for (int i = 0; i < count(); ++i) {
+ HelpViewer *data = tabData(i).value<HelpViewer*>();
+ if (data == viewer) {
+ removeTab(i);
+ break;
+ }
+ }
+ setTabsClosable(count() > 1);
+}
+
+void TabBar::titleChanged()
+{
+ TRACE_OBJ
+ for (int i = 0; i < count(); ++i) {
+ HelpViewer *data = tabData(i).value<HelpViewer*>();
+ QString title = data->title();
+ title.replace(QLatin1Char('&'), QLatin1String("&&"));
+ setTabText(i, title.isEmpty() ? tr("(Untitled)") : title);
+ }
+}
+
+void TabBar::slotCurrentChanged(int index)
+{
+ TRACE_OBJ
+ emit currentTabChanged(tabData(index).value<HelpViewer*>());
+}
+
+void TabBar::slotTabCloseRequested(int index)
+{
+ TRACE_OBJ
+ OpenPagesManager::instance()->closePage(tabData(index).value<HelpViewer*>());
+}
+
+void TabBar::slotCustomContextMenuRequested(const QPoint &pos)
+{
+ TRACE_OBJ
+ const int tab = tabAt(pos);
+ if (tab < 0)
+ return;
+
+ QMenu menu(QLatin1String(""), this);
+ menu.addAction(tr("New &Tab"), OpenPagesManager::instance(), SLOT(createPage()));
+
+ const bool enableAction = count() > 1;
+ QAction *closePage = menu.addAction(tr("&Close Tab"));
+ closePage->setEnabled(enableAction);
+
+ QAction *closePages = menu.addAction(tr("Close Other Tabs"));
+ closePages->setEnabled(enableAction);
+
+ menu.addSeparator();
+
+ HelpViewer *viewer = tabData(tab).value<HelpViewer*>();
+ QAction *newBookmark = menu.addAction(tr("Add Bookmark for this Page..."));
+ const QString &url = viewer->source().toString();
+ if (url.isEmpty() || url == QLatin1String("about:blank"))
+ newBookmark->setEnabled(false);
+
+ QAction *pickedAction = menu.exec(mapToGlobal(pos));
+ if (pickedAction == closePage)
+ slotTabCloseRequested(tab);
+ else if (pickedAction == closePages) {
+ for (int i = count() - 1; i >= 0; --i) {
+ if (i != tab)
+ slotTabCloseRequested(i);
+ }
+ } else if (pickedAction == newBookmark)
+ emit addBookmark(viewer->title(), url);
+}
+
// -- CentralWidget
CentralWidget::CentralWidget(QWidget *parent)
@@ -75,12 +195,16 @@ CentralWidget::CentralWidget(QWidget *parent)
#endif
, m_findWidget(new FindWidget(this))
, m_stackedWidget(new QStackedWidget(this))
+ , m_tabBar(new TabBar(this))
{
TRACE_OBJ
staticCentralWidget = this;
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
vboxLayout->setMargin(0);
+ vboxLayout->setSpacing(0);
+ vboxLayout->addWidget(m_tabBar);
+ m_tabBar->setVisible(HelpEngineWrapper::instance().showTabs());
vboxLayout->addWidget(m_stackedWidget);
vboxLayout->addWidget(m_findWidget);
m_findWidget->hide();
@@ -90,6 +214,8 @@ CentralWidget::CentralWidget(QWidget *parent)
connect(m_findWidget, SIGNAL(find(QString, bool, bool)), this,
SLOT(find(QString, bool, bool)));
connect(m_findWidget, SIGNAL(escapePressed()), this, SLOT(activateTab()));
+ connect(m_tabBar, SIGNAL(addBookmark(QString, QString)), this,
+ SIGNAL(addBookmark(QString, QString)));
}
CentralWidget::~CentralWidget()
@@ -170,7 +296,11 @@ void CentralWidget::addPage(HelpViewer *page, bool fromSearch)
page->installEventFilter(this);
page->setFocus(Qt::OtherFocusReason);
connectSignals(page);
- m_stackedWidget->addWidget(page);
+ const int index = m_stackedWidget->addWidget(page);
+ m_tabBar->setTabData(m_tabBar->addNewTab(page->title()),
+ QVariant::fromValue(viewerAt(index)));
+ connect (page, SIGNAL(titleChanged()), m_tabBar, SLOT(titleChanged()));
+
if (fromSearch) {
connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this,
SLOT(highlightSearchTerms()));
@@ -181,6 +311,7 @@ void CentralWidget::removePage(int index)
{
TRACE_OBJ
const bool currentChanged = index == currentIndex();
+ m_tabBar->removeTabAt(viewerAt(index));
m_stackedWidget->removeWidget(m_stackedWidget->widget(index));
if (currentChanged)
emit currentViewerChanged();
@@ -195,10 +326,18 @@ int CentralWidget::currentIndex() const
void CentralWidget::setCurrentPage(HelpViewer *page)
{
TRACE_OBJ
+ m_tabBar->setCurrent(page);
m_stackedWidget->setCurrentWidget(page);
emit currentViewerChanged();
}
+void CentralWidget::connectTabBar()
+{
+ TRACE_OBJ
+ connect(m_tabBar, SIGNAL(currentTabChanged(HelpViewer*)),
+ OpenPagesManager::instance(), SLOT(setCurrentPage(HelpViewer*)));
+}
+
// -- public slots
void CentralWidget::copy()
@@ -367,6 +506,11 @@ void CentralWidget::updateBrowserFont()
viewerAt(i)->setViewerFont(font);
}
+void CentralWidget::updateUserInterface()
+{
+ m_tabBar->setVisible(HelpEngineWrapper::instance().showTabs());
+}
+
// -- protected
void CentralWidget::keyPressEvent(QKeyEvent *e)
@@ -415,7 +559,7 @@ void CentralWidget::highlightSearchTerms()
case QHelpSearchQuery::DEFAULT:
case QHelpSearchQuery::ATLEAST:
foreach (QString term, query.wordList)
- terms.append(term.remove(QLatin1String("\"")));
+ terms.append(term.remove(QLatin1Char('"')));
}
}
}
diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h
index 69e334a..bcadcf4 100644
--- a/tools/assistant/tools/assistant/centralwidget.h
+++ b/tools/assistant/tools/assistant/centralwidget.h
@@ -43,6 +43,8 @@
#define CENTRALWIDGET_H
#include <QtCore/QUrl>
+
+#include <QtGui/QTabBar>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
@@ -51,6 +53,30 @@ class FindWidget;
class HelpViewer;
class QStackedWidget;
+class TabBar : public QTabBar
+{
+ Q_OBJECT
+public:
+ TabBar(QWidget *parent = 0);
+ ~TabBar();
+
+ int addNewTab(const QString &title);
+ void setCurrent(HelpViewer *viewer);
+ void removeTabAt(HelpViewer *viewer);
+
+public slots:
+ void titleChanged();
+
+signals:
+ void currentTabChanged(HelpViewer *viewer);
+ void addBookmark(const QString &title, const QString &url);
+
+private slots:
+ void slotCurrentChanged(int index);
+ void slotTabCloseRequested(int index);
+ void slotCustomContextMenuRequested(const QPoint &pos);
+};
+
class CentralWidget : public QWidget
{
Q_OBJECT
@@ -77,6 +103,8 @@ public:
int currentIndex() const;
void setCurrentPage(HelpViewer *page);
+ void connectTabBar();
+
public slots:
void copy();
void home();
@@ -105,6 +133,7 @@ public slots:
void activateTab();
void showTextSearch();
void updateBrowserFont();
+ void updateUserInterface();
signals:
void currentViewerChanged();
@@ -135,6 +164,7 @@ private:
#endif
FindWidget *m_findWidget;
QStackedWidget *m_stackedWidget;
+ TabBar *m_tabBar;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/cmdlineparser.cpp b/tools/assistant/tools/assistant/cmdlineparser.cpp
index b6c0beb..1cf2915 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.cpp
+++ b/tools/assistant/tools/assistant/cmdlineparser.cpp
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
-const QString CmdLineParser::m_helpMessage = QLatin1String(
+static const char helpMessage[] = QT_TRANSLATE_NOOP("CmdLineParser",
"Usage: assistant [Options]\n\n"
"-collectionFile file Uses the specified collection\n"
" file instead of the default one\n"
@@ -138,10 +138,10 @@ CmdLineParser::Result CmdLineParser::parse()
}
if (!m_error.isEmpty()) {
- showMessage(m_error + QLatin1String("\n\n\n") + m_helpMessage, true);
+ showMessage(m_error + QLatin1String("\n\n\n") + tr(helpMessage), true);
return Error;
} else if (showHelp) {
- showMessage(m_helpMessage, false);
+ showMessage(tr(helpMessage), false);
return Help;
}
return Ok;
diff --git a/tools/assistant/tools/assistant/cmdlineparser.h b/tools/assistant/tools/assistant/cmdlineparser.h
index 5573081..db66494 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.h
+++ b/tools/assistant/tools/assistant/cmdlineparser.h
@@ -93,7 +93,6 @@ private:
QStringList m_arguments;
int m_pos;
- static const QString m_helpMessage;
QString m_collectionFile;
QString m_cloneFile;
QString m_helpFile;
diff --git a/tools/assistant/tools/assistant/globalactions.cpp b/tools/assistant/tools/assistant/globalactions.cpp
index a9cc392..0eeab21 100644
--- a/tools/assistant/tools/assistant/globalactions.cpp
+++ b/tools/assistant/tools/assistant/globalactions.cpp
@@ -42,9 +42,15 @@
#include "globalactions.h"
#include "centralwidget.h"
+#include "helpviewer.h"
#include "tracer.h"
#include <QtGui/QAction>
+#include <QtGui/QMenu>
+
+#if !defined(QT_NO_WEBKIT)
+#include <QtWebKit/QWebHistory>
+#endif
GlobalActions *GlobalActions::instance(QObject *parent)
{
@@ -82,6 +88,8 @@ GlobalActions::GlobalActions(QObject *parent) : QObject(parent)
connect(m_nextAction, SIGNAL(triggered()), centralWidget, SLOT(forward()));
m_actionList << m_nextAction;
+ setupNavigationMenus(m_backAction, m_nextAction, centralWidget);
+
m_homeAction = new QAction(tr("&Home"), parent);
m_homeAction->setShortcut(tr("ALT+Home"));
m_homeAction->setIcon(QIcon(resourcePath + QLatin1String("/home.png")));
@@ -160,4 +168,79 @@ void GlobalActions::setCopyAvailable(bool available)
m_copyAction->setEnabled(available);
}
+#if !defined(QT_NO_WEBKIT)
+
+void GlobalActions::slotAboutToShowBackMenu()
+{
+ TRACE_OBJ
+ m_backMenu->clear();
+ if (QWebHistory *history = CentralWidget::instance()->currentHelpViewer()->history()) {
+ const int currentItemIndex = history->currentItemIndex();
+ QList<QWebHistoryItem> items = history->backItems(history->count());
+ for (int i = items.count() - 1; i >= 0; --i) {
+ QAction *action = new QAction(this);
+ action->setText(items.at(i).title());
+ action->setData(-1 * (currentItemIndex - i));
+ m_backMenu->addAction(action);
+ }
+ }
+}
+
+void GlobalActions::slotAboutToShowNextMenu()
+{
+ TRACE_OBJ
+ m_nextMenu->clear();
+ if (QWebHistory *history = CentralWidget::instance()->currentHelpViewer()->history()) {
+ const int count = history->count();
+ QList<QWebHistoryItem> items = history->forwardItems(count);
+ for (int i = 0; i < items.count(); ++i) {
+ QAction *action = new QAction(this);
+ action->setData(count - i);
+ action->setText(items.at(i).title());
+ m_nextMenu->addAction(action);
+ }
+ }
+}
+
+void GlobalActions::slotOpenActionUrl(QAction *action)
+{
+ TRACE_OBJ
+ if (HelpViewer* viewer = CentralWidget::instance()->currentHelpViewer()) {
+ const int offset = action->data().toInt();
+ QWebHistory *history = viewer->history();
+ if (offset > 0) {
+ history->goToItem(history->forwardItems(history->count()
+ - offset + 1).back()); // forward
+ } else if (offset < 0) {
+ history->goToItem(history->backItems(-1 * offset).first()); // back
+ }
+ }
+}
+
+#endif
+
+void GlobalActions::setupNavigationMenus(QAction *back, QAction *next,
+ QWidget *parent)
+{
+#if !defined(QT_NO_WEBKIT)
+ m_backMenu = new QMenu(parent);
+ connect(m_backMenu, SIGNAL(aboutToShow()), this,
+ SLOT(slotAboutToShowBackMenu()));
+ connect(m_backMenu, SIGNAL(triggered(QAction*)), this,
+ SLOT(slotOpenActionUrl(QAction*)));
+ back->setMenu(m_backMenu);
+
+ m_nextMenu = new QMenu(parent);
+ connect(m_nextMenu, SIGNAL(aboutToShow()), this,
+ SLOT(slotAboutToShowNextMenu()));
+ connect(m_nextMenu, SIGNAL(triggered(QAction*)), this,
+ SLOT(slotOpenActionUrl(QAction*)));
+ next->setMenu(m_nextMenu);
+#else
+ Q_UNUSED(back)
+ Q_UNUSED(next)
+ Q_UNUSED(parent)
+#endif
+}
+
GlobalActions *GlobalActions::m_instance = 0;
diff --git a/tools/assistant/tools/assistant/globalactions.h b/tools/assistant/tools/assistant/globalactions.h
index e53e08f..ca8d7eb 100644
--- a/tools/assistant/tools/assistant/globalactions.h
+++ b/tools/assistant/tools/assistant/globalactions.h
@@ -48,6 +48,7 @@
QT_BEGIN_NAMESPACE
class QAction;
+class QMenu;
class GlobalActions : public QObject
{
@@ -69,6 +70,16 @@ public:
Q_SLOT void updateActions();
Q_SLOT void setCopyAvailable(bool available);
+#if !defined(QT_NO_WEBKIT)
+private slots:
+ void slotAboutToShowBackMenu();
+ void slotAboutToShowNextMenu();
+ void slotOpenActionUrl(QAction *action);
+#endif
+
+private:
+ void setupNavigationMenus(QAction *back, QAction *next, QWidget *parent);
+
private:
GlobalActions(QObject *parent);
@@ -84,6 +95,9 @@ private:
QAction *m_findAction;
QList<QAction *> m_actionList;
+
+ QMenu *m_backMenu;
+ QMenu *m_nextMenu;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp
index 0a5445a..ba54dd6 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.cpp
+++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp
@@ -72,6 +72,7 @@ namespace {
const QString UseBrowserFontKey(QLatin1String("useBrowserFont"));
const QString VersionKey(QString(QLatin1String("qtVersion%1$$$%2")).
arg(QLatin1String(QT_VERSION_STR)));
+ const QString ShowTabsKey(QLatin1String("showTabs"));
} // anonymous namespace
class TimeoutForwarder : public QObject
@@ -114,7 +115,7 @@ private:
QMap<QString, RecentSignal> m_recentQchUpdates;
};
-const QString HelpEngineWrapper::TrUnfiltered = tr("Unfiltered");
+const QString HelpEngineWrapper::TrUnfiltered = HelpEngineWrapper::tr("Unfiltered");
HelpEngineWrapper *HelpEngineWrapper::helpEngineWrapper = 0;
@@ -147,7 +148,7 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile)
* because we will start to index them, only to be interupted
* by the next request. Also, there is a nasty SQLITE bug that will
* cause the application to hang for minutes in that case.
- * This call is reverted by initalDocSetupDone(), which must be
+ * This call is reverted by initialDocSetupDone(), which must be
* called after the new docs have been installed.
*/
disconnect(d->m_helpEngine, SIGNAL(setupFinished()),
@@ -692,11 +693,31 @@ void HelpEngineWrapper::setBrowserWritingSystem(QFontDatabase::WritingSystem sys
void HelpEngineWrapper::handleCurrentFilterChanged(const QString &filter)
{
+ TRACE_OBJ
const QString &filterToReport
= filter == Unfiltered ? TrUnfiltered : filter;
emit currentFilterChanged(filterToReport);
}
+bool HelpEngineWrapper::showTabs() const
+{
+ TRACE_OBJ
+ return d->m_helpEngine->customValue(ShowTabsKey, false).toBool();
+}
+
+void HelpEngineWrapper::setShowTabs(bool show)
+{
+ TRACE_OBJ
+ d->m_helpEngine->setCustomValue(ShowTabsKey, show);
+}
+
+bool HelpEngineWrapper::fullTextSearchFallbackEnabled() const
+{
+ TRACE_OBJ
+ return CollectionConfiguration::fullTextSearchFallbackEnabled(*d->m_helpEngine);
+}
+
+// -- TimeoutForwarder
TimeoutForwarder::TimeoutForwarder(const QString &fileName)
: m_fileName(fileName)
@@ -710,6 +731,7 @@ void TimeoutForwarder::forward()
HelpEngineWrapper::instance().d->qchFileChanged(m_fileName, true);
}
+// -- HelpEngineWrapperPrivate
HelpEngineWrapperPrivate::HelpEngineWrapperPrivate(const QString &collectionFile)
: m_helpEngine(new QHelpEngine(collectionFile, this)),
@@ -817,7 +839,6 @@ void HelpEngineWrapperPrivate::qchFileChanged(const QString &fileName,
m_recentQchUpdates.erase(it);
}
-
QT_END_NAMESPACE
#include "helpenginewrapper.moc"
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h
index f1a381a..38bde9b 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.h
+++ b/tools/assistant/tools/assistant/helpenginewrapper.h
@@ -184,8 +184,13 @@ public:
QFontDatabase::WritingSystem browserWritingSystem() const;
void setBrowserWritingSystem(QFontDatabase::WritingSystem system);
+ bool showTabs() const;
+ void setShowTabs(bool show);
+
static const QString TrUnfiltered;
+ bool fullTextSearchFallbackEnabled() const;
+
signals:
// For asynchronous doc updates triggered by external actions.
diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h
index 939096d..e2aefca 100644
--- a/tools/assistant/tools/assistant/helpviewer.h
+++ b/tools/assistant/tools/assistant/helpviewer.h
@@ -153,5 +153,6 @@ private:
};
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(HelpViewer*)
#endif // HELPVIEWER_H
diff --git a/tools/assistant/tools/assistant/installdialog.h b/tools/assistant/tools/assistant/installdialog.h
index 2f19519..afafc63 100644
--- a/tools/assistant/tools/assistant/installdialog.h
+++ b/tools/assistant/tools/assistant/installdialog.h
@@ -61,7 +61,7 @@ class InstallDialog : public QDialog
Q_OBJECT
public:
- InstallDialog(QHelpEngineCore *helpEngine, QWidget *parent = 0,
+ explicit InstallDialog(QHelpEngineCore *helpEngine, QWidget *parent = 0,
const QString &host = QString(), int port = -1);
~InstallDialog();
diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp
index 51ea9f9..bb86bfe 100644
--- a/tools/assistant/tools/assistant/main.cpp
+++ b/tools/assistant/tools/assistant/main.cpp
@@ -316,6 +316,7 @@ int main(int argc, char *argv[])
TRACE_OBJ
QApplication a(argc, argv, useGui(argc, argv));
a.addLibraryPath(a.applicationDirPath() + QLatin1String("/plugins"));
+ setupTranslations();
// Parse arguments.
CmdLineParser cmd(a.arguments());
@@ -355,7 +356,7 @@ int main(int argc, char *argv[])
QHelpEngineCore cachedCollection(cachedCollectionFile);
if (!cachedCollection.setupData()) {
cmd.showMessage(QCoreApplication::translate("Assistant",
- "Error reading collection file '%1': %2").
+ "Error reading collection file '%1': %2.").
arg(cachedCollectionFile).
arg(cachedCollection.error()), true);
return EXIT_FAILURE;
@@ -419,8 +420,6 @@ int main(int argc, char *argv[])
cachedCollection.setCurrentFilter(cmd.currentFilter());
}
- setupTranslations();
-
/*
* We need to be careful here: The main window has to be deleted before
* the help engine wrapper, which has to be deleted before the
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index e436201..537f867 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -117,6 +117,14 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
}
HelpEngineWrapper &helpEngineWrapper =
HelpEngineWrapper::instance(collectionFile);
+ BookmarkManager *bookMarkManager = BookmarkManager::instance();
+
+ if (!initHelpDB()) {
+ qDebug("Fatal error: Help engine initialization failed. "
+ "Error message was: %s\nAssistant will now exit.",
+ qPrintable(HelpEngineWrapper::instance().error()));
+ std::exit(1);
+ }
m_centralWidget = new CentralWidget(this);
setCentralWidget(m_centralWidget);
@@ -141,7 +149,6 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
searchDock->setWidget(m_searchWindow);
addDockWidget(Qt::LeftDockWidgetArea, searchDock);
- BookmarkManager *bookMarkManager = BookmarkManager::instance();
QDockWidget *bookmarkDock = new QDockWidget(tr("Bookmarks"), this);
bookmarkDock->setObjectName(QLatin1String("BookmarkWindow"));
bookmarkDock->setWidget(m_bookmarkWidget
@@ -155,33 +162,25 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
openPagesDock->setWidget(openPagesManager->openPagesWidget());
addDockWidget(Qt::LeftDockWidgetArea, openPagesDock);
-#if 0
+ connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)),
+ bookMarkManager, SLOT(addBookmark(QString, QString)));
connect(bookMarkManager, SIGNAL(escapePressed()), this,
SLOT(activateCurrentCentralWidgetTab()));
connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget,
SLOT(setSource(QUrl)));
connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)),
openPagesManager, SLOT(createPage(QUrl)));
- connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)),
- bookMarkManager, SLOT(addBookmark(QString, QString)));
QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine();
connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted()));
connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished()));
-#endif
QString defWindowTitle = tr("Qt Assistant");
setWindowTitle(defWindowTitle);
setupActions();
statusBar()->show();
-
- if (!initHelpDB()) {
- qDebug("Fatal error: Help engine initialization failed. "
- "Error message was: %s\nAssistant will now exit.",
- qPrintable(HelpEngineWrapper::instance().error()));
- std::exit(1);
- }
+ m_centralWidget->connectTabBar();
setupFilterToolbar();
setupAddressToolbar();
@@ -199,9 +198,16 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
qApp->setWindowIcon(appIcon);
}
+ QToolBar *toolBar = addToolBar(tr("Bookmark Toolbar"));
+ bookMarkManager->setBookmarksToolbar(toolBar);
+
// Show the widget here, otherwise the restore geometry and state won't work
// on x11.
show();
+
+ toolBar->hide();
+ toolBarMenu()->addAction(toolBar->toggleViewAction());
+
QByteArray ba(helpEngineWrapper.mainWindow());
if (!ba.isEmpty())
restoreState(ba);
@@ -529,7 +535,7 @@ void MainWindow::setupActions()
connect(sct, SIGNAL(activated()), openPages, SLOT(previousPageWithSwitcher()));
#endif
- BookmarkManager::instance()->takeBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks")));
+ BookmarkManager::instance()->setBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks")));
menu = menuBar()->addMenu(tr("&Help"));
m_aboutAction = menu->addAction(tr("About..."), this, SLOT(showAboutDialog()));
@@ -736,6 +742,8 @@ void MainWindow::showPreferences()
SLOT(updateApplicationFont()));
connect(&dia, SIGNAL(updateBrowserFont()), m_centralWidget,
SLOT(updateBrowserFont()));
+ connect(&dia, SIGNAL(updateUserInterface()), m_centralWidget,
+ SLOT(updateUserInterface()));
dia.showDialog();
}
@@ -791,7 +799,7 @@ void MainWindow::showAboutDialog()
aboutDia.setWindowTitle(aboutDia.documentTitle());
} else {
QByteArray resources;
- aboutDia.setText(QString::fromLatin1("<center>"
+ aboutDia.setText(tr("<center>"
"<h3>%1</h3>"
"<p>Version %2</p></center>"
"<p>Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).</p>")
diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h
index 7eb44e9..ea4ebd6 100644
--- a/tools/assistant/tools/assistant/mainwindow.h
+++ b/tools/assistant/tools/assistant/mainwindow.h
@@ -69,7 +69,7 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
- MainWindow(CmdLineParser *cmdLine, QWidget *parent = 0);
+ explicit MainWindow(CmdLineParser *cmdLine, QWidget *parent = 0);
~MainWindow();
static void activateCurrentBrowser();
diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp
index 6b08c46..3b69b50 100644
--- a/tools/assistant/tools/assistant/openpagesmanager.cpp
+++ b/tools/assistant/tools/assistant/openpagesmanager.cpp
@@ -209,6 +209,17 @@ HelpViewer *OpenPagesManager::createNewPageFromSearch(const QUrl &url)
return createPage(url, true);
}
+void OpenPagesManager::closePage(HelpViewer *viewer)
+{
+ TRACE_OBJ
+ for (int i = 0; i < m_model->rowCount(); ++i) {
+ if (m_model->pageAt(i) == viewer) {
+ removePage(i);
+ break;
+ }
+ }
+}
+
void OpenPagesManager::closePage(const QModelIndex &index)
{
TRACE_OBJ
@@ -264,7 +275,13 @@ void OpenPagesManager::setCurrentPage(const QModelIndex &index)
void OpenPagesManager::setCurrentPage(int index)
{
TRACE_OBJ
- CentralWidget::instance()->setCurrentPage(m_model->pageAt(index));
+ setCurrentPage(m_model->pageAt(index));
+}
+
+void OpenPagesManager::setCurrentPage(HelpViewer *page)
+{
+ TRACE_OBJ
+ CentralWidget::instance()->setCurrentPage(page);
m_openPagesWidget->selectCurrentPage();
}
diff --git a/tools/assistant/tools/assistant/openpagesmanager.h b/tools/assistant/tools/assistant/openpagesmanager.h
index 56a1ce7..5837392 100644
--- a/tools/assistant/tools/assistant/openpagesmanager.h
+++ b/tools/assistant/tools/assistant/openpagesmanager.h
@@ -83,6 +83,9 @@ public slots:
void previousPage();
void previousPageWithSwitcher();
+ void closePage(HelpViewer *page);
+ void setCurrentPage(HelpViewer *page);
+
private slots:
void setCurrentPage(const QModelIndex &index);
void closePage(const QModelIndex &index);
diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp
index 40a449e..495dad9 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.cpp
+++ b/tools/assistant/tools/assistant/preferencesdialog.cpp
@@ -379,6 +379,10 @@ void PreferencesDialog::applyChanges()
if (filtersWereChanged || !m_regDocs.isEmpty() || !m_unregDocs.isEmpty())
helpEngine.setupData();
+ helpEngine.setShowTabs(m_ui.showTabs->isChecked());
+ if (m_showTabs != m_ui.showTabs->isChecked())
+ emit updateUserInterface();
+
accept();
}
@@ -470,6 +474,9 @@ void PreferencesDialog::updateOptionsPage()
int option = helpEngine.startOption();
m_ui.helpStartComboBox->setCurrentIndex(option);
+ m_showTabs = helpEngine.showTabs();
+ m_ui.showTabs->setChecked(m_showTabs);
+
connect(m_ui.blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage()));
connect(m_ui.currentPageButton, SIGNAL(clicked()), this, SLOT(setCurrentPage()));
connect(m_ui.defaultPageButton, SIGNAL(clicked()), this, SLOT(setDefaultPage()));
diff --git a/tools/assistant/tools/assistant/preferencesdialog.h b/tools/assistant/tools/assistant/preferencesdialog.h
index 7a17275..22cf8c9 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.h
+++ b/tools/assistant/tools/assistant/preferencesdialog.h
@@ -81,6 +81,7 @@ private slots:
signals:
void updateBrowserFont();
void updateApplicationFont();
+ void updateUserInterface();
private:
void updateFilterPage();
@@ -101,6 +102,7 @@ private:
bool m_appFontChanged;
bool m_browserFontChanged;
HelpEngineWrapper &helpEngine;
+ bool m_showTabs;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/preferencesdialog.ui b/tools/assistant/tools/assistant/preferencesdialog.ui
index 279084d..1c6833a 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.ui
+++ b/tools/assistant/tools/assistant/preferencesdialog.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>375</width>
- <height>266</height>
+ <height>275</height>
</rect>
</property>
<property name="windowTitle">
@@ -187,7 +187,7 @@
<attribute name="title">
<string>Options</string>
</attribute>
- <layout class="QVBoxLayout" name="verticalLayout_2">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
@@ -310,6 +310,22 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>Appearance</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="showTabs">
+ <property name="text">
+ <string>Show tabs for each individual page</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp
index 06e5602..51bc733 100644
--- a/tools/assistant/tools/assistant/remotecontrol.cpp
+++ b/tools/assistant/tools/assistant/remotecontrol.cpp
@@ -58,6 +58,7 @@
#include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpIndexWidget>
+#include <QtHelp/QHelpSearchQueryWidget>
#ifdef Q_OS_WIN
# include "remotecontrol_win.h"
@@ -260,8 +261,25 @@ void RemoteControl::handleActivateKeywordCommand(const QString &arg)
m_activateKeyword = arg;
} else {
m_mainWindow->setIndexString(arg);
- if (!arg.isEmpty())
- helpEngine.indexWidget()->activateCurrentItem();
+ if (!arg.isEmpty()) {
+ if (!helpEngine.indexWidget()->currentIndex().isValid()
+ && helpEngine.fullTextSearchFallbackEnabled()) {
+ if (QHelpSearchEngine *se = helpEngine.searchEngine()) {
+ m_mainWindow->setSearchVisible(true);
+ if (QHelpSearchQueryWidget *w = se->queryWidget()) {
+ w->collapseExtendedSearch();
+ QList<QHelpSearchQuery> queryList;
+ queryList << QHelpSearchQuery(QHelpSearchQuery::DEFAULT,
+ QStringList(arg));
+ w->setQuery(queryList);
+ se->search(queryList);
+ }
+ }
+ } else {
+ m_mainWindow->setIndexVisible(true);
+ helpEngine.indexWidget()->activateCurrentItem();
+ }
+ }
}
}
diff --git a/tools/assistant/tools/assistant/searchwidget.cpp b/tools/assistant/tools/assistant/searchwidget.cpp
index 9eb2106..bb5bdeb 100644
--- a/tools/assistant/tools/assistant/searchwidget.cpp
+++ b/tools/assistant/tools/assistant/searchwidget.cpp
@@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE
SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent)
: QWidget(parent)
, zoomCount(0)
- , attached(false)
, searchEngine(engine)
{
TRACE_OBJ
@@ -130,18 +129,6 @@ void SearchWidget::resetZoom()
}
}
-bool SearchWidget::isAttached() const
-{
- TRACE_OBJ
- return attached;
-}
-
-void SearchWidget::setAttached(bool state)
-{
- TRACE_OBJ
- attached = state;
-}
-
void SearchWidget::search() const
{
TRACE_OBJ
diff --git a/tools/assistant/tools/assistant/searchwidget.h b/tools/assistant/tools/assistant/searchwidget.h
index 465e8f6..04d3e28 100644
--- a/tools/assistant/tools/assistant/searchwidget.h
+++ b/tools/assistant/tools/assistant/searchwidget.h
@@ -58,16 +58,13 @@ class SearchWidget : public QWidget
Q_OBJECT
public:
- SearchWidget(QHelpSearchEngine *engine, QWidget *parent = 0);
+ explicit SearchWidget(QHelpSearchEngine *engine, QWidget *parent = 0);
~SearchWidget();
void zoomIn();
void zoomOut();
void resetZoom();
- bool isAttached() const;
- void setAttached(bool state);
-
signals:
void requestShowLink(const QUrl &url);
void requestShowLinkInNewTab(const QUrl &url);
@@ -84,7 +81,6 @@ private:
private:
int zoomCount;
- bool attached;
QHelpSearchEngine *searchEngine;
QHelpSearchResultWidget *resultWidget;
};
diff --git a/tools/assistant/tools/qcollectiongenerator/main.cpp b/tools/assistant/tools/qcollectiongenerator/main.cpp
index b3f6bd9..1046e56 100644
--- a/tools/assistant/tools/qcollectiongenerator/main.cpp
+++ b/tools/assistant/tools/qcollectiongenerator/main.cpp
@@ -49,15 +49,21 @@
#include <QtCore/QDir>
#include <QtCore/QMap>
#include <QtCore/QFileInfo>
-#include <QtCore/QCoreApplication>
#include <QtCore/QDateTime>
#include <QtCore/QBuffer>
+#include <QtCore/QTranslator>
+#include <QtCore/QLocale>
+#include <QtCore/QLibraryInfo>
#include <QtHelp/QHelpEngineCore>
#include <QtXml/QXmlStreamReader>
QT_USE_NAMESPACE
+class QCG {
+ Q_DECLARE_TR_FUNCTIONS(QCollectionGenerator)
+};
+
class CollectionConfigReader : public QXmlStreamReader
{
public:
@@ -91,6 +97,10 @@ public:
QString cacheDirectory() const { return m_cacheDirectory; }
bool cacheDirRelativeToCollection() const { return m_cacheDirRelativeToCollection; }
+ bool fullTextSearchFallbackEnabled() const {
+ return m_enableFullTextSearchFallback;
+ }
+
private:
void raiseErrorWithLine();
void readConfig();
@@ -119,13 +129,12 @@ private:
QStringList m_filesToRegister;
QString m_cacheDirectory;
bool m_cacheDirRelativeToCollection;
+ bool m_enableFullTextSearchFallback;
};
void CollectionConfigReader::raiseErrorWithLine()
{
- raiseError(QCoreApplication::translate("QCollectionGenerator",
- "Unknown token at line %1.")
- .arg(lineNumber()));
+ raiseError(QCG::tr("Unknown token at line %1.").arg(lineNumber()));
}
void CollectionConfigReader::readData(const QByteArray &contents)
@@ -135,6 +144,7 @@ void CollectionConfigReader::readData(const QByteArray &contents)
m_enableAddressBar = true;
m_hideAddressBar = true;
m_enableDocumentationManager = true;
+ m_enableFullTextSearchFallback = false;
addData(contents);
while (!atEnd()) {
@@ -144,9 +154,8 @@ void CollectionConfigReader::readData(const QByteArray &contents)
&& attributes().value(QLatin1String("version")) == QLatin1String("1.0"))
readConfig();
else
- raiseError(QCoreApplication::translate("QCollectionGenerator",
- "Unknown token at line %1. "
- "Expected \"QtHelpCollectionProject\"!")
+ raiseError(QCG::tr("Unknown token at line %1. "
+ "Expected \"QtHelpCollectionProject\".")
.arg(lineNumber()));
}
}
@@ -169,7 +178,7 @@ void CollectionConfigReader::readConfig()
}
}
if (!ok && !hasError())
- raiseError(QLatin1String("Missing end tags."));
+ raiseError(QCG::tr("Missing end tags."));
}
void CollectionConfigReader::readAssistantSettings()
@@ -209,6 +218,9 @@ void CollectionConfigReader::readAssistantSettings()
attributes().value(QLatin1String("base"))
== QLatin1String("collection");
m_cacheDirectory = readElementText();
+ } else if (name() == QLatin1String("enableFullTextSearchFallback")) {
+ if (readElementText() == QLatin1String("true"))
+ m_enableFullTextSearchFallback = true;
} else {
raiseErrorWithLine();
}
@@ -311,7 +323,7 @@ void CollectionConfigReader::readFiles()
}
}
if (input.isEmpty() || output.isEmpty()) {
- raiseError(QLatin1String("Missing input or output file for help file generation!"));
+ raiseError(QCG::tr("Missing input or output file for help file generation."));
return;
}
m_filesToGenerate.insert(input, output);
@@ -350,6 +362,20 @@ int main(int argc, char *argv[])
bool showHelp = false;
bool showVersion = false;
+ QCoreApplication app(argc, argv);
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QTranslator qt_helpTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("assistant_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)
+ && qt_helpTranslator.load(QLatin1String("qt_help_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ app.installTranslator(&qt_helpTranslator);
+ }
+
for (int i=1; i<argc; ++i) {
arg = QString::fromLocal8Bit(argv[i]);
if (arg == QLatin1String("-o")) {
@@ -357,8 +383,7 @@ int main(int argc, char *argv[])
QFileInfo fi(QString::fromLocal8Bit(argv[i]));
collectionFile = fi.absoluteFilePath();
} else {
- error = QCoreApplication::translate("QCollectionGenerator",
- "Missing output file name!");
+ error = QCG::tr("Missing output file name.");
}
} else if (arg == QLatin1String("-h")) {
showHelp = true;
@@ -372,16 +397,15 @@ int main(int argc, char *argv[])
}
if (showVersion) {
- fprintf(stdout, "Qt Collection Generator version 1.0 (Qt %s)\n",
- QT_VERSION_STR);
+ fputs(qPrintable(QCG::tr("Qt Collection Generator version 1.0 (Qt %1)\n")
+ .arg(QT_VERSION_STR)), stdout);
return 0;
}
if (configFile.isEmpty() && !showHelp)
- error = QCoreApplication::translate("QCollectionGenerator",
- "Missing collection config file!");
+ error = QCG::tr("Missing collection config file.");
- QString help = QCoreApplication::translate("QCollectionGenerator", "\nUsage:\n\n"
+ QString help = QCG::tr("\nUsage:\n\n"
"qcollectiongenerator <collection-config-file> [options]\n\n"
" -o <collection-file> Generates a collection file\n"
" called <collection-file>. If\n"
@@ -391,7 +415,7 @@ int main(int argc, char *argv[])
" qcollectiongenerator.\n\n");
if (showHelp) {
- fprintf(stdout, "%s", qPrintable(help));
+ fputs(qPrintable(help), stdout);
return 0;
}else if (!error.isEmpty()) {
fprintf(stderr, "%s\n\n%s", qPrintable(error), qPrintable(help));
@@ -400,7 +424,7 @@ int main(int argc, char *argv[])
QFile file(configFile);
if (!file.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Could not open %s!\n", qPrintable(configFile));
+ fputs(qPrintable(QCG::tr("Could not open %1.\n").arg(configFile)), stderr);
return -1;
}
@@ -410,19 +434,18 @@ int main(int argc, char *argv[])
+ fi.baseName() + QLatin1String(".qhc");
}
- QCoreApplication app(argc, argv);
-
- fprintf(stdout, "Reading collection config file...\n");
+ fputs(qPrintable(QCG::tr("Reading collection config file...\n")), stdout);
CollectionConfigReader config;
config.readData(file.readAll());
if (config.hasError()) {
- fprintf(stderr, "Collection config file error: %s\n", qPrintable(config.errorString()));
+ fputs(qPrintable(QCG::tr("Collection config file error: %1\n")
+ .arg(config.errorString())), stderr);
return -1;
}
QMap<QString, QString>::const_iterator it = config.filesToGenerate().constBegin();
while (it != config.filesToGenerate().constEnd()) {
- fprintf(stdout, "Generating help for %s...\n", qPrintable(it.key()));
+ fputs(qPrintable(QCG::tr("Generating help for %1...\n").arg(it.key())), stdout);
QHelpProjectData helpData;
if (!helpData.readData(absoluteFileName(basePath, it.key()))) {
fprintf(stderr, "%s\n", qPrintable(helpData.errorMessage()));
@@ -437,12 +460,13 @@ int main(int argc, char *argv[])
++it;
}
- fprintf(stdout, "Creating collection file...\n");
+ fputs(qPrintable(QCG::tr("Creating collection file...\n")), stdout);
QFileInfo colFi(collectionFile);
if (colFi.exists()) {
if (!colFi.dir().remove(colFi.fileName())) {
- fprintf(stderr, "The file %s cannot be overwritten!\n", qPrintable(collectionFile));
+ fputs(qPrintable(QCG::tr("The file %1 cannot be overwritten.\n")
+ .arg(collectionFile)), stderr);
return -1;
}
}
@@ -496,11 +520,13 @@ int main(int argc, char *argv[])
!config.hideAddressBar());
CollectionConfiguration::setCreationTime(helpEngine,
QDateTime::currentDateTime().toTime_t());
+ CollectionConfiguration::setFullTextSearchFallbackEnabled(helpEngine,
+ config.fullTextSearchFallbackEnabled());
if (!config.applicationIcon().isEmpty()) {
QFile icon(absoluteFileName(basePath, config.applicationIcon()));
if (!icon.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Cannot open %s!\n", qPrintable(icon.fileName()));
+ fputs(qPrintable(QCG::tr("Cannot open %1.\n").arg(icon.fileName())), stderr);
return -1;
}
CollectionConfiguration::setApplicationIcon(helpEngine, icon.readAll());
@@ -521,7 +547,7 @@ int main(int argc, char *argv[])
if (!config.aboutIcon().isEmpty()) {
QFile icon(absoluteFileName(basePath, config.aboutIcon()));
if (!icon.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Cannot open %s!\n", qPrintable(icon.fileName()));
+ fputs(qPrintable(QCG::tr("Cannot open %1.\n").arg(icon.fileName())), stderr);
return -1;
}
CollectionConfiguration::setAboutIcon(helpEngine, icon.readAll());
@@ -543,7 +569,7 @@ int main(int argc, char *argv[])
QFileInfo fi(absoluteFileName(basePath, it.value()));
QFile f(fi.absoluteFilePath());
if (!f.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Cannot open %s!\n", qPrintable(f.fileName()));
+ fputs(qPrintable(QCG::tr("Cannot open %1.\n").arg(f.fileName())), stderr);
return -1;
}
QByteArray data = f.readAll();
@@ -565,8 +591,8 @@ int main(int argc, char *argv[])
if (!imgData.contains(src))
imgData.insert(src, img.readAll());
} else {
- fprintf(stderr, "Cannot open referenced image file %s!\n",
- qPrintable(img.fileName()));
+ fputs(qPrintable(QCG::tr("Cannot open referenced image file %1.\n")
+ .arg(img.fileName())), stderr);
}
}
}
diff --git a/tools/assistant/tools/qhelpconverter/filespage.cpp b/tools/assistant/tools/qhelpconverter/filespage.cpp
index 4ebf391..fd4a40e 100644
--- a/tools/assistant/tools/qhelpconverter/filespage.cpp
+++ b/tools/assistant/tools/qhelpconverter/filespage.cpp
@@ -59,8 +59,8 @@ FilesPage::FilesPage(QWidget *parent)
connect(m_ui.removeAllButton, SIGNAL(clicked()),
this, SLOT(removeAllFiles()));
- m_ui.fileLabel->setText(tr("<p><b>Warning:</b> Be aware "
- "when removing images or stylesheets since those files "
+ m_ui.fileLabel->setText(tr("<p><b>Warning:</b> "
+ "When removing images or stylesheets, be aware that those files "
"are not directly referenced by the .adp or .dcf "
"file.</p>"));
}
diff --git a/tools/assistant/tools/qhelpconverter/filterpage.cpp b/tools/assistant/tools/qhelpconverter/filterpage.cpp
index 7f86980..c15a580 100644
--- a/tools/assistant/tools/qhelpconverter/filterpage.cpp
+++ b/tools/assistant/tools/qhelpconverter/filterpage.cpp
@@ -50,7 +50,7 @@ FilterPage::FilterPage(QWidget *parent)
setTitle(tr("Filter Settings"));
setSubTitle(tr("Specify the filter attributes for the "
"documentation. If filter attributes are used, "
- "also define a custom filter for it. Both, the "
+ "also define a custom filter for it. Both the "
"filter attributes and the custom filters are "
"optional."));
@@ -127,7 +127,7 @@ void FilterPage::addFilter()
{
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.customFilterWidget);
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsSelectable);
- item->setText(0, QLatin1String("unfiltered"));
+ item->setText(0, tr("unfiltered", "list of available documentation"));
item->setText(1, QLatin1String(""));
m_ui.customFilterWidget->editItem(item, 0);
m_ui.removeButton->setDisabled(false);
diff --git a/tools/assistant/tools/qhelpconverter/finishpage.cpp b/tools/assistant/tools/qhelpconverter/finishpage.cpp
index 0be3a1b..f0228e3 100644
--- a/tools/assistant/tools/qhelpconverter/finishpage.cpp
+++ b/tools/assistant/tools/qhelpconverter/finishpage.cpp
@@ -52,8 +52,7 @@ FinishPage::FinishPage(QWidget *parent)
: QWizardPage(parent)
{
setTitle(tr("Converting File"));
- setSubTitle(QLatin1String("Creating the new Qt help files from the "
- "old .adp file."));
+ setSubTitle(tr("Creating the new Qt help files from the old ADP file."));
setFinalPage(true);
QVBoxLayout *layout = new QVBoxLayout(this);
diff --git a/tools/assistant/tools/qhelpconverter/helpwindow.cpp b/tools/assistant/tools/qhelpconverter/helpwindow.cpp
index 9cc1a85..2c7e030 100644
--- a/tools/assistant/tools/qhelpconverter/helpwindow.cpp
+++ b/tools/assistant/tools/qhelpconverter/helpwindow.cpp
@@ -64,7 +64,7 @@ HelpWindow::HelpWindow(QWidget *parent)
layout = new QVBoxLayout(frame);
layout->setMargin(2);
- QLabel *l = new QLabel(QLatin1String("<center><b>Wizard Assistant</b></center>"));
+ QLabel *l = new QLabel(tr("<center><b>Wizard Assistant</b></center>"));
layout->addWidget(l);
m_textEdit = new QTextEdit();
m_textEdit->setFrameStyle(QFrame::NoFrame);
diff --git a/tools/assistant/tools/qhelpconverter/inputpage.h b/tools/assistant/tools/qhelpconverter/inputpage.h
index e9276c6..28a7075 100644
--- a/tools/assistant/tools/qhelpconverter/inputpage.h
+++ b/tools/assistant/tools/qhelpconverter/inputpage.h
@@ -54,7 +54,7 @@ class InputPage : public QWizardPage
Q_OBJECT
public:
- InputPage(AdpReader *reader, QWidget *parent = 0);
+ explicit InputPage(AdpReader *reader, QWidget *parent = 0);
private slots:
void getFileName();
diff --git a/tools/assistant/tools/qhelpconverter/main.cpp b/tools/assistant/tools/qhelpconverter/main.cpp
index 4b1d815..5ee624d 100644
--- a/tools/assistant/tools/qhelpconverter/main.cpp
+++ b/tools/assistant/tools/qhelpconverter/main.cpp
@@ -40,6 +40,9 @@
****************************************************************************/
#include <QtCore/QFileInfo>
+#include <QtCore/QTranslator>
+#include <QtCore/QLocale>
+#include <QtCore/QLibraryInfo>
#include <QtGui/QApplication>
#include "conversionwizard.h"
@@ -49,6 +52,18 @@ QT_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QTranslator qt_helpTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("assistant_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)
+ && qt_helpTranslator.load(QLatin1String("qt_help_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ app.installTranslator(&qt_helpTranslator);
+ }
ConversionWizard w;
if (argc == 2) {
diff --git a/tools/assistant/tools/qhelpgenerator/main.cpp b/tools/assistant/tools/qhelpgenerator/main.cpp
index a309f42..637786c 100644
--- a/tools/assistant/tools/qhelpgenerator/main.cpp
+++ b/tools/assistant/tools/qhelpgenerator/main.cpp
@@ -44,11 +44,18 @@
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QCoreApplication>
+#include <QtCore/QTranslator>
+#include <QtCore/QLocale>
+#include <QtCore/QLibraryInfo>
#include <private/qhelpprojectdata_p.h>
QT_USE_NAMESPACE
+class QHG {
+ Q_DECLARE_TR_FUNCTIONS(QHelpGenerator)
+};
+
int main(int argc, char *argv[])
{
QString error;
@@ -60,6 +67,20 @@ int main(int argc, char *argv[])
bool showVersion = false;
bool checkLinks = false;
+ QCoreApplication app(argc, argv);
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QTranslator qt_helpTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("assistant_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)
+ && qt_helpTranslator.load(QLatin1String("qt_help_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ app.installTranslator(&qt_helpTranslator);
+ }
+
for (int i = 1; i < argc; ++i) {
arg = QString::fromLocal8Bit(argv[i]);
if (arg == QLatin1String("-o")) {
@@ -67,8 +88,7 @@ int main(int argc, char *argv[])
QFileInfo fi(QString::fromLocal8Bit(argv[i]));
compressedFile = fi.absoluteFilePath();
} else {
- error = QCoreApplication::translate("QHelpGenerator",
- "Missing output file name!");
+ error = QHG::tr("Missing output file name.");
}
} else if (arg == QLatin1String("-v")) {
showVersion = true;
@@ -84,16 +104,15 @@ int main(int argc, char *argv[])
}
if (showVersion) {
- fprintf(stdout, "Qt Help Generator version 1.0 (Qt %s)\n",
- QT_VERSION_STR);
+ fputs(qPrintable(QHG::tr("Qt Help Generator version 1.0 (Qt %1)\n")
+ .arg(QT_VERSION_STR)), stdout);
return 0;
}
if (projectFile.isEmpty() && !showHelp)
- error = QCoreApplication::translate("QHelpGenerator",
- "Missing Qt help project file!");
+ error = QHG::tr("Missing Qt help project file.");
- QString help = QCoreApplication::translate("QHelpGenerator", "\nUsage:\n\n"
+ QString help = QHG::tr("\nUsage:\n\n"
"qhelpgenerator <help-project-file> [options]\n\n"
" -o <compressed-file> Generates a Qt compressed help\n"
" file called <compressed-file>.\n"
@@ -105,7 +124,7 @@ int main(int argc, char *argv[])
" qhelpgenerator.\n\n");
if (showHelp) {
- fprintf(stdout, "%s", qPrintable(help));
+ fputs(qPrintable(help), stdout);
return 0;
}else if (!error.isEmpty()) {
fprintf(stderr, "%s\n\n%s", qPrintable(error), qPrintable(help));
@@ -114,7 +133,7 @@ int main(int argc, char *argv[])
QFile file(projectFile);
if (!file.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Could not open %s!\n", qPrintable(projectFile));
+ fputs(qPrintable(QHG::tr("Could not open %1.\n").arg(projectFile)), stderr);
return -1;
}
@@ -130,8 +149,8 @@ int main(int argc, char *argv[])
QDir parentDir = fi.dir();
if (!parentDir.exists()) {
if (!parentDir.mkpath(QLatin1String("."))) {
- fprintf(stderr, "Could not create output directory: %s\n",
- qPrintable(parentDir.path()));
+ fputs(qPrintable(QHG::tr("Could not create output directory: %1\n")
+ .arg(parentDir.path())), stderr);
}
}
}
@@ -142,7 +161,6 @@ int main(int argc, char *argv[])
return -1;
}
- QCoreApplication app(argc, argv);
HelpGenerator generator;
bool success = true;
if (checkLinks)
diff --git a/tools/assistant/tools/shared/collectionconfiguration.cpp b/tools/assistant/tools/shared/collectionconfiguration.cpp
index e3944b6..2272c64 100644
--- a/tools/assistant/tools/shared/collectionconfiguration.cpp
+++ b/tools/assistant/tools/shared/collectionconfiguration.cpp
@@ -71,6 +71,7 @@ namespace {
#endif
));
const QString WindowTitleKey(QLatin1String("WindowTitle"));
+ const QString FullTextSearchFallbackKey(QLatin1String("FullTextSearchFallback"));
} // anonymous namespace
const QString CollectionConfiguration::DefaultZoomFactor(QLatin1String("0.0"));
@@ -308,6 +309,19 @@ void CollectionConfiguration::copyConfiguration(const QHelpEngineCore &source,
setAboutTexts(target, aboutTexts(source));
setAboutImages(target, aboutImages(source));
setDefaultHomePage(target, defaultHomePage(source));
+ setFullTextSearchFallbackEnabled(target, fullTextSearchFallbackEnabled(source));
+}
+
+bool CollectionConfiguration:: fullTextSearchFallbackEnabled(
+ const QHelpEngineCore &helpEngine)
+{
+ return helpEngine.customValue(FullTextSearchFallbackKey, false).toBool();
+}
+
+void CollectionConfiguration::setFullTextSearchFallbackEnabled(
+ QHelpEngineCore &helpEngine, bool on)
+{
+ helpEngine.setCustomValue(FullTextSearchFallbackKey, on);
}
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/shared/collectionconfiguration.h b/tools/assistant/tools/shared/collectionconfiguration.h
index b7bf247..aeb636f 100644
--- a/tools/assistant/tools/shared/collectionconfiguration.h
+++ b/tools/assistant/tools/shared/collectionconfiguration.h
@@ -136,6 +136,10 @@ public:
static const QDateTime lastRegisterTime(const QHelpEngineCore &helpEngine);
static void updateLastRegisterTime(QHelpEngineCore &helpEngine);
+ static bool fullTextSearchFallbackEnabled(const QHelpEngineCore &helpEngine);
+ static void setFullTextSearchFallbackEnabled(QHelpEngineCore &helpEngine,
+ bool on);
+
static const QString DefaultZoomFactor;
static const QString ListSeparator;
};
diff --git a/tools/assistant/tools/shared/helpgenerator.cpp b/tools/assistant/tools/shared/helpgenerator.cpp
index 12008e6..4812bc5 100644
--- a/tools/assistant/tools/shared/helpgenerator.cpp
+++ b/tools/assistant/tools/shared/helpgenerator.cpp
@@ -73,12 +73,12 @@ QString HelpGenerator::error() const
void HelpGenerator::printStatus(const QString &msg)
{
- fprintf(stdout, "%s\n", qPrintable(msg));
+ puts(qPrintable(msg));
}
void HelpGenerator::printWarning(const QString &msg)
{
- fprintf(stdout, "Warning: %s\n", qPrintable(msg));
+ puts(qPrintable(tr("Warning: %1").arg(msg)));
}
QT_END_NAMESPACE
diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro
index 6450038..5b9d223 100644
--- a/tools/configure/configure.pro
+++ b/tools/configure/configure.pro
@@ -28,7 +28,7 @@ INCLUDEPATH += \
$$QT_SOURCE_TREE/src/corelib/global \
$$QT_BUILD_TREE/include \
$$QT_BUILD_TREE/include/QtCore \
- $$QT_BUILD_TREE/tools/shared
+ $$QT_SOURCE_TREE/tools/shared
HEADERS = configureapp.h environment.h tools.h\
$$QT_SOURCE_TREE/src/corelib/tools/qbytearray.h \
@@ -100,6 +100,7 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \
$$QT_SOURCE_TREE/src/corelib/io/qiodevice.cpp \
$$QT_SOURCE_TREE/src/corelib/io/qtextstream.cpp \
$$QT_SOURCE_TREE/src/corelib/io/qtemporaryfile.cpp \
+ $$QT_SOURCE_TREE/src/corelib/plugin/qsystemlibrary.cpp \
$$QT_SOURCE_TREE/src/corelib/tools/qbitarray.cpp \
$$QT_SOURCE_TREE/src/corelib/tools/qdatetime.cpp \
$$QT_SOURCE_TREE/src/corelib/tools/qmap.cpp \
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 0ed16ed..6c12cc2 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -279,6 +279,7 @@ Configure::Configure(int& argc, char** argv)
dictionary[ "DIRECTSHOW" ] = "no";
dictionary[ "WEBKIT" ] = "auto";
dictionary[ "DECLARATIVE" ] = "auto";
+ dictionary[ "DECLARATIVE_DEBUG" ]= "yes";
dictionary[ "PLUGIN_MANIFESTS" ] = "yes";
QString version;
@@ -341,7 +342,7 @@ Configure::Configure(int& argc, char** argv)
dictionary[ "ACCESSIBILITY" ] = "yes";
dictionary[ "OPENGL" ] = "yes";
dictionary[ "OPENVG" ] = "no";
- dictionary[ "IPV6" ] = "yes"; // Always, dynamicly loaded
+ dictionary[ "IPV6" ] = "yes"; // Always, dynamically loaded
dictionary[ "OPENSSL" ] = "auto";
dictionary[ "DBUS" ] = "auto";
dictionary[ "S60" ] = "yes";
@@ -381,6 +382,7 @@ Configure::Configure(int& argc, char** argv)
dictionary[ "INCREDIBUILD_XGE" ] = "auto";
dictionary[ "LTCG" ] = "no";
dictionary[ "NATIVE_GESTURES" ] = "yes";
+ dictionary[ "MSVC_MP" ] = "no";
}
Configure::~Configure()
@@ -534,6 +536,13 @@ void Configure::parseCmdLine()
else if (configCmdLine.at(i) == "-no-ltcg") {
dictionary[ "LTCG" ] = "no";
}
+ else if (configCmdLine.at(i) == "-mp") {
+ dictionary[ "MSVC_MP" ] = "yes";
+ }
+ else if (configCmdLine.at(i) == "-no-mp") {
+ dictionary[ "MSVC_MP" ] = "no";
+ }
+
#endif
else if (configCmdLine.at(i) == "-platform") {
@@ -949,10 +958,16 @@ void Configure::parseCmdLine()
dictionary[ "WEBKIT" ] = "no";
} else if (configCmdLine.at(i) == "-webkit") {
dictionary[ "WEBKIT" ] = "yes";
+ } else if (configCmdLine.at(i) == "-webkit-debug") {
+ dictionary[ "WEBKIT" ] = "debug";
} else if (configCmdLine.at(i) == "-no-declarative") {
dictionary[ "DECLARATIVE" ] = "no";
} else if (configCmdLine.at(i) == "-declarative") {
dictionary[ "DECLARATIVE" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-declarative-debug") {
+ dictionary[ "DECLARATIVE_DEBUG" ] = "no";
+ } else if (configCmdLine.at(i) == "-declarative-debug") {
+ dictionary[ "DECLARATIVE_DEBUG" ] = "yes";
} else if (configCmdLine.at(i) == "-no-plugin-manifests") {
dictionary[ "PLUGIN_MANIFESTS" ] = "no";
} else if (configCmdLine.at(i) == "-plugin-manifests") {
@@ -1509,6 +1524,10 @@ void Configure::applySpecSpecifics()
dictionary[ "QT3SUPPORT" ] = "no";
dictionary[ "OPENGL" ] = "no";
dictionary[ "OPENSSL" ] = "yes";
+ // We accidently enabled IPv6 for Qt Symbian in 4.6.x. However the underlying OpenC does not fully support IPV6.
+ // Therefore for 4.7.1 and following we disable it until OpenC either supports it or we have the native Qt
+ // symbian socket engine.
+ dictionary[ "IPV6" ] = "no";
dictionary[ "STL" ] = "yes";
dictionary[ "EXCEPTIONS" ] = "yes";
dictionary[ "RTTI" ] = "yes";
@@ -1634,7 +1653,7 @@ bool Configure::displayHelp()
"[-phonon] [-no-phonon-backend] [-phonon-backend]\n"
"[-no-multimedia] [-multimedia] [-no-audio-backend] [-audio-backend]\n"
"[-no-script] [-script] [-no-scripttools] [-scripttools]\n"
- "[-no-webkit] [-webkit] [-graphicssystem raster|opengl|openvg]\n\n", 0, 7);
+ "[-no-webkit] [-webkit] [-webkit-debug] [-graphicssystem raster|opengl|openvg]\n\n", 0, 7);
desc("Installation options:\n\n");
@@ -1818,12 +1837,15 @@ bool Configure::displayHelp()
desc("AUDIO_BACKEND", "yes","-audio-backend", "Compile in the platform audio backend into QtMultimedia");
desc("WEBKIT", "no", "-no-webkit", "Do not compile in the WebKit module");
desc("WEBKIT", "yes", "-webkit", "Compile in the WebKit module (WebKit is built if a decent C++ compiler is used.)");
+ desc("WEBKIT", "debug", "-webkit-debug", "Compile in the WebKit module with debug symbols.");
desc("SCRIPT", "no", "-no-script", "Do not build the QtScript module.");
desc("SCRIPT", "yes", "-script", "Build the QtScript module.");
desc("SCRIPTTOOLS", "no", "-no-scripttools", "Do not build the QtScriptTools module.");
desc("SCRIPTTOOLS", "yes", "-scripttools", "Build the QtScriptTools module.");
desc("DECLARATIVE", "no", "-no-declarative", "Do not build the declarative module");
desc("DECLARATIVE", "yes", "-declarative", "Build the declarative module");
+ desc("DECLARATIVE_DEBUG", "no", "-no-declarative-debug", "Do not build the declarative debugging support");
+ desc("DECLARATIVE_DEBUG", "yes", "-declarative-debug", "Build the declarative debugging support");
desc( "-arch <arch>", "Specify an architecture.\n"
"Available values for <arch>:");
@@ -1848,6 +1870,8 @@ bool Configure::displayHelp()
desc("STYLE_S60" , "yes", "", " s60\n", ' ');
desc("NATIVE_GESTURES", "no", "-no-native-gestures", "Do not use native gestures on Windows 7.");
desc("NATIVE_GESTURES", "yes", "-native-gestures", "Use native gestures on Windows 7.");
+ desc("MSVC_MP", "no", "-no-mp", "Do not use multiple processors for compiling with MSVC");
+ desc("MSVC_MP", "yes", "-mp", "Use multiple processors for compiling with MSVC (-MP)");
/* We do not support -qconfig on Windows yet
@@ -2107,7 +2131,7 @@ bool Configure::checkAvailability(const QString &part)
available = findFile("BuildConsole.exe") && findFile("xgConsole.exe");
else if (part == "XMLPATTERNS")
available = dictionary.value("EXCEPTIONS") == "yes";
- } else if (part == "PHONON") {
+ else if (part == "PHONON") {
if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
available = true;
} else {
@@ -2164,7 +2188,7 @@ bool Configure::checkAvailability(const QString &part)
available = (paths.size() == 0);
if (!available) {
- if (epocRoot.isNull() || epocRoot == "")
+ if (epocRoot.isEmpty())
epocRoot = "<empty string>";
cout << endl
<< "The QtMultimedia audio backend will not be built because required" << endl
@@ -2274,6 +2298,8 @@ void Configure::autoDetection()
dictionary["WEBKIT"] = checkAvailability("WEBKIT") ? "yes" : "no";
if (dictionary["DECLARATIVE"] == "auto")
dictionary["DECLARATIVE"] = dictionary["SCRIPT"] == "yes" ? "yes" : "no";
+ if (dictionary["DECLARATIVE_DEBUG"] == "auto")
+ dictionary["DECLARATIVE_DEBUG"] = dictionary["DECLARATIVE"] == "yes" ? "yes" : "no";
if (dictionary["AUDIO_BACKEND"] == "auto")
dictionary["AUDIO_BACKEND"] = checkAvailability("AUDIO_BACKEND") ? "yes" : "no";
if (dictionary["WMSDK"] == "auto")
@@ -2682,8 +2708,15 @@ void Configure::generateOutputVars()
qtConfig += "audio-backend";
}
- if (dictionary["WEBKIT"] == "yes")
- qtConfig += "webkit";
+ QString dst = buildPath + "/mkspecs/modules/qt_webkit_version.pri";
+ QFile::remove(dst);
+ if (dictionary["WEBKIT"] != "no") {
+ // This include takes care of adding "webkit" to QT_CONFIG.
+ QString src = sourcePath + "/src/3rdparty/webkit/WebKit/qt/qt_webkit_version.pri";
+ QFile::copy(src, dst);
+ if (dictionary["WEBKIT"] == "debug")
+ qtConfig += "webkit-debug";
+ }
if (dictionary["DECLARATIVE"] == "yes") {
if (dictionary[ "SCRIPT" ] == "no") {
@@ -2710,7 +2743,7 @@ void Configure::generateOutputVars()
QString set_config = dictionary["QCONFIG"];
if (possible_configs.contains(set_config)) {
- foreach(QString cfg, possible_configs) {
+ foreach (const QString &cfg, possible_configs) {
qtConfig += (cfg + "-config");
if (cfg == set_config)
break;
@@ -2832,11 +2865,11 @@ void Configure::generateCachefile()
for (QStringList::Iterator var = qmakeVars.begin(); var != qmakeVars.end(); ++var) {
cacheStream << (*var) << endl;
}
- cacheStream << "CONFIG += " << qmakeConfig.join(" ") << " incremental create_prl link_prl depend_includepath QTDIR_build" << endl;
+ cacheStream << "CONFIG += " << qmakeConfig.join(" ") << " incremental msvc_mp create_prl link_prl depend_includepath QTDIR_build" << endl;
QStringList buildParts;
buildParts << "libs" << "tools" << "examples" << "demos" << "docs" << "translations";
- foreach(QString item, disabledBuildParts) {
+ foreach (const QString &item, disabledBuildParts) {
buildParts.removeAll(item);
}
cacheStream << "QT_BUILD_PARTS = " << buildParts.join(" ") << endl;
@@ -2895,6 +2928,8 @@ void Configure::generateCachefile()
if (dictionary[ "LTCG" ] == "yes")
configStream << " ltcg";
+ if (dictionary[ "MSVC_MP" ] == "yes")
+ configStream << " msvc_mp";
if (dictionary[ "STL" ] == "yes")
configStream << " stl";
if (dictionary[ "EXCEPTIONS" ] == "yes")
@@ -3050,10 +3085,7 @@ void Configure::generateConfigfiles()
tmpStream << "/* Machine byte-order */" << endl;
tmpStream << "#define Q_BIG_ENDIAN 4321" << endl;
tmpStream << "#define Q_LITTLE_ENDIAN 1234" << endl;
- if (QSysInfo::ByteOrder == QSysInfo::BigEndian)
- tmpStream << "#define Q_BYTE_ORDER Q_BIG_ENDIAN" << endl;
- else
- tmpStream << "#define Q_BYTE_ORDER Q_LITTLE_ENDIAN" << endl;
+ tmpStream << "#define Q_BYTE_ORDER Q_LITTLE_ENDIAN" << endl;
tmpStream << endl << "// Compile time features" << endl;
tmpStream << "#define QT_ARCH_" << dictionary["ARCHITECTURE"].toUpper() << endl;
@@ -3095,6 +3127,7 @@ void Configure::generateConfigfiles()
if (dictionary["IPV6"] == "no") qconfigList += "QT_NO_IPV6";
if (dictionary["WEBKIT"] == "no") qconfigList += "QT_NO_WEBKIT";
if (dictionary["DECLARATIVE"] == "no") qconfigList += "QT_NO_DECLARATIVE";
+ if (dictionary["DECLARATIVE_DEBUG"] == "no") qconfigList += "QDECLARATIVE_NO_DEBUG_PROTOCOL";
if (dictionary["PHONON"] == "no") qconfigList += "QT_NO_PHONON";
if (dictionary["MULTIMEDIA"] == "no") qconfigList += "QT_NO_MULTIMEDIA";
if (dictionary["XMLPATTERNS"] == "no") qconfigList += "QT_NO_XMLPATTERNS";
@@ -3149,7 +3182,7 @@ void Configure::generateConfigfiles()
QStringList kbdDrivers = dictionary["KBD_DRIVERS"].split(" ");;
QStringList allKbdDrivers;
allKbdDrivers<<"tty"<<"usb"<<"sl5000"<<"yopy"<<"vr41xx"<<"qvfb"<<"um";
- foreach(QString kbd, allKbdDrivers) {
+ foreach (const QString &kbd, allKbdDrivers) {
if (!kbdDrivers.contains(kbd))
tmpStream<<"#define QT_NO_QWS_KBD_"<<kbd.toUpper()<<endl;
}
@@ -3157,7 +3190,7 @@ void Configure::generateConfigfiles()
QStringList mouseDrivers = dictionary["MOUSE_DRIVERS"].split(" ");
QStringList allMouseDrivers;
allMouseDrivers << "pc"<<"bus"<<"linuxtp"<<"yopy"<<"vr41xx"<<"tslib"<<"qvfb";
- foreach(QString mouse, allMouseDrivers) {
+ foreach (const QString &mouse, allMouseDrivers) {
if (!mouseDrivers.contains(mouse))
tmpStream<<"#define QT_NO_QWS_MOUSE_"<<mouse.toUpper()<<endl;
}
@@ -3165,7 +3198,7 @@ void Configure::generateConfigfiles()
QStringList gfxDrivers = dictionary["GFX_DRIVERS"].split(" ");
QStringList allGfxDrivers;
allGfxDrivers<<"linuxfb"<<"transformed"<<"qvfb"<<"vnc"<<"multiscreen"<<"ahi";
- foreach(QString gfx, allGfxDrivers) {
+ foreach (const QString &gfx, allGfxDrivers) {
if (!gfxDrivers.contains(gfx))
tmpStream<<"#define QT_NO_QWS_"<<gfx.toUpper()<<endl;
}
@@ -3173,7 +3206,7 @@ void Configure::generateConfigfiles()
tmpStream<<"#define Q_WS_QWS"<<endl;
QStringList depths = dictionary[ "QT_QWS_DEPTH" ].split(" ");
- foreach(QString depth, depths)
+ foreach (const QString &depth, depths)
tmpStream<<"#define QT_QWS_DEPTH_"+depth<<endl;
}
@@ -3390,8 +3423,14 @@ void Configure::displayConfig()
cout << "QtXmlPatterns support......." << dictionary[ "XMLPATTERNS" ] << endl;
cout << "Phonon support.............." << dictionary[ "PHONON" ] << endl;
cout << "QtMultimedia support........" << dictionary[ "MULTIMEDIA" ] << endl;
- cout << "WebKit support.............." << dictionary[ "WEBKIT" ] << endl;
+ {
+ QString webkit = dictionary[ "WEBKIT" ];
+ if (webkit == "debug")
+ webkit = "yes (debug)";
+ cout << "WebKit support.............." << webkit;
+ }
cout << "Declarative support........." << dictionary[ "DECLARATIVE" ] << endl;
+ cout << "Declarative debugging......." << dictionary[ "DECLARATIVE_DEBUG" ] << endl;
cout << "QtScript support............" << dictionary[ "SCRIPT" ] << endl;
cout << "QtScriptTools support......." << dictionary[ "SCRIPTTOOLS" ] << endl;
cout << "Graphics System............." << dictionary[ "GRAPHICS_SYSTEM" ] << endl;
@@ -3622,7 +3661,10 @@ void Configure::buildHostTools()
// generate Makefile
QStringList args;
args << QDir::toNativeSeparators(buildPath + "/bin/qmake");
- args << "-spec" << dictionary["QMAKESPEC"] << "-r";
+ // override .qmake.cache because we are not cross-building these.
+ // we need a full path so that a build with -prefix will still find it.
+ args << "-spec" << QDir::toNativeSeparators(buildPath + "/mkspecs/" + dictionary["QMAKESPEC"]);
+ args << "-r";
args << "-o" << QDir::toNativeSeparators(toolBuildPath + "/Makefile");
QDir().mkpath(toolBuildPath);
@@ -3760,8 +3802,7 @@ void Configure::generateMakefiles()
printf("Generating Makefiles...\n");
generate = false; // Now Makefiles will be done
}
- args << "-spec";
- args << spec;
+ // don't pass -spec - .qmake.cache has it already
args << "-r";
args << (sourcePath + "/projects.pro");
args << "-o";
diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp
index 5d9851f..9446864 100644
--- a/tools/configure/environment.cpp
+++ b/tools/configure/environment.cpp
@@ -271,8 +271,7 @@ static QByteArray qt_create_environment(const QStringList &environment)
pos += tmpSize;
}
// add the user environment
- for (QStringList::ConstIterator it = environment.begin(); it != environment.end(); it++ ) {
- QString tmp = *it;
+ foreach (const QString &tmp, environment) {
uint tmpSize = sizeof(wchar_t) * (tmp.length() + 1);
envlist.resize(envlist.size() + tmpSize);
memcpy(envlist.data() + pos, tmp.utf16(), tmpSize);
@@ -376,7 +375,7 @@ int Environment::execute(QStringList arguments, const QStringList &additionalEnv
switch(GetLastError()) {
case E2BIG:
cerr << "execute: Argument list exceeds 1024 bytes" << endl;
- foreach(QString arg, arguments)
+ foreach (const QString &arg, arguments)
cerr << " (" << arg.toLocal8Bit().constData() << ")" << endl;
break;
case ENOENT:
@@ -390,7 +389,7 @@ int Environment::execute(QStringList arguments, const QStringList &additionalEnv
break;
default:
cerr << "execute: Unknown error" << endl;
- foreach(QString arg, arguments)
+ foreach (const QString &arg, arguments)
cerr << " (" << arg.toLocal8Bit().constData() << ")" << endl;
break;
}
diff --git a/tools/configure/tools.cpp b/tools/configure/tools.cpp
index c4625af..c91f048 100644
--- a/tools/configure/tools.cpp
+++ b/tools/configure/tools.cpp
@@ -91,8 +91,8 @@ void Tools::checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString
QStringList components = buffer.split( '=' );
if ( components.size() >= 2 ) {
QStringList::Iterator it = components.begin();
- QString key = (*it++).trimmed().replace( "\"", QString() ).toUpper();
- QString value = (*it++).trimmed().replace( "\"", QString() );
+ QString key = (*it++).trimmed().remove('"').toUpper();
+ QString value = (*it++).trimmed().remove('"');
licenseInfo[ key ] = value;
}
}
@@ -111,7 +111,7 @@ void Tools::checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString
// Verify license info...
QString licenseKey = licenseInfo["LICENSEKEYEXT"];
QByteArray clicenseKey = licenseKey.toLatin1();
- //We check the licence
+ //We check the license
static const char * const SEP = "-";
char *licenseParts[NUMBER_OF_PARTS];
int partNumber = 0;
@@ -218,7 +218,7 @@ void Tools::checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString
if (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/.LICENSE")) {
// Generic, no-suffix license
- dictionary["LICENSE_EXTENSION"] = QString();
+ dictionary["LICENSE_EXTENSION"].clear();
} else if (dictionary["LICENSE_EXTENSION"].isEmpty()) {
cout << "License file does not contain proper license key." << endl;
dictionary["DONE"] = "error";
@@ -239,7 +239,7 @@ void Tools::checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString
fromLicenseFile += "-US";
if (!CopyFile((wchar_t*)QDir::toNativeSeparators(fromLicenseFile).utf16(),
- (wchar_t*)QDir::toNativeSeparators(toLicenseFile).utf16(), FALSE)) {
+ (wchar_t*)QDir::toNativeSeparators(toLicenseFile).utf16(), false)) {
cout << "Failed to copy license file (" << fromLicenseFile << ")";
dictionary["DONE"] = "error";
return;
diff --git a/tools/designer/data/ui4.xsd b/tools/designer/data/ui4.xsd
index f44fa71..fc9c120 100644
--- a/tools/designer/data/ui4.xsd
+++ b/tools/designer/data/ui4.xsd
@@ -434,6 +434,7 @@
<xs:element name="selectedoff" type="ResourcePixmap" minOccurs="0" />
<xs:element name="selectedon" type="ResourcePixmap" minOccurs="0" />
</xs:all>
+ <xs:attribute name="theme" type="xs:string" />
<xs:attribute name="resource" type="xs:string" /> <!-- pre 4.4 legacy support -->
</xs:complexType>
diff --git a/tools/designer/src/components/formeditor/formeditor.qrc b/tools/designer/src/components/formeditor/formeditor.qrc
index ed7e40e..e42cc66 100644
--- a/tools/designer/src/components/formeditor/formeditor.qrc
+++ b/tools/designer/src/components/formeditor/formeditor.qrc
@@ -113,7 +113,6 @@
<file>images/widgets/vslider.png</file>
<file>images/widgets/vspacer.png</file>
<file>images/widgets/widget.png</file>
- <file>images/widgets/widget.png</file>
<file>images/widgets/widgetstack.png</file>
<file>images/widgets/wizard.png</file>
<file>images/win/adjustsize.png</file>
diff --git a/tools/designer/src/components/formeditor/formeditor_optionspage.cpp b/tools/designer/src/components/formeditor/formeditor_optionspage.cpp
index 102f44a..8e0cc66 100644
--- a/tools/designer/src/components/formeditor/formeditor_optionspage.cpp
+++ b/tools/designer/src/components/formeditor/formeditor_optionspage.cpp
@@ -86,9 +86,11 @@ ZoomSettingsWidget::ZoomSettingsWidget(QWidget *parent) :
m_zoomCombo->setEditable(false);
const IntList zoomValues = ZoomMenu::zoomValues();
const IntList::const_iterator cend = zoomValues.constEnd();
- //: Zoom percentage
- for (IntList::const_iterator it = zoomValues.constBegin(); it != cend; ++it)
+
+ for (IntList::const_iterator it = zoomValues.constBegin(); it != cend; ++it) {
+ //: Zoom percentage
m_zoomCombo->addItem(QCoreApplication::translate("FormEditorOptionsPage", "%1 %").arg(*it), QVariant(*it));
+ }
// Layout
setCheckable(true);
diff --git a/tools/designer/src/components/formeditor/qdesigner_resource.cpp b/tools/designer/src/components/formeditor/qdesigner_resource.cpp
index 6c458f3..7fabf68 100644
--- a/tools/designer/src/components/formeditor/qdesigner_resource.cpp
+++ b/tools/designer/src/components/formeditor/qdesigner_resource.cpp
@@ -171,7 +171,7 @@ QDesignerResourceBuilder::QDesignerResourceBuilder(QDesignerFormEditorInterface
{
}
-static inline void setIconPixmap(QIcon::Mode m, QIcon::State s, const QDir &workingDirectory,
+static inline void setIconPixmap(QIcon::Mode m, QIcon::State s, const QDir &workingDirectory,
QString path, PropertySheetIconValue &icon,
const QDesignerLanguageExtension *lang = 0)
{
@@ -203,6 +203,7 @@ QVariant QDesignerResourceBuilder::loadResource(const QDir &workingDirectory, co
case DomProperty::IconSet: {
PropertySheetIconValue icon;
DomResourceIcon *di = property->elementIconSet();
+ icon.setTheme(di->attributeTheme());
if (const int flags = iconStateFlags(di)) { // new, post 4.4 format
if (flags & NormalOff)
setIconPixmap(QIcon::Normal, QIcon::Off, workingDirectory, di->elementNormalOff()->text(), icon, m_lang);
@@ -278,8 +279,11 @@ DomProperty *QDesignerResourceBuilder::saveResource(const QDir &workingDirectory
} else if (value.canConvert<PropertySheetIconValue>()) {
const PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(value);
const QMap<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> pixmaps = icon.paths();
- if (!pixmaps.isEmpty()) {
+ const QString theme = icon.theme();
+ if (!pixmaps.isEmpty() || !theme.isEmpty()) {
DomResourceIcon *ri = new DomResourceIcon;
+ if (!theme.isEmpty())
+ ri->setAttributeTheme(theme);
QMapIterator<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> itPix(pixmaps);
while (itPix.hasNext()) {
const QIcon::Mode mode = itPix.next().key().first;
@@ -1377,34 +1381,6 @@ DomLayoutItem *QDesignerResource::createDom(QLayoutItem *item, DomLayout *ui_lay
} else {
return 0;
}
-
- if (m_chain.size() && item->widget()) {
- if (QGridLayout *grid = qobject_cast<QGridLayout*>(m_chain.top())) {
- const int index = Utils::indexOfWidget(grid, item->widget());
-
- int row, column, rowspan, colspan;
- grid->getItemPosition(index, &row, &column, &rowspan, &colspan);
- ui_item->setAttributeRow(row);
- ui_item->setAttributeColumn(column);
-
- if (colspan != 1)
- ui_item->setAttributeColSpan(colspan);
-
- if (rowspan != 1)
- ui_item->setAttributeRowSpan(rowspan);
- } else {
- if (QFormLayout *form = qobject_cast<QFormLayout*>(m_chain.top())) {
- const int index = Utils::indexOfWidget(form, item->widget());
- int row, column, colspan;
- getFormLayoutItemPosition(form, index, &row, &column, 0, &colspan);
- ui_item->setAttributeRow(row);
- ui_item->setAttributeColumn(column);
- if (colspan != 1)
- ui_item->setAttributeColSpan(colspan);
- }
- }
- }
-
return ui_item;
}
diff --git a/tools/designer/src/components/propertyeditor/defs.cpp b/tools/designer/src/components/propertyeditor/defs.cpp
deleted file mode 100644
index 54dec74..0000000
--- a/tools/designer/src/components/propertyeditor/defs.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Designer 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 Technology Preview License Agreement accompanying
-** this package.
-**
-** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "defs.h"
-
-QT_BEGIN_NAMESPACE
-
-namespace qdesigner_internal {
-
-int size_type_to_int( QSizePolicy::Policy t )
-{
- if ( t == QSizePolicy::Fixed )
- return 0;
- if ( t == QSizePolicy::Minimum )
- return 1;
- if ( t == QSizePolicy::Maximum )
- return 2;
- if ( t == QSizePolicy::Preferred )
- return 3;
- if ( t == QSizePolicy::MinimumExpanding )
- return 4;
- if ( t == QSizePolicy::Expanding )
- return 5;
- if ( t == QSizePolicy::Ignored )
- return 6;
- return 0;
-}
-
-QString size_type_to_string( QSizePolicy::Policy t )
-{
- if ( t == QSizePolicy::Fixed )
- return QString::fromUtf8("Fixed");
- if ( t == QSizePolicy::Minimum )
- return QString::fromUtf8("Minimum");
- if ( t == QSizePolicy::Maximum )
- return QString::fromUtf8("Maximum");
- if ( t == QSizePolicy::Preferred )
- return QString::fromUtf8("Preferred");
- if ( t == QSizePolicy::MinimumExpanding )
- return QString::fromUtf8("MinimumExpanding");
- if ( t == QSizePolicy::Expanding )
- return QString::fromUtf8("Expanding");
- if ( t == QSizePolicy::Ignored )
- return QString::fromUtf8("Ignored");
- return QString();
-}
-
-QSizePolicy::Policy int_to_size_type( int i )
-{
- if ( i == 0 )
- return QSizePolicy::Fixed;
- if ( i == 1 )
- return QSizePolicy::Minimum;
- if ( i == 2 )
- return QSizePolicy::Maximum;
- if ( i == 3 )
- return QSizePolicy::Preferred;
- if ( i == 4 )
- return QSizePolicy::MinimumExpanding;
- if ( i == 5 )
- return QSizePolicy::Expanding;
- if ( i == 6 )
- return QSizePolicy::Ignored;
- return QSizePolicy::Preferred;
-}
-
-} // namespace qdesigner_internal
-
-QT_END_NAMESPACE
diff --git a/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp b/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp
index e251511..8e7312f 100644
--- a/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp
+++ b/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp
@@ -83,6 +83,7 @@ static const char *validationModesAttributeC = "validationMode";
static const char *superPaletteAttributeC = "superPalette";
static const char *defaultResourceAttributeC = "defaultResource";
static const char *fontAttributeC = "font";
+static const char *themeAttributeC = "theme";
class DesignerFlagPropertyType
{
@@ -113,13 +114,15 @@ public:
void setTextPropertyValidationMode(TextPropertyValidationMode vm);
void setRichTextDefaultFont(const QFont &font) { m_richTextDefaultFont = font; }
- QFont richTextDefaultFont() const { return m_richTextDefaultFont; }
+ QFont richTextDefaultFont() const { return m_richTextDefaultFont; }
void setSpacing(int spacing);
TextPropertyEditor::UpdateMode updateMode() const { return m_editor->updateMode(); }
void setUpdateMode(TextPropertyEditor::UpdateMode um) { m_editor->setUpdateMode(um); }
+ void setIconThemeModeEnabled(bool enable);
+
public slots:
void setText(const QString &text);
@@ -132,6 +135,8 @@ private slots:
void fileActionActivated();
private:
TextPropertyEditor *m_editor;
+ IconThemeEditor *m_themeEditor;
+ bool m_iconThemeModeEnabled;
QFont m_richTextDefaultFont;
QToolButton *m_button;
QMenu *m_menu;
@@ -144,6 +149,8 @@ private:
TextEditor::TextEditor(QDesignerFormEditorInterface *core, QWidget *parent) :
QWidget(parent),
m_editor(new TextPropertyEditor(this)),
+ m_themeEditor(new IconThemeEditor(this, false)),
+ m_iconThemeModeEnabled(false),
m_richTextDefaultFont(QApplication::font()),
m_button(new QToolButton(this)),
m_menu(new QMenu(this)),
@@ -152,7 +159,11 @@ TextEditor::TextEditor(QDesignerFormEditorInterface *core, QWidget *parent) :
m_layout(new QHBoxLayout(this)),
m_core(core)
{
+ m_themeEditor->setVisible(false);
+ m_button->setVisible(false);
+
m_layout->addWidget(m_editor);
+ m_layout->addWidget(m_themeEditor);
m_button->setText(tr("..."));
m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
m_button->setFixedWidth(20);
@@ -163,9 +174,10 @@ TextEditor::TextEditor(QDesignerFormEditorInterface *core, QWidget *parent) :
connect(m_resourceAction, SIGNAL(triggered()), this, SLOT(resourceActionActivated()));
connect(m_fileAction, SIGNAL(triggered()), this, SLOT(fileActionActivated()));
connect(m_editor, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged(QString)));
+ connect(m_themeEditor, SIGNAL(edited(QString)), this, SIGNAL(textChanged(QString)));
connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
+
setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
- m_button->setVisible(false);
setFocusProxy(m_editor);
m_menu->addAction(m_resourceAction);
@@ -177,6 +189,22 @@ void TextEditor::setSpacing(int spacing)
m_layout->setSpacing(spacing);
}
+void TextEditor::setIconThemeModeEnabled(bool enable)
+{
+ if (m_iconThemeModeEnabled == enable)
+ return; // nothing changes
+ m_iconThemeModeEnabled = enable;
+ m_editor->setVisible(!enable);
+ m_themeEditor->setVisible(enable);
+ if (enable) {
+ m_themeEditor->setTheme(m_editor->text());
+ setFocusProxy(m_themeEditor);
+ } else {
+ m_editor->setText(m_themeEditor->theme());
+ setFocusProxy(m_editor);
+ }
+}
+
TextPropertyValidationMode TextEditor::textPropertyValidationMode() const
{
return m_editor->textPropertyValidationMode();
@@ -199,7 +227,10 @@ void TextEditor::setTextPropertyValidationMode(TextPropertyValidationMode vm)
void TextEditor::setText(const QString &text)
{
- m_editor->setText(text);
+ if (m_iconThemeModeEnabled)
+ m_themeEditor->setTheme(text);
+ else
+ m_editor->setText(text);
}
void TextEditor::buttonClicked()
@@ -279,6 +310,49 @@ void TextEditor::fileActionActivated()
emit textChanged(newText);
}
+// ------------ ThemeInputDialog
+
+class IconThemeDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ static QString getTheme(QWidget *parent, const QString &theme, bool *ok);
+private:
+ IconThemeDialog(QWidget *parent);
+ IconThemeEditor *m_editor;
+};
+
+IconThemeDialog::IconThemeDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ setWindowTitle(tr("Set Icon From Theme"));
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ QLabel *label = new QLabel(tr("Input icon name from the current theme:"), this);
+ m_editor = new IconThemeEditor(this);
+ QDialogButtonBox *buttons = new QDialogButtonBox(this);
+ buttons->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+
+ layout->addWidget(label);
+ layout->addWidget(m_editor);
+ layout->addWidget(buttons);
+
+ connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
+}
+
+QString IconThemeDialog::getTheme(QWidget *parent, const QString &theme, bool *ok)
+{
+ IconThemeDialog dlg(parent);
+ dlg.m_editor->setTheme(theme);
+ if (dlg.exec() == QDialog::Accepted) {
+ *ok = true;
+ return dlg.m_editor->theme();
+ }
+ *ok = false;
+ return QString();
+}
+
// ------------ PixmapEditor
class PixmapEditor : public QWidget
{
@@ -288,12 +362,15 @@ public:
void setSpacing(int spacing);
void setPixmapCache(DesignerPixmapCache *cache);
+ void setIconThemeModeEnabled(bool enabled);
public slots:
void setPath(const QString &path);
+ void setTheme(const QString &theme);
void setDefaultPixmap(const QPixmap &pixmap);
signals:
void pathChanged(const QString &path);
+ void themeChanged(const QString &theme);
protected:
void contextMenuEvent(QContextMenuEvent *event);
@@ -302,32 +379,39 @@ private slots:
void defaultActionActivated();
void resourceActionActivated();
void fileActionActivated();
+ void themeActionActivated();
void copyActionActivated();
void pasteActionActivated();
void clipboardDataChanged();
private:
+ void updateLabels();
+ bool m_iconThemeModeEnabled;
QDesignerFormEditorInterface *m_core;
QLabel *m_pixmapLabel;
QLabel *m_pathLabel;
QToolButton *m_button;
QAction *m_resourceAction;
QAction *m_fileAction;
+ QAction *m_themeAction;
QAction *m_copyAction;
QAction *m_pasteAction;
QHBoxLayout *m_layout;
QPixmap m_defaultPixmap;
QString m_path;
+ QString m_theme;
DesignerPixmapCache *m_pixmapCache;
};
PixmapEditor::PixmapEditor(QDesignerFormEditorInterface *core, QWidget *parent) :
QWidget(parent),
+ m_iconThemeModeEnabled(false),
m_core(core),
m_pixmapLabel(new QLabel(this)),
m_pathLabel(new QLabel(this)),
m_button(new QToolButton(this)),
m_resourceAction(new QAction(tr("Choose Resource..."), this)),
m_fileAction(new QAction(tr("Choose File..."), this)),
+ m_themeAction(new QAction(tr("Set Icon From Theme..."), this)),
m_copyAction(new QAction(createIconSet(QLatin1String("editcopy.png")), tr("Copy Path"), this)),
m_pasteAction(new QAction(createIconSet(QLatin1String("editpaste.png")), tr("Paste Path"), this)),
m_layout(new QHBoxLayout(this)),
@@ -345,10 +429,12 @@ PixmapEditor::PixmapEditor(QDesignerFormEditorInterface *core, QWidget *parent)
m_pixmapLabel->setFixedWidth(16);
m_pixmapLabel->setAlignment(Qt::AlignCenter);
m_pathLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
+ m_themeAction->setVisible(false);
QMenu *menu = new QMenu(this);
menu->addAction(m_resourceAction);
menu->addAction(m_fileAction);
+ menu->addAction(m_themeAction);
m_button->setMenu(menu);
m_button->setText(tr("..."));
@@ -356,6 +442,7 @@ PixmapEditor::PixmapEditor(QDesignerFormEditorInterface *core, QWidget *parent)
connect(m_button, SIGNAL(clicked()), this, SLOT(defaultActionActivated()));
connect(m_resourceAction, SIGNAL(triggered()), this, SLOT(resourceActionActivated()));
connect(m_fileAction, SIGNAL(triggered()), this, SLOT(fileActionActivated()));
+ connect(m_themeAction, SIGNAL(triggered()), this, SLOT(themeActionActivated()));
connect(m_copyAction, SIGNAL(triggered()), this, SLOT(copyActionActivated()));
connect(m_pasteAction, SIGNAL(triggered()), this, SLOT(pasteActionActivated()));
setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored));
@@ -370,6 +457,14 @@ void PixmapEditor::setPixmapCache(DesignerPixmapCache *cache)
m_pixmapCache = cache;
}
+void PixmapEditor::setIconThemeModeEnabled(bool enabled)
+{
+ if (m_iconThemeModeEnabled == enabled)
+ return;
+ m_iconThemeModeEnabled = enabled;
+ m_themeAction->setVisible(enabled);
+}
+
void PixmapEditor::setSpacing(int spacing)
{
m_layout->setSpacing(spacing);
@@ -378,22 +473,40 @@ void PixmapEditor::setSpacing(int spacing)
void PixmapEditor::setPath(const QString &path)
{
m_path = path;
- if (m_path.isEmpty()) {
- m_pathLabel->setText(path);
- m_pixmapLabel->setPixmap(m_defaultPixmap);
- m_copyAction->setEnabled(false);
- } else {
- m_pathLabel->setText(QFileInfo(m_path).fileName());
- if (m_pixmapCache)
- m_pixmapLabel->setPixmap(QIcon(m_pixmapCache->pixmap(PropertySheetPixmapValue(path))).pixmap(16, 16));
+ updateLabels();
+}
+
+void PixmapEditor::setTheme(const QString &theme)
+{
+ m_theme = theme;
+ updateLabels();
+}
+
+void PixmapEditor::updateLabels()
+{
+ if (m_iconThemeModeEnabled && QIcon::hasThemeIcon(m_theme)) {
+ m_pixmapLabel->setPixmap(QIcon::fromTheme(m_theme).pixmap(16, 16));
+ m_pathLabel->setText(tr("[Theme] %1").arg(m_theme));
m_copyAction->setEnabled(true);
+ } else {
+ if (m_path.isEmpty()) {
+ m_pathLabel->setText(m_path);
+ m_pixmapLabel->setPixmap(m_defaultPixmap);
+ m_copyAction->setEnabled(false);
+ } else {
+ m_pathLabel->setText(QFileInfo(m_path).fileName());
+ if (m_pixmapCache)
+ m_pixmapLabel->setPixmap(QIcon(m_pixmapCache->pixmap(PropertySheetPixmapValue(m_path))).pixmap(16, 16));
+ m_copyAction->setEnabled(true);
+ }
}
}
void PixmapEditor::setDefaultPixmap(const QPixmap &pixmap)
{
m_defaultPixmap = QIcon(pixmap).pixmap(16, 16);
- if (m_path.isEmpty())
+ const bool hasThemeIcon = m_iconThemeModeEnabled && QIcon::hasThemeIcon(m_theme);
+ if (!hasThemeIcon && m_path.isEmpty())
m_pixmapLabel->setPixmap(m_defaultPixmap);
}
@@ -408,6 +521,10 @@ void PixmapEditor::contextMenuEvent(QContextMenuEvent *event)
void PixmapEditor::defaultActionActivated()
{
+ if (m_iconThemeModeEnabled && QIcon::hasThemeIcon(m_theme)) {
+ themeActionActivated();
+ return;
+ }
// Default to resource
const PropertySheetPixmapValue::PixmapSource ps = m_path.isEmpty() ? PropertySheetPixmapValue::ResourcePixmap : PropertySheetPixmapValue::getPixmapSource(m_core, m_path);
switch (ps) {
@@ -426,6 +543,7 @@ void PixmapEditor::resourceActionActivated()
const QString oldPath = m_path;
const QString newPath = IconSelector::choosePixmapResource(m_core, m_core->resourceModel(), oldPath, this);
if (!newPath.isEmpty() && newPath != oldPath) {
+ setTheme(QString());
setPath(newPath);
emit pathChanged(newPath);
}
@@ -435,15 +553,30 @@ void PixmapEditor::fileActionActivated()
{
const QString newPath = IconSelector::choosePixmapFile(m_path, m_core->dialogGui(), this);
if (!newPath.isEmpty() && newPath != m_path) {
+ setTheme(QString());
setPath(newPath);
emit pathChanged(newPath);
}
}
+void PixmapEditor::themeActionActivated()
+{
+ bool ok;
+ const QString newTheme = IconThemeDialog::getTheme(this, m_theme, &ok);
+ if (ok && newTheme != m_theme) {
+ setTheme(newTheme);
+ setPath(QString());
+ emit themeChanged(newTheme);
+ }
+}
+
void PixmapEditor::copyActionActivated()
{
QClipboard *clipboard = QApplication::clipboard();
- clipboard->setText(m_path);
+ if (m_iconThemeModeEnabled && QIcon::hasThemeIcon(m_theme))
+ clipboard->setText(m_theme);
+ else
+ clipboard->setText(m_path);
}
void PixmapEditor::pasteActionActivated()
@@ -455,8 +588,15 @@ void PixmapEditor::pasteActionActivated()
QStringList list = text.split(QLatin1Char('\n'));
if (list.size() > 0) {
text = list.at(0);
- setPath(text);
- emit pathChanged(text);
+ if (m_iconThemeModeEnabled && QIcon::hasThemeIcon(text)) {
+ setTheme(text);
+ setPath(QString());
+ emit themeChanged(text);
+ } else {
+ setPath(text);
+ setTheme(QString());
+ emit pathChanged(text);
+ }
}
}
}
@@ -807,8 +947,13 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari
} else if (QtProperty *iProperty = m_iconSubPropertyToProperty.value(property, 0)) {
QtVariantProperty *iconProperty = variantProperty(iProperty);
PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(iconProperty->value());
- QPair<QIcon::Mode, QIcon::State> pair = m_iconSubPropertyToState.value(property);
- icon.setPixmap(pair.first, pair.second, qvariant_cast<PropertySheetPixmapValue>(value));
+ QMap<QtProperty *, QPair<QIcon::Mode, QIcon::State> >::ConstIterator itState = m_iconSubPropertyToState.constFind(property);
+ if (itState != m_iconSubPropertyToState.constEnd()) {
+ QPair<QIcon::Mode, QIcon::State> pair = m_iconSubPropertyToState.value(property);
+ icon.setPixmap(pair.first, pair.second, qvariant_cast<PropertySheetPixmapValue>(value));
+ } else { // must be theme property
+ icon.setTheme(value.toString());
+ }
QtProperty *origSourceOfChange = m_sourceOfChange;
if (!origSourceOfChange)
m_sourceOfChange = property;
@@ -859,12 +1004,16 @@ void DesignerPropertyManager::slotPropertyDestroyed(QtProperty *property)
m_keySequenceToDisambiguation.remove(keySequenceDisambiguationProperty);
m_disambiguationToKeySequence.remove(property);
} else if (QtProperty *iconProperty = m_iconSubPropertyToProperty.value(property, 0)) {
- QMap<QtProperty *, QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> >::iterator it =
- m_propertyToIconSubProperties.find(iconProperty);
- QPair<QIcon::Mode, QIcon::State> state = m_iconSubPropertyToState.value(property);
- QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> &propertyList = it.value();
- propertyList.remove(state);
- m_iconSubPropertyToState.remove(property);
+ if (m_propertyToTheme.value(iconProperty) == property) {
+ m_propertyToTheme.remove(iconProperty);
+ } else {
+ QMap<QtProperty *, QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> >::iterator it =
+ m_propertyToIconSubProperties.find(iconProperty);
+ QPair<QIcon::Mode, QIcon::State> state = m_iconSubPropertyToState.value(property);
+ QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> &propertyList = it.value();
+ propertyList.remove(state);
+ m_iconSubPropertyToState.remove(property);
+ }
m_iconSubPropertyToProperty.remove(property);
} else {
m_fontManager.slotPropertyDestroyed(property);
@@ -887,6 +1036,7 @@ QStringList DesignerPropertyManager::attributes(int propertyType) const
} else if (propertyType == designerStringTypeId() || propertyType == QVariant::String) {
list.append(QLatin1String(validationModesAttributeC));
list.append(QLatin1String(fontAttributeC));
+ list.append(QLatin1String(themeAttributeC));
} else if (propertyType == QVariant::Palette) {
list.append(QLatin1String(superPaletteAttributeC));
}
@@ -912,6 +1062,8 @@ int DesignerPropertyManager::attributeType(int propertyType, const QString &attr
return QVariant::Int;
if (attribute == QLatin1String(fontAttributeC))
return QVariant::Font;
+ if (attribute == QLatin1String(themeAttributeC))
+ return QVariant::Bool;
}
if (propertyType == QVariant::Palette && attribute == QLatin1String(superPaletteAttributeC))
return QVariant::Palette;
@@ -949,6 +1101,12 @@ QVariant DesignerPropertyManager::attributeValue(const QtProperty *property, con
return it.value();
}
+ if (attribute == QLatin1String(themeAttributeC)) {
+ const PropertyBoolMap::const_iterator it = m_stringThemeAttributes.constFind(prop);
+ if (it != m_stringThemeAttributes.constEnd())
+ return it.value();
+ }
+
if (attribute == QLatin1String(superPaletteAttributeC)) {
PropertyPaletteDataMap::const_iterator it = m_paletteValues.constFind(prop);
if (it != m_paletteValues.constEnd())
@@ -1057,6 +1215,21 @@ void DesignerPropertyManager::setAttribute(QtProperty *property,
it.value() = newValue;
emit attributeChanged(property, attribute, newValue);
+ } else if (attribute == QLatin1String(themeAttributeC) && m_stringThemeAttributes.contains(property)) {
+ if (value.userType() != QVariant::Bool)
+ return;
+
+ const PropertyBoolMap::iterator it = m_stringThemeAttributes.find(property);
+ const bool oldValue = it.value();
+
+ const bool newValue = value.toBool();
+
+ if (oldValue == newValue)
+ return;
+
+ it.value() = newValue;
+
+ emit attributeChanged(property, attribute, newValue);
} else if (attribute == QLatin1String(superPaletteAttributeC) && m_paletteValues.contains(property)) {
if (value.userType() != QVariant::Palette)
return;
@@ -1234,7 +1407,11 @@ QString DesignerPropertyManager::valueText(const QtProperty *property) const
return inherited;
}
if (m_iconValues.contains(const_cast<QtProperty *>(property))) {
- const PropertySheetIconValue::ModeStateToPixmapMap paths = m_iconValues.value(const_cast<QtProperty *>(property)).paths();
+ const PropertySheetIconValue icon = m_iconValues.value(const_cast<QtProperty *>(property));
+ const QString theme = icon.theme();
+ if (!theme.isEmpty() && QIcon::hasThemeIcon(theme))
+ return tr("[Theme] %1").arg(theme);
+ const PropertySheetIconValue::ModeStateToPixmapMap paths = icon.paths();
const PropertySheetIconValue::ModeStateToPixmapMap::const_iterator it = paths.constFind(qMakePair(QIcon::Normal, QIcon::Off));
if (it == paths.constEnd())
return QString();
@@ -1339,6 +1516,8 @@ QIcon DesignerPropertyManager::valueIcon(const QtProperty *property) const
qdesigner_internal::FormWindowBase *fwb = qobject_cast<qdesigner_internal::FormWindowBase *>(formWindow);
if (fwb)
return fwb->pixmapCache()->pixmap(m_pixmapValues.value(const_cast<QtProperty *>(property)));
+ } else if (m_stringThemeAttributes.value(const_cast<QtProperty *>(property), false)) {
+ return QIcon::fromTheme(value(property).toString());
} else {
QIcon rc;
if (m_brushManager.valueIcon(property, &rc))
@@ -1604,6 +1783,12 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val
subProperty->setAttribute(QLatin1String(defaultResourceAttributeC),
defaultIcon.pixmap(16, 16, pair.first, pair.second));
}
+ QtVariantProperty *themeSubProperty = variantProperty(m_propertyToTheme.value(property));
+ if (themeSubProperty) {
+ const QString theme = icon.theme();
+ themeSubProperty->setModified(!theme.isEmpty());
+ themeSubProperty->setValue(theme);
+ }
emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(icon));
emit propertyChanged(property);
@@ -1766,6 +1951,7 @@ void DesignerPropertyManager::initializeProperty(QtProperty *property)
case QVariant::String:
m_stringAttributes[property] = ValidationSingleLine;
m_stringFontAttributes[property] = QApplication::font();
+ m_stringThemeAttributes[property] = false;
break;
case QVariant::UInt:
m_uintValues[property] = 0;
@@ -1820,6 +2006,13 @@ void DesignerPropertyManager::initializeProperty(QtProperty *property)
m_iconValues[property] = PropertySheetIconValue();
m_defaultIcons[property] = QIcon();
+ QtVariantProperty *themeProp = addProperty(QVariant::String, tr("Theme"));
+ themeProp->setAttribute(QLatin1String(themeAttributeC), true);
+ m_iconSubPropertyToProperty[themeProp] = property;
+ m_propertyToTheme[property] = themeProp;
+ m_resetMap[themeProp] = true;
+ property->addSubProperty(themeProp);
+
createIconSubProperty(property, QIcon::Normal, QIcon::Off, tr("Normal Off"));
createIconSubProperty(property, QIcon::Normal, QIcon::On, tr("Normal On"));
createIconSubProperty(property, QIcon::Disabled, QIcon::Off, tr("Disabled Off"));
@@ -1833,6 +2026,7 @@ void DesignerPropertyManager::initializeProperty(QtProperty *property)
m_stringValues[property] = val;
m_stringAttributes[property] = ValidationMultiLine;
m_stringFontAttributes[property] = QApplication::font();
+ m_stringThemeAttributes[property] = false;
QtVariantProperty *translatable = addProperty(QVariant::Bool, tr("translatable"));
translatable->setValue(val.translatable());
@@ -1921,37 +2115,43 @@ void DesignerPropertyManager::uninitializeProperty(QtProperty *property)
QtProperty *stringComment = m_stringToComment.value(property);
if (stringComment) {
delete stringComment;
- m_stringToComment.remove(stringComment);
+ m_commentToString.remove(stringComment);
}
QtProperty *stringTranslatable = m_stringToTranslatable.value(property);
if (stringTranslatable) {
delete stringTranslatable;
- m_stringToTranslatable.remove(stringTranslatable);
+ m_translatableToString.remove(stringTranslatable);
}
QtProperty *stringDisambiguation = m_stringToDisambiguation.value(property);
if (stringDisambiguation) {
delete stringDisambiguation;
- m_stringToDisambiguation.remove(stringDisambiguation);
+ m_disambiguationToString.remove(stringDisambiguation);
}
QtProperty *keySequenceComment = m_keySequenceToComment.value(property);
if (keySequenceComment) {
delete keySequenceComment;
- m_keySequenceToComment.remove(keySequenceComment);
+ m_commentToKeySequence.remove(keySequenceComment);
}
QtProperty *keySequenceTranslatable = m_keySequenceToTranslatable.value(property);
if (keySequenceTranslatable) {
delete keySequenceTranslatable;
- m_keySequenceToTranslatable.remove(keySequenceTranslatable);
+ m_translatableToKeySequence.remove(keySequenceTranslatable);
}
QtProperty *keySequenceDisambiguation = m_keySequenceToDisambiguation.value(property);
if (keySequenceDisambiguation) {
delete keySequenceDisambiguation;
- m_keySequenceToDisambiguation.remove(keySequenceDisambiguation);
+ m_disambiguationToKeySequence.remove(keySequenceDisambiguation);
+ }
+
+ QtProperty *iconTheme = m_propertyToTheme.value(property);
+ if (iconTheme) {
+ delete iconTheme;
+ m_iconSubPropertyToProperty.remove(iconTheme);
}
m_propertyToAlignH.remove(property);
@@ -2010,15 +2210,20 @@ bool DesignerPropertyManager::resetFontSubProperty(QtProperty *property)
bool DesignerPropertyManager::resetIconSubProperty(QtProperty *property)
{
- if (!m_iconSubPropertyToProperty.contains(property))
- return false;
-
- if (!m_pixmapValues.contains(property))
+ QtProperty *iconProperty = m_iconSubPropertyToProperty.value(property);
+ if (!iconProperty)
return false;
- QtVariantProperty *pixmapProperty = variantProperty(property);
- pixmapProperty->setValue(QVariant::fromValue(PropertySheetPixmapValue()));
- return true;
+ if (m_pixmapValues.contains(property)) {
+ QtVariantProperty *pixmapProperty = variantProperty(property);
+ pixmapProperty->setValue(QVariant::fromValue(PropertySheetPixmapValue()));
+ return true;
+ } else if (m_propertyToTheme.contains(iconProperty)) {
+ QtVariantProperty *themeProperty = variantProperty(property);
+ themeProperty->setValue(QString());
+ return true;
+ }
+ return false;
}
// -------- DesignerEditorFactory
@@ -2116,6 +2321,10 @@ void DesignerEditorFactory::slotAttributeChanged(QtProperty *property, const QSt
const QFont font = qvariant_cast<QFont>(value);
applyToEditors(m_stringPropertyToEditors.value(property), &TextEditor::setRichTextDefaultFont, font);
}
+ if (attribute == QLatin1String(themeAttributeC)) {
+ const bool themeEnabled = value.toBool();
+ applyToEditors(m_stringPropertyToEditors.value(property), &TextEditor::setIconThemeModeEnabled, themeEnabled);
+ }
} else if (type == QVariant::Palette && attribute == QLatin1String(superPaletteAttributeC)) {
const QPalette palette = qvariant_cast<QPalette>(value);
applyToEditors(m_palettePropertyToEditors.value(property), &PaletteEditorButton::setSuperPalette, palette);
@@ -2174,14 +2383,18 @@ void DesignerEditorFactory::slotValueChanged(QtProperty *property, const QVarian
applyToEditors(m_stringListPropertyToEditors.value(property), &StringListEditorButton::setStringList, value.toStringList());
break;
default:
- if (type == DesignerPropertyManager::designerIconTypeId())
- applyToEditors(m_iconPropertyToEditors.value(property), &PixmapEditor::setPath, qvariant_cast<PropertySheetIconValue>(value).pixmap(QIcon::Normal, QIcon::Off).path());
- else if (type == DesignerPropertyManager::designerPixmapTypeId())
+ if (type == DesignerPropertyManager::designerIconTypeId()) {
+ PropertySheetIconValue iconValue = qvariant_cast<PropertySheetIconValue>(value);
+ const QString theme = iconValue.theme();
+ applyToEditors(m_iconPropertyToEditors.value(property), &PixmapEditor::setTheme, iconValue.theme());
+ applyToEditors(m_iconPropertyToEditors.value(property), &PixmapEditor::setPath, iconValue.pixmap(QIcon::Normal, QIcon::Off).path());
+ } else if (type == DesignerPropertyManager::designerPixmapTypeId()) {
applyToEditors(m_pixmapPropertyToEditors.value(property), &PixmapEditor::setPath, qvariant_cast<PropertySheetPixmapValue>(value).path());
- else if (type == DesignerPropertyManager::designerStringTypeId())
+ } else if (type == DesignerPropertyManager::designerStringTypeId()) {
applyToEditors(m_stringPropertyToEditors.value(property), &TextEditor::setText, qvariant_cast<PropertySheetStringValue>(value).value());
- else if (type == DesignerPropertyManager::designerKeySequenceTypeId())
+ } else if (type == DesignerPropertyManager::designerKeySequenceTypeId()) {
applyToEditors(m_keySequencePropertyToEditors.value(property), &QtKeySequenceEdit::setKeySequence, qvariant_cast<PropertySheetKeySequenceValue>(value).value());
+ }
break;
}
}
@@ -2215,6 +2428,8 @@ QWidget *DesignerEditorFactory::createEditor(QtVariantPropertyManager *manager,
const QVariant richTextDefaultFont = manager->attributeValue(property, QLatin1String(fontAttributeC));
if (richTextDefaultFont.type() == QVariant::Font)
ed->setRichTextDefaultFont(qvariant_cast<QFont>(richTextDefaultFont));
+ const bool themeEnabled = manager->attributeValue(property, QLatin1String(themeAttributeC)).toBool();
+ ed->setIconThemeModeEnabled(themeEnabled);
m_stringPropertyToEditors[property].append(ed);
m_editorToStringProperty[ed] = property;
connect(ed, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
@@ -2308,7 +2523,9 @@ QWidget *DesignerEditorFactory::createEditor(QtVariantPropertyManager *manager,
} else if (type == DesignerPropertyManager::designerIconTypeId()) {
PixmapEditor *ed = new PixmapEditor(m_core, parent);
ed->setPixmapCache(m_fwb->pixmapCache());
+ ed->setIconThemeModeEnabled(true);
PropertySheetIconValue value = qvariant_cast<PropertySheetIconValue>(manager->value(property));
+ ed->setTheme(value.theme());
ed->setPath(value.pixmap(QIcon::Normal, QIcon::Off).path());
QPixmap defaultPixmap;
if (!property->isModified())
@@ -2321,6 +2538,7 @@ QWidget *DesignerEditorFactory::createEditor(QtVariantPropertyManager *manager,
m_editorToIconProperty[ed] = property;
connect(ed, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
connect(ed, SIGNAL(pathChanged(QString)), this, SLOT(slotIconChanged(QString)));
+ connect(ed, SIGNAL(themeChanged(QString)), this, SLOT(slotIconThemeChanged(QString)));
editor = ed;
} else if (type == DesignerPropertyManager::designerStringTypeId()) {
const TextPropertyValidationMode tvm = static_cast<TextPropertyValidationMode>(manager->attributeValue(property, QLatin1String(validationModesAttributeC)).toInt());
@@ -2512,6 +2730,14 @@ void DesignerEditorFactory::slotIconChanged(const QString &value)
QVariant::fromValue(PropertySheetIconValue(PropertySheetPixmapValue(value))));
}
+void DesignerEditorFactory::slotIconThemeChanged(const QString &value)
+{
+ PropertySheetIconValue icon;
+ icon.setTheme(value);
+ updateManager(this, &m_changingPropertyValue, m_editorToIconProperty, qobject_cast<QWidget *>(sender()),
+ QVariant::fromValue(icon));
+}
+
void DesignerEditorFactory::slotStringListChanged(const QStringList &value)
{
updateManager(this, &m_changingPropertyValue, m_editorToStringListProperty, qobject_cast<QWidget *>(sender()), QVariant::fromValue(value));
diff --git a/tools/designer/src/components/propertyeditor/designerpropertymanager.h b/tools/designer/src/components/propertyeditor/designerpropertymanager.h
index 11f900b..03e3dca 100644
--- a/tools/designer/src/components/propertyeditor/designerpropertymanager.h
+++ b/tools/designer/src/components/propertyeditor/designerpropertymanager.h
@@ -180,6 +180,7 @@ private:
QMap<QtProperty *, QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> > m_propertyToIconSubProperties;
QMap<QtProperty *, QPair<QIcon::Mode, QIcon::State> > m_iconSubPropertyToState;
PropertyToPropertyMap m_iconSubPropertyToProperty;
+ PropertyToPropertyMap m_propertyToTheme;
QMap<QtProperty *, qdesigner_internal::PropertySheetStringValue> m_stringValues;
QMap<QtProperty *, QtProperty *> m_stringToComment;
@@ -221,6 +222,7 @@ private:
PropertyIntMap m_stringAttributes;
typedef QMap<QtProperty *, QFont> PropertyFontMap;
PropertyFontMap m_stringFontAttributes;
+ PropertyBoolMap m_stringThemeAttributes;
BrushPropertyManager m_brushManager;
FontPropertyManager m_fontManager;
@@ -261,6 +263,7 @@ private slots:
void slotPaletteChanged(const QPalette &value);
void slotPixmapChanged(const QString &value);
void slotIconChanged(const QString &value);
+ void slotIconThemeChanged(const QString &value);
void slotUintChanged(const QString &value);
void slotLongLongChanged(const QString &value);
void slotULongLongChanged(const QString &value);
diff --git a/tools/designer/src/components/propertyeditor/propertyeditor.pri b/tools/designer/src/components/propertyeditor/propertyeditor.pri
index 7d2e7cb..bb1afdb 100644
--- a/tools/designer/src/components/propertyeditor/propertyeditor.pri
+++ b/tools/designer/src/components/propertyeditor/propertyeditor.pri
@@ -45,10 +45,8 @@ SOURCES += $$PWD/propertyeditor.cpp \
HEADERS += \
$$PWD/propertyeditor_global.h \
- $$PWD/defs.h \
$$PWD/qlonglongvalidator.h
-SOURCES += $$PWD/defs.cpp \
- $$PWD/qlonglongvalidator.cpp
+SOURCES += $$PWD/qlonglongvalidator.cpp
RESOURCES += $$PWD/propertyeditor.qrc
diff --git a/tools/designer/src/components/taskmenu/itemlisteditor.cpp b/tools/designer/src/components/taskmenu/itemlisteditor.cpp
index 29fe0c9..b2ca134 100644
--- a/tools/designer/src/components/taskmenu/itemlisteditor.cpp
+++ b/tools/designer/src/components/taskmenu/itemlisteditor.cpp
@@ -114,20 +114,20 @@ void AbstractItemEditor::keyPressEvent(QKeyEvent *e)
}
static const char * const itemFlagNames[] = {
- "Selectable",
- "Editable",
- "DragEnabled",
- "DropEnabled",
- "UserCheckable",
- "Enabled",
- "Tristate",
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Selectable"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Editable"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "DragEnabled"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "DropEnabled"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "UserCheckable"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Enabled"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Tristate"),
0
};
static const char * const checkStateNames[] = {
- "Unchecked",
- "PartiallyChecked",
- "Checked",
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Unchecked"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "PartiallyChecked"),
+ QT_TRANSLATE_NOOP("AbstractItemEditor", "Checked"),
0
};
@@ -135,7 +135,7 @@ static QStringList c2qStringList(const char * const in[])
{
QStringList out;
for (int i = 0; in[i]; i++)
- out << QLatin1String(in[i]);
+ out << AbstractItemEditor::tr(in[i]);
return out;
}
diff --git a/tools/designer/src/lib/sdk/abstractintegration.cpp b/tools/designer/src/lib/sdk/abstractintegration.cpp
index c5a60db..3924db6 100644
--- a/tools/designer/src/lib/sdk/abstractintegration.cpp
+++ b/tools/designer/src/lib/sdk/abstractintegration.cpp
@@ -42,13 +42,64 @@
#include "abstractintegration.h"
#include "abstractformeditor.h"
+#include <QtCore/QVariant>
+#include <QtCore/QSharedPointer>
+
+QT_BEGIN_NAMESPACE
+
+// Add 'private' struct as a dynamic property.
+
+static const char privatePropertyC[] = "_q_integrationprivate";
+
+struct QDesignerIntegrationInterfacePrivate {
+ QDesignerIntegrationInterfacePrivate() :
+ headerSuffix(QLatin1String(".h")),
+ headerLowercase(true) {}
+
+ QString headerSuffix;
+ bool headerLowercase;
+};
+
+typedef QSharedPointer<QDesignerIntegrationInterfacePrivate> QDesignerIntegrationInterfacePrivatePtr;
+
+QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QDesignerIntegrationInterfacePrivatePtr))
QT_BEGIN_NAMESPACE
+static QDesignerIntegrationInterfacePrivatePtr integrationD(const QObject *o)
+{
+ const QVariant property = o->property(privatePropertyC);
+ Q_ASSERT(qVariantCanConvert<QDesignerIntegrationInterfacePrivatePtr>(property));
+ return qvariant_cast<QDesignerIntegrationInterfacePrivatePtr>(property);
+}
+
QDesignerIntegrationInterface::QDesignerIntegrationInterface(QDesignerFormEditorInterface *core, QObject *parent)
: QObject(parent),
m_core(core)
{
core->setIntegration(this);
+ const QDesignerIntegrationInterfacePrivatePtr d(new QDesignerIntegrationInterfacePrivate);
+ setProperty(privatePropertyC, qVariantFromValue<QDesignerIntegrationInterfacePrivatePtr>(d));
+}
+
+QString QDesignerIntegrationInterface::headerSuffix() const
+{
+ return integrationD(this)->headerSuffix;
+}
+
+void QDesignerIntegrationInterface::setHeaderSuffix(const QString &headerSuffix)
+{
+ integrationD(this)->headerSuffix = headerSuffix;
+}
+
+bool QDesignerIntegrationInterface::isHeaderLowercase() const
+{
+ return integrationD(this)->headerLowercase;
+}
+
+void QDesignerIntegrationInterface::setHeaderLowercase(bool headerLowercase)
+{
+ integrationD(this)->headerLowercase = headerLowercase;
}
QT_END_NAMESPACE
diff --git a/tools/designer/src/lib/sdk/abstractintegration.h b/tools/designer/src/lib/sdk/abstractintegration.h
index 9b2b856..acac711 100644
--- a/tools/designer/src/lib/sdk/abstractintegration.h
+++ b/tools/designer/src/lib/sdk/abstractintegration.h
@@ -45,6 +45,7 @@
#include <QtDesigner/sdk_global.h>
#include <QtCore/QObject>
+#include <QtCore/QString>
QT_BEGIN_HEADER
@@ -55,6 +56,9 @@ class QDesignerFormEditorInterface;
class QDESIGNER_SDK_EXPORT QDesignerIntegrationInterface: public QObject
{
Q_OBJECT
+ Q_PROPERTY(QString headerSuffix READ headerSuffix WRITE setHeaderSuffix)
+ Q_PROPERTY(bool headerLowercase READ isHeaderLowercase WRITE setHeaderLowercase)
+
public:
QDesignerIntegrationInterface(QDesignerFormEditorInterface *core, QObject *parent = 0);
@@ -62,6 +66,12 @@ public:
virtual QWidget *containerWindow(QWidget *widget) const = 0;
+ QString headerSuffix() const;
+ void setHeaderSuffix(const QString &headerSuffix);
+
+ bool isHeaderLowercase() const;
+ void setHeaderLowercase(bool headerLowerCase);
+
private:
QDesignerFormEditorInterface *m_core;
};
diff --git a/tools/designer/src/lib/shared/actioneditor.cpp b/tools/designer/src/lib/shared/actioneditor.cpp
index d3716ca..9664a22 100644
--- a/tools/designer/src/lib/shared/actioneditor.cpp
+++ b/tools/designer/src/lib/shared/actioneditor.cpp
@@ -445,7 +445,6 @@ void ActionEditor::slotNewAction()
if (dlg.exec() == QDialog::Accepted) {
const ActionData actionData = dlg.actionData();
m_actionView->clearSelection();
-
QAction *action = new QAction(formWindow());
action->setObjectName(actionData.name);
formWindow()->ensureUniqueObjectName(action);
@@ -480,7 +479,7 @@ static inline bool isSameIcon(const QIcon &i1, const QIcon &i2)
static QDesignerFormWindowCommand *setIconPropertyCommand(const PropertySheetIconValue &newIcon, QAction *action, QDesignerFormWindowInterface *fw)
{
const QString iconProperty = QLatin1String(iconPropertyC);
- if (newIcon.paths().isEmpty()) {
+ if (newIcon.isEmpty()) {
ResetPropertyCommand *cmd = new ResetPropertyCommand(fw);
cmd->init(action, iconProperty);
return cmd;
diff --git a/tools/designer/src/lib/shared/actionrepository.cpp b/tools/designer/src/lib/shared/actionrepository.cpp
index 8df6f83..40801f2 100644
--- a/tools/designer/src/lib/shared/actionrepository.cpp
+++ b/tools/designer/src/lib/shared/actionrepository.cpp
@@ -397,9 +397,10 @@ void ActionTreeView::contextMenuEvent(QContextMenuEvent *event)
emit contextMenuRequested(event, m_model->actionAt(indexAt(event->pos())));
}
-void ActionTreeView::currentChanged(const QModelIndex &current, const QModelIndex &/*previous*/)
+void ActionTreeView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
{
emit currentChanged(m_model->actionAt(current));
+ QTreeView::currentChanged(current, previous);
}
void ActionTreeView::slotActivated(const QModelIndex &index)
@@ -478,9 +479,10 @@ void ActionListView::contextMenuEvent(QContextMenuEvent *event)
emit contextMenuRequested(event, m_model->actionAt(indexAt(event->pos())));
}
-void ActionListView::currentChanged(const QModelIndex &current, const QModelIndex & /*previous*/)
+void ActionListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
{
emit currentChanged(m_model->actionAt(current));
+ QListView::currentChanged(current, previous);
}
void ActionListView::slotActivated(const QModelIndex &index)
diff --git a/tools/designer/src/lib/shared/iconselector.cpp b/tools/designer/src/lib/shared/iconselector.cpp
index 4bb7430..ef20cd2 100644
--- a/tools/designer/src/lib/shared/iconselector.cpp
+++ b/tools/designer/src/lib/shared/iconselector.cpp
@@ -67,8 +67,12 @@
#include <QtGui/QImageReader>
#include <QtGui/QDialogButtonBox>
#include <QtGui/QVBoxLayout>
+#include <QtGui/QLineEdit>
+#include <QtGui/QLabel>
+#include <QtGui/QValidator>
#include <QtCore/QDebug>
+
QT_BEGIN_NAMESPACE
namespace qdesigner_internal {
@@ -181,6 +185,14 @@ LanguageResourceDialog* LanguageResourceDialog::create(QDesignerFormEditorInterf
}
// ------------ IconSelectorPrivate
+
+static inline QPixmap emptyPixmap()
+{
+ QImage img(16, 16, QImage::Format_ARGB32_Premultiplied);
+ img.fill(0);
+ return QPixmap::fromImage(img);
+}
+
class IconSelectorPrivate
{
IconSelector *q_ptr;
@@ -201,7 +213,7 @@ public:
QMap<QPair<QIcon::Mode, QIcon::State>, int> m_stateToIndex;
QMap<int, QPair<QIcon::Mode, QIcon::State> > m_indexToState;
- QIcon m_emptyIcon;
+ const QIcon m_emptyIcon;
QComboBox *m_stateComboBox;
QToolButton *m_iconButton;
QAction *m_resetAction;
@@ -215,6 +227,7 @@ public:
IconSelectorPrivate::IconSelectorPrivate() :
q_ptr(0),
+ m_emptyIcon(emptyPixmap()),
m_stateComboBox(0),
m_iconButton(0),
m_resetAction(0),
@@ -449,10 +462,6 @@ IconSelector::IconSelector(QWidget *parent) :
d_ptr->m_stateToName << qMakePair(qMakePair(QIcon::Selected, QIcon::Off), tr("Selected Off") );
d_ptr->m_stateToName << qMakePair(qMakePair(QIcon::Selected, QIcon::On), tr("Selected On") );
- QImage img(16, 16, QImage::Format_ARGB32_Premultiplied);
- img.fill(0);
- d_ptr->m_emptyIcon = QIcon(QPixmap::fromImage(img));
-
QMenu *setMenu = new QMenu(this);
QAction *setResourceAction = new QAction(tr("Choose Resource..."), this);
@@ -535,9 +544,112 @@ void IconSelector::setPixmapCache(DesignerPixmapCache *pixmapCache)
d_ptr->slotUpdate();
}
+// --- IconThemeEditor
+
+// Validator for theme line edit, accepts empty or non-blank strings.
+class BlankSuppressingValidator : public QValidator {
+public:
+ explicit BlankSuppressingValidator(QObject * parent = 0) : QValidator(parent) {}
+
+ virtual State validate(QString &input, int &pos) const {
+ const int blankPos = input.indexOf(QLatin1Char(' '));
+ if (blankPos != -1) {
+ pos = blankPos;
+ return Invalid;
+ }
+ return Acceptable;
+ }
+};
+
+struct IconThemeEditorPrivate {
+ IconThemeEditorPrivate();
+
+ const QPixmap m_emptyPixmap;
+ QLineEdit *m_themeLineEdit;
+ QLabel *m_themeLabel;
+};
+
+IconThemeEditorPrivate::IconThemeEditorPrivate() :
+ m_emptyPixmap(emptyPixmap()),
+ m_themeLineEdit(new QLineEdit),
+ m_themeLabel(new QLabel)
+{
+}
+
+IconThemeEditor::IconThemeEditor(QWidget *parent, bool wantResetButton) :
+ QWidget (parent), d(new IconThemeEditorPrivate)
+{
+ QHBoxLayout *mainHLayout = new QHBoxLayout;
+ mainHLayout->setMargin(0);
+
+ // Vertically center theme preview label
+ d->m_themeLabel->setPixmap(d->m_emptyPixmap);
+
+ QVBoxLayout *themeLabelVLayout = new QVBoxLayout;
+ d->m_themeLabel->setMargin(1);
+ themeLabelVLayout->setMargin(0);
+ themeLabelVLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
+ themeLabelVLayout->addWidget(d->m_themeLabel);
+ themeLabelVLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
+ mainHLayout->addLayout(themeLabelVLayout);
+
+ d->m_themeLineEdit = new QLineEdit;
+ d->m_themeLineEdit->setValidator(new BlankSuppressingValidator(d->m_themeLineEdit));
+ connect(d->m_themeLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotChanged(QString)));
+ connect(d->m_themeLineEdit, SIGNAL(textEdited(QString)), this, SIGNAL(edited(QString)));
+ mainHLayout->addWidget(d->m_themeLineEdit);
+
+ if (wantResetButton) {
+ QToolButton *themeResetButton = new QToolButton;
+ themeResetButton->setIcon(createIconSet(QLatin1String("resetproperty.png")));
+ connect(themeResetButton, SIGNAL(clicked()), this, SLOT(reset()));
+ mainHLayout->addWidget(themeResetButton);
+ }
+
+ setLayout(mainHLayout);
+ setFocusProxy(d->m_themeLineEdit);
+}
+
+IconThemeEditor::~IconThemeEditor()
+{
+}
+
+void IconThemeEditor::reset()
+{
+ d->m_themeLineEdit->clear();
+ emit edited(QString());
+}
+
+void IconThemeEditor::slotChanged(const QString &theme)
+{
+ updatePreview(theme);
+}
+
+void IconThemeEditor::updatePreview(const QString &t)
+{
+ // Update preview label with icon.
+ if (t.isEmpty() || !QIcon::hasThemeIcon(t)) { // Empty
+ const QPixmap *currentPixmap = d->m_themeLabel->pixmap();
+ if (currentPixmap == 0 || currentPixmap->serialNumber() != d->m_emptyPixmap.serialNumber())
+ d->m_themeLabel->setPixmap(d->m_emptyPixmap);
+ } else {
+ const QIcon icon = QIcon::fromTheme(t);
+ d->m_themeLabel->setPixmap(icon.pixmap(d->m_emptyPixmap.size()));
+ }
+}
+
+QString IconThemeEditor::theme() const
+{
+ return d->m_themeLineEdit->text();
+}
+
+void IconThemeEditor::setTheme(const QString &t)
+{
+ d->m_themeLineEdit->setText(t);
+}
+
} // qdesigner_internal
QT_END_NAMESPACE
#include "moc_iconselector_p.cpp"
-
diff --git a/tools/designer/src/lib/shared/iconselector_p.h b/tools/designer/src/lib/shared/iconselector_p.h
index 3373f80..5fa8f80 100644
--- a/tools/designer/src/lib/shared/iconselector_p.h
+++ b/tools/designer/src/lib/shared/iconselector_p.h
@@ -55,9 +55,12 @@
#define ICONSELECTOR_H
#include "shared_global_p.h"
+
#include <QtGui/QWidget>
#include <QtGui/QDialog>
+#include <QtCore/QScopedPointer>
+
QT_BEGIN_NAMESPACE
class QtResourceModel;
@@ -70,6 +73,7 @@ namespace qdesigner_internal {
class DesignerIconCache;
class DesignerPixmapCache;
class PropertySheetIconValue;
+struct IconThemeEditorPrivate;
// Resource Dialog that embeds the language-dependent resource widget as returned by the language extension
class QDESIGNER_SHARED_EXPORT LanguageResourceDialog : public QDialog
@@ -133,6 +137,32 @@ private:
Q_PRIVATE_SLOT(d_func(), void slotUpdate())
};
+// IconThemeEditor: Let's the user input theme icon names and shows a preview label.
+class QDESIGNER_SHARED_EXPORT IconThemeEditor : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString theme READ theme WRITE setTheme DESIGNABLE true)
+public:
+ explicit IconThemeEditor(QWidget *parent = 0, bool wantResetButton = true);
+ virtual ~IconThemeEditor();
+
+ QString theme() const;
+ void setTheme(const QString &theme);
+
+signals:
+ void edited(const QString &);
+
+public slots:
+ void reset();
+
+private slots:
+ void slotChanged(const QString &);
+
+private:
+ void updatePreview(const QString &);
+
+ QScopedPointer<IconThemeEditorPrivate> d;
+};
} // namespace qdesigner_internal
diff --git a/tools/designer/src/lib/shared/newactiondialog.cpp b/tools/designer/src/lib/shared/newactiondialog.cpp
index b411464..e6c95f6 100644
--- a/tools/designer/src/lib/shared/newactiondialog.cpp
+++ b/tools/designer/src/lib/shared/newactiondialog.cpp
@@ -133,6 +133,7 @@ ActionData NewActionDialog::actionData() const
rc.name = actionName();
rc.toolTip = m_ui->tooltipEditor->text();
rc.icon = m_ui->iconSelector->icon();
+ rc.icon.setTheme(m_ui->iconThemeEditor->theme());
rc.checkable = m_ui->checkableCheckBox->checkState() == Qt::Checked;
rc.keysequence = PropertySheetKeySequenceValue(m_ui->keySequenceEdit->keySequence());
return rc;
@@ -142,7 +143,8 @@ void NewActionDialog::setActionData(const ActionData &d)
{
m_ui->editActionText->setText(d.text);
m_ui->editObjectName->setText(d.name);
- m_ui->iconSelector->setIcon(d.icon);
+ m_ui->iconSelector->setIcon(d.icon.unthemed());
+ m_ui->iconThemeEditor->setTheme(d.icon.theme());
m_ui->tooltipEditor->setText(d.toolTip);
m_ui->keySequenceEdit->setKeySequence(d.keysequence.value());
m_ui->checkableCheckBox->setCheckState(d.checkable ? Qt::Checked : Qt::Unchecked);
diff --git a/tools/designer/src/lib/shared/newactiondialog.ui b/tools/designer/src/lib/shared/newactiondialog.ui
index f9cafd1..ca5406f 100644
--- a/tools/designer/src/lib/shared/newactiondialog.ui
+++ b/tools/designer/src/lib/shared/newactiondialog.ui
@@ -42,6 +42,14 @@
*********************************************************************</comment>
<class>qdesigner_internal::NewActionDialog</class>
<widget class="QDialog" name="qdesigner_internal::NewActionDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>366</width>
+ <height>270</height>
+ </rect>
+ </property>
<property name="windowTitle">
<string>New Action...</string>
</property>
@@ -81,7 +89,7 @@
<item row="1" column="1">
<widget class="QLineEdit" name="editObjectName"/>
</item>
- <item row="3" column="0">
+ <item row="4" column="0">
<widget class="QLabel" name="iconLabel">
<property name="text">
<string>&amp;Icon:</string>
@@ -91,7 +99,7 @@
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="qdesigner_internal::IconSelector" name="iconSelector" native="true"/>
@@ -111,31 +119,40 @@
</item>
</layout>
</item>
- <item row="5" column="0">
+ <item row="6" column="0">
<widget class="QLabel" name="shortcutLabel">
<property name="text">
- <string>Shortcut:</string>
+ <string>&amp;Shortcut:</string>
+ </property>
+ <property name="buddy">
+ <cstring>keySequenceEdit</cstring>
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="5" column="1">
<widget class="QCheckBox" name="checkableCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
- <item row="4" column="0">
+ <item row="5" column="0">
<widget class="QLabel" name="checkableLabel">
<property name="text">
- <string>Checkable:</string>
+ <string>&amp;Checkable:</string>
+ </property>
+ <property name="buddy">
+ <cstring>checkableCheckBox</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="toolTipLabel">
<property name="text">
- <string>ToolTip:</string>
+ <string>T&amp;oolTip:</string>
+ </property>
+ <property name="buddy">
+ <cstring>tooltipEditor</cstring>
</property>
</widget>
</item>
@@ -160,7 +177,7 @@
</item>
</layout>
</item>
- <item row="5" column="1">
+ <item row="6" column="1">
<layout class="QHBoxLayout" name="keysequenceLayout">
<item>
<widget class="QtKeySequenceEdit" name="keySequenceEdit" native="true">
@@ -181,6 +198,19 @@
</item>
</layout>
</item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="iconThemeLabel">
+ <property name="text">
+ <string>Icon th&amp;eme:</string>
+ </property>
+ <property name="buddy">
+ <cstring>iconThemeEditor</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="qdesigner_internal::IconThemeEditor" name="iconThemeEditor" native="true"/>
+ </item>
</layout>
</item>
<item>
@@ -234,6 +264,12 @@
<header>textpropertyeditor_p.h</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>qdesigner_internal::IconThemeEditor</class>
+ <extends>QWidget</extends>
+ <header>iconselector_p.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<tabstops>
<tabstop>editActionText</tabstop>
diff --git a/tools/designer/src/lib/shared/plugindialog.cpp b/tools/designer/src/lib/shared/plugindialog.cpp
index 3e88043..63ba81c 100644
--- a/tools/designer/src/lib/shared/plugindialog.cpp
+++ b/tools/designer/src/lib/shared/plugindialog.cpp
@@ -102,7 +102,7 @@ void PluginDialog::populateTreeWidget()
const QStringList fileNames = pluginManager->registeredPlugins();
if (!fileNames.isEmpty()) {
- QTreeWidgetItem *topLevelItem = setTopLevelItem(QLatin1String("Loaded Plugins"));
+ QTreeWidgetItem *topLevelItem = setTopLevelItem(tr("Loaded Plugins"));
QFont boldFont = topLevelItem->font(0);
foreach (const QString &fileName, fileNames) {
@@ -125,7 +125,7 @@ void PluginDialog::populateTreeWidget()
const QStringList notLoadedPlugins = pluginManager->failedPlugins();
if (!notLoadedPlugins.isEmpty()) {
- QTreeWidgetItem *topLevelItem = setTopLevelItem(QLatin1String("Failed Plugins"));
+ QTreeWidgetItem *topLevelItem = setTopLevelItem(tr("Failed Plugins"));
const QFont boldFont = topLevelItem->font(0);
foreach (const QString &plugin, notLoadedPlugins) {
const QString failureReason = pluginManager->failureReason(plugin);
diff --git a/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp b/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
index eca6615..1fbfccb 100644
--- a/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
@@ -49,6 +49,7 @@
#include <QtDesigner/QDesignerFormWindowInterface>
#include <QtDesigner/QDesignerPromotionInterface>
#include <QtDesigner/QDesignerWidgetDataBaseItemInterface>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <abstractdialoggui_p.h>
#include <QtCore/QTimer>
@@ -152,8 +153,13 @@ namespace qdesigner_internal {
void NewPromotedClassPanel::slotNameChanged(const QString &className) {
// Suggest a name
if (!className.isEmpty()) {
- QString suggestedHeader = className.toLower().replace(QLatin1String("::"), QString(QLatin1Char('_')));
- suggestedHeader += QLatin1String(".h");
+ const QChar dot(QLatin1Char('.'));
+ QString suggestedHeader = m_promotedHeaderLowerCase ?
+ className.toLower() : className;
+ suggestedHeader.replace(QLatin1String("::"), QString(QLatin1Char('_')));
+ if (!m_promotedHeaderSuffix.startsWith(dot))
+ suggestedHeader += dot;
+ suggestedHeader += m_promotedHeaderSuffix;
const bool blocked = m_includeFileEdit->blockSignals(true);
m_includeFileEdit->setText(suggestedHeader);
@@ -248,6 +254,8 @@ namespace qdesigner_internal {
preselectedBaseClass = baseClassNameList.indexOf(QLatin1String("QFrame"));
NewPromotedClassPanel *newPromotedClassPanel = new NewPromotedClassPanel(baseClassNameList, preselectedBaseClass);
+ newPromotedClassPanel->setPromotedHeaderSuffix(core->integration()->headerSuffix());
+ newPromotedClassPanel->setPromotedHeaderLowerCase(core->integration()->isHeaderLowercase());
connect(newPromotedClassPanel, SIGNAL(newPromotedClass(PromotionParameters,bool*)), this, SLOT(slotNewPromotedClass(PromotionParameters,bool*)));
connect(this, SIGNAL(selectedBaseClassChanged(QString)),
newPromotedClassPanel, SLOT(chooseBaseClass(QString)));
diff --git a/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h b/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h
index 1e63d81..f2a2b2a 100644
--- a/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h
@@ -84,7 +84,13 @@ namespace qdesigner_internal {
int selectedBaseClass = -1,
QWidget *parent = 0);
- signals:
+ QString promotedHeaderSuffix() const { return m_promotedHeaderSuffix; }
+ void setPromotedHeaderSuffix(const QString &s) { m_promotedHeaderSuffix = s; }
+
+ bool isPromotedHeaderLowerCase() const { return m_promotedHeaderLowerCase; }
+ void setPromotedHeaderLowerCase(bool l) { m_promotedHeaderLowerCase = l; }
+
+ signals:
void newPromotedClass(const PromotionParameters &, bool *ok);
public slots:
@@ -100,6 +106,9 @@ namespace qdesigner_internal {
PromotionParameters promotionParameters() const;
void enableButtons();
+ QString m_promotedHeaderSuffix;
+ bool m_promotedHeaderLowerCase;
+
QComboBox *m_baseClassCombo;
QLineEdit *m_classNameEdit;
QLineEdit *m_includeFileEdit;
diff --git a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
index 72ecb8f..ee05adf 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
@@ -1065,8 +1065,8 @@ QVariant QDesignerPropertySheet::resolvePropertyValue(int index, const QVariant
}
if (value.canConvert<qdesigner_internal::PropertySheetIconValue>()) {
- const int pathCount = qvariant_cast<qdesigner_internal::PropertySheetIconValue>(value).paths().count();
- if (pathCount == 0)
+ const unsigned mask = qvariant_cast<qdesigner_internal::PropertySheetIconValue>(value).mask();
+ if (mask == 0)
return defaultResourceProperty(index);
if (d->m_iconCache)
return d->m_iconCache->icon(qvariant_cast<qdesigner_internal::PropertySheetIconValue>(value));
diff --git a/tools/designer/src/lib/shared/qdesigner_utils.cpp b/tools/designer/src/lib/shared/qdesigner_utils.cpp
index de3e387..bd89c53 100644
--- a/tools/designer/src/lib/shared/qdesigner_utils.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_utils.cpp
@@ -52,15 +52,16 @@
#include <QtDesigner/QDesignerTaskMenuExtension>
#include <QtDesigner/QExtensionManager>
-#include <QtGui/QIcon>
-#include <QtGui/QPixmap>
#include <QtCore/QDir>
-
-#include <QtGui/QApplication>
#include <QtCore/QProcess>
#include <QtCore/QLibraryInfo>
#include <QtCore/QDebug>
#include <QtCore/QQueue>
+#include <QtCore/QSharedData>
+
+#include <QtGui/QApplication>
+#include <QtGui/QIcon>
+#include <QtGui/QPixmap>
#include <QtGui/QListWidget>
#include <QtGui/QTreeWidget>
#include <QtGui/QTableWidget>
@@ -314,24 +315,51 @@ namespace qdesigner_internal
}
// ---------- PropertySheetIconValue
- PropertySheetIconValue::PropertySheetIconValue(const PropertySheetPixmapValue &pixmap)
+
+ class PropertySheetIconValueData : public QSharedData {
+ public:
+ PropertySheetIconValue::ModeStateToPixmapMap m_paths;
+ QString m_theme;
+ };
+
+ PropertySheetIconValue::PropertySheetIconValue(const PropertySheetPixmapValue &pixmap) :
+ m_data(new PropertySheetIconValueData)
{
setPixmap(QIcon::Normal, QIcon::Off, pixmap);
}
- PropertySheetIconValue::PropertySheetIconValue()
+ PropertySheetIconValue::PropertySheetIconValue() :
+ m_data(new PropertySheetIconValueData)
+ {
+ }
+
+ PropertySheetIconValue::~PropertySheetIconValue()
{
}
+ PropertySheetIconValue::PropertySheetIconValue(const PropertySheetIconValue &rhs) :
+ m_data(rhs.m_data)
+ {
+ }
+
+ PropertySheetIconValue &PropertySheetIconValue::operator=(const PropertySheetIconValue &rhs)
+ {
+ if (this != &rhs)
+ m_data.operator=(rhs.m_data);
+ return *this;
+ }
+
bool PropertySheetIconValue::equals(const PropertySheetIconValue &rhs) const
{
- return m_paths == rhs.m_paths;
+ return m_data->m_theme == rhs.m_data->m_theme && m_data->m_paths == rhs.m_data->m_paths;
}
bool PropertySheetIconValue::operator<(const PropertySheetIconValue &other) const
{
- QMapIterator<ModeStateKey, PropertySheetPixmapValue> itThis(m_paths);
- QMapIterator<ModeStateKey, PropertySheetPixmapValue> itOther(other.m_paths);
+ if (const int themeCmp = m_data->m_theme.compare(other.m_data->m_theme))
+ return themeCmp < 0;
+ QMapIterator<ModeStateKey, PropertySheetPixmapValue> itThis(m_data->m_paths);
+ QMapIterator<ModeStateKey, PropertySheetPixmapValue> itOther(other.m_data->m_paths);
while (itThis.hasNext() && itOther.hasNext()) {
const ModeStateKey thisPair = itThis.next().key();
const ModeStateKey otherPair = itOther.next().key();
@@ -350,19 +378,34 @@ namespace qdesigner_internal
return false;
}
+ bool PropertySheetIconValue::isEmpty() const
+ {
+ return m_data->m_theme.isEmpty() && m_data->m_paths.isEmpty();
+ }
+
+ QString PropertySheetIconValue::theme() const
+ {
+ return m_data->m_theme;
+ }
+
+ void PropertySheetIconValue::setTheme(const QString &t)
+ {
+ m_data->m_theme = t;
+ }
+
PropertySheetPixmapValue PropertySheetIconValue::pixmap(QIcon::Mode mode, QIcon::State state) const
{
const ModeStateKey pair = qMakePair(mode, state);
- return m_paths.value(pair);
+ return m_data->m_paths.value(pair);
}
void PropertySheetIconValue::setPixmap(QIcon::Mode mode, QIcon::State state, const PropertySheetPixmapValue &pixmap)
{
const ModeStateKey pair = qMakePair(mode, state);
if (pixmap.path().isEmpty())
- m_paths.remove(pair);
+ m_data->m_paths.remove(pair);
else
- m_paths.insert(pair, pixmap);
+ m_data->m_paths.insert(pair, pixmap);
}
QPixmap DesignerPixmapCache::pixmap(const PropertySheetPixmapValue &value) const
@@ -388,16 +431,28 @@ namespace qdesigner_internal
QIcon DesignerIconCache::icon(const PropertySheetIconValue &value) const
{
+ typedef PropertySheetIconValue::ModeStateToPixmapMap::const_iterator ModeStateToPixmapMapConstIt;
+
QMap<PropertySheetIconValue, QIcon>::const_iterator it = m_cache.constFind(value);
if (it != m_cache.constEnd())
return it.value();
+ // Match on the theme first if it is available.
+ if (!value.theme().isEmpty()) {
+ const QString theme = value.theme();
+ if (QIcon::hasThemeIcon(theme)) {
+ const QIcon themeIcon = QIcon::fromTheme(theme);
+ m_cache.insert(value, themeIcon);
+ return themeIcon;
+ }
+ }
+
QIcon icon;
- QMap<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> paths = value.paths();
- QMapIterator<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> itPath(paths);
- while (itPath.hasNext()) {
- QPair<QIcon::Mode, QIcon::State> pair = itPath.next().key();
- icon.addFile(itPath.value().path(), QSize(), pair.first, pair.second);
+ const PropertySheetIconValue::ModeStateToPixmapMap &paths = value.paths();
+ const ModeStateToPixmapMapConstIt cend = paths.constEnd();
+ for (ModeStateToPixmapMapConstIt it = paths.constBegin(); it != cend; ++it) {
+ const QPair<QIcon::Mode, QIcon::State> pair = it.key();
+ icon.addFile(it.value().path(), QSize(), pair.first, pair.second);
}
m_cache.insert(value, icon);
return icon;
@@ -547,50 +602,75 @@ namespace qdesigner_internal
&& (m_translatable == rhs.m_translatable) && (m_disambiguation == rhs.m_disambiguation) && (m_comment == rhs.m_comment);
}
- class StateMap
+
+ /* IconSubPropertyMask: Assign each icon sub-property (pixmaps for the
+ * various states/modes and the theme) a flag bit (see QFont) so that they
+ * can be handled individually when assigning property values to
+ * multiselections in the set-property-commands (that is, do not clobber
+ * other subproperties when assigning just one).
+ * Provide back-and-forth mapping functions for the icon states. */
+
+ enum IconSubPropertyMask {
+ NormalOffIconMask = 0x01,
+ NormalOnIconMask = 0x02,
+ DisabledOffIconMask = 0x04,
+ DisabledOnIconMask = 0x08,
+ ActiveOffIconMask = 0x10,
+ ActiveOnIconMask = 0x20,
+ SelectedOffIconMask = 0x40,
+ SelectedOnIconMask = 0x80,
+ ThemeIconMask = 0x10000
+ };
+
+ static inline uint iconStateToSubPropertyFlag(QIcon::Mode mode, QIcon::State state)
{
- public:
- StateMap()
- {
- m_stateToFlag.insert(qMakePair(QIcon::Normal, QIcon::Off), 0x01);
- m_stateToFlag.insert(qMakePair(QIcon::Normal, QIcon::On), 0x02);
- m_stateToFlag.insert(qMakePair(QIcon::Disabled, QIcon::Off), 0x04);
- m_stateToFlag.insert(qMakePair(QIcon::Disabled, QIcon::On), 0x08);
- m_stateToFlag.insert(qMakePair(QIcon::Active, QIcon::Off), 0x10);
- m_stateToFlag.insert(qMakePair(QIcon::Active, QIcon::On), 0x20);
- m_stateToFlag.insert(qMakePair(QIcon::Selected, QIcon::Off), 0x40);
- m_stateToFlag.insert(qMakePair(QIcon::Selected, QIcon::On), 0x80);
-
- m_flagToState.insert(0x01, qMakePair(QIcon::Normal, QIcon::Off));
- m_flagToState.insert(0x02, qMakePair(QIcon::Normal, QIcon::On));
- m_flagToState.insert(0x04, qMakePair(QIcon::Disabled, QIcon::Off));
- m_flagToState.insert(0x08, qMakePair(QIcon::Disabled, QIcon::On));
- m_flagToState.insert(0x10, qMakePair(QIcon::Active, QIcon::Off));
- m_flagToState.insert(0x20, qMakePair(QIcon::Active, QIcon::On));
- m_flagToState.insert(0x40, qMakePair(QIcon::Selected, QIcon::Off));
- m_flagToState.insert(0x80, qMakePair(QIcon::Selected, QIcon::On));
- }
- uint flag(const QPair<QIcon::Mode, QIcon::State> &pair) const
- {
- return m_stateToFlag.value(pair);
+ switch (mode) {
+ case QIcon::Disabled:
+ return state == QIcon::On ? DisabledOnIconMask : DisabledOffIconMask;
+ case QIcon::Active:
+ return state == QIcon::On ? ActiveOnIconMask : ActiveOffIconMask;
+ case QIcon::Selected:
+ return state == QIcon::On ? SelectedOnIconMask : SelectedOffIconMask;
+ case QIcon::Normal:
+ break;
}
- QPair<QIcon::Mode, QIcon::State> state(uint flag) const
- {
- return m_flagToState.value(flag);
+ return state == QIcon::On ? NormalOnIconMask : NormalOffIconMask;
+ }
+
+ static inline QPair<QIcon::Mode, QIcon::State> subPropertyFlagToIconModeState(unsigned flag)
+ {
+ switch (flag) {
+ case NormalOnIconMask:
+ return qMakePair(QIcon::Normal, QIcon::On);
+ case DisabledOffIconMask:
+ return qMakePair(QIcon::Disabled, QIcon::Off);
+ case DisabledOnIconMask:
+ return qMakePair(QIcon::Disabled, QIcon::On);
+ case ActiveOffIconMask:
+ return qMakePair(QIcon::Active, QIcon::Off);
+ case ActiveOnIconMask:
+ return qMakePair(QIcon::Active, QIcon::On);
+ case SelectedOffIconMask:
+ return qMakePair(QIcon::Selected, QIcon::Off);
+ case SelectedOnIconMask:
+ return qMakePair(QIcon::Selected, QIcon::On);
+ case NormalOffIconMask:
+ default:
+ break;
}
- private:
- QMap<QPair<QIcon::Mode, QIcon::State>, uint > m_stateToFlag;
- QMap<uint, QPair<QIcon::Mode, QIcon::State> > m_flagToState;
- };
-
- Q_GLOBAL_STATIC(StateMap, stateMap)
+ return qMakePair(QIcon::Normal, QIcon::Off);
+ }
uint PropertySheetIconValue::mask() const
{
+ typedef ModeStateToPixmapMap::const_iterator ModeStateToPixmapMapConstIt;
+
uint flags = 0;
- QMapIterator<ModeStateKey, PropertySheetPixmapValue> itPath(m_paths);
- while (itPath.hasNext())
- flags |= stateMap()->flag(itPath.next().key());
+ const ModeStateToPixmapMapConstIt cend = m_data->m_paths.constEnd();
+ for (ModeStateToPixmapMapConstIt it = m_data->m_paths.constBegin(); it != cend; ++it)
+ flags |= iconStateToSubPropertyFlag(it.key().first, it.key().second);
+ if (!m_data->m_theme.isEmpty())
+ flags |= ThemeIconMask;
return flags;
}
@@ -598,30 +678,64 @@ namespace qdesigner_internal
{
uint diffMask = mask() | other.mask();
for (int i = 0; i < 8; i++) {
- uint flag = 1 << i;
+ const uint flag = 1 << i;
if (diffMask & flag) { // if state is set in both icons, compare the values
- const ModeStateKey state = stateMap()->state(flag);
+ const QPair<QIcon::Mode, QIcon::State> state = subPropertyFlagToIconModeState(flag);
if (pixmap(state.first, state.second) == other.pixmap(state.first, state.second))
diffMask &= ~flag;
}
}
+ if ((diffMask & ThemeIconMask) && theme() == other.theme())
+ diffMask &= ~ThemeIconMask;
return diffMask;
}
+ PropertySheetIconValue PropertySheetIconValue::themed() const
+ {
+ PropertySheetIconValue rc(*this);
+ rc.m_data->m_paths.clear();
+ return rc;
+ }
+
+ PropertySheetIconValue PropertySheetIconValue::unthemed() const
+ {
+ PropertySheetIconValue rc(*this);
+ rc.m_data->m_theme.clear();
+ return rc;
+ }
+
void PropertySheetIconValue::assign(const PropertySheetIconValue &other, uint mask)
{
for (int i = 0; i < 8; i++) {
uint flag = 1 << i;
if (mask & flag) {
- const ModeStateKey state = stateMap()->state(flag);
+ const ModeStateKey state = subPropertyFlagToIconModeState(flag);
setPixmap(state.first, state.second, other.pixmap(state.first, state.second));
}
}
+ if (mask & ThemeIconMask)
+ setTheme(other.theme());
}
- PropertySheetIconValue::ModeStateToPixmapMap PropertySheetIconValue::paths() const
+ const PropertySheetIconValue::ModeStateToPixmapMap &PropertySheetIconValue::paths() const
{
- return m_paths;
+ return m_data->m_paths;
+ }
+
+ QDESIGNER_SHARED_EXPORT QDebug operator<<(QDebug d, const PropertySheetIconValue &p)
+ {
+ typedef PropertySheetIconValue::ModeStateToPixmapMap::const_iterator ModeStateToPixmapMapConstIt;
+
+ QDebug nospace = d.nospace();
+ nospace << "PropertySheetIconValue theme='" << p.theme() << "' ";
+
+ const PropertySheetIconValue::ModeStateToPixmapMap &paths = p.paths();
+ const ModeStateToPixmapMapConstIt cend = paths.constEnd();
+ for (ModeStateToPixmapMapConstIt it = paths.constBegin(); it != cend; ++it)
+ nospace << " mode=" << it.key().first << ",state=" << it.key().second
+ << ",'" << it.value().path() << '\'';
+ nospace << " mask=0x" << QString::number(p.mask(), 16);
+ return d;
}
QDESIGNER_SHARED_EXPORT QDesignerFormWindowCommand *createTextPropertyCommand(const QString &propertyName, const QString &text, QObject *object, QDesignerFormWindowInterface *fw)
diff --git a/tools/designer/src/lib/shared/qdesigner_utils_p.h b/tools/designer/src/lib/shared/qdesigner_utils_p.h
index bed1d05..b310208 100644
--- a/tools/designer/src/lib/shared/qdesigner_utils_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_utils_p.h
@@ -58,6 +58,7 @@
#include <QtDesigner/QDesignerFormWindowInterface>
#include <QtCore/QVariant>
+#include <QtCore/QSharedDataPointer>
#include <QtCore/QMap>
#include <QtGui/QMainWindow>
#include <QtGui/QIcon>
@@ -65,6 +66,8 @@
QT_BEGIN_NAMESPACE
+class QDebug;
+
namespace qdesigner_internal {
class QDesignerFormWindowCommand;
class DesignerIconCache;
@@ -252,16 +255,26 @@ private:
// -------------- IconValue: Returned by the property sheet for icons
+class PropertySheetIconValueData;
+
class QDESIGNER_SHARED_EXPORT PropertySheetIconValue
{
public:
PropertySheetIconValue(const PropertySheetPixmapValue &pixmap);
PropertySheetIconValue();
+ ~PropertySheetIconValue();
+ PropertySheetIconValue(const PropertySheetIconValue &);
+ PropertySheetIconValue &operator=(const PropertySheetIconValue &);
bool operator==(const PropertySheetIconValue &other) const { return equals(other); }
bool operator!=(const PropertySheetIconValue &other) const { return !equals(other); }
bool operator<(const PropertySheetIconValue &other) const;
+ bool isEmpty() const;
+
+ QString theme() const;
+ void setTheme(const QString &);
+
PropertySheetPixmapValue pixmap(QIcon::Mode mode, QIcon::State state) const;
void setPixmap(QIcon::Mode mode, QIcon::State state, const PropertySheetPixmapValue &path); // passing the empty path resets the pixmap
@@ -269,17 +282,22 @@ class QDESIGNER_SHARED_EXPORT PropertySheetIconValue
uint compare(const PropertySheetIconValue &other) const;
void assign(const PropertySheetIconValue &other, uint mask);
+ // Convenience accessors to get themed/unthemed icons.
+ PropertySheetIconValue themed() const;
+ PropertySheetIconValue unthemed() const;
+
typedef QPair<QIcon::Mode, QIcon::State> ModeStateKey;
typedef QMap<ModeStateKey, PropertySheetPixmapValue> ModeStateToPixmapMap;
- ModeStateToPixmapMap paths() const;
+ const ModeStateToPixmapMap &paths() const;
private:
bool equals(const PropertySheetIconValue &rhs) const;
-
- ModeStateToPixmapMap m_paths;
+ QSharedDataPointer<PropertySheetIconValueData> m_data;
};
+QDESIGNER_SHARED_EXPORT QDebug operator<<(QDebug, const PropertySheetIconValue &);
+
class QDESIGNER_SHARED_EXPORT DesignerPixmapCache : public QObject
{
Q_OBJECT
diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp
index ad2aa05..3f40d81 100644
--- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp
+++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp
@@ -1381,9 +1381,83 @@ DomActionRef *QAbstractFormBuilder::createActionRefDom(QAction *action)
return ui_action_ref;
}
+// Struct to store layout item parameters for saving layout items
+struct FormBuilderSaveLayoutEntry {
+ explicit FormBuilderSaveLayoutEntry(QLayoutItem *li = 0) :
+ item(li), row(-1), column(-1), rowSpan(0), columnSpan(0) {}
+
+ QLayoutItem *item;
+ int row;
+ int column;
+ int rowSpan;
+ int columnSpan;
+};
+
+// Create list from standard box layout
+static QList<FormBuilderSaveLayoutEntry> saveLayoutEntries(const QLayout *layout)
+{
+ QList<FormBuilderSaveLayoutEntry> rc;
+ if (const int count = layout->count()) {
+ rc.reserve(count);
+ for (int idx = 0; idx < count; ++idx) {
+ QLayoutItem *item = layout->itemAt(idx);
+ rc.append(FormBuilderSaveLayoutEntry(item));
+ }
+ }
+ return rc;
+}
+
+// Create list from grid layout
+static QList<FormBuilderSaveLayoutEntry> saveGridLayoutEntries(QGridLayout *gridLayout)
+{
+ QList<FormBuilderSaveLayoutEntry> rc;
+ if (const int count = gridLayout->count()) {
+ rc.reserve(count);
+ for (int idx = 0; idx < count; ++idx) {
+ QLayoutItem *item = gridLayout->itemAt(idx);
+ FormBuilderSaveLayoutEntry entry(item);
+ gridLayout->getItemPosition(idx, &entry.row, &entry.column, &entry.rowSpan,&entry.columnSpan);
+ rc.append(entry);
+ }
+ }
+ return rc;
+}
+
+#ifndef QT_NO_FORMLAYOUT
+// Create list from form layout
+static QList<FormBuilderSaveLayoutEntry> saveFormLayoutEntries(const QFormLayout *formLayout)
+{
+ QList<FormBuilderSaveLayoutEntry> rc;
+ if (const int count = formLayout->count()) {
+ rc.reserve(count);
+ for (int idx = 0; idx < count; ++idx) {
+ QLayoutItem *item = formLayout->itemAt(idx);
+ QFormLayout::ItemRole role = QFormLayout::LabelRole;
+ FormBuilderSaveLayoutEntry entry(item);
+ formLayout->getItemPosition(idx, &entry.row, &role);
+ switch (role ) {
+ case QFormLayout::LabelRole:
+ entry.column = 0;
+ break;
+ case QFormLayout::FieldRole:
+ entry.column = 1;
+ break;
+ case QFormLayout::SpanningRole:
+ entry.column = 0;
+ entry.columnSpan = 2;
+ break;
+ }
+ rc.push_back(entry);
+ }
+ }
+ return rc;
+}
+#endif
+
/*!
\internal
*/
+
DomLayout *QAbstractFormBuilder::createDom(QLayout *layout, DomLayout *ui_layout, DomWidget *ui_parentWidget)
{
Q_UNUSED(ui_layout)
@@ -1394,37 +1468,30 @@ DomLayout *QAbstractFormBuilder::createDom(QLayout *layout, DomLayout *ui_layout
lay->setAttributeName(objectName);
lay->setElementProperty(computeProperties(layout));
- QList<DomLayoutItem*> ui_items;
-
- QMap<QObject *, QLayoutItem *> objectToItem;
- QList<QLayoutItem *> spacerItems;
- QList<QLayoutItem *> newList;
-
- for (int idx=0; layout->itemAt(idx); ++idx) {
- QLayoutItem *item = layout->itemAt(idx);
- if (item->widget())
- objectToItem[item->widget()] = item;
- else if (item->layout())
- objectToItem[item->layout()] = item;
- else if (item->spacerItem())
- spacerItems.append(item);
- newList.append(item);
- }
-
- if (qobject_cast<QGridLayout *>(layout)) {
- newList.clear();
- QList<QObject *> childrenList = layout->parentWidget()->children();
- foreach (QObject *o, childrenList) {
- if (objectToItem.contains(o))
- newList.append(objectToItem[o]);
- }
- newList += spacerItems;
+ QList<FormBuilderSaveLayoutEntry> newList;
+ if (QGridLayout *gridLayout = qobject_cast<QGridLayout *>(layout)) {
+ newList = saveGridLayoutEntries(gridLayout);
+#ifndef QT_NO_FORMLAYOUT
+ } else if (const QFormLayout *formLayout = qobject_cast<const QFormLayout *>(layout)) {
+ newList = saveFormLayoutEntries(formLayout);
+#endif
+ } else {
+ newList = saveLayoutEntries(layout);
}
- foreach (QLayoutItem *item, newList) {
- DomLayoutItem *ui_item = createDom(item, lay, ui_parentWidget);
- if (ui_item)
+ QList<DomLayoutItem*> ui_items;
+ foreach (const FormBuilderSaveLayoutEntry &item, newList) {
+ if (DomLayoutItem *ui_item = createDom(item.item, lay, ui_parentWidget)) {
+ if (item.row >= 0)
+ ui_item->setAttributeRow(item.row);
+ if (item.column >= 0)
+ ui_item->setAttributeColumn(item.column);
+ if (item.rowSpan > 1)
+ ui_item->setAttributeRowSpan(item.rowSpan);
+ if (item.columnSpan > 1)
+ ui_item->setAttributeColSpan(item.columnSpan);
ui_items.append(ui_item);
+ }
}
lay->setElementItem(ui_items);
diff --git a/tools/designer/src/lib/uilib/resourcebuilder.cpp b/tools/designer/src/lib/uilib/resourcebuilder.cpp
index d19a09a..03e2a66 100644
--- a/tools/designer/src/lib/uilib/resourcebuilder.cpp
+++ b/tools/designer/src/lib/uilib/resourcebuilder.cpp
@@ -44,6 +44,7 @@
#include <QtCore/QVariant>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
+#include <QtCore/QDebug>
#include <QtGui/QPixmap>
#include <QtGui/QIcon>
@@ -53,6 +54,8 @@ QT_BEGIN_NAMESPACE
namespace QFormInternal {
#endif
+enum { themeDebug = 0 };
+
QResourceBuilder::QResourceBuilder()
{
@@ -95,6 +98,14 @@ QVariant QResourceBuilder::loadResource(const QDir &workingDirectory, const DomP
}
case DomProperty::IconSet: {
const DomResourceIcon *dpi = property->elementIconSet();
+ if (!dpi->attributeTheme().isEmpty()) {
+ const QString theme = dpi->attributeTheme();
+ const bool known = QIcon::hasThemeIcon(theme);
+ if (themeDebug)
+ qDebug("Theme %s known %d", qPrintable(theme), known);
+ if (known)
+ return qVariantFromValue(QIcon::fromTheme(dpi->attributeTheme()));
+ } // non-empty theme
if (const int flags = iconStateFlags(dpi)) { // new, post 4.4 format
QIcon icon;
if (flags & NormalOff)
diff --git a/tools/designer/src/lib/uilib/ui4.cpp b/tools/designer/src/lib/uilib/ui4.cpp
index c13bd59..98974e6 100644
--- a/tools/designer/src/lib/uilib/ui4.cpp
+++ b/tools/designer/src/lib/uilib/ui4.cpp
@@ -7745,6 +7745,7 @@ void DomResourceIcon::clear(bool clear_all)
if (clear_all) {
m_text = QLatin1String("");
+ m_has_attr_theme = false;
m_has_attr_resource = false;
}
@@ -7762,6 +7763,7 @@ void DomResourceIcon::clear(bool clear_all)
DomResourceIcon::DomResourceIcon()
{
m_children = 0;
+ m_has_attr_theme = false;
m_has_attr_resource = false;
m_text = QLatin1String("");
m_normalOff = 0;
@@ -7791,6 +7793,10 @@ void DomResourceIcon::read(QXmlStreamReader &reader)
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
QStringRef name = attribute.name();
+ if (name == QLatin1String("theme")) {
+ setAttributeTheme(attribute.value().toString());
+ continue;
+ }
if (name == QLatin1String("resource")) {
setAttributeResource(attribute.value().toString());
continue;
@@ -7869,6 +7875,8 @@ void DomResourceIcon::read(QXmlStreamReader &reader)
#ifdef QUILOADER_QDOM_READ
void DomResourceIcon::read(const QDomElement &node)
{
+ if (node.hasAttribute(QLatin1String("theme")))
+ setAttributeTheme(node.attribute(QLatin1String("theme")));
if (node.hasAttribute(QLatin1String("resource")))
setAttributeResource(node.attribute(QLatin1String("resource")));
@@ -7938,6 +7946,9 @@ void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) co
{
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resourceicon") : tagName.toLower());
+ if (hasAttributeTheme())
+ writer.writeAttribute(QLatin1String("theme"), attributeTheme());
+
if (hasAttributeResource())
writer.writeAttribute(QLatin1String("resource"), attributeResource());
diff --git a/tools/designer/src/lib/uilib/ui4_p.h b/tools/designer/src/lib/uilib/ui4_p.h
index 1f38f88..a464a89 100644
--- a/tools/designer/src/lib/uilib/ui4_p.h
+++ b/tools/designer/src/lib/uilib/ui4_p.h
@@ -2809,6 +2809,11 @@ public:
inline void setText(const QString &s) { m_text = s; }
// attribute accessors
+ inline bool hasAttributeTheme() const { return m_has_attr_theme; }
+ inline QString attributeTheme() const { return m_attr_theme; }
+ inline void setAttributeTheme(const QString& a) { m_attr_theme = a; m_has_attr_theme = true; }
+ inline void clearAttributeTheme() { m_has_attr_theme = false; }
+
inline bool hasAttributeResource() const { return m_has_attr_resource; }
inline QString attributeResource() const { return m_attr_resource; }
inline void setAttributeResource(const QString& a) { m_attr_resource = a; m_has_attr_resource = true; }
@@ -2868,6 +2873,9 @@ private:
void clear(bool clear_all = true);
// attribute data
+ QString m_attr_theme;
+ bool m_has_attr_theme;
+
QString m_attr_resource;
bool m_has_attr_resource;
diff --git a/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp b/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp
index c508fa2..7f597ff 100644
--- a/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp
+++ b/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp
@@ -66,12 +66,12 @@ QString SeekSliderPlugin::group() const
QString SeekSliderPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString SeekSliderPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString SeekSliderPlugin::includeFile() const
diff --git a/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp b/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp
index d4af121..489a08c 100644
--- a/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp
+++ b/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp
@@ -72,12 +72,12 @@ QString VideoPlayerPlugin::group() const
QString VideoPlayerPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString VideoPlayerPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString VideoPlayerPlugin::includeFile() const
diff --git a/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp b/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp
index becd5d9..24eb829 100644
--- a/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp
+++ b/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp
@@ -66,12 +66,12 @@ QString VolumeSliderPlugin::group() const
QString VolumeSliderPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString VolumeSliderPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString VolumeSliderPlugin::includeFile() const
diff --git a/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp b/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp
index b352a9b..7148ad0 100644
--- a/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp
+++ b/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp
@@ -69,12 +69,12 @@ QString QDeclarativeViewPlugin::group() const
QString QDeclarativeViewPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString QDeclarativeViewPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString QDeclarativeViewPlugin::includeFile() const
diff --git a/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp b/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp
index 61f7e66..c90e191 100644
--- a/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp
+++ b/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp
@@ -69,12 +69,12 @@ QString QWebViewPlugin::group() const
QString QWebViewPlugin::toolTip() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString QWebViewPlugin::whatsThis() const
{
- return QString(QLatin1String(toolTipC));
+ return tr(toolTipC);
}
QString QWebViewPlugin::includeFile() const
diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp
index 094406c..d691548 100644
--- a/tools/linguist/lconvert/main.cpp
+++ b/tools/linguist/lconvert/main.cpp
@@ -45,11 +45,17 @@
#include <QtCore/QDebug>
#include <QtCore/QString>
#include <QtCore/QStringList>
+#include <QtCore/QTranslator>
+#include <QtCore/QLibraryInfo>
#include <iostream>
QT_USE_NAMESPACE
+class LC {
+ Q_DECLARE_TR_FUNCTIONS(LConvert)
+};
+
static int usage(const QStringList &args)
{
Q_UNUSED(args);
@@ -59,7 +65,7 @@ static int usage(const QStringList &args)
foreach (Translator::FileFormat format, Translator::registeredFileFormats())
loaders += line.arg(format.extension, -5).arg(format.description);
- std::cerr << qPrintable(QString(QLatin1String("\nUsage:\n"
+ std::cerr << qPrintable(LC::tr("\nUsage:\n"
" lconvert [options] <infile> [<infile>...]\n\n"
"lconvert is part of Qt's Linguist tool chain. It can be used as a\n"
"stand-alone tool to convert and filter translation data files.\n"
@@ -121,7 +127,7 @@ static int usage(const QStringList &args)
" 0 on success\n"
" 1 on command line parse failures\n"
" 2 on read failures\n"
- " 3 on write failures\n")).arg(loaders));
+ " 3 on write failures\n").arg(loaders));
return 1;
}
@@ -134,8 +140,17 @@ struct File
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
- QStringList args = app.arguments();
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ }
+ QStringList args = app.arguments();
QList<File> inFiles;
QString inFormat(QLatin1String("auto"));
QString outFileName;
diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp
index e5c8461..8520cf7 100644
--- a/tools/linguist/linguist/mainwindow.cpp
+++ b/tools/linguist/linguist/mainwindow.cpp
@@ -142,10 +142,13 @@ static Ending ending(QString str, QLocale::Language lang)
case 0x2048: // question exclamation mark
case 0x2049: // exclamation question mark
case 0x2762: // heavy exclamation mark ornament
+ case 0xff01: // full width exclamation mark
+ case 0xff1f: // full width question mark
return End_Interrobang;
case 0x003b: // greek 'compatibility' questionmark
return lang == QLocale::Greek ? End_Interrobang : End_None;
case 0x003a: // colon
+ case 0xff1a: // full width colon
return End_Colon;
case 0x2026: // horizontal ellipsis
return End_Ellipsis;
@@ -1027,6 +1030,8 @@ void MainWindow::findAgain()
break;
if (searchItem(m->extraComment()))
break;
+ if (searchItem(m->translatorComment()))
+ break;
m_foundWhere = DataModel::NoLocation;
// did not find the search string in this message
}
@@ -1517,7 +1522,7 @@ void MainWindow::selectedMessageChanged(const QModelIndex &sortedIndex, const QM
}
m_phraseView->setSourceText(-1, QString());
}
- if (m) {
+ if (m && !m->fileName().isEmpty()) {
if (hasFormPreview(m->fileName())) {
m_sourceAndFormView->setCurrentWidget(m_formPreviewView);
m_formPreviewView->setSourceContext(model, m);
@@ -1572,7 +1577,7 @@ void MainWindow::updateTranslation(const QStringList &translations)
return;
m->setTranslations(translations);
- if (hasFormPreview(m->fileName()))
+ if (!m->fileName().isEmpty() && hasFormPreview(m->fileName()))
m_formPreviewView->setSourceContext(m_currentIndex.model(), m);
updateDanger(m_currentIndex, true);
@@ -1991,7 +1996,7 @@ void MainWindow::updateLatestModel(int model)
if (m_currentIndex.isValid()) {
if (MessageItem *item = m_dataModel->messageItem(m_currentIndex)) {
- if (hasFormPreview(item->fileName()))
+ if (!item->fileName().isEmpty() && hasFormPreview(item->fileName()))
m_formPreviewView->setSourceContext(model, item);
if (enableRw && !item->isObsolete())
m_phraseView->setSourceText(model, item->text());
diff --git a/tools/linguist/linguist/phrase.cpp b/tools/linguist/linguist/phrase.cpp
index 254daf4..709ec35 100644
--- a/tools/linguist/linguist/phrase.cpp
+++ b/tools/linguist/linguist/phrase.cpp
@@ -188,10 +188,9 @@ bool QphHandler::characters(const QString &ch)
bool QphHandler::fatalError(const QXmlParseException &exception)
{
if (ferrorCount++ == 0) {
- QString msg;
- msg.sprintf("Parse error at line %d, column %d (%s).",
- exception.lineNumber(), exception.columnNumber(),
- exception.message().toLatin1().constData());
+ QString msg = PhraseBook::tr("Parse error at line %1, column %2 (%3).")
+ .arg(exception.lineNumber()).arg(exception.columnNumber())
+ .arg(exception.message());
QMessageBox::information(0,
QObject::tr("Qt Linguist"), msg);
}
diff --git a/tools/linguist/linguist/sourcecodeview.cpp b/tools/linguist/linguist/sourcecodeview.cpp
index b8dd9c0..d2eef56 100644
--- a/tools/linguist/linguist/sourcecodeview.cpp
+++ b/tools/linguist/linguist/sourcecodeview.cpp
@@ -64,7 +64,7 @@ void SourceCodeView::setSourceContext(const QString &fileName, const int lineNum
m_fileToLoad.clear();
setToolTip(fileName);
- if (fileName.isNull()) {
+ if (fileName.isEmpty()) {
clear();
m_currentFileName.clear();
appendHtml(tr("<i>Source code not available</i>"));
diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp
index b5cff90..19377ef 100644
--- a/tools/linguist/lrelease/main.cpp
+++ b/tools/linguist/lrelease/main.cpp
@@ -65,6 +65,17 @@ static void initBinaryDir(
const char *argv0
#endif
);
+
+struct LR {
+ static inline QString tr(const char *sourceText, const char *comment = 0)
+ {
+ return QCoreApplication::translate("LRelease", sourceText, comment);
+ }
+};
+#else
+class LR {
+ Q_DECLARE_TR_FUNCTIONS(LRelease)
+};
#endif
static void printOut(const QString & out)
@@ -75,7 +86,7 @@ static void printOut(const QString & out)
static void printUsage()
{
- printOut(QCoreApplication::tr(
+ printOut(LR::tr(
"Usage:\n"
" lrelease [options] project-file\n"
" lrelease [options] ts-files [-qm qm-file]\n\n"
@@ -108,7 +119,7 @@ static bool loadTsFile(Translator &tor, const QString &tsFileName, bool /* verbo
ConversionData cd;
bool ok = tor.load(tsFileName, cd, QLatin1String("auto"));
if (!ok) {
- std::cerr << "lrelease error: " << qPrintable(cd.error());
+ std::cerr << qPrintable(LR::tr("lrelease error: %1").arg(cd.error()));
} else {
if (!cd.errors().isEmpty())
printOut(cd.error());
@@ -123,17 +134,17 @@ static bool releaseTranslator(Translator &tor, const QString &qmFileName,
tor.reportDuplicates(tor.resolveDuplicates(), qmFileName, cd.isVerbose());
if (cd.isVerbose())
- printOut(QCoreApplication::tr( "Updating '%1'...\n").arg(qmFileName));
+ printOut(LR::tr("Updating '%1'...\n").arg(qmFileName));
if (removeIdentical) {
if (cd.isVerbose())
- printOut(QCoreApplication::tr( "Removing translations equal to source text in '%1'...\n").arg(qmFileName));
+ printOut(LR::tr("Removing translations equal to source text in '%1'...\n").arg(qmFileName));
tor.stripIdenticalSourceTranslations();
}
QFile file(qmFileName);
if (!file.open(QIODevice::WriteOnly)) {
- std::cerr << "lrelease error: cannot create '" << qPrintable(qmFileName)
- << "': " << qPrintable(file.errorString()) << std::endl;
+ std::cerr << qPrintable(LR::tr("lrelease error: cannot create '%1': %2\n")
+ .arg(qmFileName, file.errorString()));
return false;
}
@@ -142,8 +153,8 @@ static bool releaseTranslator(Translator &tor, const QString &qmFileName,
file.close();
if (!ok) {
- std::cerr << "lrelease error: cannot save '" << qPrintable(qmFileName)
- << "': " << qPrintable(cd.error());
+ std::cerr << qPrintable(LR::tr("lrelease error: cannot save '%1': %2")
+ .arg(qmFileName, cd.error()));
} else if (!cd.errors().isEmpty()) {
printOut(cd.error());
}
@@ -181,8 +192,14 @@ int main(int argc, char **argv)
#else
QCoreApplication app(argc, argv);
QTranslator translator;
- if (translator.load(QLatin1String("lrelease_") + QLocale::system().name()))
+ QTranslator qtTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) {
app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ }
#endif
ConversionData cd;
@@ -221,7 +238,7 @@ int main(int argc, char **argv)
cd.m_verbose = true;
continue;
} else if (!strcmp(argv[i], "-version")) {
- printOut(QCoreApplication::tr( "lrelease version %1\n").arg(QLatin1String(QT_VERSION_STR)) );
+ printOut(LR::tr("lrelease version %1\n").arg(QLatin1String(QT_VERSION_STR)));
return 0;
} else if (!strcmp(argv[i], "-qm")) {
if (i == argc - 1) {
@@ -255,20 +272,23 @@ int main(int argc, char **argv)
visitor.setVerbose(cd.isVerbose());
if (!visitor.queryProFile(&pro)) {
- std::cerr << "lrelease error: cannot read project file '"
- << qPrintable(inputFile) << "'.\n";
+ std::cerr << qPrintable(LR::tr(
+ "lrelease error: cannot read project file '%1'.\n")
+ .arg(inputFile));
continue;
}
if (!visitor.accept(&pro)) {
- std::cerr << "lrelease error: cannot process project file '"
- << qPrintable(inputFile) << "'.\n";
+ std::cerr << qPrintable(LR::tr(
+ "lrelease error: cannot process project file '%1'.\n")
+ .arg(inputFile));
continue;
}
QStringList translations = visitor.values(QLatin1String("TRANSLATIONS"));
if (translations.isEmpty()) {
- std::cerr << "lrelease warning: Met no 'TRANSLATIONS' entry in project file '"
- << qPrintable(inputFile) << "'\n";
+ std::cerr << qPrintable(LR::tr(
+ "lrelease warning: Met no 'TRANSLATIONS' entry in project file '%1'\n")
+ .arg(inputFile));
} else {
QDir proDir(fi.absolutePath());
foreach (const QString &trans, translations)
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index bc9bb26..6ea7299 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -50,6 +50,7 @@
#include <QtCore/QString>
#include <QtCore/QTextCodec>
#include <QtCore/QTextStream>
+#include <QtCore/QCoreApplication>
#include <iostream>
@@ -57,6 +58,10 @@
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
/* qmake ignore Q_OBJECT */
static QString MagicComment(QLatin1String("TRANSLATOR"));
@@ -484,6 +489,7 @@ STRING(class);
STRING(findMessage);
STRING(friend);
STRING(namespace);
+STRING(operator);
STRING(qtTrId);
STRING(return);
STRING(struct);
@@ -624,8 +630,8 @@ uint CppParser::getToken()
|| yyBraceDepth != is.braceDepth1st
|| yyParenDepth != is.parenDepth1st)
yyMsg(is.elseLine)
- << "Parenthesis/bracket/brace mismatch between "
- "#if and #else branches; using #if branch\n";
+ << qPrintable(LU::tr("Parenthesis/bracket/brace mismatch between "
+ "#if and #else branches; using #if branch\n"));
} else {
is.bracketDepth1st = yyBracketDepth;
is.braceDepth1st = yyBraceDepth;
@@ -647,8 +653,8 @@ uint CppParser::getToken()
|| yyBraceDepth != is.braceDepth1st
|| yyParenDepth != is.parenDepth1st)
yyMsg(is.elseLine)
- << "Parenthesis/brace mismatch between "
- "#if and #else branches; using #if branch\n";
+ << qPrintable(LU::tr("Parenthesis/brace mismatch between "
+ "#if and #else branches; using #if branch\n"));
yyBracketDepth = is.bracketDepth1st;
yyBraceDepth = is.braceDepth1st;
yyParenDepth = is.parenDepth1st;
@@ -674,7 +680,7 @@ uint CppParser::getToken()
forever {
yyCh = getChar();
if (yyCh == EOF) {
- yyMsg() << "Unterminated C++ comment\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated C++ comment\n"));
break;
}
@@ -748,6 +754,20 @@ uint CppParser::getToken()
if (yyWord == strnamespace)
return Tok_namespace;
break;
+ case 'o':
+ if (yyWord == stroperator) {
+ // Operator overload declaration/definition.
+ // We need to prevent those characters from confusing the followup
+ // parsing. Actually using them does not add value, so just eat them.
+ while (isspace(yyCh))
+ yyCh = getChar();
+ while (yyCh == '+' || yyCh == '-' || yyCh == '*' || yyCh == '/' || yyCh == '%'
+ || yyCh == '=' || yyCh == '<' || yyCh == '>' || yyCh == '!'
+ || yyCh == '&' || yyCh == '|' || yyCh == '~' || yyCh == '^'
+ || yyCh == '[' || yyCh == ']')
+ yyCh = getChar();
+ }
+ break;
case 'q':
if (yyWord == strqtTrId)
return Tok_trid;
@@ -804,7 +824,7 @@ uint CppParser::getToken()
forever {
yyCh = getChar();
if (yyCh == EOF) {
- yyMsg() << "Unterminated C++ comment\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated C++ comment\n"));
break;
}
*ptr++ = yyCh;
@@ -837,7 +857,7 @@ uint CppParser::getToken()
yyWord.resize(ptr - (ushort *)yyWord.unicode());
if (yyCh != '"')
- yyMsg() << "Unterminated C++ string\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated C++ string\n"));
else
yyCh = getChar();
return Tok_String;
@@ -894,8 +914,8 @@ uint CppParser::getToken()
if (yyBraceDepth == yyMinBraceDepth) {
if (!inDefine)
yyMsg(yyCurLineNo)
- << "Excess closing brace in C++ code"
- " (or abuse of the C++ preprocessor)\n";
+ << qPrintable(LU::tr("Excess closing brace in C++ code"
+ " (or abuse of the C++ preprocessor)\n"));
// Avoid things getting messed up even more
yyCh = getChar();
return Tok_Semicolon;
@@ -912,8 +932,8 @@ uint CppParser::getToken()
case ')':
if (yyParenDepth == 0)
yyMsg(yyCurLineNo)
- << "Excess closing parenthesis in C++ code"
- " (or abuse of the C++ preprocessor)\n";
+ << qPrintable(LU::tr("Excess closing parenthesis in C++ code"
+ " (or abuse of the C++ preprocessor)\n"));
else
yyParenDepth--;
yyCh = getChar();
@@ -927,8 +947,8 @@ uint CppParser::getToken()
case ']':
if (yyBracketDepth == 0)
yyMsg(yyCurLineNo)
- << "Excess closing bracket in C++ code"
- " (or abuse of the C++ preprocessor)\n";
+ << qPrintable(LU::tr("Excess closing bracket in C++ code"
+ " (or abuse of the C++ preprocessor)\n"));
else
yyBracketDepth--;
yyCh = getChar();
@@ -1296,7 +1316,7 @@ void CppParser::processInclude(const QString &file, ConversionData &cd,
QString cleanFile = QDir::cleanPath(file);
if (inclusions.contains(cleanFile)) {
- yyMsg() << "circular inclusion of " << qPrintable(cleanFile) << std::endl;
+ yyMsg() << qPrintable(LU::tr("circular inclusion of %1\n").arg(cleanFile));
return;
}
@@ -1320,9 +1340,7 @@ void CppParser::processInclude(const QString &file, ConversionData &cd,
QFile f(cleanFile);
if (!f.open(QIODevice::ReadOnly)) {
- yyMsg()
- << "Cannot open " << qPrintable(cleanFile) << ": "
- << qPrintable(f.errorString()) << std::endl;
+ yyMsg() << qPrintable(LU::tr("Cannot open %1: %2\n").arg(cleanFile, f.errorString()));
return;
}
@@ -1675,6 +1693,8 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
functionContextUnresolved.clear(); // Pointless
prospectiveContext.clear();
pendingContext.clear();
+
+ yyTok = getToken();
}
break;
case Tok_namespace:
@@ -1686,7 +1706,6 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
HashString ns = HashString(text);
yyTok = getToken();
if (yyTok == Tok_LeftBrace) {
- yyTok = getToken();
namespaceDepths.push(namespaces.count());
enterNamespace(&namespaces, ns);
@@ -1694,6 +1713,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
functionContextUnresolved.clear();
prospectiveContext.clear();
pendingContext.clear();
+ yyTok = getToken();
} else if (yyTok == Tok_Equals) {
// e.g. namespace Is = OuterSpace::InnerSpace;
QList<HashString> fullName;
@@ -1766,7 +1786,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
if (!tor)
goto case_default;
if (!sourcetext.isEmpty())
- yyMsg() << "//% cannot be used with tr() / QT_TR_NOOP(). Ignoring\n";
+ yyMsg() << qPrintable(LU::tr("//% cannot be used with tr() / QT_TR_NOOP(). Ignoring\n"));
utf8 = (yyTok == Tok_trUtf8);
line = yyLineNo;
yyTok = getToken();
@@ -1787,9 +1807,8 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
QStringList unresolved;
if (!fullyQualify(namespaces, pendingContext, true, &functionContext, &unresolved)) {
functionContextUnresolved = unresolved.join(strColons);
- yyMsg() << "Qualifying with unknown namespace/class "
- << qPrintable(stringifyNamespace(functionContext)) << "::"
- << qPrintable(unresolved.first()) << std::endl;
+ yyMsg() << qPrintable(LU::tr("Qualifying with unknown namespace/class %1::%2\n")
+ .arg(stringifyNamespace(functionContext)).arg(unresolved.first()));
}
pendingContext.clear();
}
@@ -1797,7 +1816,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
if (functionContextUnresolved.isEmpty()) {
int idx = functionContext.length();
if (idx < 2) {
- yyMsg() << "tr() cannot be called without context\n";
+ yyMsg() << qPrintable(LU::tr("tr() cannot be called without context\n"));
break;
}
Namespace *fctx;
@@ -1806,8 +1825,8 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
context = stringifyNamespace(functionContext);
fctx = findNamespace(functionContext)->classDef;
if (!fctx->complained) {
- yyMsg() << "Class '" << qPrintable(context)
- << "' lacks Q_OBJECT macro\n";
+ yyMsg() << qPrintable(LU::tr("Class '%1' lacks Q_OBJECT macro\n")
+ .arg(context));
fctx->complained = true;
}
goto gotctx;
@@ -1835,8 +1854,8 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
int last = prefix.lastIndexOf(strColons);
QString className = prefix.mid(last == -1 ? 0 : last + 2);
if (!className.isEmpty() && className == functionName) {
- yyMsg() << "It is not recommended to call tr() from within a constructor '"
- << qPrintable(className) << "::" << qPrintable(functionName) << "'\n";
+ yyMsg() << qPrintable(LU::tr("It is not recommended to call tr() from within a constructor '%1::%2'\n")
+ .arg(className).arg(functionName));
}
#endif
prefix.chop(2);
@@ -1851,7 +1870,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
context = fctx->trQualification;
}
if (!fctx->hasTrFunctions && !fctx->complained) {
- yyMsg() << "Class '" << qPrintable(context) << "' lacks Q_OBJECT macro\n";
+ yyMsg() << qPrintable(LU::tr("Class '%1' lacks Q_OBJECT macro\n").arg(context));
fctx->complained = true;
}
} else {
@@ -1873,7 +1892,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
if (!tor)
goto case_default;
if (!sourcetext.isEmpty())
- yyMsg() << "//% cannot be used with translate() / QT_TRANSLATE_NOOP(). Ignoring\n";
+ yyMsg() << qPrintable(LU::tr("//% cannot be used with translate() / QT_TRANSLATE_NOOP(). Ignoring\n"));
utf8 = (yyTok == Tok_translateUtf8);
line = yyLineNo;
yyTok = getToken();
@@ -1928,7 +1947,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
if (!tor)
goto case_default;
if (!msgid.isEmpty())
- yyMsg() << "//= cannot be used with qtTrId() / QT_TRID_NOOP(). Ignoring\n";
+ yyMsg() << qPrintable(LU::tr("//= cannot be used with qtTrId() / QT_TRID_NOOP(). Ignoring\n"));
//utf8 = false; // Maybe use //%% or something like that
line = yyLineNo;
yyTok = getToken();
@@ -1995,13 +2014,13 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
if (isspace(c))
continue;
if (c != '"') {
- yyMsg() << "Unexpected character in meta string\n";
+ yyMsg() << qPrintable(LU::tr("Unexpected character in meta string\n"));
break;
}
forever {
if (p >= yyWord.length()) {
whoops:
- yyMsg() << "Unterminated meta string\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated meta string\n"));
break;
}
c = yyWord.unicode()[p++].unicode();
@@ -2054,7 +2073,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
case Tok_Arrow:
yyTok = getToken();
if (yyTok == Tok_tr || yyTok == Tok_trUtf8)
- yyMsg() << "Cannot invoke tr() like this\n";
+ yyMsg() << qPrintable(LU::tr("Cannot invoke tr() like this\n"));
break;
case Tok_ColonColon:
if (yyBraceDepth == namespaceDepths.count() && yyParenDepth == 0 && !yyTokColonSeen)
@@ -2087,7 +2106,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
prospectiveContext.clear();
prefix.clear();
if (!sourcetext.isEmpty() || !extracomment.isEmpty() || !msgid.isEmpty() || !extra.isEmpty()) {
- yyMsg() << "Discarding unconsumed meta data\n";
+ yyMsg() << qPrintable(LU::tr("Discarding unconsumed meta data\n"));
sourcetext.clear();
extracomment.clear();
msgid.clear();
@@ -2127,16 +2146,16 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
if (yyBraceDepth != 0)
yyMsg(yyBraceLineNo)
- << "Unbalanced opening brace in C++ code"
- " (or abuse of the C++ preprocessor)\n";
+ << qPrintable(LU::tr("Unbalanced opening brace in C++ code"
+ " (or abuse of the C++ preprocessor)\n"));
else if (yyParenDepth != 0)
yyMsg(yyParenLineNo)
- << "Unbalanced opening parenthesis in C++ code"
- " (or abuse of the C++ preprocessor)\n";
+ << qPrintable(LU::tr("Unbalanced opening parenthesis in C++ code"
+ " (or abuse of the C++ preprocessor)\n"));
else if (yyBracketDepth != 0)
yyMsg(yyBracketLineNo)
- << "Unbalanced opening bracket in C++ code"
- " (or abuse of the C++ preprocessor)\n";
+ << qPrintable(LU::tr("Unbalanced opening bracket in C++ code"
+ " (or abuse of the C++ preprocessor)\n"));
}
const ParseResults *CppParser::recordResults(bool isHeader)
@@ -2197,8 +2216,7 @@ void loadCPP(Translator &translator, const QStringList &filenames, ConversionDat
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
+ cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
continue;
}
diff --git a/tools/linguist/lupdate/java.cpp b/tools/linguist/lupdate/java.cpp
index dc66e2b..165b6a3 100644
--- a/tools/linguist/lupdate/java.cpp
+++ b/tools/linguist/lupdate/java.cpp
@@ -50,6 +50,7 @@
#include <QtCore/QStack>
#include <QtCore/QString>
#include <QtCore/QTextCodec>
+#include <QtCore/QCoreApplication>
#include <iostream>
@@ -57,6 +58,10 @@
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
enum { Tok_Eof, Tok_class, Tok_return, Tok_tr,
Tok_translate, Tok_Ident, Tok_Package,
Tok_Comment, Tok_String, Tok_Colon, Tok_Dot,
@@ -196,7 +201,7 @@ static int getToken()
while ( !metAsterSlash ) {
yyCh = getChar();
if ( yyCh == EOF ) {
- yyMsg() << "Unterminated Java comment.\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated Java comment.\n"));
return Tok_Comment;
}
@@ -232,7 +237,7 @@ static int getToken()
else {
int sub(yyCh.toLower().toAscii() - 87);
if( sub > 15 || sub < 10) {
- yyMsg() << "Invalid Unicode value.\n";
+ yyMsg() << qPrintable(LU::tr("Invalid Unicode value.\n"));
break;
}
unicode += sub;
@@ -255,7 +260,7 @@ static int getToken()
}
if ( yyCh != QLatin1Char('"') )
- yyMsg() << "Unterminated string.\n";
+ yyMsg() << qPrintable(LU::tr("Unterminated string.\n"));
yyCh = getChar();
@@ -368,8 +373,9 @@ static bool matchString( QString &s )
if (yyTok == Tok_String)
s += yyString;
else {
- yyMsg() << "String used in translation can contain only literals"
- " concatenated with other literals, not expressions or numbers.\n";
+ yyMsg() << qPrintable(LU::tr(
+ "String used in translation can contain only literals"
+ " concatenated with other literals, not expressions or numbers.\n"));
return false;
}
yyTok = getToken();
@@ -477,7 +483,7 @@ static void parse( Translator *tor )
yyScope.push(new Scope(yyIdent, Scope::Clazz, yyLineNo));
}
else {
- yyMsg() << "'class' must be followed by a class name.\n";
+ yyMsg() << qPrintable(LU::tr("'class' must be followed by a class name.\n"));
break;
}
while (!match(Tok_LeftBrace)) {
@@ -549,7 +555,7 @@ static void parse( Translator *tor )
case Tok_RightBrace:
if ( yyScope.isEmpty() ) {
- yyMsg() << "Excess closing brace.\n";
+ yyMsg() << qPrintable(LU::tr("Excess closing brace.\n"));
}
else
delete (yyScope.pop());
@@ -578,7 +584,7 @@ static void parse( Translator *tor )
yyPackage.append(QLatin1String("."));
break;
default:
- yyMsg() << "'package' must be followed by package name.\n";
+ yyMsg() << qPrintable(LU::tr("'package' must be followed by package name.\n"));
break;
}
yyTok = getToken();
@@ -591,9 +597,9 @@ static void parse( Translator *tor )
}
if ( !yyScope.isEmpty() )
- yyMsg(yyScope.top()->line) << "Unbalanced opening brace.\n";
+ yyMsg(yyScope.top()->line) << qPrintable(LU::tr("Unbalanced opening brace.\n"));
else if ( yyParenDepth != 0 )
- yyMsg(yyParenLineNo) << "Unbalanced opening parenthesis.\n";
+ yyMsg(yyParenLineNo) << qPrintable(LU::tr("Unbalanced opening parenthesis.\n"));
}
@@ -601,8 +607,7 @@ bool loadJava(Translator &translator, const QString &filename, ConversionData &c
{
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
+ cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
return false;
}
diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp
index a575192..d96e205 100644
--- a/tools/linguist/lupdate/main.cpp
+++ b/tools/linguist/lupdate/main.cpp
@@ -52,6 +52,8 @@
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QTextCodec>
+#include <QtCore/QTranslator>
+#include <QtCore/QLibraryInfo>
#include <iostream>
@@ -79,7 +81,7 @@ static void recursiveFileInfoList(const QDir &dir,
static void printUsage()
{
- printOut(QObject::tr(
+ printOut(LU::tr(
"Usage:\n"
" lupdate [options] [project-file]...\n"
" lupdate [options] [source-file|path|@lst-file]... -ts ts-files|@lst-file\n\n"
@@ -186,7 +188,7 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil
else if (options & AbsoluteLocations)
tor.setLocationsType(Translator::AbsoluteLocations);
if (options & Verbose)
- printOut(QObject::tr("Updating '%1'...\n").arg(fn));
+ printOut(LU::tr("Updating '%1'...\n").arg(fn));
UpdateOptions theseOptions = options;
if (tor.locationsType() == Translator::NoLocations) // Could be set from file
@@ -201,7 +203,7 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil
}
if (options & PluralOnly) {
if (options & Verbose)
- printOut(QObject::tr("Stripping non plural forms in '%1'...\n").arg(fn));
+ printOut(LU::tr("Stripping non plural forms in '%1'...\n").arg(fn));
out.stripNonPluralForms();
}
if (options & NoObsolete)
@@ -359,12 +361,12 @@ static void processProjects(
if (visitor.contains(QLatin1String("TRANSLATIONS"))) {
if (parentTor) {
if (topLevel) {
- std::cerr << "lupdate warning: TS files from command line "
- "will override TRANSLATIONS in " << qPrintable(proFile) << ".\n";
+ std::cerr << qPrintable(LU::tr("lupdate warning: TS files from command line "
+ "will override TRANSLATIONS in %1.\n").arg(proFile));
goto noTrans;
} else if (nestComplain) {
- std::cerr << "lupdate warning: TS files from command line "
- "prevent recursing into " << qPrintable(proFile) << ".\n";
+ std::cerr << qPrintable(LU::tr("lupdate warning: TS files from command line "
+ "prevent recursing into %1.\n").arg(proFile));
continue;
}
}
@@ -395,8 +397,8 @@ static void processProjects(
noTrans:
if (!parentTor) {
if (topLevel)
- std::cerr << "lupdate warning: no TS files specified. Only diagnostics "
- "will be produced for '" << qPrintable(proFile) << "'.\n";
+ std::cerr << qPrintable(LU::tr("lupdate warning: no TS files specified. Only diagnostics "
+ "will be produced for '%1'.\n").arg(proFile));
Translator tor;
processProject(nestComplain, pfi, visitor, options, codecForSource,
targetLanguage, sourceLanguage, &tor, fail);
@@ -410,6 +412,16 @@ static void processProjects(
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ }
+
m_defaultExtensions = QLatin1String("java,jui,ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx,js,qs,qml");
QStringList args = app.arguments();
@@ -613,7 +625,7 @@ int main(int argc, char **argv)
proFiles << file;
} else if (fi.isDir()) {
if (options & Verbose)
- printOut(QObject::tr("Scanning directory '%1'...\n").arg(file));
+ printOut(LU::tr("Scanning directory '%1'...\n").arg(file));
QDir dir = QDir(fi.filePath());
projectRoots.insert(dir.absolutePath() + QLatin1Char('/'));
if (extensionsNameFilters.isEmpty()) {
diff --git a/tools/linguist/lupdate/merge.cpp b/tools/linguist/lupdate/merge.cpp
index fffdf9b..87c150c 100644
--- a/tools/linguist/lupdate/merge.cpp
+++ b/tools/linguist/lupdate/merge.cpp
@@ -44,15 +44,19 @@
#include "simtexth.h"
#include "translator.h"
+#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QMap>
#include <QtCore/QStringList>
#include <QtCore/QTextCodec>
#include <QtCore/QVector>
-
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
static bool isDigitFriendly(QChar c)
{
return c.isPunct() || c.isSpace();
@@ -485,24 +489,24 @@ Translator merge(const Translator &tor, const Translator &virginTor,
if (options & Verbose) {
int totalFound = neww + known;
- err += QObject::tr(" Found %n source text(s) (%1 new and %2 already existing)\n", 0, totalFound).arg(neww).arg(known);
+ err += LU::tr(" Found %n source text(s) (%1 new and %2 already existing)\n", 0, totalFound).arg(neww).arg(known);
if (obsoleted) {
if (options & NoObsolete) {
- err += QObject::tr(" Removed %n obsolete entries\n", 0, obsoleted);
+ err += LU::tr(" Removed %n obsolete entries\n", 0, obsoleted);
} else {
- err += QObject::tr(" Kept %n obsolete entries\n", 0, obsoleted);
+ err += LU::tr(" Kept %n obsolete entries\n", 0, obsoleted);
}
}
if (sameNumberHeuristicCount)
- err += QObject::tr(" Number heuristic provided %n translation(s)\n",
+ err += LU::tr(" Number heuristic provided %n translation(s)\n",
0, sameNumberHeuristicCount);
if (sameTextHeuristicCount)
- err += QObject::tr(" Same-text heuristic provided %n translation(s)\n",
+ err += LU::tr(" Same-text heuristic provided %n translation(s)\n",
0, sameTextHeuristicCount);
if (similarTextHeuristicCount)
- err += QObject::tr(" Similar-text heuristic provided %n translation(s)\n",
+ err += LU::tr(" Similar-text heuristic provided %n translation(s)\n",
0, similarTextHeuristicCount);
}
return outTor;
diff --git a/tools/linguist/lupdate/qdeclarative.cpp b/tools/linguist/lupdate/qdeclarative.cpp
index 2377416..01b9a1d 100644
--- a/tools/linguist/lupdate/qdeclarative.cpp
+++ b/tools/linguist/lupdate/qdeclarative.cpp
@@ -65,8 +65,26 @@
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
using namespace QDeclarativeJS;
+class Comment
+{
+public:
+ Comment() : lastLine(-1) {}
+ QString extracomment;
+ QString msgid;
+ TranslatorMessage::ExtraData extra;
+ QString sourcetext;
+ int lastLine;
+
+ bool isValid() const
+ { return !extracomment.isEmpty() || !msgid.isEmpty() || !sourcetext.isEmpty() || !extra.isEmpty(); }
+};
+
class FindTrCalls: protected AST::Visitor
{
public:
@@ -78,6 +96,8 @@ public:
accept(node);
}
+ QList<Comment> comments;
+
protected:
using AST::Visitor::visit;
using AST::Visitor::endVisit;
@@ -114,10 +134,23 @@ protected:
plural = true;
}
+ QString id;
+ QString extracomment;
+ TranslatorMessage::ExtraData extra;
+ Comment scomment = findComment(node->firstSourceLocation().startLine);
+ if (scomment.isValid()) {
+ extracomment = scomment.extracomment;
+ extra = scomment.extra;
+ id = scomment.msgid;
+ }
+
TranslatorMessage msg(m_component, source,
comment, QString(), m_fileName,
node->firstSourceLocation().startLine, QStringList(),
TranslatorMessage::Unfinished, plural);
+ msg.setExtraComment(extracomment.simplified());
+ msg.setId(id);
+ msg.setExtras(extra);
m_translator->extend(msg);
}
} else if (idExpr->name->asString() == QLatin1String("qsTranslate") ||
@@ -140,6 +173,17 @@ protected:
}
if (!literal && m_bSource.isEmpty())
return;
+
+ QString id;
+ QString extracomment;
+ TranslatorMessage::ExtraData extra;
+ Comment scomment = findComment(node->firstSourceLocation().startLine);
+ if (scomment.isValid()) {
+ extracomment = scomment.extracomment;
+ extra = scomment.extra;
+ id = scomment.msgid;
+ }
+
source = literal ? literal->value->asString() : m_bSource;
AST::ArgumentList *commentNode = sourceNode->next;
if (commentNode && AST::cast<AST::StringLiteral *>(commentNode->expression)) {
@@ -155,15 +199,48 @@ protected:
comment, QString(), m_fileName,
node->firstSourceLocation().startLine, QStringList(),
TranslatorMessage::Unfinished, plural);
+ msg.setExtraComment(extracomment.simplified());
+ msg.setId(id);
+ msg.setExtras(extra);
m_translator->extend(msg);
}
+ } else if (idExpr->name->asString() == QLatin1String("qsTrId") ||
+ idExpr->name->asString() == QLatin1String("QT_TRID_NOOP")) {
+ if (!node->arguments)
+ return;
+ AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression);
+ if (literal) {
+
+ QString extracomment;
+ QString sourcetext;
+ TranslatorMessage::ExtraData extra;
+ Comment comment = findComment(node->firstSourceLocation().startLine);
+ if (comment.isValid()) {
+ extracomment = comment.extracomment;
+ sourcetext = comment.sourcetext;
+ extra = comment.extra;
+ }
+
+ const QString id = literal->value->asString();
+ bool plural = node->arguments->next;
+
+ TranslatorMessage msg(QString(), QString(),
+ QString(), QString(), m_fileName,
+ node->firstSourceLocation().startLine, QStringList(),
+ TranslatorMessage::Unfinished, plural);
+ msg.setExtraComment(extracomment.simplified());
+ msg.setId(id);
+ msg.setExtras(extra);
+ m_translator->extend(msg);
+ }
}
}
}
private:
- bool createString(AST::BinaryExpression *b) {
+ bool createString(AST::BinaryExpression *b)
+ {
if (!b || b->op != 0)
return false;
AST::BinaryExpression *l = AST::cast<AST::BinaryExpression *>(b->left);
@@ -187,6 +264,23 @@ private:
return true;
}
+ Comment findComment(int loc)
+ {
+ if (comments.isEmpty())
+ return Comment();
+
+ int i = 0;
+ int commentLoc = comments.at(i).lastLine;
+ while (commentLoc <= loc) {
+ if (commentLoc == loc)
+ return comments.at(i);
+ if (i == comments.count()-1)
+ break;
+ commentLoc = comments.at(++i).lastLine;
+ }
+ return Comment();
+ }
+
Translator *m_translator;
QString m_fileName;
QString m_component;
@@ -236,13 +330,60 @@ QString createErrorString(const QString &filename, const QString &code, Parser &
return errorString;
}
+bool processComment(const QChar *chars, int length, Comment &comment)
+{
+ // Try to match the logic of the QtScript parser.
+ if (!length)
+ return comment.isValid();
+ if (*chars == QLatin1Char(':') && chars[1].isSpace()) {
+ comment.extracomment += QString(chars+1, length-1);
+ } else if (*chars == QLatin1Char('=') && chars[1].isSpace()) {
+ comment.msgid = QString(chars+2, length-2).simplified();
+ } else if (*chars == QLatin1Char('~') && chars[1].isSpace()) {
+ QString text = QString(chars+2, length-2).trimmed();
+ int k = text.indexOf(QLatin1Char(' '));
+ if (k > -1)
+ comment.extra.insert(text.left(k), text.mid(k + 1).trimmed());
+ } else if (*chars == QLatin1Char('%') && chars[1].isSpace()) {
+ comment.sourcetext.reserve(comment.sourcetext.length() + length-2);
+ ushort *ptr = (ushort *)comment.sourcetext.data() + comment.sourcetext.length();
+ int p = 2, c;
+ forever {
+ if (p >= length)
+ break;
+ c = chars[p++].unicode();
+ if (isspace(c))
+ continue;
+ if (c != '"')
+ break;
+ forever {
+ if (p >= length)
+ break;
+ c = chars[p++].unicode();
+ if (c == '"')
+ break;
+ if (c == '\\') {
+ if (p >= length)
+ break;
+ c = chars[p++].unicode();
+ if (c == '\n')
+ break;
+ *ptr++ = '\\';
+ }
+ *ptr++ = c;
+ }
+ }
+ comment.sourcetext.resize(ptr - (ushort *)comment.sourcetext.data());
+ }
+ return comment.isValid();
+}
+
bool loadQml(Translator &translator, const QString &filename, ConversionData &cd)
{
cd.m_sourceFileName = filename;
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
+ cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
return false;
}
@@ -260,6 +401,25 @@ bool loadQml(Translator &translator, const QString &filename, ConversionData &cd
if (parser.parse()) {
FindTrCalls trCalls;
+
+ // build up a list of comments that contain translation information.
+ for (int i = 0; i < driver.comments().size(); ++i) {
+ AST::SourceLocation loc = driver.comments().at(i);
+ QString commentStr = code.mid(loc.offset, loc.length);
+
+ if (trCalls.comments.isEmpty() || trCalls.comments.last().lastLine != int(loc.startLine)) {
+ Comment comment;
+ comment.lastLine = loc.startLine+1;
+ if (processComment(commentStr.constData(), commentStr.length(), comment))
+ trCalls.comments.append(comment);
+ } else {
+ Comment &lastComment = trCalls.comments.last();
+ lastComment.lastLine += 1;
+ processComment(commentStr.constData(), commentStr.length(), lastComment);
+ }
+ }
+
+ //find all tr calls in the code
trCalls(&translator, filename, parser.ast());
} else {
QString error = createErrorString(filename, code, parser);
diff --git a/tools/linguist/lupdate/qscript.cpp b/tools/linguist/lupdate/qscript.cpp
index 188ac36..5323022 100644
--- a/tools/linguist/lupdate/qscript.cpp
+++ b/tools/linguist/lupdate/qscript.cpp
@@ -47,6 +47,7 @@
#include <translator.h>
+#include <QtCore/QCoreApplication>
#include <QtCore/qdebug.h>
#include <QtCore/qnumeric.h>
#include <QtCore/qstring.h>
@@ -62,6 +63,10 @@
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
class QScriptGrammar
{
public:
@@ -770,13 +775,16 @@ const int QScriptGrammar::action_check [] = {
static void recordMessage(
Translator *tor, const QString &context, const QString &text, const QString &comment,
- const QString &extracomment, bool plural, const QString &fileName, int lineNo)
+ const QString &extracomment, const QString &msgid, const TranslatorMessage::ExtraData &extra,
+ bool plural, const QString &fileName, int lineNo)
{
TranslatorMessage msg(
context, text, comment, QString(),
fileName, lineNo, QStringList(),
TranslatorMessage::Unfinished, plural);
msg.setExtraComment(extracomment.simplified());
+ msg.setId(msgid);
+ msg.setExtras(extra);
tor->extend(msg);
}
@@ -784,15 +792,23 @@ static void recordMessage(
namespace QScript
{
+class CommentProcessor
+{
+public:
+ virtual ~CommentProcessor() {}
+ virtual void processComment(const QChar *chars, int length) = 0;
+};
+
class Lexer
{
public:
- Lexer();
+ Lexer(CommentProcessor *);
~Lexer();
- void setCode(const QString &c, int lineno);
+ void setCode(const QString &c, const QString &fileName, int lineno);
int lex();
+ QString fileName() const { return yyfilename; }
int currentLineNo() const { return yylineno; }
int currentColumnNo() const { return yycolumn; }
@@ -872,6 +888,7 @@ public:
{ err = NoError; }
private:
+ QString yyfilename;
int yylineno;
bool done;
char *buffer8;
@@ -925,6 +942,8 @@ private:
void syncProhibitAutomaticSemicolon();
+ void processComment(const QChar *, int);
+
const QChar *code;
uint length;
int yycolumn;
@@ -951,6 +970,8 @@ private:
ParenthesesState parenthesesState;
int parenthesesCount;
bool prohibitAutomaticSemicolon;
+
+ CommentProcessor *commentProcessor;
};
} // namespace QScript
@@ -1027,7 +1048,7 @@ double integerFromString(const char *buf, int size, int radix)
} // namespace QScript
-QScript::Lexer::Lexer()
+QScript::Lexer::Lexer(QScript::CommentProcessor *proc)
:
yylineno(0),
size8(128), size16(128), restrKeyword(false),
@@ -1038,7 +1059,8 @@ QScript::Lexer::Lexer()
err(NoError),
check_reserved(true),
parenthesesState(IgnoreParentheses),
- prohibitAutomaticSemicolon(false)
+ prohibitAutomaticSemicolon(false),
+ commentProcessor(proc)
{
// allocate space for read buffers
buffer8 = new char[size8];
@@ -1053,9 +1075,10 @@ QScript::Lexer::~Lexer()
delete [] buffer16;
}
-void QScript::Lexer::setCode(const QString &c, int lineno)
+void QScript::Lexer::setCode(const QString &c, const QString &fileName, int lineno)
{
errmsg = QString();
+ yyfilename = fileName;
yylineno = lineno;
yycolumn = 1;
restrKeyword = false;
@@ -1404,10 +1427,12 @@ int QScript::Lexer::lex()
} else if (current == '/' && next1 == '/') {
recordStartPos();
shift(1);
+ Q_ASSERT(pos16 == 0);
state = InSingleLineComment;
} else if (current == '/' && next1 == '*') {
recordStartPos();
shift(1);
+ Q_ASSERT(pos16 == 0);
state = InMultiLineComment;
} else if (current == 0) {
syncProhibitAutomaticSemicolon();
@@ -1466,7 +1491,7 @@ int QScript::Lexer::lex()
else {
setDone(Bad);
err = IllegalCharacter;
- errmsg = QLatin1String("Illegal character");
+ errmsg = LU::tr("Illegal character");
}
}
break;
@@ -1477,7 +1502,7 @@ int QScript::Lexer::lex()
} else if (current == 0 || isLineTerminator()) {
setDone(Bad);
err = UnclosedStringLiteral;
- errmsg = QLatin1String("Unclosed string at end of line");
+ errmsg = LU::tr("Unclosed string at end of line");
} else if (current == '\\') {
state = InEscapeSequence;
} else {
@@ -1503,7 +1528,7 @@ int QScript::Lexer::lex()
} else {
setDone(Bad);
err = IllegalEscapeSequence;
- errmsg = QLatin1String("Illegal escape squence");
+ errmsg = LU::tr("Illegal escape squence");
}
} else if (current == 'x')
state = InHexEscape;
@@ -1542,14 +1567,17 @@ int QScript::Lexer::lex()
} else {
setDone(Bad);
err = IllegalUnicodeEscapeSequence;
- errmsg = QLatin1String("Illegal unicode escape sequence");
+ errmsg = LU::tr("Illegal unicode escape sequence");
}
break;
case InSingleLineComment:
if (isLineTerminator()) {
+ record16(current); // include newline
+ processComment(buffer16, pos16);
shiftWindowsLineBreak();
yylineno++;
yycolumn = 0;
+ pos16 = 0;
terminator = true;
bol = true;
if (restrKeyword) {
@@ -1559,19 +1587,25 @@ int QScript::Lexer::lex()
state = Start;
} else if (current == 0) {
setDone(Eof);
+ } else {
+ record16(current);
}
break;
case InMultiLineComment:
if (current == 0) {
setDone(Bad);
err = UnclosedComment;
- errmsg = QLatin1String("Unclosed comment at end of file");
+ errmsg = LU::tr("Unclosed comment at end of file");
} else if (isLineTerminator()) {
shiftWindowsLineBreak();
yylineno++;
} else if (current == '*' && next1 == '/') {
+ processComment(buffer16, pos16);
+ pos16 = 0;
state = Start;
shift(1);
+ } else {
+ record16(current);
}
break;
case InIdentifier:
@@ -1649,7 +1683,7 @@ int QScript::Lexer::lex()
} else {
setDone(Bad);
err = IllegalExponentIndicator;
- errmsg = QLatin1String("Illegal syntax for exponential number");
+ errmsg = LU::tr("Illegal syntax for exponential number");
}
break;
case InExponent:
@@ -1675,7 +1709,7 @@ int QScript::Lexer::lex()
&& isIdentLetter(current)) {
state = Bad;
err = IllegalIdentifier;
- errmsg = QLatin1String("Identifier cannot start with numeric literal");
+ errmsg = LU::tr("Identifier cannot start with numeric literal");
}
// terminate string
@@ -1994,7 +2028,7 @@ bool QScript::Lexer::scanRegExp(RegExpBodyPrefix prefix)
while (1) {
if (isLineTerminator() || current == 0) {
- errmsg = QLatin1String("Unterminated regular expression literal");
+ errmsg = LU::tr("Unterminated regular expression literal");
return false;
}
else if (current != '/' || lastWasEscape == true)
@@ -2033,10 +2067,15 @@ void QScript::Lexer::syncProhibitAutomaticSemicolon()
}
}
+void QScript::Lexer::processComment(const QChar *chars, int length)
+{
+ commentProcessor->processComment(chars, length);
+}
+
class Translator;
-class QScriptParser: protected QScriptGrammar
+class QScriptParser: protected QScriptGrammar, public QScript::CommentProcessor
{
public:
QVariant val;
@@ -2052,10 +2091,12 @@ public:
QScriptParser();
~QScriptParser();
- bool parse(QScript::Lexer *lexer,
- const QString &fileName,
- Translator *translator);
+ void setLexer(QScript::Lexer *);
+
+ bool parse(Translator *translator);
+ QString fileName() const
+ { return lexer->fileName(); }
inline QString errorMessage() const
{ return error_message; }
inline int errorLineNumber() const
@@ -2072,6 +2113,10 @@ protected:
inline Location &loc(int index)
{ return location_stack [tos + index - 2]; }
+ std::ostream &yyMsg(int line = 0);
+
+ virtual void processComment(const QChar *, int);
+
protected:
int tos;
int stack_size;
@@ -2081,6 +2126,13 @@ protected:
QString error_message;
int error_lineno;
int error_column;
+
+private:
+ QScript::Lexer *lexer;
+ QString extracomment;
+ QString msgid;
+ QString sourcetext;
+ TranslatorMessage::ExtraData extra;
};
inline void QScriptParser::reallocateStack()
@@ -2107,7 +2159,8 @@ QScriptParser::QScriptParser():
stack_size(0),
sym_stack(0),
state_stack(0),
- location_stack(0)
+ location_stack(0),
+ lexer(0)
{
}
@@ -2129,10 +2182,14 @@ static inline QScriptParser::Location location(QScript::Lexer *lexer)
return loc;
}
-bool QScriptParser::parse(QScript::Lexer *lexer,
- const QString &fileName,
- Translator *translator)
+void QScriptParser::setLexer(QScript::Lexer *lex)
{
+ lexer = lex;
+}
+
+bool QScriptParser::parse(Translator *translator)
+{
+ Q_ASSERT(lexer != 0);
const int INITIAL_STATE = 0;
int yytoken = -1;
@@ -2214,44 +2271,70 @@ case 8: {
case 66: {
QString name = sym(1).toString();
if ((name == QLatin1String("qsTranslate")) || (name == QLatin1String("QT_TRANSLATE_NOOP"))) {
+ if (!sourcetext.isEmpty())
+ yyMsg(identLineNo) << qPrintable(LU::tr("//% cannot be used with %1(). Ignoring\n").arg(name));
QVariantList args = sym(2).toList();
if (args.size() < 2) {
- std::cerr << qPrintable(fileName) << ':' << identLineNo << ": "
- << qPrintable(name) << "() requires at least two arguments.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least two arguments.\n").arg(name));
} else {
if ((args.at(0).type() != QVariant::String)
|| (args.at(1).type() != QVariant::String)) {
- std::cerr << qPrintable(fileName) << ':' << identLineNo << ": "
- << qPrintable(name) << "(): both arguments must be literal strings.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1(): both arguments must be literal strings.\n").arg(name));
} else {
QString context = args.at(0).toString();
QString text = args.at(1).toString();
QString comment = args.value(2).toString();
- QString extracomment;
bool plural = (args.size() > 4);
recordMessage(translator, context, text, comment, extracomment,
- plural, fileName, identLineNo);
+ msgid, extra, plural, fileName(), identLineNo);
}
}
+ sourcetext.clear();
+ extracomment.clear();
+ msgid.clear();
+ extra.clear();
} else if ((name == QLatin1String("qsTr")) || (name == QLatin1String("QT_TR_NOOP"))) {
+ if (!sourcetext.isEmpty())
+ yyMsg(identLineNo) << qPrintable(LU::tr("//% cannot be used with %1(). Ignoring\n").arg(name));
QVariantList args = sym(2).toList();
if (args.size() < 1) {
- std::cerr << qPrintable(fileName) << ':' << identLineNo << ": "
- << qPrintable(name) << "() requires at least one argument.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name));
} else {
if (args.at(0).type() != QVariant::String) {
- std::cerr << qPrintable(fileName) << ':' << identLineNo << ": "
- << qPrintable(name) << "(): text to translate must be a literal string.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1(): text to translate must be a literal string.\n").arg(name));
} else {
- QString context = QFileInfo(fileName).baseName();
+ QString context = QFileInfo(fileName()).baseName();
QString text = args.at(0).toString();
QString comment = args.value(1).toString();
- QString extracomment;
bool plural = (args.size() > 2);
recordMessage(translator, context, text, comment, extracomment,
- plural, fileName, identLineNo);
+ msgid, extra, plural, fileName(), identLineNo);
}
}
+ sourcetext.clear();
+ extracomment.clear();
+ msgid.clear();
+ extra.clear();
+ } else if ((name == QLatin1String("qsTrId")) || (name == QLatin1String("QT_TRID_NOOP"))) {
+ if (!msgid.isEmpty())
+ yyMsg(identLineNo) << qPrintable(LU::tr("//= cannot be used with %1(). Ignoring\n").arg(name));
+ QVariantList args = sym(2).toList();
+ if (args.size() < 1) {
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name));
+ } else {
+ if (args.at(0).type() != QVariant::String) {
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1(): identifier must be a literal string.\n").arg(name));
+ } else {
+ msgid = args.at(0).toString();
+ bool plural = (args.size() > 1);
+ recordMessage(translator, QString(), sourcetext, QString(), extracomment,
+ msgid, extra, plural, fileName(), identLineNo);
+ }
+ }
+ sourcetext.clear();
+ extracomment.clear();
+ msgid.clear();
+ extra.clear();
}
} break;
@@ -2278,6 +2361,44 @@ case 94: {
sym(1) = QVariant();
} break;
+ case 171:
+
+ case 172:
+
+ case 173:
+
+ case 174:
+
+ case 175:
+
+ case 176:
+
+ case 177:
+
+ case 178:
+
+ case 179:
+
+ case 180:
+
+ case 181:
+
+ case 182:
+
+ case 183:
+
+ case 184:
+
+ case 185:
+ if (!sourcetext.isEmpty() || !extracomment.isEmpty() || !msgid.isEmpty() || !extra.isEmpty()) {
+ yyMsg() << qPrintable(LU::tr("Discarding unconsumed meta data\n"));
+ sourcetext.clear();
+ extracomment.clear();
+ msgid.clear();
+ extra.clear();
+ }
+ break;
+
} // switch
state_stack [tos] = nt_action (act, lhs [r] - TERMINAL_COUNT);
@@ -2332,7 +2453,9 @@ case 94: {
for (int s = 0; s < shifts; ++s)
{
if (first)
- error_message += QLatin1String ("Expected ");
+ //: Beginning of the string that contains
+ //: comma-separated list of expected tokens
+ error_message += LU::tr("Expected ");
else
error_message += QLatin1String (", ");
@@ -2356,13 +2479,69 @@ case 94: {
return false;
}
+std::ostream &QScriptParser::yyMsg(int line)
+{
+ return std::cerr << qPrintable(fileName()) << ':' << (line ? line : lexer->startLineNo()) << ": ";
+}
+
+void QScriptParser::processComment(const QChar *chars, int length)
+{
+ if (!length)
+ return;
+ // Try to match the logic of the C++ parser.
+ if (*chars == QLatin1Char(':') && chars[1].isSpace()) {
+ extracomment += QString(chars+2, length-2);
+ } else if (*chars == QLatin1Char('=') && chars[1].isSpace()) {
+ msgid = QString(chars+2, length-2).simplified();
+ } else if (*chars == QLatin1Char('~') && chars[1].isSpace()) {
+ QString text = QString(chars+2, length-2).trimmed();
+ int k = text.indexOf(QLatin1Char(' '));
+ if (k > -1)
+ extra.insert(text.left(k), text.mid(k + 1).trimmed());
+ } else if (*chars == QLatin1Char('%') && chars[1].isSpace()) {
+ sourcetext.reserve(sourcetext.length() + length-2);
+ ushort *ptr = (ushort *)sourcetext.data() + sourcetext.length();
+ int p = 2, c;
+ forever {
+ if (p >= length)
+ break;
+ c = chars[p++].unicode();
+ if (isspace(c))
+ continue;
+ if (c != '"') {
+ yyMsg() << qPrintable(LU::tr("Unexpected character in meta string\n"));
+ break;
+ }
+ forever {
+ if (p >= length) {
+ whoops:
+ yyMsg() << qPrintable(LU::tr("Unterminated meta string\n"));
+ break;
+ }
+ c = chars[p++].unicode();
+ if (c == '"')
+ break;
+ if (c == '\\') {
+ if (p >= length)
+ goto whoops;
+ c = chars[p++].unicode();
+ if (c == '\n')
+ goto whoops;
+ *ptr++ = '\\';
+ }
+ *ptr++ = c;
+ }
+ }
+ sourcetext.resize(ptr - (ushort *)sourcetext.data());
+ }
+}
+
bool loadQScript(Translator &translator, const QString &filename, ConversionData &cd)
{
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
+ cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
return false;
}
QTextStream ts(&file);
@@ -2375,10 +2554,11 @@ bool loadQScript(Translator &translator, const QString &filename, ConversionData
ts.setAutoDetectUnicode(true);
QString code = ts.readAll();
- QScript::Lexer lexer;
- lexer.setCode(code, /*lineNumber=*/1);
QScriptParser parser;
- if (!parser.parse(&lexer, filename, &translator)) {
+ QScript::Lexer lexer(&parser);
+ lexer.setCode(code, filename, /*lineNumber=*/1);
+ parser.setLexer(&lexer);
+ if (!parser.parse(&translator)) {
std::cerr << qPrintable(filename) << ':' << parser.errorLineNumber() << ": "
<< qPrintable(parser.errorMessage()) << std::endl;
return false;
diff --git a/tools/linguist/lupdate/qscript.g b/tools/linguist/lupdate/qscript.g
index 857c58a..3655f2e 100644
--- a/tools/linguist/lupdate/qscript.g
+++ b/tools/linguist/lupdate/qscript.g
@@ -84,6 +84,7 @@
/.
#include <translator.h>
+#include <QtCore/QCoreApplication>
#include <QtCore/qdebug.h>
#include <QtCore/qnumeric.h>
#include <QtCore/qstring.h>
@@ -99,15 +100,22 @@
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
static void recordMessage(
Translator *tor, const QString &context, const QString &text, const QString &comment,
- const QString &extracomment, bool plural, const QString &fileName, int lineNo)
+ const QString &extracomment, const QString &msgid, const TranslatorMessage::ExtraData &extra,
+ bool plural, const QString &fileName, int lineNo)
{
TranslatorMessage msg(
context, text, comment, QString(),
fileName, lineNo, QStringList(),
TranslatorMessage::Unfinished, plural);
msg.setExtraComment(extracomment.simplified());
+ msg.setId(msgid);
+ msg.setExtras(extra);
tor->extend(msg);
}
@@ -115,15 +123,23 @@ static void recordMessage(
namespace QScript
{
+class CommentProcessor
+{
+public:
+ virtual ~CommentProcessor() {}
+ virtual void processComment(const QChar *chars, int length) = 0;
+};
+
class Lexer
{
public:
- Lexer();
+ Lexer(CommentProcessor *);
~Lexer();
- void setCode(const QString &c, int lineno);
+ void setCode(const QString &c, const QString &fileName, int lineno);
int lex();
+ QString fileName() const { return yyfilename; }
int currentLineNo() const { return yylineno; }
int currentColumnNo() const { return yycolumn; }
@@ -203,6 +219,7 @@ public:
{ err = NoError; }
private:
+ QString yyfilename;
int yylineno;
bool done;
char *buffer8;
@@ -256,6 +273,8 @@ private:
void syncProhibitAutomaticSemicolon();
+ void processComment(const QChar *, int);
+
const QChar *code;
uint length;
int yycolumn;
@@ -282,6 +301,8 @@ private:
ParenthesesState parenthesesState;
int parenthesesCount;
bool prohibitAutomaticSemicolon;
+
+ CommentProcessor *commentProcessor;
};
} // namespace QScript
@@ -358,7 +379,7 @@ double integerFromString(const char *buf, int size, int radix)
} // namespace QScript
-QScript::Lexer::Lexer()
+QScript::Lexer::Lexer(QScript::CommentProcessor *proc)
:
yylineno(0),
size8(128), size16(128), restrKeyword(false),
@@ -369,7 +390,8 @@ QScript::Lexer::Lexer()
err(NoError),
check_reserved(true),
parenthesesState(IgnoreParentheses),
- prohibitAutomaticSemicolon(false)
+ prohibitAutomaticSemicolon(false),
+ commentProcessor(proc)
{
// allocate space for read buffers
buffer8 = new char[size8];
@@ -384,9 +406,10 @@ QScript::Lexer::~Lexer()
delete [] buffer16;
}
-void QScript::Lexer::setCode(const QString &c, int lineno)
+void QScript::Lexer::setCode(const QString &c, const QString &fileName, int lineno)
{
errmsg = QString();
+ yyfilename = fileName;
yylineno = lineno;
yycolumn = 1;
restrKeyword = false;
@@ -735,10 +758,12 @@ int QScript::Lexer::lex()
} else if (current == '/' && next1 == '/') {
recordStartPos();
shift(1);
+ Q_ASSERT(pos16 == 0);
state = InSingleLineComment;
} else if (current == '/' && next1 == '*') {
recordStartPos();
shift(1);
+ Q_ASSERT(pos16 == 0);
state = InMultiLineComment;
} else if (current == 0) {
syncProhibitAutomaticSemicolon();
@@ -797,7 +822,7 @@ int QScript::Lexer::lex()
else {
setDone(Bad);
err = IllegalCharacter;
- errmsg = QLatin1String("Illegal character");
+ errmsg = LU::tr("Illegal character");
}
}
break;
@@ -808,7 +833,7 @@ int QScript::Lexer::lex()
} else if (current == 0 || isLineTerminator()) {
setDone(Bad);
err = UnclosedStringLiteral;
- errmsg = QLatin1String("Unclosed string at end of line");
+ errmsg = LU::tr("Unclosed string at end of line");
} else if (current == '\\') {
state = InEscapeSequence;
} else {
@@ -834,7 +859,7 @@ int QScript::Lexer::lex()
} else {
setDone(Bad);
err = IllegalEscapeSequence;
- errmsg = QLatin1String("Illegal escape squence");
+ errmsg = LU::tr("Illegal escape squence");
}
} else if (current == 'x')
state = InHexEscape;
@@ -873,14 +898,17 @@ int QScript::Lexer::lex()
} else {
setDone(Bad);
err = IllegalUnicodeEscapeSequence;
- errmsg = QLatin1String("Illegal unicode escape sequence");
+ errmsg = LU::tr("Illegal unicode escape sequence");
}
break;
case InSingleLineComment:
if (isLineTerminator()) {
+ record16(current); // include newline
+ processComment(buffer16, pos16);
shiftWindowsLineBreak();
yylineno++;
yycolumn = 0;
+ pos16 = 0;
terminator = true;
bol = true;
if (restrKeyword) {
@@ -890,19 +918,25 @@ int QScript::Lexer::lex()
state = Start;
} else if (current == 0) {
setDone(Eof);
+ } else {
+ record16(current);
}
break;
case InMultiLineComment:
if (current == 0) {
setDone(Bad);
err = UnclosedComment;
- errmsg = QLatin1String("Unclosed comment at end of file");
+ errmsg = LU::tr("Unclosed comment at end of file");
} else if (isLineTerminator()) {
shiftWindowsLineBreak();
yylineno++;
} else if (current == '*' && next1 == '/') {
+ processComment(buffer16, pos16);
+ pos16 = 0;
state = Start;
shift(1);
+ } else {
+ record16(current);
}
break;
case InIdentifier:
@@ -980,7 +1014,7 @@ int QScript::Lexer::lex()
} else {
setDone(Bad);
err = IllegalExponentIndicator;
- errmsg = QLatin1String("Illegal syntax for exponential number");
+ errmsg = LU::tr("Illegal syntax for exponential number");
}
break;
case InExponent:
@@ -1006,7 +1040,7 @@ int QScript::Lexer::lex()
&& isIdentLetter(current)) {
state = Bad;
err = IllegalIdentifier;
- errmsg = QLatin1String("Identifier cannot start with numeric literal");
+ errmsg = LU::tr("Identifier cannot start with numeric literal");
}
// terminate string
@@ -1325,7 +1359,7 @@ bool QScript::Lexer::scanRegExp(RegExpBodyPrefix prefix)
while (1) {
if (isLineTerminator() || current == 0) {
- errmsg = QLatin1String("Unterminated regular expression literal");
+ errmsg = LU::tr("Unterminated regular expression literal");
return false;
}
else if (current != '/' || lastWasEscape == true)
@@ -1364,10 +1398,15 @@ void QScript::Lexer::syncProhibitAutomaticSemicolon()
}
}
+void QScript::Lexer::processComment(const QChar *chars, int length)
+{
+ commentProcessor->processComment(chars, length);
+}
+
class Translator;
-class QScriptParser: protected $table
+class QScriptParser: protected $table, public QScript::CommentProcessor
{
public:
QVariant val;
@@ -1383,10 +1422,12 @@ public:
QScriptParser();
~QScriptParser();
- bool parse(QScript::Lexer *lexer,
- const QString &fileName,
- Translator *translator);
+ void setLexer(QScript::Lexer *);
+ bool parse(Translator *translator);
+
+ QString fileName() const
+ { return lexer->fileName(); }
inline QString errorMessage() const
{ return error_message; }
inline int errorLineNumber() const
@@ -1403,6 +1444,10 @@ protected:
inline Location &loc(int index)
{ return location_stack [tos + index - 2]; }
+ std::ostream &yyMsg(int line = 0);
+
+ virtual void processComment(const QChar *, int);
+
protected:
int tos;
int stack_size;
@@ -1412,6 +1457,13 @@ protected:
QString error_message;
int error_lineno;
int error_column;
+
+private:
+ QScript::Lexer *lexer;
+ QString extracomment;
+ QString msgid;
+ QString sourcetext;
+ TranslatorMessage::ExtraData extra;
};
inline void QScriptParser::reallocateStack()
@@ -1438,7 +1490,8 @@ QScriptParser::QScriptParser():
stack_size(0),
sym_stack(0),
state_stack(0),
- location_stack(0)
+ location_stack(0),
+ lexer(0)
{
}
@@ -1460,10 +1513,14 @@ static inline QScriptParser::Location location(QScript::Lexer *lexer)
return loc;
}
-bool QScriptParser::parse(QScript::Lexer *lexer,
- const QString &fileName,
- Translator *translator)
+void QScriptParser::setLexer(QScript::Lexer *lex)
{
+ lexer = lex;
+}
+
+bool QScriptParser::parse(Translator *translator)
+{
+ Q_ASSERT(lexer != 0);
const int INITIAL_STATE = 0;
int yytoken = -1;
@@ -1630,44 +1687,70 @@ CallExpression: MemberExpression Arguments ;
case $rule_number: {
QString name = sym(1).toString();
if ((name == QLatin1String("qsTranslate")) || (name == QLatin1String("QT_TRANSLATE_NOOP"))) {
+ if (!sourcetext.isEmpty())
+ yyMsg(identLineNo) << qPrintable(LU::tr("//% cannot be used with %1(). Ignoring\n").arg(name));
QVariantList args = sym(2).toList();
if (args.size() < 2) {
- std::cerr << qPrintable(fileName) << ':' << identLineNo << ": "
- << qPrintable(name) << "() requires at least two arguments.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least two arguments.\n").arg(name));
} else {
if ((args.at(0).type() != QVariant::String)
|| (args.at(1).type() != QVariant::String)) {
- std::cerr << qPrintable(fileName) << ':' << identLineNo << ": "
- << qPrintable(name) << "(): both arguments must be literal strings.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1(): both arguments must be literal strings.\n").arg(name));
} else {
QString context = args.at(0).toString();
QString text = args.at(1).toString();
QString comment = args.value(2).toString();
- QString extracomment;
bool plural = (args.size() > 4);
recordMessage(translator, context, text, comment, extracomment,
- plural, fileName, identLineNo);
+ msgid, extra, plural, fileName(), identLineNo);
}
}
+ sourcetext.clear();
+ extracomment.clear();
+ msgid.clear();
+ extra.clear();
} else if ((name == QLatin1String("qsTr")) || (name == QLatin1String("QT_TR_NOOP"))) {
+ if (!sourcetext.isEmpty())
+ yyMsg(identLineNo) << qPrintable(LU::tr("//% cannot be used with %1(). Ignoring\n").arg(name));
QVariantList args = sym(2).toList();
if (args.size() < 1) {
- std::cerr << qPrintable(fileName) << ':' << identLineNo << ": "
- << qPrintable(name) << "() requires at least one argument.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name));
} else {
if (args.at(0).type() != QVariant::String) {
- std::cerr << qPrintable(fileName) << ':' << identLineNo << ": "
- << qPrintable(name) << "(): text to translate must be a literal string.\n";
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1(): text to translate must be a literal string.\n").arg(name));
} else {
- QString context = QFileInfo(fileName).baseName();
+ QString context = QFileInfo(fileName()).baseName();
QString text = args.at(0).toString();
QString comment = args.value(1).toString();
- QString extracomment;
bool plural = (args.size() > 2);
recordMessage(translator, context, text, comment, extracomment,
- plural, fileName, identLineNo);
+ msgid, extra, plural, fileName(), identLineNo);
}
}
+ sourcetext.clear();
+ extracomment.clear();
+ msgid.clear();
+ extra.clear();
+ } else if ((name == QLatin1String("qsTrId")) || (name == QLatin1String("QT_TRID_NOOP"))) {
+ if (!msgid.isEmpty())
+ yyMsg(identLineNo) << qPrintable(LU::tr("//= cannot be used with %1(). Ignoring\n").arg(name));
+ QVariantList args = sym(2).toList();
+ if (args.size() < 1) {
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1() requires at least one argument.\n").arg(name));
+ } else {
+ if (args.at(0).type() != QVariant::String) {
+ yyMsg(identLineNo) << qPrintable(LU::tr("%1(): identifier must be a literal string.\n").arg(name));
+ } else {
+ msgid = args.at(0).toString();
+ bool plural = (args.size() > 1);
+ recordMessage(translator, QString(), sourcetext, QString(), extracomment,
+ msgid, extra, plural, fileName(), identLineNo);
+ }
+ }
+ sourcetext.clear();
+ extracomment.clear();
+ msgid.clear();
+ extra.clear();
}
} break;
./
@@ -1813,20 +1896,73 @@ ExpressionNotInOpt: ;
ExpressionNotInOpt: ExpressionNotIn ;
Statement: Block ;
+/.
+ case $rule_number:
+./
Statement: VariableStatement ;
+/.
+ case $rule_number:
+./
Statement: EmptyStatement ;
+/.
+ case $rule_number:
+./
Statement: ExpressionStatement ;
+/.
+ case $rule_number:
+./
Statement: IfStatement ;
+/.
+ case $rule_number:
+./
Statement: IterationStatement ;
+/.
+ case $rule_number:
+./
Statement: ContinueStatement ;
+/.
+ case $rule_number:
+./
Statement: BreakStatement ;
+/.
+ case $rule_number:
+./
Statement: ReturnStatement ;
+/.
+ case $rule_number:
+./
Statement: WithStatement ;
+/.
+ case $rule_number:
+./
Statement: LabelledStatement ;
+/.
+ case $rule_number:
+./
Statement: SwitchStatement ;
+/.
+ case $rule_number:
+./
Statement: ThrowStatement ;
+/.
+ case $rule_number:
+./
Statement: TryStatement ;
+/.
+ case $rule_number:
+./
Statement: DebuggerStatement ;
+/.
+ case $rule_number:
+ if (!sourcetext.isEmpty() || !extracomment.isEmpty() || !msgid.isEmpty() || !extra.isEmpty()) {
+ yyMsg() << qPrintable(LU::tr("Discarding unconsumed meta data\n"));
+ sourcetext.clear();
+ extracomment.clear();
+ msgid.clear();
+ extra.clear();
+ }
+ break;
+./
Block: T_LBRACE StatementListOpt T_RBRACE ;
StatementList: Statement ;
@@ -1965,6 +2101,9 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
{
if (first)
error_message += QLatin1String ("Expected ");
+ //: Beginning of the string that contains
+ //: comma-separated list of expected tokens
+ error_message += LU::tr("Expected ");
else
error_message += QLatin1String (", ");
@@ -1988,13 +2127,69 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
return false;
}
+std::ostream &QScriptParser::yyMsg(int line)
+{
+ return std::cerr << qPrintable(fileName()) << ':' << (line ? line : lexer->startLineNo()) << ": ";
+}
+
+void QScriptParser::processComment(const QChar *chars, int length)
+{
+ if (!length)
+ return;
+ // Try to match the logic of the C++ parser.
+ if (*chars == QLatin1Char(':') && chars[1].isSpace()) {
+ extracomment += QString(chars+2, length-2);
+ } else if (*chars == QLatin1Char('=') && chars[1].isSpace()) {
+ msgid = QString(chars+2, length-2).simplified();
+ } else if (*chars == QLatin1Char('~') && chars[1].isSpace()) {
+ QString text = QString(chars+2, length-2).trimmed();
+ int k = text.indexOf(QLatin1Char(' '));
+ if (k > -1)
+ extra.insert(text.left(k), text.mid(k + 1).trimmed());
+ } else if (*chars == QLatin1Char('%') && chars[1].isSpace()) {
+ sourcetext.reserve(sourcetext.length() + length-2);
+ ushort *ptr = (ushort *)sourcetext.data() + sourcetext.length();
+ int p = 2, c;
+ forever {
+ if (p >= length)
+ break;
+ c = chars[p++].unicode();
+ if (isspace(c))
+ continue;
+ if (c != '"') {
+ yyMsg() << qPrintable(LU::tr("Unexpected character in meta string\n"));
+ break;
+ }
+ forever {
+ if (p >= length) {
+ whoops:
+ yyMsg() << qPrintable(LU::tr("Unterminated meta string\n"));
+ break;
+ }
+ c = chars[p++].unicode();
+ if (c == '"')
+ break;
+ if (c == '\\') {
+ if (p >= length)
+ goto whoops;
+ c = chars[p++].unicode();
+ if (c == '\n')
+ goto whoops;
+ *ptr++ = '\\';
+ }
+ *ptr++ = c;
+ }
+ }
+ sourcetext.resize(ptr - (ushort *)sourcetext.data());
+ }
+}
+
bool loadQScript(Translator &translator, const QString &filename, ConversionData &cd)
{
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
+ cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
return false;
}
QTextStream ts(&file);
@@ -2007,10 +2202,11 @@ bool loadQScript(Translator &translator, const QString &filename, ConversionData
ts.setAutoDetectUnicode(true);
QString code = ts.readAll();
- QScript::Lexer lexer;
- lexer.setCode(code, /*lineNumber=*/1);
QScriptParser parser;
- if (!parser.parse(&lexer, filename, &translator)) {
+ QScript::Lexer lexer(&parser);
+ lexer.setCode(code, filename, /*lineNumber=*/1);
+ parser.setLexer(&lexer);
+ if (!parser.parse(&translator)) {
std::cerr << qPrintable(filename) << ':' << parser.errorLineNumber() << ": "
<< qPrintable(parser.errorMessage()) << std::endl;
return false;
diff --git a/tools/linguist/lupdate/ui.cpp b/tools/linguist/lupdate/ui.cpp
index 9e22922..797ab1f 100644
--- a/tools/linguist/lupdate/ui.cpp
+++ b/tools/linguist/lupdate/ui.cpp
@@ -43,6 +43,7 @@
#include <translator.h>
+#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QString>
@@ -55,6 +56,10 @@
QT_BEGIN_NAMESPACE
+class LU {
+ Q_DECLARE_TR_FUNCTIONS(LUpdate)
+};
+
class UiReader : public QXmlDefaultHandler
{
public:
@@ -152,11 +157,10 @@ bool UiReader::characters(const QString &ch)
bool UiReader::fatalError(const QXmlParseException &exception)
{
- QString msg;
- msg.sprintf("XML error: Parse error at line %d, column %d (%s).",
- exception.lineNumber(), exception.columnNumber(),
- exception.message().toLatin1().data());
- m_cd.appendError(msg);
+ QString msg = LU::tr("XML error: Parse error at line %1, column %2 (%3).")
+ .arg(exception.lineNumber()).arg(exception.columnNumber())
+ .arg(exception.message());
+ m_cd.appendError(msg);
return false;
}
@@ -181,8 +185,7 @@ bool loadUI(Translator &translator, const QString &filename, ConversionData &cd)
cd.m_sourceFileName = filename;
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
+ cd.appendError(LU::tr("Cannot open %1: %2").arg(filename, file.errorString()));
return false;
}
QXmlInputSource in(&file);
@@ -196,7 +199,7 @@ bool loadUI(Translator &translator, const QString &filename, ConversionData &cd)
reader.setErrorHandler(&handler);
bool result = reader.parse(in);
if (!result)
- cd.appendError(QLatin1String("Parse error in UI file"));
+ cd.appendError(LU::tr("Parse error in UI file"));
reader.setContentHandler(0);
reader.setErrorHandler(0);
return result;
diff --git a/tools/linguist/shared/po.cpp b/tools/linguist/shared/po.cpp
index a692332..3fd05ee 100644
--- a/tools/linguist/shared/po.cpp
+++ b/tools/linguist/shared/po.cpp
@@ -50,8 +50,6 @@
#include <ctype.h>
-#define MAGIC_OBSOLETE_REFERENCE "Obsolete_PO_entries"
-
// Uncomment if you wish to hard wrap long lines in .po files. Note that this
// affects only msg strings, not comments.
//#define HARD_WRAP_LONG_WORDS
@@ -555,15 +553,26 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd)
TranslatorMessage msg;
msg.setContext(codec->toUnicode(item.context));
if (!item.references.isEmpty()) {
+ QString xrefs;
foreach (const QString &ref,
codec->toUnicode(item.references).split(
QRegExp(QLatin1String("\\s")), QString::SkipEmptyParts)) {
- int pos = ref.lastIndexOf(QLatin1Char(':'));
- if (pos != -1)
- msg.addReference(ref.left(pos), ref.mid(pos + 1).toInt());
+ int pos = ref.indexOf(QLatin1Char(':'));
+ int lpos = ref.lastIndexOf(QLatin1Char(':'));
+ if (pos != -1 && pos == lpos) {
+ bool ok;
+ int lno = ref.mid(pos + 1).toInt(&ok);
+ if (ok) {
+ msg.addReference(ref.left(pos), lno);
+ continue;
+ }
+ }
+ if (!xrefs.isEmpty())
+ xrefs += QLatin1Char(' ');
+ xrefs += ref;
}
- } else if (isObsolete) {
- msg.setFileName(QLatin1String(MAGIC_OBSOLETE_REFERENCE));
+ if (!xrefs.isEmpty())
+ item.extra[QLatin1String("po-references")] = xrefs;
}
msg.setId(codec->toUnicode(item.id));
msg.setSourceText(codec->toUnicode(item.msgId));
@@ -660,6 +669,8 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd)
item.isPlural = true;
} else if (line.startsWith("#~ msgctxt ")) {
item.tscomment = slurpEscapedString(lines, l, 11, "#~ ", cd);
+ if (qtContexts)
+ splitContext(&item.tscomment, &item.context);
} else {
cd.appendError(QString(QLatin1String("PO-format parse error in line %1: '%2'"))
.arg(l + 1).arg(codec->toUnicode(lines[l])));
@@ -773,11 +784,14 @@ bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd)
if (!msg.id().isEmpty())
out << QLatin1String("#. ts-id ") << msg.id() << '\n';
- if (!msg.fileName().isEmpty() && msg.fileName() != QLatin1String(MAGIC_OBSOLETE_REFERENCE)) {
+ QString xrefs = msg.extra(QLatin1String("po-references"));
+ if (!msg.fileName().isEmpty() || !xrefs.isEmpty()) {
QStringList refs;
foreach (const TranslatorMessage::Reference &ref, msg.allReferences())
refs.append(QString(QLatin1String("%2:%1"))
.arg(ref.lineNumber()).arg(ref.fileName()));
+ if (!xrefs.isEmpty())
+ refs << xrefs;
out << poWrappedEscapedLines(QLatin1String("#:"), true, refs.join(QLatin1String(" ")));
}
diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h
index cfb2178..02cfb07 100644
--- a/tools/linguist/shared/translator.h
+++ b/tools/linguist/shared/translator.h
@@ -123,8 +123,8 @@ class Translator
public:
Translator();
- bool load(const QString &filename, ConversionData &err, const QString &format /*= "auto"*/);
- bool save(const QString &filename, ConversionData &err, const QString &format /*= "auto"*/) const;
+ bool load(const QString &filename, ConversionData &err, const QString &format /* = "auto" */);
+ bool save(const QString &filename, ConversionData &err, const QString &format /* = "auto" */) const;
bool release(QFile *iod, ConversionData &cd) const;
int find(const TranslatorMessage &msg) const;
diff --git a/tools/linguist/shared/xliff.cpp b/tools/linguist/shared/xliff.cpp
index 6411426..70724ef 100644
--- a/tools/linguist/shared/xliff.cpp
+++ b/tools/linguist/shared/xliff.cpp
@@ -53,6 +53,11 @@
#include <QtXml/QXmlParseException>
+// The string value is historical and reflects the main purpose: Keeping
+// obsolete entries separate from the magic file message (which both have
+// no location information, but typically reside at opposite ends of the file).
+#define MAGIC_OBSOLETE_REFERENCE "Obsolete_PO_entries"
+
QT_BEGIN_NAMESPACE
/**
@@ -692,6 +697,9 @@ bool XLIFFHandler::finalizeMessage(bool isPlural)
m_cd.appendError(QLatin1String("XLIFF syntax error: Message without source string."));
return false;
}
+ if (m_type == TranslatorMessage::Obsolete && m_refs.size() == 1
+ && m_refs.at(0).fileName() == QLatin1String(MAGIC_OBSOLETE_REFERENCE))
+ m_refs.clear();
TranslatorMessage msg(m_context, m_sources[0],
m_comment, QString(), QString(), -1,
m_translations, m_type, isPlural);
@@ -761,12 +769,15 @@ bool saveXLIFF(const Translator &translator, QIODevice &dev, ConversionData &cd)
QHash<QString, QList<QString> > contextOrder;
QList<QString> fileOrder;
foreach (const TranslatorMessage &msg, translator.messages()) {
- QHash<QString, QList<TranslatorMessage> > &file = messageOrder[msg.fileName()];
+ QString fn = msg.fileName();
+ if (fn.isEmpty() && msg.type() == TranslatorMessage::Obsolete)
+ fn = QLatin1String(MAGIC_OBSOLETE_REFERENCE);
+ QHash<QString, QList<TranslatorMessage> > &file = messageOrder[fn];
if (file.isEmpty())
- fileOrder.append(msg.fileName());
+ fileOrder.append(fn);
QList<TranslatorMessage> &context = file[msg.context()];
if (context.isEmpty())
- contextOrder[msg.fileName()].append(msg.context());
+ contextOrder[fn].append(msg.context());
context.append(msg);
}
diff --git a/tools/porting/src/errors.cpp b/tools/porting/src/errors.cpp
index 580efb5..9081dba 100644
--- a/tools/porting/src/errors.cpp
+++ b/tools/porting/src/errors.cpp
@@ -44,8 +44,8 @@
QT_BEGIN_NAMESPACE
-QT_STATIC_CONST_IMPL Error& Errors::InternalError = Error( 1, -1, QLatin1String("Internal Error") );
-QT_STATIC_CONST_IMPL Error& Errors::SyntaxError = Error( 2, -1, QLatin1String("Syntax Error before '%1'") );
-QT_STATIC_CONST_IMPL Error& Errors::ParseError = Error( 3, -1, QLatin1String("Parse Error before '%1'") );
+QT_STATIC_CONST_IMPL Error Errors::InternalError = Error( 1, -1, QLatin1String("Internal Error") );
+QT_STATIC_CONST_IMPL Error Errors::SyntaxError = Error( 2, -1, QLatin1String("Syntax Error before '%1'") );
+QT_STATIC_CONST_IMPL Error Errors::ParseError = Error( 3, -1, QLatin1String("Parse Error before '%1'") );
QT_END_NAMESPACE
diff --git a/tools/porting/src/errors.h b/tools/porting/src/errors.h
index f0ad691..dbac833 100644
--- a/tools/porting/src/errors.h
+++ b/tools/porting/src/errors.h
@@ -61,9 +61,9 @@ public:
class Errors
{
public:
- QT_STATIC_CONST Error& InternalError;
- QT_STATIC_CONST Error& SyntaxError;
- QT_STATIC_CONST Error& ParseError;
+ QT_STATIC_CONST Error InternalError;
+ QT_STATIC_CONST Error SyntaxError;
+ QT_STATIC_CONST Error ParseError;
};
QT_END_NAMESPACE
diff --git a/tools/porting/src/rpp.cpp b/tools/porting/src/rpp.cpp
index 7b0bea1..2e2aa97 100644
--- a/tools/porting/src/rpp.cpp
+++ b/tools/porting/src/rpp.cpp
@@ -60,7 +60,7 @@ Source *Preprocessor::parse(const TokenEngine::TokenContainer &tokenContainer,
const QVector<Type> &tokenTypeList, TypedPool<Item> *memoryPool)
{
m_memoryPool = memoryPool;
- Source *m_source = createNode<Source>(m_memoryPool); //node whith no parent
+ Source *m_source = createNode<Source>(m_memoryPool); //node with no parent
m_tokenContainer = tokenContainer;
m_tokenTypeList = tokenTypeList;
lexerTokenIndex = 0;
@@ -538,7 +538,7 @@ bool Preprocessor::parsePragmaDirective(Item *group)
}
/*
Reads a preprocessor line from the source by advancing lexerTokenIndex and
- returing a TokenSection containg the read line. Text lines separated by
+ returning a TokenSection containing the read line. Text lines separated by
an escaped newline are joined.
*/
TokenSection Preprocessor::readLine()
diff --git a/tools/porting/src/semantic.cpp b/tools/porting/src/semantic.cpp
index cf0b141..bd9175f 100644
--- a/tools/porting/src/semantic.cpp
+++ b/tools/porting/src/semantic.cpp
@@ -806,10 +806,10 @@ void Semantic::parseNameUse(NameAST* name)
}
/*
- looks up name used in basescope. If name->isGlobal() is true or if classOrNamespaceList()
+ Looks up name used in basescope. If name->isGlobal() is true or if classOrNamespaceList()
returns a non-empty list, the C++ qualified name lookup rules are used. Otherwise the
unquialified name lookup rules are used. Returns the a list of members that was found,
- In most cases this list will contain zero or one element, exept in the case of overloaded functions.
+ In most cases this list will contain zero or one element, except in the case of overloaded functions.
TODO: Argument-dependent name lookup
*/
QList<CodeModel::Member *> Semantic::nameLookup(CodeModel::Scope *baseScope, const NameAST* name)
diff --git a/tools/porting/src/tokenengine.h b/tools/porting/src/tokenengine.h
index d998411..db68d88 100644
--- a/tools/porting/src/tokenengine.h
+++ b/tools/porting/src/tokenengine.h
@@ -55,7 +55,7 @@ namespace TokenEngine {
class TokenContainer;
/*
- A token is defined as a start-postion and a lenght. Since the actual text
+ A token is defined as a start-position and a length. Since the actual text
storage is not reffered to here, Token needs to be used together with
a TokenContainer in order to be useful.
*/
diff --git a/tools/porting/src/tokenreplacements.cpp b/tools/porting/src/tokenreplacements.cpp
index 02b7751..fa3cff8 100644
--- a/tools/porting/src/tokenreplacements.cpp
+++ b/tools/porting/src/tokenreplacements.cpp
@@ -126,7 +126,7 @@ int QualifiedNameParser::findScopeOperator(Direction direction)
{
int tokenIndex = currentIndex;
QByteArray tokenText;
- //loop until we get a token containg text or we pass the beginning/end of the source
+ //loop until we get a token containing text or we pass the beginning/end of the source
tokenIndex += direction;
while(tokenText.isEmpty() && isValidIndex(tokenIndex)) {
tokenText = tokenContainer.text(tokenIndex).trimmed();
@@ -146,7 +146,7 @@ int QualifiedNameParser::nextScopeToken(Direction direction)
if (tokenIndex == -1)
return -1;
QByteArray tokenText;
- //loop until we get a token containg text or we pass the start of the source
+ //loop until we get a token containing text or we pass the start of the source
tokenIndex += direction;
while(tokenText.isEmpty() && isValidIndex(tokenIndex)) {
tokenText = tokenContainer.text(tokenIndex).trimmed();
@@ -266,7 +266,7 @@ bool ScopedTokenReplacement::doReplace(const TokenContainer &tokenContainer, int
if (!attributes->attribute(sourceIndex, "unknown").isEmpty())
return false;
// If nameUse is set we test if the nameUse refers to the correct declaration.
- // This is done by checking the parentScope attriute, wich returns the scope
+ // This is done by checking the parentScope attribute, which returns the scope
// for the declaration associated with this name use.
const bool haveNameUseInfo = !attributes->attribute(sourceIndex, "nameUse").isEmpty();
if (haveNameUseInfo) {
@@ -314,7 +314,7 @@ bool ScopedTokenReplacement::doReplace(const TokenContainer &tokenContainer, int
const QByteArray sourceScope = tokenContainer.text(sourceScopeIndex);
// If we have no name use info and the source and old scopes don't match,
- // we generally dont't do a replace, unless the old scope is Qt and
+ // we generally don't do a replace, unless the old scope is Qt and
// the source scope inherits Qt. For example, QWidget::ButtonState should
// be renamed to Qt::ButtonState.
if (!haveNameUseInfo && sourceScope != oldScope) {
diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp
index 7892025..a83a321 100644
--- a/tools/qdoc3/ditaxmlgenerator.cpp
+++ b/tools/qdoc3/ditaxmlgenerator.cpp
@@ -544,6 +544,7 @@ void DitaXmlGenerator::generateTree(const Tree *tree, CodeMarker *marker)
funcIndex.clear();
legaleseTexts.clear();
serviceClasses.clear();
+ qmlClasses.clear();
findAllClasses(tree->root());
findAllFunctions(tree->root());
findAllLegaleseTexts(tree->root());
@@ -751,6 +752,9 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
else if (atom->string() == "classes") {
generateCompactList(relative, marker, nonCompatClasses, true);
}
+ else if (atom->string() == "qmlclasses") {
+ generateCompactList(relative, marker, qmlClasses, true);
+ }
else if (atom->string().contains("classesbymodule")) {
QString arg = atom->string().trimmed();
QString moduleName = atom->string().mid(atom->string().indexOf(
@@ -3675,6 +3679,12 @@ void DitaXmlGenerator::findAllClasses(const InnerNode *node)
if (!serviceName.isEmpty())
serviceClasses.insert(serviceName, *c);
}
+ else if ((*c)->type() == Node::Fake &&
+ (*c)->subType() == Node::QmlClass &&
+ !(*c)->doc().isEmpty()) {
+ QString qmlClassName = (*c)->name();
+ qmlClasses.insert(qmlClassName,*c);
+ }
else if ((*c)->isInnerNode()) {
findAllClasses(static_cast<InnerNode *>(*c));
}
diff --git a/tools/qdoc3/doc/files/qt.qdocconf b/tools/qdoc3/doc/files/qt.qdocconf
index 09c112a..4546c7a 100644
--- a/tools/qdoc3/doc/files/qt.qdocconf
+++ b/tools/qdoc3/doc/files/qt.qdocconf
@@ -22,7 +22,7 @@ edition.DesktopLight.groups = -graphicsview-api
qhp.projects = Qt
qhp.Qt.file = qt.qhp
-qhp.Qt.namespace = com.trolltech.qt.470
+qhp.Qt.namespace = com.trolltech.qt.471
qhp.Qt.virtualFolder = qdoc
qhp.Qt.indexTitle = Qt Reference Documentation
qhp.Qt.indexRoot =
@@ -36,9 +36,9 @@ qhp.Qt.extraFiles = classic.css \
images/dynamiclayouts-example.png \
images/stylesheet-coffee-plastique.png
-qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc
-qhp.Qt.customFilters.Qt.name = Qt 4.7.0
-qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0
+qhp.Qt.filterAttributes = qt 4.7.1 qtrefdoc
+qhp.Qt.customFilters.Qt.name = Qt 4.7.1
+qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.1
qhp.Qt.subprojects = classes overviews examples
qhp.Qt.subprojects.classes.title = Classes
qhp.Qt.subprojects.classes.indexTitle = Qt's Classes
diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index 4603a40..77e306a 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -376,6 +376,7 @@ void HtmlGenerator::generateTree(const Tree *tree, CodeMarker *marker)
funcIndex.clear();
legaleseTexts.clear();
serviceClasses.clear();
+ qmlClasses.clear();
findAllClasses(tree->root());
findAllFunctions(tree->root());
findAllLegaleseTexts(tree->root());
@@ -611,6 +612,9 @@ int HtmlGenerator::generateAtom(const Atom *atom,
else if (atom->string() == "classes") {
generateCompactList(relative, marker, nonCompatClasses, true);
}
+ else if (atom->string() == "qmlclasses") {
+ generateCompactList(relative, marker, qmlClasses, true);
+ }
else if (atom->string().contains("classesbymodule")) {
QString arg = atom->string().trimmed();
QString moduleName = atom->string().mid(atom->string().indexOf(
@@ -939,10 +943,10 @@ int HtmlGenerator::generateAtom(const Atom *atom,
}
}
else {
- out() << "<ol type=";
+ out() << "<ol class=";
if (atom->string() == ATOM_LIST_UPPERALPHA) {
out() << "\"A\"";
- } /* why type? */
+ } /* why type? changed to */
else if (atom->string() == ATOM_LIST_LOWERALPHA) {
out() << "\"a\"";
}
@@ -1806,18 +1810,19 @@ void HtmlGenerator::generateHeader(const QString& title,
// Adding jquery and functions - providing online tools and search features
out() << " <script src=\"scripts/jquery.js\" type=\"text/javascript\"></script>\n";
out() << " <script src=\"scripts/functions.js\" type=\"text/javascript\"></script>\n";
- // Adding style and js for small windows
- out() << " <script src=\"./scripts/superfish.js\" type=\"text/javascript\"></script>\n";
- out() << " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/superfish.css\" />";
- out() << " <script src=\"./scripts/narrow.js\" type=\"text/javascript\"></script>\n";
- out() << " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/narrow.css\" />\n";
+
// Adding syntax highlighter // future release
- // Setting some additional style sheet related details depending on configuration (e.g. online/offline)
+ // Setting some additional style sheet related details depending on configuration (e.g. Online/Creator)
switch (application) {
case Online:
+ // Adding style and js for small windows
+ out() << " <script src=\"./scripts/superfish.js\" type=\"text/javascript\"></script>\n";
+ out() << " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/superfish.css\" />";
+ out() << " <script src=\"./scripts/narrow.js\" type=\"text/javascript\"></script>\n";
+ out() << " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/narrow.css\" />\n";
// Browser spec styles
out() << " <!--[if IE]>\n";
out() << "<meta name=\"MSSmartTagsPreventParsing\" content=\"true\">\n";
@@ -1961,7 +1966,7 @@ void HtmlGenerator::generateFooter(const Node *node)
switch (application) {
case Online:
out() << " <script src=\"scripts/functions.js\" type=\"text/javascript\"></script>\n";
- out() << " <!-- <script type=\"text/javascript\">\n";
+ out() << " <script type=\"text/javascript\">\n";
out() << " var _gaq = _gaq || [];\n";
out() << " _gaq.push(['_setAccount', 'UA-4457116-5']);\n";
out() << " _gaq.push(['_trackPageview']);\n";
@@ -1972,7 +1977,7 @@ void HtmlGenerator::generateFooter(const Node *node)
out() << "'.google-analytics.com/ga.js';\n";
out() << " var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n";
out() << " })();\n";
- out() << " </script> -->\n";
+ out() << " </script>\n";
out() << "</body>\n";
break;
case Creator:
@@ -3172,7 +3177,14 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode,
if (parseArg(src, typeTag, &i, srcSize, &arg, &par1)) {
par1 = QStringRef();
const Node* n = marker->resolveTarget(arg.toString(), myTree, relative, self);
- addLink(linkForNode(n,relative), arg, &html);
+ if (n && n->subType() == Node::QmlBasicType) {
+ if (relative && relative->subType() == Node::QmlClass)
+ addLink(linkForNode(n,relative), arg, &html);
+ else
+ html += arg.toString();
+ }
+ else
+ addLink(linkForNode(n,relative), arg, &html);
handled = true;
}
else if (parseArg(src, headerTag, &i, srcSize, &arg, &par1)) {
@@ -3534,7 +3546,7 @@ QString HtmlGenerator::linkForNode(const Node *node, const Node *relative)
return QString();
if (node->access() == Node::Private)
return QString();
-
+
fn = fileName(node);
/* if (!node->url().isEmpty())
return fn;*/
@@ -3707,6 +3719,12 @@ void HtmlGenerator::findAllClasses(const InnerNode *node)
if (!serviceName.isEmpty())
serviceClasses.insert(serviceName, *c);
}
+ else if ((*c)->type() == Node::Fake &&
+ (*c)->subType() == Node::QmlClass &&
+ !(*c)->doc().isEmpty()) {
+ QString qmlClassName = (*c)->name();
+ qmlClasses.insert(qmlClassName,*c);
+ }
else if ((*c)->isInnerNode()) {
findAllClasses(static_cast<InnerNode *>(*c));
}
@@ -4167,36 +4185,16 @@ void HtmlGenerator::generateQmlSummary(const Section& section,
CodeMarker *marker)
{
if (!section.members.isEmpty()) {
- NodeList::ConstIterator m;
- int count = section.members.size();
- bool twoColumn = false;
- if (section.members.first()->type() == Node::QmlProperty) {
- twoColumn = (count >= 5);
- twoColumn = false;
- }
- if (twoColumn)
- out() << "<table class=\"qmlsummary\">\n";
- if (++numTableRows % 2 == 1)
- out() << "<tr class=\"odd topAlign\">";
- else
- out() << "<tr class=\"even topAlign\">";
- // << "<tr><td class=\"topAlign\">";
out() << "<ul>\n";
-
- int row = 0;
+ NodeList::ConstIterator m;
m = section.members.begin();
while (m != section.members.end()) {
- if (twoColumn && row == (int) (count + 1) / 2)
- out() << "</ul></td><td class=\"topAlign\"><ul>\n";
out() << "<li class=\"fn\">";
generateQmlItem(*m,relative,marker,true);
out() << "</li>\n";
- row++;
++m;
}
out() << "</ul>\n";
- if (twoColumn)
- out() << "</td></tr>\n</table>\n";
}
}
@@ -4412,57 +4410,103 @@ bool HtmlGenerator::generatePageElement(QXmlStreamWriter& writer,
return true;
if (node->access() == Node::Private)
return false;
- if (!node->isInnerNode())
- return false;
+ QString guid = QUuid::createUuid().toString();
+ QString url = PageGenerator::fileName(node);
QString title;
QString rawTitle;
QString fullTitle;
- const InnerNode* inner = static_cast<const InnerNode*>(node);
-
- writer.writeStartElement("page");
+ QStringList pageWords;
QXmlStreamAttributes attributes;
- QString t;
- t.setNum(id++);
- switch (node->type()) {
- case Node::Fake:
- {
- const FakeNode* fake = static_cast<const FakeNode*>(node);
- title = fake->fullTitle();
+
+ writer.writeStartElement("page");
+
+ if (node->isInnerNode()) {
+ const InnerNode* inner = static_cast<const InnerNode*>(node);
+ if (!inner->pageKeywords().isEmpty())
+ pageWords << inner->pageKeywords();
+
+ switch (node->type()) {
+ case Node::Fake:
+ {
+ const FakeNode* fake = static_cast<const FakeNode*>(node);
+ title = fake->fullTitle();
+ pageWords << title;
+ break;
+ }
+ case Node::Class:
+ {
+ title = node->name() + " Class Reference";
+ pageWords << node->name() << "class" << "reference";
+ break;
+ }
+ case Node::Namespace:
+ {
+ rawTitle = marker->plainName(inner);
+ fullTitle = marker->plainFullName(inner);
+ title = rawTitle + " Namespace Reference";
+ pageWords << rawTitle << "namespace" << "reference";
+ break;
+ }
+ default:
+ title = node->name();
+ pageWords << title;
break;
}
- case Node::Class:
- {
- title = node->name() + " Class Reference";
+ }
+ else {
+ switch (node->type()) {
+ case Node::Enum:
+ {
+ title = node->name() + " Enum Reference";
+ pageWords << node->name() << "enum" << "type";
+ url += "#" + node->name() + "-enum";
+ break;
+ }
+ case Node::Function:
+ {
+ title = node->name() + " Function Reference";
+ pageWords << node->name() << "function";
+ url += "#" + node->name();
+ break;
+ }
+ case Node::Property:
+ {
+ title = node->name() + " Property Reference";
+ pageWords << node->name() << "property";
+ url += "#" + node->name() + "-prop";
+ break;
+ }
+ case Node::Typedef:
+ {
+ title = node->name() + " Type Reference";
+ pageWords << node->name() << "typedef" << "type";
+ url += "#" + node->name();
+ break;
+ }
+ default:
+ title = node->name();
+ pageWords << title;
break;
}
- case Node::Namespace:
- {
- rawTitle = marker->plainName(inner);
- fullTitle = marker->plainFullName(inner);
- title = rawTitle + " Namespace Reference";
- break;
+
+ Node* parent = node->parent();
+ if (parent && ((parent->type() == Node::Class) ||
+ (parent->type() == Node::Namespace))) {
+ pageWords << parent->name();
}
- default:
- title = node->name();
- break;
}
- writer.writeAttribute("id",t);
+
+ writer.writeAttribute("id",guid);
writer.writeStartElement("pageWords");
- writer.writeCharacters(title);
- if (!inner->pageKeywords().isEmpty()) {
- const QStringList& w = inner->pageKeywords();
- for (int i = 0; i < w.size(); ++i) {
- writer.writeCharacters(" ");
- writer.writeCharacters(w.at(i).toLocal8Bit().constData());
- }
- }
+ writer.writeCharacters(pageWords.join(" "));
+
writer.writeEndElement();
writer.writeStartElement("pageTitle");
writer.writeCharacters(title);
writer.writeEndElement();
writer.writeStartElement("pageUrl");
- writer.writeCharacters(PageGenerator::fileName(node));
+ writer.writeCharacters(url);
writer.writeEndElement();
writer.writeStartElement("pageType");
switch (node->pageType()) {
@@ -4480,6 +4524,35 @@ bool HtmlGenerator::generatePageElement(QXmlStreamWriter& writer,
}
writer.writeEndElement();
writer.writeEndElement();
+
+ if (node->type() == Node::Fake && node->doc().hasTableOfContents()) {
+ QList<Atom*> toc = node->doc().tableOfContents();
+ if (!toc.isEmpty()) {
+ for (int i = 0; i < toc.size(); ++i) {
+ Text headingText = Text::sectionHeading(toc.at(i));
+ QString s = headingText.toString();
+ writer.writeStartElement("page");
+ guid = QUuid::createUuid().toString();
+ QString internalUrl = url + "#" + Doc::canonicalTitle(s);
+ writer.writeAttribute("id",guid);
+ writer.writeStartElement("pageWords");
+ writer.writeCharacters(pageWords.join(" "));
+ writer.writeCharacters(" ");
+ writer.writeCharacters(s);
+ writer.writeEndElement();
+ writer.writeStartElement("pageTitle");
+ writer.writeCharacters(s);
+ writer.writeEndElement();
+ writer.writeStartElement("pageUrl");
+ writer.writeCharacters(internalUrl);
+ writer.writeEndElement();
+ writer.writeStartElement("pageType");
+ writer.writeCharacters("Article");
+ writer.writeEndElement();
+ writer.writeEndElement();
+ }
+ }
+ }
return true;
}
diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h
index eab10c6..d885ada 100644
--- a/tools/qdoc3/htmlgenerator.h
+++ b/tools/qdoc3/htmlgenerator.h
@@ -330,6 +330,7 @@ class HtmlGenerator : public PageGenerator
NodeMap obsoleteClasses;
NodeMap namespaceIndex;
NodeMap serviceClasses;
+ NodeMap qmlClasses;
QMap<QString, NodeMap > funcIndex;
QMap<Text, const Node *> legaleseTexts;
NewSinceMaps newSinceMaps;
diff --git a/tools/qdoc3/main.cpp b/tools/qdoc3/main.cpp
index fa7efee..2bfe38e 100644
--- a/tools/qdoc3/main.cpp
+++ b/tools/qdoc3/main.cpp
@@ -148,7 +148,7 @@ static void printHelp()
*/
static void printVersion()
{
- QString s = QString(tr("qdoc version ")) + QString(QT_VERSION_STR);
+ QString s = tr("qdoc version %1").arg(QT_VERSION_STR);
Location::information(s);
}
diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp
index 259641e..41f90d5 100644
--- a/tools/qdoc3/node.cpp
+++ b/tools/qdoc3/node.cpp
@@ -652,8 +652,14 @@ NodeList InnerNode::overloads(const QString &funcName) const
InnerNode::InnerNode(Type type, InnerNode *parent, const QString& name)
: Node(type, parent, name)
{
- if (type == Class)
+ switch (type) {
+ case Class:
+ case Namespace:
setPageType(ApiPage);
+ break;
+ default:
+ break;
+ }
}
/*!
@@ -845,6 +851,19 @@ bool LeafNode::isInnerNode() const
LeafNode::LeafNode(Type type, InnerNode *parent, const QString& name)
: Node(type, parent, name)
{
+ switch (type) {
+ case Enum:
+ case Function:
+ case Typedef:
+ case Variable:
+ case QmlProperty:
+ case QmlSignal:
+ case QmlMethod:
+ setPageType(ApiPage);
+ break;
+ default:
+ break;
+ }
}
/*!
@@ -1600,7 +1619,7 @@ QmlPropertyNode::QmlPropertyNode(QmlPropGroupNode *parent,
des(Trool_Default),
att(attached)
{
- // nothing.
+ setPageType(ApiPage);
}
/*!
diff --git a/tools/qdoc3/qdoc3.pro b/tools/qdoc3/qdoc3.pro
index 5bedc29..ae0bf25 100644
--- a/tools/qdoc3/qdoc3.pro
+++ b/tools/qdoc3/qdoc3.pro
@@ -6,6 +6,7 @@ DEFINES += QT_NO_CAST_TO_ASCII
qdoc_bootstrapped {
include(../../src/tools/bootstrap/bootstrap.pri)
+ SOURCES += ../../src/corelib/plugin/quuid.cpp
DEFINES -= QT_NO_CAST_FROM_ASCII
DEFINES += QT_NO_TRANSLATION
} else {
diff --git a/tools/qdoc3/test/assistant.qdocconf b/tools/qdoc3/test/assistant.qdocconf
index ab2b69a..bb98db4 100644
--- a/tools/qdoc3/test/assistant.qdocconf
+++ b/tools/qdoc3/test/assistant.qdocconf
@@ -6,7 +6,7 @@ include(qt-defines.qdocconf)
project = Qt Assistant
description = Qt Assistant Manual
-url = http://qt.nokia.com/doc/4.8
+url = http://doc.qt.nokia.com/4.8/
indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index
diff --git a/tools/qdoc3/test/designer.qdocconf b/tools/qdoc3/test/designer.qdocconf
index 1bb366d..448ed23 100644
--- a/tools/qdoc3/test/designer.qdocconf
+++ b/tools/qdoc3/test/designer.qdocconf
@@ -6,7 +6,7 @@ include(qt-defines.qdocconf)
project = Qt Designer
description = Qt Designer Manual
-url = http://qt.nokia.com/doc/4.8
+url = http://doc.qt.nokia.com/4.8/
indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index
@@ -18,6 +18,9 @@ qhp.Designer.virtualFolder = qdoc
qhp.Designer.indexTitle = Qt Designer Manual
qhp.Designer.extraFiles = images/bg_l.png \
images/bg_l_blank.png \
+ images/bg_ll_blank.png \
+ images/bg_ul_blank.png \
+ images/header_bg.png \
images/bg_r.png \
images/box_bg.png \
images/breadcrumb.png \
@@ -25,12 +28,12 @@ qhp.Designer.extraFiles = images/bg_l.png \
images/bullet_dn.png \
images/bullet_sq.png \
images/bullet_up.png \
+ images/arrow_down.png \
images/feedbackground.png \
images/horBar.png \
images/page.png \
images/page_bg.png \
images/sprites-combined.png \
- images/arrow-down.png \
images/spinner.gif \
images/stylesheet-coffee-plastique.png \
images/taskmenuextension-example.png \
@@ -38,7 +41,10 @@ qhp.Designer.extraFiles = images/bg_l.png \
images/dynamiclayouts-example.png \
scripts/functions.js \
scripts/jquery.js \
- style/OfflineStyle.css \
+ scripts/narrow.js \
+ scripts/superfish.js \
+ style/narrow.css \
+ style/superfish.css \
style/style_ie6.css \
style/style_ie7.css \
style/style_ie8.css \
diff --git a/tools/qdoc3/test/linguist.qdocconf b/tools/qdoc3/test/linguist.qdocconf
index 4cb4cc7..7c4b938 100644
--- a/tools/qdoc3/test/linguist.qdocconf
+++ b/tools/qdoc3/test/linguist.qdocconf
@@ -6,7 +6,7 @@ include(qt-defines.qdocconf)
project = Qt Linguist
description = Qt Linguist Manual
-url = http://qt.nokia.com/doc/4.8
+url = http://doc.qt.nokia.com/4.8/
indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index
@@ -18,6 +18,9 @@ qhp.Linguist.virtualFolder = qdoc
qhp.Linguist.indexTitle = Qt Linguist Manual
qhp.Linguist.extraFiles = images/bg_l.png \
images/bg_l_blank.png \
+ images/bg_ll_blank.png \
+ images/bg_ul_blank.png \
+ images/header_bg.png \
images/bg_r.png \
images/box_bg.png \
images/breadcrumb.png \
@@ -25,20 +28,23 @@ qhp.Linguist.extraFiles = images/bg_l.png \
images/bullet_dn.png \
images/bullet_sq.png \
images/bullet_up.png \
+ images/arrow_down.png \
images/feedbackground.png \
images/horBar.png \
images/page.png \
images/page_bg.png \
images/sprites-combined.png \
- images/arrow-down.png \
-s images/spinner.gif \
+ images/spinner.gif \
images/stylesheet-coffee-plastique.png \
images/taskmenuextension-example.png \
images/coloreditorfactoryimage.png \
images/dynamiclayouts-example.png \
scripts/functions.js \
scripts/jquery.js \
- style/OfflineStyle.css \
+ scripts/narrow.js \
+ scripts/superfish.js \
+ style/narrow.css \
+ style/superfish.css \
style/style_ie6.css \
style/style_ie7.css \
style/style_ie8.css \
diff --git a/tools/qdoc3/test/qdeclarative.qdocconf b/tools/qdoc3/test/qdeclarative.qdocconf
index 80bca29..45f48a6 100644
--- a/tools/qdoc3/test/qdeclarative.qdocconf
+++ b/tools/qdoc3/test/qdeclarative.qdocconf
@@ -28,32 +28,38 @@ qhp.Qml.indexTitle = Qml Reference
# Files not referenced in any qdoc file
# See also extraimages.HTML
qhp.Qml.extraFiles = images/bg_l.png \
- images/bg_l_blank.png \
- images/bg_r.png \
- images/box_bg.png \
- images/breadcrumb.png \
- images/bullet_gt.png \
- images/bullet_dn.png \
- images/bullet_sq.png \
- images/bullet_up.png \
- images/feedbackground.png \
- images/horBar.png \
- images/page.png \
- images/page_bg.png \
- images/sprites-combined.png \
- images/arrow-down.png \
- images/spinner.png \
- images/stylesheet-coffee-plastique.png \
- images/taskmenuextension-example.png \
- images/coloreditorfactoryimage.png \
- images/dynamiclayouts-example.png \
- scripts/functions.js \
- scripts/jquery.js \
- style/OfflineStyle.css \
- style/style_ie6.css \
- style/style_ie7.css \
- style/style_ie8.css \
- style/style.css
+ images/bg_l_blank.png \
+ images/bg_ll_blank.png \
+ images/bg_ul_blank.png \
+ images/header_bg.png \
+ images/bg_r.png \
+ images/box_bg.png \
+ images/breadcrumb.png \
+ images/bullet_gt.png \
+ images/bullet_dn.png \
+ images/bullet_sq.png \
+ images/bullet_up.png \
+ images/arrow_down.png \
+ images/feedbackground.png \
+ images/horBar.png \
+ images/page.png \
+ images/page_bg.png \
+ images/sprites-combined.png \
+ images/spinner.gif \
+ images/stylesheet-coffee-plastique.png \
+ images/taskmenuextension-example.png \
+ images/coloreditorfactoryimage.png \
+ images/dynamiclayouts-example.png \
+ scripts/functions.js \
+ scripts/jquery.js \
+ scripts/narrow.js \
+ scripts/superfish.js \
+ style/narrow.css \
+ style/superfish.css \
+ style/style_ie6.css \
+ style/style_ie7.css \
+ style/style_ie8.css \
+ style/style.css
qhp.Qml.filterAttributes = qt 4.7.0 qtrefdoc
qhp.Qml.customFilters.Qt.name = Qt 4.7.0
diff --git a/tools/qdoc3/test/qmake.qdocconf b/tools/qdoc3/test/qmake.qdocconf
index 04fe6f8..56e7f96 100644
--- a/tools/qdoc3/test/qmake.qdocconf
+++ b/tools/qdoc3/test/qmake.qdocconf
@@ -17,32 +17,38 @@ qhp.qmake.namespace = com.trolltech.qmake.480
qhp.qmake.virtualFolder = qdoc
qhp.qmake.indexTitle = QMake Manual
qhp.qmake.extraFiles = images/bg_l.png \
- images/bg_l_blank.png \
- images/bg_r.png \
- images/box_bg.png \
- images/breadcrumb.png \
- images/bullet_gt.png \
- images/bullet_dn.png \
- images/bullet_sq.png \
- images/bullet_up.png \
- images/feedbackground.png \
- images/horBar.png \
- images/page.png \
- images/page_bg.png \
- images/sprites-combined.png \
- images/arrow-down.png \
- images/spinner.gif \
- images/stylesheet-coffee-plastique.png \
- images/taskmenuextension-example.png \
- images/coloreditorfactoryimage.png \
- images/dynamiclayouts-example.png \
- scripts/functions.js \
- scripts/jquery.js \
- style/OfflineStyle.css \
- style/style_ie6.css \
- style/style_ie7.css \
- style/style_ie8.css \
- style/style.css
+ images/bg_l_blank.png \
+ images/bg_ll_blank.png \
+ images/bg_ul_blank.png \
+ images/header_bg.png \
+ images/bg_r.png \
+ images/box_bg.png \
+ images/breadcrumb.png \
+ images/bullet_gt.png \
+ images/bullet_dn.png \
+ images/bullet_sq.png \
+ images/bullet_up.png \
+ images/arrow_down.png \
+ images/feedbackground.png \
+ images/horBar.png \
+ images/page.png \
+ images/page_bg.png \
+ images/sprites-combined.png \
+ images/spinner.gif \
+ images/stylesheet-coffee-plastique.png \
+ images/taskmenuextension-example.png \
+ images/coloreditorfactoryimage.png \
+ images/dynamiclayouts-example.png \
+ scripts/functions.js \
+ scripts/jquery.js \
+ scripts/narrow.js \
+ scripts/superfish.js \
+ style/narrow.css \
+ style/superfish.css \
+ style/style_ie6.css \
+ style/style_ie7.css \
+ style/style_ie8.css \
+ style/style.css
qhp.qmake.filterAttributes = qt 4.8.0 tools qmake
qhp.qmake.customFilters.qmake.name = qmake Manual
diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf
index a674c72..6a06a8c 100644
--- a/tools/qdoc3/test/qt-build-docs.qdocconf
+++ b/tools/qdoc3/test/qt-build-docs.qdocconf
@@ -103,6 +103,7 @@ excludedirs = $QT_SOURCE_TREE/src/3rdparty/clucene \
$QT_SOURCE_TREE/src/3rdparty/freetype \
$QT_SOURCE_TREE/src/3rdparty/harfbuzz \
$QT_SOURCE_TREE/src/3rdparty/kdebase \
+ $QT_SOURCE_TREE/src/3rdparty/libconninet \
$QT_SOURCE_TREE/src/3rdparty/libjpeg \
$QT_SOURCE_TREE/src/3rdparty/libmng \
$QT_SOURCE_TREE/src/3rdparty/libpng \
diff --git a/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf b/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf
index 7701cae..c24ddef 100644
--- a/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf
+++ b/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf
@@ -32,6 +32,9 @@ qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0
qhp.Qt.extraFiles = index.html \
images/bg_l.png \
images/bg_l_blank.png \
+ images/bg_ll_blank.png \
+ images/bg_ul_blank.png \
+ images/header_bg.png \
images/bg_r.png \
images/box_bg.png \
images/breadcrumb.png \
@@ -39,12 +42,12 @@ qhp.Qt.extraFiles = index.html \
images/bullet_dn.png \
images/bullet_sq.png \
images/bullet_up.png \
+ images/arrow_down.png \
images/feedbackground.png \
images/horBar.png \
images/page.png \
images/page_bg.png \
images/sprites-combined.png \
- images/arrow-down.png \
images/spinner.gif \
images/stylesheet-coffee-plastique.png \
images/taskmenuextension-example.png \
@@ -52,17 +55,10 @@ qhp.Qt.extraFiles = index.html \
images/dynamiclayouts-example.png \
scripts/functions.js \
scripts/jquery.js \
- scripts/shBrushCpp.js \
- scripts/shCore.js \
- scripts/shLegacy.js \
scripts/narrow.js \
scripts/superfish.js \
- style/shCore.css \
- style/shThemeDefault.css \
style/narrow.css \
style/superfish.css \
- style/superfish_skin.css \
- style/OfflineStyle.css \
style/style_ie6.css \
style/style_ie7.css \
style/style_ie8.css \
@@ -77,6 +73,7 @@ excludedirs = $QT_SOURCE_TREE/src/3rdparty/clucene \
$QT_SOURCE_TREE/src/3rdparty/freetype \
$QT_SOURCE_TREE/src/3rdparty/harfbuzz \
$QT_SOURCE_TREE/src/3rdparty/kdebase \
+ $QT_SOURCE_TREE/src/3rdparty/libconninet \
$QT_SOURCE_TREE/src/3rdparty/libjpeg \
$QT_SOURCE_TREE/src/3rdparty/libmng \
$QT_SOURCE_TREE/src/3rdparty/libpng \
diff --git a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf
index 720fa1d..d932dfb 100644
--- a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf
+++ b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf
@@ -32,6 +32,9 @@ qhp.Qt.customFilters.Qt.filterAttributes = qt 4.8.0
qhp.Qt.extraFiles = index.html \
images/bg_l.png \
images/bg_l_blank.png \
+ images/bg_ll_blank.png \
+ images/bg_ul_blank.png \
+ images/header_bg.png \
images/bg_r.png \
images/box_bg.png \
images/breadcrumb.png \
@@ -39,12 +42,12 @@ qhp.Qt.extraFiles = index.html \
images/bullet_dn.png \
images/bullet_sq.png \
images/bullet_up.png \
+ images/arrow_down.png \
images/feedbackground.png \
images/horBar.png \
images/page.png \
images/page_bg.png \
images/sprites-combined.png \
- images/arrow-down.png \
images/spinner.gif \
images/stylesheet-coffee-plastique.png \
images/taskmenuextension-example.png \
@@ -52,17 +55,10 @@ qhp.Qt.extraFiles = index.html \
images/dynamiclayouts-example.png \
scripts/functions.js \
scripts/jquery.js \
- scripts/shBrushCpp.js \
- scripts/shCore.js \
- scripts/shLegacy.js \
scripts/narrow.js \
scripts/superfish.js \
- style/shCore.css \
- style/shThemeDefault.css \
style/narrow.css \
style/superfish.css \
- style/superfish_skin.css \
- style/OfflineStyle.css \
style/style_ie6.css \
style/style_ie7.css \
style/style_ie8.css \
@@ -77,6 +73,7 @@ excludedirs = $QT_SOURCE_TREE/src/3rdparty/clucene \
$QT_SOURCE_TREE/src/3rdparty/freetype \
$QT_SOURCE_TREE/src/3rdparty/harfbuzz \
$QT_SOURCE_TREE/src/3rdparty/kdebase \
+ $QT_SOURCE_TREE/src/3rdparty/libconninet \
$QT_SOURCE_TREE/src/3rdparty/libjpeg \
$QT_SOURCE_TREE/src/3rdparty/libmng \
$QT_SOURCE_TREE/src/3rdparty/libpng \
diff --git a/tools/qdoc3/test/qt-defines.qdocconf b/tools/qdoc3/test/qt-defines.qdocconf
index 9e41d93..51ee0d3 100644
--- a/tools/qdoc3/test/qt-defines.qdocconf
+++ b/tools/qdoc3/test/qt-defines.qdocconf
@@ -20,49 +20,43 @@ codeindent = 1
# See also qhp.Qt.extraFiles
extraimages.HTML = qt-logo \
trolltech-logo \
- bg_l.png \
- bg_l_blank.png \
- bg_ll_blank.png \
- bg_ul_blank.png \
- header_bg.png \
- bg_r.png \
- box_bg.png \
- breadcrumb.png \
- bullet_gt.png \
- bullet_dn.png \
- bullet_sq.png \
- bullet_up.png \
- arrow_down.png \
- feedbackground.png \
- horBar.png \
- page.png \
- page_bg.png \
- sprites-combined.png \
- spinner.gif \
- stylesheet-coffee-plastique.png \
- taskmenuextension-example.png \
- coloreditorfactoryimage.png \
- dynamiclayouts-example.png \
+ bg_l.png \
+ bg_l_blank.png \
+ bg_ll_blank.png \
+ bg_ul_blank.png \
+ header_bg.png \
+ bg_r.png \
+ box_bg.png \
+ breadcrumb.png \
+ bullet_gt.png \
+ bullet_dn.png \
+ bullet_sq.png \
+ bullet_up.png \
+ arrow_down.png \
+ feedbackground.png \
+ horBar.png \
+ page.png \
+ page_bg.png \
+ sprites-combined.png \
+ spinner.gif \
+ stylesheet-coffee-plastique.png \
+ taskmenuextension-example.png \
+ coloreditorfactoryimage.png \
+ dynamiclayouts-example.png
# This stuff is used by the new doc format.
scriptdirs = $QT_SOURCE_TREE/doc/src/template/scripts
styledirs = $QT_SOURCE_TREE/doc/src/template/style
scripts.HTML = functions.js \
- shBrushCpp.js \
- shCore.js \
- shLegacy.js \
narrow.js \
superfish.js \
jquery.js
styles.HTML = style.css \
- shCore.css \
- shThemeDefault.css \
narrow.css \
superfish.css \
superfish_skin.css \
- OfflineStyle.css \
style_ie6.css \
style_ie7.css \
style_ie8.css
diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf
index 03dd008..b3bf764 100644
--- a/tools/qdoc3/test/qt-html-templates.qdocconf
+++ b/tools/qdoc3/test/qt-html-templates.qdocconf
@@ -9,11 +9,6 @@ HTML.postheader = " <div class=\"header\" id=\"qtdocheader\">\n" \
" <div id=\"nav-logo\">\n" \
" <a href=\"index.html\">Home</a></div>\n" \
" <a href=\"index.html\" class=\"qtref\"><span>Qt Reference Documentation</span></a>\n" \
- " <div id=\"narrowsearch\"><form onsubmit=\"return false;\" action=\"\" id=\"qtdocsearchTop\">\n" \
- " <fieldset>\n" \
- " <input type=\"text\" value=\"\" id=\"pageType2\" name=\"searchstring\"/>\n" \
- " </fieldset>\n" \
- " </form></div>\n" \
" <div id=\"nav-topright\">\n" \
" <ul>\n" \
" <li class=\"nav-topright-home\"><a href=\"http://qt.nokia.com/\">Qt HOME</a></li>\n" \
@@ -39,15 +34,17 @@ HTML.postheader = " <div class=\"header\" id=\"qtdocheader\">\n" \
" <li><a href=\"modules.html\">Modules</a></li> \n" \
" <li><a href=\"namespaces.html\">Namespaces</a></li> \n" \
" <li><a href=\"qtglobal.html\">Global Declarations</a></li> \n" \
- " <li><a href=\"qdeclarativeelements.html\">QML elements</a></li> \n" \
+ " <li><a href=\"licensing.html\">Licenses and Credits</a></li> \n" \
" </ul> \n" \
" </li> \n" \
" <li><a href=\"#\">Qt Topics</a> \n" \
" <ul id=\"topmenuTopic\"> \n" \
- " <li><a href=\"qt-basic-concepts.html\">Basic Qt architecture</a></li> \n" \
+ " <li><a href=\"qt-basic-concepts.html\">Programming with Qt</a></li> \n" \
" <li><a href=\"qtquick.html\">Device UI's &amp; Qt Quick</a></li> \n" \
- " <li><a href=\"qt-gui-concepts.html\">Desktop UI components</a></li> \n" \
+ " <li><a href=\"qt-gui-concepts.html\">UI Design with Qt</a></li> \n" \
+ " <li><a href=\"developing-with-qt.html\">Cross-platform and Platform-specific</a></li> \n" \
" <li><a href=\"platform-specific.html\">Platform-specific info</a></li> \n" \
+ " <li><a href=\"technology-apis.html\">Qt and Key Technologies</a></li> \n" \
" <li><a href=\"best-practices.html\">How-To's and Best Practices</a></li> \n" \
" </ul> \n" \
" </li> \n" \
@@ -86,7 +83,7 @@ HTML.postheader = " <div class=\"header\" id=\"qtdocheader\">\n" \
" <li class=\"defaultLink\"><a href=\"functions.html\">Function index</a></li>\n" \
" <li class=\"defaultLink\"><a href=\"modules.html\">Modules</a></li>\n" \
" <li class=\"defaultLink\"><a href=\"namespaces.html\">Namespaces</a></li>\n" \
- " <li class=\"defaultLink\"><a href=\"qtglobal.html\">Global stuff</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"qtglobal.html\">Global Declarations</a></li>\n" \
" <li class=\"defaultLink\"><a href=\"qdeclarativeelements.html\">QML elements</a></li>\n" \
" </ul> \n" \
" </div>\n" \
@@ -96,10 +93,13 @@ HTML.postheader = " <div class=\"header\" id=\"qtdocheader\">\n" \
" Qt Topics</h2>\n" \
" <div id=\"list002\" class=\"list\">\n" \
" <ul id=\"ul002\" >\n" \
- " <li class=\"defaultLink\"><a href=\"qt-basic-concepts.html\">Basic Qt architecture</a></li>\n" \
- " <li class=\"defaultLink\"><a href=\"qtquick.html\">Device UI's &amp; Qt Quick</a></li>\n" \
- " <li class=\"defaultLink\"><a href=\"qt-gui-concepts.html\">Desktop UI components</a></li>\n" \
- " <li class=\"defaultLink\"><a href=\"platform-specific.html\">Platform-specific info</a></li>\n" \
+ " <li class=\"defaultLink\"><a href=\"qt-basic-concepts.html\">Programming with Qt</a></li> \n" \
+ " <li class=\"defaultLink\"><a href=\"qtquick.html\">Device UI's &amp; Qt Quick</a></li> \n" \
+ " <li class=\"defaultLink\"><a href=\"qt-gui-concepts.html\">UI Design with Qt</a></li> \n" \
+ " <li class=\"defaultLink\"><a href=\"developing-with-qt.html\">Cross-platform and Platform-specific</a></li> \n" \
+ " <li class=\"defaultLink\"><a href=\"platform-specific.html\">Platform-specific info</a></li> \n" \
+ " <li class=\"defaultLink\"><a href=\"technology-apis.html\">Qt and Key Technologies</a></li> \n" \
+ " <li class=\"defaultLink\"><a href=\"best-practices.html\">How-To's and Best Practices</a></li> \n" \
" </ul> \n" \
" </div>\n" \
" </div>\n" \
@@ -133,20 +133,20 @@ HTML.postpostheader = " </ul>\n" \
" <li id=\"print\" class=\"t_button\"><a href=\"javascript:this.print();\">\n" \
" <span>Print</span></a></li>\n" \
" </ul>\n" \
- " </div>\n" \
+ " </div>\n" \
" </div>\n" \
" <div class=\"content\">\n"
-HTML.footer = " <!-- /div -->\n" \
+HTML.footer = "" \
" <div class=\"feedback t_button\">\n" \
" [+] Documentation Feedback</div>\n" \
" </div>\n" \
" </div>\n" \
+ " </div> \n" \
" <div class=\"ft\">\n" \
" <span></span>\n" \
" </div>\n" \
" </div> \n" \
- " </div> \n" \
" <div class=\"footer\">\n" \
" <p>\n" \
" <acronym title=\"Copyright\">&copy;</acronym> 2008-2010 Nokia Corporation and/or its\n" \
@@ -155,16 +155,24 @@ HTML.footer = " <!-- /div -->\n" \
" <p>\n" \
" All other trademarks are property of their respective owners. <a title=\"Privacy Policy\"\n" \
" href=\"http://qt.nokia.com/about/privacy-policy\">Privacy Policy</a></p>\n" \
+ " <br />\n" \
+ " <p>\n" \
+ " Licensees holding valid Qt Commercial licenses may use this document in accordance with the" \
+ " Qt Commercial License Agreement provided with the Software or, alternatively, in accordance" \
+ " with the terms contained in a written agreement between you and Nokia.</p>\n" \
+ " <p>\n" \
+ " Alternatively, this document may be used under the terms of the <a href=\"http://www.gnu.org/licenses/fdl.html\">GNU\n" \
+ " Free Documentation License version 1.3</a>\n" \
+ " as published by the Free Software Foundation.</p>\n" \
" </div>\n" \
" <div id=\"feedbackBox\">\n" \
" <div id=\"feedcloseX\" class=\"feedclose t_button\">X</div>\n" \
" <form id=\"feedform\" action=\"http://doc.qt.nokia.com/docFeedbck/feedback.php\" method=\"get\">\n" \
- " <p id=\"noteHead\">Thank you for giving your feedback.</p> <div class=\"note\"><p>Make sure it is related to this specific page. For more general bugs and \n" \
- " requests, please use the <a href=\"http://bugreports.qt.nokia.com/secure/Dashboard.jspa\">Qt Bug Tracker</a>.</p></div>\n" \
+ " <p id=\"noteHead\">Thank you for giving your feedback.</p> <p class=\"note\">Make sure it is related to this specific page. For more general bugs and \n" \
+ " requests, please use the <a href=\"http://bugreports.qt.nokia.com/secure/Dashboard.jspa\">Qt Bug Tracker</a>.</p>\n" \
" <p><textarea id=\"feedbox\" name=\"feedText\" rows=\"5\" cols=\"40\"></textarea></p>\n" \
" <p><input id=\"feedsubmit\" class=\"feedclose\" type=\"submit\" name=\"feedback\" /></p>\n" \
" </form>\n" \
" </div>\n" \
" <div id=\"blurpage\">\n" \
- " </div>\n" \
- " </div>\n"
+ " </div>\n"
diff --git a/tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf b/tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf
index e2abd2a..da20766 100644
--- a/tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf
+++ b/tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf
@@ -156,6 +156,15 @@ HTML.footer = " <!-- /div -->\n" \
" <p>\n" \
" All other trademarks are property of their respective owners. <a title=\"Privacy Policy\"\n" \
" href=\"http://qt.nokia.com/about/privacy-policy\">Privacy Policy</a></p>\n" \
+ " <br />\n" \
+ " <p>\n" \
+ " Licensees holding valid Qt Commercial licenses may use this document in accordance with the" \
+ " Qt Commercial License Agreement provided with the Software or, alternatively, in accordance" \
+ " with the terms contained in a written agreement between you and Nokia.</p>\n" \
+ " <p>\n" \
+ " Alternatively, this document may be used under the terms of the <a href=\"http://www.gnu.org/licenses/fdl.html\">GNU\n" \
+ " Free Documentation License version 1.3</a>\n" \
+ " as published by the Free Software Foundation.</p>\n" \
" </div>\n" \
" <div id=\"feedbackBox\">\n" \
" <div id=\"feedcloseX\" class=\"feedclose t_button\">X</div>\n" \
diff --git a/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf b/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf
index 2c5c9d9..b91530f 100644
--- a/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf
+++ b/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf
@@ -156,6 +156,15 @@ HTML.footer = " <!-- /div -->\n" \
" <p>\n" \
" All other trademarks are property of their respective owners. <a title=\"Privacy Policy\"\n" \
" href=\"http://qt.nokia.com/about/privacy-policy\">Privacy Policy</a></p>\n" \
+ " <br />\n" \
+ " <p>\n" \
+ " Licensees holding valid Qt Commercial licenses may use this document in accordance with the" \
+ " Qt Commercial License Agreement provided with the Software or, alternatively, in accordance" \
+ " with the terms contained in a written agreement between you and Nokia.</p>\n" \
+ " <p>\n" \
+ " Alternatively, this document may be used under the terms of the <a href=\"http://www.gnu.org/licenses/fdl.html\">GNU\n" \
+ " Free Documentation License version 1.3</a>\n" \
+ " as published by the Free Software Foundation.</p>\n" \
" </div>\n" \
" <div id=\"feedbackBox\">\n" \
" <div id=\"feedcloseX\" class=\"feedclose t_button\">X</div>\n" \
diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf
index 7095d1a..f50cb69 100644
--- a/tools/qdoc3/test/qt.qdocconf
+++ b/tools/qdoc3/test/qt.qdocconf
@@ -50,17 +50,10 @@ qhp.Qt.extraFiles = index.html \
images/dynamiclayouts-example.png \
scripts/functions.js \
scripts/jquery.js \
- scripts/shBrushCpp.js \
- scripts/shCore.js \
- scripts/shLegacy.js \
scripts/narrow.js \
scripts/superfish.js \
- style/shCore.css \
- style/shThemeDefault.css \
style/narrow.css \
style/superfish.css \
- style/superfish_skin.css \
- style/OfflineStyle.css \
style/style_ie6.css \
style/style_ie7.css \
style/style_ie8.css \
@@ -110,6 +103,7 @@ excludedirs = $QTDIR/src/3rdparty/clucene \
$QTDIR/src/3rdparty/freetype \
$QTDIR/src/3rdparty/harfbuzz \
$QTDIR/src/3rdparty/kdebase \
+ $QTDIR/src/3rdparty/libconninet \
$QTDIR/src/3rdparty/libjpeg \
$QTDIR/src/3rdparty/libmng \
$QTDIR/src/3rdparty/libpng \
diff --git a/tools/qdoc3/test/qt_ja_JP.qdocconf b/tools/qdoc3/test/qt_ja_JP.qdocconf
index d4141c7..f9ce142 100644
--- a/tools/qdoc3/test/qt_ja_JP.qdocconf
+++ b/tools/qdoc3/test/qt_ja_JP.qdocconf
@@ -57,17 +57,10 @@ qhp.Qt.extraFiles = index.html \
images/dynamiclayouts-example.png \
scripts/functions.js \
scripts/jquery.js \
- scripts/shBrushCpp.js \
- scripts/shCore.js \
- scripts/shLegacy.js \
scripts/narrow.js \
scripts/superfish.js \
- style/shCore.css \
- style/shThemeDefault.css \
style/narrow.css \
style/superfish.css \
- style/superfish_skin.css \
- style/OfflineStyle.css \
style/style_ie6.css \
style/style_ie7.css \
style/style_ie8.css \
diff --git a/tools/qdoc3/test/qt_zh_CN.qdocconf b/tools/qdoc3/test/qt_zh_CN.qdocconf
index dc7e613..7b49315 100644
--- a/tools/qdoc3/test/qt_zh_CN.qdocconf
+++ b/tools/qdoc3/test/qt_zh_CN.qdocconf
@@ -34,6 +34,9 @@ qhp.Qt.customFilters.Qt.filterAttributes = qt 4.8.0
qhp.Qt.extraFiles = index.html \
images/bg_l.png \
images/bg_l_blank.png \
+ images/bg_ll_blank.png \
+ images/bg_ul_blank.png \
+ images/header_bg.png \
images/bg_r.png \
images/box_bg.png \
images/breadcrumb.png \
@@ -41,6 +44,7 @@ qhp.Qt.extraFiles = index.html \
images/bullet_dn.png \
images/bullet_sq.png \
images/bullet_up.png \
+ images/arrow_down.png \
images/feedbackground.png \
images/horBar.png \
images/page.png \
@@ -53,6 +57,13 @@ qhp.Qt.extraFiles = index.html \
images/dynamiclayouts-example.png \
scripts/functions.js \
scripts/jquery.js \
+ scripts/narrow.js \
+ scripts/superfish.js \
+ style/narrow.css \
+ style/superfish.css \
+ style/style_ie6.css \
+ style/style_ie7.css \
+ style/style_ie8.css \
style/style.css
language = Cpp
diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp
index 56e3484..540ffa9 100644
--- a/tools/qdoc3/tree.cpp
+++ b/tools/qdoc3/tree.cpp
@@ -1963,8 +1963,8 @@ QString Tree::fullDocumentLocation(const Node *node) const
if ((node->subType() == Node::QmlClass) ||
(node->subType() == Node::QmlBasicType)) {
QString fb = node->fileBase();
- if (fb.startsWith(QLatin1String("QML:")))
- return node->fileBase() + ".html";
+ if (fb.startsWith(QLatin1String("qml-")))
+ return fb + ".html";
else
return "qml-" + node->fileBase() + ".html";
} else
@@ -1981,7 +1981,7 @@ QString Tree::fullDocumentLocation(const Node *node) const
else if ((parentNode = node->parent())) {
if (parentNode->subType() == Node::QmlPropertyGroup) {
parentNode = parentNode->parent();
- parentName = "qml-" + parentNode->fileBase() + ".html";
+ parentName = fullDocumentLocation(parentNode);
}
else
parentName = fullDocumentLocation(node->parent());
diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp
new file mode 100644
index 0000000..0670ac4
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#define ENSURE_RUNNING_MEEGO {if (! QMeeGoGraphicsSystemHelper::isRunningMeeGo()) { qFatal("Using meego functionality but not running meego graphics system!"); }}
+
+#include "qmeegographicssystemhelper.h"
+#include <private/qapplication_p.h>
+#include <private/qgraphicssystem_runtime_p.h>
+#include <private/qpixmap_raster_p.h>
+#include "qmeegoruntime.h"
+
+QString QMeeGoGraphicsSystemHelper::runningGraphicsSystemName()
+{
+ if (! QApplicationPrivate::instance()) {
+ qWarning("Querying graphics system but application not running yet!");
+ return QString();
+ }
+
+ QString name = QApplicationPrivate::instance()->graphics_system_name;
+ if (name == QLatin1String("runtime")) {
+ QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system;
+ name = rsystem->graphicsSystemName();
+ }
+
+ return name;
+}
+
+bool QMeeGoGraphicsSystemHelper::isRunningMeeGo()
+{
+ return (runningGraphicsSystemName() == QLatin1String("meego"));
+}
+
+void QMeeGoGraphicsSystemHelper::switchToMeeGo()
+{
+ if (isRunningMeeGo())
+ return;
+
+ if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime"))
+ qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system.");
+ else {
+ QApplication *app = static_cast<QApplication *>(QCoreApplication::instance());
+ app->setGraphicsSystem(QLatin1String("meego"));
+ }
+}
+
+void QMeeGoGraphicsSystemHelper::switchToRaster()
+{
+ if (runningGraphicsSystemName() == QLatin1String("raster"))
+ return;
+
+ if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime"))
+ qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system.");
+ else {
+ QApplication *app = static_cast<QApplication *>(QCoreApplication::instance());
+ app->setGraphicsSystem(QLatin1String("raster"));
+ }
+}
+
+Qt::HANDLE QMeeGoGraphicsSystemHelper::imageToEGLSharedImage(const QImage &image)
+{
+ ENSURE_RUNNING_MEEGO;
+ return QMeeGoRuntime::imageToEGLSharedImage(image);
+}
+
+QPixmap QMeeGoGraphicsSystemHelper::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage)
+{
+ // This function is supported when not running meego too. A raster-backed
+ // pixmap will be created... but when you switch back to 'meego', it'll
+ // be replaced with a EGL shared image backing.
+ return QMeeGoRuntime::pixmapFromEGLSharedImage(handle, softImage);
+}
+
+QPixmap QMeeGoGraphicsSystemHelper::pixmapWithGLTexture(int w, int h)
+{
+ ENSURE_RUNNING_MEEGO;
+ return QMeeGoRuntime::pixmapWithGLTexture(w, h);
+}
+
+bool QMeeGoGraphicsSystemHelper::destroyEGLSharedImage(Qt::HANDLE handle)
+{
+ ENSURE_RUNNING_MEEGO;
+ return QMeeGoRuntime::destroyEGLSharedImage(handle);
+}
+
+void QMeeGoGraphicsSystemHelper::updateEGLSharedImagePixmap(QPixmap *p)
+{
+ ENSURE_RUNNING_MEEGO;
+ return QMeeGoRuntime::updateEGLSharedImagePixmap(p);
+}
+
+void QMeeGoGraphicsSystemHelper::setTranslucent(bool translucent)
+{
+ ENSURE_RUNNING_MEEGO;
+ QMeeGoRuntime::setTranslucent(translucent);
+}
diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h
new file mode 100644
index 0000000..02f2fa2
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMEEGOGRAPHICSSYSTEMHELPER_H
+#define QMEEGOGRAPHICSSYSTEMHELPER_H
+
+#include <QPixmap>
+#include <QImage>
+#include "qmeegolivepixmap.h"
+
+class QLibrary;
+
+//! The base class for accressing special meego graphics system features.
+/*!
+ This class is a helper class with static-only methods for accessing various
+ meego graphics system functionalities. The way it works is that the helper
+ dynamically calls-in to the loaded graphicssystem plugin... therefore, you're
+ expected to make sure that you're indeed running with 'meego' before using any
+ of the specialized methods.
+
+ In example:
+
+ \code
+ QPixmap p;
+ if (QMeeGoGraphicsSystemHelper::isRunningMeeGo()) {
+ p = QMeeGoGraphicsSystemHelper::pixmapWithGLTexture(64, 64);
+ } else {
+ p = QPixmap(64, 64);
+ }
+ \endcode
+
+ Calling any of the meego-specific features while not running meego might
+ give unpredictable results. The only functions safe to call at all times are:
+
+ \code
+ QMeeGoGraphicsSystemHelper::isRunningMeeGo();
+ QMeeGoGraphicsSystemHelper::runningGraphicsSystemName();
+ QMeeGoGraphicsSystemHelper::switchToMeeGo();
+ QMeeGoGraphicsSystemHelper::switchToRaster();
+ \endcode
+*/
+
+class Q_DECL_EXPORT QMeeGoGraphicsSystemHelper
+{
+public:
+ //! Returns true if running meego.
+ /*!
+ Returns true if the currently active (running) system is 'meego' with OpenGL.
+ This returns both true if the app was started with 'meego' or was started with
+ 'runtime' graphics system and the currently active system through the runtime
+ switching is 'meego'.
+ */
+ static bool isRunningMeeGo();
+
+ //! Switches to meego graphics system.
+ /*!
+ When running with the 'runtime' graphics system, sets the currently active
+ system to 'meego'. The window surface and all the resources are automatically
+ migrated to OpenGL. Will fail if the active graphics system is not 'runtime'.
+ */
+ static void switchToMeeGo();
+
+ //! Switches to raster graphics system
+ /*!
+ When running with the 'runtime' graphics system, sets the currently active
+ system to 'raster'. The window surface and the graphics resources (including the
+ EGL shared image resources) are automatically migrated back to the CPU. All OpenGL
+ resources (surface, context, cache, font cache) are automaticall anihilated.
+ */
+ static void switchToRaster();
+
+ //! Returns the name of the active graphics system
+ /*!
+ Returns the name of the currently active system. If running with 'runtime' graphics
+ system, returns the name of the active system inside the runtime graphics system
+ */
+ static QString runningGraphicsSystemName();
+
+ //! Creates a new EGL shared image.
+ /*!
+ Creates a new EGL shared image from the given image. The EGL shared image wraps
+ a GL texture in the native format and can be easily accessed from other processes.
+ */
+ static Qt::HANDLE imageToEGLSharedImage(const QImage &image);
+
+ //! Creates a QPixmap from an EGL shared image
+ /*!
+ Creates a new QPixmap from the given EGL shared image handle. The QPixmap can be
+ used for painting like any other pixmap. The softImage should point to an alternative,
+ software version of the graphical resource -- ie. obtained from theme daemon. The
+ softImage can be allocated on a QSharedMemory slice for easy sharing across processes
+ too. When the application is migrated ToRaster, this softImage will replace the
+ contents of the sharedImage.
+
+ It's ok to call this function too when not running 'meego' graphics system. In this
+ case it'll create a QPixmap backed with a raster data (from softImage)... but when
+ the system is switched back to 'meego', the QPixmap will be migrated to a EGL-shared image
+ backed storage (handle).
+ */
+ static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage);
+
+ //! Destroys an EGL shared image.
+ /*!
+ Destroys an EGLSharedImage previously created with an ::imageToEGLSharedImage call.
+ Returns true if the image was found and the destruction was successfull. Notice that
+ this destroys the image for all processes using it.
+ */
+ static bool destroyEGLSharedImage(Qt::HANDLE handle);
+
+ //! Updates the QPixmap backed with an EGLShared image.
+ /*!
+ This function re-reads the softImage that was specified when creating the pixmap with
+ ::pixmapFromEGLSharedImage and updates the EGL Shared image contents. It can be used
+ to share cross-proccess mutable EGLShared images.
+ */
+ static void updateEGLSharedImagePixmap(QPixmap *p);
+
+ //! Create a new QPixmap with a GL texture.
+ /*!
+ Creates a new QPixmap which is backed by an OpenGL local texture. Drawing to this
+ QPixmap will be accelerated by hardware -- unlike the normal (new QPixmap()) pixmaps,
+ which are backed by a software engine and only migrated to GPU when used. Migrating those
+ GL-backed pixmaps when going ToRaster is expsensive (they need to be downloaded from
+ GPU to CPU) so use wisely.
+ */
+ static QPixmap pixmapWithGLTexture(int w, int h);
+
+ //! Sets translucency (alpha) on the base window surface.
+ /*!
+ This function needs to be called *before* any widget/content is created.
+ When called with true, the base window surface will be translucent and initialized
+ with QGLFormat.alpha == true.
+ */
+ static void setTranslucent(bool translucent);
+};
+
+#endif
diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro
new file mode 100644
index 0000000..1e6e233
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro
@@ -0,0 +1,10 @@
+TEMPLATE = lib
+TARGET = QtMeeGoGraphicsSystemHelper
+
+include(../../src/qbase.pri)
+
+QT += gui
+INCLUDEPATH += '../../src/plugins/graphicssystems/meego'
+
+HEADERS = qmeegographicssystemhelper.h qmeegooverlaywidget.h qmeegolivepixmap.h qmeegoliveimage.h qmeegoruntime.h qmeegoliveimage_p.h qmeegolivepixmap_p.h
+SOURCES = qmeegographicssystemhelper.cpp qmeegooverlaywidget.cpp qmeegoruntime.cpp qmeegolivepixmap.cpp qmeegoliveimage.cpp
diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp
new file mode 100644
index 0000000..83a1e28
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmeegoliveimage.h"
+#include "qmeegoliveimage_p.h"
+#include "qmeegolivepixmap.h"
+#include "qmeegolivepixmap_p.h"
+
+/* QMeeGoLiveImagePrivate */
+
+QMeeGoLiveImagePrivate::QMeeGoLiveImagePrivate()
+{
+}
+
+QMeeGoLiveImagePrivate::~QMeeGoLiveImagePrivate()
+{
+ if (attachedPixmaps.length() > 0)
+ qWarning("Destroying QMeeGoLiveImage but it still has QMeeGoLivePixmaps attached!");
+}
+
+void QMeeGoLiveImagePrivate::attachPixmap(QMeeGoLivePixmap* pixmap)
+{
+ attachedPixmaps << pixmap;
+}
+
+void QMeeGoLiveImagePrivate::detachPixmap(QMeeGoLivePixmap* pixmap)
+{
+ attachedPixmaps.removeAll(pixmap);
+}
+
+/* QMeeGoLiveImage */
+
+QMeeGoLiveImage* QMeeGoLiveImage::liveImageWithSize(int w, int h, Format format, int buffers)
+{
+ if (format != Format_ARGB32_Premultiplied) {
+ qWarning("Only _ARGB32_Premultiplied format is supported for live images now!");
+ return 0;
+ }
+
+ if (buffers != 1) {
+ qWarning("Only single-buffer streams are supported at the moment");
+ return 0;
+ }
+
+ QMeeGoLiveImage *liveImage = new QMeeGoLiveImage(w, h);
+ return liveImage;
+}
+
+QMeeGoLiveImage::QMeeGoLiveImage(int w, int h) : QImage(w, h, QImage::Format_ARGB32_Premultiplied), d_ptr(new QMeeGoLiveImagePrivate())
+{
+ Q_D(QMeeGoLiveImage);
+ d->q_ptr = this;
+}
+
+QMeeGoLiveImage::~QMeeGoLiveImage()
+{
+}
+
+void QMeeGoLiveImage::lock(int buffer)
+{
+ if (buffer != 0)
+ qWarning("Only locking 0 buffer is supported at the moment!");
+}
+
+void QMeeGoLiveImage::release(int buffer)
+{
+ Q_D(QMeeGoLiveImage);
+
+ if (buffer != 0) {
+ qWarning("Only locking 0 buffer is supported at the moment!");
+ return;
+ }
+
+ // We need to copy the update image to all the client QMeeGoLivePixmap's
+ foreach (QMeeGoLivePixmap* livePixmap, d->attachedPixmaps)
+ livePixmap->d_ptr->copyBackFrom((const void *) bits());
+}
diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.h b/tools/qmeegographicssystemhelper/qmeegoliveimage.h
new file mode 100644
index 0000000..1e21e7b
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegoliveimage.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMEEGOLIVEIMAGE_H
+#define QMEEGOLIVEIMAGE_H
+
+#include <QImage>
+
+class QMeeGoLivePixmap;
+class QMeeGoLiveImagePrivate;
+
+//! A streamable QImage subclass.
+/*!
+*/
+
+class QMeeGoLiveImage : public QImage
+{
+public:
+ //! Format specifier.
+ /*!
+ Used to specify the format of the underlying image data for QMeeGoLiveImage.
+ */
+ enum Format {
+ Format_ARGB32_Premultiplied //! 32bit, AARRGGBB format. The typical Qt format.
+ };
+
+ //! Locks the access to the image.
+ /*!
+ All drawing/access to the underlying image data needs to happen between
+ ::lock() and ::unlock() pairs.
+ */
+ void lock(int buffer = 0);
+
+ //! Unlocks the access to the image.
+ /*!
+ All drawing/access to the underlying image data needs to happen between
+ ::lock() and ::unlock() pairs.
+ */
+ void release(int buffer = 0);
+
+ //! Destroys the image.
+ /*!
+ It's a mistake to destroy an image before destroying all the QMeeGoLivePixmaps
+ built on top of it. You should first destroy all the QMeeGoLivePixmaps.
+ */
+ virtual ~QMeeGoLiveImage();
+
+ //! Creates and returns a new live image with the given parameters.
+ /*!
+ The new image is created with the given width w and the given height h.
+ The format specifies the color format used by the image. Optionally, a
+ number of buffers can be specfied for a stream-like behavior.
+ */
+ static QMeeGoLiveImage* liveImageWithSize(int w, int h, Format format, int buffers = 1);
+
+private:
+ QMeeGoLiveImage(int w, int h); //! Private bits.
+ Q_DISABLE_COPY(QMeeGoLiveImage)
+ Q_DECLARE_PRIVATE(QMeeGoLiveImage)
+
+protected:
+ QScopedPointer<QMeeGoLiveImagePrivate> d_ptr;
+
+ friend class QMeeGoLivePixmap;
+ friend class QMeeGoLivePixmapPrivate;
+};
+
+#endif
diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h
new file mode 100644
index 0000000..085fed4
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmeegoliveimage.h"
+
+#ifndef QMEEGOLIVEIMAGE_P_H
+#define QMEEGOLIVEIMAGE_P_H
+
+class QMeeGoLiveImagePrivate
+{
+public:
+ Q_DECLARE_PUBLIC(QMeeGoLiveImage);
+ QMeeGoLiveImagePrivate();
+ virtual ~QMeeGoLiveImagePrivate();
+ void attachPixmap(QMeeGoLivePixmap* pixmap);
+ void detachPixmap(QMeeGoLivePixmap* pixmap);
+
+ QList <QMeeGoLivePixmap*> attachedPixmaps;
+ QMeeGoLiveImage *q_ptr;
+
+ friend class QMeeGoLivePixmap;
+ friend class QMeeGoLivePixmapPrivate;
+};
+
+#endif
diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp
new file mode 100644
index 0000000..2a1c04b
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmeegolivepixmap.h"
+#include <private/qimage_p.h>
+#include <private/qpixmap_raster_p.h>
+#include "qmeegolivepixmap_p.h"
+#include "qmeegoliveimage_p.h"
+#include <QSharedMemory>
+
+/* QMeeGoLivePixmapPrivate */
+
+QMeeGoLivePixmapPrivate::QMeeGoLivePixmapPrivate() : shm(0), shmSerial(0), owns(true), parentImage(0)
+{
+}
+
+void QMeeGoLivePixmapPrivate::copyBackFrom(const void *raw)
+{
+ Q_Q(QMeeGoLivePixmap);
+
+ q->detach();
+ shm->lock();
+ uchar *dest = ((uchar *) shm->data()) + (2 * sizeof(int));
+ memcpy(dest, raw, q->width() * q->height() * 4);
+ shm->unlock();
+}
+
+QMeeGoLivePixmapPrivate::~QMeeGoLivePixmapPrivate()
+{
+ Q_Q(QMeeGoLivePixmap);
+
+ if (parentImage)
+ parentImage->d_ptr->detachPixmap(q);
+
+ if (shm)
+ shm->detach();
+
+ if (owns)
+ delete shm;
+}
+
+/* QMeeGoLivePixmap */
+
+QMeeGoLivePixmap::QMeeGoLivePixmap(QPixmapData *p) : QPixmap(p), d_ptr(new QMeeGoLivePixmapPrivate())
+{
+ Q_D(QMeeGoLivePixmap);
+ d->q_ptr = this;
+}
+
+QMeeGoLivePixmap* QMeeGoLivePixmap::fromLiveImage(QMeeGoLiveImage *liveImage)
+{
+ static int counter = 100;
+ QSharedMemory *shm = NULL;
+ uchar* imgData = NULL;
+ int *header = NULL;
+ int w = liveImage->width();
+ int h = liveImage->height();
+
+ counter++;
+ shm = new QSharedMemory(QString(QLatin1String("QMeeGoLivePixmap%1")).arg(counter));
+ shm->create((w * h * 4) + 2 * sizeof(int)); // +2 to store width & height
+ shm->attach();
+
+ imgData = ((uchar *) shm->data()) + (2 * sizeof(int));
+ header = (int *) shm->data();
+
+ header[0] = w;
+ header[1] = h;
+
+ QImage img(imgData, w, h, QImage::Format_ARGB32_Premultiplied);
+
+ QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType);
+ pmd->fromImage(img, Qt::NoOpaqueDetection);
+
+ QMeeGoLivePixmap *livePixmap = new QMeeGoLivePixmap(pmd);
+ livePixmap->d_ptr->shm = shm;
+ livePixmap->d_ptr->owns = true;
+ livePixmap->d_ptr->shmSerial = counter;
+ livePixmap->d_ptr->parentImage = liveImage;
+
+ liveImage->d_ptr->attachPixmap(livePixmap);
+
+ return livePixmap;
+}
+
+QMeeGoLivePixmap* QMeeGoLivePixmap::fromHandle(Qt::HANDLE handle)
+{
+ QSharedMemory *shm = NULL;
+ int *header;
+ int width;
+ int height;
+ uchar* imgData;
+
+ shm = new QSharedMemory(QString(QLatin1String("QMeeGoLivePixmap%1")).arg(handle));
+ shm->attach();
+
+ shm->lock();
+ header = (int *) shm->data();
+ width = header[0];
+ height = header[1];
+ shm->unlock();
+
+ imgData = ((uchar *) shm->data()) + (2 * sizeof(int));
+ QImage img(imgData, width, height, QImage::Format_ARGB32_Premultiplied);
+
+ QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType);
+ pmd->fromImage(img, Qt::NoOpaqueDetection);
+
+ QMeeGoLivePixmap *livePixmap = new QMeeGoLivePixmap(pmd);
+ livePixmap->d_ptr->shm = shm;
+ livePixmap->d_ptr->owns = false;
+ livePixmap->d_ptr->shmSerial = handle;
+
+ return livePixmap;
+}
+
+QMeeGoLivePixmap::~QMeeGoLivePixmap()
+{
+}
+
+Qt::HANDLE QMeeGoLivePixmap::handle()
+{
+ Q_D(QMeeGoLivePixmap);
+ return d->shmSerial;
+}
diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h
new file mode 100644
index 0000000..2fa9db2
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMEEGOLIVEPIXMAP_H
+#define QMEEGOLIVEPIXMAP_H
+
+#include <QPixmap>
+#include "qmeegoliveimage.h"
+
+class QMeeGoLivePixmapPrivate;
+class QSharedMemory;
+class QImage;
+
+//! A pixmap representing streamed content.
+/*!
+*/
+
+class QMeeGoLivePixmap : public QPixmap
+{
+public:
+ //! Creates new pixmap from the given QMeeGoLiveImage.
+ /*!
+ The created QMeeGoLivePixmap will be attached to the given QMeeGoLiveImage.
+ Updates to the QMeeGoLiveImage will be represented on this newly created
+ QMeeGoLivePixmap.
+ */
+ static QMeeGoLivePixmap* fromLiveImage(QMeeGoLiveImage *liveImage);
+
+ //! Creates a new QMeeGoLivePixmap from the specified handle.
+ /*!
+ The handle can be used to share QMeeGoLivePixmap cross-process.
+ */
+ static QMeeGoLivePixmap* fromHandle(Qt::HANDLE handle);
+
+ //! Returns the handle for this QMeeGoLivePixmap.
+ /*!
+ The handle can be used to share QMeeGoLivePixmap cross-process.
+ */
+ Qt::HANDLE handle();
+
+ //! Destroys the QMeeGoLivePixmap.
+ /*!
+ All QMeeGoLivePixmaps attached to a given QMeeGoLiveImage have to be destroyed
+ before the QMeeGoLiveImage itself is destroyed.
+ */
+ virtual ~QMeeGoLivePixmap();
+
+private:
+ QMeeGoLivePixmap(QPixmapData *p);
+ Q_DISABLE_COPY(QMeeGoLivePixmap)
+ Q_DECLARE_PRIVATE(QMeeGoLivePixmap)
+
+protected:
+ QScopedPointer<QMeeGoLivePixmapPrivate> d_ptr; //! Private bits.
+
+ friend class QMeeGoLiveImage;
+ friend class QMeeGoLiveImagePrivate;
+};
+
+#endif
diff --git a/tools/designer/src/components/propertyeditor/defs.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h
index 28e39fc..c2591dc 100644
--- a/tools/designer/src/components/propertyeditor/defs.h
+++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Designer of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,22 +39,28 @@
**
****************************************************************************/
-#ifndef DEFS_H
-#define DEFS_H
+#include "qmeegolivepixmap.h"
-#include <QtGui/QSizePolicy>
-#include <QtCore/QString>
+#ifndef QMEEGOLIVEPIXMAP_P_H
+#define QMEEGOLIVEPIXMAP_P_H
-QT_BEGIN_NAMESPACE
+class QMeeGoLivePixmapPrivate
+{
+public:
+ Q_DECLARE_PUBLIC(QMeeGoLivePixmap);
+ QMeeGoLivePixmapPrivate();
+ void copyBackFrom(const void *raw);
+ virtual ~QMeeGoLivePixmapPrivate();
+
+ QSharedMemory *shm;
+ int shmSerial;
+ bool owns;
+ QMeeGoLiveImage *parentImage;
+
+ QMeeGoLivePixmap *q_ptr;
+
+ friend class QMeeGoLiveImage;
+ friend class QMeeGoLiveImagePrivate;
+};
-namespace qdesigner_internal {
-
-int size_type_to_int(QSizePolicy::Policy t);
-QString size_type_to_string(QSizePolicy::Policy t);
-QSizePolicy::Policy int_to_size_type(int i);
-
-} // namespace qdesigner_internal
-
-QT_END_NAMESPACE
-
-#endif // DEFS_H
+#endif
diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp
new file mode 100644
index 0000000..f9f14ae
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include <QEvent>
+#include <QMouseEvent>
+#include <QCoreApplication>
+#include "qmeegooverlaywidget.h"
+#include "qmeegographicssystemhelper.h"
+#include "qmeegoruntime.h"
+
+QMeeGoOverlayWidget::QMeeGoOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent) : QWidget(parent, 0),
+ sw(surfaceWidth),
+ sh(surfaceHeight)
+{
+ if (! QMeeGoGraphicsSystemHelper::isRunningMeeGo())
+ qFatal("QMeeGoOverlayWidget can only be used when running with 'meego' graphics system!");
+
+ QMeeGoRuntime::setSurfaceFixedSize(surfaceWidth, surfaceHeight);
+
+ scaleW = sw / 864.0;
+ scaleH = sh / 480.0;
+ installEventFilter(this);
+}
+
+QPoint QMeeGoOverlayWidget::convertPoint(const QPoint &p)
+{
+ int x = p.x() * scaleW;
+ int y = p.y() * scaleH;
+ return QPoint(x, y);
+}
+
+void QMeeGoOverlayWidget::showEvent(QShowEvent *)
+{
+ QMeeGoRuntime::setSurfaceScaling(0, 0, width(), height());
+}
+
+bool QMeeGoOverlayWidget::eventFilter(QObject *, QEvent *event)
+{
+ if (event->spontaneous() == false)
+ return false;
+
+ switch(event->type()) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ {
+ QMouseEvent *e = static_cast <QMouseEvent *>(event);
+ QMouseEvent newEvent = QMouseEvent(e->type(),
+ convertPoint(e->pos()),
+ convertPoint(e->globalPos()),
+ e->button(),
+ e->buttons(),
+ e->modifiers());
+ QCoreApplication::sendEvent(this, &newEvent);
+ return true;
+ }
+
+ default:
+ return false;
+ }
+}
diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h
new file mode 100644
index 0000000..c2c08b4
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMEEGOOVERLAYWIDGET_H
+#define QMEEGOOVERLAYWIDGET_H
+
+#include <QWidget>
+
+//! A widget automatically scaling it's content.
+/*!
+*/
+
+class QMeeGoOverlayWidget : public QWidget
+{
+public:
+ //! Constructs a new scaling widget.
+ /*!
+ The real surface used for this widget will have the specified
+ width and height.
+ */
+ QMeeGoOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent = 0);
+
+
+ //! Event filtering function.
+ /*!
+ Converts coordinates for mouse/touch event. Do not
+ call manually.
+ */
+ bool eventFilter(QObject *obj, QEvent *event);
+
+ //! Standard override.
+ /*!
+ The surface scaling on the target paint device is being
+ set when the widget is displayed for the first time.
+ */
+ virtual void showEvent(QShowEvent *event);
+
+private:
+ //! Converts coordinates between real & virtual area of the widget.
+ QPoint convertPoint(const QPoint &p);
+
+ int sw; /// Surface real width.
+ int sh; /// Surface real height.
+ float scaleW; /// Width scaling factor.
+ float scaleH; /// Height scaling factor.
+};
+
+#endif
diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
new file mode 100644
index 0000000..70b5dc1
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmeegoruntime.h"
+
+#include <private/qlibrary_p.h>
+#include <private/qfactoryloader_p.h>
+#include <private/qgraphicssystemplugin_p.h>
+
+#define ENSURE_INITIALIZED {if (!initialized) initialize();}
+
+bool QMeeGoRuntime::initialized = false;
+
+typedef int (*QMeeGoImageToEglSharedImageFunc) (const QImage&);
+typedef QPixmapData* (*QMeeGoPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&);
+typedef QPixmapData* (*QMeeGoPixmapDataWithGLTextureFunc) (int w, int h);
+typedef bool (*QMeeGoDestroyEGLSharedImageFunc) (Qt::HANDLE handle);
+typedef void (*QMeeGoUpdateEglSharedImagePixmapFunc) (QPixmap*);
+typedef void (*QMeeGoSetSurfaceFixedSizeFunc) (int w, int h);
+typedef void (*QMeeGoSetSurfaceScalingFunc) (int x, int y, int w, int h);
+typedef void (*QMeeGoSetTranslucentFunc) (bool translucent);
+
+static QMeeGoImageToEglSharedImageFunc qt_meego_image_to_egl_shared_image = NULL;
+static QMeeGoPixmapDataFromEglSharedImageFunc qt_meego_pixmapdata_from_egl_shared_image = NULL;
+static QMeeGoPixmapDataWithGLTextureFunc qt_meego_pixmapdata_with_gl_texture = NULL;
+static QMeeGoDestroyEGLSharedImageFunc qt_meego_destroy_egl_shared_image = NULL;
+static QMeeGoUpdateEglSharedImagePixmapFunc qt_meego_update_egl_shared_image_pixmap = NULL;
+static QMeeGoSetSurfaceFixedSizeFunc qt_meego_set_surface_fixed_size = NULL;
+static QMeeGoSetSurfaceScalingFunc qt_meego_set_surface_scaling = NULL;
+static QMeeGoSetTranslucentFunc qt_meego_set_translucent = NULL;
+
+void QMeeGoRuntime::initialize()
+{
+ QFactoryLoader loader(QGraphicsSystemFactoryInterface_iid, QLatin1String("/graphicssystems"), Qt::CaseInsensitive);
+
+ QLibraryPrivate *libraryPrivate = loader.library(QLatin1String("meego"));
+ Q_ASSERT(libraryPrivate);
+
+ QLibrary library(libraryPrivate->fileName, libraryPrivate->fullVersion);
+
+ bool success = library.load();
+
+ if (success) {
+ qt_meego_image_to_egl_shared_image = (QMeeGoImageToEglSharedImageFunc) library.resolve("qt_meego_image_to_egl_shared_image");
+ qt_meego_pixmapdata_from_egl_shared_image = (QMeeGoPixmapDataFromEglSharedImageFunc) library.resolve("qt_meego_pixmapdata_from_egl_shared_image");
+ qt_meego_pixmapdata_with_gl_texture = (QMeeGoPixmapDataWithGLTextureFunc) library.resolve("qt_meego_pixmapdata_with_gl_texture");
+ qt_meego_destroy_egl_shared_image = (QMeeGoDestroyEGLSharedImageFunc) library.resolve("qt_meego_destroy_egl_shared_image");
+ qt_meego_update_egl_shared_image_pixmap = (QMeeGoUpdateEglSharedImagePixmapFunc) library.resolve("qt_meego_update_egl_shared_image_pixmap");
+ qt_meego_set_surface_fixed_size = (QMeeGoSetSurfaceFixedSizeFunc) library.resolve("qt_meego_set_surface_fixed_size");
+ qt_meego_set_surface_scaling = (QMeeGoSetSurfaceScalingFunc) library.resolve("qt_meego_set_surface_scaling");
+ qt_meego_set_translucent = (QMeeGoSetTranslucentFunc) library.resolve("qt_meego_set_translucent");
+
+ if (qt_meego_image_to_egl_shared_image && qt_meego_pixmapdata_from_egl_shared_image && qt_meego_pixmapdata_with_gl_texture
+ && qt_meego_destroy_egl_shared_image && qt_meego_update_egl_shared_image_pixmap && qt_meego_set_surface_fixed_size
+ && qt_meego_set_surface_scaling && qt_meego_set_translucent)
+ {
+ qDebug("Successfully resolved MeeGo graphics system: %s %s\n", qPrintable(libraryPrivate->fileName), qPrintable(libraryPrivate->fullVersion));
+ }
+ } else {
+ Q_ASSERT(false);
+ }
+
+ initialized = true;
+}
+
+Qt::HANDLE QMeeGoRuntime::imageToEGLSharedImage(const QImage &image)
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_image_to_egl_shared_image);
+ return qt_meego_image_to_egl_shared_image(image);
+}
+
+QPixmap QMeeGoRuntime::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage)
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_pixmapdata_from_egl_shared_image);
+ return QPixmap(qt_meego_pixmapdata_from_egl_shared_image(handle, softImage));
+}
+
+QPixmap QMeeGoRuntime::pixmapWithGLTexture(int w, int h)
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_pixmapdata_with_gl_texture);
+ return QPixmap(qt_meego_pixmapdata_with_gl_texture(w, h));
+}
+
+bool QMeeGoRuntime::destroyEGLSharedImage(Qt::HANDLE handle)
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_destroy_egl_shared_image);
+ return qt_meego_destroy_egl_shared_image(handle);
+}
+
+void QMeeGoRuntime::updateEGLSharedImagePixmap(QPixmap *p)
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_update_egl_shared_image_pixmap);
+ return qt_meego_update_egl_shared_image_pixmap(p);
+}
+
+void QMeeGoRuntime::setSurfaceFixedSize(int w, int h)
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_set_surface_fixed_size);
+ qt_meego_set_surface_fixed_size(w, h);
+}
+
+void QMeeGoRuntime::setSurfaceScaling(int x, int y, int w, int h)
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_set_surface_scaling);
+ qt_meego_set_surface_scaling(x, y, w, h);
+}
+
+void QMeeGoRuntime::setTranslucent(bool translucent)
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_set_translucent);
+ qt_meego_set_translucent(translucent);
+}
diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h
new file mode 100644
index 0000000..82fdb52
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QPixmap>
+#include <QImage>
+
+class QMeeGoRuntime
+{
+public:
+ static void initialize();
+
+ static Qt::HANDLE imageToEGLSharedImage(const QImage &image);
+ static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage);
+ static QPixmap pixmapWithGLTexture(int w, int h);
+ static bool destroyEGLSharedImage(Qt::HANDLE handle);
+ static void updateEGLSharedImagePixmap(QPixmap *p);
+ static void setSurfaceFixedSize(int w, int h);
+ static void setSurfaceScaling(int x, int y, int w, int h);
+ static void setTranslucent(bool translucent);
+
+private:
+ static bool initialized;
+};
diff --git a/tools/qml/deviceorientation.cpp b/tools/qml/deviceorientation.cpp
index e7c70d5..d3014ad 100644
--- a/tools/qml/deviceorientation.cpp
+++ b/tools/qml/deviceorientation.cpp
@@ -53,6 +53,11 @@ public:
return m_orientation;
}
+ void pauseListening() {
+ }
+ void resumeListening() {
+ }
+
void setOrientation(Orientation o) {
if (o != m_orientation) {
m_orientation = o;
diff --git a/tools/qml/deviceorientation.h b/tools/qml/deviceorientation.h
index 817bfc8..487ebd4 100644
--- a/tools/qml/deviceorientation.h
+++ b/tools/qml/deviceorientation.h
@@ -63,6 +63,9 @@ public:
virtual Orientation orientation() const = 0;
virtual void setOrientation(Orientation) = 0;
+ virtual void pauseListening() = 0;
+ virtual void resumeListening() = 0;
+
static DeviceOrientation *instance();
signals:
diff --git a/tools/qml/deviceorientation_maemo5.cpp b/tools/qml/deviceorientation_maemo5.cpp
index e942579..a324820 100644
--- a/tools/qml/deviceorientation_maemo5.cpp
+++ b/tools/qml/deviceorientation_maemo5.cpp
@@ -50,23 +50,9 @@ class MaemoOrientation : public DeviceOrientation
Q_OBJECT
public:
MaemoOrientation()
- : o(UnknownOrientation)
+ : o(UnknownOrientation), sensorEnabled(false)
{
- // enable the orientation sensor
- QDBusConnection::systemBus().call(
- QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
- MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ));
-
- // query the initial orientation
- QDBusMessage reply = QDBusConnection::systemBus().call(
- QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
- MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET));
- if (reply.type() == QDBusMessage::ErrorMessage) {
- qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage()));
- } else {
- o = toOrientation(reply.arguments().value(0).toString());
- }
-
+ resumeListening();
// connect to the orientation change signal
QDBusConnection::systemBus().connect(QString(), MCE_SIGNAL_PATH, MCE_SIGNAL_IF,
MCE_DEVICE_ORIENTATION_SIG,
@@ -91,6 +77,40 @@ public:
{
}
+ void pauseListening() {
+ if (sensorEnabled) {
+ // disable the orientation sensor
+ QDBusConnection::systemBus().call(
+ QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
+ MCE_REQUEST_IF, MCE_ACCELEROMETER_DISABLE_REQ));
+ sensorEnabled = false;
+ }
+ }
+
+ void resumeListening() {
+ if (!sensorEnabled) {
+ // enable the orientation sensor
+ QDBusConnection::systemBus().call(
+ QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
+ MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ));
+
+ QDBusMessage reply = QDBusConnection::systemBus().call(
+ QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
+ MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET));
+
+ if (reply.type() == QDBusMessage::ErrorMessage) {
+ qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage()));
+ } else {
+ Orientation orientation = toOrientation(reply.arguments().value(0).toString());
+ if (o != orientation) {
+ o = orientation;
+ emit orientationChanged();
+ }
+ sensorEnabled = true;
+ }
+ }
+ }
+
private Q_SLOTS:
void deviceOrientationChanged(const QString &newOrientation)
{
@@ -116,6 +136,7 @@ private:
private:
Orientation o;
+ bool sensorEnabled;
};
DeviceOrientation* DeviceOrientation::instance()
diff --git a/tools/qml/deviceorientation_symbian.cpp b/tools/qml/deviceorientation_symbian.cpp
index 307c417..7710cf9 100644
--- a/tools/qml/deviceorientation_symbian.cpp
+++ b/tools/qml/deviceorientation_symbian.cpp
@@ -52,7 +52,7 @@ class SymbianOrientation : public DeviceOrientation, public MSensrvDataListener
Q_OBJECT
public:
SymbianOrientation()
- : DeviceOrientation(), m_current(UnknownOrientation), m_sensorChannel(0)
+ : DeviceOrientation(), m_current(UnknownOrientation), m_sensorChannel(0), m_channelOpen(false)
{
TRAP_IGNORE(initL());
if (!m_sensorChannel)
@@ -84,6 +84,7 @@ public:
TRAP(error, m_sensorChannel->OpenChannelL());
if (!error) {
TRAP(error, m_sensorChannel->StartDataListeningL(this, 1, 1, 0));
+ m_channelOpen = true;
break;
}
if (error) {
@@ -107,6 +108,30 @@ public:
private:
DeviceOrientation::Orientation m_current;
CSensrvChannel *m_sensorChannel;
+ bool m_channelOpen;
+ void pauseListening() {
+ if (m_sensorChannel && m_channelOpen) {
+ m_sensorChannel->StopDataListening();
+ m_sensorChannel->CloseChannel();
+ m_channelOpen = false;
+ }
+ }
+
+ void resumeListening() {
+ if (m_sensorChannel && !m_channelOpen) {
+ TRAPD(error, m_sensorChannel->OpenChannelL());
+ if (!error) {
+ TRAP(error, m_sensorChannel->StartDataListeningL(this, 1, 1, 0));
+ if (!error) {
+ m_channelOpen = true;
+ }
+ }
+ if (error) {
+ delete m_sensorChannel;
+ m_sensorChannel = 0;
+ }
+ }
+ }
void DataReceived(CSensrvChannel &channel, TInt count, TInt dataLost)
{
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 7421b5e..78cd64d 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -441,6 +441,7 @@ static QDeclarativeViewer *createViewer()
QDeclarativeViewer *viewer = new QDeclarativeViewer(0, wflags);
viewer->setAttribute(Qt::WA_DeleteOnClose, true);
+ viewer->setUseGL(opts.useGL);
if (!opts.scriptopts.isEmpty()) {
viewer->setScriptOptions(opts.scriptOptions);
@@ -492,8 +493,6 @@ void showViewer(QDeclarativeViewer *viewer)
viewer->showMaximized();
else
viewer->show();
-
- viewer->setUseGL(opts.useGL);
viewer->raise();
}
diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro
index d794005..3927dd6 100644
--- a/tools/qml/qml.pro
+++ b/tools/qml/qml.pro
@@ -34,7 +34,7 @@ maemo5 {
}
symbian {
TARGET.UID3 = 0x20021317
- include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+ include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
TARGET.EPOCHEAPSIZE = 0x20000 0x4000000
TARGET.CAPABILITY = NetworkServices ReadUserData
!contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) {
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index b9fd570..c59621a 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -85,6 +85,7 @@
#include <QMenu>
#include <QAction>
#include <QFileDialog>
+#include <QInputDialog>
#include <QTimer>
#include <QGraphicsObject>
#include <QNetworkProxyFactory>
@@ -691,12 +692,14 @@ QDeclarativeViewer::~QDeclarativeViewer()
void QDeclarativeViewer::enableExperimentalGestures()
{
+#ifndef QT_NO_GESTURES
canvas->viewport()->grabGesture(Qt::TapGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent);
canvas->viewport()->grabGesture(Qt::TapAndHoldGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent);
canvas->viewport()->grabGesture(Qt::PanGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent);
canvas->viewport()->grabGesture(Qt::PinchGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent);
canvas->viewport()->grabGesture(Qt::SwipeGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent);
canvas->viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
+#endif
}
QDeclarativeView *QDeclarativeViewer::view() const
@@ -715,6 +718,9 @@ void QDeclarativeViewer::createMenu()
openAction->setShortcuts(QKeySequence::Open);
connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
+ QAction *openUrlAction = new QAction(tr("Open &URL..."), this);
+ connect(openUrlAction, SIGNAL(triggered()), this, SLOT(openUrl()));
+
QAction *reloadAction = new QAction(tr("&Reload"), this);
reloadAction->setShortcuts(QKeySequence::Refresh);
connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload()));
@@ -789,6 +795,7 @@ void QDeclarativeViewer::createMenu()
#if defined(Q_WS_MAEMO_5)
menu->addAction(openAction);
+ menu->addAction(openUrlAction);
menu->addAction(reloadAction);
menu->addAction(snapshotAction);
@@ -809,6 +816,7 @@ void QDeclarativeViewer::createMenu()
QMenu *fileMenu = menu->addMenu(tr("&File"));
fileMenu->addAction(openAction);
+ fileMenu->addAction(openUrlAction);
fileMenu->addAction(reloadAction);
fileMenu->addSeparator();
fileMenu->addAction(closeAction);
@@ -1021,6 +1029,14 @@ void QDeclarativeViewer::openFile()
}
}
+void QDeclarativeViewer::openUrl()
+{
+ QString cur = canvas->source().toLocalFile();
+ QString url= QInputDialog::getText(this, tr("Open QML file"), tr("URL of main QML file:"), QLineEdit::Normal, cur);
+ if (!url.isEmpty())
+ open(url);
+}
+
void QDeclarativeViewer::statusChanged()
{
if (canvas->status() == QDeclarativeView::Error && tester)
@@ -1053,11 +1069,7 @@ void QDeclarativeViewer::loadDummyDataFiles(const QString& directory)
QStringList list = dir.entryList();
for (int i = 0; i < list.size(); ++i) {
QString qml = list.at(i);
- QFile f(dir.filePath(qml));
- f.open(QIODevice::ReadOnly);
- QByteArray data = f.readAll();
- QDeclarativeComponent comp(canvas->engine());
- comp.setData(data, QUrl());
+ QDeclarativeComponent comp(canvas->engine(), dir.filePath(qml));
QObject *dummyData = comp.create();
if(comp.isError()) {
@@ -1194,8 +1206,10 @@ bool QDeclarativeViewer::event(QEvent *event)
{
if (event->type() == QEvent::WindowActivate) {
Runtime::instance()->setActiveWindow(true);
+ DeviceOrientation::instance()->resumeListening();
} else if (event->type() == QEvent::WindowDeactivate) {
Runtime::instance()->setActiveWindow(false);
+ DeviceOrientation::instance()->pauseListening();
}
return QWidget::event(event);
}
diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h
index 6fa7d81..d1ec26d 100644
--- a/tools/qml/qmlruntime.h
+++ b/tools/qml/qmlruntime.h
@@ -113,6 +113,7 @@ public slots:
void sceneResized(QSize size);
bool open(const QString&);
void openFile();
+ void openUrl();
void reload();
void takeSnapShot();
void toggleRecording();
diff --git a/tools/qml/startup/startup.qml b/tools/qml/startup/startup.qml
index be67598..ddc7217 100644
--- a/tools/qml/startup/startup.qml
+++ b/tools/qml/startup/startup.qml
@@ -49,14 +49,53 @@ Rectangle {
Component.onCompleted: treatsApp.state = "part1"
signal animationFinished
- Logo {
- id: logo
- x: 165
- y: 35
- rotation: -15
- scale: 0.6
- opacity: 0
- onAnimationFinished: treatsApp.animationFinished();
+ Item {
+ width: 800
+ height: 480
+ anchors.centerIn: parent
+ clip: true
+
+ Logo {
+ id: logo
+ x: 165
+ y: 35
+ rotation: -15
+ scale: 0.6
+ opacity: 0
+ onAnimationFinished: treatsApp.animationFinished();
+ }
+
+ Item {
+ id: quickblur
+ x: 800//325
+ y: 344
+ Image {
+ id: blurText
+ source: "quick-blur.png"
+ }
+ Image {
+ id: quickregular
+ x: -1
+ y: 0
+ opacity: 0
+ source: "quick-regular.png"
+ }
+ Image {
+ id: star
+ x: -1
+ y: 0
+ opacity: 0
+ source: "white-star.png"
+ smooth: true
+ NumberAnimation on rotation {
+ from: 0
+ to: 360
+ loops: NumberAnimation.Infinite
+ running: true
+ duration: 2000
+ }
+ }
+ }
}
states: [
@@ -96,39 +135,6 @@ Rectangle {
}
]
-
- Item {
- id: quickblur
- x: 800//325
- y: 344
- Image {
- id: blurText
- source: "quick-blur.png"
- }
- Image {
- id: quickregular
- x: -1
- y: 0
- opacity: 0
- source: "quick-regular.png"
- }
- Image {
- id: star
- x: -1
- y: 0
- opacity: 0
- source: "white-star.png"
- smooth: true
- NumberAnimation on rotation {
- from: 0
- to: 360
- loops: NumberAnimation.Infinite
- running: true
- duration: 2000
- }
- }
- }
-
transitions: [
Transition {
ParallelAnimation {
diff --git a/tools/qtconfig/main.cpp b/tools/qtconfig/main.cpp
index 24d044f..928cf01 100644
--- a/tools/qtconfig/main.cpp
+++ b/tools/qtconfig/main.cpp
@@ -42,6 +42,9 @@
#include "ui_previewwidgetbase.h"
#include "mainwindow.h"
#include <QApplication>
+#include <QLibraryInfo>
+#include <QLocale>
+#include <QTranslator>
QT_USE_NAMESPACE
@@ -50,6 +53,17 @@ int main(int argc, char **argv)
Q_INIT_RESOURCE(qtconfig);
QApplication app(argc, argv);
+
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("qtconfig_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ }
+
MainWindow mw;
mw.show();
return app.exec();
diff --git a/tools/qvfb/main.cpp b/tools/qvfb/main.cpp
index d96b255..28aa7d4 100644
--- a/tools/qvfb/main.cpp
+++ b/tools/qvfb/main.cpp
@@ -43,6 +43,9 @@
#include <QApplication>
#include <QRegExp>
+#include <QLibraryInfo>
+#include <QLocale>
+#include <QTranslator>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
@@ -73,6 +76,16 @@ int runQVfb( int argc, char *argv[] )
QApplication app( argc, argv );
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("qvfb_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ }
+
int width = 0;
int height = 0;
int depth = -32; // default, but overridable by skin
diff --git a/tools/qvfb/qvfb.cpp b/tools/qvfb/qvfb.cpp
index bc9e529..b4ccebc 100644
--- a/tools/qvfb/qvfb.cpp
+++ b/tools/qvfb/qvfb.cpp
@@ -398,47 +398,47 @@ void QVFb::createMenu(T *menu)
QMenu* QVFb::createFileMenu()
{
- QMenu *file = new QMenu( "File", this );
- file->addAction( "Configure...", this, SLOT(configure()), 0 );
+ QMenu *file = new QMenu( tr("&File"), this );
+ file->addAction( tr("&Configure..."), this, SLOT(configure()), QKeySequence::Preferences );
file->addSeparator();
- file->addAction( "&Save image...", this, SLOT(saveImage()), 0 );
- file->addAction( "&Animation...", this, SLOT(toggleAnimation()), 0 );
+ file->addAction( tr("&Save image..."), this, SLOT(saveImage()), QKeySequence::Save );
+ file->addAction( tr("&Animation..."), this, SLOT(toggleAnimation()), 0 );
file->addSeparator();
- file->addAction( "&Quit", qApp, SLOT(quit()) );
+ file->addAction( tr("&Quit"), qApp, SLOT(quit()), QKeySequence::Quit );
return file;
}
QMenu* QVFb::createViewMenu()
{
- viewMenu = new QMenu( "View", this );
- cursorAction = viewMenu->addAction( "Show &Cursor", this,
+ viewMenu = new QMenu( tr("&View"), this );
+ cursorAction = viewMenu->addAction( tr("Show &Cursor"), this,
SLOT(toggleCursor()) );
cursorAction->setCheckable(true);
if ( view )
enableCursor(true);
- viewMenu->addAction( "&Refresh Rate...", this, SLOT(changeRate()) );
+ viewMenu->addAction( tr("&Refresh Rate..."), this, SLOT(changeRate()) );
viewMenu->addSeparator();
- viewMenu->addAction( "No rotation", this, SLOT(setRot0()) );
- viewMenu->addAction( "90\260 rotation", this, SLOT(setRot90()) );
- viewMenu->addAction( "180\260 rotation", this, SLOT(setRot180()) );
- viewMenu->addAction( "270\260 rotation", this, SLOT(setRot270()) );
+ viewMenu->addAction( tr("&No rotation"), this, SLOT(setRot0()) );
+ viewMenu->addAction( tr("&90\260 rotation"), this, SLOT(setRot90()) );
+ viewMenu->addAction( tr("1&80\260 rotation"), this, SLOT(setRot180()) );
+ viewMenu->addAction( tr("2&70\260 rotation"), this, SLOT(setRot270()) );
viewMenu->addSeparator();
- viewMenu->addAction( "Zoom scale &0.5", this, SLOT(setZoomHalf()) );
- viewMenu->addAction( "Zoom scale 0.75", this, SLOT(setZoom075()) );
- viewMenu->addAction( "Zoom scale &1", this, SLOT(setZoom1()) );
- viewMenu->addAction( "Zoom scale &2", this, SLOT(setZoom2()) );
- viewMenu->addAction( "Zoom scale &3", this, SLOT(setZoom3()) );
- viewMenu->addAction( "Zoom scale &4", this, SLOT(setZoom4()) );
+ viewMenu->addAction( tr("Zoom scale &0.5"), this, SLOT(setZoomHalf()) );
+ viewMenu->addAction( tr("Zoom scale 0.7&5"), this, SLOT(setZoom075()) );
+ viewMenu->addAction( tr("Zoom scale &1"), this, SLOT(setZoom1()) );
+ viewMenu->addAction( tr("Zoom scale &2"), this, SLOT(setZoom2()) );
+ viewMenu->addAction( tr("Zoom scale &3"), this, SLOT(setZoom3()) );
+ viewMenu->addAction( tr("Zoom scale &4"), this, SLOT(setZoom4()) );
viewMenu->addSeparator();
- viewMenu->addAction( "Zoom scale...", this, SLOT(setZoom()) );
+ viewMenu->addAction( tr("Zoom &scale..."), this, SLOT(setZoom()) );
return viewMenu;
}
QMenu* QVFb::createHelpMenu()
{
- QMenu *help = new QMenu( "Help", this );
- help->addAction("About...", this, SLOT(about()));
+ QMenu *help = new QMenu( tr("&Help"), this );
+ help->addAction(tr("&About..."), this, SLOT(about()));
return help;
}
@@ -525,17 +525,17 @@ void QVFb::setZoom4()
void QVFb::saveImage()
{
QImage img = view->image();
- QString filename = QFileDialog::getSaveFileName(this, "Save Main Screen image", "snapshot.png", "Portable Network Graphics (*.png)");
+ QString filename = QFileDialog::getSaveFileName(this, tr("Save Main Screen image"), tr("snapshot.png"), tr("Portable Network Graphics (*.png)"));
if (!filename.isEmpty()){
if(!img.save(filename,"PNG"))
- QMessageBox::critical(this, "Save Main Screen Image", "Save failed. Check that you have permission to write to the target directory.");
+ QMessageBox::critical(this, tr("Save Main Screen Image"), tr("Save failed. Check that you have permission to write to the target directory."));
}
if (secondaryView) {
QImage img = view->image();
- QString filename = QFileDialog::getSaveFileName(this, "Save Second Screen image", "snapshot.png", "Portable Network Graphics (*.png)");
+ QString filename = QFileDialog::getSaveFileName(this, tr("Save Second Screen image"), tr("snapshot.png"), tr("Portable Network Graphics (*.png)"));
if (!filename.isEmpty()) {
if(!img.save(filename,"PNG"))
- QMessageBox::critical(this, "Save Second Screen Image", "Save failed. Check that you have permission to write to the target directory.");
+ QMessageBox::critical(this, tr("Save Second Screen Image"), tr("Save failed. Check that you have permission to write to the target directory."));
}
}
}
@@ -577,7 +577,7 @@ void QVFb::setRate(int i)
void QVFb::about()
{
- QMessageBox::about(this, "About QVFB",
+ QMessageBox::about(this, tr("About QVFB"), tr(
"<h2>The Qt for Embedded Linux Virtual X11 Framebuffer</h2>"
"<p>This application runs under Qt for X11, emulating a simple framebuffer, "
"which the Qt for Embedded Linux server and clients can attach to just as if "
@@ -586,7 +586,7 @@ void QVFb::about()
"Linux applications under X11 without having to switch to a virtual console. "
"This means you can comfortably use your other development tools such "
"as GUI profilers and debuggers."
- );
+ ));
}
void QVFb::findSkins(const QString &currentSkin)
diff --git a/tools/qvfb/qvfbratedlg.cpp b/tools/qvfb/qvfbratedlg.cpp
index e491bdf..a0cbb2f 100644
--- a/tools/qvfb/qvfbratedlg.cpp
+++ b/tools/qvfb/qvfbratedlg.cpp
@@ -55,7 +55,7 @@ QVFbRateDialog::QVFbRateDialog(int rate, QWidget *parent)
QVBoxLayout *tl = new QVBoxLayout(this);
tl->setMargin(5);
- QLabel *label = new QLabel("Target frame rate:", this);
+ QLabel *label = new QLabel(tr("Target frame rate:"), this);
tl->addWidget(label);
QHBoxLayout *hl = new QHBoxLayout();
@@ -67,15 +67,15 @@ QVFbRateDialog::QVFbRateDialog(int rate, QWidget *parent)
rateSlider->setValue(rate);
hl->addWidget(rateSlider);
connect(rateSlider, SIGNAL(valueChanged(int)), this, SLOT(rateChanged(int)));
- rateLabel = new QLabel(QString("%1fps").arg(rate), this);
+ rateLabel = new QLabel(tr("%1fps").arg(rate), this);
hl->addWidget(rateLabel);
hl = new QHBoxLayout();
tl->addItem(hl);
- QPushButton *pb = new QPushButton("OK", this);
+ QPushButton *pb = new QPushButton(tr("OK"), this);
connect(pb, SIGNAL(clicked()), this, SLOT(ok()));
hl->addWidget(pb);
- pb = new QPushButton("Cancel", this);
+ pb = new QPushButton(tr("Cancel"), this);
connect(pb, SIGNAL(clicked()), this, SLOT(cancel()));
hl->addWidget(pb);
}
@@ -84,7 +84,7 @@ void QVFbRateDialog::rateChanged(int r)
{
if (rateSlider->value() != r)
rateSlider->setValue(r);
- rateLabel->setText(QString("%1fps").arg(r));
+ rateLabel->setText(tr("%1fps").arg(r));
emit updateRate(r);
}
diff --git a/tools/runonphone/ossignalconverter.cpp b/tools/runonphone/ossignalconverter.cpp
index 6554e9f..8566458 100644
--- a/tools/runonphone/ossignalconverter.cpp
+++ b/tools/runonphone/ossignalconverter.cpp
@@ -42,6 +42,7 @@
#include "ossignalconverter_p.h"
#include <signal.h>
#include <QTimer>
+#include <stdio.h>
Q_GLOBAL_STATIC(OsSignalConverter, osSignalConverter);
diff --git a/tools/runonphone/ossignalconverter.h b/tools/runonphone/ossignalconverter.h
index f53f3c1..398d0f6 100644
--- a/tools/runonphone/ossignalconverter.h
+++ b/tools/runonphone/ossignalconverter.h
@@ -43,6 +43,8 @@
#define OSSIGNALCONVERTER_H
#include <QObject>
+class OsSignalConverterPrivate;
+
class OsSignalConverter : public QObject
{
friend class OsSignalConverterPrivate;
diff --git a/tools/runonphone/runonphone.pro b/tools/runonphone/runonphone.pro
index 15dff51..7ff361c 100644
--- a/tools/runonphone/runonphone.pro
+++ b/tools/runonphone/runonphone.pro
@@ -31,4 +31,5 @@ else {
SOURCES += serenum_stub.cpp
}
-
+target.path=$$[QT_INSTALL_BINS]
+INSTALLS += target
diff --git a/tools/shared/qtpropertybrowser/qtpropertymanager.cpp b/tools/shared/qtpropertybrowser/qtpropertymanager.cpp
index d9ff10a..8c7835c 100644
--- a/tools/shared/qtpropertybrowser/qtpropertymanager.cpp
+++ b/tools/shared/qtpropertybrowser/qtpropertymanager.cpp
@@ -2399,15 +2399,23 @@ QString QtLocalePropertyManager::valueText(const QtProperty *property) const
if (it == d_ptr->m_values.constEnd())
return QString();
- QLocale loc = it.value();
+ const QLocale loc = it.value();
int langIdx = 0;
int countryIdx = 0;
- metaEnumProvider()->localeToIndex(loc.language(), loc.country(), &langIdx, &countryIdx);
- QString str = tr("%1, %2")
- .arg(metaEnumProvider()->languageEnumNames().at(langIdx))
- .arg(metaEnumProvider()->countryEnumNames(loc.language()).at(countryIdx));
- return str;
+ const QtMetaEnumProvider *me = metaEnumProvider();
+ me->localeToIndex(loc.language(), loc.country(), &langIdx, &countryIdx);
+ if (langIdx < 0) {
+ qWarning("QtLocalePropertyManager::valueText: Unknown language %d", loc.language());
+ return tr("<Invalid>");
+ }
+ const QString languageName = me->languageEnumNames().at(langIdx);
+ if (countryIdx < 0) {
+ qWarning("QtLocalePropertyManager::valueText: Unknown country %d for %s", loc.country(), qPrintable(languageName));
+ return languageName;
+ }
+ const QString countryName = me->countryEnumNames(loc.language()).at(countryIdx);
+ return tr("%1, %2").arg(languageName, countryName);
}
/*!
@@ -2635,8 +2643,8 @@ QString QtPointPropertyManager::valueText(const QtProperty *property) const
if (it == d_ptr->m_values.constEnd())
return QString();
const QPoint v = it.value();
- return QString(tr("(%1, %2)").arg(QString::number(v.x()))
- .arg(QString::number(v.y())));
+ return tr("(%1, %2)").arg(QString::number(v.x()))
+ .arg(QString::number(v.y()));
}
/*!
@@ -2876,8 +2884,8 @@ QString QtPointFPropertyManager::valueText(const QtProperty *property) const
return QString();
const QPointF v = it.value().val;
const int dec = it.value().decimals;
- return QString(tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec))
- .arg(QString::number(v.y(), 'f', dec)));
+ return tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec))
+ .arg(QString::number(v.y(), 'f', dec));
}
/*!
@@ -3196,8 +3204,8 @@ QString QtSizePropertyManager::valueText(const QtProperty *property) const
if (it == d_ptr->m_values.constEnd())
return QString();
const QSize v = it.value().val;
- return QString(tr("%1 x %2").arg(QString::number(v.width()))
- .arg(QString::number(v.height())));
+ return tr("%1 x %2").arg(QString::number(v.width()))
+ .arg(QString::number(v.height()));
}
/*!
@@ -3561,8 +3569,8 @@ QString QtSizeFPropertyManager::valueText(const QtProperty *property) const
return QString();
const QSizeF v = it.value().val;
const int dec = it.value().decimals;
- return QString(tr("%1 x %2").arg(QString::number(v.width(), 'f', dec))
- .arg(QString::number(v.height(), 'f', dec)));
+ return tr("%1 x %2").arg(QString::number(v.width(), 'f', dec))
+ .arg(QString::number(v.height(), 'f', dec));
}
/*!
@@ -3954,10 +3962,10 @@ QString QtRectPropertyManager::valueText(const QtProperty *property) const
if (it == d_ptr->m_values.constEnd())
return QString();
const QRect v = it.value().val;
- return QString(tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x()))
- .arg(QString::number(v.y()))
- .arg(QString::number(v.width()))
- .arg(QString::number(v.height())));
+ return tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x()))
+ .arg(QString::number(v.y()))
+ .arg(QString::number(v.width()))
+ .arg(QString::number(v.height()));
}
/*!
diff --git a/tools/tools.pro b/tools/tools.pro
index f254230..8f23fe4 100644
--- a/tools/tools.pro
+++ b/tools/tools.pro
@@ -43,3 +43,7 @@ embedded: SUBDIRS += makeqpf
CONFIG+=ordered
QTDIR_build:REQUIRES = "contains(QT_CONFIG, full-config)"
+
+!win32:!embedded:!mac:!symbian:CONFIG += x11
+
+x11:contains(QT_CONFIG, opengles2):contains(QT_CONFIG, egl):SUBDIRS += qmeegographicssystemhelper