diff options
Diffstat (limited to 'tools')
209 files changed, 7190 insertions, 5465 deletions
diff --git a/tools/activeqt/dumpcpp/main.cpp b/tools/activeqt/dumpcpp/main.cpp index bb65806..f95d31d 100644 --- a/tools/activeqt/dumpcpp/main.cpp +++ b/tools/activeqt/dumpcpp/main.cpp @@ -48,6 +48,7 @@ #include <QStringList> #include <QUuid> #include <QWidget> +#include <QFileInfo> #include <qt_windows.h> #include <ocidl.h> @@ -129,10 +130,10 @@ void writeEnums(QTextStream &out, const QMetaObject *mo) } } -void writeHeader(QTextStream &out, const QByteArray &nameSpace) +void writeHeader(QTextStream &out, const QByteArray &nameSpace, const QString &outFileName) { - out << "#ifndef QAX_DUMPCPP_" << nameSpace.toUpper() << "_H" << endl; - out << "#define QAX_DUMPCPP_" << nameSpace.toUpper() << "_H" << endl; + out << "#ifndef QAX_DUMPCPP_" << outFileName.toUpper() << "_H" << endl; + out << "#define QAX_DUMPCPP_" << outFileName.toUpper() << "_H" << endl; out << endl; out << "// Define this symbol to __declspec(dllexport) or __declspec(dllimport)" << endl; out << "#ifndef " << nameSpace.toUpper() << "_EXPORT" << endl; @@ -880,7 +881,7 @@ bool generateClass(QAxObject *object, const QByteArray &className, const QByteAr out << "****************************************************************************/" << endl; out << endl; - writeHeader(out, nameSpace); + writeHeader(out, nameSpace, outfile.fileName()); generateNameSpace(out, mo, nameSpace); // close namespace file @@ -1040,7 +1041,8 @@ bool generateTypeLibrary(const QByteArray &typeLib, const QByteArray &outname, O declOut << "****************************************************************************/" << endl; declOut << endl; - writeHeader(declOut, libName.toLatin1()); + QFileInfo cppFileInfo(cppFile); + writeHeader(declOut, libName.toLatin1(), cppFileInfo.fileName()); UINT typeCount = typelib->GetTypeInfoCount(); if (declFile.isOpen()) { diff --git a/tools/activeqt/testcon/changeproperties.cpp b/tools/activeqt/testcon/changeproperties.cpp index c36b3ad..ef896b6 100644 --- a/tools/activeqt/testcon/changeproperties.cpp +++ b/tools/activeqt/testcon/changeproperties.cpp @@ -108,7 +108,7 @@ void ChangeProperties::on_buttonSet_clicked() QColor col; col.setNamedColor(editValue->text()); if (col.isValid()) { - value = qVariantFromValue(col); + value = QVariant::fromValue(col); } else { QMessageBox::warning(this, tr("Can't parse input"), tr("Failed to create a color from %1\n" @@ -122,7 +122,7 @@ void ChangeProperties::on_buttonSet_clicked() { QFont fnt; if (fnt.fromString(editValue->text())) { - value = qVariantFromValue(fnt); + value = QVariant::fromValue(fnt); } else { QMessageBox::warning(this, tr("Can't parse input"), tr("Failed to create a font from %1\n" @@ -141,7 +141,7 @@ void ChangeProperties::on_buttonSet_clicked() if (pm.isNull()) return; - value = qVariantFromValue(pm); + value = QVariant::fromValue(pm); } break; case QVariant::Bool: diff --git a/tools/assistant/lib/fulltextsearch/fulltextsearch.pro b/tools/assistant/lib/fulltextsearch/fulltextsearch.pro index 4d2fddb..d0e7a87 100644 --- a/tools/assistant/lib/fulltextsearch/fulltextsearch.pro +++ b/tools/assistant/lib/fulltextsearch/fulltextsearch.pro @@ -23,7 +23,7 @@ contains(QT_CONFIG, reduce_exports) { linux*-g++*:DEFINES += _GLIBCXX_EXTERN_TEMPLATE=0 } -unix:QMAKE_PKGCONFIG_REQUIRES = QtCore +unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore # impossible to disable exceptions in clucene atm CONFIG(exceptions_off) { diff --git a/tools/assistant/lib/fulltextsearch/qanalyzer.cpp b/tools/assistant/lib/fulltextsearch/qanalyzer.cpp index d6b00a0..71dd2c9 100644 --- a/tools/assistant/lib/fulltextsearch/qanalyzer.cpp +++ b/tools/assistant/lib/fulltextsearch/qanalyzer.cpp @@ -96,6 +96,11 @@ QCLuceneStandardAnalyzer::QCLuceneStandardAnalyzer(const QStringList &stopWords) tArray[stopWords.count()] = 0; d->analyzer = new lucene::analysis::standard::StandardAnalyzer(tArray); + + for (int i = 0; i < stopWords.count(); ++i) + delete [] tArray[i]; + + delete [] tArray; } @@ -147,6 +152,11 @@ QCLuceneStopAnalyzer::QCLuceneStopAnalyzer(const QStringList &stopWords) tArray[stopWords.count()] = 0; d->analyzer = new lucene::analysis::StopAnalyzer(tArray); + + for (int i = 0; i < stopWords.count(); ++i) + delete [] tArray[i]; + + delete [] tArray; } QStringList QCLuceneStopAnalyzer::englishStopWords() const diff --git a/tools/assistant/lib/lib.pro b/tools/assistant/lib/lib.pro index 26d3456..03821b2 100644 --- a/tools/assistant/lib/lib.pro +++ b/tools/assistant/lib/lib.pro @@ -19,7 +19,7 @@ if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { win32:qclucene = $${qclucene}d } linux-lsb-g++:LIBS_PRIVATE += --lsb-shared-libs=$$qclucene -unix:QMAKE_PKGCONFIG_REQUIRES += QtNetwork \ +unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES += QtNetwork \ QtSql \ QtXml LIBS_PRIVATE += -l$$qclucene diff --git a/tools/assistant/lib/qhelpsearchquerywidget.cpp b/tools/assistant/lib/qhelpsearchquerywidget.cpp index c917907..e6a789a 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 8cf4b2b..e9fb61c 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/aboutdialog.cpp b/tools/assistant/tools/assistant/aboutdialog.cpp index 186dbda..b4c390e 100644 --- a/tools/assistant/tools/assistant/aboutdialog.cpp +++ b/tools/assistant/tools/assistant/aboutdialog.cpp @@ -38,6 +38,9 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + +#include "aboutdialog.h" + #include "helpviewer.h" #include "tracer.h" @@ -51,8 +54,6 @@ #include <QtGui/QMessageBox> #include <QtGui/QDesktopServices> -#include "aboutdialog.h" - QT_BEGIN_NAMESPACE AboutLabel::AboutLabel(QWidget *parent) @@ -96,8 +97,8 @@ QVariant AboutLabel::loadResource(int type, const QUrl &name) void AboutLabel::setSource(const QUrl &url) { TRACE_OBJ - if (url.isValid() && (!AbstractHelpViewer::isLocalUrl(url) - || !AbstractHelpViewer::canOpenPage(url.path()))) { + if (url.isValid() && (!HelpViewer::isLocalUrl(url) + || !HelpViewer::canOpenPage(url.path()))) { if (!QDesktopServices::openUrl(url)) { QMessageBox::warning(this, tr("Warning"), tr("Unable to launch external application.\n"), tr("OK")); diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index d9aff7a..7f0fdd1 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -12,6 +12,8 @@ DESTDIR = ../../../../bin target.path = $$[QT_INSTALL_BINS] INSTALLS += target DEPENDPATH += ../shared +DEPENDPATH += . +INCLUDEPATH += . # ## Work around a qmake issue when statically linking to # ## not-yet-installed plugins @@ -30,6 +32,7 @@ HEADERS += aboutdialog.h \ filternamedialog.h \ helpenginewrapper.h \ helpviewer.h \ + helpviewer_p.h \ indexwindow.h \ installdialog.h \ mainwindow.h \ @@ -40,12 +43,12 @@ HEADERS += aboutdialog.h \ topicchooser.h \ tracer.h \ xbelsupport.h \ - ../shared/collectionconfiguration.h -contains(QT_CONFIG, webkit) { - HEADERS += helpviewer_qwv.h -} else { - HEADERS += helpviewer_qtb.h - } + ../shared/collectionconfiguration.h \ + openpagesmodel.h \ + globalactions.h \ + openpageswidget.h \ + openpagesmanager.h \ + openpagesswitcher.h win32:HEADERS += remotecontrol_win.h SOURCES += aboutdialog.cpp \ @@ -72,8 +75,13 @@ SOURCES += aboutdialog.cpp \ searchwidget.cpp \ topicchooser.cpp \ xbelsupport.cpp \ - ../shared/collectionconfiguration.cpp - contains(QT_CONFIG, webkit) { + ../shared/collectionconfiguration.cpp \ + openpagesmodel.cpp \ + globalactions.cpp \ + openpageswidget.cpp \ + openpagesmanager.cpp \ + openpagesswitcher.cpp +contains(QT_CONFIG, webkit) { SOURCES += helpviewer_qwv.cpp } else { SOURCES += helpviewer_qtb.cpp diff --git a/tools/assistant/tools/assistant/assistant_images.qrc b/tools/assistant/tools/assistant/assistant_images.qrc index 34918c0..b4f2523 100644 --- a/tools/assistant/tools/assistant/assistant_images.qrc +++ b/tools/assistant/tools/assistant/assistant_images.qrc @@ -1,11 +1,10 @@ <RCC> - <qresource prefix="/trolltech/assistant" > + <qresource prefix="/trolltech/assistant"> <file>images/trolltech-logo.png</file> <file>images/assistant-128.png</file> <file>images/assistant.png</file> <file>images/wrap.png</file> <file>images/bookmark.png</file> -#mac <file>images/mac/addtab.png</file> <file>images/mac/book.png</file> <file>images/mac/closetab.png</file> @@ -19,7 +18,6 @@ <file>images/mac/zoomin.png</file> <file>images/mac/zoomout.png</file> <file>images/mac/resetzoom.png</file> -#win <file>images/win/addtab.png</file> <file>images/win/book.png</file> <file>images/win/closetab.png</file> @@ -33,5 +31,7 @@ <file>images/win/zoomin.png</file> <file>images/win/zoomout.png</file> <file>images/win/resetzoom.png</file> + <file>images/closebutton.png</file> + <file>images/darkclosebutton.png</file> </qresource> </RCC> diff --git a/tools/assistant/tools/assistant/bookmarkfiltermodel.cpp b/tools/assistant/tools/assistant/bookmarkfiltermodel.cpp index 769e6c4..412e08e 100644 --- a/tools/assistant/tools/assistant/bookmarkfiltermodel.cpp +++ b/tools/assistant/tools/assistant/bookmarkfiltermodel.cpp @@ -50,11 +50,29 @@ BookmarkFilterModel::BookmarkFilterModel(QObject *parent) { } -void -BookmarkFilterModel::setSourceModel(QAbstractItemModel *_sourceModel) +void BookmarkFilterModel::setSourceModel(QAbstractItemModel *_sourceModel) { beginResetModel(); + if (sourceModel) { + 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 +97,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 +116,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 +124,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 +146,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 +175,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 +224,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 +247,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 +255,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 +305,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()); diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp index a683870..8733146 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() @@ -283,7 +301,7 @@ void BookmarkManager::buildBookmarksMenu(const QModelIndex &index, QMenu* menu) return; const QString &text = index.data().toString(); - const QIcon &icon = qVariantValue<QIcon>(index.data(Qt::DecorationRole)); + const QIcon &icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole)); if (index.data(UserRoleFolder).toBool()) { if (QMenu* subMenu = menu->addMenu(icon, text)) { for (int i = 0; i < bookmarkModel->rowCount(index); ++i) @@ -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 862d767..f5823a7 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/bookmarkmodel.cpp b/tools/assistant/tools/assistant/bookmarkmodel.cpp index 2c98b65..49b89c3 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 7ac4467..c8c454f 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -38,966 +38,514 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" #include "centralwidget.h" + #include "findwidget.h" #include "helpenginewrapper.h" -#include "searchwidget.h" -#include "mainwindow.h" +#include "helpviewer.h" +#include "openpagesmanager.h" +#include "tracer.h" #include "../shared/collectionconfiguration.h" -#if defined(QT_NO_WEBKIT) -#include "helpviewer_qtb.h" -#else -#include "helpviewer_qwv.h" -#endif // QT_NO_WEBKIT - #include <QtCore/QTimer> -#include <QtGui/QApplication> #include <QtGui/QKeyEvent> -#include <QtGui/QLayout> #include <QtGui/QMenu> -#include <QtGui/QPrinter> -#include <QtGui/QTabBar> -#include <QtGui/QTabWidget> -#include <QtGui/QTextBrowser> -#include <QtGui/QToolButton> #include <QtGui/QPageSetupDialog> #include <QtGui/QPrintDialog> #include <QtGui/QPrintPreviewDialog> +#include <QtGui/QPrinter> +#include <QtGui/QStackedWidget> +#include <QtGui/QTextBrowser> +#include <QtGui/QVBoxLayout> #include <QtHelp/QHelpSearchEngine> QT_BEGIN_NAMESPACE namespace { - HelpViewer* helpViewerFromTabPosition(const QTabWidget *widget, - const QPoint &point) - { - TRACE_OBJ - QTabBar *tabBar = qFindChild<QTabBar*>(widget); - for (int i = 0; i < tabBar->count(); ++i) { - if (tabBar->tabRect(i).contains(point)) - return qobject_cast<HelpViewer*>(widget->widget(i)); - } - return 0; - } CentralWidget *staticCentralWidget = 0; } -// -- CentralWidget +// -- TabBar -CentralWidget::CentralWidget(MainWindow *parent) - : QWidget(parent) - , lastTabPage(0) - , tabWidget(0) - , findWidget(0) - , printer(0) - , usesDefaultCollection(parent->usesDefaultCollection()) - , m_searchWidget(0) +TabBar::TabBar(QWidget *parent) + : QTabBar(parent) { TRACE_OBJ - globalActionList.clear(); - staticCentralWidget = this; - QVBoxLayout *vboxLayout = new QVBoxLayout(this); - QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); - - vboxLayout->setMargin(0); - tabWidget = new QTabWidget(this); -#ifndef Q_OS_MAC - resourcePath.append(QLatin1String("win")); -#else - resourcePath.append(QLatin1String("mac")); - tabWidget->setDocumentMode(true); -#endif - - connect(tabWidget, SIGNAL(currentChanged(int)), this, - SLOT(currentPageChanged(int))); - - QToolButton *newTabButton = new QToolButton(this); - newTabButton->setAutoRaise(true); - newTabButton->setToolTip(tr("Add new page")); - newTabButton->setIcon(QIcon(resourcePath + QLatin1String("/addtab.png"))); - - tabWidget->setCornerWidget(newTabButton, Qt::TopLeftCorner); - connect(newTabButton, SIGNAL(clicked()), this, SLOT(newTab())); - - QToolButton *closeTabButton = new QToolButton(this); - closeTabButton->setEnabled(false); - closeTabButton->setAutoRaise(true); - closeTabButton->setToolTip(tr("Close current page")); - closeTabButton->setIcon(QIcon(resourcePath + QLatin1String("/closetab.png"))); - - tabWidget->setCornerWidget(closeTabButton, Qt::TopRightCorner); - connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeTab())); - - vboxLayout->addWidget(tabWidget); - - findWidget = new FindWidget(this); - vboxLayout->addWidget(findWidget); - findWidget->hide(); - - connect(findWidget, SIGNAL(findNext()), this, SLOT(findNext())); - connect(findWidget, SIGNAL(findPrevious()), this, SLOT(findPrevious())); - connect(findWidget, SIGNAL(find(QString, bool)), this, - SLOT(find(QString, bool))); - connect(findWidget, SIGNAL(escapePressed()), this, SLOT(activateTab())); - - QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget); - if (tabBar) { - tabBar->installEventFilter(this); - tabBar->setContextMenuPolicy(Qt::CustomContextMenu); - connect(tabBar, SIGNAL(customContextMenuRequested(QPoint)), this, - SLOT(showTabBarContextMenu(QPoint))); - } - -#if defined(QT_NO_WEBKIT) - QPalette p = palette(); - p.setColor(QPalette::Inactive, QPalette::Highlight, - p.color(QPalette::Active, QPalette::Highlight)); - p.setColor(QPalette::Inactive, QPalette::HighlightedText, - p.color(QPalette::Active, QPalette::HighlightedText)); - setPalette(p); +#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))); } -CentralWidget::~CentralWidget() +TabBar::~TabBar() { TRACE_OBJ -#ifndef QT_NO_PRINTER - delete printer; -#endif - - QStringList zoomFactors; - QStringList currentPages; - bool searchAttached = m_searchWidget->isAttached(); - - int i = searchAttached ? 1 : 0; - for (; i < tabWidget->count(); ++i) { - HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i)); - if (viewer && viewer->source().isValid()) { - currentPages << viewer->source().toString(); - zoomFactors << QString::number(viewer->scale()); - } - } - - HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - helpEngine.setLastTabPage(tabWidget->currentIndex()); - helpEngine.setLastShownPages(currentPages); - helpEngine.setSearchWasAttached(searchAttached); - helpEngine.setLastZoomFactors(zoomFactors); } -CentralWidget *CentralWidget::instance() +int TabBar::addNewTab(const QString &title) { TRACE_OBJ - return staticCentralWidget; + const int index = addTab(title); + setTabsClosable(count() > 1); + return index; } -void CentralWidget::newTab() +void TabBar::setCurrent(HelpViewer *viewer) { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); -#if !defined(QT_NO_WEBKIT) - if (viewer && viewer->hasLoadFinished()) -#else - if (viewer) -#endif - setSourceInNewTab(viewer->source()); -} - -void CentralWidget::zoomIn() -{ - TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->scaleUp(); - - if (tabWidget->currentWidget() == m_searchWidget) - m_searchWidget->zoomIn(); + for (int i = 0; i < count(); ++i) { + HelpViewer *data = tabData(i).value<HelpViewer*>(); + if (data == viewer) { + setCurrentIndex(i); + break; + } + } } -void CentralWidget::zoomOut() +void TabBar::removeTabAt(HelpViewer *viewer) { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->scaleDown(); - - if (tabWidget->currentWidget() == m_searchWidget) - m_searchWidget->zoomOut(); + for (int i = 0; i < count(); ++i) { + HelpViewer *data = tabData(i).value<HelpViewer*>(); + if (data == viewer) { + removeTab(i); + break; + } + } + setTabsClosable(count() > 1); } -void CentralWidget::nextPage() +void TabBar::titleChanged() { TRACE_OBJ - int index = tabWidget->currentIndex() + 1; - if (index >= tabWidget->count()) - index = 0; - tabWidget->setCurrentIndex(index); + 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 CentralWidget::resetZoom() +void TabBar::slotCurrentChanged(int index) { TRACE_OBJ - if (HelpViewer *viewer = currentHelpViewer()) - viewer->resetScale(); - - if (tabWidget->currentWidget() == m_searchWidget) - m_searchWidget->resetZoom(); + emit currentTabChanged(tabData(index).value<HelpViewer*>()); } -void CentralWidget::previousPage() +void TabBar::slotTabCloseRequested(int index) { TRACE_OBJ - int index = tabWidget->currentIndex() -1; - if (index < 0) - index = tabWidget->count() -1; - tabWidget->setCurrentIndex(index); + OpenPagesManager::instance()->closePage(tabData(index).value<HelpViewer*>()); } -void CentralWidget::closeTab() +void TabBar::slotCustomContextMenuRequested(const QPoint &pos) { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (!viewer|| tabWidget->count() == 1) + const int tab = tabAt(pos); + if (tab < 0) return; - tabWidget->removeTab(tabWidget->indexOf(viewer)); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); + 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); } -void CentralWidget::setSource(const QUrl &url) +// -- CentralWidget + +CentralWidget::CentralWidget(QWidget *parent) + : QWidget(parent) +#ifndef QT_NO_PRINTER + , m_printer(0) +#endif + , m_findWidget(new FindWidget(this)) + , m_stackedWidget(new QStackedWidget(this)) + , m_tabBar(new TabBar(this)) { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - HelpViewer *lastViewer = - qobject_cast<HelpViewer*>(tabWidget->widget(lastTabPage)); - - if (!viewer && !lastViewer) { - viewer = new HelpViewer(this); - viewer->installEventFilter(this); - lastTabPage = tabWidget->addTab(viewer, QString()); - tabWidget->setCurrentIndex(lastTabPage); - connectSignals(); - } else { - viewer = lastViewer; - } + staticCentralWidget = this; + QVBoxLayout *vboxLayout = new QVBoxLayout(this); - viewer->setSource(url); - currentPageChanged(lastTabPage); - viewer->setFocus(Qt::OtherFocusReason); - tabWidget->setCurrentIndex(lastTabPage); - tabWidget->setTabText(lastTabPage, quoteTabTitle(viewer->documentTitle())); + 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(); + + connect(m_findWidget, SIGNAL(findNext()), this, SLOT(findNext())); + connect(m_findWidget, SIGNAL(findPrevious()), this, SLOT(findPrevious())); + 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))); } -void CentralWidget::setupWidget() +CentralWidget::~CentralWidget() { TRACE_OBJ - HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - int option = helpEngine.startOption(); - if (option != ShowLastPages) { - QString homePage; - if (option == ShowHomePage) - homePage = helpEngine.homePage(); - else if (option == ShowBlankPage) - homePage = QLatin1String("about:blank"); - setSource(homePage); - } else { - setLastShownPages(); + QStringList zoomFactors; + QStringList currentPages; + for (int i = 0; i < m_stackedWidget->count(); ++i) { + const HelpViewer * const viewer = viewerAt(i); + const QUrl &source = viewer->source(); + if (source.isValid()) { + currentPages << source.toString(); + zoomFactors << QString::number(viewer->scale()); + } } -} -void CentralWidget::setLastShownPages() -{ - TRACE_OBJ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - const QStringList &lastShownPageList = helpEngine.lastShownPages(); - const int pageCount = lastShownPageList.count(); - if (pageCount == 0) { - if (usesDefaultCollection) - setSource(QUrl(QLatin1String("help"))); - else - setSource(QUrl(QLatin1String("about:blank"))); - return; - } - QStringList zoomFactors = helpEngine.lastZoomFactors(); - while (zoomFactors.count() < pageCount) - zoomFactors.append(CollectionConfiguration::DefaultZoomFactor); - - const bool searchIsAttached = m_searchWidget->isAttached(); - const bool searchWasAttached = helpEngine.searchWasAttached(); - int tabToShow = helpEngine.lastTabPage(); - if (searchWasAttached && !searchIsAttached && tabToShow != 0) - --tabToShow; - else if (!searchWasAttached && searchIsAttached) - ++tabToShow; - - for (int curTab = 0; curTab < pageCount; ++curTab) { - const QString &curFile = lastShownPageList.at(curTab); - if (helpEngine.findFile(curFile).isValid() - || curFile == QLatin1String("about:blank")) { - setSourceInNewTab(curFile, zoomFactors.at(curTab).toFloat()); - } else if (curTab + searchIsAttached <= tabToShow) - --tabToShow; - } + helpEngine.setLastShownPages(currentPages); + helpEngine.setLastZoomFactors(zoomFactors); + helpEngine.setLastTabPage(m_stackedWidget->currentIndex()); - tabWidget->setCurrentIndex(tabToShow); +#ifndef QT_NO_PRINTER + delete m_printer; +#endif } -bool CentralWidget::hasSelection() const +CentralWidget *CentralWidget::instance() { TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - return viewer ? viewer->hasSelection() : false; + return staticCentralWidget; } QUrl CentralWidget::currentSource() const { TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - if (viewer) - return viewer->source(); - - return QUrl(); + return currentHelpViewer()->source(); } QString CentralWidget::currentTitle() const { TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - if (viewer) - return viewer->documentTitle(); - - return QString(); + return currentHelpViewer()->title(); } -void CentralWidget::copySelection() +bool CentralWidget::hasSelection() const { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->copy(); + return !currentHelpViewer()->selectedText().isEmpty(); } -void CentralWidget::showTextSearch() +bool CentralWidget::isForwardAvailable() const { TRACE_OBJ - findWidget->show(); + return currentHelpViewer()->isForwardAvailable(); } -void CentralWidget::initPrinter() +bool CentralWidget::isBackwardAvailable() const { TRACE_OBJ -#ifndef QT_NO_PRINTER - if (!printer) - printer = new QPrinter(QPrinter::HighResolution); -#endif + return currentHelpViewer()->isBackwardAvailable(); } -void CentralWidget::print() +HelpViewer* CentralWidget::viewerAt(int index) const { TRACE_OBJ -#ifndef QT_NO_PRINTER - HelpViewer *viewer = currentHelpViewer(); - if (!viewer) - return; - - initPrinter(); - - QPrintDialog dlg(printer, this); -#if defined(QT_NO_WEBKIT) - if (viewer->textCursor().hasSelection()) - dlg.addEnabledOption(QAbstractPrintDialog::PrintSelection); -#endif - dlg.addEnabledOption(QAbstractPrintDialog::PrintPageRange); - dlg.addEnabledOption(QAbstractPrintDialog::PrintCollateCopies); - dlg.setWindowTitle(tr("Print Document")); - if (dlg.exec() == QDialog::Accepted) { - viewer->print(printer); - } -#endif + return static_cast<HelpViewer*>(m_stackedWidget->widget(index)); } -void CentralWidget::printPreview() +HelpViewer* CentralWidget::currentHelpViewer() const { TRACE_OBJ -#ifndef QT_NO_PRINTER - initPrinter(); - QPrintPreviewDialog preview(printer, this); - connect(&preview, SIGNAL(paintRequested(QPrinter*)), - SLOT(printPreview(QPrinter*))); - preview.exec(); -#endif + return static_cast<HelpViewer *>(m_stackedWidget->currentWidget()); } -void CentralWidget::printPreview(QPrinter *p) +void CentralWidget::addPage(HelpViewer *page, bool fromSearch) { TRACE_OBJ -#ifndef QT_NO_PRINTER - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->print(p); -#endif -} + page->installEventFilter(this); + page->setFocus(Qt::OtherFocusReason); + connectSignals(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())); -void CentralWidget::pageSetup() -{ - TRACE_OBJ -#ifndef QT_NO_PRINTER - initPrinter(); - QPageSetupDialog dlg(printer); - dlg.exec(); -#endif + if (fromSearch) { + connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); + } } -bool CentralWidget::isHomeAvailable() const +void CentralWidget::removePage(int index) { TRACE_OBJ - return currentHelpViewer() ? true : false; + const bool currentChanged = index == currentIndex(); + m_tabBar->removeTabAt(viewerAt(index)); + m_stackedWidget->removeWidget(m_stackedWidget->widget(index)); + if (currentChanged) + emit currentViewerChanged(); } -void CentralWidget::home() +int CentralWidget::currentIndex() const { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->home(); + return m_stackedWidget->currentIndex(); } -bool CentralWidget::isForwardAvailable() const +void CentralWidget::setCurrentPage(HelpViewer *page) { TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - if (viewer) - return viewer->isForwardAvailable(); - - return false; + m_tabBar->setCurrent(page); + m_stackedWidget->setCurrentWidget(page); + emit currentViewerChanged(); } -void CentralWidget::forward() +void CentralWidget::connectTabBar() { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->forward(); + connect(m_tabBar, SIGNAL(currentTabChanged(HelpViewer*)), + OpenPagesManager::instance(), SLOT(setCurrentPage(HelpViewer*))); } -bool CentralWidget::isBackwardAvailable() const -{ - TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - if (viewer) - return viewer->isBackwardAvailable(); - - return false; -} +// -- public slots -void CentralWidget::backward() +void CentralWidget::copy() { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->backward(); + currentHelpViewer()->copy(); } - -QList<QAction*> CentralWidget::globalActions() const +void CentralWidget::home() { TRACE_OBJ - return globalActionList; + currentHelpViewer()->home(); } -void CentralWidget::setGlobalActions(const QList<QAction*> &actions) +void CentralWidget::zoomIn() { TRACE_OBJ - globalActionList = actions; + currentHelpViewer()->scaleUp(); } -void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) +void CentralWidget::zoomOut() { TRACE_OBJ - if (HelpViewer *viewer = currentHelpViewer()) { - if (viewer->launchWithExternalApp(url)) - return; - } - - HelpViewer *viewer = new HelpViewer(this, zoom); - viewer->installEventFilter(this); - viewer->setSource(url); - viewer->setFocus(Qt::OtherFocusReason); - tabWidget->setCurrentIndex(tabWidget->addTab(viewer, - quoteTabTitle(viewer->documentTitle()))); - connectSignals(); + currentHelpViewer()->scaleDown(); } -HelpViewer *CentralWidget::newEmptyTab() +void CentralWidget::resetZoom() { TRACE_OBJ - HelpViewer *viewer = new HelpViewer(this); - viewer->installEventFilter(this); - viewer->setFocus(Qt::OtherFocusReason); -#if defined(QT_NO_WEBKIT) - viewer->setDocumentTitle(tr("unknown")); -#endif - tabWidget->setCurrentIndex(tabWidget->addTab(viewer, tr("unknown"))); - - connectSignals(); - return viewer; + currentHelpViewer()->resetScale(); } -void CentralWidget::connectSignals() +void CentralWidget::forward() { TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - if (viewer) { - connect(viewer, SIGNAL(copyAvailable(bool)), this, - SIGNAL(copyAvailable(bool))); - connect(viewer, SIGNAL(forwardAvailable(bool)), this, - SIGNAL(forwardAvailable(bool))); - connect(viewer, SIGNAL(backwardAvailable(bool)), this, - SIGNAL(backwardAvailable(bool))); - connect(viewer, SIGNAL(sourceChanged(QUrl)), this, - SIGNAL(sourceChanged(QUrl))); - connect(viewer, SIGNAL(highlighted(QString)), this, - SIGNAL(highlighted(QString))); - connect(viewer, SIGNAL(sourceChanged(QUrl)), this, - SLOT(setTabTitle(QUrl))); - connect(viewer, SIGNAL(printRequested()), this, SLOT(print())); - } + currentHelpViewer()->forward(); } -HelpViewer* CentralWidget::viewerAt(int index) const +void CentralWidget::nextPage() { TRACE_OBJ - return qobject_cast<HelpViewer*>(tabWidget->widget(index)); + m_stackedWidget->setCurrentIndex((m_stackedWidget->currentIndex() + 1) + % m_stackedWidget->count()); } -HelpViewer* CentralWidget::currentHelpViewer() const +void CentralWidget::backward() { TRACE_OBJ - return qobject_cast<HelpViewer*>(tabWidget->currentWidget()); + currentHelpViewer()->backward(); } -void CentralWidget::activateTab(bool onlyHelpViewer) +void CentralWidget::previousPage() { TRACE_OBJ - if (currentHelpViewer()) { - currentHelpViewer()->setFocus(); - } else { - int idx = 0; - if (onlyHelpViewer) - idx = lastTabPage; - tabWidget->setCurrentIndex(idx); - tabWidget->currentWidget()->setFocus(); - } + m_stackedWidget->setCurrentIndex((m_stackedWidget->currentIndex() - 1) + % m_stackedWidget->count()); } -void CentralWidget::setTabTitle(const QUrl &url) +void CentralWidget::print() { TRACE_OBJ - Q_UNUSED(url) -#if !defined(QT_NO_WEBKIT) - QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget); - for (int tab = 0; tab < tabBar->count(); ++tab) { - HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(tab)); - if (viewer) { - tabWidget->setTabText(tab, - quoteTabTitle(viewer->documentTitle().trimmed())); - } - } -#else - HelpViewer *viewer = currentHelpViewer(); - if (viewer) { - tabWidget->setTabText(lastTabPage, - quoteTabTitle(viewer->documentTitle().trimmed())); - } +#ifndef QT_NO_PRINTER + initPrinter(); + QPrintDialog dlg(m_printer, this); + + if (!currentHelpViewer()->selectedText().isEmpty()) + dlg.addEnabledOption(QAbstractPrintDialog::PrintSelection); + dlg.addEnabledOption(QAbstractPrintDialog::PrintPageRange); + dlg.addEnabledOption(QAbstractPrintDialog::PrintCollateCopies); + dlg.setWindowTitle(tr("Print Document")); + if (dlg.exec() == QDialog::Accepted) + currentHelpViewer()->print(m_printer); #endif } -void CentralWidget::currentPageChanged(int index) +void CentralWidget::pageSetup() { TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - if (viewer) - lastTabPage = index; - - QWidget *widget = tabWidget->cornerWidget(Qt::TopRightCorner); - widget->setEnabled(viewer && enableTabCloseAction()); - - widget = tabWidget->cornerWidget(Qt::TopLeftCorner); - widget->setEnabled(viewer ? true : false); - - emit currentViewerChanged(); +#ifndef QT_NO_PRINTER + initPrinter(); + QPageSetupDialog dlg(m_printer); + dlg.exec(); +#endif } -void CentralWidget::showTabBarContextMenu(const QPoint &point) +void CentralWidget::printPreview() { TRACE_OBJ - HelpViewer *viewer = helpViewerFromTabPosition(tabWidget, point); - if (!viewer) - return; - - QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget); - - QMenu menu(QLatin1String(""), tabBar); - QAction *newPage = menu.addAction(tr("Add New Page")); - - bool enableAction = enableTabCloseAction(); - QAction *closePage = menu.addAction(tr("Close This Page")); - closePage->setEnabled(enableAction); - - QAction *closePages = menu.addAction(tr("Close Other Pages")); - closePages->setEnabled(enableAction); - - menu.addSeparator(); - - 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(tabBar->mapToGlobal(point)); - if (pickedAction == newPage) - setSourceInNewTab(viewer->source()); - - if (pickedAction == closePage) { - tabWidget->removeTab(tabWidget->indexOf(viewer)); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); - } - - if (pickedAction == closePages) { - int currentPage = tabWidget->indexOf(viewer); - for (int i = tabBar->count() -1; i >= 0; --i) { - viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i)); - if (i != currentPage && viewer) { - tabWidget->removeTab(i); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); - - if (i < currentPage) - --currentPage; - } - } - } - - if (pickedAction == newBookmark) - emit addBookmark(viewer->documentTitle(), viewer->source().toString()); +#ifndef QT_NO_PRINTER + initPrinter(); + QPrintPreviewDialog preview(m_printer, this); + connect(&preview, SIGNAL(paintRequested(QPrinter*)), + SLOT(printPreview(QPrinter*))); + preview.exec(); +#endif } -bool CentralWidget::eventFilter(QObject *object, QEvent *e) +void CentralWidget::setSource(const QUrl &url) { TRACE_OBJ - if (e->type() == QEvent::KeyPress) { - QKeyEvent *ke = static_cast<QKeyEvent*>(e); - switch (ke->key()) { - default: { - return QWidget::eventFilter(object, e); - } break; - - case Qt::Key_Backspace: { - HelpViewer *viewer = currentHelpViewer(); - if (viewer == object) { -#if defined(QT_NO_WEBKIT) - if (viewer->isBackwardAvailable()) { -#else - if (viewer->isBackwardAvailable() && !viewer->hasFocus()) { -#endif - viewer->backward(); - return true; - } - } - } break; - } - } - - if (qobject_cast<QTabBar*>(object)) { - const bool dblClick = e->type() == QEvent::MouseButtonDblClick; - if ((e->type() == QEvent::MouseButtonRelease) || dblClick) { - QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(e); - HelpViewer *viewer = helpViewerFromTabPosition(tabWidget, - mouseEvent->pos()); - if (viewer) { - if ((mouseEvent->button() == Qt::MidButton) || dblClick) { - if (availableHelpViewer() > 1) { - tabWidget->removeTab(tabWidget->indexOf(viewer)); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); - currentPageChanged(tabWidget->currentIndex()); - return true; - } - } - } - } - } - - return QWidget::eventFilter(object, e); + HelpViewer *viewer = currentHelpViewer(); + viewer->setSource(url); + viewer->setFocus(Qt::OtherFocusReason); } -void CentralWidget::keyPressEvent(QKeyEvent *e) +void CentralWidget::setSourceFromSearch(const QUrl &url) { TRACE_OBJ - const QString &text = e->text(); - if (text.startsWith(QLatin1Char('/'))) { - if (!findWidget->isVisible()) { - findWidget->showAndClear(); - } else { - findWidget->show(); - } - } else { - QWidget::keyPressEvent(e); - } + connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); + currentHelpViewer()->setSource(url); + currentHelpViewer()->setFocus(Qt::OtherFocusReason); } void CentralWidget::findNext() { TRACE_OBJ - find(findWidget->text(), true); + find(m_findWidget->text(), true, false); } void CentralWidget::findPrevious() { TRACE_OBJ - find(findWidget->text(), false); + find(m_findWidget->text(), false, false); } -void CentralWidget::find(const QString &ttf, bool forward) +void CentralWidget::find(const QString &ttf, bool forward, bool incremental) { TRACE_OBJ bool found = false; -#if defined(QT_NO_WEBKIT) - found = findInTextBrowser(ttf, forward); -#else - found = findInWebPage(ttf, forward); -#endif + if (HelpViewer *viewer = currentHelpViewer()) { + HelpViewer::FindFlags flags = 0; + if (!forward) + flags |= HelpViewer::FindBackward; + if (m_findWidget->caseSensitive()) + flags |= HelpViewer::FindCaseSensitively; + found = viewer->findText(ttf, flags, incremental, false); + } if (!found && ttf.isEmpty()) found = true; // the line edit is empty, no need to mark it red... - if (!findWidget->isVisible()) - findWidget->show(); - findWidget->setPalette(found); + if (!m_findWidget->isVisible()) + m_findWidget->show(); + m_findWidget->setPalette(found); } -bool CentralWidget::findInWebPage(const QString &ttf, bool forward) +void CentralWidget::activateTab() { TRACE_OBJ -#if !defined(QT_NO_WEBKIT) - if (HelpViewer *viewer = currentHelpViewer()) { - bool found = false; - QWebPage::FindFlags options; - if (!ttf.isEmpty()) { - if (!forward) - options |= QWebPage::FindBackward; - - if (findWidget->caseSensitive()) - options |= QWebPage::FindCaseSensitively; - - found = viewer->findText(ttf, options); - findWidget->setTextWrappedVisible(false); - - if (!found) { - options |= QWebPage::FindWrapsAroundDocument; - found = viewer->findText(ttf, options); - if (found) - findWidget->setTextWrappedVisible(true); - } - } - // force highlighting of all other matches, also when empty (clear) - options = QWebPage::HighlightAllOccurrences; - if (findWidget->caseSensitive()) - options |= QWebPage::FindCaseSensitively; - viewer->findText(QLatin1String(""), options); - viewer->findText(ttf, options); - return found; - } - - // this needs to stay, case for active search results page - return findInTextBrowser(ttf, forward); -#else - Q_UNUSED(ttf); - Q_UNUSED(forward); -#endif - return false; + currentHelpViewer()->setFocus(); } -bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward) +void CentralWidget::showTextSearch() { TRACE_OBJ - QTextBrowser *browser = qobject_cast<QTextBrowser*>(currentHelpViewer()); - if (tabWidget->currentWidget() == m_searchWidget) - browser = qFindChild<QTextBrowser*>(m_searchWidget); - - if (!browser || ttf.isEmpty()) - return false; - - QTextDocument *doc = browser->document(); - QTextCursor cursor = browser->textCursor(); - - if (!doc || cursor.isNull()) - return false; - - QTextDocument::FindFlags options; - - if (cursor.hasSelection()) { - cursor.setPosition(forward ? cursor.position() : cursor.anchor(), - QTextCursor::MoveAnchor); - } - - if (!forward) - options |= QTextDocument::FindBackward; - - if (findWidget->caseSensitive()) - options |= QTextDocument::FindCaseSensitively; - - findWidget->setTextWrappedVisible(false); - - bool found = true; - QTextCursor newCursor = doc->find(ttf, cursor, options); - if (newCursor.isNull()) { - QTextCursor ac(doc); - ac.movePosition(options & QTextDocument::FindBackward - ? QTextCursor::End : QTextCursor::Start); - newCursor = doc->find(ttf, ac, options); - if (newCursor.isNull()) { - found = false; - newCursor = cursor; - } else { - findWidget->setTextWrappedVisible(true); - } - } - browser->setTextCursor(newCursor); - return found; + m_findWidget->show(); } void CentralWidget::updateBrowserFont() { TRACE_OBJ - const bool searchAttached = searchWidgetAttached(); - if (searchAttached) { - HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - m_searchWidget->setFont(helpEngine.usesBrowserFont() - ? helpEngine.browserFont() : qApp->font()); - } - - const int count = tabWidget->count(); - if (HelpViewer* viewer = viewerAt(count - 1)) { - const QFont &font = viewer->viewerFont(); - for (int i = searchAttached ? 1 : 0; i < count; ++i) - viewerAt(i)->setViewerFont(font); - } -} - -bool CentralWidget::searchWidgetAttached() const -{ - TRACE_OBJ - return m_searchWidget && m_searchWidget->isAttached(); + const int count = m_stackedWidget->count(); + const QFont &font = viewerAt(count - 1)->viewerFont(); + for (int i = 0; i < count; ++i) + viewerAt(i)->setViewerFont(font); } -void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) +void CentralWidget::updateUserInterface() { - TRACE_OBJ - if (m_searchWidget) - return; - - m_searchWidget = new SearchWidget(searchEngine, this); - connect(m_searchWidget, SIGNAL(requestShowLink(QUrl)), this, - SLOT(setSourceFromSearch(QUrl))); - connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this, - SLOT(setSourceFromSearchInNewTab(QUrl))); - - HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - m_searchWidget->setFont(!helpEngine.usesBrowserFont() ? qApp->font() - : helpEngine.browserFont()); + m_tabBar->setVisible(HelpEngineWrapper::instance().showTabs()); } -void CentralWidget::activateSearchWidget(bool updateLastTabPage) -{ - TRACE_OBJ - if (!m_searchWidget) - createSearchWidget(HelpEngineWrapper::instance().searchEngine()); - - if (!m_searchWidget->isAttached()) { - tabWidget->insertTab(0, m_searchWidget, tr("Search")); - m_searchWidget->setAttached(true); +// -- protected - if (updateLastTabPage) - lastTabPage++; - } - - tabWidget->setCurrentWidget(m_searchWidget); - m_searchWidget->setFocus(); -} - -void CentralWidget::removeSearchWidget() +void CentralWidget::keyPressEvent(QKeyEvent *e) { TRACE_OBJ - if (searchWidgetAttached()) { - tabWidget->removeTab(0); - m_searchWidget->setAttached(false); + const QString &text = e->text(); + if (text.startsWith(QLatin1Char('/'))) { + if (!m_findWidget->isVisible()) { + m_findWidget->showAndClear(); + } else { + m_findWidget->show(); + } + } else { + QWidget::keyPressEvent(e); } } -int CentralWidget::availableHelpViewer() const -{ - TRACE_OBJ - int count = tabWidget->count(); - if (searchWidgetAttached()) - count--; - return count; -} - -bool CentralWidget::enableTabCloseAction() const -{ - TRACE_OBJ - int minTabCount = 1; - if (searchWidgetAttached()) - minTabCount = 2; - - return (tabWidget->count() > minTabCount); -} - -QString CentralWidget::quoteTabTitle(const QString &title) const -{ - TRACE_OBJ - QString s = title; - return s.replace(QLatin1Char('&'), QLatin1String("&&")); -} - -void -CentralWidget::setSourceFromSearch(const QUrl &url) +void CentralWidget::focusInEvent(QFocusEvent * /* event */) { TRACE_OBJ - setSource(url); -#if defined(QT_NO_WEBKIT) - highlightSearchTerms(); -#else - connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, - SLOT(highlightSearchTerms())); -#endif + // If we have a current help viewer then this is the 'focus proxy', + // otherwise it's the central widget. This is needed, so an embedding + // program can just set the focus to the central widget and it does + // The Right Thing(TM) + QObject *receiver = m_stackedWidget; + if (HelpViewer *viewer = currentHelpViewer()) + receiver = viewer; + QTimer::singleShot(1, receiver, SLOT(setFocus())); } -void -CentralWidget::setSourceFromSearchInNewTab(const QUrl &url) -{ - TRACE_OBJ - setSourceInNewTab(url); -#if defined(QT_NO_WEBKIT) - highlightSearchTerms(); -#else - connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, - SLOT(highlightSearchTerms())); -#endif -} +// -- private slots -void -CentralWidget::highlightSearchTerms() +void CentralWidget::highlightSearchTerms() { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (!viewer) - return; - QHelpSearchEngine *searchEngine = HelpEngineWrapper::instance().searchEngine(); QList<QHelpSearchQuery> queryList = searchEngine->query(); @@ -1016,91 +564,73 @@ CentralWidget::highlightSearchTerms() } } -#if defined(QT_NO_WEBKIT) - viewer->viewport()->setUpdatesEnabled(false); - - QTextCharFormat marker; - marker.setForeground(Qt::red); - - QTextCursor firstHit; - - QTextCursor c = viewer->textCursor(); - c.beginEditBlock(); - foreach (const QString& term, terms) { - c.movePosition(QTextCursor::Start); - viewer->setTextCursor(c); - - while (viewer->find(term, QTextDocument::FindWholeWords)) { - QTextCursor hit = viewer->textCursor(); - if (firstHit.isNull() || hit.position() < firstHit.position()) - firstHit = hit; - - hit.mergeCharFormat(marker); - } - } - - if (firstHit.isNull()) { - firstHit = viewer->textCursor(); - firstHit.movePosition(QTextCursor::Start); - } - firstHit.clearSelection(); - c.endEditBlock(); - viewer->setTextCursor(firstHit); - - viewer->viewport()->setUpdatesEnabled(true); -#else - viewer->findText("", QWebPage::HighlightAllOccurrences); - // clears existing selections + HelpViewer *viewer = currentHelpViewer(); foreach (const QString& term, terms) - viewer->findText(term, QWebPage::HighlightAllOccurrences); - + viewer->findText(term, 0, false, true); disconnect(viewer, SIGNAL(loadFinished(bool)), this, SLOT(highlightSearchTerms())); +} + +void CentralWidget::printPreview(QPrinter *p) +{ + TRACE_OBJ +#ifndef QT_NO_PRINTER + currentHelpViewer()->print(p); #endif } +void CentralWidget::handleSourceChanged(const QUrl &url) +{ + TRACE_OBJ + if (sender() == currentHelpViewer()) + emit sourceChanged(url); +} -void CentralWidget::closeOrReloadTabs(const QList<int> &indices, bool tryReload) +// -- private + +void CentralWidget::initPrinter() { TRACE_OBJ - QList<int> sortedIndices = indices; - qSort(sortedIndices); - for (int i = sortedIndices.count(); --i >= 0;) { - const int tab = sortedIndices.at(i); - bool close = true; - if (tryReload) { - HelpViewer *viewer = - qobject_cast<HelpViewer*>(tabWidget->widget(tab)); - if (HelpEngineWrapper::instance().findFile(viewer->source()).isValid()) { - viewer->reload(); - close = false; - } - } - if (close) - closeTabAt(tab); - } - if (availableHelpViewer() == 0) - setSource(QUrl(QLatin1String("about:blank"))); +#ifndef QT_NO_PRINTER + if (!m_printer) + m_printer = new QPrinter(QPrinter::HighResolution); +#endif } -void CentralWidget::closeTabAt(int index) +void CentralWidget::connectSignals(HelpViewer *page) { TRACE_OBJ - HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(index)); - tabWidget->removeTab(index); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); + connect(page, SIGNAL(copyAvailable(bool)), this, + SIGNAL(copyAvailable(bool))); + connect(page, SIGNAL(forwardAvailable(bool)), this, + SIGNAL(forwardAvailable(bool))); + connect(page, SIGNAL(backwardAvailable(bool)), this, + SIGNAL(backwardAvailable(bool))); + connect(page, SIGNAL(sourceChanged(QUrl)), this, + SLOT(handleSourceChanged(QUrl))); + connect(page, SIGNAL(highlighted(QString)), this, + SIGNAL(highlighted(QString))); + connect(page, SIGNAL(printRequested()), this, SLOT(print())); } -QMap<int, QString> CentralWidget::currentSourceFileList() const +bool CentralWidget::eventFilter(QObject *object, QEvent *e) { TRACE_OBJ - QMap<int, QString> sourceList; - for (int i = 0; i < tabWidget->count(); ++i) { - HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i)); - if (viewer && viewer->source().isValid()) - sourceList.insert(i, viewer->source().host()); + if (e->type() != QEvent::KeyPress) + return QWidget::eventFilter(object, e); + + HelpViewer *viewer = currentHelpViewer(); + QKeyEvent *keyEvent = static_cast<QKeyEvent*> (e); + if (viewer == object && keyEvent->key() == Qt::Key_Backspace) { + if (viewer->isBackwardAvailable()) { +#if !defined(QT_NO_WEBKIT) + // this helps in case there is an html <input> field + if (!viewer->hasFocus()) +#endif + viewer->backward(); + } } - return sourceList; + return QWidget::eventFilter(object, e); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 53d0607..2645fa8 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -38,80 +38,102 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef CENTRALWIDGET_H #define CENTRALWIDGET_H #include <QtCore/QUrl> + +#include <QtGui/QTabBar> #include <QtGui/QWidget> QT_BEGIN_NAMESPACE class FindWidget; class HelpViewer; -class MainWindow; -class QHelpSearchEngine; -class QTabWidget; -class SearchWidget; +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 public: - CentralWidget(MainWindow *parent); + CentralWidget(QWidget *parent = 0); ~CentralWidget(); - void setupWidget(); - bool hasSelection() const; + static CentralWidget *instance(); + QUrl currentSource() const; QString currentTitle() const; - bool isHomeAvailable() const; + + bool hasSelection() const; bool isForwardAvailable() const; bool isBackwardAvailable() const; - QList<QAction*> globalActions() const; - void setGlobalActions(const QList<QAction*> &actions); HelpViewer *viewerAt(int index) const; HelpViewer *currentHelpViewer() const; - bool searchWidgetAttached() const; - void createSearchWidget(QHelpSearchEngine *searchEngine); - void activateSearchWidget(bool updateLastTabPage = false); - void removeSearchWidget(); - - int availableHelpViewer() const; - bool enableTabCloseAction() const; + void addPage(HelpViewer *page, bool fromSearch = false); + void removePage(int index); - void closeOrReloadTabs(const QList<int> &indices, bool tryReload); - void closeTabAt(int index); - QMap<int, QString> currentSourceFileList() const; + int currentIndex() const; + void setCurrentPage(HelpViewer *page); - static CentralWidget *instance(); + void connectTabBar(); public slots: + void copy(); + void home(); + void zoomIn(); void zoomOut(); - void nextPage(); void resetZoom(); + + void forward(); + void nextPage(); + + void backward(); void previousPage(); - void copySelection(); - void showTextSearch(); + void print(); void pageSetup(); void printPreview(); - void updateBrowserFont(); - void setSource(const QUrl &url); - void setSourceInNewTab(const QUrl &url, qreal zoom = 0.0); - HelpViewer *newEmptyTab(); - void home(); - void forward(); - void backward(); - void activateTab(bool onlyHelpViewer = false); + void setSource(const QUrl &url); + void setSourceFromSearch(const QUrl &url); void findNext(); void findPrevious(); - void find(const QString &text, bool forward); + void find(const QString &text, bool forward, bool incremental); + + void activateTab(); + void showTextSearch(); + void updateBrowserFont(); + void updateUserInterface(); signals: void currentViewerChanged(); @@ -124,37 +146,25 @@ signals: protected: void keyPressEvent(QKeyEvent *); + void focusInEvent(QFocusEvent *event); private slots: - void newTab(); - void closeTab(); - void setTabTitle(const QUrl& url); - void currentPageChanged(int index); - void showTabBarContextMenu(const QPoint &point); - void printPreview(QPrinter *printer); - void setSourceFromSearch(const QUrl &url); - void setSourceFromSearchInNewTab(const QUrl &url); void highlightSearchTerms(); + void printPreview(QPrinter *printer); + void handleSourceChanged(const QUrl &url); private: - void connectSignals(); - bool eventFilter(QObject *object, QEvent *e); - bool findInWebPage(const QString &ttf, bool forward); - bool findInTextBrowser(const QString &ttf, bool forward); void initPrinter(); - QString quoteTabTitle(const QString &title) const; - void setLastShownPages(); + void connectSignals(HelpViewer *page); + bool eventFilter(QObject *object, QEvent *e); private: - int lastTabPage; - QList<QAction*> globalActionList; - - QTabWidget *tabWidget; - FindWidget *findWidget; - QPrinter *printer; - bool usesDefaultCollection; - - SearchWidget *m_searchWidget; +#ifndef QT_NO_PRINTER + QPrinter *m_printer; +#endif + FindWidget *m_findWidget; + QStackedWidget *m_stackedWidget; + TabBar *m_tabBar; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index 84b76e0..fbf70aa 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -38,12 +38,14 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" #include "contentwindow.h" + #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" +#include "openpagesmanager.h" +#include "tracer.h" #include <QtGui/QLayout> #include <QtGui/QFocusEvent> @@ -146,8 +148,8 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e) qobject_cast<QHelpContentModel*>(m_contentWidget->model()); if (contentModel) { QHelpContentItem *itm = contentModel->contentItemAt(index); - if (itm && AbstractHelpViewer::canOpenPage(itm->url().path())) - CentralWidget::instance()->setSourceInNewTab(itm->url()); + if (itm && HelpViewer::canOpenPage(itm->url().path())) + OpenPagesManager::instance()->createPage(itm->url()); } } else if (button == Qt::LeftButton) { itemClicked(index); @@ -172,7 +174,7 @@ void ContentWindow::showContextMenu(const QPoint &pos) QMenu menu; QAction *curTab = menu.addAction(tr("Open Link")); QAction *newTab = menu.addAction(tr("Open Link in New Tab")); - if (!AbstractHelpViewer::canOpenPage(itm->url().path())) + if (!HelpViewer::canOpenPage(itm->url().path())) newTab->setEnabled(false); menu.move(m_contentWidget->mapToGlobal(pos)); @@ -181,7 +183,7 @@ void ContentWindow::showContextMenu(const QPoint &pos) if (curTab == action) emit linkActivated(itm->url()); else if (newTab == action) - CentralWidget::instance()->setSourceInNewTab(itm->url()); + OpenPagesManager::instance()->createPage(itm->url()); } void ContentWindow::itemClicked(const QModelIndex &index) diff --git a/tools/assistant/tools/assistant/contentwindow.h b/tools/assistant/tools/assistant/contentwindow.h index 56d69e9..b8bdc8f 100644 --- a/tools/assistant/tools/assistant/contentwindow.h +++ b/tools/assistant/tools/assistant/contentwindow.h @@ -76,7 +76,6 @@ private: void focusInEvent(QFocusEvent *e); void keyPressEvent(QKeyEvent *e); bool eventFilter(QObject *o, QEvent *e); - bool isPdfFile(QHelpContentItem *item) const; QHelpContentWidget * const m_contentWidget; int m_expandDepth; diff --git a/tools/assistant/tools/assistant/doc/assistant.qdocconf b/tools/assistant/tools/assistant/doc/assistant.qdocconf index 45ad76a..4bd3842 100644 --- a/tools/assistant/tools/assistant/doc/assistant.qdocconf +++ b/tools/assistant/tools/assistant/doc/assistant.qdocconf @@ -12,5 +12,5 @@ HTML.footer = "<p /><address><hr /><div align=\"center\">\n" \ "<table width=\"100%\" cellspacing=\"0\" border=\"0\"><tr class=\"address\">\n" \ "<td width=\"30%\" align=\"left\">Copyright © 2011 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \ "<td width=\"40%\" align=\"center\">Trademarks</td>\n" \ - "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt 4.7.4</div></td>\n" \ + "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt 4.8.0</div></td>\n" \ "</tr></table></div></address>" diff --git a/tools/assistant/tools/assistant/findwidget.cpp b/tools/assistant/tools/assistant/findwidget.cpp index f2fc32d..d45ed30 100644 --- a/tools/assistant/tools/assistant/findwidget.cpp +++ b/tools/assistant/tools/assistant/findwidget.cpp @@ -203,7 +203,7 @@ void FindWidget::updateButtons() void FindWidget::textChanged(const QString &text) { TRACE_OBJ - emit find(text, true); + emit find(text, true, true); } bool FindWidget::eventFilter(QObject *object, QEvent *e) diff --git a/tools/assistant/tools/assistant/findwidget.h b/tools/assistant/tools/assistant/findwidget.h index 8449657..d3be0f5 100644 --- a/tools/assistant/tools/assistant/findwidget.h +++ b/tools/assistant/tools/assistant/findwidget.h @@ -67,11 +67,10 @@ public: void setTextWrappedVisible(bool visible); signals: - void escapePressed(); - void findNext(); void findPrevious(); - void find(const QString &text, bool forward); + void escapePressed(); + void find(const QString &text, bool forward, bool incremental); protected: void hideEvent(QHideEvent* event); diff --git a/tools/assistant/tools/assistant/globalactions.cpp b/tools/assistant/tools/assistant/globalactions.cpp new file mode 100644 index 0000000..7fc59eb --- /dev/null +++ b/tools/assistant/tools/assistant/globalactions.cpp @@ -0,0 +1,246 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "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) +{ + Q_ASSERT(!m_instance != !parent); + if (!m_instance) + m_instance = new GlobalActions(parent); + return m_instance; +} + +GlobalActions::GlobalActions(QObject *parent) : QObject(parent) +{ + TRACE_OBJ + + // TODO: Put resource path in misc class + QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); +#ifdef Q_OS_MAC + resourcePath.append(QLatin1String("mac")); +#else + resourcePath.append(QLatin1String("win")); +#endif + CentralWidget *centralWidget = CentralWidget::instance(); + + m_backAction = new QAction(tr("&Back"), parent); + m_backAction->setEnabled(false); + m_backAction->setShortcuts(QKeySequence::Back); + m_backAction->setIcon(QIcon(resourcePath + QLatin1String("/previous.png"))); + connect(m_backAction, SIGNAL(triggered()), centralWidget, SLOT(backward())); + m_actionList << m_backAction; + + m_nextAction = new QAction(tr("&Forward"), parent); + m_nextAction->setPriority(QAction::LowPriority); + m_nextAction->setEnabled(false); + m_nextAction->setShortcuts(QKeySequence::Forward); + m_nextAction->setIcon(QIcon(resourcePath + QLatin1String("/next.png"))); + 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"))); + connect(m_homeAction, SIGNAL(triggered()), centralWidget, SLOT(home())); + m_actionList << m_homeAction; + + QAction *separator = new QAction(parent); + separator->setSeparator(true); + m_actionList << separator; + + m_zoomInAction = new QAction(tr("Zoom &in"), parent); + m_zoomInAction->setPriority(QAction::LowPriority); + m_zoomInAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomin.png"))); + m_zoomInAction->setShortcut(QKeySequence::ZoomIn); + connect(m_zoomInAction, SIGNAL(triggered()), centralWidget, SLOT(zoomIn())); + m_actionList << m_zoomInAction; + + m_zoomOutAction = new QAction(tr("Zoom &out"), parent); + m_zoomOutAction->setPriority(QAction::LowPriority); + m_zoomOutAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomout.png"))); + m_zoomOutAction->setShortcut(QKeySequence::ZoomOut); + connect(m_zoomOutAction, SIGNAL(triggered()), centralWidget, SLOT(zoomOut())); + m_actionList << m_zoomOutAction; + + separator = new QAction(parent); + separator->setSeparator(true); + m_actionList << separator; + + m_copyAction = new QAction(tr("&Copy selected Text"), parent); + m_copyAction->setPriority(QAction::LowPriority); + m_copyAction->setIconText("&Copy"); + m_copyAction->setIcon(QIcon(resourcePath + QLatin1String("/editcopy.png"))); + m_copyAction->setShortcuts(QKeySequence::Copy); + m_copyAction->setEnabled(false); + connect(m_copyAction, SIGNAL(triggered()), centralWidget, SLOT(copy())); + m_actionList << m_copyAction; + + m_printAction = new QAction(tr("&Print..."), parent); + m_printAction->setPriority(QAction::LowPriority); + m_printAction->setIcon(QIcon(resourcePath + QLatin1String("/print.png"))); + m_printAction->setShortcut(QKeySequence::Print); + connect(m_printAction, SIGNAL(triggered()), centralWidget, SLOT(print())); + m_actionList << m_printAction; + + m_findAction = new QAction(tr("&Find in Text..."), parent); + m_findAction->setIconText(tr("&Find")); + m_findAction->setIcon(QIcon(resourcePath + QLatin1String("/find.png"))); + m_findAction->setShortcuts(QKeySequence::Find); + connect(m_findAction, SIGNAL(triggered()), centralWidget, SLOT(showTextSearch())); + m_actionList << m_findAction; + +#ifdef Q_WS_X11 + m_backAction->setIcon(QIcon::fromTheme("go-previous" , m_backAction->icon())); + m_nextAction->setIcon(QIcon::fromTheme("go-next" , m_nextAction->icon())); + m_zoomInAction->setIcon(QIcon::fromTheme("zoom-in" , m_zoomInAction->icon())); + m_zoomOutAction->setIcon(QIcon::fromTheme("zoom-out" , m_zoomOutAction->icon())); + m_copyAction->setIcon(QIcon::fromTheme("edit-copy" , m_copyAction->icon())); + m_findAction->setIcon(QIcon::fromTheme("edit-find" , m_findAction->icon())); + m_homeAction->setIcon(QIcon::fromTheme("go-home" , m_homeAction->icon())); + m_printAction->setIcon(QIcon::fromTheme("document-print" , m_printAction->icon())); +#endif +} + +void GlobalActions::updateActions() +{ + TRACE_OBJ + CentralWidget *centralWidget = CentralWidget::instance(); + m_copyAction->setEnabled(centralWidget->hasSelection()); + m_nextAction->setEnabled(centralWidget->isForwardAvailable()); + m_backAction->setEnabled(centralWidget->isBackwardAvailable()); +} + +void GlobalActions::setCopyAvailable(bool available) +{ + TRACE_OBJ + 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 new file mode 100644 index 0000000..a9059a9 --- /dev/null +++ b/tools/assistant/tools/assistant/globalactions.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 GLOBALACTION_H +#define GLOBALACTION_H + +#include <QtCore/QList> +#include <QtCore/QObject> + +QT_BEGIN_NAMESPACE + +class QAction; +class QMenu; + +class GlobalActions : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(GlobalActions) +public: + static GlobalActions *instance(QObject *parent = 0); + + QList<QAction *> actionList() const { return m_actionList; } + QAction *backAction() const { return m_backAction; } + QAction *nextAction() const { return m_nextAction; } + QAction *homeAction() const { return m_homeAction; } + QAction *zoomInAction() const { return m_zoomInAction; } + QAction *zoomOutAction() const { return m_zoomOutAction; } + QAction *copyAction() const { return m_copyAction; } + QAction *printAction() const { return m_printAction; } + QAction *findAction() const { return m_findAction; } + + 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); + + static GlobalActions *m_instance; + + QAction *m_backAction; + QAction *m_nextAction; + QAction *m_homeAction; + QAction *m_zoomInAction; + QAction *m_zoomOutAction; + QAction *m_copyAction; + QAction *m_printAction; + QAction *m_findAction; + + QList<QAction *> m_actionList; + + QMenu *m_backMenu; + QMenu *m_nextMenu; +}; + +QT_END_NAMESPACE + +#endif // GLOBALACTION_H diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index c692158..4c7ff5b 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 @@ -147,7 +148,7 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile) * because we will start to index them, only to be interrupted * 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()), @@ -569,18 +570,6 @@ void HelpEngineWrapper::setLastTabPage(int lastPage) CollectionConfiguration::setLastTabPage(*d->m_helpEngine, lastPage); } -bool HelpEngineWrapper::searchWasAttached() const -{ - TRACE_OBJ - return d->m_helpEngine->customValue(SearchWasAttachedKey).toBool(); -} - -void HelpEngineWrapper::setSearchWasAttached(bool attached) -{ - TRACE_OBJ - d->m_helpEngine->setCustomValue(SearchWasAttachedKey, attached); -} - int HelpEngineWrapper::startOption() const { TRACE_OBJ @@ -655,7 +644,7 @@ void HelpEngineWrapper::setUseBrowserFont(bool useBrowserFont) const QFont HelpEngineWrapper::appFont() const { TRACE_OBJ - return qVariantValue<QFont>(d->m_helpEngine->customValue(AppFontKey)); + return qvariant_cast<QFont>(d->m_helpEngine->customValue(AppFontKey)); } void HelpEngineWrapper::setAppFont(const QFont &font) @@ -680,7 +669,7 @@ void HelpEngineWrapper::setAppWritingSystem(QFontDatabase::WritingSystem system) const QFont HelpEngineWrapper::browserFont() const { TRACE_OBJ - return qVariantValue<QFont>(d->m_helpEngine->customValue(BrowserFontKey)); + return qvariant_cast<QFont>(d->m_helpEngine->customValue(BrowserFontKey)); } void HelpEngineWrapper::setBrowserFont(const QFont &font) @@ -704,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) @@ -722,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)), @@ -829,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 e94f96a..ff825b0 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.h +++ b/tools/assistant/tools/assistant/helpenginewrapper.h @@ -170,9 +170,6 @@ public: int startOption() const; void setStartOption(int option); - bool searchWasAttached() const; - void setSearchWasAttached(bool attached); - bool hasFontSettings() const; bool usesAppFont() const; void setUseAppFont(bool useAppFont); @@ -187,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.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index fb520e9..7bed496 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -38,7 +38,10 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "helpviewer.h" +#include "helpviewer_p.h" + #include "helpenginewrapper.h" #include "tracer.h" @@ -49,18 +52,21 @@ #include <QtCore/QUrl> #include <QtGui/QDesktopServices> +#include <QtGui/QMouseEvent> + +#include <QtHelp/QHelpEngineCore> QT_BEGIN_NAMESPACE -const QLatin1String AbstractHelpViewer::DocPath("qthelp://com.trolltech."); +const QString HelpViewer::DocPath = QLatin1String("qthelp://com.trolltech."); -const QString AbstractHelpViewer::AboutBlank = +const QString HelpViewer::AboutBlank = QCoreApplication::translate("HelpViewer", "<title>about:blank</title>"); -const QString AbstractHelpViewer::LocalHelpFile = QLatin1String("qthelp://" +const QString HelpViewer::LocalHelpFile = QLatin1String("qthelp://" "com.trolltech.com.assistantinternal-1.0.0/assistant/assistant.html"); -const QString AbstractHelpViewer::PageNotFoundMessage = +const QString HelpViewer::PageNotFoundMessage = QCoreApplication::translate("HelpViewer", "<title>Error 404...</title><div " "align=\"center\"><br><br><h1>The page could not be found</h1><br><h3>'%1'" "</h3></div>"); @@ -102,17 +108,13 @@ struct ExtensionMap { { 0, 0 } }; -// -- AbstractHelpViewer - -AbstractHelpViewer::AbstractHelpViewer() -{ -} - -AbstractHelpViewer::~AbstractHelpViewer() +HelpViewer::~HelpViewer() { + TRACE_OBJ + delete d; } -bool AbstractHelpViewer::isLocalUrl(const QUrl &url) +bool HelpViewer::isLocalUrl(const QUrl &url) { TRACE_OBJ const QString &scheme = url.scheme(); @@ -124,13 +126,13 @@ bool AbstractHelpViewer::isLocalUrl(const QUrl &url) || scheme == QLatin1String("about"); } -bool AbstractHelpViewer::canOpenPage(const QString &url) +bool HelpViewer::canOpenPage(const QString &url) { TRACE_OBJ return !mimeFromUrl(url).isEmpty(); } -QString AbstractHelpViewer::mimeFromUrl(const QUrl &url) +QString HelpViewer::mimeFromUrl(const QUrl &url) { TRACE_OBJ const QString &path = url.path(); @@ -146,7 +148,7 @@ QString AbstractHelpViewer::mimeFromUrl(const QUrl &url) return QLatin1String(""); } -bool AbstractHelpViewer::launchWithExternalApp(const QUrl &url) +bool HelpViewer::launchWithExternalApp(const QUrl &url) { TRACE_OBJ if (isLocalUrl(url)) { @@ -177,4 +179,43 @@ bool AbstractHelpViewer::launchWithExternalApp(const QUrl &url) return false; } +// -- public slots + +void HelpViewer::home() +{ + TRACE_OBJ + setSource(HelpEngineWrapper::instance().homePage()); +} + +// -- private slots + +void HelpViewer::setLoadStarted() +{ + d->m_loadFinished = false; +} + +void HelpViewer::setLoadFinished(bool ok) +{ + d->m_loadFinished = ok; + emit sourceChanged(source()); +} + +// -- private + +bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *event) +{ + TRACE_OBJ + if (event->button() == Qt::XButton1) { + backward(); + return true; + } + + if (event->button() == Qt::XButton2) { + forward(); + return true; + } + + return false; +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index 29376d5..bba01d0 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -38,36 +38,69 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef HELPVIEWER_H #define HELPVIEWER_H +#include <QtCore/qglobal.h> #include <QtCore/QString> +#include <QtCore/QUrl> +#include <QtCore/QVariant> +#include <QtGui/QAction> #include <QtGui/QFont> -QT_BEGIN_NAMESPACE +#if defined(QT_NO_WEBKIT) +#include <QtGui/QTextBrowser> +#else +#include <QtWebKit/QWebView> +#endif -class QMouseEvent; -class QUrl; +QT_BEGIN_NAMESPACE -class AbstractHelpViewer +#if !defined(QT_NO_WEBKIT) +class HelpViewer : public QWebView +#else +class HelpViewer : public QTextBrowser +#endif { + Q_OBJECT + class HelpViewerPrivate; + Q_DISABLE_COPY(HelpViewer) + public: - AbstractHelpViewer(); - virtual ~AbstractHelpViewer(); + enum FindFlag { + FindBackward = 0x01, + FindCaseSensitively = 0x02 + }; + Q_DECLARE_FLAGS(FindFlags, FindFlag) + + HelpViewer(qreal zoom, QWidget *parent = 0); + ~HelpViewer(); + + QFont viewerFont() const; + void setViewerFont(const QFont &font); + + void scaleUp(); + void scaleDown(); + + void resetScale(); + qreal scale() const; - virtual QFont viewerFont() const = 0; - virtual void setViewerFont(const QFont &font) = 0; + QString title() const; + void setTitle(const QString &title); - virtual void scaleUp() = 0; - virtual void scaleDown() = 0; - - virtual void resetScale() = 0; - virtual qreal scale() const = 0; + QUrl source() const; + void setSource(const QUrl &url); - virtual bool handleForwardBackwardMouseButtons(QMouseEvent *e) = 0; + QString selectedText() const; + bool isForwardAvailable() const; + bool isBackwardAvailable() const; - static const QLatin1String DocPath; + bool findText(const QString &text, FindFlags flags, bool incremental, + bool fromSearch); + + static const QString DocPath; static const QString AboutBlank; static const QString LocalHelpFile; static const QString PageNotFoundMessage; @@ -76,8 +109,50 @@ public: static bool canOpenPage(const QString &url); static QString mimeFromUrl(const QUrl &url); static bool launchWithExternalApp(const QUrl &url); + +public slots: + void copy(); + void home(); + + void forward(); + void backward(); + +signals: + void titleChanged(); +#if !defined(QT_NO_WEBKIT) + void copyAvailable(bool yes); + void sourceChanged(const QUrl &url); + void forwardAvailable(bool enabled); + void backwardAvailable(bool enabled); + void highlighted(const QString &link); + void printRequested(); +#else + void loadStarted(); + void loadFinished(bool finished); +#endif + +protected: + void keyPressEvent(QKeyEvent *e); + void wheelEvent(QWheelEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + +private slots: + void actionChanged(); + void setLoadStarted(); + void setLoadFinished(bool ok); + +private: + bool eventFilter(QObject *obj, QEvent *event); + void contextMenuEvent(QContextMenuEvent *event); + QVariant loadResource(int type, const QUrl &name); + bool handleForwardBackwardMouseButtons(QMouseEvent *e); + +private: + HelpViewerPrivate *d; }; QT_END_NAMESPACE +Q_DECLARE_METATYPE(HelpViewer*) #endif // HELPVIEWER_H diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.h b/tools/assistant/tools/assistant/helpviewer_p.h index efb75b1..3788711 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.h +++ b/tools/assistant/tools/assistant/helpviewer_p.h @@ -38,76 +38,86 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef HELPVIEWERQTB_H -#define HELPVIEWERQTB_H -#include "helpviewer.h" +#ifndef HELPVIEWERPRIVATE_H +#define HELPVIEWERPRIVATE_H -#include <QtCore/QUrl> -#include <QtCore/QVariant> +#include "centralwidget.h" +#include "helpviewer.h" +#include "openpagesmanager.h" +#include <QtCore/QObject> +#ifdef QT_NO_WEBKIT #include <QtGui/QTextBrowser> +#endif QT_BEGIN_NAMESPACE -class CentralWidget; -class HelpEngineWrapper; -class QContextMenuEvent; -class QKeyEvent; -class QMouseEvent; - -class HelpViewer : public QTextBrowser, public AbstractHelpViewer +class HelpViewer::HelpViewerPrivate : public QObject { Q_OBJECT public: - explicit HelpViewer(CentralWidget *parent, qreal zoom = 0.0); - ~HelpViewer(); - - QFont viewerFont() const; - void setViewerFont(const QFont &font); - - void scaleUp(); - void scaleDown(); - void resetScale(); - qreal scale() const { return zoomCount; } - - bool handleForwardBackwardMouseButtons(QMouseEvent *e); - - void setSource(const QUrl &url); - - inline bool hasSelection() const - { return textCursor().hasSelection(); } +#ifdef QT_NO_WEBKIT + HelpViewerPrivate(int zoom) + : zoomCount(zoom) + , forceFont(false) + , lastAnchor(QString()) +#else + HelpViewerPrivate() +#endif + { + m_loadFinished = false; + } + +#ifdef QT_NO_WEBKIT + bool hasAnchorAt(QTextBrowser *browser, const QPoint& pos) + { + lastAnchor = browser->anchorAt(pos); + if (lastAnchor.isEmpty()) + return false; + + lastAnchor = browser->source().resolved(lastAnchor).toString(); + if (lastAnchor.at(0) == QLatin1Char('#')) { + QString src = browser->source().toString(); + int hsh = src.indexOf(QLatin1Char('#')); + lastAnchor = (hsh >= 0 ? src.left(hsh) : src) + lastAnchor; + } + return true; + } + + void openLink(bool newPage) + { + if(lastAnchor.isEmpty()) + return; + if (newPage) + OpenPagesManager::instance()->createPage(lastAnchor); + else + CentralWidget::instance()->setSource(lastAnchor); + lastAnchor.clear(); + } + +public slots: + void openLink() + { + openLink(false); + } + + void openLinkInNewPage() + { + openLink(true); + } -public Q_SLOTS: - void home(); - -protected: - void wheelEvent(QWheelEvent *e); - bool eventFilter(QObject *obj, QEvent *event); - -private: - QVariant loadResource(int type, const QUrl &name); - void openLinkInNewTab(const QString &link); - bool hasAnchorAt(const QPoint& pos); - void contextMenuEvent(QContextMenuEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void keyPressEvent(QKeyEvent *e); - void mousePressEvent(QMouseEvent *e); - -private slots: - void openLinkInNewTab(); - -private: +public: int zoomCount; - bool controlPressed; + bool forceFont; QString lastAnchor; - CentralWidget* parentWidget; - HelpEngineWrapper &helpEngine; +#endif // QT_NO_WEBKIT - bool forceFont; +public: + bool m_loadFinished; }; QT_END_NAMESPACE -#endif // HELPVIEWERQTB_H +#endif // HELPVIEWERPRIVATE_H diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp index 69f4192..0a6325c 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -38,10 +38,13 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "helpviewer_qtb.h" -#include "centralwidget.h" +#include "helpviewer.h" + +#include "globalactions.h" #include "helpenginewrapper.h" +#include "helpviewer_p.h" +#include "openpagesmanager.h" #include "tracer.h" #include <QtCore/QStringBuilder> @@ -53,34 +56,34 @@ QT_BEGIN_NAMESPACE -HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) +HelpViewer::HelpViewer(qreal zoom, QWidget *parent) : QTextBrowser(parent) - , zoomCount(zoom) - , controlPressed(false) - , lastAnchor(QString()) - , parentWidget(parent) - , helpEngine(HelpEngineWrapper::instance()) - , forceFont(false) + , d(new HelpViewerPrivate(zoom)) { TRACE_OBJ + QPalette p = palette(); + p.setColor(QPalette::Inactive, QPalette::Highlight, + p.color(QPalette::Active, QPalette::Highlight)); + p.setColor(QPalette::Inactive, QPalette::HighlightedText, + p.color(QPalette::Active, QPalette::HighlightedText)); + setPalette(p); + installEventFilter(this); document()->setDocumentMargin(8); QFont font = viewerFont(); font.setPointSize(int(font.pointSize() + zoom)); setViewerFont(font); -} -HelpViewer::~HelpViewer() -{ - TRACE_OBJ + connect(this, SIGNAL(sourceChanged(QUrl)), this, SIGNAL(titleChanged())); + connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); } QFont HelpViewer::viewerFont() const { TRACE_OBJ if (HelpEngineWrapper::instance().usesBrowserFont()) - return helpEngine.browserFont(); + return HelpEngineWrapper::instance().browserFont(); return qApp->font(); } @@ -88,185 +91,183 @@ void HelpViewer::setViewerFont(const QFont &newFont) { TRACE_OBJ if (font() != newFont) { - forceFont = true; + d->forceFont = true; setFont(newFont); - forceFont = false; + d->forceFont = false; } } void HelpViewer::scaleUp() { TRACE_OBJ - if (zoomCount < 10) { - ++zoomCount; - forceFont = true; + if (d->zoomCount < 10) { + d->zoomCount++; + d->forceFont = true; zoomIn(); - forceFont = false; + d->forceFont = false; } } void HelpViewer::scaleDown() { TRACE_OBJ - if (zoomCount > -5) { - --zoomCount; - forceFont = true; + if (d->zoomCount > -5) { + d->zoomCount--; + d->forceFont = true; zoomOut(); - forceFont = false; + d->forceFont = false; } } void HelpViewer::resetScale() { TRACE_OBJ - if (zoomCount != 0) { - forceFont = true; - zoomOut(zoomCount); - forceFont = false; + if (d->zoomCount != 0) { + d->forceFont = true; + zoomOut(d->zoomCount); + d->forceFont = false; } - zoomCount = 0; + d->zoomCount = 0; } -bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e) +qreal HelpViewer::scale() const { - if (e->button() == Qt::XButton1) { - QTextBrowser::backward(); - return true; - } + TRACE_OBJ + return d->zoomCount; +} - if (e->button() == Qt::XButton2) { - QTextBrowser::forward(); - return true; - } - return false; +QString HelpViewer::title() const +{ + TRACE_OBJ + return documentTitle(); +} + +void HelpViewer::setTitle(const QString &title) +{ + TRACE_OBJ + setDocumentTitle(title); +} + +QUrl HelpViewer::source() const +{ + TRACE_OBJ + return QTextBrowser::source(); } void HelpViewer::setSource(const QUrl &url) { TRACE_OBJ - const QString &string = url.toString(); - if (url.isValid() && string != QLatin1String("help")) { - if (launchWithExternalApp(url)) - return; - - const QUrl &resolvedUrl = helpEngine.findFile(url); - if (resolvedUrl.isValid()) { - QTextBrowser::setSource(resolvedUrl); - return; - } - } + if (launchWithExternalApp(url)) + return; - if (string != QLatin1String("help")) { - QTextBrowser::setSource(url); + emit loadStarted(); + QString string = url.toString(); + const HelpEngineWrapper &engine = HelpEngineWrapper::instance(); + const QUrl &resolvedUrl = (string == QLatin1String("help") ? LocalHelpFile : + engine.findFile(string)); + QTextBrowser::setSource(resolvedUrl); + if (!url.isValid()) { setHtml(string == QLatin1String("about:blank") ? AboutBlank : PageNotFoundMessage.arg(url.toString())); - emit sourceChanged(url); - } else { - QTextBrowser::setSource(LocalHelpFile); } + emit loadFinished(true); } -QVariant HelpViewer::loadResource(int type, const QUrl &name) +QString HelpViewer::selectedText() const { TRACE_OBJ - QByteArray ba; - if (type < 4) { - ba = helpEngine.fileData(name); - if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) { - QImage image; - image.loadFromData(ba, "svg"); - if (!image.isNull()) - return image; - } - } - return ba; + return textCursor().selectedText(); } -void HelpViewer::openLinkInNewTab() +bool HelpViewer::isForwardAvailable() const { TRACE_OBJ - if(lastAnchor.isEmpty()) - return; - - parentWidget->setSourceInNewTab(QUrl(lastAnchor)); - lastAnchor.clear(); + return QTextBrowser::isForwardAvailable(); } -void HelpViewer::openLinkInNewTab(const QString &link) +bool HelpViewer::isBackwardAvailable() const { TRACE_OBJ - lastAnchor = link; - openLinkInNewTab(); + return QTextBrowser::isBackwardAvailable(); } -bool HelpViewer::hasAnchorAt(const QPoint& pos) +bool HelpViewer::findText(const QString &text, FindFlags flags, bool incremental, + bool fromSearch) { TRACE_OBJ - lastAnchor = anchorAt(pos); - if (lastAnchor.isEmpty()) + QTextDocument *doc = document(); + QTextCursor cursor = textCursor(); + if (!doc || cursor.isNull()) return false; - lastAnchor = source().resolved(lastAnchor).toString(); - if (lastAnchor.at(0) == QLatin1Char('#')) { - QString src = source().toString(); - int hsh = src.indexOf(QLatin1Char('#')); - lastAnchor = (hsh>=0 ? src.left(hsh) : src) + lastAnchor; + const int position = cursor.selectionStart(); + if (incremental) + cursor.setPosition(position); + + QTextDocument::FindFlags textDocFlags; + if (flags & HelpViewer::FindBackward) + textDocFlags |= QTextDocument::FindBackward; + if (flags & HelpViewer::FindCaseSensitively) + textDocFlags |= QTextDocument::FindCaseSensitively; + + QTextCursor found = doc->find(text, cursor, textDocFlags); + if (found.isNull()) { + if ((flags & HelpViewer::FindBackward) == 0) + cursor.movePosition(QTextCursor::Start); + else + cursor.movePosition(QTextCursor::End); + found = doc->find(text, cursor, textDocFlags); } - return true; -} + if (fromSearch) { + cursor.beginEditBlock(); + viewport()->setUpdatesEnabled(false); -void HelpViewer::contextMenuEvent(QContextMenuEvent *e) -{ - TRACE_OBJ - QMenu menu(QLatin1String(""), 0); + QTextCharFormat marker; + marker.setForeground(Qt::red); + cursor.movePosition(QTextCursor::Start); + setTextCursor(cursor); - QUrl link; - QAction *copyAnchorAction = 0; - if (hasAnchorAt(e->pos())) { - link = anchorAt(e->pos()); - if (link.isRelative()) - link = source().resolved(link); - copyAnchorAction = menu.addAction(tr("Copy &Link Location")); - copyAnchorAction->setEnabled(!link.isEmpty() && link.isValid()); + while (find(text)) { + QTextCursor hit = textCursor(); + hit.mergeCharFormat(marker); + } - menu.addAction(tr("Open Link in New Tab\tCtrl+LMB"), this, - SLOT(openLinkInNewTab())); - menu.addSeparator(); + viewport()->setUpdatesEnabled(true); + cursor.endEditBlock(); } - menu.addActions(parentWidget->globalActions()); - QAction *action = menu.exec(e->globalPos()); - if (action == copyAnchorAction) - QApplication::clipboard()->setText(link.toString()); + + bool cursorIsNull = found.isNull(); + if (cursorIsNull) { + found = textCursor(); + found.setPosition(position); + } + setTextCursor(found); + return !cursorIsNull; } -void HelpViewer::mouseReleaseEvent(QMouseEvent *e) +// -- public slots + +void HelpViewer::copy() { TRACE_OBJ -#ifndef Q_OS_LINUX - if (handleForwardBackwardMouseButtons(e)) - return; -#endif - - controlPressed = e->modifiers() & Qt::ControlModifier; - if ((controlPressed && hasAnchorAt(e->pos())) || - (e->button() == Qt::MidButton && hasAnchorAt(e->pos()))) { - openLinkInNewTab(); - return; - } + QTextBrowser::copy(); +} - QTextBrowser::mouseReleaseEvent(e); +void HelpViewer::forward() +{ + TRACE_OBJ + QTextBrowser::forward(); } -void HelpViewer::mousePressEvent(QMouseEvent *e) +void HelpViewer::backward() { -#ifdef Q_OS_LINUX - if (handleForwardBackwardMouseButtons(e)) - return; -#endif - QTextBrowser::mousePressEvent(e); + TRACE_OBJ + QTextBrowser::backward(); } +// -- protected + void HelpViewer::keyPressEvent(QKeyEvent *e) { TRACE_OBJ @@ -279,11 +280,6 @@ void HelpViewer::keyPressEvent(QKeyEvent *e) QTextBrowser::keyPressEvent(e); } -void HelpViewer::home() -{ - TRACE_OBJ - setSource(helpEngine.homePage()); -} void HelpViewer::wheelEvent(QWheelEvent *e) { @@ -296,12 +292,93 @@ void HelpViewer::wheelEvent(QWheelEvent *e) } } +void HelpViewer::mousePressEvent(QMouseEvent *e) +{ + TRACE_OBJ +#ifdef Q_OS_LINUX + if (handleForwardBackwardMouseButtons(e)) + return; +#endif + + QTextBrowser::mousePressEvent(e); +} + +void HelpViewer::mouseReleaseEvent(QMouseEvent *e) +{ + TRACE_OBJ +#ifndef Q_OS_LINUX + if (handleForwardBackwardMouseButtons(e)) + return; +#endif + + bool controlPressed = e->modifiers() & Qt::ControlModifier; + if ((controlPressed && d->hasAnchorAt(this, e->pos())) || + (e->button() == Qt::MidButton && d->hasAnchorAt(this, e->pos()))) { + d->openLinkInNewPage(); + return; + } + + QTextBrowser::mouseReleaseEvent(e); +} + +// -- private slots + +void HelpViewer::actionChanged() +{ + // stub + TRACE_OBJ +} + +// -- private + bool HelpViewer::eventFilter(QObject *obj, QEvent *event) { TRACE_OBJ - if (event->type() == QEvent::FontChange && !forceFont) + if (event->type() == QEvent::FontChange && !d->forceFont) return true; return QTextBrowser::eventFilter(obj, event); } +void HelpViewer::contextMenuEvent(QContextMenuEvent *event) +{ + TRACE_OBJ + + QMenu menu(QString(), 0); + QUrl link; + QAction *copyAnchorAction = 0; + if (d->hasAnchorAt(this, event->pos())) { + link = anchorAt(event->pos()); + if (link.isRelative()) + link = source().resolved(link); + menu.addAction(tr("Open Link"), d, SLOT(openLink())); + menu.addAction(tr("Open Link in New Tab\tCtrl+LMB"), d, SLOT(openLinkInNewPage())); + + if (!link.isEmpty() && link.isValid()) + copyAnchorAction = menu.addAction(tr("Copy &Link Location")); + } else if (!selectedText().isEmpty()) { + menu.addAction(tr("Copy"), this, SLOT(copy())); + } else { + menu.addAction(tr("Reload"), this, SLOT(reload())); + } + + if (copyAnchorAction == menu.exec(event->globalPos())) + QApplication::clipboard()->setText(link.toString()); +} + +QVariant HelpViewer::loadResource(int type, const QUrl &name) +{ + TRACE_OBJ + QByteArray ba; + if (type < 4) { + ba = HelpEngineWrapper::instance().fileData(name); + if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) { + QImage image; + image.loadFromData(ba, "svg"); + if (!image.isNull()) + return image; + } + } + return ba; +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index 495756e..efb9b59 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -39,25 +39,31 @@ ** ****************************************************************************/ -#include "helpviewer_qwv.h" +#include "helpviewer.h" +#include "helpviewer_p.h" #include "centralwidget.h" #include "helpenginewrapper.h" +#include "openpagesmanager.h" #include "tracer.h" #include <QtCore/QFileInfo> #include <QtCore/QString> -#include <QtCore/QStringBuilder> #include <QtCore/QTimer> +#include <QtGui/QApplication> #include <QtGui/QWheelEvent> +#include <QtHelp/QHelpEngineCore> + #include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkReply> #include <QtNetwork/QNetworkRequest> QT_BEGIN_NAMESPACE +// -- HelpNetworkReply + class HelpNetworkReply : public QNetworkReply { public: @@ -109,6 +115,8 @@ qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen) return len; } +// -- HelpNetworkAccessManager + class HelpNetworkAccessManager : public QNetworkAccessManager { public: @@ -130,15 +138,14 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, { TRACE_OBJ QString url = request.url().toString(); - HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - + const HelpEngineWrapper &engine = HelpEngineWrapper::instance(); // TODO: For some reason the url to load is already wrong (passed from webkit) // though the css file and the references inside should work that way. One // possible problem might be that the css is loaded at the same level as the // html, thus a path inside the css like (../images/foo.png) might cd out of // the virtual folder - if (!helpEngine.findFile(url).isValid()) { - if (url.startsWith(AbstractHelpViewer::DocPath)) { + if (!engine.findFile(url).isValid()) { + if (url.startsWith(HelpViewer::DocPath)) { QUrl newUrl = request.url(); if (!newUrl.path().startsWith(QLatin1String("/qdoc/"))) { newUrl.setPath(QLatin1String("qdoc") + newUrl.path()); @@ -147,18 +154,20 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, } } - const QString &mimeType = AbstractHelpViewer::mimeFromUrl(url); - const QByteArray &data = helpEngine.findFile(url).isValid() - ? helpEngine.fileData(url) - : AbstractHelpViewer::PageNotFoundMessage.arg(url).toUtf8(); + const QString &mimeType = HelpViewer::mimeFromUrl(url); + const QByteArray &data = engine.findFile(url).isValid() ? engine.fileData(url) + : HelpViewer::PageNotFoundMessage.arg(url).toUtf8(); + return new HelpNetworkReply(request, data, mimeType.isEmpty() ? QLatin1String("application/octet-stream") : mimeType); } +// -- HelpPage + class HelpPage : public QWebPage { public: - HelpPage(CentralWidget *central, QObject *parent); + HelpPage(QObject *parent); protected: virtual QWebPage *createWindow(QWebPage::WebWindowType); @@ -168,7 +177,6 @@ protected: const QNetworkRequest &request, NavigationType type); private: - CentralWidget *centralWidget; bool closeNewTabIfNeeded; friend class HelpViewer; @@ -177,9 +185,8 @@ private: Qt::KeyboardModifiers m_keyboardModifiers; }; -HelpPage::HelpPage(CentralWidget *central, QObject *parent) +HelpPage::HelpPage(QObject *parent) : QWebPage(parent) - , centralWidget(central) , closeNewTabIfNeeded(false) , m_pressedButtons(Qt::NoButton) , m_keyboardModifiers(Qt::NoModifier) @@ -190,9 +197,9 @@ HelpPage::HelpPage(CentralWidget *central, QObject *parent) QWebPage *HelpPage::createWindow(QWebPage::WebWindowType) { TRACE_OBJ - HelpPage* newPage = static_cast<HelpPage*>(centralWidget->newEmptyTab()->page()); - if (newPage) - newPage->closeNewTabIfNeeded = closeNewTabIfNeeded; + HelpPage* newPage = static_cast<HelpPage*>(OpenPagesManager::instance() + ->createPage()->page()); + newPage->closeNewTabIfNeeded = closeNewTabIfNeeded; closeNewTabIfNeeded = false; return newPage; } @@ -217,19 +224,17 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, closeNewTabIfNeeded = false; const QUrl &url = request.url(); - if (AbstractHelpViewer::launchWithExternalApp(url)) { + if (HelpViewer::launchWithExternalApp(url)) { if (closeNewTab) - QMetaObject::invokeMethod(centralWidget, "closeTab"); + QMetaObject::invokeMethod(OpenPagesManager::instance(), "closeCurrentPage"); return false; } if (type == QWebPage::NavigationTypeLinkClicked - && (m_keyboardModifiers & Qt::ControlModifier - || m_pressedButtons == Qt::MidButton)) { - if (centralWidget->newEmptyTab()) - centralWidget->setSource(url); + && (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton)) { m_pressedButtons = Qt::NoButton; m_keyboardModifiers = Qt::NoModifier; + OpenPagesManager::instance()->createPage(url); return false; } @@ -243,23 +248,20 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, // -- HelpViewer -HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) +HelpViewer::HelpViewer(qreal zoom, QWidget *parent) : QWebView(parent) - , parentWidget(parent) - , loadFinished(false) - , helpEngine(HelpEngineWrapper::instance()) + , d(new HelpViewerPrivate) { TRACE_OBJ setAcceptDrops(false); + settings()->setAttribute(QWebSettings::JavaEnabled, false); + settings()->setAttribute(QWebSettings::PluginsEnabled, false); - setPage(new HelpPage(parent, this)); - + setPage(new HelpPage(this)); page()->setNetworkAccessManager(new HelpNetworkAccessManager(this)); QAction* action = pageAction(QWebPage::OpenLinkInNewWindow); - action->setText(tr("Open Link in New Tab")); - if (!parent) - action->setVisible(false); + action->setText(tr("Open Link in New Page")); pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false); pageAction(QWebPage::DownloadImageToDisk)->setVisible(false); @@ -271,27 +273,23 @@ HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) SLOT(actionChanged())); connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this, SLOT(actionChanged())); - connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this, + connect(page(), SIGNAL(linkHovered(QString, QString, QString)), this, SIGNAL(highlighted(QString))); connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); connect(this, SIGNAL(loadStarted()), this, SLOT(setLoadStarted())); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); + connect(this, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged())); connect(page(), SIGNAL(printRequested(QWebFrame*)), this, SIGNAL(printRequested())); setFont(viewerFont()); setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom); } -HelpViewer::~HelpViewer() -{ - TRACE_OBJ -} - QFont HelpViewer::viewerFont() const { TRACE_OBJ - if (helpEngine.usesBrowserFont()) - return helpEngine.browserFont(); + if (HelpEngineWrapper::instance().usesBrowserFont()) + return HelpEngineWrapper::instance().browserFont(); QWebSettings *webSettings = QWebSettings::globalSettings(); return QFont(webSettings->fontFamily(QWebSettings::StandardFont), @@ -324,26 +322,29 @@ void HelpViewer::resetScale() setTextSizeMultiplier(1.0); } -bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e) +qreal HelpViewer::scale() const { TRACE_OBJ - if (e->button() == Qt::XButton1) { - triggerPageAction(QWebPage::Back); - return true; - } + return textSizeMultiplier(); +} - if (e->button() == Qt::XButton2) { - triggerPageAction(QWebPage::Forward); - return true; - } +QString HelpViewer::title() const +{ + TRACE_OBJ + return QWebView::title(); +} - return false; +void HelpViewer::setTitle(const QString &title) +{ + TRACE_OBJ + Q_UNUSED(title) } QUrl HelpViewer::source() const { + TRACE_OBJ HelpPage *currentPage = static_cast<HelpPage*> (page()); - if (currentPage && !hasLoadFinished()) { + if (currentPage && !d->m_loadFinished) { // see HelpPage::acceptNavigationRequest(...) return currentPage->m_loadingUrl; } @@ -356,44 +357,84 @@ void HelpViewer::setSource(const QUrl &url) load(url.toString() == QLatin1String("help") ? LocalHelpFile : url); } -void HelpViewer::home() +QString HelpViewer::selectedText() const { TRACE_OBJ - setSource(helpEngine.homePage()); + return QWebView::selectedText(); } -void HelpViewer::wheelEvent(QWheelEvent *e) +bool HelpViewer::isForwardAvailable() const { TRACE_OBJ - if (e->modifiers()& Qt::ControlModifier) { - e->accept(); - e->delta() > 0 ? scaleUp() : scaleDown(); - } else { - QWebView::wheelEvent(e); - } + return pageAction(QWebPage::Forward)->isEnabled(); } -void HelpViewer::mouseReleaseEvent(QMouseEvent *e) +bool HelpViewer::isBackwardAvailable() const { TRACE_OBJ -#ifndef Q_OS_LINUX - if (handleForwardBackwardMouseButtons(e)) - return; -#endif + return pageAction(QWebPage::Back)->isEnabled(); +} - QWebView::mouseReleaseEvent(e); +bool HelpViewer::findText(const QString &text, FindFlags flags, bool incremental, + bool fromSearch) +{ + TRACE_OBJ + Q_UNUSED(incremental); Q_UNUSED(fromSearch); + QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; + if (flags & FindBackward) + options |= QWebPage::FindBackward; + if (flags & FindCaseSensitively) + options |= QWebPage::FindCaseSensitively; + + bool found = QWebView::findText(text, options); + options = QWebPage::HighlightAllOccurrences; + QWebView::findText(QLatin1String(""), options); // clear first + QWebView::findText(text, options); // force highlighting of all other matches + return found; } -void HelpViewer::actionChanged() +// -- public slots + +void HelpViewer::copy() { TRACE_OBJ - QAction *a = qobject_cast<QAction *>(sender()); - if (a == pageAction(QWebPage::Copy)) - emit copyAvailable(a->isEnabled()); - else if (a == pageAction(QWebPage::Back)) - emit backwardAvailable(a->isEnabled()); - else if (a == pageAction(QWebPage::Forward)) - emit forwardAvailable(a->isEnabled()); + triggerPageAction(QWebPage::Copy); +} + +void HelpViewer::forward() +{ + TRACE_OBJ + QWebView::forward(); +} + +void HelpViewer::backward() +{ + TRACE_OBJ + back(); +} + +// -- protected + +void HelpViewer::keyPressEvent(QKeyEvent *e) +{ + TRACE_OBJ + // TODO: remove this once we support multiple keysequences per command + if (e->key() == Qt::Key_Insert && e->modifiers() == Qt::CTRL) { + if (!selectedText().isEmpty()) + copy(); + } + QWebView::keyPressEvent(e); +} + +void HelpViewer::wheelEvent(QWheelEvent *event) +{ + TRACE_OBJ + if (event->modifiers()& Qt::ControlModifier) { + event->accept(); + event->delta() > 0 ? scaleUp() : scaleDown(); + } else { + QWebView::wheelEvent(event); + } } void HelpViewer::mousePressEvent(QMouseEvent *event) @@ -404,24 +445,51 @@ void HelpViewer::mousePressEvent(QMouseEvent *event) return; #endif - HelpPage *currentPage = static_cast<HelpPage*>(page()); - if (currentPage) { + if (HelpPage *currentPage = static_cast<HelpPage*> (page())) { currentPage->m_pressedButtons = event->buttons(); currentPage->m_keyboardModifiers = event->modifiers(); } + QWebView::mousePressEvent(event); } -void HelpViewer::setLoadStarted() +void HelpViewer::mouseReleaseEvent(QMouseEvent *event) { - loadFinished = false; + TRACE_OBJ +#ifndef Q_OS_LINUX + if (handleForwardBackwardMouseButtons(event)) + return; +#endif + + QWebView::mouseReleaseEvent(event); +} + +// -- private slots + +void HelpViewer::actionChanged() +{ + TRACE_OBJ + QAction *a = qobject_cast<QAction *>(sender()); + if (a == pageAction(QWebPage::Copy)) + emit copyAvailable(a->isEnabled()); + else if (a == pageAction(QWebPage::Back)) + emit backwardAvailable(a->isEnabled()); + else if (a == pageAction(QWebPage::Forward)) + emit forwardAvailable(a->isEnabled()); +} + +// -- private + +bool HelpViewer::eventFilter(QObject *obj, QEvent *event) +{ + TRACE_OBJ + return QWebView::eventFilter(obj, event); } -void HelpViewer::setLoadFinished(bool ok) +void HelpViewer::contextMenuEvent(QContextMenuEvent *event) { TRACE_OBJ - loadFinished = ok; - emit sourceChanged(url()); + QWebView::contextMenuEvent(event); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h deleted file mode 100644 index c24d584..0000000 --- a/tools/assistant/tools/assistant/helpviewer_qwv.h +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Assistant 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 HELPVIEWERQWV_H -#define HELPVIEWERQWV_H - -#include "helpviewer.h" - -#include <QtGui/QAction> -#include <QtWebKit/QWebView> - -QT_BEGIN_NAMESPACE - -class CentralWidget; -class HelpEngineWrapper; -class QMouseEvent; - -class HelpViewer : public QWebView, public AbstractHelpViewer -{ - Q_OBJECT - -public: - explicit HelpViewer(CentralWidget *parent, qreal zoom = 0.0); - ~HelpViewer(); - - QFont viewerFont() const; - void setViewerFont(const QFont &font); - - void scaleUp(); - void scaleDown(); - void resetScale(); - qreal scale() const { return textSizeMultiplier(); } - - bool handleForwardBackwardMouseButtons(QMouseEvent *e); - - QUrl source() const; - void setSource(const QUrl &url); - - inline QString documentTitle() const - { return title(); } - - inline bool hasSelection() const - { return !selectedText().isEmpty(); } // ### this is suboptimal - - inline void copy() - { return triggerPageAction(QWebPage::Copy); } - - inline bool isForwardAvailable() const - { return pageAction(QWebPage::Forward)->isEnabled(); } - inline bool isBackwardAvailable() const - { return pageAction(QWebPage::Back)->isEnabled(); } - inline bool hasLoadFinished() const - { return loadFinished; } - -public Q_SLOTS: - void home(); - void backward() { back(); } - -Q_SIGNALS: - void copyAvailable(bool enabled); - void forwardAvailable(bool enabled); - void backwardAvailable(bool enabled); - void highlighted(const QString &); - void sourceChanged(const QUrl &); - void printRequested(); - -protected: - virtual void wheelEvent(QWheelEvent *); - void mouseReleaseEvent(QMouseEvent *e); - void mousePressEvent(QMouseEvent *event); - -private Q_SLOTS: - void actionChanged(); - void setLoadStarted(); - void setLoadFinished(bool ok); - -private: - CentralWidget* parentWidget; - bool loadFinished; - HelpEngineWrapper &helpEngine; -}; - -QT_END_NAMESPACE - -#endif // HELPVIEWERQWV_H diff --git a/tools/assistant/tools/assistant/images/closebutton.png b/tools/assistant/tools/assistant/images/closebutton.png Binary files differnew file mode 100644 index 0000000..c978cf5 --- /dev/null +++ b/tools/assistant/tools/assistant/images/closebutton.png diff --git a/tools/assistant/tools/assistant/images/darkclosebutton.png b/tools/assistant/tools/assistant/images/darkclosebutton.png Binary files differnew file mode 100644 index 0000000..1077663 --- /dev/null +++ b/tools/assistant/tools/assistant/images/darkclosebutton.png diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp index a57a0a4..38bc8b9 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -38,13 +38,15 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" #include "indexwindow.h" + #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" +#include "openpagesmanager.h" #include "topicchooser.h" +#include "tracer.h" #include <QtGui/QLayout> #include <QtGui/QLabel> @@ -219,10 +221,10 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index) return; } - if (!AbstractHelpViewer::canOpenPage(url.path())) + if (!HelpViewer::canOpenPage(url.path())) CentralWidget::instance()->setSource(url); else - CentralWidget::instance()->setSourceInNewTab(url); + OpenPagesManager::instance()->createPage(url); } } diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index 3d625ba..84972c5 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -292,7 +292,8 @@ void setupTranslation(const QString &fileName, const QString &dir) QTranslator *translator = new QTranslator(QCoreApplication::instance()); if (translator->load(fileName, dir)) { QCoreApplication::installTranslator(translator); - } else if (!fileName.endsWith(QLatin1String("en_US"))) { + } else if (!fileName.endsWith(QLatin1String("en_US")) + && !fileName.endsWith(QLatin1String("_C"))) { qWarning("Could not load translation file %s in directory %s.", qPrintable(fileName), qPrintable(dir)); } diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 2fb9aed..342fc76 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -38,57 +38,58 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" #include "mainwindow.h" +#include "aboutdialog.h" #include "bookmarkmanager.h" #include "centralwidget.h" -#include "indexwindow.h" -#include "topicchooser.h" +#include "cmdlineparser.h" #include "contentwindow.h" -#include "preferencesdialog.h" +#include "globalactions.h" #include "helpenginewrapper.h" +#include "indexwindow.h" +#include "openpagesmanager.h" +#include "preferencesdialog.h" +#include "qtdocinstaller.h" #include "remotecontrol.h" -#include "cmdlineparser.h" -#include "aboutdialog.h" #include "searchwidget.h" -#include "qtdocinstaller.h" - -// #define TRACING_REQUESTED +#include "topicchooser.h" +#include "tracer.h" -#include <QtCore/QDir> -#include <QtCore/QTimer> +#include <QtCore/QByteArray> #include <QtCore/QDateTime> #include <QtCore/QDebug> -#include <QtCore/QFileSystemWatcher> +#include <QtCore/QDir> #include <QtCore/QPair> #include <QtCore/QResource> -#include <QtCore/QByteArray> #include <QtCore/QTextStream> -#include <QtCore/QCoreApplication> +#include <QtCore/QTimer> -#include <QtGui/QMenuBar> #include <QtGui/QAction> -#include <QtGui/QToolBar> -#include <QtGui/QStatusBar> +#include <QtGui/QComboBox> +#include <QtGui/QDesktopServices> +#include <QtGui/QDesktopWidget> +#include <QtGui/QDockWidget> +#include <QtGui/QFontDatabase> +#include <QtGui/QFileDialog> #include <QtGui/QLabel> -#include <QtGui/QLineEdit> #include <QtGui/QLayout> -#include <QtGui/QDockWidget> -#include <QtGui/QTreeView> +#include <QtGui/QLineEdit> +#include <QtGui/QMenuBar> #include <QtGui/QMessageBox> -#include <QtGui/QFontDatabase> -#include <QtGui/QComboBox> #include <QtGui/QProgressBar> -#include <QtGui/QDesktopServices> +#include <QtGui/QShortcut> +#include <QtGui/QStatusBar> +#include <QtGui/QToolBar> #include <QtGui/QToolButton> -#include <QtGui/QFileDialog> -#include <QtHelp/QHelpEngineCore> -#include <QtHelp/QHelpSearchEngine> #include <QtHelp/QHelpContentModel> +#include <QtHelp/QHelpEngineCore> #include <QtHelp/QHelpIndexModel> +#include <QtHelp/QHelpSearchEngine> + +#include <cstdlib> QT_BEGIN_NAMESPACE @@ -105,6 +106,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) TRACE_OBJ setToolButtonStyle(Qt::ToolButtonFollowStyle); + setDockOptions(dockOptions() | AllowNestedDocks); QString collectionFile; if (usesDefaultCollection()) { @@ -115,6 +117,14 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) } HelpEngineWrapper &helpEngineWrapper = HelpEngineWrapper::instance(collectionFile); + BookmarkManager *bookMarkManager = BookmarkManager::instance(); + + if (!initHelpDB(!cmdLine->collectionFileGiven())) { + 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); @@ -131,132 +141,154 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) contentDock->setWidget(m_contentWindow); addDockWidget(Qt::LeftDockWidgetArea, contentDock); - QDockWidget *bookmarkDock = 0; - if (BookmarkManager *manager = BookmarkManager::instance()) { - bookmarkDock = new QDockWidget(tr("Bookmarks"), this); - bookmarkDock->setObjectName(QLatin1String("BookmarkWindow")); - bookmarkDock->setWidget(m_bookmarkWidget = manager->bookmarkDockWidget()); - addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock); - - connect(manager, SIGNAL(escapePressed()), this, + m_searchWindow = new SearchWidget(helpEngineWrapper.searchEngine()); + m_searchWindow->setFont(!helpEngineWrapper.usesBrowserFont() ? qApp->font() + : helpEngineWrapper.browserFont()); + QDockWidget *searchDock = new QDockWidget(tr("Search"), this); + searchDock->setObjectName(QLatin1String("SearchWindow")); + searchDock->setWidget(m_searchWindow); + addDockWidget(Qt::LeftDockWidgetArea, searchDock); + + QDockWidget *bookmarkDock = new QDockWidget(tr("Bookmarks"), this); + bookmarkDock->setObjectName(QLatin1String("BookmarkWindow")); + bookmarkDock->setWidget(m_bookmarkWidget + = bookMarkManager->bookmarkDockWidget()); + addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock); + + QDockWidget *openPagesDock = new QDockWidget(tr("Open Pages"), this); + openPagesDock->setObjectName(QLatin1String("Open Pages")); + OpenPagesManager *openPagesManager + = OpenPagesManager::createInstance(this, usesDefaultCollection(), m_cmdLine->url()); + openPagesDock->setWidget(openPagesManager->openPagesWidget()); + addDockWidget(Qt::LeftDockWidgetArea, openPagesDock); + + connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)), + bookMarkManager, SLOT(addBookmark(QString, QString))); + connect(bookMarkManager, SIGNAL(escapePressed()), this, SLOT(activateCurrentCentralWidgetTab())); - connect(manager, SIGNAL(setSource(QUrl)), m_centralWidget, + connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget, SLOT(setSource(QUrl))); - connect(manager, SIGNAL(setSourceInNewTab(QUrl)), m_centralWidget, - SLOT(setSourceInNewTab(QUrl))); - connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)), manager, - SLOT(addBookmark(QString, QString))); - } + connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)), + openPagesManager, SLOT(createPage(QUrl))); QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine(); connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted())); connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); - m_centralWidget->createSearchWidget(searchEngine); - m_centralWidget->activateSearchWidget(); - QString defWindowTitle = tr("Qt Assistant"); setWindowTitle(defWindowTitle); setupActions(); statusBar()->show(); + m_centralWidget->connectTabBar(); - if (initHelpDB(!cmdLine->collectionFileGiven())) { - setupFilterToolbar(); - setupAddressToolbar(); - - const QString windowTitle = helpEngineWrapper.windowTitle(); - setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle); - QByteArray iconArray = helpEngineWrapper.applicationIcon(); - if (iconArray.size() > 0) { - QPixmap pix; - pix.loadFromData(iconArray); - QIcon appIcon(pix); - qApp->setWindowIcon(appIcon); - } else { - QIcon appIcon(QLatin1String(":/trolltech/assistant/images/assistant-128.png")); - qApp->setWindowIcon(appIcon); - } + setupFilterToolbar(); + setupAddressToolbar(); - // Show the widget here, otherwise the restore geometry and state won't work - // on x11. - show(); - QByteArray ba(helpEngineWrapper.mainWindow()); - if (!ba.isEmpty()) - restoreState(ba); - - ba = helpEngineWrapper.mainWindowGeometry(); - if (!ba.isEmpty()) { - restoreGeometry(ba); - } else { - tabifyDockWidget(contentDock, indexDock); - if (bookmarkDock) - tabifyDockWidget(indexDock, bookmarkDock); - contentDock->raise(); - resize(QSize(800, 600)); - } + const QString windowTitle = helpEngineWrapper.windowTitle(); + setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle); + QByteArray iconArray = helpEngineWrapper.applicationIcon(); + if (iconArray.size() > 0) { + QPixmap pix; + pix.loadFromData(iconArray); + QIcon appIcon(pix); + qApp->setWindowIcon(appIcon); + } else { + QIcon appIcon(QLatin1String(":/trolltech/assistant/images/assistant-128.png")); + qApp->setWindowIcon(appIcon); + } - if (!helpEngineWrapper.hasFontSettings()) { - helpEngineWrapper.setUseAppFont(false); - helpEngineWrapper.setUseBrowserFont(false); - helpEngineWrapper.setAppFont(qApp->font()); - helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin); - helpEngineWrapper.setBrowserFont(qApp->font()); - helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin); - } else { - updateApplicationFont(); - } + QToolBar *toolBar = addToolBar(tr("Bookmark Toolbar")); + toolBar->setObjectName(QLatin1String("Bookmark Toolbar")); + bookMarkManager->setBookmarksToolbar(toolBar); - updateAboutMenuText(); - - QTimer::singleShot(0, this, SLOT(insertLastPages())); - if (m_cmdLine->enableRemoteControl()) - (void)new RemoteControl(this); - - if (m_cmdLine->contents() == CmdLineParser::Show) - showContents(); - else if (m_cmdLine->contents() == CmdLineParser::Hide) - hideContents(); - - if (m_cmdLine->index() == CmdLineParser::Show) - showIndex(); - else if (m_cmdLine->index() == CmdLineParser::Hide) - hideIndex(); - - if (m_cmdLine->bookmarks() == CmdLineParser::Show) - showBookmarksDockWidget(); - else if (m_cmdLine->bookmarks() == CmdLineParser::Hide) - hideBookmarksDockWidget(); - - if (m_cmdLine->search() == CmdLineParser::Show) - showSearch(); - else if (m_cmdLine->search() == CmdLineParser::Hide) - hideSearch(); - - if (m_cmdLine->contents() == CmdLineParser::Activate) - showContents(); - else if (m_cmdLine->index() == CmdLineParser::Activate) - showIndex(); - else if (m_cmdLine->bookmarks() == CmdLineParser::Activate) - showBookmarksDockWidget(); - - if (!m_cmdLine->currentFilter().isEmpty()) { - const QString &curFilter = m_cmdLine->currentFilter(); - if (helpEngineWrapper.customFilters().contains(curFilter)) - helpEngineWrapper.setCurrentFilter(curFilter); - } + // Show the widget here, otherwise the restore geometry and state won't work + // on x11. + show(); - if (usesDefaultCollection()) - QTimer::singleShot(0, this, SLOT(lookForNewQtDocumentation())); - else - checkInitState(); + toolBar->hide(); + toolBarMenu()->addAction(toolBar->toggleViewAction()); + + QByteArray ba(helpEngineWrapper.mainWindow()); + if (!ba.isEmpty()) + restoreState(ba); + + ba = helpEngineWrapper.mainWindowGeometry(); + if (!ba.isEmpty()) { + restoreGeometry(ba); + } else { + tabifyDockWidget(contentDock, indexDock); + tabifyDockWidget(indexDock, bookmarkDock); + tabifyDockWidget(bookmarkDock, searchDock); + contentDock->raise(); + const QRect screen = QApplication::desktop()->screenGeometry(); + resize(4*screen.width()/5, 4*screen.height()/5); + } - connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)), - this, SLOT(documentationRemoved(QString))); - connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)), - this, SLOT(documentationUpdated(QString))); + if (!helpEngineWrapper.hasFontSettings()) { + helpEngineWrapper.setUseAppFont(false); + helpEngineWrapper.setUseBrowserFont(false); + helpEngineWrapper.setAppFont(qApp->font()); + helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin); + helpEngineWrapper.setBrowserFont(qApp->font()); + helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin); + } else { + updateApplicationFont(); + } + + updateAboutMenuText(); + + QTimer::singleShot(0, this, SLOT(insertLastPages())); + if (m_cmdLine->enableRemoteControl()) + (void)new RemoteControl(this); + + if (m_cmdLine->contents() == CmdLineParser::Show) + showContents(); + else if (m_cmdLine->contents() == CmdLineParser::Hide) + hideContents(); + + if (m_cmdLine->index() == CmdLineParser::Show) + showIndex(); + else if (m_cmdLine->index() == CmdLineParser::Hide) + hideIndex(); + + if (m_cmdLine->bookmarks() == CmdLineParser::Show) + showBookmarksDockWidget(); + else if (m_cmdLine->bookmarks() == CmdLineParser::Hide) + hideBookmarksDockWidget(); + + if (m_cmdLine->search() == CmdLineParser::Show) + showSearch(); + else if (m_cmdLine->search() == CmdLineParser::Hide) + hideSearch(); + + if (m_cmdLine->contents() == CmdLineParser::Activate) + showContents(); + else if (m_cmdLine->index() == CmdLineParser::Activate) + showIndex(); + else if (m_cmdLine->bookmarks() == CmdLineParser::Activate) + showBookmarksDockWidget(); + + if (!m_cmdLine->currentFilter().isEmpty()) { + const QString &curFilter = m_cmdLine->currentFilter(); + if (helpEngineWrapper.customFilters().contains(curFilter)) + helpEngineWrapper.setCurrentFilter(curFilter); } + + if (usesDefaultCollection()) + QTimer::singleShot(0, this, SLOT(lookForNewQtDocumentation())); + else + checkInitState(); + + connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)), + this, SLOT(documentationRemoved(QString))); + connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)), + this, SLOT(documentationUpdated(QString))); + setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); + GlobalActions::instance()->updateActions(); + if (helpEngineWrapper.addressBarEnabled()) + showNewAddress(); } MainWindow::~MainWindow() @@ -392,11 +424,6 @@ void MainWindow::checkInitState() void MainWindow::insertLastPages() { TRACE_OBJ - if (m_cmdLine->url().isValid()) - m_centralWidget->setSource(m_cmdLine->url()); - else - m_centralWidget->setupWidget(); - if (m_cmdLine->search() == CmdLineParser::Activate) showSearch(); } @@ -414,8 +441,13 @@ void MainWindow::setupActions() QMenu *menu = menuBar()->addMenu(tr("&File")); - m_newTabAction = menu->addAction(tr("New &Tab"), m_centralWidget, SLOT(newTab())); + OpenPagesManager * const openPages = OpenPagesManager::instance(); + m_newTabAction + = menu->addAction(tr("New &Tab"), openPages, SLOT(createPage())); m_newTabAction->setShortcut(QKeySequence::AddTab); + m_closeTabAction = menu->addAction(tr("&Close Tab"), + openPages, SLOT(closeCurrentPage())); + m_closeTabAction->setShortcuts(QKeySequence::Close); menu->addSeparator(); @@ -424,40 +456,24 @@ void MainWindow::setupActions() m_printPreviewAction = menu->addAction(tr("Print Preview..."), m_centralWidget, SLOT(printPreview())); - m_printAction = menu->addAction(tr("&Print..."), m_centralWidget, SLOT(print())); - m_printAction->setPriority(QAction::LowPriority); - m_printAction->setIcon(QIcon(resourcePath + QLatin1String("/print.png"))); - m_printAction->setShortcut(QKeySequence::Print); - + GlobalActions *globalActions = GlobalActions::instance(this); + menu->addAction(globalActions->printAction()); menu->addSeparator(); - m_closeTabAction = menu->addAction(tr("&Close Tab"), m_centralWidget, - SLOT(closeTab())); - m_closeTabAction->setShortcuts(QKeySequence::Close); - - QAction *tmp = menu->addAction(QIcon::fromTheme("application-exit"), - tr("&Quit"), this, SLOT(close())); - tmp->setMenuRole(QAction::QuitRole); + QIcon appExitIcon = QIcon::fromTheme("application-exit"); + QAction *tmp; #ifdef Q_OS_WIN + tmp = menu->addAction(appExitIcon, tr("E&xit"), this, SLOT(close())); tmp->setShortcut(QKeySequence(tr("CTRL+Q"))); #else + tmp = menu->addAction(appExitIcon, tr("&Quit"), this, SLOT(close())); tmp->setShortcut(QKeySequence::Quit); #endif + tmp->setMenuRole(QAction::QuitRole); menu = menuBar()->addMenu(tr("&Edit")); - m_copyAction = menu->addAction(tr("&Copy selected Text"), m_centralWidget, - SLOT(copySelection())); - m_copyAction->setPriority(QAction::LowPriority); - m_copyAction->setIconText("&Copy"); - m_copyAction->setIcon(QIcon(resourcePath + QLatin1String("/editcopy.png"))); - m_copyAction->setShortcuts(QKeySequence::Copy); - m_copyAction->setEnabled(false); - - m_findAction = menu->addAction(tr("&Find in Text..."), m_centralWidget, - SLOT(showTextSearch())); - m_findAction->setIconText(tr("&Find")); - m_findAction->setIcon(QIcon(resourcePath + QLatin1String("/find.png"))); - m_findAction->setShortcuts(QKeySequence::Find); + menu->addAction(globalActions->copyAction()); + menu->addAction(globalActions->findAction()); QAction *findNextAction = menu->addAction(tr("Find &Next"), m_centralWidget, SLOT(findNext())); @@ -472,17 +488,8 @@ void MainWindow::setupActions() tmp->setMenuRole(QAction::PreferencesRole); m_viewMenu = menuBar()->addMenu(tr("&View")); - m_zoomInAction = m_viewMenu->addAction(tr("Zoom &in"), m_centralWidget, - SLOT(zoomIn())); - m_zoomInAction->setPriority(QAction::LowPriority); - m_zoomInAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomin.png"))); - m_zoomInAction->setShortcut(QKeySequence::ZoomIn); - - m_zoomOutAction = m_viewMenu->addAction(tr("Zoom &out"), m_centralWidget, - SLOT(zoomOut())); - m_zoomOutAction->setPriority(QAction::LowPriority); - m_zoomOutAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomout.png"))); - m_zoomOutAction->setShortcut(QKeySequence::ZoomOut); + m_viewMenu->addAction(globalActions->zoomInAction()); + m_viewMenu->addAction(globalActions->zoomOutAction()); m_resetZoomAction = m_viewMenu->addAction(tr("Normal &Size"), m_centralWidget, SLOT(resetZoom())); @@ -498,24 +505,15 @@ void MainWindow::setupActions() QKeySequence(tr("ALT+I"))); m_viewMenu->addAction(tr("Bookmarks"), this, SLOT(showBookmarksDockWidget()), QKeySequence(tr("ALT+O"))); - m_viewMenu->addAction(tr("Search"), this, SLOT(showSearchWidget()), + m_viewMenu->addAction(tr("Search"), this, SLOT(showSearch()), QKeySequence(tr("ALT+S"))); + m_viewMenu->addAction(tr("Open Pages"), this, SLOT(showOpenPages()), + QKeySequence(tr("ALT+P"))); menu = menuBar()->addMenu(tr("&Go")); - m_homeAction = menu->addAction(tr("&Home"), m_centralWidget, SLOT(home())); - m_homeAction->setShortcut(tr("ALT+Home")); - m_homeAction->setIcon(QIcon(resourcePath + QLatin1String("/home.png"))); - - m_backAction = menu->addAction(tr("&Back"), m_centralWidget, SLOT(backward())); - m_backAction->setEnabled(false); - m_backAction->setShortcuts(QKeySequence::Back); - m_backAction->setIcon(QIcon(resourcePath + QLatin1String("/previous.png"))); - - m_nextAction = menu->addAction(tr("&Forward"), m_centralWidget, SLOT(forward())); - m_nextAction->setPriority(QAction::LowPriority); - m_nextAction->setEnabled(false); - m_nextAction->setShortcuts(QKeySequence::Forward); - m_nextAction->setIcon(QIcon(resourcePath + QLatin1String("/next.png"))); + menu->addAction(globalActions->homeAction()); + menu->addAction(globalActions->backAction()); + menu->addAction(globalActions->nextAction()); m_syncAction = menu->addAction(tr("Sync with Table of Contents"), this, SLOT(syncContents())); @@ -524,60 +522,52 @@ void MainWindow::setupActions() menu->addSeparator(); - tmp = menu->addAction(tr("Next Page"), m_centralWidget, SLOT(nextPage())); + tmp = menu->addAction(tr("Next Page"), openPages, SLOT(nextPage())); tmp->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("Ctrl+Alt+Right")) << QKeySequence(Qt::CTRL + Qt::Key_PageDown)); - tmp = menu->addAction(tr("Previous Page"), m_centralWidget, SLOT(previousPage())); + tmp = menu->addAction(tr("Previous Page"), openPages, SLOT(previousPage())); tmp->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("Ctrl+Alt+Left")) << QKeySequence(Qt::CTRL + Qt::Key_PageUp)); - if (BookmarkManager *manager = BookmarkManager::instance()) - manager->takeBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks"))); +#ifdef Q_WS_MAC + QShortcut *sct = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_Tab), this); + connect(sct, SIGNAL(activated()), openPages, SLOT(nextPageWithSwitcher())); + sct = new QShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Tab), this); + connect(sct, SIGNAL(activated()), openPages, SLOT(previousPageWithSwitcher())); +#else + QShortcut *sct = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab), this); + connect(sct, SIGNAL(activated()), openPages, SLOT(nextPageWithSwitcher())); + sct = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab), this); + connect(sct, SIGNAL(activated()), openPages, SLOT(previousPageWithSwitcher())); +#endif + + BookmarkManager::instance()->setBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks"))); menu = menuBar()->addMenu(tr("&Help")); m_aboutAction = menu->addAction(tr("About..."), this, SLOT(showAboutDialog())); m_aboutAction->setMenuRole(QAction::AboutRole); #ifdef Q_WS_X11 - m_newTabAction->setIcon(QIcon::fromTheme("tab-new", m_newTabAction->icon())); - m_closeTabAction->setIcon(QIcon::fromTheme("window-close", m_closeTabAction->icon())); - m_backAction->setIcon(QIcon::fromTheme("go-previous" , m_backAction->icon())); - m_nextAction->setIcon(QIcon::fromTheme("go-next" , m_nextAction->icon())); - m_zoomInAction->setIcon(QIcon::fromTheme("zoom-in" , m_zoomInAction->icon())); - m_zoomOutAction->setIcon(QIcon::fromTheme("zoom-out" , m_zoomOutAction->icon())); m_resetZoomAction->setIcon(QIcon::fromTheme("zoom-original" , m_resetZoomAction->icon())); m_syncAction->setIcon(QIcon::fromTheme("view-refresh" , m_syncAction->icon())); - m_copyAction->setIcon(QIcon::fromTheme("edit-copy" , m_copyAction->icon())); - m_findAction->setIcon(QIcon::fromTheme("edit-find" , m_findAction->icon())); - m_homeAction->setIcon(QIcon::fromTheme("go-home" , m_homeAction->icon())); - m_pageSetupAction->setIcon(QIcon::fromTheme("document-page-setup", m_pageSetupAction->icon())); - m_printPreviewAction->setIcon(QIcon::fromTheme("document-print-preview", m_printPreviewAction->icon())); - m_printAction->setIcon(QIcon::fromTheme("document-print" , m_printAction->icon())); - m_aboutAction->setIcon(QIcon::fromTheme("help-about", m_aboutAction->icon())); #endif QToolBar *navigationBar = addToolBar(tr("Navigation Toolbar")); navigationBar->setObjectName(QLatin1String("NavigationToolBar")); - navigationBar->addAction(m_backAction); - navigationBar->addAction(m_nextAction); - navigationBar->addAction(m_homeAction); + navigationBar->addAction(globalActions->backAction()); + navigationBar->addAction(globalActions->nextAction()); + navigationBar->addAction(globalActions->homeAction()); navigationBar->addAction(m_syncAction); - QAction *sep = navigationBar->addSeparator(); - navigationBar->addAction(m_copyAction); - navigationBar->addAction(m_printAction); - navigationBar->addAction(m_findAction); - QAction *sep2 = navigationBar->addSeparator(); - navigationBar->addAction(m_zoomInAction); - navigationBar->addAction(m_zoomOutAction); + navigationBar->addSeparator(); + navigationBar->addAction(globalActions->copyAction()); + navigationBar->addAction(globalActions->printAction()); + navigationBar->addAction(globalActions->findAction()); + navigationBar->addSeparator(); + navigationBar->addAction(globalActions->zoomInAction()); + navigationBar->addAction(globalActions->zoomOutAction()); navigationBar->addAction(m_resetZoomAction); - QList<QAction*> actionList; - actionList << m_backAction << m_nextAction << m_homeAction << sep - << m_zoomInAction << m_zoomOutAction << sep2 << m_copyAction - << m_printAction << m_findAction; - m_centralWidget->setGlobalActions(actionList); - #if defined(Q_WS_MAC) QMenu *windowMenu = new QMenu(tr("&Window"), this); menuBar()->insertMenu(menu->menuAction(), windowMenu); @@ -587,16 +577,14 @@ void MainWindow::setupActions() #endif // content viewer connections - connect(m_centralWidget, SIGNAL(copyAvailable(bool)), this, - SLOT(copyAvailable(bool))); - connect(m_centralWidget, SIGNAL(currentViewerChanged()), this, - SLOT(updateNavigationItems())); - connect(m_centralWidget, SIGNAL(currentViewerChanged()), this, - SLOT(updateTabCloseAction())); - connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), this, - SLOT(updateNavigationItems())); - connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), this, - SLOT(updateNavigationItems())); + connect(m_centralWidget, SIGNAL(copyAvailable(bool)), globalActions, + SLOT(setCopyAvailable(bool))); + connect(m_centralWidget, SIGNAL(currentViewerChanged()), globalActions, + SLOT(updateActions())); + connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), globalActions, + SLOT(updateActions())); + connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), globalActions, + SLOT(updateActions())); connect(m_centralWidget, SIGNAL(highlighted(QString)), statusBar(), SLOT(showMessage(QString))); @@ -614,6 +602,12 @@ void MainWindow::setupActions() connect(m_contentWindow, SIGNAL(escapePressed()), this, SLOT(activateCurrentCentralWidgetTab())); + // search window + connect(m_searchWindow, SIGNAL(requestShowLink(QUrl)), + CentralWidget::instance(), SLOT(setSourceFromSearch(QUrl))); + connect(m_searchWindow, SIGNAL(requestShowLinkInNewTab(QUrl)), + OpenPagesManager::instance(), SLOT(createNewPageFromSearch(QUrl))); + #if defined(QT_NO_PRINTER) m_pageSetupAction->setVisible(false); m_printPreviewAction->setVisible(false); @@ -737,26 +731,6 @@ void MainWindow::gotoAddress() m_centralWidget->setSource(m_addressLineEdit->text()); } -void MainWindow::updateNavigationItems() -{ - TRACE_OBJ - bool hasCurrentViewer = m_centralWidget->isHomeAvailable(); - m_copyAction->setEnabled(m_centralWidget->hasSelection()); - m_homeAction->setEnabled(hasCurrentViewer); - m_syncAction->setEnabled(hasCurrentViewer); - m_printPreviewAction->setEnabled(hasCurrentViewer); - m_printAction->setEnabled(hasCurrentViewer); - m_nextAction->setEnabled(m_centralWidget->isForwardAvailable()); - m_backAction->setEnabled(m_centralWidget->isBackwardAvailable()); - m_newTabAction->setEnabled(hasCurrentViewer); -} - -void MainWindow::updateTabCloseAction() -{ - TRACE_OBJ - m_closeTabAction->setEnabled(m_centralWidget->enableTabCloseAction()); -} - void MainWindow::showTopicChooser(const QMap<QString, QUrl> &links, const QString &keyword) { @@ -775,6 +749,8 @@ void MainWindow::showPreferences() SLOT(updateApplicationFont())); connect(&dia, SIGNAL(updateBrowserFont()), m_centralWidget, SLOT(updateBrowserFont())); + connect(&dia, SIGNAL(updateUserInterface()), m_centralWidget, + SLOT(updateUserInterface())); dia.showDialog(); } @@ -790,12 +766,6 @@ void MainWindow::syncContents() qApp->restoreOverrideCursor(); } -void MainWindow::copyAvailable(bool yes) -{ - TRACE_OBJ - m_copyAction->setEnabled(yes); -} - void MainWindow::showAboutDialog() { TRACE_OBJ @@ -904,15 +874,13 @@ void MainWindow::setBookmarksVisible(bool visible) void MainWindow::showBookmarksDockWidget() { TRACE_OBJ - if (m_bookmarkWidget) - activateDockWidget(m_bookmarkWidget); + activateDockWidget(m_bookmarkWidget); } void MainWindow::hideBookmarksDockWidget() { TRACE_OBJ - if (m_bookmarkWidget) - m_bookmarkWidget->parentWidget()->hide(); + m_bookmarkWidget->parentWidget()->hide(); } void MainWindow::setSearchVisible(bool visible) @@ -927,13 +895,19 @@ void MainWindow::setSearchVisible(bool visible) void MainWindow::showSearch() { TRACE_OBJ - m_centralWidget->activateSearchWidget(); + activateDockWidget(m_searchWindow); +} + +void MainWindow::showOpenPages() +{ + TRACE_OBJ + activateDockWidget(OpenPagesManager::instance()->openPagesWidget()); } void MainWindow::hideSearch() { TRACE_OBJ - m_centralWidget->removeSearchWidget(); + m_searchWindow->parentWidget()->hide(); } void MainWindow::activateDockWidget(QWidget *w) @@ -953,10 +927,7 @@ void MainWindow::setIndexString(const QString &str) void MainWindow::activateCurrentBrowser() { TRACE_OBJ - CentralWidget *cw = CentralWidget::instance(); - if (cw) { - cw->activateTab(true); - } + CentralWidget::instance()->activateTab(); } void MainWindow::activateCurrentCentralWidgetTab() @@ -965,12 +936,6 @@ void MainWindow::activateCurrentCentralWidgetTab() m_centralWidget->activateTab(); } -void MainWindow::showSearchWidget() -{ - TRACE_OBJ - m_centralWidget->activateSearchWidget(true); -} - void MainWindow::updateApplicationFont() { TRACE_OBJ @@ -1092,17 +1057,13 @@ void MainWindow::currentFilterChanged(const QString &filter) void MainWindow::documentationRemoved(const QString &namespaceName) { TRACE_OBJ - CentralWidget* widget = CentralWidget::instance(); - widget->closeOrReloadTabs(widget->currentSourceFileList(). - keys(namespaceName), false); + OpenPagesManager::instance()->closePages(namespaceName); } void MainWindow::documentationUpdated(const QString &namespaceName) { TRACE_OBJ - CentralWidget* widget = CentralWidget::instance(); - widget->closeOrReloadTabs(widget->currentSourceFileList(). - keys(namespaceName), true); + OpenPagesManager::instance()->reloadPages(namespaceName); } void MainWindow::resetQtDocInfo(const QString &component) diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 47709c7..6fe10ec 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -42,24 +42,27 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include <QtCore/QList> #include <QtCore/QUrl> #include <QtGui/QMainWindow> QT_BEGIN_NAMESPACE class QAction; +class QComboBox; class QFileSystemWatcher; class QLineEdit; -class QComboBox; class QMenu; -class IndexWindow; -class QHelpEngineCore; -class QHelpEngine; class CentralWidget; -class ContentWindow; class CmdLineParser; +class ContentWindow; +class IndexWindow; +class OpenPagesWindow; class QtDocInstaller; +class QHelpEngineCore; +class QHelpEngine; +class SearchWidget; class MainWindow : public QMainWindow { @@ -87,7 +90,6 @@ public slots: void setIndexVisible(bool visible); void setBookmarksVisible(bool visible); void setSearchVisible(bool visible); - void showSearchWidget(); void syncContents(); void activateCurrentCentralWidgetTab(); void currentFilterChanged(const QString &filter); @@ -96,14 +98,12 @@ private slots: void showContents(); void showIndex(); void showSearch(); + void showOpenPages(); void insertLastPages(); void gotoAddress(); void showPreferences(); void showNewAddress(); void showAboutDialog(); - void copyAvailable(bool yes); - void updateNavigationItems(); - void updateTabCloseAction(); void showNewAddress(const QUrl &url); void showTopicChooser(const QMap<QString, QUrl> &links, const QString &keyword); void updateApplicationFont(); @@ -144,20 +144,13 @@ private: CentralWidget *m_centralWidget; IndexWindow *m_indexWindow; ContentWindow *m_contentWindow; + SearchWidget *m_searchWindow; QLineEdit *m_addressLineEdit; QComboBox *m_filterCombo; - QAction *m_backAction; - QAction *m_nextAction; - QAction *m_homeAction; QAction *m_syncAction; - QAction *m_copyAction; - QAction *m_findAction; - QAction *m_printAction; QAction *m_printPreviewAction; QAction *m_pageSetupAction; - QAction *m_zoomInAction; - QAction *m_zoomOutAction; QAction *m_resetZoomAction; QAction *m_aboutAction; QAction *m_closeTabAction; diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp new file mode 100644 index 0000000..272d9e2 --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesmanager.cpp @@ -0,0 +1,378 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "openpagesmanager.h" + +#include "centralwidget.h" +#include "helpenginewrapper.h" +#include "helpviewer.h" +#include "openpagesmodel.h" +#include "openpagesswitcher.h" +#include "openpageswidget.h" +#include "tracer.h" +#include "../shared/collectionconfiguration.h" + +#include <QtGui/QApplication> +#include <QtGui/QTreeView> + +QT_BEGIN_NAMESPACE + +OpenPagesManager *OpenPagesManager::m_instance = 0; + +OpenPagesManager *OpenPagesManager::createInstance(QObject *parent, + bool defaultCollection, const QUrl &cmdLineUrl) +{ + TRACE_OBJ + Q_ASSERT(!m_instance); + m_instance = new OpenPagesManager(parent, defaultCollection, cmdLineUrl); + return m_instance; +} + +OpenPagesManager *OpenPagesManager::instance() +{ + TRACE_OBJ + Q_ASSERT(m_instance); + return m_instance; +} + +OpenPagesManager::OpenPagesManager(QObject *parent, bool defaultCollection, + const QUrl &cmdLineUrl) + : QObject(parent) + , m_model(new OpenPagesModel(this)) + , m_openPagesWidget(0) + , m_openPagesSwitcher(0) +{ + TRACE_OBJ + m_openPagesWidget = new OpenPagesWidget(m_model); + m_openPagesWidget->setFrameStyle(QFrame::NoFrame); + connect(m_openPagesWidget, SIGNAL(setCurrentPage(QModelIndex)), this, + SLOT(setCurrentPage(QModelIndex))); + connect(m_openPagesWidget, SIGNAL(closePage(QModelIndex)), this, + SLOT(closePage(QModelIndex))); + connect(m_openPagesWidget, SIGNAL(closePagesExcept(QModelIndex)), this, + SLOT(closePagesExcept(QModelIndex))); + + m_openPagesSwitcher = new OpenPagesSwitcher(m_model); + connect(m_openPagesSwitcher, SIGNAL(closePage(QModelIndex)), this, + SLOT(closePage(QModelIndex))); + connect(m_openPagesSwitcher, SIGNAL(setCurrentPage(QModelIndex)), this, + SLOT(setCurrentPage(QModelIndex))); + + setupInitialPages(defaultCollection, cmdLineUrl); +} + +OpenPagesManager ::~OpenPagesManager() +{ + TRACE_OBJ + m_instance = 0; + delete m_openPagesSwitcher; +} + +int OpenPagesManager::pageCount() const +{ + TRACE_OBJ + return m_model->rowCount(); +} + +void OpenPagesManager::setupInitialPages(bool defaultCollection, + const QUrl &cmdLineUrl) +{ + TRACE_OBJ + if (cmdLineUrl.isValid()) { + createPage(cmdLineUrl); + return; + } + + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + int initialPage = 0; + switch (helpEngine.startOption()) { + case ShowHomePage: + m_model->addPage(helpEngine.homePage()); + break; + case ShowBlankPage: + m_model->addPage(QUrl(QLatin1String("about:blank"))); + break; + case ShowLastPages: { + const QStringList &lastShownPageList = helpEngine.lastShownPages(); + const int pageCount = lastShownPageList.count(); + if (pageCount == 0) { + if (defaultCollection) + m_model->addPage(QUrl(QLatin1String("help"))); + else + m_model->addPage(QUrl(QLatin1String("about:blank"))); + } else { + QStringList zoomFactors = helpEngine.lastZoomFactors(); + while (zoomFactors.count() < pageCount) + zoomFactors.append(CollectionConfiguration::DefaultZoomFactor); + initialPage = helpEngine.lastTabPage(); + if (initialPage >= pageCount) { + qWarning("Initial page set to %d, maximum possible value is %d", + initialPage, pageCount - 1); + initialPage = 0; + } + for (int curPage = 0; curPage < pageCount; ++curPage) { + const QString &curFile = lastShownPageList.at(curPage); + if (helpEngine.findFile(curFile).isValid() + || curFile == QLatin1String("about:blank")) { + m_model->addPage(curFile, zoomFactors.at(curPage).toFloat()); + } else if (curPage <= initialPage && initialPage > 0) + --initialPage; + } + } + break; + } + default: + Q_ASSERT(!"Unhandled option"); + } + + if (m_model->rowCount() == 0) + m_model->addPage(helpEngine.homePage()); + for (int i = 0; i < m_model->rowCount(); ++i) + CentralWidget::instance()->addPage(m_model->pageAt(i)); + setCurrentPage((initialPage >= m_model->rowCount()) + ? m_model->rowCount() - 1 : initialPage); + m_openPagesSwitcher->selectCurrentPage(); +} + +HelpViewer *OpenPagesManager::createPage() +{ + TRACE_OBJ + return createPage(QUrl(QLatin1String("about:blank"))); +} + +void OpenPagesManager::closeCurrentPage() +{ + TRACE_OBJ + Q_ASSERT(m_model->rowCount() > 1); + const QModelIndexList selectedIndexes + = m_openPagesWidget->selectionModel()->selectedRows(); + if (selectedIndexes.isEmpty()) + return; + Q_ASSERT(selectedIndexes.count() == 1); + removePage(selectedIndexes.first().row()); +} + +HelpViewer *OpenPagesManager::createPage(const QUrl &url, bool fromSearch) +{ + TRACE_OBJ + if (HelpViewer::launchWithExternalApp(url)) + return 0; + + m_model->addPage(url); + const int index = m_model->rowCount() - 1; + HelpViewer * const page = m_model->pageAt(index); + CentralWidget::instance()->addPage(page, fromSearch); + setCurrentPage(index); + return page; +} + +HelpViewer *OpenPagesManager::createNewPageFromSearch(const QUrl &url) +{ + TRACE_OBJ + 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 + if (index.isValid()) + removePage(index.row()); +} + +void OpenPagesManager::closePages(const QString &nameSpace) +{ + TRACE_OBJ + closeOrReloadPages(nameSpace, false); +} + +void OpenPagesManager::reloadPages(const QString &nameSpace) +{ + TRACE_OBJ + closeOrReloadPages(nameSpace, true); + m_openPagesWidget->selectCurrentPage(); +} + +void OpenPagesManager::closeOrReloadPages(const QString &nameSpace, bool tryReload) +{ + TRACE_OBJ + for (int i = m_model->rowCount() - 1; i >= 0; --i) { + HelpViewer *page = m_model->pageAt(i); + if (page->source().host() != nameSpace) + continue; + if (tryReload && HelpEngineWrapper::instance().findFile(page->source()).isValid()) + page->reload(); + else if (m_model->rowCount() == 1) + page->setSource(QUrl(QLatin1String("about:blank"))); + else + removePage(i); + } +} + +bool OpenPagesManager::pagesOpenForNamespace(const QString &nameSpace) const +{ + TRACE_OBJ + for (int i = 0; i < m_model->rowCount(); ++i) + if (m_model->pageAt(i)->source().host() == nameSpace) + return true; + return false; +} + +void OpenPagesManager::setCurrentPage(const QModelIndex &index) +{ + TRACE_OBJ + if (index.isValid()) + setCurrentPage(index.row()); +} + +void OpenPagesManager::setCurrentPage(int index) +{ + TRACE_OBJ + setCurrentPage(m_model->pageAt(index)); +} + +void OpenPagesManager::setCurrentPage(HelpViewer *page) +{ + TRACE_OBJ + CentralWidget::instance()->setCurrentPage(page); + m_openPagesWidget->selectCurrentPage(); +} + +void OpenPagesManager::removePage(int index) +{ + TRACE_OBJ + CentralWidget::instance()->removePage(index); + m_model->removePage(index); + m_openPagesWidget->selectCurrentPage(); +} + + +void OpenPagesManager::closePagesExcept(const QModelIndex &index) +{ + TRACE_OBJ + if (!index.isValid()) + return; + + int i = 0; + HelpViewer *viewer = m_model->pageAt(index.row()); + while (m_model->rowCount() > 1) { + if (m_model->pageAt(i) != viewer) + removePage(i); + else + ++i; + } +} + +QAbstractItemView *OpenPagesManager::openPagesWidget() const +{ + TRACE_OBJ + return m_openPagesWidget; +} + +void OpenPagesManager::nextPage() +{ + TRACE_OBJ + nextOrPreviousPage(1); +} + +void OpenPagesManager::nextPageWithSwitcher() +{ + TRACE_OBJ + if (!m_openPagesSwitcher->isVisible()) { + m_openPagesSwitcher->selectCurrentPage(); + m_openPagesSwitcher->gotoNextPage(); + showSwitcherOrSelectPage(); + } else { + m_openPagesSwitcher->gotoNextPage(); + } +} + +void OpenPagesManager::previousPage() +{ + TRACE_OBJ + nextOrPreviousPage(-1); +} + +void OpenPagesManager::previousPageWithSwitcher() +{ + TRACE_OBJ + if (!m_openPagesSwitcher->isVisible()) { + m_openPagesSwitcher->selectCurrentPage(); + m_openPagesSwitcher->gotoPreviousPage(); + showSwitcherOrSelectPage(); + } else { + m_openPagesSwitcher->gotoPreviousPage(); + } +} + +void OpenPagesManager::nextOrPreviousPage(int offset) +{ + TRACE_OBJ + setCurrentPage((CentralWidget::instance()->currentIndex() + offset + + m_model->rowCount()) % m_model->rowCount()); +} + +void OpenPagesManager::showSwitcherOrSelectPage() const +{ + TRACE_OBJ + if (QApplication::keyboardModifiers() != Qt::NoModifier) { + const int width = CentralWidget::instance()->width(); + const int height = CentralWidget::instance()->height(); + const QPoint p(CentralWidget::instance()->mapToGlobal(QPoint(0, 0))); + m_openPagesSwitcher->move((width - m_openPagesSwitcher->width()) / 2 + p.x(), + (height - m_openPagesSwitcher->height()) / 2 + p.y()); + m_openPagesSwitcher->setVisible(true); + } else { + m_openPagesSwitcher->selectAndHide(); + } +} + +QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/openpagesmanager.h b/tools/assistant/tools/assistant/openpagesmanager.h new file mode 100644 index 0000000..c34686c --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesmanager.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 OPENPAGESMANAGER_H +#define OPENPAGESMANAGER_H + +#include <QtCore/QObject> + +QT_BEGIN_NAMESPACE + +class QAbstractItemView; +class QModelIndex; +class QUrl; + +class HelpViewer; +class OpenPagesModel; +class OpenPagesSwitcher; +class OpenPagesWidget; + +class OpenPagesManager : public QObject +{ + Q_OBJECT +public: + static OpenPagesManager *createInstance(QObject *parent, + bool defaultCollection, const QUrl &cmdLineUrl); + static OpenPagesManager *instance(); + + bool pagesOpenForNamespace(const QString &nameSpace) const; + void closePages(const QString &nameSpace); + void reloadPages(const QString &nameSpace); + + QAbstractItemView* openPagesWidget() const; + + int pageCount() const; + void setCurrentPage(int index); + +public slots: + HelpViewer *createPage(const QUrl &url, bool fromSearch = false); + HelpViewer *createNewPageFromSearch(const QUrl &url); + HelpViewer *createPage(); + void closeCurrentPage(); + + void nextPage(); + void nextPageWithSwitcher(); + void previousPage(); + void previousPageWithSwitcher(); + + void closePage(HelpViewer *page); + void setCurrentPage(HelpViewer *page); + +private slots: + void setCurrentPage(const QModelIndex &index); + void closePage(const QModelIndex &index); + void closePagesExcept(const QModelIndex &index); + +private: + OpenPagesManager(QObject *parent, bool defaultCollection, + const QUrl &cmdLineUrl); + ~OpenPagesManager(); + + void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl); + void closeOrReloadPages(const QString &nameSpace, bool tryReload); + void removePage(int index); + + void nextOrPreviousPage(int offset); + void showSwitcherOrSelectPage() const; + + OpenPagesModel *m_model; + OpenPagesWidget *m_openPagesWidget; + OpenPagesSwitcher *m_openPagesSwitcher; + + static OpenPagesManager *m_instance; +}; + +QT_END_NAMESPACE + +#endif // OPENPAGESMANAGER_H diff --git a/tools/assistant/tools/assistant/openpagesmodel.cpp b/tools/assistant/tools/assistant/openpagesmodel.cpp new file mode 100644 index 0000000..3517693 --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesmodel.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "openpagesmodel.h" + +#include "helpenginewrapper.h" +#include "helpviewer.h" +#include "tracer.h" + +#include <QtCore/QStringList> +#include <QtCore/QUrl> + +QT_BEGIN_NAMESPACE + +OpenPagesModel::OpenPagesModel(QObject *parent) : QAbstractTableModel(parent) +{ + TRACE_OBJ +} + +int OpenPagesModel::rowCount(const QModelIndex &parent) const +{ + TRACE_OBJ + return parent.isValid() ? 0 : m_pages.count(); +} + +int OpenPagesModel::columnCount(const QModelIndex &/*parent*/) const +{ + TRACE_OBJ + return 2; +} + +QVariant OpenPagesModel::data(const QModelIndex &index, int role) const +{ + TRACE_OBJ + if (!index.isValid() || index.row() >= rowCount() || index.column() > 0 + || role != Qt::DisplayRole) + return QVariant(); + QString title = m_pages.at(index.row())->title(); + title.replace(QLatin1Char('&'), QLatin1String("&&")); + return title.isEmpty() ? QLatin1String("(Untitled)") : title; +} + +void OpenPagesModel::addPage(const QUrl &url, qreal zoom) +{ + TRACE_OBJ + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + HelpViewer *page = new HelpViewer(zoom); + connect(page, SIGNAL(titleChanged()), this, SLOT(handleTitleChanged())); + m_pages << page; + endInsertRows(); + page->setSource(url); +} + +void OpenPagesModel::removePage(int index) +{ + TRACE_OBJ + Q_ASSERT(index >= 0 && index < rowCount()); + beginRemoveRows(QModelIndex(), index, index); + HelpViewer *page = m_pages.at(index); + m_pages.removeAt(index); + endRemoveRows(); + page->deleteLater(); +} + +HelpViewer *OpenPagesModel::pageAt(int index) const +{ + TRACE_OBJ + Q_ASSERT(index >= 0 && index < rowCount()); + return m_pages.at(index); +} + +void OpenPagesModel::handleTitleChanged() +{ + TRACE_OBJ + HelpViewer *page = static_cast<HelpViewer *>(sender()); + const int row = m_pages.indexOf(page); + Q_ASSERT(row != -1 ); + const QModelIndex &item = index(row, 0); + emit dataChanged(item, item); +} + +QT_END_NAMESPACE diff --git a/tools/qtconfig/previewwidgetbase.h b/tools/assistant/tools/assistant/openpagesmodel.h index 624e612..dd28a7c 100644 --- a/tools/qtconfig/previewwidgetbase.h +++ b/tools/assistant/tools/assistant/openpagesmodel.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the tools applications of the Qt Toolkit. +** This file is part of the Assistant module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,30 +39,38 @@ ** ****************************************************************************/ -#ifndef PREVIEWWIDGETBASE_H -#define PREVIEWWIDGETBASE_H +#ifndef OPENPAGESMODEL_H +#define OPENPAGESMODEL_H -#include "ui_previewwidgetbase.h" -#include <QVariant> +#include <QtCore/QAbstractTableModel> +#include <QtCore/QList> QT_BEGIN_NAMESPACE -class PreviewWidgetBase : public QWidget, public Ui::PreviewWidgetBase +class HelpViewer; +class QUrl; + +class OpenPagesModel : public QAbstractTableModel { Q_OBJECT - public: - PreviewWidgetBase(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = 0); - ~PreviewWidgetBase(); + OpenPagesModel(QObject *parent); + + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; + virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; -protected slots: - virtual void languageChange(); + void addPage(const QUrl &url, qreal zoom = 0); + void removePage(int index); + HelpViewer *pageAt(int index) const; - virtual void init(); - virtual void destroy(); +private slots: + void handleTitleChanged(); +private: + QList<HelpViewer *> m_pages; }; QT_END_NAMESPACE -#endif // PREVIEWWIDGETBASE_H +#endif // OPENPAGESMODEL_H diff --git a/tools/assistant/tools/assistant/openpagesswitcher.cpp b/tools/assistant/tools/assistant/openpagesswitcher.cpp new file mode 100644 index 0000000..8e7f29b --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesswitcher.cpp @@ -0,0 +1,194 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "openpagesswitcher.h" + +#include "centralwidget.h" +#include "openpagesmodel.h" +#include "openpageswidget.h" +#include "tracer.h" + +#include <QtCore/QEvent> + +#include <QtGui/QKeyEvent> +#include <QtGui/QVBoxLayout> + +QT_BEGIN_NAMESPACE + +const int gWidth = 300; +const int gHeight = 200; + +OpenPagesSwitcher::OpenPagesSwitcher(OpenPagesModel *model) + : QFrame(0, Qt::Popup) + , m_openPagesModel(model) +{ + TRACE_OBJ + resize(gWidth, gHeight); + + m_openPagesWidget = new OpenPagesWidget(m_openPagesModel); + + // We disable the frame on this list view and use a QFrame around it instead. + // This improves the look with QGTKStyle. +#ifndef Q_WS_MAC + setFrameStyle(m_openPagesWidget->frameStyle()); +#endif + m_openPagesWidget->setFrameStyle(QFrame::NoFrame); + + m_openPagesWidget->allowContextMenu(false); + m_openPagesWidget->installEventFilter(this); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->addWidget(m_openPagesWidget); + + connect(m_openPagesWidget, SIGNAL(closePage(QModelIndex)), this, + SIGNAL(closePage(QModelIndex))); + connect(m_openPagesWidget, SIGNAL(setCurrentPage(QModelIndex)), this, + SIGNAL(setCurrentPage(QModelIndex))); +} + +OpenPagesSwitcher::~OpenPagesSwitcher() +{ + TRACE_OBJ +} + +void OpenPagesSwitcher::gotoNextPage() +{ + TRACE_OBJ + selectPageUpDown(1); +} + +void OpenPagesSwitcher::gotoPreviousPage() +{ + TRACE_OBJ + selectPageUpDown(-1); +} + +void OpenPagesSwitcher::selectAndHide() +{ + TRACE_OBJ + setVisible(false); + emit setCurrentPage(m_openPagesWidget->currentIndex()); +} + +void OpenPagesSwitcher::selectCurrentPage() +{ + TRACE_OBJ + m_openPagesWidget->selectCurrentPage(); +} + +void OpenPagesSwitcher::setVisible(bool visible) +{ + TRACE_OBJ + QWidget::setVisible(visible); + if (visible) + setFocus(); +} + +void OpenPagesSwitcher::focusInEvent(QFocusEvent *event) +{ + TRACE_OBJ + Q_UNUSED(event) + m_openPagesWidget->setFocus(); +} + +bool OpenPagesSwitcher::eventFilter(QObject *object, QEvent *event) +{ + TRACE_OBJ + if (object == m_openPagesWidget) { + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = static_cast<QKeyEvent*>(event); + if (ke->key() == Qt::Key_Escape) { + setVisible(false); + return true; + } + + const int key = ke->key(); + if (key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Space) { + emit setCurrentPage(m_openPagesWidget->currentIndex()); + return true; + } + + Qt::KeyboardModifier modifier = Qt::ControlModifier; +#ifdef Q_WS_MAC + modifier = Qt::AltModifier; +#endif + if (key == Qt::Key_Backtab + && (ke->modifiers() == (modifier | Qt::ShiftModifier))) + gotoPreviousPage(); + else if (key == Qt::Key_Tab && (ke->modifiers() == modifier)) + gotoNextPage(); + } else if (event->type() == QEvent::KeyRelease) { + QKeyEvent *ke = static_cast<QKeyEvent*>(event); + if (ke->modifiers() == 0 + /*HACK this is to overcome some event inconsistencies between platforms*/ + || (ke->modifiers() == Qt::AltModifier + && (ke->key() == Qt::Key_Alt || ke->key() == -1))) { + selectAndHide(); + } + } + } + return QWidget::eventFilter(object, event); +} + +void OpenPagesSwitcher::selectPageUpDown(int summand) +{ + TRACE_OBJ + const int pageCount = m_openPagesModel->rowCount(); + if (pageCount < 2) + return; + + const QModelIndexList &list = m_openPagesWidget->selectionModel()->selectedIndexes(); + if (list.isEmpty()) + return; + + QModelIndex index = list.first(); + if (!index.isValid()) + return; + + index = m_openPagesModel->index((index.row() + summand + pageCount) % pageCount, 0); + if (index.isValid()) { + m_openPagesWidget->setCurrentIndex(index); + m_openPagesWidget->scrollTo(index, QAbstractItemView::PositionAtCenter); + } +} + +QT_END_NAMESPACE diff --git a/tools/qtconfig/previewwidgetbase.cpp b/tools/assistant/tools/assistant/openpagesswitcher.h index c156c32..80c7e96 100644 --- a/tools/qtconfig/previewwidgetbase.cpp +++ b/tools/assistant/tools/assistant/openpagesswitcher.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the tools applications of the Qt Toolkit. +** This file is part of the Assistant module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,50 +39,47 @@ ** ****************************************************************************/ -#include "previewwidgetbase.h" +#ifndef OPENPAGESSWITCHER_H +#define OPENPAGESSWITCHER_H -#include <QVariant> +#include <QtGui/QFrame> QT_BEGIN_NAMESPACE -/* - * Constructs a PreviewWidgetBase as a child of 'parent', with the - * name 'name' and widget flags set to 'f'. - */ -PreviewWidgetBase::PreviewWidgetBase(QWidget* parent, const char* name, Qt::WindowFlags fl) - : QWidget(parent, name, fl) +class OpenPagesModel; +class OpenPagesWidget; +class QModelIndex; + +class OpenPagesSwitcher : public QFrame { - setupUi(this); + Q_OBJECT +public: + OpenPagesSwitcher(OpenPagesModel *model); + ~OpenPagesSwitcher(); - // signals and slots connections - init(); -} + void gotoNextPage(); + void gotoPreviousPage(); -/* - * Destroys the object and frees any allocated resources - */ -PreviewWidgetBase::~PreviewWidgetBase() -{ - destroy(); - // no need to delete child widgets, Qt does it all for us -} + void selectAndHide(); + void selectCurrentPage(); -/* - * Sets the strings of the subwidgets using the current - * language. - */ -void PreviewWidgetBase::languageChange() -{ - retranslateUi(this); -} + void setVisible(bool visible); + void focusInEvent(QFocusEvent *event); + bool eventFilter(QObject *object, QEvent *event); -void PreviewWidgetBase::init() -{ -} +signals: + void closePage(const QModelIndex &index); + void setCurrentPage(const QModelIndex &index); -void PreviewWidgetBase::destroy() -{ -} +private: + void selectPageUpDown(int summand); + +private: + OpenPagesModel *m_openPagesModel; + OpenPagesWidget *m_openPagesWidget; +}; QT_END_NAMESPACE + +#endif // OPENPAGESSWITCHER_H diff --git a/tools/assistant/tools/assistant/openpageswidget.cpp b/tools/assistant/tools/assistant/openpageswidget.cpp new file mode 100644 index 0000000..db03712 --- /dev/null +++ b/tools/assistant/tools/assistant/openpageswidget.cpp @@ -0,0 +1,237 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 "openpageswidget.h" + +#include "centralwidget.h" +#include "openpagesmodel.h" +#include "tracer.h" + +#include <QtGui/QApplication> +#include <QtGui/QHeaderView> +#include <QtGui/QKeyEvent> +#include <QtGui/QMouseEvent> +#include <QtGui/QMenu> +#include <QtGui/QPainter> + +#ifdef Q_WS_MAC +#include <qmacstyle_mac.h> +#endif + +QT_BEGIN_NAMESPACE + +OpenPagesDelegate::OpenPagesDelegate(QObject *parent) + : QStyledItemDelegate(parent) +{ + TRACE_OBJ +} + +void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + TRACE_OBJ + if (option.state & QStyle::State_MouseOver) { + if ((QApplication::mouseButtons() & Qt::LeftButton) == 0) + pressedIndex = QModelIndex(); + QBrush brush = option.palette.alternateBase(); + if (index == pressedIndex) + brush = option.palette.dark(); + painter->fillRect(option.rect, brush); + } + + QStyledItemDelegate::paint(painter, option, index); + + if (index.column() == 1 && index.model()->rowCount() > 1 + && option.state & QStyle::State_MouseOver) { + QIcon icon((option.state & QStyle::State_Selected) + ? ":/trolltech/assistant/images/closebutton.png" + : ":/trolltech/assistant/images/darkclosebutton.png"); + + const QRect iconRect(option.rect.right() - option.rect.height(), + option.rect.top(), option.rect.height(), option.rect.height()); + icon.paint(painter, iconRect, Qt::AlignRight | Qt::AlignVCenter); + } +} + +// -- OpenPagesWidget + +OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model) + : m_allowContextMenu(true) +{ + TRACE_OBJ + setModel(model); + setIndentation(0); + setItemDelegate((m_delegate = new OpenPagesDelegate(this))); + + setTextElideMode(Qt::ElideMiddle); + setAttribute(Qt::WA_MacShowFocusRect, false); + + viewport()->setAttribute(Qt::WA_Hover); + setSelectionBehavior(QAbstractItemView::SelectRows); + setSelectionMode(QAbstractItemView::SingleSelection); + + header()->hide(); + header()->setStretchLastSection(false); + header()->setResizeMode(0, QHeaderView::Stretch); + header()->setResizeMode(1, QHeaderView::Fixed); + header()->resizeSection(1, 18); + + installEventFilter(this); + setUniformRowHeights(true); + setContextMenuPolicy(Qt::CustomContextMenu); + + connect(this, SIGNAL(clicked(QModelIndex)), this, + SLOT(handleClicked(QModelIndex))); + connect(this, SIGNAL(pressed(QModelIndex)), this, + SLOT(handlePressed(QModelIndex))); + connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, + SLOT(contextMenuRequested(QPoint))); +} + +OpenPagesWidget::~OpenPagesWidget() +{ + TRACE_OBJ +} + +void OpenPagesWidget::selectCurrentPage() +{ + TRACE_OBJ + const QModelIndex ¤t = + model()->index(CentralWidget::instance()->currentIndex(), 0); + + QItemSelectionModel * const selModel = selectionModel(); + selModel->select(current, + QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + selModel->clearSelection(); + + setCurrentIndex(current); + scrollTo(currentIndex()); +} + +void OpenPagesWidget::allowContextMenu(bool ok) +{ + TRACE_OBJ + m_allowContextMenu = ok; +} + +void OpenPagesWidget::contextMenuRequested(QPoint pos) +{ + TRACE_OBJ + QModelIndex index = indexAt(pos); + if (!index.isValid() || !m_allowContextMenu) + return; + + if (index.column() == 1) + index = index.sibling(index.row(), 0); + QMenu contextMenu; + QAction *closeEditor = contextMenu.addAction(tr("Close %1").arg(index.data() + .toString())); + QAction *closeOtherEditors = contextMenu.addAction(tr("Close All Except %1") + .arg(index.data().toString())); + + if (model()->rowCount() == 1) { + closeEditor->setEnabled(false); + closeOtherEditors->setEnabled(false); + } + + QAction *action = contextMenu.exec(mapToGlobal(pos)); + if (action == closeEditor) + emit closePage(index); + else if (action == closeOtherEditors) + emit closePagesExcept(index); +} + +void OpenPagesWidget::handlePressed(const QModelIndex &index) +{ + TRACE_OBJ + if (index.column() == 0) + emit setCurrentPage(index); + + if (index.column() == 1) + m_delegate->pressedIndex = index; +} + +void OpenPagesWidget::handleClicked(const QModelIndex &index) +{ + TRACE_OBJ + // implemented here to handle the funky close button and to work around a + // bug in item views where the delegate wouldn't get the QStyle::State_MouseOver + if (index.column() == 1) { + if (model()->rowCount() > 1) + emit closePage(index); + + QWidget *vp = viewport(); + const QPoint &cursorPos = QCursor::pos(); + QMouseEvent e(QEvent::MouseMove, vp->mapFromGlobal(cursorPos), cursorPos, + Qt::NoButton, 0, 0); + QCoreApplication::sendEvent(vp, &e); + } +} + +bool OpenPagesWidget::eventFilter(QObject *obj, QEvent *event) +{ + TRACE_OBJ + if (obj != this) + return QWidget::eventFilter(obj, event); + + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = static_cast<QKeyEvent*>(event); + if (currentIndex().isValid() && ke->modifiers() == 0) { + const int key = ke->key(); + if (key == Qt::Key_Return || key == Qt::Key_Enter + || key == Qt::Key_Space) { + emit setCurrentPage(currentIndex()); + } else if ((key == Qt::Key_Delete || key == Qt::Key_Backspace) + && model()->rowCount() > 1) { + emit closePage(currentIndex()); + } + } + } else if (event->type() == QEvent::KeyRelease) { + QKeyEvent *ke = static_cast<QKeyEvent*>(event); + if (ke->modifiers() == 0 + && (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down)) { + emit setCurrentPage(currentIndex()); + } + } + return QWidget::eventFilter(obj, event); +} + +QT_END_NAMESPACE diff --git a/tools/qtconfig/paletteeditoradvancedbase.h b/tools/assistant/tools/assistant/openpageswidget.h index c097382..6041fe2 100644 --- a/tools/qtconfig/paletteeditoradvancedbase.h +++ b/tools/assistant/tools/assistant/openpageswidget.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the tools applications of the Qt Toolkit. +** This file is part of the Assistant module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,40 +39,54 @@ ** ****************************************************************************/ -#ifndef PALETTEEDITORADVANCEDBASE_H -#define PALETTEEDITORADVANCEDBASE_H +#ifndef OPENPAGESWIDGET_H +#define OPENPAGESWIDGET_H -#include "ui_paletteeditoradvancedbase.h" -#include <QVariant> +#include <QtGui/QStyledItemDelegate> +#include <QtGui/QTreeView> QT_BEGIN_NAMESPACE -class ColorButton; +class OpenPagesModel; -class PaletteEditorAdvancedBase : public QDialog, public Ui::PaletteEditorAdvancedBase +class OpenPagesDelegate : public QStyledItemDelegate { Q_OBJECT +public: + explicit OpenPagesDelegate(QObject *parent = 0); + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + + mutable QModelIndex pressedIndex; +}; +class OpenPagesWidget : public QTreeView +{ + Q_OBJECT public: - PaletteEditorAdvancedBase(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0); - ~PaletteEditorAdvancedBase(); + OpenPagesWidget(OpenPagesModel *model); + ~OpenPagesWidget(); + + void selectCurrentPage(); + void allowContextMenu(bool ok); + +signals: + void setCurrentPage(const QModelIndex &index); + void closePage(const QModelIndex &index); + void closePagesExcept(const QModelIndex &index); -protected slots: - virtual void languageChange(); +private slots: + void contextMenuRequested(QPoint pos); + void handlePressed(const QModelIndex &index); + void handleClicked(const QModelIndex &index); - virtual void init(); - virtual void destroy(); - virtual void onCentral(int); - virtual void onChooseCentralColor(); - virtual void onChooseEffectColor(); - virtual void onEffect(int); - virtual void onToggleBuildDisabled(bool); - virtual void onToggleBuildEffects(bool); - virtual void onToggleBuildInactive(bool); - virtual void paletteSelected(int); +private: + bool eventFilter(QObject *obj, QEvent *event); + bool m_allowContextMenu; + OpenPagesDelegate *m_delegate; }; QT_END_NAMESPACE -#endif // PALETTEEDITORADVANCEDBASE_H +#endif // OPENPAGESWIDGET_H diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index 731a75c..9bfd35c 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.cpp +++ b/tools/assistant/tools/assistant/preferencesdialog.cpp @@ -45,6 +45,7 @@ #include "fontpanel.h" #include "helpenginewrapper.h" #include "installdialog.h" +#include "openpagesmanager.h" #include "tracer.h" #include <QtCore/QtAlgorithms> @@ -302,15 +303,12 @@ void PreferencesDialog::addDocumentationLocal() void PreferencesDialog::removeDocumentation() { TRACE_OBJ - bool foundBefore = false; - CentralWidget* widget = CentralWidget::instance(); - QMap<int, QString> openedDocList = widget->currentSourceFileList(); - QStringList values(openedDocList.values()); + bool foundBefore = false; QList<QListWidgetItem*> l = m_ui.registeredDocsListWidget->selectedItems(); foreach (QListWidgetItem* item, l) { const QString& ns = item->text(); - if (!foundBefore && values.contains(ns)) { + if (!foundBefore && OpenPagesManager::instance()->pagesOpenForNamespace(ns)) { if (0 == QMessageBox::information(this, tr("Remove Documentation"), tr("Some documents currently opened in Assistant reference the " "documentation you are attempting to remove. Removing the " @@ -320,7 +318,6 @@ void PreferencesDialog::removeDocumentation() } m_unregDocs.append(ns); - m_TabsToClose += openedDocList.keys(ns); delete m_ui.registeredDocsListWidget->takeItem( m_ui.registeredDocsListWidget->row(item)); } @@ -374,14 +371,18 @@ void PreferencesDialog::applyChanges() } } - CentralWidget::instance()->closeOrReloadTabs(m_TabsToClose, false); - - foreach (const QString &doc, m_unregDocs) + foreach (const QString &doc, m_unregDocs) { + OpenPagesManager::instance()->closePages(doc); helpEngine.unregisterDocumentation(doc); + } 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(); } @@ -424,13 +425,13 @@ void PreferencesDialog::updateFontSettingsPage() connect(m_browserFontPanel, SIGNAL(toggled(bool)), this, SLOT(browserFontSettingToggled(bool))); - QList<QComboBox*> allCombos = qFindChildren<QComboBox*>(m_appFontPanel); + QList<QComboBox*> allCombos = m_appFontPanel->findChildren<QComboBox*>(); foreach (QComboBox* box, allCombos) { connect(box, SIGNAL(currentIndexChanged(int)), this, SLOT(appFontSettingChanged(int))); } - allCombos = qFindChildren<QComboBox*>(m_browserFontPanel); + allCombos = m_browserFontPanel->findChildren<QComboBox*>(); foreach (QComboBox* box, allCombos) { connect(box, SIGNAL(currentIndexChanged(int)), this, SLOT(browserFontSettingChanged(int))); @@ -473,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 373c777..f9b445e 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(); @@ -96,12 +97,12 @@ private: QStringList m_docsBackup; QStringList m_regDocs; QStringList m_unregDocs; - QList<int> m_TabsToClose; FontPanel *m_appFontPanel; FontPanel *m_browserFontPanel; 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 f63d237..5d93fbc 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -38,12 +38,13 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" - #include "remotecontrol.h" -#include "mainwindow.h" + #include "centralwidget.h" #include "helpenginewrapper.h" +#include "mainwindow.h" +#include "openpagesmanager.h" +#include "tracer.h" #include <QtCore/QFile> #include <QtCore/QFileInfo> @@ -57,6 +58,7 @@ #include <QtHelp/QHelpEngine> #include <QtHelp/QHelpIndexWidget> +#include <QtHelp/QHelpSearchQueryWidget> #ifdef Q_OS_WIN # include "remotecontrol_win.h" @@ -259,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(); + } + } } } @@ -323,8 +342,7 @@ void RemoteControl::handleUnregisterCommand(const QString &arg) const QString &absFileName = QFileInfo(arg).absoluteFilePath(); const QString &ns = QHelpEngineCore::namespaceName(absFileName); if (helpEngine.registeredDocumentations().contains(ns)) { - CentralWidget* widget = CentralWidget::instance(); - widget->closeOrReloadTabs(widget->currentSourceFileList().keys(ns), false); + OpenPagesManager::instance()->closePages(ns); if (helpEngine.unregisterDocumentation(ns)) helpEngine.setupData(); } diff --git a/tools/assistant/tools/assistant/searchwidget.cpp b/tools/assistant/tools/assistant/searchwidget.cpp index 763861e..627d9e7 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 @@ -86,7 +85,7 @@ SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent) connect(searchEngine, SIGNAL(searchingFinished(int)), this, SLOT(searchingFinished(int))); - QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); + QTextBrowser* browser = resultWidget->findChild<QTextBrowser*>(); if (browser) // Will be null if lib was configured not to use CLucene. browser->viewport()->installEventFilter(this); } @@ -100,7 +99,7 @@ SearchWidget::~SearchWidget() void SearchWidget::zoomIn() { TRACE_OBJ - QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); + QTextBrowser* browser = resultWidget->findChild<QTextBrowser*>(); if (browser && zoomCount != 10) { zoomCount++; browser->zoomIn(); @@ -110,7 +109,7 @@ void SearchWidget::zoomIn() void SearchWidget::zoomOut() { TRACE_OBJ - QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); + QTextBrowser* browser = resultWidget->findChild<QTextBrowser*>(); if (browser && zoomCount != -5) { zoomCount--; browser->zoomOut(); @@ -123,25 +122,13 @@ void SearchWidget::resetZoom() if (zoomCount == 0) return; - QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); + QTextBrowser* browser = resultWidget->findChild<QTextBrowser*>(); if (browser) { browser->zoomOut(zoomCount); zoomCount = 0; } } -bool SearchWidget::isAttached() const -{ - TRACE_OBJ - return attached; -} - -void SearchWidget::setAttached(bool state) -{ - TRACE_OBJ - attached = state; -} - void SearchWidget::search() const { TRACE_OBJ @@ -165,7 +152,7 @@ void SearchWidget::searchingFinished(int hits) bool SearchWidget::eventFilter(QObject* o, QEvent *e) { TRACE_OBJ - QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); + QTextBrowser* browser = resultWidget->findChild<QTextBrowser*>(); if (browser && o == browser->viewport() && e->type() == QEvent::MouseButtonRelease){ QMouseEvent *me = static_cast<QMouseEvent*>(e); @@ -196,7 +183,7 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent) QMenu menu; QPoint point = contextMenuEvent->globalPos(); - QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget); + QTextBrowser* browser = resultWidget->findChild<QTextBrowser*>(); if (!browser) return; diff --git a/tools/assistant/tools/assistant/searchwidget.h b/tools/assistant/tools/assistant/searchwidget.h index 7c5985d..077c787 100644 --- a/tools/assistant/tools/assistant/searchwidget.h +++ b/tools/assistant/tools/assistant/searchwidget.h @@ -65,9 +65,6 @@ public: 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 605b5de..058d428 100644 --- a/tools/assistant/tools/qcollectiongenerator/main.cpp +++ b/tools/assistant/tools/qcollectiongenerator/main.cpp @@ -97,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(); @@ -125,6 +129,7 @@ private: QStringList m_filesToRegister; QString m_cacheDirectory; bool m_cacheDirRelativeToCollection; + bool m_enableFullTextSearchFallback; }; void CollectionConfigReader::raiseErrorWithLine() @@ -139,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()) { @@ -212,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(); } @@ -513,6 +522,8 @@ 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())); diff --git a/tools/assistant/tools/shared/collectionconfiguration.cpp b/tools/assistant/tools/shared/collectionconfiguration.cpp index 707117c..35d5b66 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 997aac1..226460e 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/configure/configure.pro b/tools/configure/configure.pro index 0a49fbe..1245646 100644 --- a/tools/configure/configure.pro +++ b/tools/configure/configure.pro @@ -48,6 +48,10 @@ HEADERS = configureapp.h environment.h tools.h\ $$QT_SOURCE_TREE/src/corelib/io/qdiriterator.h \ $$QT_SOURCE_TREE/src/corelib/io/qfile.h \ $$QT_SOURCE_TREE/src/corelib/io/qfileinfo.h \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry_p.h \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_p.h \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemmetadata_p.h \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemiterator_p.h \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.h \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator_p.h \ $$QT_SOURCE_TREE/src/corelib/io/qiodevice.h \ @@ -61,6 +65,7 @@ HEADERS = configureapp.h environment.h tools.h\ $$QT_SOURCE_TREE/src/corelib/tools/qstringlist.h \ $$QT_SOURCE_TREE/src/corelib/tools/qstringmatcher.h \ $$QT_SOURCE_TREE/src/corelib/tools/qunicodetables_p.h \ + $$QT_SOURCE_TREE/src/corelib/kernel/qsystemerror_p.h \ $$QT_SOURCE_TREE/src/corelib/xml/qxmlstream.h \ $$QT_SOURCE_TREE/src/corelib/xml/qxmlutils_p.h \ $$QT_SOURCE_TREE/tools/shared/symbian/epocroot_p.h \ @@ -86,9 +91,13 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfile.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfileinfo.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qabstractfileengine.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_win.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemiterator_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator_win.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 \ @@ -103,6 +112,7 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qunicodetables.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qvsnprintf.cpp \ $$QT_SOURCE_TREE/src/corelib/kernel/qvariant.cpp \ + $$QT_SOURCE_TREE/src/corelib/kernel/qsystemerror.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qurl.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qline.cpp \ $$QT_SOURCE_TREE/src/corelib/tools/qsize.cpp \ @@ -115,8 +125,6 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/tools/shared/symbian/epocroot.cpp \ $$QT_SOURCE_TREE/tools/shared/windows/registry.cpp -win32:SOURCES += $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp - DEFINES += COMMERCIAL_VERSION INCLUDEPATH += $$QT_SOURCE_TREE/src/corelib/arch/generic \ diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index be44646..ab19a04 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -281,6 +281,7 @@ Configure::Configure(int& argc, char** argv) dictionary[ "DECLARATIVE" ] = "auto"; dictionary[ "DECLARATIVE_DEBUG" ]= "yes"; dictionary[ "PLUGIN_MANIFESTS" ] = "yes"; + dictionary[ "DIRECTWRITE" ] = "no"; QString version; QFile qglobal_h(sourcePath + "/src/corelib/global/qglobal.h"); @@ -437,6 +438,7 @@ void Configure::parseCmdLine() { int argCount = configCmdLine.size(); int i = 0; + const QStringList imageFormats = QStringList() << "gif" << "png" << "mng" << "jpeg" << "tiff"; #if !defined(EVAL) if (argCount < 1) // skip rest if no arguments @@ -590,8 +592,6 @@ void Configure::parseCmdLine() // Image formats -------------------------------------------- else if (configCmdLine.at(i) == "-no-gif") dictionary[ "GIF" ] = "no"; - else if (configCmdLine.at(i) == "-qt-gif") - dictionary[ "GIF" ] = "plugin"; else if (configCmdLine.at(i) == "-no-libtiff") { dictionary[ "TIFF"] = "no"; @@ -831,6 +831,17 @@ void Configure::parseCmdLine() dictionary[ "SQL_IBASE" ] = "plugin"; else if (configCmdLine.at(i) == "-no-sql-ibase") dictionary[ "SQL_IBASE" ] = "no"; + + // Image formats -------------------------------------------- + else if (configCmdLine.at(i).startsWith("-qt-imageformat-") && + imageFormats.contains(configCmdLine.at(i).section('-', 3))) + dictionary[ configCmdLine.at(i).section('-', 3).toUpper() ] = "yes"; + else if (configCmdLine.at(i).startsWith("-plugin-imageformat-") && + imageFormats.contains(configCmdLine.at(i).section('-', 3))) + dictionary[ configCmdLine.at(i).section('-', 3).toUpper() ] = "plugin"; + else if (configCmdLine.at(i).startsWith("-no-imageformat-") && + imageFormats.contains(configCmdLine.at(i).section('-', 3))) + dictionary[ configCmdLine.at(i).section('-', 3).toUpper() ] = "no"; #endif // IDE project generation ----------------------------------- else if (configCmdLine.at(i) == "-no-dsp") @@ -1219,6 +1230,12 @@ void Configure::parseCmdLine() } } + else if (configCmdLine.at(i) == "-directwrite") { + dictionary["DIRECTWRITE"] = "yes"; + } else if (configCmdLine.at(i) == "-no-directwrite") { + dictionary["DIRECTWRITE"] = "no"; + } + else { dictionary[ "HELP" ] = "yes"; cout << "Unknown option " << configCmdLine.at(i) << endl; @@ -1663,7 +1680,7 @@ bool Configure::displayHelp() "[-no-qmake] [-qmake] [-dont-process] [-process]\n" "[-no-style-<style>] [-qt-style-<style>] [-redo]\n" "[-saveconfig <config>] [-loadconfig <config>]\n" - "[-qt-zlib] [-system-zlib] [-no-gif] [-qt-gif] [-no-libpng]\n" + "[-qt-zlib] [-system-zlib] [-no-gif] [-no-libpng]\n" "[-qt-libpng] [-system-libpng] [-no-libtiff] [-qt-libtiff]\n" "[-system-libtiff] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg]\n" "[-no-libmng] [-qt-libmng] [-system-libmng] [-no-qt3support] [-mmx]\n" @@ -1674,7 +1691,9 @@ 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] [-webkit-debug] [-graphicssystem raster|opengl|openvg]\n\n", 0, 7); + "[-no-webkit] [-webkit] [-webkit-debug]\n" + "[-graphicssystem raster|opengl|openvg]\n" + "[-no-directwrite] [-directwrite]\n\n", 0, 7); desc("Installation options:\n\n"); @@ -1796,7 +1815,6 @@ bool Configure::displayHelp() desc("ZLIB", "system", "-system-zlib", "Use zlib from the operating system.\nSee http://www.gzip.org/zlib\n"); desc("GIF", "no", "-no-gif", "Do not compile GIF reading support."); - desc("GIF", "auto", "-qt-gif", "Compile GIF reading support.\nSee also src/gui/image/qgifhandler_p.h\n"); desc("LIBPNG", "no", "-no-libpng", "Do not compile PNG support."); desc("LIBPNG", "qt", "-qt-libpng", "Use the libpng bundled with Qt."); @@ -1872,6 +1890,8 @@ bool Configure::displayHelp() 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("DIRECTWRITE", "no", "-no-directwrite", "Do not build support for DirectWrite font rendering"); + desc("DIRECTWRITE", "yes", "-directwrite", "Build support for DirectWrite font rendering (experimental, requires DirectWrite availability on target systems, e.g. Windows Vista with Platform Update, Windows 7, etc.)"); desc( "-arch <arch>", "Specify an architecture.\n" "Available values for <arch>:"); @@ -1961,6 +1981,22 @@ QString Configure::findFileInPaths(const QString &fileName, const QString &paths return QString(); } +static QString mingwPaths(const QString &mingwPath, const QString &pathName) +{ + QString ret; + QDir mingwDir = QFileInfo(mingwPath).dir(); + const QFileInfoList subdirs = mingwDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + for (int i = 0 ;i < subdirs.length(); ++i) { + const QFileInfo &fi = subdirs.at(i); + const QString name = fi.fileName(); + if (name == pathName) + ret += fi.absoluteFilePath() + ';'; + else if (name.contains("mingw")) + ret += fi.absoluteFilePath() + QDir::separator() + pathName + ';'; + } + return ret; +} + bool Configure::findFile(const QString &fileName) { const QString file = fileName.toLower(); @@ -1971,18 +2007,22 @@ bool Configure::findFile(const QString &fileName) QString paths; if (file.endsWith(".h")) { if (!mingwPath.isNull()) { - if (!findFileInPaths(file, mingwPath + QLatin1String("/../include")).isNull()) + if (!findFileInPaths(file, mingwPaths(mingwPath, "include")).isNull()) return true; //now let's try the additional compiler path - QDir mingwLibDir = mingwPath + QLatin1String("/../lib/gcc/mingw32"); - foreach(const QFileInfo &version, mingwLibDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) { - if (!findFileInPaths(file, version.absoluteFilePath() + QLatin1String("/include")).isNull()) - return true; + + const QFileInfoList mingwConfigs = QDir(mingwPath + QLatin1String("/../lib/gcc")).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + for (int i = 0; i < mingwConfigs.length(); ++i) { + const QDir mingwLibDir = mingwConfigs.at(i).absoluteFilePath(); + foreach(const QFileInfo &version, mingwLibDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) { + if (!findFileInPaths(file, version.absoluteFilePath() + QLatin1String("/include")).isNull()) + return true; + } } } paths = QString::fromLocal8Bit(getenv("INCLUDE")); } else if (file.endsWith(".lib") || file.endsWith(".a")) { - if (!mingwPath.isNull() && !findFileInPaths(file, mingwPath + QLatin1String("/../lib")).isNull()) + if (!mingwPath.isNull() && !findFileInPaths(file, mingwPaths(mingwPath, "lib")).isNull()) return true; paths = QString::fromLocal8Bit(getenv("LIB")); } else { @@ -2135,13 +2175,8 @@ bool Configure::checkAvailability(const QString &part) else if (part == "INCREDIBUILD_XGE") available = findFile("BuildConsole.exe") && findFile("xgConsole.exe"); else if (part == "XMLPATTERNS") - { - /* MSVC 6.0 and MSVC 2002/7.0 has too poor C++ support for QtXmlPatterns. */ - return dictionary.value("QMAKESPEC") != "win32-msvc" - && dictionary.value("QMAKESPEC") != "win32-msvc.net" // Leave for now, since we can't be sure if they are using 2002 or 2003 with this spec - && dictionary.value("QMAKESPEC") != "win32-msvc2002" - && dictionary.value("EXCEPTIONS") == "yes"; - } else if (part == "PHONON") { + available = dictionary.value("EXCEPTIONS") == "yes"; + else if (part == "PHONON") { if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) { available = true; } else { @@ -2220,6 +2255,8 @@ bool Configure::checkAvailability(const QString &part) available = false; } } + } else if (part == "DIRECTWRITE") { + available = findFile("dwrite.h") && findFile("d2d1.h") && findFile("dwrite.lib"); } return available; @@ -2375,6 +2412,15 @@ bool Configure::verifyConfiguration() dictionary["SCRIPT"] = "yes"; } + if (dictionary["DIRECTWRITE"] == "yes" && !checkAvailability("DIRECTWRITE")) { + cout << "WARNING: To be able to compile the DirectWrite font engine you will" << endl + << "need the Microsoft DirectWrite and Microsoft Direct2D development" << endl + << "files such as headers and libraries." << endl + << "(Press any key to continue..)"; + if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout) + exit(0); // Exit cleanly for Ctrl+C + } + return true; } @@ -2731,6 +2777,9 @@ void Configure::generateOutputVars() qtConfig += "declarative"; } + if (dictionary["DIRECTWRITE"] == "yes") + qtConfig += "directwrite"; + if (dictionary[ "NATIVE_GESTURES" ] == "yes") qtConfig += "native-gestures"; @@ -2962,6 +3011,10 @@ void Configure::generateCachefile() configStream << " def_files_disabled"; } } + + if (dictionary["DIRECTWRITE"] == "yes") + configStream << "directwrite"; + configStream << endl; configStream << "QT_ARCH = " << dictionary[ "ARCHITECTURE" ] << endl; if (dictionary["QT_EDITION"].contains("OPENSOURCE")) @@ -3087,10 +3140,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; @@ -3433,7 +3483,8 @@ void Configure::displayConfig() cout << "QtScript support............" << dictionary[ "SCRIPT" ] << endl; cout << "QtScriptTools support......." << dictionary[ "SCRIPTTOOLS" ] << endl; cout << "Graphics System............." << dictionary[ "GRAPHICS_SYSTEM" ] << endl; - cout << "Qt3 compatibility..........." << dictionary[ "QT3SUPPORT" ] << endl << endl; + cout << "Qt3 compatibility..........." << dictionary[ "QT3SUPPORT" ] << endl; + cout << "DirectWrite support........." << dictionary[ "DIRECTWRITE" ] << endl << endl; cout << "Third Party Libraries:" << endl; cout << " ZLIB support............" << dictionary[ "ZLIB" ] << endl; diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp index 9d1c23a..1885955 100644 --- a/tools/configure/environment.cpp +++ b/tools/configure/environment.cpp @@ -75,8 +75,6 @@ struct CompilerInfo{ {CC_BORLAND, "Borland C++", 0, "bcc32.exe"}, {CC_MINGW, "MinGW (Minimalist GNU for Windows)", 0, "g++.exe"}, {CC_INTEL, "Intel(R) C++ Compiler for 32-bit applications", 0, "icl.exe"}, // xilink.exe, xilink5.exe, xilink6.exe, xilib.exe - {CC_MSVC6, "Microsoft (R) 32-bit C/C++ Optimizing Compiler (6.x)", "Software\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual C++\\ProductDir", "cl.exe"}, // link.exe, lib.exe - {CC_NET2002, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2002 (7.0)", "Software\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir", "cl.exe"}, // link.exe, lib.exe {CC_NET2003, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2003 (7.1)", "Software\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir", "cl.exe"}, // link.exe, lib.exe {CC_NET2005, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2005 (8.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\8.0", "cl.exe"}, // link.exe, lib.exe {CC_NET2008, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2008 (9.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\9.0", "cl.exe"}, // link.exe, lib.exe @@ -118,14 +116,6 @@ QString Environment::detectQMakeSpec() case CC_NET2003: spec = "win32-msvc2003"; break; - case CC_NET2002: - spec = "win32-msvc2002"; - break; - case CC_MSVC4: - case CC_MSVC5: - case CC_MSVC6: - spec = "win32-msvc"; - break; case CC_INTEL: spec = "win32-icc"; break; @@ -152,7 +142,7 @@ QString Environment::detectQMakeSpec() Compiler Environment::detectCompiler() { #ifndef Q_OS_WIN32 - return MSVC6; // Always generate MSVC 6.0 versions on other platforms + return CC_UNKNOWN; // Always generate CC_UNKNOWN on other platforms #else if(detectedCompiler != CC_UNKNOWN) return detectedCompiler; diff --git a/tools/configure/environment.h b/tools/configure/environment.h index 61e97eb..faee63f 100644 --- a/tools/configure/environment.h +++ b/tools/configure/environment.h @@ -50,10 +50,6 @@ enum Compiler { CC_BORLAND = 0x01, CC_MINGW = 0x02, CC_INTEL = 0x03, - CC_MSVC4 = 0x40, - CC_MSVC5 = 0x50, - CC_MSVC6 = 0x60, - CC_NET2002 = 0x70, CC_NET2003 = 0x71, CC_NET2005 = 0x80, CC_NET2008 = 0x90, diff --git a/tools/designer/data/ui4.xsd b/tools/designer/data/ui4.xsd index de4253c..53bae62 100644 --- a/tools/designer/data/ui4.xsd +++ b/tools/designer/data/ui4.xsd @@ -207,6 +207,7 @@ <xs:attribute name="column" type="xs:integer" /> <xs:attribute name="rowspan" type="xs:integer" /> <xs:attribute name="colspan" type="xs:integer" /> + <xs:attribute name="alignment" type="xs:string" /> </xs:complexType> <!-- item view begin --> @@ -414,7 +415,7 @@ <xs:complexType name="StringList"> <xs:sequence> - <xs:element name="string" type="xs:string" maxOccurs="unbounded" /> + <xs:element name="string" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> @@ -434,6 +435,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/buddyeditor/buddyeditor.cpp b/tools/designer/src/components/buddyeditor/buddyeditor.cpp index 0879599..34e1681 100644 --- a/tools/designer/src/components/buddyeditor/buddyeditor.cpp +++ b/tools/designer/src/components/buddyeditor/buddyeditor.cpp @@ -51,6 +51,7 @@ #include <qdesigner_utils_p.h> #include <qlayout_widget_p.h> #include <connectionedit_p.h> +#include <metadatabase_p.h> #include <QtCore/qdebug.h> #include <QtGui/QLabel> @@ -75,7 +76,8 @@ static bool canBeBuddy(QWidget *w, QDesignerFormWindowInterface *form) if (index != -1) { bool ok = false; const Qt::FocusPolicy q = static_cast<Qt::FocusPolicy>(qdesigner_internal::Utils::valueOf(sheet->property(index), &ok)); - return ok && q != Qt::NoFocus; + // Refuse No-focus unless the widget is promoted. + return (ok && q != Qt::NoFocus) || qdesigner_internal::isPromoted(form->core(), w); } } return false; @@ -153,13 +155,13 @@ void BuddyEditor::updateBackground() m_updating = true; QList<Connection *> newList; - const LabelList label_list = qFindChildren<QLabel*>(background()); + const LabelList label_list = background()->findChildren<QLabel*>(); foreach (QLabel *label, label_list) { const QString buddy_name = buddy(label, m_formWindow->core()); if (buddy_name.isEmpty()) continue; - const QList<QWidget *> targets = qFindChildren<QWidget*>(background(), buddy_name); + const QList<QWidget *> targets = background()->findChildren<QWidget*>(buddy_name); if (targets.isEmpty()) continue; @@ -238,12 +240,12 @@ void BuddyEditor::setBackground(QWidget *background) clear(); ConnectionEdit::setBackground(background); - const LabelList label_list = qFindChildren<QLabel*>(background); + const LabelList label_list = background->findChildren<QLabel*>(); foreach (QLabel *label, label_list) { const QString buddy_name = buddy(label, m_formWindow->core()); if (buddy_name.isEmpty()) continue; - QWidget *target = qFindChild<QWidget*>(background, buddy_name); + QWidget *target = background->findChild<QWidget*>(buddy_name); if (target == 0) continue; @@ -297,7 +299,7 @@ void BuddyEditor::endConnection(QWidget *target, const QPoint &pos) void BuddyEditor::widgetRemoved(QWidget *widget) { - QList<QWidget*> child_list = qFindChildren<QWidget*>(widget); + QList<QWidget*> child_list = widget->findChildren<QWidget*>(); child_list.prepend(widget); ConnectionSet remove_set; @@ -354,7 +356,7 @@ void BuddyEditor::deleteSelected() void BuddyEditor::autoBuddy() { // Any labels? - LabelList labelList = qFindChildren<QLabel*>(background()); + LabelList labelList = background()->findChildren<QLabel*>(); if (labelList.empty()) return; // Find already used buddies diff --git a/tools/designer/src/components/formeditor/dpi_chooser.cpp b/tools/designer/src/components/formeditor/dpi_chooser.cpp index 880ddfc..6d665dd 100644 --- a/tools/designer/src/components/formeditor/dpi_chooser.cpp +++ b/tools/designer/src/components/formeditor/dpi_chooser.cpp @@ -97,13 +97,13 @@ DPI_Chooser::DPI_Chooser(QWidget *parent) : m_systemEntry->description = 0; const struct DPI_Entry *systemEntry = m_systemEntry; //: System resolution - m_predefinedCombo->addItem(tr("System (%1 x %2)").arg(m_systemEntry->dpiX).arg(m_systemEntry->dpiY), qVariantFromValue(systemEntry)); + m_predefinedCombo->addItem(tr("System (%1 x %2)").arg(m_systemEntry->dpiX).arg(m_systemEntry->dpiY), QVariant::fromValue(systemEntry)); // Devices. Exclude the system values as not to duplicate the entries const int predefinedCount = sizeof(dpiEntries)/sizeof(DPI_Entry); const struct DPI_Entry *ecend = dpiEntries + predefinedCount; for (const struct DPI_Entry *it = dpiEntries; it < ecend; ++it) if (it->dpiX != m_systemEntry->dpiX || it->dpiY != m_systemEntry->dpiY) - m_predefinedCombo->addItem(tr(it->description), qVariantFromValue(it)); + m_predefinedCombo->addItem(tr(it->description), QVariant::fromValue(it)); m_predefinedCombo->addItem(tr("User defined")); setFocusProxy(m_predefinedCombo); diff --git a/tools/designer/src/components/formeditor/formeditor.qrc b/tools/designer/src/components/formeditor/formeditor.qrc index 42724dd..e42cc66 100644 --- a/tools/designer/src/components/formeditor/formeditor.qrc +++ b/tools/designer/src/components/formeditor/formeditor.qrc @@ -152,6 +152,7 @@ <file>images/win/textjustify.png</file> <file>images/win/textsuperscript.png</file> <file>images/win/textsubscript.png</file> + <file>images/win/simplifyrichtext.png</file> <file>images/win/back.png</file> <file>images/win/forward.png</file> <file>images/win/down.png</file> @@ -166,6 +167,7 @@ <file>images/mac/textjustify.png</file> <file>images/mac/textsuperscript.png</file> <file>images/mac/textsubscript.png</file> + <file>images/mac/simplifyrichtext.png</file> </qresource> <qresource prefix="/trolltech/brushes"> <file>defaultbrushes.xml</file> diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index 540599f..3fb18aa 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -387,7 +387,7 @@ void FormWindow::setCursorToAll(const QCursor &c, QWidget *start) { #ifndef QT_NO_CURSOR start->setCursor(c); - const QWidgetList widgets = qFindChildren<QWidget*>(start); + const QWidgetList widgets = start->findChildren<QWidget*>(); foreach (QWidget *widget, widgets) { if (!qobject_cast<WidgetHandle*>(widget)) { widget->setCursor(c); @@ -945,7 +945,7 @@ bool FormWindow::isMainContainer(const QWidget *w) const void FormWindow::updateChildSelections(QWidget *w) { - const QWidgetList l = qFindChildren<QWidget*>(w); + const QWidgetList l = w->findChildren<QWidget*>(); if (!l.empty()) { const QWidgetList::const_iterator lcend = l.constEnd(); for (QWidgetList::const_iterator it = l.constBegin(); it != lcend; ++it) { @@ -1155,19 +1155,19 @@ bool FormWindow::unify(QObject *w, QString &s, bool changeIt) existingNames.insert(main->objectName()); const QDesignerMetaDataBaseInterface *metaDataBase = core()->metaDataBase(); - const QWidgetList widgetChildren = qFindChildren<QWidget*>(main); + const QWidgetList widgetChildren = main->findChildren<QWidget*>(); if (!widgetChildren.empty()) insertNames(metaDataBase, widgetChildren.constBegin(), widgetChildren.constEnd(), w, existingNames); - const QList<QLayout *> layoutChildren = qFindChildren<QLayout*>(main); + const QList<QLayout *> layoutChildren = main->findChildren<QLayout*>(); if (!layoutChildren.empty()) insertNames(metaDataBase, layoutChildren.constBegin(), layoutChildren.constEnd(), w, existingNames); - const QList<QAction *> actionChildren = qFindChildren<QAction*>(main); + const QList<QAction *> actionChildren = main->findChildren<QAction*>(); if (!actionChildren.empty()) insertNames(metaDataBase, actionChildren.constBegin(), actionChildren.constEnd(), w, existingNames); - const QList<QButtonGroup *> buttonGroupChildren = qFindChildren<QButtonGroup*>(main); + const QList<QButtonGroup *> buttonGroupChildren = main->findChildren<QButtonGroup*>(); if (!buttonGroupChildren.empty()) insertNames(metaDataBase, buttonGroupChildren.constBegin(), buttonGroupChildren.constEnd(), w, existingNames); @@ -1283,7 +1283,7 @@ void FormWindow::resizeWidget(QWidget *widget, const QRect &geometry) void FormWindow::raiseChildSelections(QWidget *w) { - const QWidgetList l = qFindChildren<QWidget*>(w); + const QWidgetList l = w->findChildren<QWidget*>(); if (l.isEmpty()) return; m_selection->raiseList(l); @@ -1344,7 +1344,7 @@ QWidgetList FormWindow::selectedWidgets() const void FormWindow::selectWidgets() { bool selectionChanged = false; - const QWidgetList l = qFindChildren<QWidget*>(mainContainer()); + const QWidgetList l = mainContainer()->findChildren<QWidget*>(); QListIterator <QWidget*> it(l); const QRect selRect(mapToGlobal(m_currRect.topLeft()), m_currRect.size()); while (it.hasNext()) { @@ -1523,7 +1523,7 @@ void ArrowKeyPropertyCommand::init(QWidgetList &l, const ArrowKeyOperation &op) QObjectList ol; foreach(QWidget *w, l) ol.push_back(w); - SetPropertyCommand::init(ol, QLatin1String("geometry"), qVariantFromValue(op)); + SetPropertyCommand::init(ol, QLatin1String("geometry"), QVariant::fromValue(op)); setText(op.resize ? FormWindow::tr("Key Resize") : FormWindow::tr("Key Move")); } @@ -1531,14 +1531,14 @@ void ArrowKeyPropertyCommand::init(QWidgetList &l, const ArrowKeyOperation &op) QVariant ArrowKeyPropertyCommand::mergeValue(const QVariant &newMergeValue) { // Merge move operations of the same arrow key - if (!qVariantCanConvert<ArrowKeyOperation>(newMergeValue)) + if (!newMergeValue.canConvert<ArrowKeyOperation>()) return QVariant(); ArrowKeyOperation mergedOperation = qvariant_cast<ArrowKeyOperation>(newValue()); const ArrowKeyOperation newMergeOperation = qvariant_cast<ArrowKeyOperation>(newMergeValue); if (mergedOperation.resize != newMergeOperation.resize || mergedOperation.arrowKey != newMergeOperation.arrowKey) return QVariant(); mergedOperation.distance += newMergeOperation.distance; - return qVariantFromValue(mergedOperation); + return QVariant::fromValue(mergedOperation); } void FormWindow::handleArrowKeyEvent(int key, Qt::KeyboardModifiers modifiers) @@ -2248,7 +2248,7 @@ QAction *FormWindow::createSelectAncestorSubMenu(QWidget *w) for (int i = 0; i < size; i++) { QWidget *w = parents.at(i); QAction *a = ag->addAction(objectNameOf(w)); - a->setData(qVariantFromValue(w)); + a->setData(QVariant::fromValue(w)); menu->addAction(a); } QAction *ma = new QAction(tr("Select Ancestor"), 0); @@ -2803,7 +2803,7 @@ bool FormWindow::dropDockWidget(QDesignerDnDItemInterface *item, const QPoint &g PropertySheetEnumValue e = qvariant_cast<PropertySheetEnumValue>(propertySheet->property(propertySheet->indexOf(dockWidgetAreaName))); e.value = area; QVariant v; - qVariantSetValue(v, e); + v.setValue(e); SetPropertyCommand *cmd = new SetPropertyCommand(this); cmd->init(widget, dockWidgetAreaName, v); m_undoStack.push(cmd); diff --git a/tools/designer/src/components/formeditor/images/mac/simplifyrichtext.png b/tools/designer/src/components/formeditor/images/mac/simplifyrichtext.png Binary files differnew file mode 100644 index 0000000..a48e974 --- /dev/null +++ b/tools/designer/src/components/formeditor/images/mac/simplifyrichtext.png diff --git a/tools/designer/src/components/formeditor/images/win/simplifyrichtext.png b/tools/designer/src/components/formeditor/images/win/simplifyrichtext.png Binary files differnew file mode 100644 index 0000000..e251cf7 --- /dev/null +++ b/tools/designer/src/components/formeditor/images/win/simplifyrichtext.png diff --git a/tools/designer/src/components/formeditor/qdesigner_resource.cpp b/tools/designer/src/components/formeditor/qdesigner_resource.cpp index 6d718bb..409a20e 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) { @@ -197,12 +197,13 @@ QVariant QDesignerResourceBuilder::loadResource(const QDir &workingDirectory, co m_loadedQrcFiles.insert(QFileInfo(workingDirectory, dp->attributeResource()).absoluteFilePath(), false); #endif } - return qVariantFromValue(pixmap); + return QVariant::fromValue(pixmap); } 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); @@ -227,7 +228,7 @@ QVariant QDesignerResourceBuilder::loadResource(const QDir &workingDirectory, co m_loadedQrcFiles.insert(QFileInfo(workingDirectory, di->attributeResource()).absoluteFilePath(), false); #endif } - return qVariantFromValue(icon); + return QVariant::fromValue(icon); } default: break; @@ -237,12 +238,12 @@ QVariant QDesignerResourceBuilder::loadResource(const QDir &workingDirectory, co QVariant QDesignerResourceBuilder::toNativeValue(const QVariant &value) const { - if (qVariantCanConvert<PropertySheetPixmapValue>(value)) { + if (value.canConvert<PropertySheetPixmapValue>()) { if (m_pixmapCache) - return m_pixmapCache->pixmap(qVariantValue<PropertySheetPixmapValue>(value)); - } else if (qVariantCanConvert<PropertySheetIconValue>(value)) { + return m_pixmapCache->pixmap(qvariant_cast<PropertySheetPixmapValue>(value)); + } else if (value.canConvert<PropertySheetIconValue>()) { if (m_iconCache) - return m_iconCache->icon(qVariantValue<PropertySheetIconValue>(value)); + return m_iconCache->icon(qvariant_cast<PropertySheetIconValue>(value)); } return value; } @@ -250,7 +251,7 @@ QVariant QDesignerResourceBuilder::toNativeValue(const QVariant &value) const DomProperty *QDesignerResourceBuilder::saveResource(const QDir &workingDirectory, const QVariant &value) const { DomProperty *p = new DomProperty; - if (qVariantCanConvert<PropertySheetPixmapValue>(value)) { + if (value.canConvert<PropertySheetPixmapValue>()) { const PropertySheetPixmapValue pix = qvariant_cast<PropertySheetPixmapValue>(value); DomResourcePixmap *rp = new DomResourcePixmap; const QString pixPath = pix.path(); @@ -275,11 +276,14 @@ DomProperty *QDesignerResourceBuilder::saveResource(const QDir &workingDirectory } p->setElementPixmap(rp); return p; - } else if (qVariantCanConvert<PropertySheetIconValue>(value)) { + } 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; @@ -331,7 +335,7 @@ DomProperty *QDesignerResourceBuilder::saveResource(const QDir &workingDirectory bool QDesignerResourceBuilder::isResourceType(const QVariant &value) const { - if (qVariantCanConvert<PropertySheetPixmapValue>(value) || qVariantCanConvert<PropertySheetIconValue>(value)) + if (value.canConvert<PropertySheetPixmapValue>() || value.canConvert<PropertySheetIconValue>()) return true; return false; } @@ -364,26 +368,26 @@ QVariant QDesignerTextBuilder::loadText(const DomProperty *text) const if (!translatable) strVal.setTranslatable(translatable); } - return qVariantFromValue(strVal); + return QVariant::fromValue(strVal); } QVariant QDesignerTextBuilder::toNativeValue(const QVariant &value) const { - if (qVariantCanConvert<PropertySheetStringValue>(value)) - return qVariantFromValue(qVariantValue<PropertySheetStringValue>(value).value()); + if (value.canConvert<PropertySheetStringValue>()) + return QVariant::fromValue(qvariant_cast<PropertySheetStringValue>(value).value()); return value; } DomProperty *QDesignerTextBuilder::saveText(const QVariant &value) const { - if (!qVariantCanConvert<PropertySheetStringValue>(value) && !qVariantCanConvert<QString>(value)) + if (!value.canConvert<PropertySheetStringValue>() && !value.canConvert<QString>()) return 0; DomProperty *property = new DomProperty(); DomString *domStr = new DomString(); - if (qVariantCanConvert<PropertySheetStringValue>(value)) { - PropertySheetStringValue str = qVariantValue<PropertySheetStringValue>(value); + if (value.canConvert<PropertySheetStringValue>()) { + PropertySheetStringValue str = qvariant_cast<PropertySheetStringValue>(value); domStr->setText(str.value()); @@ -475,7 +479,7 @@ void QDesignerResource::saveDom(DomUI *ui, QWidget *widget) if (classVar.canConvert(QVariant::String)) classStr = classVar.toString(); else - classStr = qVariantValue<PropertySheetStringValue>(classVar).value(); + classStr = qvariant_cast<PropertySheetStringValue>(classVar).value(); ui->setElementClass(classStr); for (int index = 0; index < m_formWindow->toolCount(); ++index) { @@ -737,7 +741,10 @@ QWidget *QDesignerResource::load(QIODevice *dev, QWidget *parentWidget) case LoadPreCheckOk: break; } - return QEditorFormBuilder::load(dev, parentWidget); + QWidget *w = QEditorFormBuilder::load(dev, parentWidget); + if (w) // Store the class name as 'reset' value for the main container's object name. + w->setProperty("_q_classname", w->objectName()); + return w; } bool QDesignerResource::saveRelative() const @@ -946,7 +953,7 @@ QWidget *QDesignerResource::create(DomWidget *ui_widget, QWidget *parentWidget) w->addAction(a); } else if (QActionGroup *g = m_actionGroups.value(name)) { w->addActions(g->actions()); - } else if (QMenu *menu = qFindChild<QMenu*>(w, name)) { + } else if (QMenu *menu = w->findChild<QMenu*>(name)) { w->addAction(menu->menuAction()); addMenuAction(menu->menuAction()); } @@ -1045,7 +1052,7 @@ static bool readDomEnumerationValue(const DomProperty *p, switch (p->kind()) { case DomProperty::Set: { const QVariant sheetValue = sheet->property(index); - if (qVariantCanConvert<PropertySheetFlagValue>(sheetValue)) { + if (sheetValue.canConvert<PropertySheetFlagValue>()) { const PropertySheetFlagValue f = qvariant_cast<PropertySheetFlagValue>(sheetValue); bool ok = false; v = f.metaFlags.parseFlags(p->elementSet(), &ok); @@ -1057,7 +1064,7 @@ static bool readDomEnumerationValue(const DomProperty *p, break; case DomProperty::Enum: { const QVariant sheetValue = sheet->property(index); - if (qVariantCanConvert<PropertySheetEnumValue>(sheetValue)) { + if (sheetValue.canConvert<PropertySheetEnumValue>()) { const PropertySheetEnumValue e = qvariant_cast<PropertySheetEnumValue>(sheetValue); bool ok = false; v = e.metaEnum.parseEnum(p->elementEnum(), &ok); @@ -1110,7 +1117,7 @@ void QDesignerResource::applyProperties(QObject *o, const QList<DomProperty*> &p if (!translatable) keyVal.setTranslatable(translatable); } - v = qVariantFromValue(keyVal); + v = QVariant::fromValue(keyVal); } else { const DomString *str = p->elementString(); PropertySheetStringValue strVal(v.toString()); @@ -1124,7 +1131,7 @@ void QDesignerResource::applyProperties(QObject *o, const QList<DomProperty*> &p if (!translatable) strVal.setTranslatable(translatable); } - v = qVariantFromValue(strVal); + v = QVariant::fromValue(strVal); } } @@ -1135,18 +1142,18 @@ void QDesignerResource::applyProperties(QObject *o, const QList<DomProperty*> &p } else if (dynamicPropertiesAllowed) { QVariant defaultValue = QVariant(v.type()); bool isDefault = (v == defaultValue); - if (qVariantCanConvert<PropertySheetIconValue>(v)) { + if (v.canConvert<PropertySheetIconValue>()) { defaultValue = QVariant(QVariant::Icon); - isDefault = (qVariantValue<PropertySheetIconValue>(v) == PropertySheetIconValue()); - } else if (qVariantCanConvert<PropertySheetPixmapValue>(v)) { + isDefault = (qvariant_cast<PropertySheetIconValue>(v) == PropertySheetIconValue()); + } else if (v.canConvert<PropertySheetPixmapValue>()) { defaultValue = QVariant(QVariant::Pixmap); - isDefault = (qVariantValue<PropertySheetPixmapValue>(v) == PropertySheetPixmapValue()); - } else if (qVariantCanConvert<PropertySheetStringValue>(v)) { + isDefault = (qvariant_cast<PropertySheetPixmapValue>(v) == PropertySheetPixmapValue()); + } else if (v.canConvert<PropertySheetStringValue>()) { defaultValue = QVariant(QVariant::String); - isDefault = (qVariantValue<PropertySheetStringValue>(v) == PropertySheetStringValue()); - } else if (qVariantCanConvert<PropertySheetKeySequenceValue>(v)) { + isDefault = (qvariant_cast<PropertySheetStringValue>(v) == PropertySheetStringValue()); + } else if (v.canConvert<PropertySheetKeySequenceValue>()) { defaultValue = QVariant(QVariant::KeySequence); - isDefault = (qVariantValue<PropertySheetKeySequenceValue>(v) == PropertySheetKeySequenceValue()); + isDefault = (qvariant_cast<PropertySheetKeySequenceValue>(v) == PropertySheetKeySequenceValue()); } if (defaultValue.type() != QVariant::UserType) { const int idx = dynamicSheet->addDynamicProperty(p->attributeName(), defaultValue); @@ -1185,12 +1192,12 @@ QWidget *QDesignerResource::createWidget(const QString &widgetName, QWidget *par if (!qobject_cast<QMenu*>(w) && (!parentWidget || !container)) { m_formWindow->manageWidget(w); if (parentWidget) { - QList<QWidget *> list = qVariantValue<QWidgetList>(parentWidget->property("_q_widgetOrder")); + QList<QWidget *> list = qvariant_cast<QWidgetList>(parentWidget->property("_q_widgetOrder")); list.append(w); - parentWidget->setProperty("_q_widgetOrder", qVariantFromValue(list)); - QList<QWidget *> zOrder = qVariantValue<QWidgetList>(parentWidget->property("_q_zOrder")); + parentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(list)); + QList<QWidget *> zOrder = qvariant_cast<QWidgetList>(parentWidget->property("_q_zOrder")); zOrder.append(w); - parentWidget->setProperty("_q_zOrder", qVariantFromValue(zOrder)); + parentWidget->setProperty("_q_zOrder", QVariant::fromValue(zOrder)); } } else { core()->metaDataBase()->add(w); @@ -1320,7 +1327,7 @@ DomLayout *QDesignerResource::createDom(QLayout *layout, DomLayout *ui_parentLay QDesignerMetaDataBaseItemInterface *item = core()->metaDataBase()->item(layout); if (item == 0) { - layout = qFindChild<QLayout*>(layout); + layout = layout->findChild<QLayout*>(); // refresh the meta database item item = core()->metaDataBase()->item(layout); } @@ -1377,34 +1384,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; } @@ -1440,7 +1419,7 @@ void QDesignerResource::applyTabStops(QWidget *widget, DomTabStops *tabStops) QList<QWidget*> tabOrder; foreach (const QString &widgetName, tabStops->elementTabStop()) { - if (QWidget *w = qFindChild<QWidget*>(widget, widgetName)) { + if (QWidget *w = widget->findChild<QWidget*>(widgetName)) { tabOrder.append(w); } } @@ -1605,8 +1584,8 @@ DomWidget *QDesignerResource::saveWidget(QTabWidget *widget, DomWidget *ui_paren // attribute `icon' widget->setCurrentIndex(i); QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), widget); - PropertySheetIconValue icon = qVariantValue<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String("currentTabIcon")))); - DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), qVariantFromValue(icon)); + PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String("currentTabIcon")))); + DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), QVariant::fromValue(icon)); if (p) { p->setAttributeName(strings.iconAttribute); ui_attribute_list.append(p); @@ -1620,7 +1599,7 @@ DomWidget *QDesignerResource::saveWidget(QTabWidget *widget, DomWidget *ui_paren // attribute `toolTip' QVariant v = sheet->property(sheet->indexOf(QLatin1String("currentTabToolTip"))); - if (!qVariantValue<PropertySheetStringValue>(v).value().isEmpty()) { + if (!qvariant_cast<PropertySheetStringValue>(v).value().isEmpty()) { p = textBuilder()->saveText(v); if (p) { p->setAttributeName(strings.toolTipAttribute); @@ -1630,7 +1609,7 @@ DomWidget *QDesignerResource::saveWidget(QTabWidget *widget, DomWidget *ui_paren // attribute `whatsThis' v = sheet->property(sheet->indexOf(QLatin1String("currentTabWhatsThis"))); - if (!qVariantValue<PropertySheetStringValue>(v).value().isEmpty()) { + if (!qvariant_cast<PropertySheetStringValue>(v).value().isEmpty()) { p = textBuilder()->saveText(v); if (p) { p->setAttributeName(strings.whatsThisAttribute); @@ -1676,8 +1655,8 @@ DomWidget *QDesignerResource::saveWidget(QToolBox *widget, DomWidget *ui_parentW // attribute `icon' widget->setCurrentIndex(i); QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), widget); - PropertySheetIconValue icon = qVariantValue<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String("currentItemIcon")))); - DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), qVariantFromValue(icon)); + PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String("currentItemIcon")))); + DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), QVariant::fromValue(icon)); if (p) { p->setAttributeName(strings.iconAttribute); ui_attribute_list.append(p); @@ -1690,7 +1669,7 @@ DomWidget *QDesignerResource::saveWidget(QToolBox *widget, DomWidget *ui_parentW // attribute `toolTip' QVariant v = sheet->property(sheet->indexOf(QLatin1String("currentItemToolTip"))); - if (!qVariantValue<PropertySheetStringValue>(v).value().isEmpty()) { + if (!qvariant_cast<PropertySheetStringValue>(v).value().isEmpty()) { p = textBuilder()->saveText(v); if (p) { p->setAttributeName(strings.toolTipAttribute); @@ -2209,8 +2188,8 @@ DomProperty *QDesignerResource::createProperty(QObject *object, const QString &p return 0; } - if (qVariantCanConvert<PropertySheetFlagValue>(value)) { - const PropertySheetFlagValue f = qVariantValue<PropertySheetFlagValue>(value); + if (value.canConvert<PropertySheetFlagValue>()) { + const PropertySheetFlagValue f = qvariant_cast<PropertySheetFlagValue>(value); const QString flagString = f.metaFlags.toString(f.value, DesignerMetaFlags::FullyQualified); if (flagString.isEmpty()) return 0; @@ -2222,8 +2201,8 @@ DomProperty *QDesignerResource::createProperty(QObject *object, const QString &p p->setAttributeName(propertyName); p->setElementSet(flagString); return applyProperStdSetAttribute(object, propertyName, p); - } else if (qVariantCanConvert<PropertySheetEnumValue>(value)) { - const PropertySheetEnumValue e = qVariantValue<PropertySheetEnumValue>(value); + } else if (value.canConvert<PropertySheetEnumValue>()) { + const PropertySheetEnumValue e = qvariant_cast<PropertySheetEnumValue>(value); bool ok; const QString id = e.metaEnum.toString(e.value, DesignerMetaEnum::FullyQualified, &ok); if (!ok) @@ -2238,8 +2217,8 @@ DomProperty *QDesignerResource::createProperty(QObject *object, const QString &p p->setAttributeName(propertyName); p->setElementEnum(id); return applyProperStdSetAttribute(object, propertyName, p); - } else if (qVariantCanConvert<PropertySheetStringValue>(value)) { - const PropertySheetStringValue strVal = qVariantValue<PropertySheetStringValue>(value); + } else if (value.canConvert<PropertySheetStringValue>()) { + const PropertySheetStringValue strVal = qvariant_cast<PropertySheetStringValue>(value); DomProperty *p = new DomProperty; if (!hasSetter(core(), object, propertyName)) p->setAttributeStdset(0); @@ -2249,8 +2228,8 @@ DomProperty *QDesignerResource::createProperty(QObject *object, const QString &p saveStringProperty(p, strVal); return applyProperStdSetAttribute(object, propertyName, p); - } else if (qVariantCanConvert<PropertySheetKeySequenceValue>(value)) { - const PropertySheetKeySequenceValue keyVal = qVariantValue<PropertySheetKeySequenceValue>(value); + } else if (value.canConvert<PropertySheetKeySequenceValue>()) { + const PropertySheetKeySequenceValue keyVal = qvariant_cast<PropertySheetKeySequenceValue>(value); DomProperty *p = new DomProperty; if (!hasSetter(core(), object, propertyName)) p->setAttributeStdset(0); @@ -2302,6 +2281,7 @@ void QDesignerResource::createResources(DomResources *resources) path = core()->dialogGui()->getOpenFileName(dialogParent, fileDialogTitle, fi.absolutePath(), fileDialogPattern); if (path.isEmpty()) break; + m_formWindow->setProperty("_q_resourcepathchanged", QVariant(true)); } else { break; } diff --git a/tools/designer/src/components/formeditor/qmainwindow_container.cpp b/tools/designer/src/components/formeditor/qmainwindow_container.cpp index 27d273a..d2664b4 100644 --- a/tools/designer/src/components/formeditor/qmainwindow_container.cpp +++ b/tools/designer/src/components/formeditor/qmainwindow_container.cpp @@ -104,7 +104,7 @@ Qt::DockWidgetArea dockWidgetArea(QDockWidget *me) QList<QLayout*> candidates; if (mw->layout()) { candidates.append(mw->layout()); - candidates += qFindChildren<QLayout*>(mw->layout()); + candidates += mw->layout()->findChildren<QLayout*>(); } foreach (QLayout *l, candidates) { if (l->indexOf(me) != -1) { diff --git a/tools/designer/src/components/lib/lib.pro b/tools/designer/src/components/lib/lib.pro index 0ada845..50a8b00 100644 --- a/tools/designer/src/components/lib/lib.pro +++ b/tools/designer/src/components/lib/lib.pro @@ -64,7 +64,7 @@ PRECOMPILED_HEADER= lib_pch.h include(../../sharedcomponents.pri) include(../component.pri) -unix { +unix|win32-g++* { QMAKE_PKGCONFIG_REQUIRES = QtCore QtDesigner QtGui QtXml contains(QT_CONFIG, script): QMAKE_PKGCONFIG_REQUIRES += QtScript } diff --git a/tools/designer/src/components/objectinspector/objectinspectormodel.cpp b/tools/designer/src/components/objectinspector/objectinspectormodel.cpp index acad660..20f0ff1 100644 --- a/tools/designer/src/components/objectinspector/objectinspectormodel.cpp +++ b/tools/designer/src/components/objectinspector/objectinspectormodel.cpp @@ -273,7 +273,7 @@ namespace qdesigner_internal { void ObjectData::setItems(const StandardItemList &row, const ObjectInspectorIcons &icons) const { - const QVariant object = qVariantFromValue(m_object); + const QVariant object = QVariant::fromValue(m_object); row[ObjectInspectorModel::ObjectNameColumn]->setData(object, DataRole); row[ObjectInspectorModel::ClassNameColumn]->setData(object, DataRole); setItemsDisplayData(row, icons, ClassNameChanged|ObjectNameChanged|ClassIconChanged|TypeChanged|LayoutTypeChanged); diff --git a/tools/designer/src/components/propertyeditor/brushpropertymanager.cpp b/tools/designer/src/components/propertyeditor/brushpropertymanager.cpp index 7856add..973de63 100644 --- a/tools/designer/src/components/propertyeditor/brushpropertymanager.cpp +++ b/tools/designer/src/components/propertyeditor/brushpropertymanager.cpp @@ -163,7 +163,7 @@ void BrushPropertyManager::initializeProperty(QtVariantPropertyManager *vm, QtPr for (int i = 0; i < brushStyleCount; i++) styles.push_back(QCoreApplication::translate("BrushPropertyManager", brushStyles[i])); styleSubProperty->setAttribute(QLatin1String("enumNames"), styles); - styleSubProperty->setAttribute(QLatin1String("enumIcons"), qVariantFromValue(brushStyleIcons())); + styleSubProperty->setAttribute(QLatin1String("enumIcons"), QVariant::fromValue(brushStyleIcons())); m_brushPropertyToStyleSubProperty.insert(property, styleSubProperty); m_brushStyleSubPropertyToProperty.insert(styleSubProperty, property); // color diff --git a/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp b/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp index 36f7da5..78fb9aa 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); + } } } } @@ -740,7 +880,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari m_changingSubValue = false; data.val = newValue; QVariant v; - qVariantSetValue(v, data.val); + v.setValue(data.val); variantProperty(flagProperty)->setValue(v); } else if (QtProperty *alignProperty = m_alignHToProperty.value(property, 0)) { const uint v = m_alignValues.value(alignProperty); @@ -763,7 +903,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (v == newValue) return; - variantProperty(stringProperty)->setValue(qVariantFromValue(newValue)); + variantProperty(stringProperty)->setValue(QVariant::fromValue(newValue)); } else if (QtProperty *stringProperty = m_translatableToString.value(property, 0)) { const PropertySheetStringValue v = m_stringValues.value(stringProperty); PropertySheetStringValue newValue = v; @@ -771,7 +911,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (v == newValue) return; - variantProperty(stringProperty)->setValue(qVariantFromValue(newValue)); + variantProperty(stringProperty)->setValue(QVariant::fromValue(newValue)); } else if (QtProperty *stringProperty = m_disambiguationToString.value(property, 0)) { const PropertySheetStringValue v = m_stringValues.value(stringProperty); PropertySheetStringValue newValue = v; @@ -779,7 +919,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (v == newValue) return; - variantProperty(stringProperty)->setValue(qVariantFromValue(newValue)); + variantProperty(stringProperty)->setValue(QVariant::fromValue(newValue)); } else if (QtProperty *keySequenceProperty = m_commentToKeySequence.value(property, 0)) { const PropertySheetKeySequenceValue v = m_keySequenceValues.value(keySequenceProperty); PropertySheetKeySequenceValue newValue = v; @@ -787,7 +927,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (v == newValue) return; - variantProperty(keySequenceProperty)->setValue(qVariantFromValue(newValue)); + variantProperty(keySequenceProperty)->setValue(QVariant::fromValue(newValue)); } else if (QtProperty *keySequenceProperty = m_translatableToKeySequence.value(property, 0)) { const PropertySheetKeySequenceValue v = m_keySequenceValues.value(keySequenceProperty); PropertySheetKeySequenceValue newValue = v; @@ -795,7 +935,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (v == newValue) return; - variantProperty(keySequenceProperty)->setValue(qVariantFromValue(newValue)); + variantProperty(keySequenceProperty)->setValue(QVariant::fromValue(newValue)); } else if (QtProperty *keySequenceProperty = m_disambiguationToKeySequence.value(property, 0)) { const PropertySheetKeySequenceValue v = m_keySequenceValues.value(keySequenceProperty); PropertySheetKeySequenceValue newValue = v; @@ -803,16 +943,21 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (v == newValue) return; - variantProperty(keySequenceProperty)->setValue(qVariantFromValue(newValue)); + variantProperty(keySequenceProperty)->setValue(QVariant::fromValue(newValue)); } else if (QtProperty *iProperty = m_iconSubPropertyToProperty.value(property, 0)) { QtVariantProperty *iconProperty = variantProperty(iProperty); - PropertySheetIconValue icon = qVariantValue<PropertySheetIconValue>(iconProperty->value()); - QPair<QIcon::Mode, QIcon::State> pair = m_iconSubPropertyToState.value(property); - icon.setPixmap(pair.first, pair.second, qVariantValue<PropertySheetPixmapValue>(value)); + PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(iconProperty->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; - iconProperty->setValue(qVariantFromValue(icon)); + iconProperty->setValue(QVariant::fromValue(icon)); if (!origSourceOfChange) m_sourceOfChange = origSourceOfChange; } else if (m_iconValues.contains(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; @@ -933,7 +1085,7 @@ QVariant DesignerPropertyManager::attributeValue(const QtProperty *property, con PropertyFlagDataMap::const_iterator it = m_flagValues.constFind(prop); if (it != m_flagValues.constEnd()) { QVariant v; - qVariantSetValue(v, it.value().flags); + v.setValue(it.value().flags); return v; } } @@ -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()) @@ -985,7 +1143,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, if (value.userType() != designerFlagListTypeId()) return; - const DesignerFlagList flags = qVariantValue<DesignerFlagList>(value); + const DesignerFlagList flags = qvariant_cast<DesignerFlagList>(value); PropertyFlagDataMap::iterator fit = m_flagValues.find(property); FlagData data = fit.value(); if (data.flags == flags) @@ -1022,7 +1180,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, fit.value() = data; QVariant v; - qVariantSetValue(v, flags); + v.setValue(flags); emit attributeChanged(property, attribute, v); emit propertyChanged(property); @@ -1057,11 +1215,26 @@ 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; - QPalette superPalette = qVariantValue<QPalette>(value); + QPalette superPalette = qvariant_cast<QPalette>(value); const PropertyPaletteDataMap::iterator it = m_paletteValues.find(property); PaletteData data = it.value(); @@ -1077,7 +1250,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, it.value() = data; QVariant v; - qVariantSetValue(v, superPalette); + v.setValue(superPalette); emit attributeChanged(property, attribute, v); emit propertyChanged(property); @@ -1086,7 +1259,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, if (value.userType() != QVariant::Pixmap) return; - QPixmap defaultPixmap = qVariantValue<QPixmap>(value); + QPixmap defaultPixmap = qvariant_cast<QPixmap>(value); const QMap<QtProperty *, QPixmap>::iterator it = m_defaultPixmaps.find(property); QPixmap oldDefaultPixmap = it.value(); @@ -1095,7 +1268,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, it.value() = defaultPixmap; - QVariant v = qVariantFromValue(defaultPixmap); + QVariant v = QVariant::fromValue(defaultPixmap); emit attributeChanged(property, attribute, v); emit propertyChanged(property); @@ -1103,7 +1276,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, if (value.userType() != QVariant::Icon) return; - QIcon defaultIcon = qVariantValue<QIcon>(value); + QIcon defaultIcon = qvariant_cast<QIcon>(value); const QMap<QtProperty *, QIcon>::iterator it = m_defaultIcons.find(property); QIcon oldDefaultIcon = it.value(); @@ -1124,7 +1297,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, } } - QVariant v = qVariantFromValue(defaultIcon); + QVariant v = QVariant::fromValue(defaultIcon); emit attributeChanged(property, attribute, v); emit propertyChanged(property); @@ -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(); @@ -1265,12 +1442,12 @@ QString DesignerPropertyManager::valueText(const QtProperty *property) const return m_stringListValues.value(const_cast<QtProperty *>(property)).join(QLatin1String("; ")); } if (QtVariantPropertyManager::valueType(property) == QVariant::String || QtVariantPropertyManager::valueType(property) == designerStringTypeId()) { - const QString str = (QtVariantPropertyManager::valueType(property) == QVariant::String) ? value(property).toString() : qVariantValue<PropertySheetStringValue>(value(property)).value(); + const QString str = (QtVariantPropertyManager::valueType(property) == QVariant::String) ? value(property).toString() : qvariant_cast<PropertySheetStringValue>(value(property)).value(); const int validationMode = attributeValue(property, QLatin1String(validationModesAttributeC)).toInt(); return TextPropertyEditor::stringToEditorString(str, static_cast<TextPropertyValidationMode>(validationMode)); } if (QtVariantPropertyManager::valueType(property) == designerKeySequenceTypeId()) { - return qVariantValue<PropertySheetKeySequenceValue>(value(property)).value(); + return qvariant_cast<PropertySheetKeySequenceValue>(value(property)).value(); } if (QtVariantPropertyManager::valueType(property) == QVariant::Bool) { return QString(); @@ -1313,13 +1490,13 @@ void DesignerPropertyManager::reloadResourceProperties() } emit propertyChanged(property); - emit QtVariantPropertyManager::valueChanged(property, qVariantFromValue(itIcon.value())); + emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(itIcon.value())); } QMapIterator<QtProperty *, qdesigner_internal::PropertySheetPixmapValue> itPix(m_pixmapValues); while (itPix.hasNext()) { QtProperty *property = itPix.next().key(); emit propertyChanged(property); - emit QtVariantPropertyManager::valueChanged(property, qVariantFromValue(itPix.value())); + emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(itPix.value())); } } @@ -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)) @@ -1357,13 +1536,13 @@ QVariant DesignerPropertyManager::value(const QtProperty *property) const if (m_paletteValues.contains(const_cast<QtProperty *>(property))) return m_paletteValues.value(const_cast<QtProperty *>(property)).val; if (m_iconValues.contains(const_cast<QtProperty *>(property))) - return qVariantFromValue(m_iconValues.value(const_cast<QtProperty *>(property))); + return QVariant::fromValue(m_iconValues.value(const_cast<QtProperty *>(property))); if (m_pixmapValues.contains(const_cast<QtProperty *>(property))) - return qVariantFromValue(m_pixmapValues.value(const_cast<QtProperty *>(property))); + return QVariant::fromValue(m_pixmapValues.value(const_cast<QtProperty *>(property))); if (m_stringValues.contains(const_cast<QtProperty *>(property))) - return qVariantFromValue(m_stringValues.value(const_cast<QtProperty *>(property))); + return QVariant::fromValue(m_stringValues.value(const_cast<QtProperty *>(property))); if (m_keySequenceValues.contains(const_cast<QtProperty *>(property))) - return qVariantFromValue(m_keySequenceValues.value(const_cast<QtProperty *>(property))); + return QVariant::fromValue(m_keySequenceValues.value(const_cast<QtProperty *>(property))); if (m_uintValues.contains(const_cast<QtProperty *>(property))) return m_uintValues.value(const_cast<QtProperty *>(property)); if (m_longLongValues.contains(const_cast<QtProperty *>(property))) @@ -1497,7 +1676,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val if (value.userType() != designerStringTypeId()) return; - const PropertySheetStringValue v = qVariantValue<PropertySheetStringValue>(value); + const PropertySheetStringValue v = qvariant_cast<PropertySheetStringValue>(value); const PropertySheetStringValue val = m_stringValues.value(property); @@ -1517,7 +1696,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val m_stringValues[property] = v; - emit QtVariantPropertyManager::valueChanged(property, qVariantFromValue(v)); + emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(v)); emit propertyChanged(property); return; @@ -1525,7 +1704,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val if (value.userType() != designerKeySequenceTypeId()) return; - const PropertySheetKeySequenceValue v = qVariantValue<PropertySheetKeySequenceValue>(value); + const PropertySheetKeySequenceValue v = qvariant_cast<PropertySheetKeySequenceValue>(value); const PropertySheetKeySequenceValue val = m_keySequenceValues.value(property); @@ -1545,7 +1724,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val m_keySequenceValues[property] = v; - emit QtVariantPropertyManager::valueChanged(property, qVariantFromValue(v)); + emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(v)); emit propertyChanged(property); return; @@ -1553,7 +1732,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val if (value.type() != QVariant::Palette && !value.canConvert(QVariant::Palette)) return; - QPalette p = qVariantValue<QPalette>(value); + QPalette p = qvariant_cast<QPalette>(value); PaletteData data = m_paletteValues.value(property); @@ -1575,7 +1754,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val if (value.userType() != designerIconTypeId()) return; - const PropertySheetIconValue icon = qVariantValue<PropertySheetIconValue>(value); + const PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(value); const PropertySheetIconValue oldIcon = m_iconValues.value(property); if (icon == oldIcon) @@ -1600,12 +1779,18 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val QtVariantProperty *subProperty = variantProperty(itSub.value()); bool hasPath = iconPaths.contains(pair); subProperty->setModified(hasPath); - subProperty->setValue(qVariantFromValue(iconPaths.value(pair))); + subProperty->setValue(QVariant::fromValue(iconPaths.value(pair))); 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, qVariantFromValue(icon)); + emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(icon)); emit propertyChanged(property); QString toolTip; @@ -1620,7 +1805,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val if (value.userType() != designerPixmapTypeId()) return; - const PropertySheetPixmapValue pixmap = qVariantValue<PropertySheetPixmapValue>(value); + const PropertySheetPixmapValue pixmap = qvariant_cast<PropertySheetPixmapValue>(value); const PropertySheetPixmapValue oldPixmap = m_pixmapValues.value(property); if (pixmap == oldPixmap) @@ -1628,7 +1813,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val m_pixmapValues[property] = pixmap; - emit QtVariantPropertyManager::valueChanged(property, qVariantFromValue(pixmap)); + emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(pixmap)); emit propertyChanged(property); property->setToolTip(pixmap.path()); @@ -1746,9 +1931,9 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val if (QtVariantPropertyManager::valueType(property) == QVariant::String) property->setToolTip(DesignerPropertyManager::value(property).toString()); else if (QtVariantPropertyManager::valueType(property) == designerStringTypeId()) - property->setToolTip(qVariantValue<PropertySheetStringValue>(DesignerPropertyManager::value(property)).value()); + property->setToolTip(qvariant_cast<PropertySheetStringValue>(DesignerPropertyManager::value(property)).value()); else if (QtVariantPropertyManager::valueType(property) == designerKeySequenceTypeId()) - property->setToolTip(qVariantValue<PropertySheetKeySequenceValue>(DesignerPropertyManager::value(property)).value()); + property->setToolTip(qvariant_cast<PropertySheetKeySequenceValue>(DesignerPropertyManager::value(property)).value()); else if (QtVariantPropertyManager::valueType(property) == QVariant::Bool) property->setToolTip(QtVariantPropertyManager::valueText(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(qVariantFromValue(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); @@ -2131,7 +2340,7 @@ void DesignerEditorFactory::slotPropertyChanged(QtProperty *property) if (!property->isModified()) defaultPixmap = qvariant_cast<QIcon>(manager->attributeValue(property, QLatin1String(defaultResourceAttributeC))).pixmap(16, 16); else if (m_fwb) - defaultPixmap = m_fwb->iconCache()->icon(qVariantValue<PropertySheetIconValue>(manager->value(property))).pixmap(16, 16); + defaultPixmap = m_fwb->iconCache()->icon(qvariant_cast<PropertySheetIconValue>(manager->value(property))).pixmap(16, 16); QList<PixmapEditor *> editors = m_iconPropertyToEditors.value(property); QListIterator<PixmapEditor *> it(editors); while (it.hasNext()) { @@ -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, qVariantValue<PropertySheetIconValue>(value).pixmap(QIcon::Normal, QIcon::Off).path()); - else if (type == DesignerPropertyManager::designerPixmapTypeId()) - applyToEditors(m_pixmapPropertyToEditors.value(property), &PixmapEditor::setPath, qVariantValue<PropertySheetPixmapValue>(value).path()); - else if (type == DesignerPropertyManager::designerStringTypeId()) - applyToEditors(m_stringPropertyToEditors.value(property), &TextEditor::setText, qVariantValue<PropertySheetStringValue>(value).value()); - else if (type == DesignerPropertyManager::designerKeySequenceTypeId()) - applyToEditors(m_keySequencePropertyToEditors.value(property), &QtKeySequenceEdit::setKeySequence, qVariantValue<PropertySheetKeySequenceValue>(value).value()); + 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()) { + applyToEditors(m_stringPropertyToEditors.value(property), &TextEditor::setText, qvariant_cast<PropertySheetStringValue>(value).value()); + } 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,10 +2538,11 @@ 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()); - TextEditor *ed = createTextEditor(parent, tvm, qVariantValue<PropertySheetStringValue>(manager->value(property)).value()); + TextEditor *ed = createTextEditor(parent, tvm, qvariant_cast<PropertySheetStringValue>(manager->value(property)).value()); const QVariant richTextDefaultFont = manager->attributeValue(property, QLatin1String(fontAttributeC)); if (richTextDefaultFont.type() == QVariant::Font) ed->setRichTextDefaultFont(qvariant_cast<QFont>(richTextDefaultFont)); @@ -2335,7 +2553,7 @@ QWidget *DesignerEditorFactory::createEditor(QtVariantPropertyManager *manager, editor = ed; } else if (type == DesignerPropertyManager::designerKeySequenceTypeId()) { QtKeySequenceEdit *ed = new QtKeySequenceEdit(parent); - ed->setKeySequence(qVariantValue<PropertySheetKeySequenceValue>(manager->value(property)).value()); + ed->setKeySequence(qvariant_cast<PropertySheetKeySequenceValue>(manager->value(property)).value()); m_keySequencePropertyToEditors[property].append(ed); m_editorToKeySequenceProperty[ed] = property; connect(ed, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*))); @@ -2456,12 +2674,12 @@ void DesignerEditorFactory::slotStringTextChanged(const QString &value) QtVariantProperty *varProp = manager->variantProperty(prop); QVariant val = varProp->value(); if (val.userType() == DesignerPropertyManager::designerStringTypeId()) { - PropertySheetStringValue strVal = qVariantValue<PropertySheetStringValue>(val); + PropertySheetStringValue strVal = qvariant_cast<PropertySheetStringValue>(val); strVal.setValue(value); // Disable translation if no translation subproperties exist. if (varProp->subProperties().empty()) strVal.setTranslatable(false); - val = qVariantFromValue(strVal); + val = QVariant::fromValue(strVal); } else { val = QVariant(value); } @@ -2482,11 +2700,11 @@ void DesignerEditorFactory::slotKeySequenceChanged(const QKeySequence &value) QtVariantProperty *varProp = manager->variantProperty(prop); QVariant val = varProp->value(); if (val.userType() == DesignerPropertyManager::designerKeySequenceTypeId()) { - PropertySheetKeySequenceValue keyVal = qVariantValue<PropertySheetKeySequenceValue>(val); + PropertySheetKeySequenceValue keyVal = qvariant_cast<PropertySheetKeySequenceValue>(val); keyVal.setValue(value); - val = qVariantFromValue(keyVal); + val = QVariant::fromValue(keyVal); } else { - val = qVariantFromValue(value); + val = QVariant::fromValue(value); } m_changingPropertyValue = true; manager->variantProperty(prop)->setValue(val); @@ -2497,24 +2715,32 @@ void DesignerEditorFactory::slotKeySequenceChanged(const QKeySequence &value) void DesignerEditorFactory::slotPaletteChanged(const QPalette &value) { - updateManager(this, &m_changingPropertyValue, m_editorToPaletteProperty, qobject_cast<QWidget *>(sender()), qVariantFromValue(value)); + updateManager(this, &m_changingPropertyValue, m_editorToPaletteProperty, qobject_cast<QWidget *>(sender()), QVariant::fromValue(value)); } void DesignerEditorFactory::slotPixmapChanged(const QString &value) { updateManager(this, &m_changingPropertyValue, m_editorToPixmapProperty, qobject_cast<QWidget *>(sender()), - qVariantFromValue(PropertySheetPixmapValue(value))); + QVariant::fromValue(PropertySheetPixmapValue(value))); } void DesignerEditorFactory::slotIconChanged(const QString &value) { updateManager(this, &m_changingPropertyValue, m_editorToIconProperty, qobject_cast<QWidget *>(sender()), - qVariantFromValue(PropertySheetIconValue(PropertySheetPixmapValue(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()), qVariantFromValue(value)); + updateManager(this, &m_changingPropertyValue, m_editorToStringListProperty, qobject_cast<QWidget *>(sender()), QVariant::fromValue(value)); } ResetDecorator::~ResetDecorator() diff --git a/tools/designer/src/components/propertyeditor/designerpropertymanager.h b/tools/designer/src/components/propertyeditor/designerpropertymanager.h index 77fd20c..4f4bb3c 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/fontpropertymanager.cpp b/tools/designer/src/components/propertyeditor/fontpropertymanager.cpp index f83b00a..d04bfe6 100644 --- a/tools/designer/src/components/propertyeditor/fontpropertymanager.cpp +++ b/tools/designer/src/components/propertyeditor/fontpropertymanager.cpp @@ -123,7 +123,7 @@ namespace qdesigner_internal { // This will cause a recursion QtVariantProperty *antialiasing = vm->addProperty(enumTypeId, QCoreApplication::translate("FontPropertyManager", "Antialiasing")); - const QFont font = qVariantValue<QFont>(vm->variantProperty(property)->value()); + const QFont font = qvariant_cast<QFont>(vm->variantProperty(property)->value()); antialiasing->setAttribute(QLatin1String("enumNames"), m_aliasingEnumNames); antialiasing->setValue(antialiasingToIndex(font.styleStrategy())); @@ -196,7 +196,7 @@ namespace qdesigner_internal { mask &= ~flag; font.resolve(mask); - qVariantSetValue(v, font); + v.setValue(font); fontProperty->setValue(v); return true; } @@ -250,13 +250,13 @@ namespace qdesigner_internal { QtVariantProperty *fontProperty = vm->variantProperty(antialiasingProperty); const QFont::StyleStrategy newValue = indexToAntialiasing(value.toInt()); - QFont font = qVariantValue<QFont>(fontProperty->value()); + QFont font = qvariant_cast<QFont>(fontProperty->value()); const QFont::StyleStrategy oldValue = font.styleStrategy(); if (newValue == oldValue) return Unchanged; font.setStyleStrategy(newValue); - fontProperty->setValue(qVariantFromValue(font)); + fontProperty->setValue(QVariant::fromValue(font)); return Changed; } @@ -268,7 +268,7 @@ namespace qdesigner_internal { const PropertyList &subProperties = it.value(); - QFont font = qVariantValue<QFont>(value); + QFont font = qvariant_cast<QFont>(value); const unsigned mask = font.resolve(); const int count = subProperties.size(); @@ -285,7 +285,7 @@ namespace qdesigner_internal { if (QtProperty *antialiasingProperty = m_propertyToAntialiasing.value(property, 0)) { QtVariantProperty *antialiasing = vm->variantProperty(antialiasingProperty); if (antialiasing) { - QFont font = qVariantValue<QFont>(value); + QFont font = qvariant_cast<QFont>(value); antialiasing->setValue(antialiasingToIndex(font.styleStrategy())); } } diff --git a/tools/designer/src/components/propertyeditor/paletteeditor.cpp b/tools/designer/src/components/propertyeditor/paletteeditor.cpp index de3f5cf..55a6da5 100644 --- a/tools/designer/src/components/propertyeditor/paletteeditor.cpp +++ b/tools/designer/src/components/propertyeditor/paletteeditor.cpp @@ -294,7 +294,7 @@ bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int return false; if (index.column() != 0 && role == BrushRole) { - const QBrush br = qVariantValue<QBrush>(value); + const QBrush br = qvariant_cast<QBrush>(value); const QPalette::ColorRole r = static_cast<QPalette::ColorRole>(index.row()); const QPalette::ColorGroup g = columnToGroup(index.column()); m_palette.setBrush(g, r, br); @@ -336,7 +336,7 @@ bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int } if (index.column() == 0 && role == Qt::EditRole) { uint mask = m_palette.resolve(); - const bool isMask = qVariantValue<bool>(value); + const bool isMask = qvariant_cast<bool>(value); const int r = index.row(); if (isMask) mask |= (1 << r); @@ -532,13 +532,13 @@ QWidget *ColorDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem void ColorDelegate::setEditorData(QWidget *ed, const QModelIndex &index) const { if (index.column() == 0) { - const bool mask = qVariantValue<bool>(index.model()->data(index, Qt::EditRole)); + const bool mask = qvariant_cast<bool>(index.model()->data(index, Qt::EditRole)); RoleEditor *editor = static_cast<RoleEditor *>(ed); editor->setEdited(mask); - const QString colorName = qVariantValue<QString>(index.model()->data(index, Qt::DisplayRole)); + const QString colorName = qvariant_cast<QString>(index.model()->data(index, Qt::DisplayRole)); editor->setLabel(colorName); } else { - const QBrush br = qVariantValue<QBrush>(index.model()->data(index, BrushRole)); + const QBrush br = qvariant_cast<QBrush>(index.model()->data(index, BrushRole)); BrushEditor *editor = static_cast<BrushEditor *>(ed); editor->setBrush(br); } @@ -571,11 +571,11 @@ void ColorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const { QStyleOptionViewItem option = opt; - const bool mask = qVariantValue<bool>(index.model()->data(index, Qt::EditRole)); + const bool mask = qvariant_cast<bool>(index.model()->data(index, Qt::EditRole)); if (index.column() == 0 && mask) { option.font.setBold(true); } - QBrush br = qVariantValue<QBrush>(index.model()->data(index, BrushRole)); + QBrush br = qvariant_cast<QBrush>(index.model()->data(index, BrushRole)); if (br.style() == Qt::LinearGradientPattern || br.style() == Qt::RadialGradientPattern || br.style() == Qt::ConicalGradientPattern) { diff --git a/tools/designer/src/components/propertyeditor/propertyeditor.cpp b/tools/designer/src/components/propertyeditor/propertyeditor.cpp index 27c017b..9f298d0 100644 --- a/tools/designer/src/components/propertyeditor/propertyeditor.cpp +++ b/tools/designer/src/components/propertyeditor/propertyeditor.cpp @@ -91,6 +91,7 @@ static const char *ViewKeyC = "View"; static const char *ColorKeyC = "Colored"; static const char *SortedKeyC = "Sorted"; static const char *ExpansionKeyC = "ExpandedItems"; +static const char *SplitterPositionKeyC = "SplitterPosition"; enum SettingsView { TreeView, ButtonView }; @@ -365,10 +366,12 @@ PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *pare m_sorting = settings->value(QLatin1String(SortedKeyC), false).toBool(); m_coloring = settings->value(QLatin1String(ColorKeyC), true).toBool(); const QVariantMap expansionState = settings->value(QLatin1String(ExpansionKeyC), QVariantMap()).toMap(); + const int splitterPosition = settings->value(QLatin1String(SplitterPositionKeyC), 150).toInt(); settings->endGroup(); // Apply settings m_sortingAction->setChecked(m_sorting); m_coloringAction->setChecked(m_coloring); + m_treeBrowser->setSplitterPosition(splitterPosition); #if QT_VERSION >= 0x040500 switch (view) { case TreeView: @@ -415,6 +418,7 @@ void PropertyEditor::saveSettings() const expansionState.insert(it.key(), QVariant(it.value())); } settings->setValue(QLatin1String(ExpansionKeyC), expansionState); + settings->setValue(QLatin1String(SplitterPositionKeyC), m_treeBrowser->splitterPosition()); settings->endGroup(); } @@ -872,12 +876,12 @@ void PropertyEditor::updateBrowserValue(QtVariantProperty *property, const QVari int PropertyEditor::toBrowserType(const QVariant &value, const QString &propertyName) const { - if (qVariantCanConvert<PropertySheetFlagValue>(value)) { + if (value.canConvert<PropertySheetFlagValue>()) { if (m_strings.m_alignmentProperties.contains(propertyName)) return DesignerPropertyManager::designerAlignmentTypeId(); return DesignerPropertyManager::designerFlagTypeId(); } - if (qVariantCanConvert<PropertySheetEnumValue>(value)) + if (value.canConvert<PropertySheetEnumValue>()) return DesignerPropertyManager::enumTypeId(); return value.userType(); @@ -1034,7 +1038,7 @@ void PropertyEditor::setObject(QObject *object) } m_updatingBrowser = true; QVariant v; - qVariantSetValue(v, flags); + v.setValue(flags); property->setAttribute(m_strings.m_flagsAttribute, v); m_updatingBrowser = false; } @@ -1223,7 +1227,7 @@ void PropertyEditor::slotValueChanged(QtProperty *property, const QVariant &valu e.value = e.metaEnum.parseEnum(valName, &ok); Q_ASSERT(ok); QVariant v; - qVariantSetValue(v, e); + v.setValue(e); emitPropertyValueChanged(property->propertyName(), v, true); return; } diff --git a/tools/designer/src/components/signalsloteditor/connectdialog.cpp b/tools/designer/src/components/signalsloteditor/connectdialog.cpp index 7759a76..64be113 100644 --- a/tools/designer/src/components/signalsloteditor/connectdialog.cpp +++ b/tools/designer/src/components/signalsloteditor/connectdialog.cpp @@ -231,7 +231,7 @@ void ConnectDialog::populateSlotList(const QString &signal) QFont font = QApplication::font(); font.setItalic(true); - QVariant variantFont = qVariantFromValue(font); + QVariant variantFont = QVariant::fromValue(font); QListWidgetItem *curr = 0; QMap<QString, QString>::ConstIterator itMember = memberToClassName.constBegin(); @@ -271,7 +271,7 @@ void ConnectDialog::populateSignalList() QFont font = QApplication::font(); font.setItalic(true); - QVariant variantFont = qVariantFromValue(font); + QVariant variantFont = QVariant::fromValue(font); QListWidgetItem *curr = 0; QMap<QString, QString>::ConstIterator itMember = memberToClassName.constBegin(); diff --git a/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp b/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp index 9f72816..ac1fe1c 100644 --- a/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp +++ b/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp @@ -248,7 +248,7 @@ namespace qdesigner_internal { if (obj_name == form->mainContainer()->objectName()) { object = form->mainContainer(); } else { - object = qFindChild<QObject*>(form->mainContainer(), obj_name); + object = form->mainContainer()->findChild<QObject*>(obj_name); } if (!object) return ClassesMemberFunctions(); diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditor.cpp b/tools/designer/src/components/signalsloteditor/signalsloteditor.cpp index d1a23e2..6738640 100644 --- a/tools/designer/src/components/signalsloteditor/signalsloteditor.cpp +++ b/tools/designer/src/components/signalsloteditor/signalsloteditor.cpp @@ -372,7 +372,7 @@ QObject *SignalSlotEditor::objectByName(QWidget *topLevel, const QString &name) if (topLevel->objectName() == name) object = topLevel; else - object = qFindChild<QObject*>(topLevel, name); + object = topLevel->findChild<QObject*>(name); const QDesignerMetaDataBaseInterface *mdb = formWindow()->core()->metaDataBase(); if (mdb->item(object)) return object; diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp index 6690948..b06a66f 100644 --- a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp +++ b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp @@ -117,7 +117,7 @@ static QStringList objectNameList(QDesignerFormWindowInterface *form) const QDesignerMetaDataBaseInterface *mdb = form->core()->metaDataBase(); // Add managed actions and actions with managed menus - const ActionList actions = qFindChildren<QAction*>(mainContainer); + const ActionList actions = mainContainer->findChildren<QAction*>(); if (!actions.empty()) { const ActionList::const_iterator cend = actions.constEnd(); for (ActionList::const_iterator it = actions.constBegin(); it != cend; ++it) { @@ -135,7 +135,7 @@ static QStringList objectNameList(QDesignerFormWindowInterface *form) } // Add managed buttons groups - const ButtonGroupList buttonGroups = qFindChildren<QButtonGroup *>(mainContainer); + const ButtonGroupList buttonGroups = mainContainer->findChildren<QButtonGroup *>(); if (!buttonGroups.empty()) { const ButtonGroupList::const_iterator cend = buttonGroups.constEnd(); for (ButtonGroupList::const_iterator it = buttonGroups.constBegin(); it != cend; ++it) @@ -473,7 +473,7 @@ void InlineEditorModel::addTextList(const QMap<QString, bool> &text_list) insertRows(cnt, text_list.size()); QFont font = QApplication::font(); font.setItalic(true); - QVariant fontVariant = qVariantFromValue(font); + QVariant fontVariant = QVariant::fromValue(font); QMap<QString, bool>::ConstIterator it = text_list.constBegin(); const QMap<QString, bool>::ConstIterator itEnd = text_list.constEnd(); while (it != itEnd) { @@ -662,7 +662,7 @@ QWidget *ConnectionDelegate::createEditor(QWidget *parent, if (obj_name == m_form->mainContainer()->objectName()) { object = m_form->mainContainer(); } else { - object = qFindChild<QObject*>(m_form->mainContainer(), obj_name); + object = m_form->mainContainer()->findChild<QObject*>(obj_name); } inline_editor->addText(type == qdesigner_internal::SignalMember ? tr("<signal>") : tr("<slot>")); foreach (const qdesigner_internal::ClassMemberFunctions &class_info, class_list) { @@ -771,7 +771,7 @@ void SignalSlotEditorWindow::setActiveFormWindow(QDesignerFormWindowInterface *f } } - m_editor = qFindChild<SignalSlotEditor*>(form); + m_editor = form->findChild<SignalSlotEditor*>(); m_model->setEditor(m_editor); if (!m_editor.isNull()) { ConnectionDelegate *delegate diff --git a/tools/designer/src/components/tabordereditor/tabordereditor.cpp b/tools/designer/src/components/tabordereditor/tabordereditor.cpp index d416373..e372bdc 100644 --- a/tools/designer/src/components/tabordereditor/tabordereditor.cpp +++ b/tools/designer/src/components/tabordereditor/tabordereditor.cpp @@ -239,7 +239,7 @@ void TabOrderEditor::initTabOrder() childQueue.append(formWindow()->mainContainer()); while (!childQueue.isEmpty()) { QWidget *child = childQueue.takeFirst(); - childQueue += qVariantValue<QWidgetList>(child->property("_q_widgetOrder")); + childQueue += qvariant_cast<QWidgetList>(child->property("_q_widgetOrder")); if (skipWidget(child)) continue; diff --git a/tools/designer/src/components/taskmenu/button_taskmenu.cpp b/tools/designer/src/components/taskmenu/button_taskmenu.cpp index bd77a65..953996b 100644 --- a/tools/designer/src/components/taskmenu/button_taskmenu.cpp +++ b/tools/designer/src/components/taskmenu/button_taskmenu.cpp @@ -508,7 +508,7 @@ bool ButtonTaskMenu::refreshAssignMenu(const QDesignerFormWindowInterface *fw, i QButtonGroup *bg = *it; if (*it != currentGroup) { QAction *a = new QAction(bg->objectName(), m_assignGroupSubMenu); - a->setData(qVariantFromValue(bg)); + a->setData(QVariant::fromValue(bg)); m_assignActionGroup->addAction(a); m_assignGroupSubMenu->addAction(a); } @@ -528,7 +528,7 @@ bool ButtonTaskMenu::refreshAssignMenu(const QDesignerFormWindowInterface *fw, i QList<QAction*> ButtonTaskMenu::taskActions() const { ButtonTaskMenu *ncThis = const_cast<ButtonTaskMenu*>(this); - QButtonGroup *buttonGroup; + QButtonGroup *buttonGroup = 0; QDesignerFormWindowInterface *fw = formWindow(); const SelectionType st = selectionType(fw->cursor(), &buttonGroup); diff --git a/tools/designer/src/components/taskmenu/inplace_editor.cpp b/tools/designer/src/components/taskmenu/inplace_editor.cpp index fd3a6d9..fd74b25 100644 --- a/tools/designer/src/components/taskmenu/inplace_editor.cpp +++ b/tools/designer/src/components/taskmenu/inplace_editor.cpp @@ -106,7 +106,7 @@ void TaskMenuInlineEditor::editText() const int index = sheet->indexOf(m_property); if (index == -1) return; - m_value = qVariantValue<PropertySheetStringValue>(sheet->property(index)); + m_value = qvariant_cast<PropertySheetStringValue>(sheet->property(index)); const QString oldValue = m_value.value(); m_editor = new InPlaceEditor(m_widget, m_vm, m_formWindow, oldValue, editRectangle()); @@ -119,9 +119,9 @@ void TaskMenuInlineEditor::updateText(const QString &text) // do not use the cursor selection m_value.setValue(text); if (m_managed) { - m_formWindow->cursor()->setProperty(m_property, qVariantFromValue(m_value)); + m_formWindow->cursor()->setProperty(m_property, QVariant::fromValue(m_value)); } else { - m_formWindow->cursor()->setWidgetProperty(m_widget, m_property, qVariantFromValue(m_value)); + m_formWindow->cursor()->setWidgetProperty(m_widget, m_property, QVariant::fromValue(m_value)); } } diff --git a/tools/designer/src/components/taskmenu/itemlisteditor.cpp b/tools/designer/src/components/taskmenu/itemlisteditor.cpp index f33182b..a04246d 100644 --- a/tools/designer/src/components/taskmenu/itemlisteditor.cpp +++ b/tools/designer/src/components/taskmenu/itemlisteditor.cpp @@ -80,7 +80,7 @@ private: ////////////////// Item editor /////////////// AbstractItemEditor::AbstractItemEditor(QDesignerFormWindowInterface *form, QWidget *parent) - : QDialog(parent), + : QWidget(parent), m_iconCache(qobject_cast<FormWindowBase *>(form)->iconCache()), m_updatingBrowser(false) { @@ -104,15 +104,6 @@ AbstractItemEditor::~AbstractItemEditor() m_propertyBrowser->unsetFactoryForManager(m_propertyManager); } -void AbstractItemEditor::keyPressEvent(QKeyEvent *e) -{ - // Avoid that embedded dialogs react to enter and escape keys. - if (this == window()) - QDialog::keyPressEvent(e); - else - QWidget::keyPressEvent(e); -} - static const char * const itemFlagNames[] = { QT_TRANSLATE_NOOP("AbstractItemEditor", "Selectable"), QT_TRANSLATE_NOOP("AbstractItemEditor", "Editable"), @@ -191,8 +182,8 @@ void AbstractItemEditor::propertyChanged(QtProperty *property) return; if ((role == ItemFlagsShadowRole && prop->value().toInt() == (int)QListWidgetItem().flags()) - || (role == Qt::DecorationPropertyRole && !qVariantValue<PropertySheetIconValue>(prop->value()).mask()) - || (role == Qt::FontRole && !qVariantValue<QFont>(prop->value()).resolve())) { + || (role == Qt::DecorationPropertyRole && !qvariant_cast<PropertySheetIconValue>(prop->value()).mask()) + || (role == Qt::FontRole && !qvariant_cast<QFont>(prop->value()).resolve())) { prop->setModified(false); setItemData(role, QVariant()); } else { @@ -202,19 +193,19 @@ void AbstractItemEditor::propertyChanged(QtProperty *property) switch (role) { case Qt::DecorationPropertyRole: - setItemData(Qt::DecorationRole, qVariantFromValue(iconCache()->icon(qVariantValue<PropertySheetIconValue>(prop->value())))); + setItemData(Qt::DecorationRole, QVariant::fromValue(iconCache()->icon(qvariant_cast<PropertySheetIconValue>(prop->value())))); break; case Qt::DisplayPropertyRole: - setItemData(Qt::EditRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value())); + setItemData(Qt::EditRole, QVariant::fromValue(qvariant_cast<PropertySheetStringValue>(prop->value()).value())); break; case Qt::ToolTipPropertyRole: - setItemData(Qt::ToolTipRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value())); + setItemData(Qt::ToolTipRole, QVariant::fromValue(qvariant_cast<PropertySheetStringValue>(prop->value()).value())); break; case Qt::StatusTipPropertyRole: - setItemData(Qt::StatusTipRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value())); + setItemData(Qt::StatusTipRole, QVariant::fromValue(qvariant_cast<PropertySheetStringValue>(prop->value()).value())); break; case Qt::WhatsThisPropertyRole: - setItemData(Qt::WhatsThisRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value())); + setItemData(Qt::WhatsThisRole, QVariant::fromValue(qvariant_cast<PropertySheetStringValue>(prop->value()).value())); break; default: break; @@ -236,22 +227,22 @@ void AbstractItemEditor::resetProperty(QtProperty *property) QtVariantProperty *prop = m_propertyManager->variantProperty(property); int role = m_propertyToRole.value(prop); if (role == ItemFlagsShadowRole) - prop->setValue(qVariantFromValue((int)QListWidgetItem().flags())); + prop->setValue(QVariant::fromValue((int)QListWidgetItem().flags())); else prop->setValue(QVariant(prop->valueType(), (void *)0)); prop->setModified(false); setItemData(role, QVariant()); if (role == Qt::DecorationPropertyRole) - setItemData(Qt::DecorationRole, qVariantFromValue(QIcon())); + setItemData(Qt::DecorationRole, QVariant::fromValue(QIcon())); if (role == Qt::DisplayPropertyRole) - setItemData(Qt::EditRole, qVariantFromValue(QString())); + setItemData(Qt::EditRole, QVariant::fromValue(QString())); if (role == Qt::ToolTipPropertyRole) - setItemData(Qt::ToolTipRole, qVariantFromValue(QString())); + setItemData(Qt::ToolTipRole, QVariant::fromValue(QString())); if (role == Qt::StatusTipPropertyRole) - setItemData(Qt::StatusTipRole, qVariantFromValue(QString())); + setItemData(Qt::StatusTipRole, QVariant::fromValue(QString())); if (role == Qt::WhatsThisPropertyRole) - setItemData(Qt::WhatsThisRole, qVariantFromValue(QString())); + setItemData(Qt::WhatsThisRole, QVariant::fromValue(QString())); } void AbstractItemEditor::cacheReloaded() @@ -268,7 +259,7 @@ void AbstractItemEditor::updateBrowser() QVariant val = getItemData(role); if (!val.isValid()) { if (role == ItemFlagsShadowRole) - val = qVariantFromValue((int)QListWidgetItem().flags()); + val = QVariant::fromValue((int)QListWidgetItem().flags()); else val = QVariant((int)prop->value().userType(), (void *)0); prop->setModified(false); @@ -304,7 +295,7 @@ ItemListEditor::ItemListEditor(QDesignerFormWindowInterface *form, QWidget *pare injectPropertyBrowser(this, ui.widget); connect(ui.showPropertiesButton, SIGNAL(clicked()), this, SLOT(togglePropertyBrowser())); - togglePropertyBrowser(); + setPropertyBrowserVisible(false); QIcon upIcon = createIconSet(QString::fromUtf8("up.png")); QIcon downIcon = createIconSet(QString::fromUtf8("down.png")); @@ -340,7 +331,7 @@ void ItemListEditor::on_newListItemButton_clicked() int row = ui.listWidget->currentRow() + 1; QListWidgetItem *item = new QListWidgetItem(m_newItemText); - item->setData(Qt::DisplayPropertyRole, qVariantFromValue(PropertySheetStringValue(m_newItemText))); + item->setData(Qt::DisplayPropertyRole, QVariant::fromValue(PropertySheetStringValue(m_newItemText))); item->setFlags(item->flags() | Qt::ItemIsEditable); if (row < ui.listWidget->count()) ui.listWidget->insertItem(row, item); @@ -403,29 +394,27 @@ void ItemListEditor::on_listWidget_itemChanged(QListWidgetItem *item) if (m_updatingBrowser) return; - PropertySheetStringValue val = qVariantValue<PropertySheetStringValue>(item->data(Qt::DisplayPropertyRole)); + PropertySheetStringValue val = qvariant_cast<PropertySheetStringValue>(item->data(Qt::DisplayPropertyRole)); val.setValue(item->text()); BoolBlocker block(m_updatingBrowser); - item->setData(Qt::DisplayPropertyRole, qVariantFromValue(val)); + item->setData(Qt::DisplayPropertyRole, QVariant::fromValue(val)); // The checkState could change, too, but if this signal is connected, // checkState is not in the list anyway, as we are editing a header item. emit itemChanged(ui.listWidget->currentRow(), Qt::DisplayPropertyRole, - qVariantFromValue(val)); + QVariant::fromValue(val)); updateBrowser(); } void ItemListEditor::togglePropertyBrowser() { - // Always hide in case parent widget is not visible -> on startup - const bool isVisible = - !this->isVisible() ? true : m_propertyBrowser->isVisible(); - if (isVisible) - ui.showPropertiesButton->setText(tr("Properties &<<")); - else - ui.showPropertiesButton->setText(tr("Properties &>>")); + setPropertyBrowserVisible(!m_propertyBrowser->isVisible()); +} - m_propertyBrowser->setVisible(!isVisible); +void ItemListEditor::setPropertyBrowserVisible(bool v) +{ + ui.showPropertiesButton->setText(v ? tr("Properties &>>") : tr("Properties &<<")); + m_propertyBrowser->setVisible(v); } void ItemListEditor::setItemData(int role, const QVariant &v) @@ -438,8 +427,8 @@ void ItemListEditor::setItemData(int role, const QVariant &v) QVariant newValue = v; if (role == Qt::FontRole && newValue.type() == QVariant::Font) { QFont oldFont = ui.listWidget->font(); - QFont newFont = qVariantValue<QFont>(newValue).resolve(oldFont); - newValue = qVariantFromValue(newFont); + QFont newFont = qvariant_cast<QFont>(newValue).resolve(oldFont); + newValue = QVariant::fromValue(newFont); item->setData(role, QVariant()); // force the right font with the current resolve mask is set (item view bug) } item->setData(role, newValue); @@ -484,6 +473,6 @@ void ItemListEditor::updateEditor() else m_propertyBrowser->clear(); } -} +} // namespace qdesigner_internal QT_END_NAMESPACE diff --git a/tools/designer/src/components/taskmenu/itemlisteditor.h b/tools/designer/src/components/taskmenu/itemlisteditor.h index 2059620..ffacad2 100644 --- a/tools/designer/src/components/taskmenu/itemlisteditor.h +++ b/tools/designer/src/components/taskmenu/itemlisteditor.h @@ -53,6 +53,7 @@ class QtProperty; class QtVariantProperty; class QtTreePropertyBrowser; class QSplitter; +class QVBoxLayout; namespace qdesigner_internal { @@ -72,12 +73,12 @@ private: bool reset; }; -class AbstractItemEditor: public QDialog +class AbstractItemEditor: public QWidget { Q_OBJECT public: - AbstractItemEditor(QDesignerFormWindowInterface *form, QWidget *parent); + explicit AbstractItemEditor(QDesignerFormWindowInterface *form, QWidget *parent); ~AbstractItemEditor(); DesignerIconCache *iconCache() const { return m_iconCache; } @@ -95,7 +96,6 @@ private slots: void cacheReloaded(); protected: - void keyPressEvent(QKeyEvent *e); void setupProperties(PropertyDefinition *propDefs); void setupObject(QWidget *object); void setupEditor(QWidget *object, PropertyDefinition *propDefs); @@ -120,7 +120,7 @@ class ItemListEditor: public AbstractItemEditor Q_OBJECT public: - ItemListEditor(QDesignerFormWindowInterface *form, QWidget *parent); + explicit ItemListEditor(QDesignerFormWindowInterface *form, QWidget *parent); void setupEditor(QWidget *object, PropertyDefinition *propDefs); QListWidget *listWidget() const { return ui.listWidget; } @@ -150,6 +150,8 @@ protected: virtual void setItemData(int role, const QVariant &v); virtual QVariant getItemData(int role) const; +private: + void setPropertyBrowserVisible(bool v); void updateEditor(); Ui::ItemListEditor ui; bool m_updating; diff --git a/tools/designer/src/components/taskmenu/listwidgeteditor.h b/tools/designer/src/components/taskmenu/listwidgeteditor.h index 7719451..12d0591 100644 --- a/tools/designer/src/components/taskmenu/listwidgeteditor.h +++ b/tools/designer/src/components/taskmenu/listwidgeteditor.h @@ -45,7 +45,7 @@ #include "itemlisteditor.h" #include <qdesigner_command_p.h> -#include <QtGui/QDialog> +#include <QtGui/QWidget> QT_BEGIN_NAMESPACE diff --git a/tools/designer/src/components/taskmenu/tablewidget_taskmenu.cpp b/tools/designer/src/components/taskmenu/tablewidget_taskmenu.cpp index e3170bd..e98714f 100644 --- a/tools/designer/src/components/taskmenu/tablewidget_taskmenu.cpp +++ b/tools/designer/src/components/taskmenu/tablewidget_taskmenu.cpp @@ -94,7 +94,7 @@ void TableWidgetTaskMenu::editItems() Q_ASSERT(m_tableWidget != 0); - TableWidgetEditor dlg(m_formWindow, m_tableWidget->window()); + TableWidgetEditorDialog dlg(m_formWindow, m_tableWidget->window()); TableWidgetContents oldCont = dlg.fillContentsFromTableWidget(m_tableWidget); if (dlg.exec() == QDialog::Accepted) { TableWidgetContents newCont = dlg.contents(); diff --git a/tools/designer/src/components/taskmenu/tablewidgeteditor.cpp b/tools/designer/src/components/taskmenu/tablewidgeteditor.cpp index db1b14e..35f1a0e 100644 --- a/tools/designer/src/components/taskmenu/tablewidgeteditor.cpp +++ b/tools/designer/src/components/taskmenu/tablewidgeteditor.cpp @@ -57,10 +57,10 @@ QT_BEGIN_NAMESPACE -using namespace qdesigner_internal; +namespace qdesigner_internal { -TableWidgetEditor::TableWidgetEditor(QDesignerFormWindowInterface *form, QWidget *parent) - : AbstractItemEditor(form, parent), m_updatingBrowser(false) +TableWidgetEditor::TableWidgetEditor(QDesignerFormWindowInterface *form, QDialog *dialog) + : AbstractItemEditor(form, 0), m_updatingBrowser(false) { m_columnEditor = new ItemListEditor(form, this); m_columnEditor->setObjectName(QLatin1String("columnEditor")); @@ -68,12 +68,12 @@ TableWidgetEditor::TableWidgetEditor(QDesignerFormWindowInterface *form, QWidget m_rowEditor = new ItemListEditor(form, this); m_rowEditor->setObjectName(QLatin1String("rowEditor")); m_rowEditor->setNewItemText(tr("New Row")); - ui.setupUi(this); + ui.setupUi(dialog); injectPropertyBrowser(ui.itemsTab, ui.widget); connect(ui.showPropertiesButton, SIGNAL(clicked()), this, SLOT(togglePropertyBrowser())); - togglePropertyBrowser(); + setPropertyBrowserVisible(false); ui.tabWidget->insertTab(0, m_columnEditor, tr("&Columns")); ui.tabWidget->insertTab(1, m_rowEditor, tr("&Rows")); @@ -83,6 +83,36 @@ TableWidgetEditor::TableWidgetEditor(QDesignerFormWindowInterface *form, QWidget ui.tableWidget->setSelectionMode(QAbstractItemView::SingleSelection); connect(iconCache(), SIGNAL(reloaded()), this, SLOT(cacheReloaded())); + + connect(ui.tableWidget, SIGNAL(currentCellChanged(int,int,int,int)), + this, SLOT(on_tableWidget_currentCellChanged(int,int,int,int))); + connect(ui.tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), + this, SLOT(on_tableWidget_itemChanged(QTableWidgetItem*))); + connect(m_columnEditor, SIGNAL(indexChanged(int)), + this, SLOT(on_columnEditor_indexChanged(int))); + connect(m_columnEditor, SIGNAL(itemChanged(int,int,QVariant)), + this, SLOT(on_columnEditor_itemChanged(int,int,QVariant))); + connect(m_columnEditor, SIGNAL(itemInserted(int)), + this, SLOT(on_columnEditor_itemInserted(int))); + connect(m_columnEditor, SIGNAL(itemDeleted(int)), + this, SLOT(on_columnEditor_itemDeleted(int))); + connect(m_columnEditor, SIGNAL(itemMovedUp(int)), + this, SLOT(on_columnEditor_itemMovedUp(int))); + connect(m_columnEditor, SIGNAL(itemMovedDown(int)), + this, SLOT(on_columnEditor_itemMovedDown(int))); + + connect(m_rowEditor, SIGNAL(indexChanged(int)), + this, SLOT(on_rowEditor_indexChanged(int))); + connect(m_rowEditor, SIGNAL(itemChanged(int,int,QVariant)), + this, SLOT(on_rowEditor_itemChanged(int,int,QVariant))); + connect(m_rowEditor, SIGNAL(itemInserted(int)), + this, SLOT(on_rowEditor_itemInserted(int))); + connect(m_rowEditor, SIGNAL(itemDeleted(int)), + this, SLOT(on_rowEditor_itemDeleted(int))); + connect(m_rowEditor, SIGNAL(itemMovedUp(int)), + this, SLOT(on_rowEditor_itemMovedUp(int))); + connect(m_rowEditor, SIGNAL(itemMovedDown(int)), + this, SLOT(on_rowEditor_itemMovedDown(int))); } static AbstractItemEditor::PropertyDefinition tableHeaderPropList[] = { @@ -152,8 +182,8 @@ void TableWidgetEditor::setItemData(int role, const QVariant &v) QVariant newValue = v; if (role == Qt::FontRole && newValue.type() == QVariant::Font) { QFont oldFont = ui.tableWidget->font(); - QFont newFont = qVariantValue<QFont>(newValue).resolve(oldFont); - newValue = qVariantFromValue(newFont); + QFont newFont = qvariant_cast<QFont>(newValue).resolve(oldFont); + newValue = QVariant::fromValue(newFont); item->setData(role, QVariant()); // force the right font with the current resolve mask is set (item view bug) } item->setData(role, newValue); @@ -179,10 +209,10 @@ void TableWidgetEditor::on_tableWidget_itemChanged(QTableWidgetItem *item) if (m_updatingBrowser) return; - PropertySheetStringValue val = qVariantValue<PropertySheetStringValue>(item->data(Qt::DisplayPropertyRole)); + PropertySheetStringValue val = qvariant_cast<PropertySheetStringValue>(item->data(Qt::DisplayPropertyRole)); val.setValue(item->text()); BoolBlocker block(m_updatingBrowser); - item->setData(Qt::DisplayPropertyRole, qVariantFromValue(val)); + item->setData(Qt::DisplayPropertyRole, QVariant::fromValue(val)); updateBrowser(); } @@ -207,16 +237,15 @@ void TableWidgetEditor::on_rowEditor_itemChanged(int idx, int role, const QVaria ui.tableWidget->verticalHeaderItem(idx)->setData(role, v); } +void TableWidgetEditor::setPropertyBrowserVisible(bool v) +{ + ui.showPropertiesButton->setText(v ? tr("Properties &>>") : tr("Properties &<<")); + m_propertyBrowser->setVisible(v); +} + void TableWidgetEditor::togglePropertyBrowser() { - // Always hide in case parent widget is not visible -> on startup - const bool isVisible = - !this->isVisible() ? true : m_propertyBrowser->isVisible(); - if (isVisible) - ui.showPropertiesButton->setText(tr("Properties &<<")); - else - ui.showPropertiesButton->setText(tr("Properties &>>")); - m_propertyBrowser->setVisible(!isVisible); + setPropertyBrowserVisible(!m_propertyBrowser->isVisible()); } void TableWidgetEditor::updateEditor() @@ -317,7 +346,7 @@ void TableWidgetEditor::on_columnEditor_itemInserted(int idx) ui.tableWidget->setColumnCount(columnCount + 1); QTableWidgetItem *newItem = new QTableWidgetItem(m_columnEditor->newItemText()); - newItem->setData(Qt::DisplayPropertyRole, qVariantFromValue(PropertySheetStringValue(m_columnEditor->newItemText()))); + newItem->setData(Qt::DisplayPropertyRole, QVariant::fromValue(PropertySheetStringValue(m_columnEditor->newItemText()))); ui.tableWidget->setHorizontalHeaderItem(columnCount, newItem); moveColumnsLeft(idx, columnCount); @@ -359,7 +388,7 @@ void TableWidgetEditor::on_rowEditor_itemInserted(int idx) ui.tableWidget->setRowCount(rowCount + 1); QTableWidgetItem *newItem = new QTableWidgetItem(m_rowEditor->newItemText()); - newItem->setData(Qt::DisplayPropertyRole, qVariantFromValue(PropertySheetStringValue(m_rowEditor->newItemText()))); + newItem->setData(Qt::DisplayPropertyRole, QVariant::fromValue(PropertySheetStringValue(m_rowEditor->newItemText()))); ui.tableWidget->setVerticalHeaderItem(rowCount, newItem); moveRowsDown(idx, rowCount); @@ -400,4 +429,22 @@ void TableWidgetEditor::cacheReloaded() reloadIconResources(iconCache(), ui.tableWidget); } +TableWidgetEditorDialog::TableWidgetEditorDialog(QDesignerFormWindowInterface *form, QWidget *parent) : + QDialog(parent), m_editor(form, this) +{ + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); +} + +TableWidgetContents TableWidgetEditorDialog::fillContentsFromTableWidget(QTableWidget *tableWidget) +{ + return m_editor.fillContentsFromTableWidget(tableWidget); +} + +TableWidgetContents TableWidgetEditorDialog::contents() const +{ + return m_editor.contents(); +} + +} // namespace qdesigner_internal + QT_END_NAMESPACE diff --git a/tools/designer/src/components/taskmenu/tablewidgeteditor.h b/tools/designer/src/components/taskmenu/tablewidgeteditor.h index cea2e2f..1d5ad1f 100644 --- a/tools/designer/src/components/taskmenu/tablewidgeteditor.h +++ b/tools/designer/src/components/taskmenu/tablewidgeteditor.h @@ -46,6 +46,8 @@ #include "listwidgeteditor.h" +#include <QtGui/QDialog> + QT_BEGIN_NAMESPACE class QTableWidget; @@ -60,7 +62,7 @@ class TableWidgetEditor: public AbstractItemEditor { Q_OBJECT public: - TableWidgetEditor(QDesignerFormWindowInterface *form, QWidget *parent); + explicit TableWidgetEditor(QDesignerFormWindowInterface *form, QDialog *dialog); TableWidgetContents fillContentsFromTableWidget(QTableWidget *tableWidget); TableWidgetContents contents() const; @@ -95,6 +97,7 @@ protected: virtual QVariant getItemData(int role) const; private: + void setPropertyBrowserVisible(bool v); void updateEditor(); void moveColumnsLeft(int fromColumn, int toColumn); void moveColumnsRight(int fromColumn, int toColumn); @@ -107,6 +110,19 @@ private: bool m_updatingBrowser; }; +class TableWidgetEditorDialog : public QDialog +{ + Q_OBJECT +public: + explicit TableWidgetEditorDialog(QDesignerFormWindowInterface *form, QWidget *parent); + + TableWidgetContents fillContentsFromTableWidget(QTableWidget *tableWidget); + TableWidgetContents contents() const; + +private: + TableWidgetEditor m_editor; +}; + } // namespace qdesigner_internal QT_END_NAMESPACE diff --git a/tools/designer/src/components/taskmenu/treewidget_taskmenu.cpp b/tools/designer/src/components/taskmenu/treewidget_taskmenu.cpp index 882c656..96210dc 100644 --- a/tools/designer/src/components/taskmenu/treewidget_taskmenu.cpp +++ b/tools/designer/src/components/taskmenu/treewidget_taskmenu.cpp @@ -93,7 +93,7 @@ void TreeWidgetTaskMenu::editItems() Q_ASSERT(m_treeWidget != 0); - TreeWidgetEditor dlg(m_formWindow, m_treeWidget->window()); + TreeWidgetEditorDialog dlg(m_formWindow, m_treeWidget->window()); TreeWidgetContents oldCont = dlg.fillContentsFromTreeWidget(m_treeWidget); if (dlg.exec() == QDialog::Accepted) { TreeWidgetContents newCont = dlg.contents(); diff --git a/tools/designer/src/components/taskmenu/treewidgeteditor.cpp b/tools/designer/src/components/taskmenu/treewidgeteditor.cpp index ae1fe12..f5f6035 100644 --- a/tools/designer/src/components/taskmenu/treewidgeteditor.cpp +++ b/tools/designer/src/components/taskmenu/treewidgeteditor.cpp @@ -60,18 +60,18 @@ QT_BEGIN_NAMESPACE namespace qdesigner_internal { -TreeWidgetEditor::TreeWidgetEditor(QDesignerFormWindowInterface *form, QWidget *parent) - : AbstractItemEditor(form, parent), m_updatingBrowser(false) +TreeWidgetEditor::TreeWidgetEditor(QDesignerFormWindowInterface *form, QDialog *dialog) + : AbstractItemEditor(form, 0), m_updatingBrowser(false) { m_columnEditor = new ItemListEditor(form, this); m_columnEditor->setObjectName(QLatin1String("columnEditor")); m_columnEditor->setNewItemText(tr("New Column")); - ui.setupUi(this); + ui.setupUi(dialog); injectPropertyBrowser(ui.itemsTab, ui.widget); connect(ui.showPropertiesButton, SIGNAL(clicked()), this, SLOT(togglePropertyBrowser())); - togglePropertyBrowser(); + setPropertyBrowserVisible(false); ui.tabWidget->insertTab(0, m_columnEditor, tr("&Columns")); ui.tabWidget->setCurrentIndex(0); @@ -87,6 +87,30 @@ TreeWidgetEditor::TreeWidgetEditor(QDesignerFormWindowInterface *form, QWidget * ui.treeWidget->header()->setMovable(false); + connect(ui.newItemButton, SIGNAL(clicked()), this, SLOT(on_newItemButton_clicked())); + connect(ui.newSubItemButton, SIGNAL(clicked()), this, SLOT(on_newSubItemButton_clicked())); + connect(ui.moveItemUpButton, SIGNAL(clicked()), this, SLOT(on_moveItemUpButton_clicked())); + connect(ui.moveItemDownButton, SIGNAL(clicked()), this, SLOT(on_moveItemDownButton_clicked())); + connect(ui.moveItemRightButton, SIGNAL(clicked()), this, SLOT(on_moveItemRightButton_clicked())); + connect(ui.moveItemLeftButton, SIGNAL(clicked()), this, SLOT(on_moveItemLeftButton_clicked())); + connect(ui.treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), + this, SLOT(on_treeWidget_currentItemChanged())); + connect(ui.treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)), + this, SLOT(on_treeWidget_itemChanged(QTreeWidgetItem*,int))); + + connect(m_columnEditor, SIGNAL(indexChanged(int)), + this, SLOT(on_columnEditor_indexChanged(int))); + connect(m_columnEditor, SIGNAL(itemChanged(int,int,QVariant)), + this, SLOT(on_columnEditor_itemChanged(int,int,QVariant))); + connect(m_columnEditor, SIGNAL(itemInserted(int)), + this, SLOT(on_columnEditor_itemInserted(int))); + connect(m_columnEditor, SIGNAL(itemDeleted(int)), + this, SLOT(on_columnEditor_itemDeleted(int))); + connect(m_columnEditor, SIGNAL(itemMovedUp(int)), + this, SLOT(on_columnEditor_itemMovedUp(int))); + connect(m_columnEditor, SIGNAL(itemMovedDown(int)), + this, SLOT(on_columnEditor_itemMovedDown(int))); + connect(iconCache(), SIGNAL(reloaded()), this, SLOT(cacheReloaded())); } @@ -171,8 +195,8 @@ void TreeWidgetEditor::setItemData(int role, const QVariant &v) BoolBlocker block(m_updatingBrowser); if (role == Qt::FontRole && newValue.type() == QVariant::Font) { QFont oldFont = ui.treeWidget->font(); - QFont newFont = qVariantValue<QFont>(newValue).resolve(oldFont); - newValue = qVariantFromValue(newFont); + QFont newFont = qvariant_cast<QFont>(newValue).resolve(oldFont); + newValue = QVariant::fromValue(newFont); ui.treeWidget->currentItem()->setData(col, role, QVariant()); // force the right font with the current resolve mask is set (item view bug) } ui.treeWidget->currentItem()->setData(col, role, newValue); @@ -198,7 +222,7 @@ void TreeWidgetEditor::on_newItemButton_clicked() newItem = new QTreeWidgetItem(ui.treeWidget); const QString newItemText = tr("New Item"); newItem->setText(0, newItemText); - newItem->setData(0, Qt::DisplayPropertyRole, qVariantFromValue(PropertySheetStringValue(newItemText))); + newItem->setData(0, Qt::DisplayPropertyRole, QVariant::fromValue(PropertySheetStringValue(newItemText))); newItem->setFlags(newItem->flags() | Qt::ItemIsEditable); ui.treeWidget->blockSignals(false); @@ -217,7 +241,7 @@ void TreeWidgetEditor::on_newSubItemButton_clicked() QTreeWidgetItem *newItem = new QTreeWidgetItem(curItem); const QString newItemText = tr("New Subitem"); newItem->setText(0, newItemText); - newItem->setData(0, Qt::DisplayPropertyRole, qVariantFromValue(PropertySheetStringValue(newItemText))); + newItem->setData(0, Qt::DisplayPropertyRole, QVariant::fromValue(PropertySheetStringValue(newItemText))); newItem->setFlags(newItem->flags() | Qt::ItemIsEditable); ui.treeWidget->blockSignals(false); @@ -386,15 +410,13 @@ void TreeWidgetEditor::on_moveItemRightButton_clicked() void TreeWidgetEditor::togglePropertyBrowser() { - // Always hide in case parent widget is not visible -> on startup - const bool isVisible = - !this->isVisible() ? true : m_propertyBrowser->isVisible(); - if (isVisible) - ui.showPropertiesButton->setText(tr("Properties &<<")); - else - ui.showPropertiesButton->setText(tr("Properties &>>")); + setPropertyBrowserVisible(!m_propertyBrowser->isVisible()); +} - m_propertyBrowser->setVisible(!isVisible); +void TreeWidgetEditor::setPropertyBrowserVisible(bool v) +{ + ui.showPropertiesButton->setText(v ? tr("Properties &>>") : tr("Properties &<<")); + m_propertyBrowser->setVisible(v); } void TreeWidgetEditor::on_treeWidget_currentItemChanged() @@ -408,10 +430,10 @@ void TreeWidgetEditor::on_treeWidget_itemChanged(QTreeWidgetItem *item, int colu if (m_updatingBrowser) return; - PropertySheetStringValue val = qVariantValue<PropertySheetStringValue>(item->data(column, Qt::DisplayPropertyRole)); + PropertySheetStringValue val = qvariant_cast<PropertySheetStringValue>(item->data(column, Qt::DisplayPropertyRole)); val.setValue(item->text(column)); BoolBlocker block(m_updatingBrowser); - item->setData(column, Qt::DisplayPropertyRole, qVariantFromValue(val)); + item->setData(column, Qt::DisplayPropertyRole, QVariant::fromValue(val)); updateBrowser(); } @@ -425,7 +447,7 @@ void TreeWidgetEditor::on_columnEditor_indexChanged(int idx) void TreeWidgetEditor::on_columnEditor_itemChanged(int idx, int role, const QVariant &v) { if (role == Qt::DisplayPropertyRole) - ui.treeWidget->headerItem()->setData(idx, Qt::EditRole, qVariantValue<PropertySheetStringValue>(v).value()); + ui.treeWidget->headerItem()->setData(idx, Qt::EditRole, qvariant_cast<PropertySheetStringValue>(v).value()); ui.treeWidget->headerItem()->setData(idx, role, v); } @@ -599,5 +621,22 @@ void TreeWidgetEditor::cacheReloaded() reloadIconResources(iconCache(), ui.treeWidget); } +TreeWidgetEditorDialog::TreeWidgetEditorDialog(QDesignerFormWindowInterface *form, QWidget *parent) : + QDialog(parent), m_editor(form, this) +{ + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); +} + +TreeWidgetContents TreeWidgetEditorDialog::fillContentsFromTreeWidget(QTreeWidget *treeWidget) +{ + return m_editor.fillContentsFromTreeWidget(treeWidget); } + +TreeWidgetContents TreeWidgetEditorDialog::contents() const +{ + return m_editor.contents(); +} + +} // namespace qdesigner_internal + QT_END_NAMESPACE diff --git a/tools/designer/src/components/taskmenu/treewidgeteditor.h b/tools/designer/src/components/taskmenu/treewidgeteditor.h index 461b20f..f502bf3 100644 --- a/tools/designer/src/components/taskmenu/treewidgeteditor.h +++ b/tools/designer/src/components/taskmenu/treewidgeteditor.h @@ -46,6 +46,8 @@ #include "listwidgeteditor.h" +#include <QtGui/QDialog> + QT_BEGIN_NAMESPACE class QTreeWidget; @@ -60,7 +62,7 @@ class TreeWidgetEditor: public AbstractItemEditor { Q_OBJECT public: - TreeWidgetEditor(QDesignerFormWindowInterface *form, QWidget *parent); + explicit TreeWidgetEditor(QDesignerFormWindowInterface *form, QDialog *dialog); TreeWidgetContents fillContentsFromTreeWidget(QTreeWidget *treeWidget); TreeWidgetContents contents() const; @@ -93,6 +95,7 @@ protected: virtual QVariant getItemData(int role) const; private: + void setPropertyBrowserVisible(bool v); QtVariantProperty *setupPropertyGroup(const QString &title, PropertyDefinition *propDefs); void updateEditor(); void moveColumnItems(const PropertyDefinition *propList, QTreeWidgetItem *item, int fromColumn, int toColumn, int step); @@ -106,6 +109,19 @@ private: bool m_updatingBrowser; }; +class TreeWidgetEditorDialog : public QDialog +{ + Q_OBJECT +public: + explicit TreeWidgetEditorDialog(QDesignerFormWindowInterface *form, QWidget *parent); + + TreeWidgetContents fillContentsFromTreeWidget(QTreeWidget *treeWidget); + TreeWidgetContents contents() const; + +private: + TreeWidgetEditor m_editor; +}; + } // namespace qdesigner_internal QT_END_NAMESPACE diff --git a/tools/designer/src/components/widgetbox/widgetbox_dnditem.cpp b/tools/designer/src/components/widgetbox/widgetbox_dnditem.cpp index b25bc23..c122c84 100644 --- a/tools/designer/src/components/widgetbox/widgetbox_dnditem.cpp +++ b/tools/designer/src/components/widgetbox/widgetbox_dnditem.cpp @@ -185,7 +185,7 @@ static QWidget *decorationFromDomWidget(DomUI *dom_ui, QDesignerFormEditorInterf fakeTopLevel->setParent(0, Qt::ToolTip); // Container // Actual widget const DomWidget *domW = dom_ui->elementWidget()->elementWidget().front(); - QWidget *w = qFindChildren<QWidget*>(fakeTopLevel).front(); + QWidget *w = fakeTopLevel->findChildren<QWidget*>().front(); Q_ASSERT(w); // hack begin; // We set _q_dockDrag dynamic property which will be detected in drag enter event of form window. diff --git a/tools/designer/src/designer/qdesigner_formwindow.cpp b/tools/designer/src/designer/qdesigner_formwindow.cpp index 1fbdcec..4770d2a 100644 --- a/tools/designer/src/designer/qdesigner_formwindow.cpp +++ b/tools/designer/src/designer/qdesigner_formwindow.cpp @@ -159,6 +159,7 @@ void QDesignerFormWindow::firstShow() if (m_editor) { connect(m_editor, SIGNAL(fileNameChanged(QString)), this, SLOT(updateWindowTitle(QString))); updateWindowTitle(m_editor->fileName()); + updateChanged(); } } show(); diff --git a/tools/designer/src/designer/qdesigner_settings.cpp b/tools/designer/src/designer/qdesigner_settings.cpp index 1a038f1..89bec14 100644 --- a/tools/designer/src/designer/qdesigner_settings.cpp +++ b/tools/designer/src/designer/qdesigner_settings.cpp @@ -241,7 +241,7 @@ ToolWindowFontSettings QDesignerSettings::toolWindowFont() const fontSettings.m_writingSystem = static_cast<QFontDatabase::WritingSystem>(value(QLatin1String("UI/writingSystem"), QFontDatabase::Any).toInt()); - fontSettings.m_font = qVariantValue<QFont>(value(QLatin1String("UI/font"))); + fontSettings.m_font = qvariant_cast<QFont>(value(QLatin1String("UI/font"))); fontSettings.m_useFont = settings()->value(QLatin1String("UI/useFont"), QVariant(false)).toBool(); return fontSettings; diff --git a/tools/designer/src/designer/qdesigner_workbench.cpp b/tools/designer/src/designer/qdesigner_workbench.cpp index 836feb7..ffc4b8c 100644 --- a/tools/designer/src/designer/qdesigner_workbench.cpp +++ b/tools/designer/src/designer/qdesigner_workbench.cpp @@ -198,7 +198,7 @@ QDesignerWorkbench::QDesignerWorkbench() : // Build main menu bar addMenu(m_globalMenuBar, tr("&File"), m_actionManager->fileActions()->actions()); - QMenu *editMenu = addMenu(m_globalMenuBar, tr("Edit"), m_actionManager->editActions()->actions()); + QMenu *editMenu = addMenu(m_globalMenuBar, tr("&Edit"), m_actionManager->editActions()->actions()); editMenu->addSeparator(); addActionsToMenu(editMenu, m_actionManager->toolActions()->actions()); @@ -966,7 +966,9 @@ QDesignerFormWindow * QDesignerWorkbench::loadForm(const QString &fileName, return 0; } *uic3Converted = editor->fileName().isEmpty(); - editor->setDirty(false); + // Did user specify another (missing) resource path -> set dirty. + const bool dirty = editor->property("_q_resourcepathchanged").toBool(); + editor->setDirty(dirty); resizeForm(formWindow, editor->mainContainer()); formWindowManager->setActiveFormWindow(editor); return formWindow; diff --git a/tools/designer/src/lib/lib.pro b/tools/designer/src/lib/lib.pro index 495976d..3ba6f52 100644 --- a/tools/designer/src/lib/lib.pro +++ b/tools/designer/src/lib/lib.pro @@ -13,7 +13,7 @@ isEmpty(QT_MAJOR_VERSION) { VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} } -unix:QMAKE_PKGCONFIG_REQUIRES += QtXml +unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES += QtXml include(../../../../src/qt_targets.pri) QMAKE_TARGET_PRODUCT = Designer diff --git a/tools/designer/src/lib/sdk/abstractintegration.cpp b/tools/designer/src/lib/sdk/abstractintegration.cpp index b8e4a22..0c888f6 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 b24e34b..9e27f90 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 251730e..fb882c3 100644 --- a/tools/designer/src/lib/shared/actioneditor.cpp +++ b/tools/designer/src/lib/shared/actioneditor.cpp @@ -288,7 +288,7 @@ void ActionEditor::setFormWindow(QDesignerFormWindowInterface *formWindow) return; if (m_formWindow != 0) { - const ActionList actionList = qFindChildren<QAction*>(m_formWindow->mainContainer()); + const ActionList actionList = m_formWindow->mainContainer()->findChildren<QAction*>(); foreach (QAction *action, actionList) disconnect(action, SIGNAL(changed()), this, SLOT(slotActionChanged())); } @@ -311,7 +311,7 @@ void ActionEditor::setFormWindow(QDesignerFormWindowInterface *formWindow) m_actionNew->setEnabled(true); m_filterWidget->setEnabled(true); - const ActionList actionList = qFindChildren<QAction*>(formWindow->mainContainer()); + const ActionList actionList = formWindow->mainContainer()->findChildren<QAction*>(); foreach (QAction *action, actionList) if (!action->isSeparator() && core()->metaDataBase()->item(action) != 0) { // Show unless it has a menu. However, listen for change on menu actions also as it might be removed @@ -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); @@ -459,9 +458,9 @@ void ActionEditor::slotNewAction() setInitialProperty(sheet, QLatin1String(checkablePropertyC), QVariant(true)); if (!actionData.keysequence.value().isEmpty()) - setInitialProperty(sheet, QLatin1String(shortcutPropertyC), qVariantFromValue(actionData.keysequence)); + setInitialProperty(sheet, QLatin1String(shortcutPropertyC), QVariant::fromValue(actionData.keysequence)); - sheet->setProperty(sheet->indexOf(QLatin1String(iconPropertyC)), qVariantFromValue(actionData.icon)); + sheet->setProperty(sheet->indexOf(QLatin1String(iconPropertyC)), QVariant::fromValue(actionData.icon)); AddActionCommand *cmd = new AddActionCommand(formWindow()); cmd->init(action); @@ -480,13 +479,13 @@ 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; } SetPropertyCommand *cmd = new SetPropertyCommand(fw); - cmd->init(action, iconProperty, qVariantFromValue(newIcon)); + cmd->init(action, iconProperty, QVariant::fromValue(newIcon)); return cmd; } @@ -502,7 +501,7 @@ static QDesignerFormWindowCommand *setKeySequencePropertyCommand(const PropertyS return cmd; } SetPropertyCommand *cmd = new SetPropertyCommand(fw); - cmd->init(action, shortcutProperty, qVariantFromValue(ks)); + cmd->init(action, shortcutProperty, QVariant::fromValue(ks)); return cmd; } @@ -528,7 +527,7 @@ static inline QString textPropertyValue(const QDesignerPropertySheetExtension *s { const int index = sheet->indexOf(name); Q_ASSERT(index != -1); - const PropertySheetStringValue ps = qVariantValue<PropertySheetStringValue>(sheet->property(index)); + const PropertySheetStringValue ps = qvariant_cast<PropertySheetStringValue>(sheet->property(index)); return ps.value(); } @@ -545,7 +544,7 @@ void ActionEditor::editAction(QAction *action) oldActionData.name = action->objectName(); oldActionData.text = action->text(); oldActionData.toolTip = textPropertyValue(sheet, QLatin1String(toolTipPropertyC)); - oldActionData.icon = qVariantValue<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC)))); + oldActionData.icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC)))); oldActionData.keysequence = ActionModel::actionShortCut(sheet); oldActionData.checkable = action->isCheckable(); dlg.setActionData(oldActionData); @@ -677,7 +676,7 @@ void ActionEditor::resourceImageDropped(const QString &path, QAction *action) QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action); const PropertySheetIconValue oldIcon = - qVariantValue<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC)))); + qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC)))); PropertySheetIconValue newIcon; newIcon.setPixmap(QIcon::Normal, QIcon::Off, PropertySheetPixmapValue(path)); if (newIcon.paths().isEmpty() || newIcon.paths() == oldIcon.paths()) diff --git a/tools/designer/src/lib/shared/actionrepository.cpp b/tools/designer/src/lib/shared/actionrepository.cpp index ba00feb..d7701cb 100644 --- a/tools/designer/src/lib/shared/actionrepository.cpp +++ b/tools/designer/src/lib/shared/actionrepository.cpp @@ -136,7 +136,7 @@ QModelIndex ActionModel::addAction(QAction *action) const Qt::ItemFlags flags = Qt::ItemIsSelectable|Qt::ItemIsDropEnabled|Qt::ItemIsDragEnabled|Qt::ItemIsEnabled; QVariant itemData; - qVariantSetValue(itemData, action); + itemData.setValue(action); for (int i = 0; i < NumColumns; i++) { QStandardItem *item = new QStandardItem; diff --git a/tools/designer/src/lib/shared/connectionedit.cpp b/tools/designer/src/lib/shared/connectionedit.cpp index c193da7..5f5085c 100644 --- a/tools/designer/src/lib/shared/connectionedit.cpp +++ b/tools/designer/src/lib/shared/connectionedit.cpp @@ -1395,7 +1395,7 @@ void ConnectionEdit::widgetRemoved(QWidget *widget) if (m_con_list.empty()) return; - QWidgetList child_list = qFindChildren<QWidget*>(widget); + QWidgetList child_list = widget->findChildren<QWidget*>(); child_list.prepend(widget); const ConnectionSet remove_set = findConnectionsOf(m_con_list, child_list.constBegin(), child_list.constEnd()); @@ -1545,7 +1545,7 @@ void ConnectionEdit::setSource(Connection *con, const QString &obj_name) { QObject *object = 0; if (!obj_name.isEmpty()) { - object = qFindChild<QObject*>(m_bg_widget, obj_name); + object = m_bg_widget->findChild<QObject*>(obj_name); if (object == 0 && m_bg_widget->objectName() == obj_name) object = m_bg_widget; @@ -1559,7 +1559,7 @@ void ConnectionEdit::setTarget(Connection *con, const QString &obj_name) { QObject *object = 0; if (!obj_name.isEmpty()) { - object = qFindChild<QObject*>(m_bg_widget, obj_name); + object = m_bg_widget->findChild<QObject*>(obj_name); if (object == 0 && m_bg_widget->objectName() == obj_name) object = m_bg_widget; diff --git a/tools/designer/src/lib/shared/formlayoutmenu.cpp b/tools/designer/src/lib/shared/formlayoutmenu.cpp index 544b721..d52bb53 100644 --- a/tools/designer/src/lib/shared/formlayoutmenu.cpp +++ b/tools/designer/src/lib/shared/formlayoutmenu.cpp @@ -432,16 +432,16 @@ static QPair<QWidget *,QWidget *> const QString objectNameProperty = QLatin1String("objectName"); QDesignerPropertySheetExtension *labelSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), rc.first); int nameIndex = labelSheet->indexOf(objectNameProperty); - labelSheet->setProperty(nameIndex, qVariantFromValue(PropertySheetStringValue(row.labelName))); + labelSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.labelName))); labelSheet->setChanged(nameIndex, true); formWindow->ensureUniqueObjectName(rc.first); const int textIndex = labelSheet->indexOf(QLatin1String("text")); - labelSheet->setProperty(textIndex, qVariantFromValue(PropertySheetStringValue(row.labelText))); + labelSheet->setProperty(textIndex, QVariant::fromValue(PropertySheetStringValue(row.labelText))); labelSheet->setChanged(textIndex, true); // Set up properties of the control QDesignerPropertySheetExtension *controlSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), rc.second); nameIndex = controlSheet->indexOf(objectNameProperty); - controlSheet->setProperty(nameIndex, qVariantFromValue(PropertySheetStringValue(row.fieldName))); + controlSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.fieldName))); controlSheet->setChanged(nameIndex, true); formWindow->ensureUniqueObjectName(rc.second); return rc; diff --git a/tools/designer/src/lib/shared/formwindowbase.cpp b/tools/designer/src/lib/shared/formwindowbase.cpp index ba34805..7c87eaf 100644 --- a/tools/designer/src/lib/shared/formwindowbase.cpp +++ b/tools/designer/src/lib/shared/formwindowbase.cpp @@ -184,11 +184,11 @@ void FormWindowBase::reloadProperties() const int index = itIndex.next().key(); const QVariant newValue = sheet->property(index); if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == QLatin1String("text")) { - const PropertySheetStringValue newString = qVariantValue<PropertySheetStringValue>(newValue); + const PropertySheetStringValue newString = qvariant_cast<PropertySheetStringValue>(newValue); // optimize a bit, reset only if the text value might contain a reference to qt resources // (however reloading of icons other than taken from resources might not work here) if (newString.value().contains(QLatin1String(":/"))) { - const QVariant resetValue = qVariantFromValue(PropertySheetStringValue()); + const QVariant resetValue = QVariant::fromValue(PropertySheetStringValue()); sheet->setProperty(index, resetValue); } } diff --git a/tools/designer/src/lib/shared/grid.cpp b/tools/designer/src/lib/shared/grid.cpp index 57ee2f7..ba991c7 100644 --- a/tools/designer/src/lib/shared/grid.cpp +++ b/tools/designer/src/lib/shared/grid.cpp @@ -71,7 +71,7 @@ template <class T> const QVariantMap::const_iterator it = v.constFind(key); const bool found = it != v.constEnd(); if (found) - value = qVariantValue<T>(it.value()); + value = qvariant_cast<T>(it.value()); return found; } @@ -89,12 +89,20 @@ Grid::Grid() : bool Grid::fromVariantMap(const QVariantMap& vm) { - *this = Grid(); - valueFromVariantMap(vm, QLatin1String(KEY_VISIBLE), m_visible); - valueFromVariantMap(vm, QLatin1String(KEY_SNAPX), m_snapX); - valueFromVariantMap(vm, QLatin1String(KEY_SNAPY), m_snapY); - valueFromVariantMap(vm, QLatin1String(KEY_DELTAX), m_deltaX); - return valueFromVariantMap(vm, QLatin1String(KEY_DELTAY), m_deltaY); + Grid grid; + bool anyData = valueFromVariantMap(vm, QLatin1String(KEY_VISIBLE), grid.m_visible); + anyData |= valueFromVariantMap(vm, QLatin1String(KEY_SNAPX), grid.m_snapX); + anyData |= valueFromVariantMap(vm, QLatin1String(KEY_SNAPY), grid.m_snapY); + anyData |= valueFromVariantMap(vm, QLatin1String(KEY_DELTAX), grid.m_deltaX); + anyData |= valueFromVariantMap(vm, QLatin1String(KEY_DELTAY), grid.m_deltaY); + if (!anyData) + return false; + if (grid.m_deltaX == 0 || grid.m_deltaY == 0) { + qWarning("Attempt to set invalid grid with a spacing of 0."); + return false; + } + *this = grid; + return true; } QVariantMap Grid::toVariantMap(bool forceKeys) const diff --git a/tools/designer/src/lib/shared/iconselector.cpp b/tools/designer/src/lib/shared/iconselector.cpp index 9248129..0d6e3e0 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 50ad938..4f68b73 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/layoutinfo.cpp b/tools/designer/src/lib/shared/layoutinfo.cpp index 8f2d509..804d069 100644 --- a/tools/designer/src/lib/shared/layoutinfo.cpp +++ b/tools/designer/src/lib/shared/layoutinfo.cpp @@ -190,7 +190,7 @@ LayoutInfo::Type LayoutInfo::laidoutWidgetType(const QDesignerFormEditorInterfac } // 3) Some child layout (see below comment about Q3GroupBox) - const QList<QLayout*> childLayouts = qFindChildren<QLayout*>(parentLayout); + const QList<QLayout*> childLayouts = parentLayout->findChildren<QLayout*>(); if (childLayouts.empty()) return NoLayout; const QList<QLayout*>::const_iterator lcend = childLayouts.constEnd(); @@ -244,7 +244,7 @@ QLayout *LayoutInfo::managedLayout(const QDesignerFormEditorInterface *core, QLa * widget->layout() returns an internal VBoxLayout. */ const QDesignerMetaDataBaseItemInterface *item = metaDataBase->item(layout); if (item == 0) { - layout = qFindChild<QLayout*>(layout); + layout = layout->findChild<QLayout*>(); item = metaDataBase->item(layout); } if (!item) diff --git a/tools/designer/src/lib/shared/morphmenu.cpp b/tools/designer/src/lib/shared/morphmenu.cpp index e4c5b81..67121e5 100644 --- a/tools/designer/src/lib/shared/morphmenu.cpp +++ b/tools/designer/src/lib/shared/morphmenu.cpp @@ -193,7 +193,7 @@ static QStringList classesOfCategory(MorphCategory cat) << QLatin1String("QSpinBox") << QLatin1String("QDoubleSpinBox"); break; case MorphTextEdit: - l << QLatin1String("QTextEdit") << QLatin1String("QPlainTextEdit"); + l << QLatin1String("QTextEdit") << QLatin1String("QPlainTextEdit") << QLatin1String("QTextBrowser"); break; } } @@ -240,7 +240,7 @@ static QString suggestObjectName(const QString &oldClassName, const QString &new QLabel *buddyLabelOf(QDesignerFormWindowInterface *fw, QWidget *w) { typedef QList<QLabel*> LabelList; - const LabelList labelList = qFindChildren<QLabel*>(fw); + const LabelList labelList = fw->findChildren<QLabel*>(); if (labelList.empty()) return 0; const LabelList::const_iterator cend = labelList.constEnd(); @@ -256,11 +256,11 @@ static void replaceWidgetListDynamicProperty(QWidget *parentWidget, QWidget *oldWidget, QWidget *newWidget, const char *name) { - QWidgetList list = qVariantValue<QWidgetList>(parentWidget->property(name)); + QWidgetList list = qvariant_cast<QWidgetList>(parentWidget->property(name)); const int index = list.indexOf(oldWidget); if (index != -1) { list.replace(index, newWidget); - parentWidget->setProperty(name, qVariantFromValue(list)); + parentWidget->setProperty(name, QVariant::fromValue(list)); } } diff --git a/tools/designer/src/lib/shared/newactiondialog.cpp b/tools/designer/src/lib/shared/newactiondialog.cpp index d4444ab..9aaa347 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 ed210a7..aef9710 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,51 @@ <item row="1" column="1"> <widget class="QLineEdit" name="editObjectName"/> </item> + <item row="2" column="0"> + <widget class="QLabel" name="toolTipLabel"> + <property name="text"> + <string>T&oolTip:</string> + </property> + <property name="buddy"> + <cstring>tooltipEditor</cstring> + </property> + </widget> + </item> + <item row="2" column="1"> + <layout class="QHBoxLayout" name="toolTipLayout"> + <item> + <widget class="TextPropertyEditor" name="tooltipEditor" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="toolTipToolButton"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> <item row="3" column="0"> + <widget class="QLabel" name="iconThemeLabel"> + <property name="text"> + <string>Icon th&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> + <item row="4" column="0"> <widget class="QLabel" name="iconLabel"> <property name="text"> <string>&Icon:</string> @@ -91,7 +143,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,56 +163,34 @@ </item> </layout> </item> - <item row="5" column="0"> - <widget class="QLabel" name="shortcutLabel"> - <property name="text"> - <string>Shortcut:</string> - </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>&Checkable:</string> + </property> + <property name="buddy"> + <cstring>checkableCheckBox</cstring> </property> </widget> </item> - <item row="2" column="0"> - <widget class="QLabel" name="toolTipLabel"> + <item row="6" column="0"> + <widget class="QLabel" name="shortcutLabel"> <property name="text"> - <string>ToolTip:</string> + <string>&Shortcut:</string> + </property> + <property name="buddy"> + <cstring>keySequenceEdit</cstring> </property> </widget> </item> - <item row="2" column="1"> - <layout class="QHBoxLayout" name="toolTipLayout"> - <item> - <widget class="TextPropertyEditor" name="tooltipEditor" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="toolTipToolButton"> - <property name="text"> - <string>...</string> - </property> - </widget> - </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"> @@ -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/qdesigner_command.cpp b/tools/designer/src/lib/shared/qdesigner_command.cpp index 295c94a..f4e250d 100644 --- a/tools/designer/src/lib/shared/qdesigner_command.cpp +++ b/tools/designer/src/lib/shared/qdesigner_command.cpp @@ -107,23 +107,23 @@ static const char *zOrderPropertyC = "_q_zOrder"; static void addToWidgetListDynamicProperty(QWidget *parentWidget, QWidget *widget, const char *name, int index = -1) { - QWidgetList list = qVariantValue<QWidgetList>(parentWidget->property(name)); + QWidgetList list = qvariant_cast<QWidgetList>(parentWidget->property(name)); list.removeAll(widget); if (index >= 0 && index < list.size()) { list.insert(index, widget); } else { list.append(widget); } - parentWidget->setProperty(name, qVariantFromValue(list)); + parentWidget->setProperty(name, QVariant::fromValue(list)); } static int removeFromWidgetListDynamicProperty(QWidget *parentWidget, QWidget *widget, const char *name) { - QWidgetList list = qVariantValue<QWidgetList>(parentWidget->property(name)); + QWidgetList list = qvariant_cast<QWidgetList>(parentWidget->property(name)); const int firstIndex = list.indexOf(widget); if (firstIndex != -1) { list.removeAll(widget); - parentWidget->setProperty(name, qVariantFromValue(list)); + parentWidget->setProperty(name, QVariant::fromValue(list)); } return firstIndex; } @@ -247,7 +247,7 @@ void InsertWidgetCommand::refreshBuddyLabels() { typedef QList<QLabel*> LabelList; - const LabelList label_list = qFindChildren<QLabel*>(formWindow()); + const LabelList label_list = formWindow()->findChildren<QLabel*>(); if (label_list.empty()) return; @@ -281,7 +281,7 @@ void ChangeZOrderCommand::init(QWidget *widget) setText(QApplication::translate("Command", "Change Z-order of '%1'").arg(widget->objectName())); - m_oldParentZOrder = qVariantValue<QWidgetList>(widget->parentWidget()->property("_q_zOrder")); + m_oldParentZOrder = qvariant_cast<QWidgetList>(widget->parentWidget()->property("_q_zOrder")); const int index = m_oldParentZOrder.indexOf(m_widget); if (index != -1 && index + 1 < m_oldParentZOrder.count()) m_oldPreceding = m_oldParentZOrder.at(index + 1); @@ -289,14 +289,14 @@ void ChangeZOrderCommand::init(QWidget *widget) void ChangeZOrderCommand::redo() { - m_widget->parentWidget()->setProperty("_q_zOrder", qVariantFromValue(reorderWidget(m_oldParentZOrder, m_widget))); + m_widget->parentWidget()->setProperty("_q_zOrder", QVariant::fromValue(reorderWidget(m_oldParentZOrder, m_widget))); reorder(m_widget); } void ChangeZOrderCommand::undo() { - m_widget->parentWidget()->setProperty("_q_zOrder", qVariantFromValue(m_oldParentZOrder)); + m_widget->parentWidget()->setProperty("_q_zOrder", QVariant::fromValue(m_oldParentZOrder)); if (m_oldPreceding) m_widget->stackUnder(m_oldPreceding); @@ -365,7 +365,7 @@ void ManageWidgetCommandHelper::init(const QDesignerFormWindowInterface *fw, QWi m_widget = widget; m_managedChildren.clear(); - const QWidgetList children = qFindChildren<QWidget *>(m_widget); + const QWidgetList children = m_widget->findChildren<QWidget *>(); if (children.empty()) return; @@ -580,8 +580,8 @@ void ReparentWidgetCommand::init(QWidget *widget, QWidget *parentWidget) setText(QApplication::translate("Command", "Reparent '%1'").arg(widget->objectName())); - m_oldParentList = qVariantValue<QWidgetList>(m_oldParentWidget->property("_q_widgetOrder")); - m_oldParentZOrder = qVariantValue<QWidgetList>(m_oldParentWidget->property("_q_zOrder")); + m_oldParentList = qvariant_cast<QWidgetList>(m_oldParentWidget->property("_q_widgetOrder")); + m_oldParentZOrder = qvariant_cast<QWidgetList>(m_oldParentWidget->property("_q_zOrder")); } void ReparentWidgetCommand::redo() @@ -591,19 +591,19 @@ void ReparentWidgetCommand::redo() QWidgetList oldList = m_oldParentList; oldList.removeAll(m_widget); - m_oldParentWidget->setProperty("_q_widgetOrder", qVariantFromValue(oldList)); + m_oldParentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(oldList)); - QWidgetList newList = qVariantValue<QWidgetList>(m_newParentWidget->property("_q_widgetOrder")); + QWidgetList newList = qvariant_cast<QWidgetList>(m_newParentWidget->property("_q_widgetOrder")); newList.append(m_widget); - m_newParentWidget->setProperty("_q_widgetOrder", qVariantFromValue(newList)); + m_newParentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(newList)); QWidgetList oldZOrder = m_oldParentZOrder; oldZOrder.removeAll(m_widget); - m_oldParentWidget->setProperty("_q_zOrder", qVariantFromValue(oldZOrder)); + m_oldParentWidget->setProperty("_q_zOrder", QVariant::fromValue(oldZOrder)); - QWidgetList newZOrder = qVariantValue<QWidgetList>(m_newParentWidget->property("_q_zOrder")); + QWidgetList newZOrder = qvariant_cast<QWidgetList>(m_newParentWidget->property("_q_zOrder")); newZOrder.append(m_widget); - m_newParentWidget->setProperty("_q_zOrder", qVariantFromValue(newZOrder)); + m_newParentWidget->setProperty("_q_zOrder", QVariant::fromValue(newZOrder)); m_widget->show(); core()->objectInspector()->setFormWindow(formWindow()); @@ -614,16 +614,16 @@ void ReparentWidgetCommand::undo() m_widget->setParent(m_oldParentWidget); m_widget->move(m_oldPos); - m_oldParentWidget->setProperty("_q_widgetOrder", qVariantFromValue(m_oldParentList)); + m_oldParentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(m_oldParentList)); - QWidgetList newList = qVariantValue<QWidgetList>(m_newParentWidget->property("_q_widgetOrder")); + QWidgetList newList = qvariant_cast<QWidgetList>(m_newParentWidget->property("_q_widgetOrder")); newList.removeAll(m_widget); - m_newParentWidget->setProperty("_q_widgetOrder", qVariantFromValue(newList)); + m_newParentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(newList)); - m_oldParentWidget->setProperty("_q_zOrder", qVariantFromValue(m_oldParentZOrder)); + m_oldParentWidget->setProperty("_q_zOrder", QVariant::fromValue(m_oldParentZOrder)); - QWidgetList newZOrder = qVariantValue<QWidgetList>(m_newParentWidget->property("_q_zOrder")); - m_newParentWidget->setProperty("_q_zOrder", qVariantFromValue(newZOrder)); + QWidgetList newZOrder = qvariant_cast<QWidgetList>(m_newParentWidget->property("_q_zOrder")); + m_newParentWidget->setProperty("_q_zOrder", QVariant::fromValue(newZOrder)); m_widget->show(); core()->objectInspector()->setFormWindow(formWindow()); @@ -1016,7 +1016,7 @@ void ToolBoxCommand::addPage() QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(formWindow()->core()->extensionManager(), m_toolBox); if (sheet) { qdesigner_internal::PropertySheetStringValue itemText(m_itemText); - sheet->setProperty(sheet->indexOf(QLatin1String("currentItemText")), qVariantFromValue(itemText)); + sheet->setProperty(sheet->indexOf(QLatin1String("currentItemText")), QVariant::fromValue(itemText)); } m_widget->show(); @@ -1176,7 +1176,7 @@ void TabWidgetCommand::addPage() QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(formWindow()->core()->extensionManager(), m_tabWidget); if (sheet) { qdesigner_internal::PropertySheetStringValue itemText(m_itemText); - sheet->setProperty(sheet->indexOf(QLatin1String("currentTabText")), qVariantFromValue(itemText)); + sheet->setProperty(sheet->indexOf(QLatin1String("currentTabText")), QVariant::fromValue(itemText)); } formWindow()->clearSelection(); @@ -2094,12 +2094,12 @@ void AddContainerWidgetPageCommand::init(QWidget *containerWidget, ContainerType case PageContainer: setText(QApplication::translate("Command", "Insert Page")); m_widget = new QDesignerWidget(formWindow(), m_containerWidget); - m_widget->setObjectName(QApplication::translate("Command", "page")); + m_widget->setObjectName(QLatin1String("page")); break; case MdiContainer: setText(QApplication::translate("Command", "Insert Subwindow")); m_widget = new QDesignerWidget(formWindow(), m_containerWidget); - m_widget->setObjectName(QApplication::translate("Command", "subwindow")); + m_widget->setObjectName(QLatin1String("subwindow")); setPropertySheetWindowTitle(core, m_widget, QApplication::translate("Command", "Subwindow")); break; case WizardContainer: // Apply style, don't manage @@ -2193,7 +2193,7 @@ static void copyRolesFromItem(ItemData *id, const T *item, bool editor) if (editor) copyRoleFromItem<T>(id, ItemFlagsShadowRole, item); else if (item->flags() != defaultFlags) - id->m_properties.insert(ItemFlagsShadowRole, qVariantFromValue((int)item->flags())); + id->m_properties.insert(ItemFlagsShadowRole, QVariant::fromValue((int)item->flags())); } template<class T> @@ -2210,19 +2210,19 @@ static void copyRolesToItem(const ItemData *id, T *item, DesignerIconCache *icon switch (it.key()) { case Qt::DecorationPropertyRole: if (iconCache) - item->setIcon(iconCache->icon(qVariantValue<PropertySheetIconValue>(it.value()))); + item->setIcon(iconCache->icon(qvariant_cast<PropertySheetIconValue>(it.value()))); break; case Qt::DisplayPropertyRole: - item->setText(qVariantValue<PropertySheetStringValue>(it.value()).value()); + item->setText(qvariant_cast<PropertySheetStringValue>(it.value()).value()); break; case Qt::ToolTipPropertyRole: - item->setToolTip(qVariantValue<PropertySheetStringValue>(it.value()).value()); + item->setToolTip(qvariant_cast<PropertySheetStringValue>(it.value()).value()); break; case Qt::StatusTipPropertyRole: - item->setStatusTip(qVariantValue<PropertySheetStringValue>(it.value()).value()); + item->setStatusTip(qvariant_cast<PropertySheetStringValue>(it.value()).value()); break; case Qt::WhatsThisPropertyRole: - item->setWhatsThis(qVariantValue<PropertySheetStringValue>(it.value()).value()); + item->setWhatsThis(qvariant_cast<PropertySheetStringValue>(it.value()).value()); break; } } @@ -2267,7 +2267,7 @@ ItemData::ItemData(const QTreeWidgetItem *item, int column) { copyRoleFromItem(this, Qt::EditRole, item, column); PropertySheetStringValue str(item->text(column)); - m_properties.insert(Qt::DisplayPropertyRole, qVariantFromValue(str)); + m_properties.insert(Qt::DisplayPropertyRole, QVariant::fromValue(str)); for (int i = 0; itemRoles[i] != -1; i++) copyRoleFromItem(this, itemRoles[i], item, column); @@ -2282,19 +2282,19 @@ void ItemData::fillTreeItemColumn(QTreeWidgetItem *item, int column, DesignerIco switch (it.key()) { case Qt::DecorationPropertyRole: if (iconCache) - item->setIcon(column, iconCache->icon(qVariantValue<PropertySheetIconValue>(it.value()))); + item->setIcon(column, iconCache->icon(qvariant_cast<PropertySheetIconValue>(it.value()))); break; case Qt::DisplayPropertyRole: - item->setText(column, qVariantValue<PropertySheetStringValue>(it.value()).value()); + item->setText(column, qvariant_cast<PropertySheetStringValue>(it.value()).value()); break; case Qt::ToolTipPropertyRole: - item->setToolTip(column, qVariantValue<PropertySheetStringValue>(it.value()).value()); + item->setToolTip(column, qvariant_cast<PropertySheetStringValue>(it.value()).value()); break; case Qt::StatusTipPropertyRole: - item->setStatusTip(column, qVariantValue<PropertySheetStringValue>(it.value()).value()); + item->setStatusTip(column, qvariant_cast<PropertySheetStringValue>(it.value()).value()); break; case Qt::WhatsThisPropertyRole: - item->setWhatsThis(column, qVariantValue<PropertySheetStringValue>(it.value()).value()); + item->setWhatsThis(column, qvariant_cast<PropertySheetStringValue>(it.value()).value()); break; } } @@ -2364,10 +2364,10 @@ void ListContents::applyToComboBox(QComboBox *comboBox, DesignerIconCache *iconC foreach (const ItemData &hash, m_items) { QIcon icon; if (iconCache) - icon = iconCache->icon(qVariantValue<PropertySheetIconValue>( + icon = iconCache->icon(qvariant_cast<PropertySheetIconValue>( hash.m_properties[Qt::DecorationPropertyRole])); QVariant var = hash.m_properties[Qt::DisplayPropertyRole]; - PropertySheetStringValue str = qVariantValue<PropertySheetStringValue>(var); + PropertySheetStringValue str = qvariant_cast<PropertySheetStringValue>(var); comboBox->addItem(icon, str.value()); comboBox->setItemData(comboBox->count() - 1, var, @@ -2407,7 +2407,7 @@ bool TableWidgetContents::nonEmpty(const QTableWidgetItem *item, int headerColum if (item->flags() != defaultFlags) return true; - QString text = qVariantValue<PropertySheetStringValue>(item->data(Qt::DisplayPropertyRole)).value(); + QString text = qvariant_cast<PropertySheetStringValue>(item->data(Qt::DisplayPropertyRole)).value(); if (!text.isEmpty()) { if (headerColumn < 0 || text != defaultHeaderText(headerColumn)) return true; @@ -2545,7 +2545,7 @@ QTreeWidgetItem *TreeWidgetContents::ItemContents::createTreeItem(DesignerIconCa if (m_itemFlags != -1) { if (editor) - item->setData(0, ItemFlagsShadowRole, qVariantFromValue(m_itemFlags)); + item->setData(0, ItemFlagsShadowRole, QVariant::fromValue(m_itemFlags)); else item->setFlags((Qt::ItemFlags)m_itemFlags); } diff --git a/tools/designer/src/lib/shared/qdesigner_command2.cpp b/tools/designer/src/lib/shared/qdesigner_command2.cpp index 6667eff..2b0a5a2 100644 --- a/tools/designer/src/lib/shared/qdesigner_command2.cpp +++ b/tools/designer/src/lib/shared/qdesigner_command2.cpp @@ -154,6 +154,68 @@ QString MorphLayoutCommand::formatDescription(QDesignerFormEditorInterface * /* return QApplication::translate("Command", "Change layout of '%1' from %2 to %3").arg(widgetName, oldName, newName); } +LayoutAlignmentCommand::LayoutAlignmentCommand(QDesignerFormWindowInterface *formWindow) : + QDesignerFormWindowCommand(QApplication::translate("Command", "Change layout alignment"), formWindow), + m_newAlignment(0), m_oldAlignment(0), m_widget(0) +{ +} + +bool LayoutAlignmentCommand::init(QWidget *w, Qt::Alignment alignment) +{ + bool enabled; + m_newAlignment = alignment; + m_oldAlignment = LayoutAlignmentCommand::alignmentOf(core(), w, &enabled); + m_widget = w; + return enabled; +} + +void LayoutAlignmentCommand::redo() +{ + LayoutAlignmentCommand::applyAlignment(core(), m_widget, m_newAlignment); +} + +void LayoutAlignmentCommand::undo() +{ + LayoutAlignmentCommand::applyAlignment(core(), m_widget, m_oldAlignment); +} + +// Find out alignment and return whether command is enabled. +Qt::Alignment LayoutAlignmentCommand::alignmentOf(const QDesignerFormEditorInterface *core, QWidget *w, bool *enabledIn) +{ + bool managed; + QLayout *layout; + + if (enabledIn) + *enabledIn = false; + // Can only work on a managed layout + const LayoutInfo::Type type = LayoutInfo::laidoutWidgetType(core, w, &managed, &layout); + const bool enabled = layout && managed && + (type == LayoutInfo::HBox || type == LayoutInfo::VBox + || type == LayoutInfo::Grid); + if (!enabled) + return Qt::Alignment(0); + // Get alignment + const int index = layout->indexOf(w); + Q_ASSERT(index >= 0); + if (enabledIn) + *enabledIn = true; + return layout->itemAt(index)->alignment(); +} + +void LayoutAlignmentCommand::applyAlignment(const QDesignerFormEditorInterface *core, QWidget *w, Qt::Alignment a) +{ + // Find layout and apply to item + QLayout *layout; + LayoutInfo::laidoutWidgetType(core, w, 0, &layout); + if (layout) { + const int index = layout->indexOf(w); + if (index >= 0) { + layout->itemAt(index)->setAlignment(a); + layout->update(); + } + } +} + } // namespace qdesigner_internal QT_END_NAMESPACE diff --git a/tools/designer/src/lib/shared/qdesigner_command2_p.h b/tools/designer/src/lib/shared/qdesigner_command2_p.h index eb9fef7..0a6cce8 100644 --- a/tools/designer/src/lib/shared/qdesigner_command2_p.h +++ b/tools/designer/src/lib/shared/qdesigner_command2_p.h @@ -94,6 +94,28 @@ private: QWidget *m_layoutBase; }; +// Change the alignment of a widget in a managed grid/box layout cell. +class LayoutAlignmentCommand : public QDesignerFormWindowCommand { + Q_DISABLE_COPY(LayoutAlignmentCommand) +public: + explicit LayoutAlignmentCommand(QDesignerFormWindowInterface *formWindow); + + bool init(QWidget *w, Qt::Alignment alignment); + + virtual void redo(); + virtual void undo(); + + // Find out alignment and return whether command is enabled. + static Qt::Alignment alignmentOf(const QDesignerFormEditorInterface *core, QWidget *w, bool *enabled = 0); + +private: + static void applyAlignment(const QDesignerFormEditorInterface *core, QWidget *w, Qt::Alignment a); + + Qt::Alignment m_newAlignment; + Qt::Alignment m_oldAlignment; + QWidget *m_widget; +}; + } // namespace qdesigner_internal QT_END_NAMESPACE diff --git a/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp b/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp index 478a240..a805474 100644 --- a/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp +++ b/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp @@ -243,7 +243,7 @@ static bool readDomEnumerationValue(const DomProperty *p, if (index == -1) return false; const QVariant sheetValue = sheet->property(index); - if (qVariantCanConvert<PropertySheetFlagValue>(sheetValue)) { + if (sheetValue.canConvert<PropertySheetFlagValue>()) { const PropertySheetFlagValue f = qvariant_cast<PropertySheetFlagValue>(sheetValue); bool ok = false; v = f.metaFlags.parseFlags(p->elementSet(), &ok); @@ -258,7 +258,7 @@ static bool readDomEnumerationValue(const DomProperty *p, if (index == -1) return false; const QVariant sheetValue = sheet->property(index); - if (qVariantCanConvert<PropertySheetEnumValue>(sheetValue)) { + if (sheetValue.canConvert<PropertySheetEnumValue>()) { const PropertySheetEnumValue e = qvariant_cast<PropertySheetEnumValue>(sheetValue); bool ok = false; v = e.metaEnum.parseEnum(p->elementEnum(), &ok); diff --git a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp index cac79ef..3efc829 100644 --- a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp +++ b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp @@ -115,7 +115,7 @@ void QDesignerFormWindowCommand::updateBuddies(QDesignerFormWindowInterface *for typedef QList<QLabel*> LabelList; - const LabelList label_list = qFindChildren<QLabel*>(form); + const LabelList label_list = form->findChildren<QLabel*>(); if (label_list.empty()) return; diff --git a/tools/designer/src/lib/shared/qdesigner_menu.cpp b/tools/designer/src/lib/shared/qdesigner_menu.cpp index cab00ec..e9abf30 100644 --- a/tools/designer/src/lib/shared/qdesigner_menu.cpp +++ b/tools/designer/src/lib/shared/qdesigner_menu.cpp @@ -477,7 +477,7 @@ bool QDesignerMenu::handleContextMenuEvent(QWidget *, QContextMenuEvent *event) QMenu menu; QVariant itemData; - qVariantSetValue(itemData, action); + itemData.setValue(action); QAction *addSeparatorAction = menu.addAction(tr("Insert separator")); addSeparatorAction->setData(itemData); @@ -630,7 +630,7 @@ QDesignerMenu *QDesignerMenu::findActivatedMenu() const { QList<QDesignerMenu*> candidates; candidates.append(const_cast<QDesignerMenu*>(this)); - candidates += qFindChildren<QDesignerMenu*>(this); + candidates += findChildren<QDesignerMenu*>(); foreach (QDesignerMenu *m, candidates) { if (m == qApp->activeWindow()) @@ -867,7 +867,7 @@ void QDesignerMenu::closeMenuChain() w = w->parentWidget(); if (w) { - foreach (QMenu *subMenu, qFindChildren<QMenu*>(w)) { + foreach (QMenu *subMenu, w->findChildren<QMenu*>()) { subMenu->hide(); } } @@ -1323,7 +1323,7 @@ QAction *QDesignerMenu::safeActionAt(int index) const void QDesignerMenu::hideSubMenu() { m_lastSubMenuIndex = -1; - foreach (QMenu *subMenu, qFindChildren<QMenu*>(this)) { + foreach (QMenu *subMenu, findChildren<QMenu*>()) { subMenu->hide(); } } diff --git a/tools/designer/src/lib/shared/qdesigner_menubar.cpp b/tools/designer/src/lib/shared/qdesigner_menubar.cpp index 3424b49..534cf0c 100644 --- a/tools/designer/src/lib/shared/qdesigner_menubar.cpp +++ b/tools/designer/src/lib/shared/qdesigner_menubar.cpp @@ -403,7 +403,7 @@ ActionList QDesignerMenuBar::contextMenuActions() if (QAction *action = safeActionAt(m_currentIndex)) { if (!qobject_cast<SpecialMenuAction*>(action)) { QVariant itemData; - qVariantSetValue(itemData, action); + itemData.setValue(action); QAction *remove_action = new QAction(tr("Remove Menu '%1'").arg(action->menu()->objectName()), 0); remove_action->setData(itemData); diff --git a/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp b/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp index befe09c..6463016 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 76d8a5c..73cf7ad 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_propertycommand.cpp b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp index 01c0206..a9949d8 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp +++ b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp @@ -505,7 +505,7 @@ PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant case QVariant::Size: return PropertyHelper::Value(applySizeSubProperty(oldValue.toSize(), newValue.toSize(), mask), changed); case QVariant::SizePolicy: - return PropertyHelper::Value(qVariantFromValue(applySizePolicySubProperty(qvariant_cast<QSizePolicy>(oldValue), qvariant_cast<QSizePolicy>(newValue), mask)), changed); + return PropertyHelper::Value(QVariant::fromValue(applySizePolicySubProperty(qvariant_cast<QSizePolicy>(oldValue), qvariant_cast<QSizePolicy>(newValue), mask)), changed); case QVariant::Font: { // Changed flag in case of font and palette depends on resolve mask only, not on the passed "changed" value. @@ -524,27 +524,27 @@ PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant // He press reset button for the whole font property. In result whole font properties for both // widgets should be marked as unchanged. QFont font = applyFontSubProperty(qvariant_cast<QFont>(oldValue), qvariant_cast<QFont>(newValue), mask); - return PropertyHelper::Value(qVariantFromValue(font), font.resolve()); + return PropertyHelper::Value(QVariant::fromValue(font), font.resolve()); } case QVariant::Palette: { QPalette palette = applyPaletteSubProperty(qvariant_cast<QPalette>(oldValue), qvariant_cast<QPalette>(newValue), mask); - return PropertyHelper::Value(qVariantFromValue(palette), palette.resolve()); + return PropertyHelper::Value(QVariant::fromValue(palette), palette.resolve()); } default: if (oldValue.userType() == qMetaTypeId<qdesigner_internal::PropertySheetIconValue>()) { PropertySheetIconValue icon = qvariant_cast<qdesigner_internal::PropertySheetIconValue>(oldValue); icon.assign(qvariant_cast<qdesigner_internal::PropertySheetIconValue>(newValue), mask); - return PropertyHelper::Value(qVariantFromValue(icon), icon.mask()); + return PropertyHelper::Value(QVariant::fromValue(icon), icon.mask()); } else if (oldValue.userType() == qMetaTypeId<qdesigner_internal::PropertySheetStringValue>()) { qdesigner_internal::PropertySheetStringValue str = applyStringSubProperty( qvariant_cast<qdesigner_internal::PropertySheetStringValue>(oldValue), qvariant_cast<qdesigner_internal::PropertySheetStringValue>(newValue), mask); - return PropertyHelper::Value(qVariantFromValue(str), changed); + return PropertyHelper::Value(QVariant::fromValue(str), changed); } else if (oldValue.userType() == qMetaTypeId<qdesigner_internal::PropertySheetKeySequenceValue>()) { qdesigner_internal::PropertySheetKeySequenceValue key = applyKeySequenceSubProperty( qvariant_cast<qdesigner_internal::PropertySheetKeySequenceValue>(oldValue), qvariant_cast<qdesigner_internal::PropertySheetKeySequenceValue>(newValue), mask); - return PropertyHelper::Value(qVariantFromValue(key), changed); + return PropertyHelper::Value(QVariant::fromValue(key), changed); } // Enumerations, flags switch (specialProperty) { @@ -552,7 +552,7 @@ PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant qdesigner_internal::PropertySheetFlagValue f = qvariant_cast<qdesigner_internal::PropertySheetFlagValue>(oldValue); f.value = applyAlignmentSubProperty(variantToAlignment(oldValue), variantToAlignment(newValue), mask); QVariant v; - qVariantSetValue(v, f); + v.setValue(f); return PropertyHelper::Value(v, changed); } default: @@ -651,7 +651,7 @@ void PropertyHelper::checkApplyWidgetValue(QDesignerFormWindowInterface *fw, QWi switch (specialProperty) { case SP_MinimumSize: { const QSize size = checkSize(value.toSize()); - qVariantSetValue(value, size); + value.setValue(size); } break; @@ -660,7 +660,7 @@ void PropertyHelper::checkApplyWidgetValue(QDesignerFormWindowInterface *fw, QWi checkSizes(fw, value.toSize(), &fs, &cs); container->setMaximumSize(cs); fw->mainContainer()->setMaximumSize(fs); - qVariantSetValue(value, fs); + value.setValue(fs); } break; @@ -670,7 +670,7 @@ void PropertyHelper::checkApplyWidgetValue(QDesignerFormWindowInterface *fw, QWi checkSizes(fw, r.size(), &fs, &cs); container->resize(cs); r.setSize(fs); - qVariantSetValue(value, r); + value.setValue(r); } break; default: @@ -727,8 +727,8 @@ void PropertyHelper::updateObject(QDesignerFormWindowInterface *fw, const QVaria case OT_Widget: { switch (m_specialProperty) { case SP_ObjectName: { - const QString oldName = qVariantValue<PropertySheetStringValue>(oldValue).value(); - const QString newName = qVariantValue<PropertySheetStringValue>(newValue).value(); + const QString oldName = qvariant_cast<PropertySheetStringValue>(oldValue).value(); + const QString newName = qvariant_cast<PropertySheetStringValue>(newValue).value(); QDesignerFormWindowCommand::updateBuddies(fw, oldName, newName); } break; @@ -751,8 +751,8 @@ void PropertyHelper::updateObject(QDesignerFormWindowInterface *fw, const QVaria case SP_LayoutName: case SP_SpacerName: if (QDesignerIntegration *integr = integration(fw)) { - const QString oldName = qVariantValue<PropertySheetStringValue>(oldValue).value(); - const QString newName = qVariantValue<PropertySheetStringValue>(newValue).value(); + const QString oldName = qvariant_cast<PropertySheetStringValue>(oldValue).value(); + const QString newName = qvariant_cast<PropertySheetStringValue>(newValue).value(); integr->emitObjectNameChanged(fw, m_object, newName, oldName); } break; diff --git a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp index 2b2428b..27527da 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp +++ b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp @@ -290,18 +290,18 @@ bool QDesignerPropertySheetPrivate::isResourceProperty(int index) const void QDesignerPropertySheetPrivate::addResourceProperty(int index, QVariant::Type type) { if (type == QVariant::Pixmap) - m_resourceProperties.insert(index, qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue())); + m_resourceProperties.insert(index, QVariant::fromValue(qdesigner_internal::PropertySheetPixmapValue())); else if (type == QVariant::Icon) - m_resourceProperties.insert(index, qVariantFromValue(qdesigner_internal::PropertySheetIconValue())); + m_resourceProperties.insert(index, QVariant::fromValue(qdesigner_internal::PropertySheetIconValue())); } QVariant QDesignerPropertySheetPrivate::emptyResourceProperty(int index) const { QVariant v = m_resourceProperties.value(index); - if (qVariantCanConvert<qdesigner_internal::PropertySheetPixmapValue>(v)) - return qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue()); - if (qVariantCanConvert<qdesigner_internal::PropertySheetIconValue>(v)) - return qVariantFromValue(qdesigner_internal::PropertySheetIconValue()); + if (v.canConvert<qdesigner_internal::PropertySheetPixmapValue>()) + return QVariant::fromValue(qdesigner_internal::PropertySheetPixmapValue()); + if (v.canConvert<qdesigner_internal::PropertySheetIconValue>()) + return QVariant::fromValue(qdesigner_internal::PropertySheetIconValue()); return v; } @@ -320,8 +320,8 @@ void QDesignerPropertySheetPrivate::setResourceProperty(int index, const QVarian Q_ASSERT(isResourceProperty(index)); QVariant &v = m_resourceProperties[index]; - if ((qVariantCanConvert<qdesigner_internal::PropertySheetPixmapValue>(value) && qVariantCanConvert<qdesigner_internal::PropertySheetPixmapValue>(v)) - || (qVariantCanConvert<qdesigner_internal::PropertySheetIconValue>(value) && qVariantCanConvert<qdesigner_internal::PropertySheetIconValue>(v))) + if ((value.canConvert<qdesigner_internal::PropertySheetPixmapValue>() && v.canConvert<qdesigner_internal::PropertySheetPixmapValue>()) + || (value.canConvert<qdesigner_internal::PropertySheetIconValue>() && v.canConvert<qdesigner_internal::PropertySheetIconValue>())) v = value; } @@ -722,14 +722,14 @@ int QDesignerPropertySheet::addDynamicProperty(const QString &propName, const QV QVariant v = value; if (value.type() == QVariant::Icon) - v = qVariantFromValue(qdesigner_internal::PropertySheetIconValue()); + v = QVariant::fromValue(qdesigner_internal::PropertySheetIconValue()); else if (value.type() == QVariant::Pixmap) - v = qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue()); + v = QVariant::fromValue(qdesigner_internal::PropertySheetPixmapValue()); else if (value.type() == QVariant::String) - v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(value.toString())); + v = QVariant::fromValue(qdesigner_internal::PropertySheetStringValue(value.toString())); else if (value.type() == QVariant::KeySequence) { - const QKeySequence keySequence = qVariantValue<QKeySequence>(value); - v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence)); + const QKeySequence keySequence = qvariant_cast<QKeySequence>(value); + v = QVariant::fromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence)); } if (d->m_addIndex.contains(propName)) { @@ -873,9 +873,9 @@ int QDesignerPropertySheet::createFakeProperty(const QString &propertyName, cons info.kind = QDesignerPropertySheetPrivate::FakeProperty; QVariant v = value.isValid() ? value : metaProperty(index); if (v.type() == QVariant::String) - v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); + v = QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()); if (v.type() == QVariant::KeySequence) - v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue()); + v = QVariant::fromValue(qdesigner_internal::PropertySheetKeySequenceValue()); d->m_fakeProperties.insert(index, v); return index; } @@ -1002,17 +1002,17 @@ QVariant QDesignerPropertySheet::property(int index) const value.setValue(strValue); d->setStringProperty(index, value); // cache it } - return qVariantFromValue(value); + return QVariant::fromValue(value); } if (d->isKeySequenceProperty(index)) { - QKeySequence keyValue = qVariantValue<QKeySequence>(metaProperty(index)); + QKeySequence keyValue = qvariant_cast<QKeySequence>(metaProperty(index)); qdesigner_internal::PropertySheetKeySequenceValue value = d->keySequenceProperty(index); if (keyValue != value.value()) { value.setValue(keyValue); d->setKeySequenceProperty(index, value); // cache it } - return qVariantFromValue(value); + return QVariant::fromValue(value); } return metaProperty(index); @@ -1027,12 +1027,12 @@ QVariant QDesignerPropertySheet::metaProperty(int index) const switch (p->kind()) { case QDesignerMetaPropertyInterface::FlagKind: { qdesigner_internal::PropertySheetFlagValue psflags = qdesigner_internal::PropertySheetFlagValue(v.toInt(), designerMetaFlagsFor(p->enumerator())); - qVariantSetValue(v, psflags); + v.setValue(psflags); } break; case QDesignerMetaPropertyInterface::EnumKind: { qdesigner_internal::PropertySheetEnumValue pse = qdesigner_internal::PropertySheetEnumValue(v.toInt(), designerMetaEnumFor(p->enumerator())); - qVariantSetValue(v, pse); + v.setValue(pse); } break; case QDesignerMetaPropertyInterface::OtherKind: @@ -1043,20 +1043,20 @@ QVariant QDesignerPropertySheet::metaProperty(int index) const QVariant QDesignerPropertySheet::resolvePropertyValue(int index, const QVariant &value) const { - if (qVariantCanConvert<qdesigner_internal::PropertySheetEnumValue>(value)) + if (value.canConvert<qdesigner_internal::PropertySheetEnumValue>()) return qvariant_cast<qdesigner_internal::PropertySheetEnumValue>(value).value; - if (qVariantCanConvert<qdesigner_internal::PropertySheetFlagValue>(value)) + if (value.canConvert<qdesigner_internal::PropertySheetFlagValue>()) return qvariant_cast<qdesigner_internal::PropertySheetFlagValue>(value).value; - if (qVariantCanConvert<qdesigner_internal::PropertySheetStringValue>(value)) - return qVariantValue<qdesigner_internal::PropertySheetStringValue>(value).value(); + if (value.canConvert<qdesigner_internal::PropertySheetStringValue>()) + return qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value).value(); - if (qVariantCanConvert<qdesigner_internal::PropertySheetKeySequenceValue>(value)) - return qVariantValue<qdesigner_internal::PropertySheetKeySequenceValue>(value).value(); + if (value.canConvert<qdesigner_internal::PropertySheetKeySequenceValue>()) + return qvariant_cast<qdesigner_internal::PropertySheetKeySequenceValue>(value).value(); - if (qVariantCanConvert<qdesigner_internal::PropertySheetPixmapValue>(value)) { - const QString path = qVariantValue<qdesigner_internal::PropertySheetPixmapValue>(value).path(); + if (value.canConvert<qdesigner_internal::PropertySheetPixmapValue>()) { + const QString path = qvariant_cast<qdesigner_internal::PropertySheetPixmapValue>(value).path(); if (path.isEmpty()) return defaultResourceProperty(index); if (d->m_pixmapCache) { @@ -1064,9 +1064,9 @@ QVariant QDesignerPropertySheet::resolvePropertyValue(int index, const QVariant } } - if (qVariantCanConvert<qdesigner_internal::PropertySheetIconValue>(value)) { - const int pathCount = qVariantValue<qdesigner_internal::PropertySheetIconValue>(value).paths().count(); - if (pathCount == 0) + if (value.canConvert<qdesigner_internal::PropertySheetIconValue>()) { + 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)); @@ -1082,17 +1082,17 @@ void QDesignerPropertySheet::setFakeProperty(int index, const QVariant &value) QVariant &v = d->m_fakeProperties[index]; // set resource properties also (if we are going to have fake resource properties) - if (qVariantCanConvert<qdesigner_internal::PropertySheetFlagValue>(value) || qVariantCanConvert<qdesigner_internal::PropertySheetEnumValue>(value)) { + if (value.canConvert<qdesigner_internal::PropertySheetFlagValue>() || value.canConvert<qdesigner_internal::PropertySheetEnumValue>()) { v = value; - } else if (qVariantCanConvert<qdesigner_internal::PropertySheetFlagValue>(v)) { + } else if (v.canConvert<qdesigner_internal::PropertySheetFlagValue>()) { qdesigner_internal::PropertySheetFlagValue f = qvariant_cast<qdesigner_internal::PropertySheetFlagValue>(v); f.value = value.toInt(); - qVariantSetValue(v, f); + v.setValue(f); Q_ASSERT(value.type() == QVariant::Int); - } else if (qVariantCanConvert<qdesigner_internal::PropertySheetEnumValue>(v)) { + } else if (v.canConvert<qdesigner_internal::PropertySheetEnumValue>()) { qdesigner_internal::PropertySheetEnumValue e = qvariant_cast<qdesigner_internal::PropertySheetEnumValue>(v); e.value = value.toInt(); - qVariantSetValue(v, e); + v.setValue(e); Q_ASSERT(value.type() == QVariant::Int); } else { v = value; @@ -1139,9 +1139,9 @@ void QDesignerPropertySheet::setProperty(int index, const QVariant &value) if (d->isResourceProperty(index)) d->setResourceProperty(index, value); if (d->isStringProperty(index)) - d->setStringProperty(index, qVariantValue<qdesigner_internal::PropertySheetStringValue>(value)); + d->setStringProperty(index, qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value)); if (d->isKeySequenceProperty(index)) - d->setKeySequenceProperty(index, qVariantValue<qdesigner_internal::PropertySheetKeySequenceValue>(value)); + d->setKeySequenceProperty(index, qvariant_cast<qdesigner_internal::PropertySheetKeySequenceValue>(value)); d->m_object->setProperty(propertyName(index).toUtf8(), resolvePropertyValue(index, value)); if (d->m_object->isWidgetType()) { QWidget *w = qobject_cast<QWidget *>(d->m_object); @@ -1155,26 +1155,26 @@ void QDesignerPropertySheet::setProperty(int index, const QVariant &value) if (d->isResourceProperty(index)) d->setResourceProperty(index, value); if (d->isStringProperty(index)) - d->setStringProperty(index, qVariantValue<qdesigner_internal::PropertySheetStringValue>(value)); + d->setStringProperty(index, qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value)); if (d->isKeySequenceProperty(index)) - d->setKeySequenceProperty(index, qVariantValue<qdesigner_internal::PropertySheetKeySequenceValue>(value)); + d->setKeySequenceProperty(index, qvariant_cast<qdesigner_internal::PropertySheetKeySequenceValue>(value)); const QDesignerMetaPropertyInterface *p = d->m_meta->property(index); p->write(d->m_object, resolvePropertyValue(index, value)); if (qobject_cast<QGroupBox *>(d->m_object) && propertyType(index) == PropertyCheckable) { const int idx = indexOf(QLatin1String("focusPolicy")); if (!isChanged(idx)) { - qdesigner_internal::PropertySheetEnumValue e = qVariantValue<qdesigner_internal::PropertySheetEnumValue>(property(idx)); + qdesigner_internal::PropertySheetEnumValue e = qvariant_cast<qdesigner_internal::PropertySheetEnumValue>(property(idx)); if (value.toBool()) { const QDesignerMetaPropertyInterface *p = d->m_meta->property(idx); p->write(d->m_object, Qt::NoFocus); e.value = Qt::StrongFocus; QVariant v; - qVariantSetValue(v, e); + v.setValue(e); setFakeProperty(idx, v); } else { e.value = Qt::NoFocus; QVariant v; - qVariantSetValue(v, e); + v.setValue(e); setFakeProperty(idx, v); } } @@ -1195,10 +1195,19 @@ bool QDesignerPropertySheet::reset(int index) { if (d->invalidIndex(Q_FUNC_INFO, index)) return false; - if (d->isStringProperty(index)) - setProperty(index, qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); + if (d->isStringProperty(index)) { + qdesigner_internal::PropertySheetStringValue value; + // Main container: Reset to stored class name as not to change the file names generated by uic. + if (propertyName(index) == QLatin1String("objectName")) { + const QVariant classNameDefaultV = d->m_object->property("_q_classname"); + if (classNameDefaultV.isValid()) + value.setValue(classNameDefaultV.toString()); + } + setProperty(index, QVariant::fromValue(value)); + return true; + } if (d->isKeySequenceProperty(index)) - setProperty(index, qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue())); + setProperty(index, QVariant::fromValue(qdesigner_internal::PropertySheetKeySequenceValue())); if (d->isResourceProperty(index)) { setProperty(index, d->emptyResourceProperty(index)); return true; @@ -1208,10 +1217,10 @@ bool QDesignerPropertySheet::reset(int index) const QVariant defaultValue = d->m_info.value(index).defaultValue; QVariant newValue = defaultValue; if (d->isStringProperty(index)) { - newValue = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(newValue.toString())); + newValue = QVariant::fromValue(qdesigner_internal::PropertySheetStringValue(newValue.toString())); } else if (d->isKeySequenceProperty(index)) { - const QKeySequence keySequence = qVariantValue<QKeySequence>(newValue); - newValue = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence)); + const QKeySequence keySequence = qvariant_cast<QKeySequence>(newValue); + newValue = QVariant::fromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence)); } if (oldValue == newValue) return true; diff --git a/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp b/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp index 8fe5f6e..6110dea 100644 --- a/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp +++ b/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp @@ -134,7 +134,7 @@ QTabBar *QTabWidgetEventFilter::tabBar() const { // QTabWidget::tabBar() accessor is protected, grmbl... if (!m_cachedTabBar) { - const QList<QTabBar *> tabBars = qFindChildren<QTabBar *>(m_tabWidget); + const QList<QTabBar *> tabBars = m_tabWidget->findChildren<QTabBar *>(); Q_ASSERT(tabBars.size() == 1); m_cachedTabBar = tabBars.front(); } @@ -405,13 +405,13 @@ QTabWidgetPropertySheet::QTabWidgetPropertySheet(QTabWidget *object, QObject *pa QDesignerPropertySheet(object, parent), m_tabWidget(object) { - createFakeProperty(QLatin1String(currentTabTextKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(QLatin1String(currentTabTextKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); createFakeProperty(QLatin1String(currentTabNameKey), QString()); - createFakeProperty(QLatin1String(currentTabIconKey), qVariantFromValue(qdesigner_internal::PropertySheetIconValue())); + createFakeProperty(QLatin1String(currentTabIconKey), QVariant::fromValue(qdesigner_internal::PropertySheetIconValue())); if (formWindowBase()) formWindowBase()->addReloadableProperty(this, indexOf(QLatin1String(currentTabIconKey))); - createFakeProperty(QLatin1String(currentTabToolTipKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); - createFakeProperty(QLatin1String(currentTabWhatsThisKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(QLatin1String(currentTabToolTipKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(QLatin1String(currentTabWhatsThisKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); // Prevent the tab widget's drag and drop handling from interfering with Designer's createFakeProperty(QLatin1String(tabMovableKey), QVariant(false)); } @@ -447,22 +447,22 @@ void QTabWidgetPropertySheet::setProperty(int index, const QVariant &value) switch (tabWidgetProperty) { case PropertyCurrentTabText: m_tabWidget->setTabText(currentIndex, qvariant_cast<QString>(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].text = qVariantValue<qdesigner_internal::PropertySheetStringValue>(value); + m_pageToData[currentWidget].text = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value); break; case PropertyCurrentTabName: currentWidget->setObjectName(value.toString()); break; case PropertyCurrentTabIcon: m_tabWidget->setTabIcon(currentIndex, qvariant_cast<QIcon>(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].icon = qVariantValue<qdesigner_internal::PropertySheetIconValue>(value); + m_pageToData[currentWidget].icon = qvariant_cast<qdesigner_internal::PropertySheetIconValue>(value); break; case PropertyCurrentTabToolTip: m_tabWidget->setTabToolTip(currentIndex, qvariant_cast<QString>(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].tooltip = qVariantValue<qdesigner_internal::PropertySheetStringValue>(value); + m_pageToData[currentWidget].tooltip = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value); break; case PropertyCurrentTabWhatsThis: m_tabWidget->setTabWhatsThis(currentIndex, qvariant_cast<QString>(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].whatsthis = qVariantValue<qdesigner_internal::PropertySheetStringValue>(value); + m_pageToData[currentWidget].whatsthis = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value); break; case PropertyTabWidgetNone: break; @@ -486,28 +486,28 @@ QVariant QTabWidgetPropertySheet::property(int index) const QWidget *currentWidget = m_tabWidget->currentWidget(); if (!currentWidget) { if (tabWidgetProperty == PropertyCurrentTabIcon) - return qVariantFromValue(qdesigner_internal::PropertySheetIconValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetIconValue()); if (tabWidgetProperty == PropertyCurrentTabText) - return qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()); if (tabWidgetProperty == PropertyCurrentTabToolTip) - return qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()); if (tabWidgetProperty == PropertyCurrentTabWhatsThis) - return qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()); return QVariant(QString()); } // index-dependent switch (tabWidgetProperty) { case PropertyCurrentTabText: - return qVariantFromValue(m_pageToData.value(currentWidget).text); + return QVariant::fromValue(m_pageToData.value(currentWidget).text); case PropertyCurrentTabName: return currentWidget->objectName(); case PropertyCurrentTabIcon: - return qVariantFromValue(m_pageToData.value(currentWidget).icon); + return QVariant::fromValue(m_pageToData.value(currentWidget).icon); case PropertyCurrentTabToolTip: - return qVariantFromValue(m_pageToData.value(currentWidget).tooltip); + return QVariant::fromValue(m_pageToData.value(currentWidget).tooltip); case PropertyCurrentTabWhatsThis: - return qVariantFromValue(m_pageToData.value(currentWidget).whatsthis); + return QVariant::fromValue(m_pageToData.value(currentWidget).whatsthis); case PropertyTabWidgetNone: break; } diff --git a/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp b/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp index 0e89f90..5a9ace4 100644 --- a/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp +++ b/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp @@ -41,6 +41,7 @@ #include "qdesigner_taskmenu_p.h" #include "qdesigner_command_p.h" +#include "qdesigner_command2_p.h" #include "richtexteditor_p.h" #include "plaintexteditor_p.h" #include "stylesheeteditor_p.h" @@ -132,7 +133,7 @@ static QString objName(const QDesignerFormEditorInterface *core, QObject *object const QString objectNameProperty = QLatin1String("objectName"); const int index = sheet->indexOf(objectNameProperty); const qdesigner_internal::PropertySheetStringValue objectNameValue - = qVariantValue<qdesigner_internal::PropertySheetStringValue>(sheet->property(index)); + = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(sheet->property(index)); return objectNameValue.value(); } @@ -180,10 +181,128 @@ QString ObjectNameDialog::newObjectName() const { return m_editor->text(); } +} // namespace +namespace qdesigner_internal { + +// Sub menu displaying the alignment options of a widget in a managed +// grid/box layout cell. +class LayoutAlignmentMenu { +public: + explicit LayoutAlignmentMenu(QObject *parent); + + QAction *subMenuAction() const { return m_subMenuAction; } + + void connect(QObject *receiver, const char *aSlot); + + // Set up enabled state and checked actions according to widget (managed box/grid) + bool setAlignment(const QDesignerFormEditorInterface *core, QWidget *w); + + // Return the currently checked alignment + Qt::Alignment alignment() const; + +private: + enum Actions { HorizNone, Left, HorizCenter, Right, VerticalNone, Top, VerticalCenter, Bottom }; + static QAction *createAction(const QString &text, int data, QMenu *menu, QActionGroup *ag); + + QAction *m_subMenuAction; + QActionGroup *m_horizGroup; + QActionGroup *m_verticalGroup; + QAction *m_actions[Bottom + 1]; +}; + +QAction *LayoutAlignmentMenu::createAction(const QString &text, int data, QMenu *menu, QActionGroup *ag) +{ + QAction * a = new QAction(text, 0); + a->setCheckable(true); + a->setData(QVariant(data)); + menu->addAction(a); + ag->addAction(a); + return a; +} + +LayoutAlignmentMenu::LayoutAlignmentMenu(QObject *parent) : + m_subMenuAction(new QAction(QDesignerTaskMenu::tr("Layout Alignment"), parent)), + m_horizGroup(new QActionGroup(parent)), + m_verticalGroup(new QActionGroup(parent)) +{ + m_horizGroup->setExclusive(true); + m_verticalGroup->setExclusive(true); + + QMenu *menu = new QMenu; + m_subMenuAction->setMenu(menu); + + m_actions[HorizNone] = createAction(QDesignerTaskMenu::tr("No Horizontal Alignment"), 0, menu, m_horizGroup); + m_actions[Left] = createAction(QDesignerTaskMenu::tr("Left"), Qt::AlignLeft, menu, m_horizGroup); + m_actions[HorizCenter] = createAction(QDesignerTaskMenu::tr("Center Horizontally"), Qt::AlignHCenter, menu, m_horizGroup); + m_actions[Right] = createAction(QDesignerTaskMenu::tr("Right"), Qt::AlignRight, menu, m_horizGroup); + menu->addSeparator(); + m_actions[VerticalNone] = createAction(QDesignerTaskMenu::tr("No Vertical Alignment"), 0, menu, m_verticalGroup); + m_actions[Top] = createAction(QDesignerTaskMenu::tr("Top"), Qt::AlignTop, menu, m_verticalGroup); + m_actions[VerticalCenter] = createAction(QDesignerTaskMenu::tr("Center Vertically"), Qt::AlignVCenter, menu, m_verticalGroup); + m_actions[Bottom] = createAction(QDesignerTaskMenu::tr("Bottom"), Qt::AlignBottom, menu, m_verticalGroup); +} + +void LayoutAlignmentMenu::connect(QObject *receiver, const char *aSlot) +{ + QObject::connect(m_horizGroup, SIGNAL(triggered(QAction*)), receiver, aSlot); + QObject::connect(m_verticalGroup, SIGNAL(triggered(QAction*)), receiver, aSlot); +} + +bool LayoutAlignmentMenu::setAlignment(const QDesignerFormEditorInterface *core, QWidget *w) +{ + bool enabled; + const Qt::Alignment alignment = LayoutAlignmentCommand::alignmentOf(core, w, &enabled); + if (!enabled) { + m_subMenuAction->setEnabled(false); + m_actions[HorizNone]->setChecked(true); + m_actions[VerticalNone]->setChecked(true); + return false; + } + // Get alignment + switch (alignment & Qt::AlignHorizontal_Mask) { + case Qt::AlignLeft: + m_actions[Left]->setChecked(true); + break; + case Qt::AlignHCenter: + m_actions[HorizCenter]->setChecked(true); + break; + case Qt::AlignRight: + m_actions[Right]->setChecked(true); + break; + default: + m_actions[HorizNone]->setChecked(true); + break; + } + switch (alignment & Qt::AlignVertical_Mask) { + case Qt::AlignTop: + m_actions[Top]->setChecked(true); + break; + case Qt::AlignVCenter: + m_actions[VerticalCenter]->setChecked(true); + break; + case Qt::AlignBottom: + m_actions[Bottom]->setChecked(true); + break; + default: + m_actions[VerticalNone]->setChecked(true); + break; + } + return true; +} + +Qt::Alignment LayoutAlignmentMenu::alignment() const +{ + Qt::Alignment alignment = 0; + if (const QAction *horizAction = m_horizGroup->checkedAction()) + if (const int horizAlign = horizAction->data().toInt()) + alignment |= static_cast<Qt::Alignment>(horizAlign); + if (const QAction *vertAction = m_verticalGroup->checkedAction()) + if (const int vertAlign = vertAction->data().toInt()) + alignment |= static_cast<Qt::Alignment>(vertAlign); + return alignment; } -namespace qdesigner_internal { // -------------- QDesignerTaskMenuPrivate class QDesignerTaskMenuPrivate { public: @@ -214,6 +333,7 @@ public: QAction *m_navigateToSlot; PromotionTaskMenu* m_promotionTaskMenu; QActionGroup *m_sizeActionGroup; + LayoutAlignmentMenu m_layoutAlignmentMenu; QAction *m_sizeActionsSubMenu; }; @@ -242,6 +362,7 @@ QDesignerTaskMenuPrivate::QDesignerTaskMenuPrivate(QWidget *widget, QObject *par m_navigateToSlot(new QAction(QDesignerTaskMenu::tr("Go to slot..."), parent)), m_promotionTaskMenu(new PromotionTaskMenu(widget, PromotionTaskMenu::ModeManagedMultiSelection, parent)), m_sizeActionGroup(new QActionGroup(parent)), + m_layoutAlignmentMenu(parent), m_sizeActionsSubMenu(new QAction(QDesignerTaskMenu::tr("Size Constraints"), parent)) { QMenu *sizeMenu = new QMenu; @@ -293,6 +414,7 @@ QDesignerTaskMenu::QDesignerTaskMenu(QWidget *widget, QObject *parent) : connect(d->m_containerFakeMethods, SIGNAL(triggered()), this, SLOT(containerFakeMethods())); connect(d->m_navigateToSlot, SIGNAL(triggered()), this, SLOT(slotNavigateToSlot())); connect(d->m_sizeActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(applySize(QAction*))); + d->m_layoutAlignmentMenu.connect(this, SLOT(slotLayoutAlignment())); } QDesignerTaskMenu::~QDesignerTaskMenu() @@ -410,6 +532,9 @@ QList<QAction*> QDesignerTaskMenu::taskActions() const actions.append(d->m_changeStyleSheet); actions.append(d->m_separator6); actions.append(d->m_sizeActionsSubMenu); + if (d->m_layoutAlignmentMenu.setAlignment(formWindow->core(), d->m_widget)) + actions.append(d->m_layoutAlignmentMenu.subMenuAction()); + d->m_promotionTaskMenu->setMode(formWindow->isManaged(d->m_widget) ? PromotionTaskMenu::ModeManagedMultiSelection : PromotionTaskMenu::ModeUnmanagedMultiSelection); d->m_promotionTaskMenu->addActions(formWindow, PromotionTaskMenu::LeadingSeparator, actions); @@ -447,7 +572,7 @@ void QDesignerTaskMenu::changeObjectName() const QString objectNameProperty = QLatin1String("objectName"); PropertySheetStringValue objectNameValue; objectNameValue.setValue(newObjectName); - setProperty(fw, CurrentWidgetMode, objectNameProperty, qVariantFromValue(objectNameValue)); + setProperty(fw, CurrentWidgetMode, objectNameProperty, QVariant::fromValue(objectNameValue)); } } } @@ -465,7 +590,7 @@ void QDesignerTaskMenu::changeTextProperty(const QString &propertyName, const QS qDebug() << "** WARNING Invalid property" << propertyName << " passed to changeTextProperty!"; return; } - PropertySheetStringValue textValue = qVariantValue<PropertySheetStringValue>(sheet->property(index)); + PropertySheetStringValue textValue = qvariant_cast<PropertySheetStringValue>(sheet->property(index)); const QString oldText = textValue.value(); // Pop up respective dialog bool accepted = false; @@ -498,7 +623,7 @@ void QDesignerTaskMenu::changeTextProperty(const QString &propertyName, const QS textValue.setValue(newText); - setProperty(fw, pm, propertyName, qVariantFromValue(textValue)); + setProperty(fw, pm, propertyName, QVariant::fromValue(textValue)); } void QDesignerTaskMenu::changeToolTip() @@ -673,7 +798,7 @@ void QDesignerTaskMenu::navigateToSlot(QDesignerFormEditorInterface *core, if (selectSignalDialog.exec() == QDialog::Accepted) { QTreeWidgetItem *selectedItem = dialogUi.signalList->selectedItems().first(); const QString signalSignature = selectedItem->text(0); - const QStringList parameterNames = qVariantValue<QStringList>(selectedItem->data(0, Qt::UserRole)); + const QStringList parameterNames = qvariant_cast<QStringList>(selectedItem->data(0, Qt::UserRole)); // TODO: Check whether signal is connected to slot integr->emitNavigateToSlot(objectName, signalSignature, parameterNames); @@ -771,7 +896,17 @@ void QDesignerTaskMenu::setProperty(QDesignerFormWindowInterface *fw, PropertyM } } - +void QDesignerTaskMenu::slotLayoutAlignment() +{ + QDesignerFormWindowInterface *fw = formWindow(); + const Qt::Alignment newAlignment = d->m_layoutAlignmentMenu.alignment(); + LayoutAlignmentCommand *cmd = new LayoutAlignmentCommand(fw); + if (cmd->init(d->m_widget, newAlignment)) { + fw->commandHistory()->push(cmd); + } else { + delete cmd; + } +} } // namespace qdesigner_internal QT_END_NAMESPACE diff --git a/tools/designer/src/lib/shared/qdesigner_taskmenu_p.h b/tools/designer/src/lib/shared/qdesigner_taskmenu_p.h index a8b3cb8..b86ce69 100644 --- a/tools/designer/src/lib/shared/qdesigner_taskmenu_p.h +++ b/tools/designer/src/lib/shared/qdesigner_taskmenu_p.h @@ -118,6 +118,7 @@ private slots: void containerFakeMethods(); void slotNavigateToSlot(); void applySize(QAction *a); + void slotLayoutAlignment(); private: QDesignerTaskMenuPrivate *d; diff --git a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp index 249228e..0fe7303 100644 --- a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp +++ b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp @@ -146,7 +146,7 @@ ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos) // Insert before if (action && index != 0 && !action->isSeparator()) { QAction *newSeperatorAct = new QAction(tr("Insert Separator before '%1'").arg(action->objectName()), 0); - qVariantSetValue(itemData, action); + itemData.setValue(action); newSeperatorAct->setData(itemData); connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator())); rc.push_back(newSeperatorAct); @@ -155,7 +155,7 @@ ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos) // Append separator if (actions.empty() || !actions.back()->isSeparator()) { QAction *newSeperatorAct = new QAction(tr("Append Separator"), 0); - qVariantSetValue(itemData, static_cast<QAction*>(0)); + itemData.setValue(static_cast<QAction*>(0)); newSeperatorAct->setData(itemData); connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator())); rc.push_back(newSeperatorAct); @@ -167,7 +167,7 @@ ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos) // Remove if (action) { QAction *a = new QAction(tr("Remove action '%1'").arg(action->objectName()), 0); - qVariantSetValue(itemData, action); + itemData.setValue(action); a->setData(itemData); connect(a, SIGNAL(triggered()), this, SLOT(slotRemoveSelectedAction())); rc.push_back(a); diff --git a/tools/designer/src/lib/shared/qdesigner_toolbox.cpp b/tools/designer/src/lib/shared/qdesigner_toolbox.cpp index bb05af7..675e98c 100644 --- a/tools/designer/src/lib/shared/qdesigner_toolbox.cpp +++ b/tools/designer/src/lib/shared/qdesigner_toolbox.cpp @@ -260,12 +260,12 @@ QToolBoxWidgetPropertySheet::QToolBoxWidgetPropertySheet(QToolBox *object, QObje QDesignerPropertySheet(object, parent), m_toolBox(object) { - createFakeProperty(QLatin1String(currentItemTextKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(QLatin1String(currentItemTextKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); createFakeProperty(QLatin1String(currentItemNameKey), QString()); - createFakeProperty(QLatin1String(currentItemIconKey), qVariantFromValue(qdesigner_internal::PropertySheetIconValue())); + createFakeProperty(QLatin1String(currentItemIconKey), QVariant::fromValue(qdesigner_internal::PropertySheetIconValue())); if (formWindowBase()) formWindowBase()->addReloadableProperty(this, indexOf(QLatin1String(currentItemIconKey))); - createFakeProperty(QLatin1String(currentItemToolTipKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(QLatin1String(currentItemToolTipKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); createFakeProperty(QLatin1String(tabSpacingKey), QVariant(tabSpacingDefault)); } @@ -306,18 +306,18 @@ void QToolBoxWidgetPropertySheet::setProperty(int index, const QVariant &value) switch (toolBoxProperty) { case PropertyCurrentItemText: m_toolBox->setItemText(currentIndex, qvariant_cast<QString>(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].text = qVariantValue<qdesigner_internal::PropertySheetStringValue>(value); + m_pageToData[currentWidget].text = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value); break; case PropertyCurrentItemName: currentWidget->setObjectName(value.toString()); break; case PropertyCurrentItemIcon: m_toolBox->setItemIcon(currentIndex, qvariant_cast<QIcon>(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].icon = qVariantValue<qdesigner_internal::PropertySheetIconValue>(value); + m_pageToData[currentWidget].icon = qvariant_cast<qdesigner_internal::PropertySheetIconValue>(value); break; case PropertyCurrentItemToolTip: m_toolBox->setItemToolTip(currentIndex, qvariant_cast<QString>(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].tooltip = qVariantValue<qdesigner_internal::PropertySheetStringValue>(value); + m_pageToData[currentWidget].tooltip = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(value); break; case PropertyTabSpacing: case PropertyToolBoxNone: @@ -353,24 +353,24 @@ QVariant QToolBoxWidgetPropertySheet::property(int index) const QWidget *currentWidget = m_toolBox->currentWidget(); if (!currentWidget) { if (toolBoxProperty == PropertyCurrentItemIcon) - return qVariantFromValue(qdesigner_internal::PropertySheetIconValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetIconValue()); if (toolBoxProperty == PropertyCurrentItemText) - return qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()); if (toolBoxProperty == PropertyCurrentItemToolTip) - return qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()); return QVariant(QString()); } // index-dependent switch (toolBoxProperty) { case PropertyCurrentItemText: - return qVariantFromValue(m_pageToData.value(currentWidget).text); + return QVariant::fromValue(m_pageToData.value(currentWidget).text); case PropertyCurrentItemName: return currentWidget->objectName(); case PropertyCurrentItemIcon: - return qVariantFromValue(m_pageToData.value(currentWidget).icon); + return QVariant::fromValue(m_pageToData.value(currentWidget).icon); case PropertyCurrentItemToolTip: - return qVariantFromValue(m_pageToData.value(currentWidget).tooltip); + return QVariant::fromValue(m_pageToData.value(currentWidget).tooltip); case PropertyTabSpacing: case PropertyToolBoxNone: break; diff --git a/tools/designer/src/lib/shared/qdesigner_utils.cpp b/tools/designer/src/lib/shared/qdesigner_utils.cpp index def6b31..1c6c854 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> @@ -82,8 +83,8 @@ namespace qdesigner_internal for (int c = 0; c < item->columnCount(); c++) { const QVariant v = item->data(c, Qt::DecorationPropertyRole); - if (qVariantCanConvert<PropertySheetIconValue>(v)) - item->setIcon(c, iconCache->icon(qVariantValue<PropertySheetIconValue>(v))); + if (v.canConvert<PropertySheetIconValue>()) + item->setIcon(c, iconCache->icon(qvariant_cast<PropertySheetIconValue>(v))); } } @@ -93,8 +94,8 @@ namespace qdesigner_internal return; const QVariant v = item->data(Qt::DecorationPropertyRole); - if (qVariantCanConvert<PropertySheetIconValue>(v)) - item->setIcon(iconCache->icon(qVariantValue<PropertySheetIconValue>(v))); + if (v.canConvert<PropertySheetIconValue>()) + item->setIcon(iconCache->icon(qvariant_cast<PropertySheetIconValue>(v))); } void reloadTableItem(DesignerIconCache *iconCache, QTableWidgetItem *item) @@ -103,8 +104,8 @@ namespace qdesigner_internal return; const QVariant v = item->data(Qt::DecorationPropertyRole); - if (qVariantCanConvert<PropertySheetIconValue>(v)) - item->setIcon(iconCache->icon(qVariantValue<PropertySheetIconValue>(v))); + if (v.canConvert<PropertySheetIconValue>()) + item->setIcon(iconCache->icon(qvariant_cast<PropertySheetIconValue>(v))); } void reloadIconResources(DesignerIconCache *iconCache, QObject *object) @@ -115,8 +116,8 @@ namespace qdesigner_internal } else if (QComboBox *comboBox = qobject_cast<QComboBox *>(object)) { for (int i = 0; i < comboBox->count(); i++) { const QVariant v = comboBox->itemData(i, Qt::DecorationPropertyRole); - if (qVariantCanConvert<PropertySheetIconValue>(v)) { - QIcon icon = iconCache->icon(qVariantValue<PropertySheetIconValue>(v)); + if (v.canConvert<PropertySheetIconValue>()) { + QIcon icon = iconCache->icon(qvariant_cast<PropertySheetIconValue>(v)); comboBox->setItemIcon(i, icon); comboBox->setItemData(i, icon); } @@ -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 770dfbc..1e48cf8 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 @@ -432,15 +450,15 @@ namespace Utils { inline int valueOf(const QVariant &value, bool *ok = 0) { - if (qVariantCanConvert<PropertySheetEnumValue>(value)) { + if (value.canConvert<PropertySheetEnumValue>()) { if (ok) *ok = true; - return qVariantValue<PropertySheetEnumValue>(value).value; + return qvariant_cast<PropertySheetEnumValue>(value).value; } - else if (qVariantCanConvert<PropertySheetFlagValue>(value)) { + else if (value.canConvert<PropertySheetFlagValue>()) { if (ok) *ok = true; - return qVariantValue<PropertySheetFlagValue>(value).value; + return qvariant_cast<PropertySheetFlagValue>(value).value; } return value.toInt(ok); } diff --git a/tools/designer/src/lib/shared/qlayout_widget.cpp b/tools/designer/src/lib/shared/qlayout_widget.cpp index 4debb5e..66e7a79 100644 --- a/tools/designer/src/lib/shared/qlayout_widget.cpp +++ b/tools/designer/src/lib/shared/qlayout_widget.cpp @@ -601,7 +601,7 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const } } - // Grid Layout state. Datatypically store the state of a GridLayout as a map of + // Grid Layout state. Datatype storing the state of a GridLayout as a map of // widgets to QRect(columns, rows) and size. Used to store the state for undo operations // that do not change the widgets within the layout; also provides some manipulation // functions and ability to apply the state to a layout provided its widgets haven't changed. @@ -634,7 +634,11 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const static CellStates cellStates(const QList<QRect> &rects, int numRows, int numColumns); typedef QMap<QWidget *, QRect> WidgetItemMap; + typedef QMap<QWidget *, Qt::Alignment> WidgetAlignmentMap; + WidgetItemMap widgetItemMap; + WidgetAlignmentMap widgetAlignmentMap; + int rowCount; int colCount; }; @@ -706,8 +710,11 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const const int count = l->count(); for (int i = 0; i < count; i++) { QLayoutItem *item = l->itemAt(i); - if (!LayoutInfo::isEmptyItem(item)) + if (!LayoutInfo::isEmptyItem(item)) { widgetItemMap.insert(item->widget(), gridItemInfo(l, i)); + if (item->alignment()) + widgetAlignmentMap.insert(item->widget(), item->alignment()); + } } } @@ -743,7 +750,8 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const const LayoutItemRectMap::const_iterator icend = itemMap.constEnd(); for (LayoutItemRectMap::const_iterator it = itemMap.constBegin(); it != icend; ++it) { const QRect info = it.value(); - grid->addItem(it.key(), info.y(), info.x(), info.height(), info.width()); + const Qt::Alignment alignment = widgetAlignmentMap.value(it.key()->widget(), Qt::Alignment(0)); + grid->addItem(it.key(), info.y(), info.x(), info.height(), info.width(), alignment); } // create spacers const CellStates cs = cellStates(itemMap.values(), rowCount, colCount); diff --git a/tools/designer/src/lib/shared/qtresourcemodel.cpp b/tools/designer/src/lib/shared/qtresourcemodel.cpp index cf9b1ee..ca2fb78 100644 --- a/tools/designer/src/lib/shared/qtresourcemodel.cpp +++ b/tools/designer/src/lib/shared/qtresourcemodel.cpp @@ -184,15 +184,15 @@ const QByteArray *QtResourceModelPrivate::createResource(const QString &path, QS break; // return code cannot be fully trusted, might still be empty const ResourceDataFileMap resMap = library.resourceDataFileMap(); - if (resMap.empty()) - break; - if (!library.output(buffer, errorDevice)) break; *errorCount = library.failedResources().size(); *contents = resMap.keys(); + if (resMap.empty()) + break; + buffer.close(); rc = new QByteArray(buffer.data()); } while (false); @@ -225,15 +225,18 @@ void QtResourceModelPrivate::registerResourceSet(QtResourceSet *resourceSet) qDebug() << "registerResourceSet " << path; const PathDataMap::const_iterator itRcc = m_pathToData.constFind(path); if (itRcc != m_pathToData.constEnd()) { // otherwise data was not created yet - if (!QResource::registerResource(reinterpret_cast<const uchar *>(itRcc.value()->constData()))) { - qDebug() << "** WARNING: Failed to register " << path << " (QResource failure)."; - } else { - QStringList contents = m_pathToContents.value(path); - QStringListIterator itContents(contents); - while (itContents.hasNext()) { - const QString filePath = itContents.next(); - if (!m_fileToQrc.contains(filePath)) // the first loaded resource has higher priority in qt resource system - m_fileToQrc.insert(filePath, path); + const QByteArray *data = itRcc.value(); + if (data) { + if (!QResource::registerResource(reinterpret_cast<const uchar *>(data->constData()))) { + qWarning() << "** WARNING: Failed to register " << path << " (QResource failure)."; + } else { + QStringList contents = m_pathToContents.value(path); + QStringListIterator itContents(contents); + while (itContents.hasNext()) { + const QString filePath = itContents.next(); + if (!m_fileToQrc.contains(filePath)) // the first loaded resource has higher priority in qt resource system + m_fileToQrc.insert(filePath, path); + } } } } @@ -254,8 +257,11 @@ void QtResourceModelPrivate::unregisterResourceSet(QtResourceSet *resourceSet) qDebug() << "unregisterResourceSet " << path; const PathDataMap::const_iterator itRcc = m_pathToData.constFind(path); if (itRcc != m_pathToData.constEnd()) { // otherwise data was not created yet - if (!QResource::unregisterResource(reinterpret_cast<const uchar *>(itRcc.value()->constData()))) - qDebug() << "** WARNING: Failed to unregister " << path << " (QResource failure)."; + const QByteArray *data = itRcc.value(); + if (data) { + if (!QResource::unregisterResource(reinterpret_cast<const uchar *>(itRcc.value()->constData()))) + qWarning() << "** WARNING: Failed to unregister " << path << " (QResource failure)."; + } } } m_fileToQrc.clear(); @@ -292,15 +298,13 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL QStringList contents; int qrcErrorCount; generatedCount++; - if (const QByteArray *data = createResource(path, &contents, &qrcErrorCount, errorStream)) { - newPathToData.insert(path, data); - if (qrcErrorCount) // Count single failed files as sort of 1/2 error - errorCount++; - addWatcher(path); - } else { - newPathToData.remove(path); + const QByteArray *data = createResource(path, &contents, &qrcErrorCount, errorStream); + + newPathToData.insert(path, data); + if (qrcErrorCount) // Count single failed files as sort of 1/2 error errorCount++; - } + addWatcher(path); + m_pathToModified.insert(path, false); m_pathToContents.insert(path, contents); newResourceSetChanged = true; @@ -326,7 +330,7 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL QListIterator<const QByteArray *> itOld(oldData); if (itOld.hasNext()) { const QByteArray *array = itOld.next(); - if (!newData.contains(array)) + if (array && !newData.contains(array)) toDelete.append(array); } diff --git a/tools/designer/src/lib/shared/richtexteditor.cpp b/tools/designer/src/lib/shared/richtexteditor.cpp index 7c87209..c2cdb20 100644 --- a/tools/designer/src/lib/shared/richtexteditor.cpp +++ b/tools/designer/src/lib/shared/richtexteditor.cpp @@ -52,6 +52,9 @@ #include <QtCore/QList> #include <QtCore/QMap> #include <QtCore/QPointer> +#include <QtCore/QXmlStreamReader> +#include <QtCore/QXmlStreamWriter> +#include <QtCore/QXmlStreamAttributes> #include <QtGui/QAction> #include <QtGui/QColorDialog> @@ -74,28 +77,129 @@ QT_BEGIN_NAMESPACE -static const char *RichTextDialogC = "RichTextDialog"; -static const char *Geometry = "Geometry"; +static const char RichTextDialogGroupC[] = "RichTextDialog"; +static const char GeometryKeyC[] = "Geometry"; +static const char TabKeyC[] = "Tab"; + +const bool simplifyRichTextDefault = true; namespace qdesigner_internal { +// Richtext simplification filter helpers: Elements to be discarded +static inline bool filterElement(const QStringRef &name) +{ + return name != QLatin1String("meta") && name != QLatin1String("style"); +} + +// Richtext simplification filter helpers: Filter attributes of elements +static inline void filterAttributes(const QStringRef &name, + QXmlStreamAttributes *atts, + bool *paragraphAlignmentFound) +{ + typedef QXmlStreamAttributes::iterator AttributeIt; + + if (atts->isEmpty()) + return; + + // No style attributes for <body> + if (name == QLatin1String("body")) { + atts->clear(); + return; + } + + // Clean out everything except 'align' for 'p' + if (name == QLatin1String("p")) { + for (AttributeIt it = atts->begin(); it != atts->end(); ) { + if (it->name() == QLatin1String("align")) { + ++it; + *paragraphAlignmentFound = true; + } else { + it = atts->erase(it); + } + } + return; + } +} + +// Richtext simplification filter helpers: Check for blank QStringRef. +static inline bool isWhiteSpace(const QStringRef &in) +{ + const int count = in.size(); + for (int i = 0; i < count; i++) + if (!in.at(i).isSpace()) + return false; + return true; +} + +// Richtext simplification filter: Remove hard-coded font settings, +// <style> elements, <p> attributes other than 'align' and +// and unnecessary meta-information. +QString simplifyRichTextFilter(const QString &in, bool *isPlainTextPtr = 0) +{ + unsigned elementCount = 0; + bool paragraphAlignmentFound = false; + QString out; + QXmlStreamReader reader(in); + QXmlStreamWriter writer(&out); + writer.setAutoFormatting(false); + writer.setAutoFormattingIndent(0); + + while (!reader.atEnd()) { + switch (reader.readNext()) { + case QXmlStreamReader::StartElement: + elementCount++; + if (filterElement(reader.name())) { + const QStringRef name = reader.name(); + QXmlStreamAttributes attributes = reader.attributes(); + filterAttributes(name, &attributes, ¶graphAlignmentFound); + writer.writeStartElement(name.toString()); + if (!attributes.isEmpty()) + writer.writeAttributes(attributes); + } else { + reader.readElementText(); // Skip away all nested elements and characters. + } + break; + case QXmlStreamReader::Characters: + if (!isWhiteSpace(reader.text())) + writer.writeCharacters(reader.text().toString()); + break; + case QXmlStreamReader::EndElement: + writer.writeEndElement(); + break; + default: + break; + } + } + // Check for plain text (no spans, just <html><head><body><p>) + if (isPlainTextPtr) + *isPlainTextPtr = !paragraphAlignmentFound && elementCount == 4u; // + return out; +} + class RichTextEditor : public QTextEdit { Q_OBJECT public: - RichTextEditor(QWidget *parent = 0); - void setDefaultFont(const QFont &font); + explicit RichTextEditor(QWidget *parent = 0); + void setDefaultFont(QFont font); QToolBar *createToolBar(QDesignerFormEditorInterface *core, QWidget *parent = 0); + bool simplifyRichText() const { return m_simplifyRichText; } + public slots: void setFontBold(bool b); void setFontPointSize(double); void setText(const QString &text); + void setSimplifyRichText(bool v); QString text(Qt::TextFormat format) const; signals: void stateChanged(); + void simplifyRichTextChanged(bool); + +private: + bool m_simplifyRichText; }; class AddLinkDialog : public QDialog @@ -303,6 +407,7 @@ private: QAction *m_align_justify_action; QAction *m_link_action; QAction *m_image_action; + QAction *m_simplify_richtext_action; ColorAction *m_color_action; QComboBox *m_font_size_input; @@ -432,6 +537,17 @@ RichTextEditorToolBar::RichTextEditorToolBar(QDesignerFormEditorInterface *core, this, SLOT(colorChanged(QColor))); addAction(m_color_action); + addSeparator(); + + // Simplify rich text + m_simplify_richtext_action + = createCheckableAction(createIconSet(QLatin1String("simplifyrichtext.png")), + tr("Simplify Rich Text"), m_editor, SLOT(setSimplifyRichText(bool))); + m_simplify_richtext_action->setChecked(m_editor->simplifyRichText()); + connect(m_editor, SIGNAL(simplifyRichTextChanged(bool)), + m_simplify_richtext_action, SLOT(setChecked(bool))); + addAction(m_simplify_richtext_action); + connect(editor, SIGNAL(textChanged()), this, SLOT(updateActions())); connect(editor, SIGNAL(stateChanged()), this, SLOT(updateActions())); @@ -551,7 +667,7 @@ void RichTextEditorToolBar::updateActions() } RichTextEditor::RichTextEditor(QWidget *parent) - : QTextEdit(parent) + : QTextEdit(parent), m_simplifyRichText(simplifyRichTextDefault) { connect(this, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SIGNAL(stateChanged())); @@ -579,14 +695,31 @@ void RichTextEditor::setFontPointSize(double d) void RichTextEditor::setText(const QString &text) { + if (Qt::mightBeRichText(text)) setHtml(text); else setPlainText(text); } -void RichTextEditor::setDefaultFont(const QFont &font) +void RichTextEditor::setSimplifyRichText(bool v) { + if (v != m_simplifyRichText) { + m_simplifyRichText = v; + emit simplifyRichTextChanged(v); + } +} + +void RichTextEditor::setDefaultFont(QFont font) +{ + // Some default fonts on Windows have a default size of 7.8, + // which results in complicated rich text generated by toHtml(). + // Use an integer value. + const int pointSize = qRound(font.pointSizeF()); + if (pointSize > 0 && !qFuzzyCompare(qreal(pointSize), font.pointSizeF())) { + font.setPointSize(pointSize); + } + document()->setDefaultFont(font); if (font.pointSize() > 0) setFontPointSize(font.pointSize()); @@ -602,15 +735,16 @@ QString RichTextEditor::text(Qt::TextFormat format) const case Qt::PlainText: return toPlainText(); case Qt::RichText: - return toHtml(); + return m_simplifyRichText ? simplifyRichTextFilter(toHtml()) : toHtml(); case Qt::AutoText: break; } const QString html = toHtml(); - const QString plain = toPlainText(); - QTextEdit tester; - tester.setPlainText(plain); - return tester.toHtml() == html ? plain : html; + bool isPlainText; + const QString simplifiedHtml = simplifyRichTextFilter(html, &isPlainText); + if (isPlainText) + return toPlainText(); + return m_simplifyRichText ? simplifiedHtml : html; } RichTextEditorDialog::RichTextEditorDialog(QDesignerFormEditorInterface *core, QWidget *parent) : @@ -619,15 +753,25 @@ RichTextEditorDialog::RichTextEditorDialog(QDesignerFormEditorInterface *core, Q m_text_edit(new HtmlTextEdit), m_tab_widget(new QTabWidget), m_state(Clean), - m_core(core) + m_core(core), + m_initialTab(RichTextIndex) { setWindowTitle(tr("Edit text")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + // Read settings + const QDesignerSettingsInterface *settings = core->settingsManager(); + const QString rootKey = QLatin1String(RichTextDialogGroupC) + QLatin1Char('/'); + const QByteArray lastGeometry = settings->value(rootKey + QLatin1String(GeometryKeyC)).toByteArray(); + const int initialTab = settings->value(rootKey + QLatin1String(TabKeyC), QVariant(m_initialTab)).toInt(); + if (initialTab == RichTextIndex || initialTab == SourceIndex) + m_initialTab = initialTab; + m_text_edit->setAcceptRichText(false); new HtmlHighlighter(m_text_edit); connect(m_editor, SIGNAL(textChanged()), this, SLOT(richTextChanged())); + connect(m_editor, SIGNAL(simplifyRichTextChanged(bool)), this, SLOT(richTextChanged())); connect(m_text_edit, SIGNAL(textChanged()), this, SLOT(sourceChanged())); // The toolbar needs to be created after the RichTextEditor @@ -661,32 +805,33 @@ RichTextEditorDialog::RichTextEditorDialog(QDesignerFormEditorInterface *core, Q layout->addWidget(m_tab_widget); layout->addWidget(buttonBox); - m_editor->setFocus(); - - QDesignerSettingsInterface *settings = core->settingsManager(); - settings->beginGroup(QLatin1String(RichTextDialogC)); - - if (settings->contains(QLatin1String(Geometry))) - restoreGeometry(settings->value(QLatin1String(Geometry)).toByteArray()); - - settings->endGroup(); + if (!lastGeometry.isEmpty()) + restoreGeometry(lastGeometry); } RichTextEditorDialog::~RichTextEditorDialog() { QDesignerSettingsInterface *settings = m_core->settingsManager(); - settings->beginGroup(QLatin1String(RichTextDialogC)); + settings->beginGroup(QLatin1String(RichTextDialogGroupC)); - settings->setValue(QLatin1String(Geometry), saveGeometry()); + settings->setValue(QLatin1String(GeometryKeyC), saveGeometry()); + settings->setValue(QLatin1String(TabKeyC), m_tab_widget->currentIndex()); settings->endGroup(); } int RichTextEditorDialog::showDialog() { - m_tab_widget->setCurrentIndex(0); - m_editor->selectAll(); - m_editor->setFocus(); - + m_tab_widget->setCurrentIndex(m_initialTab); + switch (m_initialTab) { + case RichTextIndex: + m_editor->selectAll(); + m_editor->setFocus(); + break; + case SourceIndex: + m_text_edit->selectAll(); + m_text_edit->setFocus(); + break; + } return exec(); } @@ -697,6 +842,9 @@ void RichTextEditorDialog::setDefaultFont(const QFont &font) void RichTextEditorDialog::setText(const QString &text) { + // Generally simplify rich text unless verbose text is found. + const bool isSimplifiedRichText = !text.startsWith("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">"); + m_editor->setSimplifyRichText(isSimplifiedRichText); m_editor->setText(text); m_text_edit->setPlainText(text); m_state = Clean; diff --git a/tools/designer/src/lib/shared/richtexteditor_p.h b/tools/designer/src/lib/shared/richtexteditor_p.h index a78db32..086c5d5 100644 --- a/tools/designer/src/lib/shared/richtexteditor_p.h +++ b/tools/designer/src/lib/shared/richtexteditor_p.h @@ -93,6 +93,7 @@ private: QTabWidget *m_tab_widget; State m_state; QDesignerFormEditorInterface *m_core; + int m_initialTab; }; } // namespace qdesigner_internal diff --git a/tools/designer/src/lib/shared/shared.pri b/tools/designer/src/lib/shared/shared.pri index 8286360..9d50911 100644 --- a/tools/designer/src/lib/shared/shared.pri +++ b/tools/designer/src/lib/shared/shared.pri @@ -2,7 +2,7 @@ INCLUDEPATH += $$PWD contains(QT_CONFIG, script): QT += script -include(../../../../shared/qtpropertybrowser/qtpropertybrowser.pri) +include(../../../../shared/qtpropertybrowser/qtpropertybrowserutils.pri) include(../../../../shared/deviceskin/deviceskin.pri) include(../../../../../src/tools/rcc/rcc.pri) include(../../../../shared/findwidget/findwidget.pri) diff --git a/tools/designer/src/lib/shared/stylesheeteditor.cpp b/tools/designer/src/lib/shared/stylesheeteditor.cpp index 0c378a7..ee5fea4 100644 --- a/tools/designer/src/lib/shared/stylesheeteditor.cpp +++ b/tools/designer/src/lib/shared/stylesheeteditor.cpp @@ -394,14 +394,14 @@ StyleSheetPropertyEditorDialog::StyleSheetPropertyEditorDialog(QWidget *parent, qt_extension<QDesignerPropertySheetExtension*>(m_fw->core()->extensionManager(), m_widget); Q_ASSERT(sheet != 0); const int index = sheet->indexOf(QLatin1String(styleSheetProperty)); - const PropertySheetStringValue value = qVariantValue<PropertySheetStringValue>(sheet->property(index)); + const PropertySheetStringValue value = qvariant_cast<PropertySheetStringValue>(sheet->property(index)); setText(value.value()); } void StyleSheetPropertyEditorDialog::applyStyleSheet() { const PropertySheetStringValue value(text(), false); - m_fw->cursor()->setWidgetProperty(m_widget, QLatin1String(styleSheetProperty), qVariantFromValue(value)); + m_fw->cursor()->setWidgetProperty(m_widget, QLatin1String(styleSheetProperty), QVariant::fromValue(value)); } } // namespace qdesigner_internal diff --git a/tools/designer/src/lib/shared/widgetdatabase.cpp b/tools/designer/src/lib/shared/widgetdatabase.cpp index 6b8fc0d..aa1a775 100644 --- a/tools/designer/src/lib/shared/widgetdatabase.cpp +++ b/tools/designer/src/lib/shared/widgetdatabase.cpp @@ -54,7 +54,8 @@ #include <QtDesigner/QDesignerFormEditorInterface> #include <QtXml/QXmlStreamWriter> -#include <QtCore/QtAlgorithms> + +#include <QtCore/QScopedPointer> #include <QtCore/qdebug.h> #include <QtCore/QMetaProperty> #include <QtCore/QTextStream> @@ -565,10 +566,10 @@ static QString xmlFromWidgetBox(const QDesignerFormEditorInterface *core, const const bool found = QDesignerWidgetBox::findWidget(core->widgetBox(), className, QString(), &widget); if (!found) return QString(); - DomUI *domUI = QDesignerWidgetBox::xmlToUi(className, widget.domXml(), false); - domUI->setAttributeVersion(QLatin1String("4.0")); - if (!domUI) + QScopedPointer<DomUI> domUI(QDesignerWidgetBox::xmlToUi(className, widget.domXml(), false)); + if (domUI.isNull()) return QString(); + domUI->setAttributeVersion(QLatin1String("4.0")); DomWidget *domWidget = domUI->elementWidget(); if (!domWidget) return QString(); @@ -615,7 +616,6 @@ static QString xmlFromWidgetBox(const QDesignerFormEditorInterface *core, const domUI->write(writer); writer.writeEndDocument(); } - delete domUI; return rc; } diff --git a/tools/designer/src/lib/shared/widgetfactory.cpp b/tools/designer/src/lib/shared/widgetfactory.cpp index 36f795e..bcd23ee 100644 --- a/tools/designer/src/lib/shared/widgetfactory.cpp +++ b/tools/designer/src/lib/shared/widgetfactory.cpp @@ -784,7 +784,7 @@ void WidgetFactory::applyStyleToTopLevel(QStyle *style, QWidget *widget) widget->setStyle(style); widget->setPalette(standardPalette); - const QWidgetList lst = qFindChildren<QWidget*>(widget); + const QWidgetList lst = widget->findChildren<QWidget*>(); const QWidgetList::const_iterator cend = lst.constEnd(); for (QWidgetList::const_iterator it = lst.constBegin(); it != cend; ++it) (*it)->setStyle(style); diff --git a/tools/designer/src/lib/shared/zoomwidget.cpp b/tools/designer/src/lib/shared/zoomwidget.cpp index 57d8f69..c77a518 100644 --- a/tools/designer/src/lib/shared/zoomwidget.cpp +++ b/tools/designer/src/lib/shared/zoomwidget.cpp @@ -328,7 +328,7 @@ void ZoomWidget::setWidget(QWidget *w, Qt::WindowFlags wFlags) scene().removeItem(m_proxy); if (QWidget *w = m_proxy->widget()) { // remove the event filter - if (QObject *evf = qFindChild<QObject*>(w, QLatin1String(zoomedEventFilterRedirectorNameC))) + if (QObject *evf = w->findChild<QObject*>(QLatin1String(zoomedEventFilterRedirectorNameC))) w->removeEventFilter(evf); } m_proxy->deleteLater(); diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp index 9353e05..ecb43db 100644 --- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp @@ -341,7 +341,7 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge w->addAction(a); } else if (QActionGroup *g = m_actionGroups.value(name)) { w->addActions(g->actions()); - } else if (QMenu *menu = qFindChild<QMenu*>(w, name)) { + } else if (QMenu *menu = w->findChild<QMenu*>(name)) { w->addAction(menu->menuAction()); addMenuAction(menu->menuAction()); } @@ -363,9 +363,9 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge const QStringList zOrderNames = ui_widget->elementZOrder(); if (!zOrderNames.isEmpty()) { - QList<QWidget *> zOrder = qVariantValue<QWidgetList>(w->property("_q_zOrder")); + QList<QWidget *> zOrder = qvariant_cast<QWidgetList>(w->property("_q_zOrder")); foreach (const QString &widgetName, zOrderNames) { - if (QWidget *child = qFindChild<QWidget*>(w, widgetName)) { + if (QWidget *child = w->findChild<QWidget*>(widgetName)) { if (child->parentWidget() == w) { zOrder.removeAll(child); zOrder.append(child); @@ -373,7 +373,7 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge } } } - w->setProperty("_q_zOrder", qVariantFromValue(zOrder)); + w->setProperty("_q_zOrder", QVariant::fromValue(zOrder)); } return w; @@ -794,6 +794,69 @@ static inline QFormLayout::ItemRole formLayoutRole(int column, int colspan) } #endif +static inline QString alignmentValue(Qt::Alignment a) +{ + QString h,v; + switch (a & Qt::AlignHorizontal_Mask) { + case Qt::AlignLeft: + h = QLatin1String("Qt::AlignLeft"); + break; + case Qt::AlignRight: + h = QLatin1String("Qt::AlignRight"); + break; + case Qt::AlignHCenter: + h = QLatin1String("Qt::AlignHCenter"); + break; + case Qt::AlignJustify: + h = QLatin1String("Qt::AlignJustify"); + break; + } + switch (a & Qt::AlignVertical_Mask) { + case Qt::AlignTop: + v = QLatin1String("Qt::AlignTop"); + break; + case Qt::AlignBottom: + v = QLatin1String("Qt::AlignBottom"); + break; + case Qt::AlignVCenter: + v = QLatin1String("Qt::AlignVCenter"); + break; + } + if (h.isEmpty() && v.isEmpty()) + return QString(); + if (!v.isEmpty()) { + if (!h.isEmpty()) + h += QLatin1Char('|'); + h += v; + } + return h; +} + +static inline Qt::Alignment alignmentFromDom(const QString &in) +{ + Qt::Alignment rc = 0; + if (!in.isEmpty()) { + foreach (const QString &f, in.split(QLatin1Char('|'))) { + if (f == QLatin1String("Qt::AlignLeft")) { + rc |= Qt::AlignLeft; + } else if (f == QLatin1String("Qt::AlignRight")) { + rc |= Qt::AlignRight; + } else if (f == QLatin1String("Qt::AlignHCenter")) { + rc |= Qt::AlignHCenter; + } else if (f == QLatin1String("Qt::AlignJustify")) { + rc |= Qt::AlignJustify; + } else if (f == QLatin1String("Qt::AlignTop")) { + rc |= Qt::AlignTop; + } else if (f == QLatin1String("Qt::AlignBottom")) { + rc |= Qt::AlignBottom; + } else if (f == QLatin1String("Qt::AlignVCenter")) { + rc |= Qt::AlignVCenter; + } + } + } + return rc; +} + /*! \internal */ @@ -838,12 +901,15 @@ QLayoutItem *QAbstractFormBuilder::create(DomLayoutItem *ui_layoutItem, QLayout { switch (ui_layoutItem->kind()) { case DomLayoutItem::Widget: { - if (QWidget *w = create(ui_layoutItem->elementWidget(), parentWidget)) + if (QWidget *w = create(ui_layoutItem->elementWidget(), parentWidget)) { #ifdef QFORMINTERNAL_NAMESPACE // uilib - return new QWidgetItemV2(w); + QWidgetItem *item = new QWidgetItemV2(w); #else // Within Designer: Use factory method that returns special items that refuse to shrink to 0,0 - return QLayoutPrivate::createWidgetItem(layout, w); + QWidgetItem *item = QLayoutPrivate::createWidgetItem(layout, w); #endif + item->setAlignment(alignmentFromDom(ui_layoutItem->attributeAlignment())); + return item; + } qWarning() << QCoreApplication::translate("QAbstractFormBuilder", "Empty widget item in %1 '%2'.").arg(QString::fromUtf8(layout->metaObject()->className()), layout->objectName()); return 0; } @@ -1287,7 +1353,7 @@ DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parent { QList<QObject *> childObjects = widget->children(); - const QList<QWidget *> list = qVariantValue<QWidgetList>(widget->property("_q_widgetOrder")); + const QList<QWidget *> list = qvariant_cast<QWidgetList>(widget->property("_q_widgetOrder")); foreach (QWidget *w, list) { if (childObjects.contains(w)) { children.append(w); @@ -1296,7 +1362,7 @@ DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parent } children += childObjects; - const QList<QWidget *> zOrder = qVariantValue<QWidgetList>(widget->property("_q_zOrder")); + const QList<QWidget *> zOrder = qvariant_cast<QWidgetList>(widget->property("_q_zOrder")); if (list != zOrder) { QStringList zOrderList; QListIterator<QWidget* > itZOrder(zOrder); @@ -1381,9 +1447,87 @@ 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), alignment(0) {} + + QLayoutItem *item; + int row; + int column; + int rowSpan; + int columnSpan; + Qt::Alignment alignment; +}; + +// 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); + FormBuilderSaveLayoutEntry entry(item); + entry.alignment = item->alignment(); + rc.append(entry); + } + } + 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); + entry.alignment = item->alignment(); + 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 +1538,32 @@ 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); + if (item.alignment) + ui_item->setAttributeAlignment(alignmentValue(item.alignment)); ui_items.append(ui_item); + } } lay->setElementItem(ui_items); @@ -1603,14 +1742,14 @@ void QAbstractFormBuilder::applyTabStops(QWidget *widget, DomTabStops *tabStops) for (int i=0; i<l.size(); ++i) { const QString name = l.at(i); - QWidget *child = qFindChild<QWidget*>(widget, name); + QWidget *child = widget->findChild<QWidget*>(name); if (!child) { uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "While applying tab stops: The widget '%1' could not be found.").arg(name)); continue; } if (i == 0) { - lastWidget = qFindChild<QWidget*>(widget, name); + lastWidget = widget->findChild<QWidget*>(name); continue; } else if (!child || !lastWidget) { continue; @@ -1618,7 +1757,7 @@ void QAbstractFormBuilder::applyTabStops(QWidget *widget, DomTabStops *tabStops) QWidget::setTabOrder(lastWidget, child); - lastWidget = qFindChild<QWidget*>(widget, name); + lastWidget = widget->findChild<QWidget*>(name); } } @@ -1747,7 +1886,7 @@ static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, T *item, if ((p = properties.value(it.second))) { v = formBuilder->textBuilder()->loadText(p); QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v); - item->setData(it.first.first, qVariantValue<QString>(nativeValue)); + item->setData(it.first.first, qvariant_cast<QString>(nativeValue)); item->setData(it.first.second, v); } @@ -1759,7 +1898,7 @@ static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, T *item, if ((p = properties.value(strings.iconAttribute))) { v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p); QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v); - item->setIcon(qVariantValue<QIcon>(nativeValue)); + item->setIcon(qvariant_cast<QIcon>(nativeValue)); item->setData(Qt::DecorationPropertyRole, v); } } @@ -1855,7 +1994,7 @@ static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QTableWidge if ((p = properties.value(it.second))) { v = formBuilder->textBuilder()->loadText(p); QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v); - item->setData(it.first.first, qVariantValue<QString>(nativeValue)); + item->setData(it.first.first, qvariant_cast<QString>(nativeValue)); item->setData(it.first.second, v); } @@ -1867,7 +2006,7 @@ static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QTableWidge if ((p = properties.value(strings.iconAttribute))) { v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p); QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v); - item->setIcon(qVariantValue<QIcon>(nativeValue)); + item->setIcon(qvariant_cast<QIcon>(nativeValue)); item->setData(Qt::DecorationPropertyRole, v); } } @@ -1885,7 +2024,7 @@ static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QListWidget if ((p = properties.value(it.second))) { v = formBuilder->textBuilder()->loadText(p); QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v); - item->setData(it.first.first, qVariantValue<QString>(nativeValue)); + item->setData(it.first.first, qvariant_cast<QString>(nativeValue)); item->setData(it.first.second, v); } @@ -1897,7 +2036,7 @@ static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QListWidget if ((p = properties.value(strings.iconAttribute))) { v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p); QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v); - item->setIcon(qVariantValue<QIcon>(nativeValue)); + item->setIcon(qvariant_cast<QIcon>(nativeValue)); item->setData(Qt::DecorationPropertyRole, v); } } @@ -2152,6 +2291,7 @@ void QAbstractFormBuilder::saveButtonExtraInfo(const QAbstractButton *widget, Do DomPropertyList attributes = ui_widget->elementAttribute(); DomString *domString = new DomString(); domString->setText(buttonGroup->objectName()); + domString->setAttributeNotr(QLatin1String("true")); DomProperty *domProperty = new DomProperty(); domProperty->setAttributeName(QLatin1String(buttonGroupPropertyC)); domProperty->setElementString(domString); @@ -2337,14 +2477,14 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi if ((p = properties.value(it.second))) { v = textBuilder()->loadText(p); QVariant nativeValue = textBuilder()->toNativeValue(v); - treeWidget->headerItem()->setData(i, it.first.first, qVariantValue<QString>(nativeValue)); + treeWidget->headerItem()->setData(i, it.first.first, qvariant_cast<QString>(nativeValue)); treeWidget->headerItem()->setData(i, it.first.second, v); } if ((p = properties.value(strings.iconAttribute))) { v = resourceBuilder()->loadResource(workingDirectory(), p); QVariant nativeValue = resourceBuilder()->toNativeValue(v); - treeWidget->headerItem()->setIcon(i, qVariantValue<QIcon>(nativeValue)); + treeWidget->headerItem()->setIcon(i, qvariant_cast<QIcon>(nativeValue)); treeWidget->headerItem()->setData(i, Qt::DecorationPropertyRole, v); } } @@ -2374,14 +2514,14 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi col++; QVariant textV = textBuilder()->loadText(property); QVariant nativeValue = textBuilder()->toNativeValue(textV); - currentItem->setText(col, qVariantValue<QString>(nativeValue)); + currentItem->setText(col, qvariant_cast<QString>(nativeValue)); currentItem->setData(col, Qt::DisplayPropertyRole, textV); } else if (col >= 0) { if (property->attributeName() == strings.iconAttribute) { QVariant v = resourceBuilder()->loadResource(workingDirectory(), property); if (v.isValid()) { QVariant nativeValue = resourceBuilder()->toNativeValue(v); - currentItem->setIcon(col, qVariantValue<QIcon>(nativeValue)); + currentItem->setIcon(col, qvariant_cast<QIcon>(nativeValue)); currentItem->setData(col, Qt::DecorationPropertyRole, v); } } else { @@ -2397,7 +2537,7 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi if (rolePair.first >= 0) { QVariant textV = textBuilder()->loadText(property); QVariant nativeValue = textBuilder()->toNativeValue(textV); - currentItem->setData(col, rolePair.first, qVariantValue<QString>(nativeValue)); + currentItem->setData(col, rolePair.first, qvariant_cast<QString>(nativeValue)); currentItem->setData(col, rolePair.second, textV); } } @@ -2475,13 +2615,13 @@ void QAbstractFormBuilder::loadComboBoxExtraInfo(DomWidget *ui_widget, QComboBox p = properties.value(strings.textAttribute); if (p && p->elementString()) { textData = textBuilder()->loadText(p); - text = qVariantValue<QString>(textBuilder()->toNativeValue(textData)); + text = qvariant_cast<QString>(textBuilder()->toNativeValue(textData)); } p = properties.value(strings.iconAttribute); if (p) { iconData = resourceBuilder()->loadResource(workingDirectory(), p); - icon = qVariantValue<QIcon>(resourceBuilder()->toNativeValue(iconData)); + icon = qvariant_cast<QIcon>(resourceBuilder()->toNativeValue(iconData)); } comboBox->addItem(icon, text); diff --git a/tools/designer/src/lib/uilib/formbuilder.cpp b/tools/designer/src/lib/uilib/formbuilder.cpp index ac6dcdb..b997cc9 100644 --- a/tools/designer/src/lib/uilib/formbuilder.cpp +++ b/tools/designer/src/lib/uilib/formbuilder.cpp @@ -319,7 +319,7 @@ QWidget *QFormBuilder::widgetByName(QWidget *topLevel, const QString &name) if (topLevel->objectName() == name) return topLevel; - return qFindChild<QWidget*>(topLevel, name); + return topLevel->findChild<QWidget*>(name); } static QObject *objectByName(QWidget *topLevel, const QString &name) @@ -328,7 +328,7 @@ static QObject *objectByName(QWidget *topLevel, const QString &name) if (topLevel->objectName() == name) return topLevel; - return qFindChild<QObject*>(topLevel, name); + return topLevel->findChild<QObject*>(name); } /*! diff --git a/tools/designer/src/lib/uilib/formbuilderextra.cpp b/tools/designer/src/lib/uilib/formbuilderextra.cpp index 96bae0a..ecc6288 100644 --- a/tools/designer/src/lib/uilib/formbuilderextra.cpp +++ b/tools/designer/src/lib/uilib/formbuilderextra.cpp @@ -136,7 +136,7 @@ bool QFormBuilderExtra::applyBuddy(const QString &buddyName, BuddyMode applyMode return false; } - const QWidgetList widgets = qFindChildren<QWidget*>(label->topLevelWidget(), buddyName); + const QWidgetList widgets = label->topLevelWidget()->findChildren<QWidget*>(buddyName); if (widgets.empty()) { label->setBuddy(0); return false; diff --git a/tools/designer/src/lib/uilib/properties.cpp b/tools/designer/src/lib/uilib/properties.cpp index 80a91e3..67f4d11 100644 --- a/tools/designer/src/lib/uilib/properties.cpp +++ b/tools/designer/src/lib/uilib/properties.cpp @@ -78,7 +78,7 @@ QVariant domPropertyToVariant(QAbstractFormBuilder *afb,const QMetaObject *meta, case DomProperty::String: { const int index = meta->indexOfProperty(p->attributeName().toUtf8()); if (index != -1 && meta->property(index).type() == QVariant::KeySequence) - return qVariantFromValue(QKeySequence(p->elementString()->text())); + return QVariant::fromValue(QKeySequence(p->elementString()->text())); } break; @@ -96,7 +96,7 @@ QVariant domPropertyToVariant(QAbstractFormBuilder *afb,const QMetaObject *meta, afb->setupColorGroup(palette, QPalette::Disabled, dom->elementDisabled()); palette.setCurrentColorGroup(QPalette::Active); - return qVariantFromValue(palette); + return QVariant::fromValue(palette); } case DomProperty::Set: { @@ -135,7 +135,7 @@ QVariant domPropertyToVariant(QAbstractFormBuilder *afb,const QMetaObject *meta, return QVariant(e.keyToValue(enumValue.toUtf8())); } case DomProperty::Brush: - return qVariantFromValue(afb->setupBrush(p->elementBrush())); + return QVariant::fromValue(afb->setupBrush(p->elementBrush())); default: if (afb->resourceBuilder()->isResourceProperty(p)) { return afb->resourceBuilder()->loadResource(afb->workingDirectory(), p); @@ -212,7 +212,7 @@ QVariant domPropertyToVariant(const DomProperty *p) case DomProperty::Char: { const DomChar *character = p->elementChar(); const QChar c(character->elementUnicode()); - return qVariantFromValue(c); + return QVariant::fromValue(c); } case DomProperty::Color: { @@ -220,7 +220,7 @@ QVariant domPropertyToVariant(const DomProperty *p) QColor c(color->elementRed(), color->elementGreen(), color->elementBlue()); if (color->hasAttributeAlpha()) c.setAlpha(color->attributeAlpha()); - return qVariantFromValue(c); + return QVariant::fromValue(c); } case DomProperty::Font: { @@ -248,7 +248,7 @@ QVariant domPropertyToVariant(const DomProperty *p) if (font->hasElementStyleStrategy()) { f.setStyleStrategy(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QFont::StyleStrategy>("styleStrategy", font->elementStyleStrategy().toLatin1())); } - return qVariantFromValue(f); + return QVariant::fromValue(f); } case DomProperty::Date: { @@ -275,15 +275,15 @@ QVariant domPropertyToVariant(const DomProperty *p) #ifndef QT_NO_CURSOR case DomProperty::Cursor: - return qVariantFromValue(QCursor(static_cast<Qt::CursorShape>(p->elementCursor()))); + return QVariant::fromValue(QCursor(static_cast<Qt::CursorShape>(p->elementCursor()))); case DomProperty::CursorShape: - return qVariantFromValue(QCursor(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, Qt::CursorShape>("cursorShape", p->elementCursorShape().toLatin1()))); + return QVariant::fromValue(QCursor(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, Qt::CursorShape>("cursorShape", p->elementCursorShape().toLatin1()))); #endif case DomProperty::Locale: { const DomLocale *locale = p->elementLocale(); - return qVariantFromValue(QLocale(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Language>("language", locale->attributeLanguage().toLatin1()), + return QVariant::fromValue(QLocale(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Language>("language", locale->attributeLanguage().toLatin1()), enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Country>("country", locale->attributeCountry().toLatin1()))); } case DomProperty::SizePolicy: { @@ -309,7 +309,7 @@ QVariant domPropertyToVariant(const DomProperty *p) sizePolicy.setVerticalPolicy(sp); } - return qVariantFromValue(sizePolicy); + return QVariant::fromValue(sizePolicy); } case DomProperty::StringList: diff --git a/tools/designer/src/lib/uilib/resourcebuilder.cpp b/tools/designer/src/lib/uilib/resourcebuilder.cpp index eb08a6b..0ea5d4c 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() { @@ -91,10 +94,18 @@ QVariant QResourceBuilder::loadResource(const QDir &workingDirectory, const DomP case DomProperty::Pixmap: { const DomResourcePixmap *dpx = property->elementPixmap(); QPixmap pixmap(QFileInfo(workingDirectory, dpx->text()).absoluteFilePath()); - return qVariantFromValue(pixmap); + return QVariant::fromValue(pixmap); } 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) @@ -113,10 +124,10 @@ QVariant QResourceBuilder::loadResource(const QDir &workingDirectory, const DomP icon.addFile(QFileInfo(workingDirectory, dpi->elementSelectedOff()->text()).absoluteFilePath(), QSize(), QIcon::Selected, QIcon::Off); if (flags & SelectedOn) icon.addFile(QFileInfo(workingDirectory, dpi->elementSelectedOn()->text()).absoluteFilePath(), QSize(), QIcon::Selected, QIcon::On); - return qVariantFromValue(icon); + return QVariant::fromValue(icon); } else { // 4.3 legacy const QIcon icon(QFileInfo(workingDirectory, dpi->text()).absoluteFilePath()); - return qVariantFromValue(icon); + return QVariant::fromValue(icon); } } break; diff --git a/tools/designer/src/lib/uilib/ui4.cpp b/tools/designer/src/lib/uilib/ui4.cpp index f0082c5..f79543f 100644 --- a/tools/designer/src/lib/uilib/ui4.cpp +++ b/tools/designer/src/lib/uilib/ui4.cpp @@ -3673,6 +3673,7 @@ void DomLayoutItem::clear(bool clear_all) m_attr_rowSpan = 0; m_has_attr_colSpan = false; m_attr_colSpan = 0; + m_has_attr_alignment = false; } m_kind = Unknown; @@ -3694,6 +3695,7 @@ DomLayoutItem::DomLayoutItem() m_attr_rowSpan = 0; m_has_attr_colSpan = false; m_attr_colSpan = 0; + m_has_attr_alignment = false; m_widget = 0; m_layout = 0; m_spacer = 0; @@ -3727,6 +3729,10 @@ void DomLayoutItem::read(QXmlStreamReader &reader) setAttributeColSpan(attribute.value().toString().toInt()); continue; } + if (name == QLatin1String("alignment")) { + setAttributeAlignment(attribute.value().toString()); + continue; + } reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); } @@ -3779,6 +3785,8 @@ void DomLayoutItem::read(const QDomElement &node) setAttributeRowSpan(node.attribute(QLatin1String("rowspan")).toInt()); if (node.hasAttribute(QLatin1String("colspan"))) setAttributeColSpan(node.attribute(QLatin1String("colspan")).toInt()); + if (node.hasAttribute(QLatin1String("alignment"))) + setAttributeAlignment(node.attribute(QLatin1String("alignment"))); for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { if (!n.isElement()) @@ -3828,6 +3836,9 @@ void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) cons if (hasAttributeColSpan()) writer.writeAttribute(QLatin1String("colspan"), QString::number(attributeColSpan())); + if (hasAttributeAlignment()) + writer.writeAttribute(QLatin1String("alignment"), attributeAlignment()); + switch (kind()) { case Widget: { DomWidget* v = elementWidget(); @@ -7745,6 +7756,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 +7774,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 +7804,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 +7886,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 +7957,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 2e09c67..6caf515 100644 --- a/tools/designer/src/lib/uilib/ui4_p.h +++ b/tools/designer/src/lib/uilib/ui4_p.h @@ -1427,6 +1427,11 @@ public: inline void setAttributeColSpan(int a) { m_attr_colSpan = a; m_has_attr_colSpan = true; } inline void clearAttributeColSpan() { m_has_attr_colSpan = false; } + inline bool hasAttributeAlignment() const { return m_has_attr_alignment; } + inline QString attributeAlignment() const { return m_attr_alignment; } + inline void setAttributeAlignment(const QString& a) { m_attr_alignment = a; m_has_attr_alignment = true; } + inline void clearAttributeAlignment() { m_has_attr_alignment = false; } + // child element accessors enum Kind { Unknown = 0, Widget, Layout, Spacer }; inline Kind kind() const { return m_kind; } @@ -1460,6 +1465,9 @@ private: int m_attr_colSpan; bool m_has_attr_colSpan; + QString m_attr_alignment; + bool m_has_attr_alignment; + // child element data Kind m_kind; DomWidget* m_widget; @@ -2809,6 +2817,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 +2881,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/uitools/quiloader.cpp b/tools/designer/src/uitools/quiloader.cpp index 21f2bd9..13ee48a 100644 --- a/tools/designer/src/uitools/quiloader.cpp +++ b/tools/designer/src/uitools/quiloader.cpp @@ -102,27 +102,27 @@ QVariant TranslatingTextBuilder::loadText(const DomProperty *text) const if (str->hasAttributeNotr()) { const QString notr = str->attributeNotr(); if (notr == QLatin1String("true") || notr == QLatin1String("yes")) - return qVariantFromValue(str->text()); + return QVariant::fromValue(str->text()); } QUiTranslatableStringValue strVal; strVal.setValue(str->text().toUtf8()); if (str->hasAttributeComment()) strVal.setComment(str->attributeComment().toUtf8()); - return qVariantFromValue(strVal); + return QVariant::fromValue(strVal); } QVariant TranslatingTextBuilder::toNativeValue(const QVariant &value) const { - if (qVariantCanConvert<QUiTranslatableStringValue>(value)) { - QUiTranslatableStringValue tsv = qVariantValue<QUiTranslatableStringValue>(value); + if (value.canConvert<QUiTranslatableStringValue>()) { + QUiTranslatableStringValue tsv = qvariant_cast<QUiTranslatableStringValue>(value); if (!m_trEnabled) return QString::fromUtf8(tsv.value().data()); - return qVariantFromValue( + return QVariant::fromValue( QApplication::translate(m_className, tsv.value(), tsv.comment(), QCoreApplication::UnicodeUTF8)); } - if (qVariantCanConvert<QString>(value)) - return qVariantFromValue(qVariantValue<QString>(value)); + if (value.canConvert<QString>()) + return QVariant::fromValue(qvariant_cast<QString>(value)); return value; } @@ -150,7 +150,7 @@ static void recursiveReTranslate(QTreeWidgetItem *item, const QByteArray &class_ for (unsigned j = 0; irs[j].shadowRole >= 0; j++) { QVariant v = item->data(i, irs[j].shadowRole); if (v.isValid()) { - QUiTranslatableStringValue tsv = qVariantValue<QUiTranslatableStringValue>(v); + QUiTranslatableStringValue tsv = qvariant_cast<QUiTranslatableStringValue>(v); const QString text = QApplication::translate(class_name, tsv.value(), tsv.comment(), QCoreApplication::UnicodeUTF8); @@ -172,7 +172,7 @@ static void reTranslateWidgetItem(T *item, const QByteArray &class_name) for (unsigned j = 0; irs[j].shadowRole >= 0; j++) { QVariant v = item->data(irs[j].shadowRole); if (v.isValid()) { - QUiTranslatableStringValue tsv = qVariantValue<QUiTranslatableStringValue>(v); + QUiTranslatableStringValue tsv = qvariant_cast<QUiTranslatableStringValue>(v); const QString text = QApplication::translate(class_name, tsv.value(), tsv.comment(), QCoreApplication::UnicodeUTF8); @@ -191,7 +191,7 @@ static void reTranslateTableItem(QTableWidgetItem *item, const QByteArray &class do { \ QVariant v = mainWidget->widget(i)->property(propName); \ if (v.isValid()) { \ - QUiTranslatableStringValue tsv = qVariantValue<QUiTranslatableStringValue>(v); \ + QUiTranslatableStringValue tsv = qvariant_cast<QUiTranslatableStringValue>(v); \ const QString text = QApplication::translate(m_className, \ tsv.value(), tsv.comment(), \ QCoreApplication::UnicodeUTF8); \ @@ -217,7 +217,7 @@ public: if (prop.startsWith(PROP_GENERIC_PREFIX)) { const QByteArray propName = prop.mid(sizeof(PROP_GENERIC_PREFIX) - 1); const QUiTranslatableStringValue tsv = - qVariantValue<QUiTranslatableStringValue>(o->property(prop)); + qvariant_cast<QUiTranslatableStringValue>(o->property(prop)); const QString text = QApplication::translate(m_className, tsv.value(), tsv.comment(), QCoreApplication::UnicodeUTF8); @@ -273,7 +273,7 @@ public: for (int i = 0; i < cnt; ++i) { const QVariant v = combow->itemData(i, Qt::DisplayPropertyRole); if (v.isValid()) { - QUiTranslatableStringValue tsv = qVariantValue<QUiTranslatableStringValue>(v); + QUiTranslatableStringValue tsv = qvariant_cast<QUiTranslatableStringValue>(v); const QString text = QApplication::translate(m_className, tsv.value(), tsv.comment(), QCoreApplication::UnicodeUTF8); @@ -430,7 +430,7 @@ void FormBuilderPrivate::applyProperties(QObject *o, const QList<DomProperty*> & continue; const QByteArray name = p->attributeName().toUtf8(); if (dynamicTr) { - o->setProperty(PROP_GENERIC_PREFIX + name, qVariantFromValue(strVal)); + o->setProperty(PROP_GENERIC_PREFIX + name, QVariant::fromValue(strVal)); anyTrs = trEnabled; } o->setProperty(name, text); @@ -489,7 +489,7 @@ QWidget *FormBuilderPrivate::create(DomWidget *ui_widget, QWidget *parentWidget) const QString text = convertTranslatable(p##attribute, m_class, &strVal); \ if (!text.isEmpty()) { \ if (dynamicTr) \ - mainWidget->widget(i)->setProperty(propName, qVariantFromValue(strVal)); \ + mainWidget->widget(i)->setProperty(propName, QVariant::fromValue(strVal)); \ mainWidget->setter(i, text); \ } \ } \ diff --git a/tools/designer/src/uitools/uitools.pro b/tools/designer/src/uitools/uitools.pro index 7b94587..be46afc 100644 --- a/tools/designer/src/uitools/uitools.pro +++ b/tools/designer/src/uitools/uitools.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -TARGET = $$qtLibraryTarget(QtUiTools) +TARGET = QtUiTools QT += xml CONFIG += qt staticlib DESTDIR = ../../../../lib @@ -35,7 +35,7 @@ INSTALLS += quitools_headers target.path=$$[QT_INSTALL_LIBS] INSTALLS += target -unix { +unix|win32-g++* { CONFIG += create_pc QMAKE_PKGCONFIG_LIBDIR = $$[QT_INSTALL_LIBS] QMAKE_PKGCONFIG_INCDIR = $$[QT_INSTALL_HEADERS]/$$TARGET @@ -43,3 +43,5 @@ unix { QMAKE_PKGCONFIG_DESTDIR = pkgconfig QMAKE_PKGCONFIG_REQUIRES += QtXml } + +TARGET = $$qtLibraryTarget($$TARGET$$QT_LIBINFIX) #do this towards the end diff --git a/tools/doxygen/config/footer.html b/tools/doxygen/config/footer.html index 8e99c72..d7e968d 100644 --- a/tools/doxygen/config/footer.html +++ b/tools/doxygen/config/footer.html @@ -1,6 +1,6 @@ <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> -<td width="30%">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies).</td> +<td width="30%">Copyright © 2011 Nokia Corporation and/or its subsidiary(-ies).</td> <td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="30%" align="right"><div align="right">Qt $projectnumber</div></td> </tr></table></div></address> diff --git a/tools/linguist/linguist/formpreviewview.cpp b/tools/linguist/linguist/formpreviewview.cpp index fc37cff..a2a6002 100644 --- a/tools/linguist/linguist/formpreviewview.cpp +++ b/tools/linguist/linguist/formpreviewview.cpp @@ -83,7 +83,7 @@ static bool operator==(const QUiTranslatableStringValue &tsv1, const QUiTranslat target.type = _type; \ target.target._target; \ target.prop._prop; \ - (*targets)[qVariantValue<QUiTranslatableStringValue>(_tsv)].append(target); \ + (*targets)[qvariant_cast<QUiTranslatableStringValue>(_tsv)].append(target); \ } while (0) static void registerTreeItem(QTreeWidgetItem *item, TargetsHash *targets) @@ -350,14 +350,14 @@ static void highlightAction(QAction *a, bool on) if (on) { if (!bak.isValid()) { QFont fnt = qApp->font(); - a->setProperty(FONT_BACKUP_PROP, qVariantFromValue(a->font().resolve(fnt))); + a->setProperty(FONT_BACKUP_PROP, QVariant::fromValue(a->font().resolve(fnt))); fnt.setBold(true); fnt.setItalic(true); a->setFont(fnt); } } else { if (bak.isValid()) { - a->setFont(qVariantValue<QFont>(bak)); + a->setFont(qvariant_cast<QFont>(bak)); a->setProperty(FONT_BACKUP_PROP, QVariant()); } } @@ -374,8 +374,8 @@ static void highlightWidget(QWidget *w, bool on) foreach (QObject *co, w->children()) if (QWidget *cw = qobject_cast<QWidget *>(co)) cw->setPalette(cw->palette().resolve(pal)); - w->setProperty(PALETTE_BACKUP_PROP, qVariantFromValue(w->palette().resolve(pal))); - w->setProperty(AUTOFILL_BACKUP_PROP, qVariantFromValue(w->autoFillBackground())); + w->setProperty(PALETTE_BACKUP_PROP, QVariant::fromValue(w->palette().resolve(pal))); + w->setProperty(AUTOFILL_BACKUP_PROP, QVariant::fromValue(w->autoFillBackground())); QColor col1 = pal.color(QPalette::Dark); QColor col2 = pal.color(QPalette::Light); pal.setColor(QPalette::Base, col1); @@ -390,8 +390,8 @@ static void highlightWidget(QWidget *w, bool on) } } else { if (bak.isValid()) { - w->setPalette(qVariantValue<QPalette>(bak)); - w->setAutoFillBackground(qVariantValue<bool>(w->property(AUTOFILL_BACKUP_PROP))); + w->setPalette(qvariant_cast<QPalette>(bak)); + w->setAutoFillBackground(qvariant_cast<bool>(w->property(AUTOFILL_BACKUP_PROP))); w->setProperty(PALETTE_BACKUP_PROP, QVariant()); w->setProperty(AUTOFILL_BACKUP_PROP, QVariant()); } @@ -463,6 +463,8 @@ FormPreviewView::FormPreviewView(QWidget *parent, MultiDataModel *dataModel) m_mdiArea = new QMdiArea(this); m_mdiArea->addSubWindow(m_mdiSubWindow); setCentralWidget(m_mdiArea); + m_mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + m_mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); } void FormPreviewView::setSourceContext(int model, MessageItem *messageItem) diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp index f4bc64d..e6fad1b 100644 --- a/tools/linguist/linguist/mainwindow.cpp +++ b/tools/linguist/linguist/mainwindow.cpp @@ -187,7 +187,7 @@ private: static const QVariant &pxObsolete() { static const QVariant v = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_obsolete.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_obsolete.png"))); return v; } diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp index 6afcf7e..2d12657 100644 --- a/tools/linguist/linguist/messagemodel.cpp +++ b/tools/linguist/linguist/messagemodel.cpp @@ -1238,17 +1238,17 @@ int MessageModel::columnCount(const QModelIndex &) const QVariant MessageModel::data(const QModelIndex &index, int role) const { static QVariant pxOn = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_on.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_on.png"))); static QVariant pxOff = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_off.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_off.png"))); static QVariant pxObsolete = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_obsolete.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_obsolete.png"))); static QVariant pxDanger = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_danger.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_danger.png"))); static QVariant pxWarning = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_warning.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_warning.png"))); static QVariant pxEmpty = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_empty.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_empty.png"))); int row = index.row(); int column = index.column() - 1; diff --git a/tools/linguist/lupdate/qdeclarative.cpp b/tools/linguist/lupdate/qdeclarative.cpp index 1c1e9ad..6bf9cf4 100644 --- a/tools/linguist/lupdate/qdeclarative.cpp +++ b/tools/linguist/lupdate/qdeclarative.cpp @@ -62,6 +62,7 @@ #include <iostream> #include <cstdlib> +#include <cctype> QT_BEGIN_NAMESPACE diff --git a/tools/linguist/lupdate/qscript.cpp b/tools/linguist/lupdate/qscript.cpp index 23fb9f6..e53c9dc 100644 --- a/tools/linguist/lupdate/qscript.cpp +++ b/tools/linguist/lupdate/qscript.cpp @@ -67,6 +67,8 @@ class LU { Q_DECLARE_TR_FUNCTIONS(LUpdate) }; +static QString MagicComment(QLatin1String("TRANSLATOR")); + class QScriptGrammar { public: @@ -2092,8 +2094,9 @@ public: ~QScriptParser(); void setLexer(QScript::Lexer *); + void setTranslator(Translator *); - bool parse(Translator *translator); + bool parse(); QString fileName() const { return lexer->fileName(); } @@ -2129,6 +2132,8 @@ protected: private: QScript::Lexer *lexer; + Translator *translator; + QString trcontext; QString extracomment; QString msgid; QString sourcetext; @@ -2160,7 +2165,8 @@ QScriptParser::QScriptParser(): sym_stack(0), state_stack(0), location_stack(0), - lexer(0) + lexer(0), + translator(0) { } @@ -2187,9 +2193,17 @@ void QScriptParser::setLexer(QScript::Lexer *lex) lexer = lex; } -bool QScriptParser::parse(Translator *translator) +void QScriptParser::setTranslator(Translator *tor) +{ + translator = tor; +} + +bool QScriptParser::parse() { Q_ASSERT(lexer != 0); + Q_ASSERT(translator != 0); + trcontext = QFileInfo(fileName()).baseName(); + const int INITIAL_STATE = 0; int yytoken = -1; @@ -2303,11 +2317,10 @@ case 66: { if (args.at(0).type() != QVariant::String) { yyMsg(identLineNo) << qPrintable(LU::tr("%1(): text to translate must be a literal string.\n").arg(name)); } else { - QString context = QFileInfo(fileName()).baseName(); QString text = args.at(0).toString(); QString comment = args.value(1).toString(); bool plural = (args.size() > 2); - recordMessage(translator, context, text, comment, extracomment, + recordMessage(translator, trcontext, text, comment, extracomment, msgid, extra, plural, fileName(), identLineNo); } } @@ -2533,6 +2546,32 @@ void QScriptParser::processComment(const QChar *chars, int length) } } sourcetext.resize(ptr - (ushort *)sourcetext.data()); + } else { + int idx = 0; + ushort c; + while ((c = chars[idx].unicode()) == ' ' || c == '\t' || c == '\n') + ++idx; + if (!memcmp(chars + idx, MagicComment.unicode(), MagicComment.length() * 2)) { + idx += MagicComment.length(); + QString comment = QString(chars + idx, length - idx).simplified(); + int k = comment.indexOf(QLatin1Char(' ')); + if (k == -1) { + trcontext = comment; + } else { + trcontext = comment.left(k); + comment.remove(0, k + 1); + TranslatorMessage msg( + trcontext, QString(), + comment, QString(), + fileName(), lexer->startLineNo(), QStringList(), + TranslatorMessage::Finished, /*plural=*/false); + msg.setExtraComment(extracomment.simplified()); + extracomment.clear(); + translator->append(msg); + translator->setExtras(extra); + extra.clear(); + } + } } } @@ -2558,7 +2597,8 @@ bool loadQScript(Translator &translator, const QString &filename, ConversionData QScript::Lexer lexer(&parser); lexer.setCode(code, filename, /*lineNumber=*/1); parser.setLexer(&lexer); - if (!parser.parse(&translator)) { + parser.setTranslator(&translator); + if (!parser.parse()) { 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 fb4eee7..b8b7b5f 100644 --- a/tools/linguist/lupdate/qscript.g +++ b/tools/linguist/lupdate/qscript.g @@ -104,6 +104,8 @@ class LU { Q_DECLARE_TR_FUNCTIONS(LUpdate) }; +static QString MagicComment(QLatin1String("TRANSLATOR")); + static void recordMessage( Translator *tor, const QString &context, const QString &text, const QString &comment, const QString &extracomment, const QString &msgid, const TranslatorMessage::ExtraData &extra, @@ -1423,8 +1425,9 @@ public: ~QScriptParser(); void setLexer(QScript::Lexer *); + void setTranslator(Translator *); - bool parse(Translator *translator); + bool parse(); QString fileName() const { return lexer->fileName(); } @@ -1460,6 +1463,8 @@ protected: private: QScript::Lexer *lexer; + Translator *translator; + QString trcontext; QString extracomment; QString msgid; QString sourcetext; @@ -1491,7 +1496,8 @@ QScriptParser::QScriptParser(): sym_stack(0), state_stack(0), location_stack(0), - lexer(0) + lexer(0), + translator(0) { } @@ -1518,9 +1524,17 @@ void QScriptParser::setLexer(QScript::Lexer *lex) lexer = lex; } -bool QScriptParser::parse(Translator *translator) +void QScriptParser::setTranslator(Translator *tor) +{ + translator = tor; +} + +bool QScriptParser::parse() { Q_ASSERT(lexer != 0); + Q_ASSERT(translator != 0); + trcontext = QFileInfo(fileName()).baseName(); + const int INITIAL_STATE = 0; int yytoken = -1; @@ -1719,11 +1733,10 @@ case $rule_number: { if (args.at(0).type() != QVariant::String) { yyMsg(identLineNo) << qPrintable(LU::tr("%1(): text to translate must be a literal string.\n").arg(name)); } else { - QString context = QFileInfo(fileName()).baseName(); QString text = args.at(0).toString(); QString comment = args.value(1).toString(); bool plural = (args.size() > 2); - recordMessage(translator, context, text, comment, extracomment, + recordMessage(translator, trcontext, text, comment, extracomment, msgid, extra, plural, fileName(), identLineNo); } } @@ -2181,6 +2194,32 @@ void QScriptParser::processComment(const QChar *chars, int length) } } sourcetext.resize(ptr - (ushort *)sourcetext.data()); + } else { + int idx = 0; + ushort c; + while ((c = chars[idx].unicode()) == ' ' || c == '\t' || c == '\n') + ++idx; + if (!memcmp(chars + idx, MagicComment.unicode(), MagicComment.length() * 2)) { + idx += MagicComment.length(); + QString comment = QString(chars + idx, length - idx).simplified(); + int k = comment.indexOf(QLatin1Char(' ')); + if (k == -1) { + trcontext = comment; + } else { + trcontext = comment.left(k); + comment.remove(0, k + 1); + TranslatorMessage msg( + trcontext, QString(), + comment, QString(), + fileName(), lexer->startLineNo(), QStringList(), + TranslatorMessage::Finished, /*plural=*/false); + msg.setExtraComment(extracomment.simplified()); + extracomment.clear(); + translator->append(msg); + translator->setExtras(extra); + extra.clear(); + } + } } } @@ -2206,7 +2245,8 @@ bool loadQScript(Translator &translator, const QString &filename, ConversionData QScript::Lexer lexer(&parser); lexer.setCode(code, filename, /*lineNumber=*/1); parser.setLexer(&lexer); - if (!parser.parse(&translator)) { + parser.setTranslator(&translator); + if (!parser.parse()) { std::cerr << qPrintable(filename) << ':' << parser.errorLineNumber() << ": " << qPrintable(parser.errorMessage()) << std::endl; return false; diff --git a/tools/macdeployqt/shared/shared.cpp b/tools/macdeployqt/shared/shared.cpp index 1a38236..36a080c 100644 --- a/tools/macdeployqt/shared/shared.cpp +++ b/tools/macdeployqt/shared/shared.cpp @@ -574,9 +574,13 @@ void createDiskImage(const QString &appBundlePath) } // More dmg options can be found in the hdiutil man page. - QString options = QString("create %1.dmg -srcfolder %1.app -format UDZO -volname %1").arg(appBaseName); + QStringList options = QStringList() + << "create" << dmgName + << "-srcfolder" << appBundlePath + << "-format" << "UDZO" + << "-volname" << appBaseName; QProcess hdutil; - hdutil.start("hdiutil", options.split(' ')); + hdutil.start("hdiutil", options); hdutil.waitForFinished(-1); } diff --git a/tools/makeqpf/mainwindow.cpp b/tools/makeqpf/mainwindow.cpp index 0209a47..249f49c 100644 --- a/tools/makeqpf/mainwindow.cpp +++ b/tools/makeqpf/mainwindow.cpp @@ -199,7 +199,7 @@ void MainWindow::on_generate_clicked() if (item->checkState() != Qt::Checked) continue; - QPF::CharacterRange range = qVariantValue<QPF::CharacterRange>(item->data(Qt::UserRole)); + QPF::CharacterRange range = qvariant_cast<QPF::CharacterRange>(item->data(Qt::UserRole)); ranges.append(range); } } @@ -297,7 +297,7 @@ void MainWindow::populateCharacterRanges() item->setText(text); item->setCheckState(Qt::Checked); - item->setData(Qt::UserRole, qVariantFromValue(range)); + item->setData(Qt::UserRole, QVariant::fromValue(range)); } } diff --git a/tools/qdbus/qdbus/qdbus.cpp b/tools/qdbus/qdbus/qdbus.cpp index 8e1c384..a3821a1 100644 --- a/tools/qdbus/qdbus/qdbus.cpp +++ b/tools/qdbus/qdbus/qdbus.cpp @@ -332,7 +332,7 @@ static int placeCall(const QString &service, const QString &path, const QString if (id == int(QMetaType::UChar)) { // special case: QVariant::convert doesn't convert to/from // UChar because it can't decide if it's a character or a number - p = qVariantFromValue<uchar>(p.toUInt()); + p = QVariant::fromValue<uchar>(p.toUInt()); } else if (id < int(QMetaType::User) && id != int(QVariant::Map)) { p.convert(QVariant::Type(id)); if (p.type() == QVariant::Invalid) { @@ -342,7 +342,7 @@ static int placeCall(const QString &service, const QString &path, const QString } } else if (id == qMetaTypeId<QDBusVariant>()) { QDBusVariant tmp(p); - p = qVariantFromValue(tmp); + p = QVariant::fromValue(tmp); } else if (id == qMetaTypeId<QDBusObjectPath>()) { QDBusObjectPath path(argument); if (path.path().isNull()) { @@ -350,7 +350,7 @@ static int placeCall(const QString &service, const QString &path, const QString qPrintable(argument)); return 1; } - p = qVariantFromValue(path); + p = QVariant::fromValue(path); } else if (id == qMetaTypeId<QDBusSignature>()) { QDBusSignature sig(argument); if (sig.signature().isNull()) { @@ -358,7 +358,7 @@ static int placeCall(const QString &service, const QString &path, const QString qPrintable(argument)); return 1; } - p = qVariantFromValue(sig); + p = QVariant::fromValue(sig); } else { fprintf(stderr, "Sorry, can't pass arg of type '%s'.\n", types.at(i).constData()); diff --git a/tools/qdbus/qdbusviewer/qdbusviewer.cpp b/tools/qdbus/qdbusviewer/qdbusviewer.cpp index 40ca561..cab1093 100644 --- a/tools/qdbus/qdbusviewer/qdbusviewer.cpp +++ b/tools/qdbus/qdbusviewer/qdbusviewer.cpp @@ -217,7 +217,7 @@ void QDBusViewer::setProperty(const BusSignature &sig) QDBusMessage message = QDBusMessage::createMethodCall(sig.mService, sig.mPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("Set")); QList<QVariant> arguments; - arguments << sig.mInterface << sig.mName << qVariantFromValue(QDBusVariant(value)); + arguments << sig.mInterface << sig.mName << QVariant::fromValue(QDBusVariant(value)); message.setArguments(arguments); c.callWithCallback(message, this, SLOT(dumpMessage(QDBusMessage))); @@ -283,7 +283,7 @@ void QDBusViewer::callMethod(const BusSignature &sig) // interface wants a variant for (int i = 0; i < args.count(); ++i) { if (types.at(i) == qMetaTypeId<QDBusVariant>()) - args[i] = qVariantFromValue(QDBusVariant(args.at(i))); + args[i] = QVariant::fromValue(QDBusVariant(args.at(i))); } QDBusMessage message = QDBusMessage::createMethodCall(sig.mService, sig.mPath, sig.mInterface, diff --git a/tools/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp b/tools/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp index 8ebf85e..cfe848e 100644 --- a/tools/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp +++ b/tools/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp @@ -617,7 +617,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf if (property.access != QDBusIntrospection::Property::Read) { hs << " inline void " << setter << "(" << constRefArg(type) << "value)" << endl << " { setProperty(\"" << property.name - << "\", qVariantFromValue(value)); }" << endl; + << "\", QVariant::fromValue(value)); }" << endl; } hs << endl; @@ -660,7 +660,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf if (!method.inputArgs.isEmpty()) { hs << " argumentList"; for (int argPos = 0; argPos < method.inputArgs.count(); ++argPos) - hs << " << qVariantFromValue(" << argNames.at(argPos) << ')'; + hs << " << QVariant::fromValue(" << argNames.at(argPos) << ')'; hs << ";" << endl; } @@ -693,7 +693,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf if (!method.inputArgs.isEmpty()) { hs << " argumentList"; for (argPos = 0; argPos < method.inputArgs.count(); ++argPos) - hs << " << qVariantFromValue(" << argNames.at(argPos) << ')'; + hs << " << QVariant::fromValue(" << argNames.at(argPos) << ')'; hs << ";" << endl; } @@ -940,7 +940,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte cs << "void " << className << "::" << setter << "(" << constRefType << "value)" << endl << "{" << endl << " // set the value of property " << property.name << endl - << " parent()->setProperty(\"" << property.name << "\", qVariantFromValue(value"; + << " parent()->setProperty(\"" << property.name << "\", QVariant::fromValue(value"; if (constRefType.contains(QLatin1String("QDBusVariant"))) cs << ".variant()"; cs << "));" << endl diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp index e27916b..c2cad89 100644 --- a/tools/qdoc3/cppcodemarker.cpp +++ b/tools/qdoc3/cppcodemarker.cpp @@ -49,6 +49,8 @@ #include "text.h" #include "tree.h" +#include <ctype.h> + QT_BEGIN_NAMESPACE /*! diff --git a/tools/qdoc3/jscodemarker.cpp b/tools/qdoc3/jscodemarker.cpp index cbf040f..55835be 100644 --- a/tools/qdoc3/jscodemarker.cpp +++ b/tools/qdoc3/jscodemarker.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tools/qdoc3/qmlcodemarker.cpp b/tools/qdoc3/qmlcodemarker.cpp index ccca7b5..29499af 100644 --- a/tools/qdoc3/qmlcodemarker.cpp +++ b/tools/qdoc3/qmlcodemarker.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tools/qdoc3/qmlcodeparser.cpp b/tools/qdoc3/qmlcodeparser.cpp index 45ca96f..9299053 100644 --- a/tools/qdoc3/qmlcodeparser.cpp +++ b/tools/qdoc3/qmlcodeparser.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tools/qdoc3/qmlmarkupvisitor.cpp b/tools/qdoc3/qmlmarkupvisitor.cpp index d88694b..6365c02 100644 --- a/tools/qdoc3/qmlmarkupvisitor.cpp +++ b/tools/qdoc3/qmlmarkupvisitor.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tools/qdoc3/qmlmarkupvisitor.h b/tools/qdoc3/qmlmarkupvisitor.h index 97e392f..14041a2 100644 --- a/tools/qdoc3/qmlmarkupvisitor.h +++ b/tools/qdoc3/qmlmarkupvisitor.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tools/qdoc3/qmlvisitor.cpp b/tools/qdoc3/qmlvisitor.cpp index fc65093..437bd57 100644 --- a/tools/qdoc3/qmlvisitor.cpp +++ b/tools/qdoc3/qmlvisitor.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tools/qdoc3/test/assistant.qdocconf b/tools/qdoc3/test/assistant.qdocconf index 4141a03..bb98db4 100644 --- a/tools/qdoc3/test/assistant.qdocconf +++ b/tools/qdoc3/test/assistant.qdocconf @@ -6,14 +6,14 @@ include(qt-defines.qdocconf) project = Qt Assistant description = Qt Assistant Manual -url = http://doc.qt.nokia.com/4.7/ +url = http://doc.qt.nokia.com/4.8/ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Assistant qhp.Assistant.file = assistant.qhp -qhp.Assistant.namespace = com.trolltech.assistant.474 +qhp.Assistant.namespace = com.trolltech.assistant.480 qhp.Assistant.virtualFolder = qdoc qhp.Assistant.indexTitle = Qt Assistant Manual qhp.Assistant.extraFiles = images/bg_l.png \ @@ -50,7 +50,7 @@ qhp.Assistant.extraFiles = images/bg_l.png \ style/style_ie8.css \ style/style.css -qhp.Assistant.filterAttributes = qt 4.7.4 tools assistant +qhp.Assistant.filterAttributes = qt 4.8.0 tools assistant qhp.Assistant.customFilters.Assistant.name = Qt Assistant Manual qhp.Assistant.customFilters.Assistant.filterAttributes = qt tools assistant qhp.Assistant.subprojects = manual examples diff --git a/tools/qdoc3/test/carbide-eclipse-integration.qdocconf b/tools/qdoc3/test/carbide-eclipse-integration.qdocconf index 4d43403..ff50ce6 100644 --- a/tools/qdoc3/test/carbide-eclipse-integration.qdocconf +++ b/tools/qdoc3/test/carbide-eclipse-integration.qdocconf @@ -6,7 +6,7 @@ macro.TheEclipseIntegration = Carbide.c++ HTML.footer = "<p /><address><hr /><div align=\"center\">\n" \ "<table width=\"100%\" cellspacing=\"0\" border=\"0\"><tr class=\"address\">\n" \ - "<td width=\"30%\" align=\"left\">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \ + "<td width=\"30%\" align=\"left\">Copyright © 2011 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \ "<td width=\"40%\" align=\"center\"><a href=\"http://qt.nokia.com/doc\">Trademarks</a></td>\n" \ "<td width=\"30%\" align=\"right\"><div align=\"right\">Carbide.c++</div></td>\n" \ "</tr></table></div></address>" diff --git a/tools/qdoc3/test/designer.qdocconf b/tools/qdoc3/test/designer.qdocconf index 6c98ddf..f59fdf0 100644 --- a/tools/qdoc3/test/designer.qdocconf +++ b/tools/qdoc3/test/designer.qdocconf @@ -6,14 +6,14 @@ include(qt-defines.qdocconf) project = Qt Designer description = Qt Designer Manual -url = http://doc.qt.nokia.com/4.7/ +url = http://doc.qt.nokia.com/4.8/ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Designer qhp.Designer.file = designer.qhp -qhp.Designer.namespace = com.trolltech.designer.474 +qhp.Designer.namespace = com.trolltech.designer.480 qhp.Designer.virtualFolder = qdoc qhp.Designer.indexTitle = Qt Designer Manual qhp.Designer.extraFiles = images/bg_l.png \ @@ -50,7 +50,7 @@ qhp.Designer.extraFiles = images/bg_l.png \ style/style_ie8.css \ style/style.css -qhp.Designer.filterAttributes = qt 4.7.4 tools designer +qhp.Designer.filterAttributes = qt 4.8.0 tools designer qhp.Designer.customFilters.Designer.name = Qt Designer Manual qhp.Designer.customFilters.Designer.filterAttributes = qt tools designer qhp.Designer.subprojects = manual examples diff --git a/tools/qdoc3/test/jambi.qdocconf b/tools/qdoc3/test/jambi.qdocconf index aa87826..3f4b42d 100644 --- a/tools/qdoc3/test/jambi.qdocconf +++ b/tools/qdoc3/test/jambi.qdocconf @@ -42,7 +42,7 @@ HTML.postheader = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0 HTML.footer = "<p /><address><hr /><div align=\"center\">\n" \ "<table width=\"100%\" cellspacing=\"0\" border=\"0\"><tr class=\"address\">\n" \ - "<td width=\"30%\" align=\"left\">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \ + "<td width=\"30%\" align=\"left\">Copyright © 2011 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \ "<td width=\"40%\" align=\"center\"><a href=\"trademarks.html\">Trademarks</a></td>\n" \ "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt Jambi \\version</div></td>\n" \ "</tr></table></div></address>" diff --git a/tools/qdoc3/test/linguist.qdocconf b/tools/qdoc3/test/linguist.qdocconf index c9d6751..7c4b938 100644 --- a/tools/qdoc3/test/linguist.qdocconf +++ b/tools/qdoc3/test/linguist.qdocconf @@ -6,14 +6,14 @@ include(qt-defines.qdocconf) project = Qt Linguist description = Qt Linguist Manual -url = http://doc.qt.nokia.com/4.7/ +url = http://doc.qt.nokia.com/4.8/ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Linguist qhp.Linguist.file = linguist.qhp -qhp.Linguist.namespace = com.trolltech.linguist.474 +qhp.Linguist.namespace = com.trolltech.linguist.480 qhp.Linguist.virtualFolder = qdoc qhp.Linguist.indexTitle = Qt Linguist Manual qhp.Linguist.extraFiles = images/bg_l.png \ @@ -50,7 +50,7 @@ qhp.Linguist.extraFiles = images/bg_l.png \ style/style_ie8.css \ style/style.css -qhp.Linguist.filterAttributes = qt 4.7.4 tools linguist +qhp.Linguist.filterAttributes = qt 4.8.0 tools linguist qhp.Linguist.customFilters.Linguist.name = Qt Linguist Manual qhp.Linguist.customFilters.Linguist.filterAttributes = qt tools linguist qhp.Linguist.subprojects = manual examples diff --git a/tools/qdoc3/test/qdeclarative.qdocconf b/tools/qdoc3/test/qdeclarative.qdocconf index 8fe9034..4abe40c 100644 --- a/tools/qdoc3/test/qdeclarative.qdocconf +++ b/tools/qdoc3/test/qdeclarative.qdocconf @@ -21,7 +21,7 @@ edition.DesktopLight.groups = -graphicsview-api qhp.projects = Qml qhp.Qml.file = qml.qhp -qhp.Qml.namespace = com.trolltech.qml.474 +qhp.Qml.namespace = com.trolltech.qml.480 qhp.Qml.virtualFolder = qdoc qhp.Qml.indexTitle = Qml Reference @@ -61,9 +61,9 @@ qhp.Qml.extraFiles = images/bg_l.png \ style/style_ie8.css \ style/style.css -qhp.Qml.filterAttributes = qt 4.7.4 qtrefdoc -qhp.Qml.customFilters.Qt.name = Qt 4.7.4 -qhp.Qml.customFilters.Qt.filterAttributes = qt 4.7.4 +qhp.Qml.filterAttributes = qt 4.8.0 qtrefdoc +qhp.Qml.customFilters.Qt.name = Qt 4.8.0 +qhp.Qml.customFilters.Qt.filterAttributes = qt 4.8.0 qhp.Qml.subprojects = classes qhp.Qml.subprojects.classes.title = Elements qhp.Qml.subprojects.classes.indexTitle = Qml Elements diff --git a/tools/qdoc3/test/qmake.qdocconf b/tools/qdoc3/test/qmake.qdocconf index c5a0f40..56e7f96 100644 --- a/tools/qdoc3/test/qmake.qdocconf +++ b/tools/qdoc3/test/qmake.qdocconf @@ -6,14 +6,14 @@ include(qt-defines.qdocconf) project = QMake description = QMake Manual -url = http://qt.nokia.com/doc/4.7 +url = http://qt.nokia.com/doc/4.8 indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = qmake qhp.qmake.file = qmake.qhp -qhp.qmake.namespace = com.trolltech.qmake.474 +qhp.qmake.namespace = com.trolltech.qmake.480 qhp.qmake.virtualFolder = qdoc qhp.qmake.indexTitle = QMake Manual qhp.qmake.extraFiles = images/bg_l.png \ @@ -50,7 +50,7 @@ qhp.qmake.extraFiles = images/bg_l.png \ style/style_ie8.css \ style/style.css -qhp.qmake.filterAttributes = qt 4.7.4 tools qmake +qhp.qmake.filterAttributes = qt 4.8.0 tools qmake qhp.qmake.customFilters.qmake.name = qmake Manual qhp.qmake.customFilters.qmake.filterAttributes = qt tools qmake qhp.qmake.subprojects = manual diff --git a/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf b/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf index a14054c..06cc9a0 100644 --- a/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf +++ b/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf @@ -17,15 +17,15 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Qt qhp.Qt.file = qt.qhp -qhp.Qt.namespace = com.trolltech.qt.474 +qhp.Qt.namespace = com.trolltech.qt.480 qhp.Qt.virtualFolder = qdoc qhp.Qt.title = Qt qhp.Qt.indexTitle = Qt qhp.Qt.selectors = fake:example -qhp.Qt.filterAttributes = qt 4.7.4 qtrefdoc ja_JP -qhp.Qt.customFilters.Qt.name = Qt 4.7.4 -qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.4 +qhp.Qt.filterAttributes = qt 4.8.0 qtrefdoc ja_JP +qhp.Qt.customFilters.Qt.name = Qt 4.8.0 +qhp.Qt.customFilters.Qt.filterAttributes = qt 4.8.0 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML diff --git a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf index d4d43b8..1efda05 100644 --- a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf @@ -6,7 +6,7 @@ include(qt-defines.qdocconf) project = Qt description = Qt Reference Documentation -url = http://qt.nokia.com/doc/zh_CN/4.7 +url = http://qt.nokia.com/doc/zh_CN/4.8 sourceencoding = UTF-8 outputencoding = UTF-8 @@ -17,15 +17,15 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Qt qhp.Qt.file = qt.qhp -qhp.Qt.namespace = com.trolltech.qt.474 +qhp.Qt.namespace = com.trolltech.qt.480 qhp.Qt.virtualFolder = qdoc qhp.Qt.title = 教程 qhp.Qt.indexTitle = 教程 qhp.Qt.selectors = fake:example -qhp.Qt.filterAttributes = qt 4.7.4 qtrefdoc zh_CN -qhp.Qt.customFilters.Qt.name = Qt 4.7.4 -qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.4 +qhp.Qt.filterAttributes = qt 4.8.0 qtrefdoc zh_CN +qhp.Qt.customFilters.Qt.name = Qt 4.8.0 +qhp.Qt.customFilters.Qt.filterAttributes = qt 4.8.0 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML diff --git a/tools/qdoc3/test/qt-html-templates_ja_JP-online.qdocconf b/tools/qdoc3/test/qt-html-templates_ja_JP-online.qdocconf index fa15d90..a69d7a1 100644 --- a/tools/qdoc3/test/qt-html-templates_ja_JP-online.qdocconf +++ b/tools/qdoc3/test/qt-html-templates_ja_JP-online.qdocconf @@ -149,7 +149,7 @@ HTML.footer = \ " </div> \n" \ " <div class=\"footer\">\n" \ " <p>\n" \ - " <acronym title=\"Copyright\">©</acronym> 2008-2010 Nokia Corporation and/or its\n" \ + " <acronym title=\"Copyright\">©</acronym> 2008-2011 Nokia Corporation and/or its\n" \ " subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation \n" \ " in Finland and/or other countries worldwide.</p>\n" \ " <p>\n" \ diff --git a/tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf b/tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf index 18ed5c1..74a4d14 100644 --- a/tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf +++ b/tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf @@ -36,7 +36,7 @@ HTML.footer = \ " </div> \n" \ " <div class=\"footer\">\n" \ " <p>\n" \ - " <acronym title=\"Copyright\">©</acronym> 2008-2010 Nokia Corporation and/or its\n" \ + " <acronym title=\"Copyright\">©</acronym> 2008-2011 Nokia Corporation and/or its\n" \ " subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation \n" \ " in Finland and/or other countries worldwide.</p>\n" \ " <p>\n" \ diff --git a/tools/qdoc3/test/qt-html-templates_zh_CN-online.qdocconf b/tools/qdoc3/test/qt-html-templates_zh_CN-online.qdocconf index 285ec27..ed2162e 100644 --- a/tools/qdoc3/test/qt-html-templates_zh_CN-online.qdocconf +++ b/tools/qdoc3/test/qt-html-templates_zh_CN-online.qdocconf @@ -149,7 +149,7 @@ HTML.footer = \ " </div> \n" \ " <div class=\"footer\">\n" \ " <p>\n" \ - " <acronym title=\"Copyright\">©</acronym> 2008-2010 Nokia Corporation and/or its\n" \ + " <acronym title=\"Copyright\">©</acronym> 2008-2011 Nokia Corporation and/or its\n" \ " subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation \n" \ " in Finland and/or other countries worldwide.</p>\n" \ " <p>\n" \ diff --git a/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf b/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf index 7773aa6..b4c8f7b 100644 --- a/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf @@ -24,7 +24,7 @@ HTML.postheader = \ " </div>\n" \ " <div id=\"shortCut\">\n" \ " <ul>\n" \ - " <li class=\"shortCut-topleft-inactive\"><span><a href=\"index.html\">Qt 4.7</a></span></li>\n" \ + " <li class=\"shortCut-topleft-inactive\"><span><a href=\"index.html\">Qt 4.8</a></span></li>\n" \ " <li class=\"shortCut-topleft-active\"><a href=\"http://qt.nokia.com/doc/\">ALL VERSIONS" \ " </a></li>\n" \ " </ul>\n" \ @@ -149,7 +149,7 @@ HTML.footer = \ " </div> \n" \ " <div class=\"footer\">\n" \ " <p>\n" \ - " <acronym title=\"Copyright\">©</acronym> 2008-2010 Nokia Corporation and/or its\n" \ + " <acronym title=\"Copyright\">©</acronym> 2008-2011 Nokia Corporation and/or its\n" \ " subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation \n" \ " in Finland and/or other countries worldwide.</p>\n" \ " <p>\n" \ diff --git a/tools/qdoc3/test/qt-project.qdocconf b/tools/qdoc3/test/qt-project.qdocconf index 9c18608..d03dfd2 100644 --- a/tools/qdoc3/test/qt-project.qdocconf +++ b/tools/qdoc3/test/qt-project.qdocconf @@ -15,14 +15,14 @@ naturallanguage = en_US qhp.projects = Qt qhp.Qt.file = qt.qhp -qhp.Qt.namespace = com.trolltech.qt.474 +qhp.Qt.namespace = com.trolltech.qt.473 qhp.Qt.virtualFolder = qdoc qhp.Qt.indexTitle = Qt Reference Documentation qhp.Qt.indexRoot = -qhp.Qt.filterAttributes = qt 4.7.4 qtrefdoc -qhp.Qt.customFilters.Qt.name = Qt 4.7.4 -qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.4 +qhp.Qt.filterAttributes = qt 4.7.3 qtrefdoc +qhp.Qt.customFilters.Qt.name = Qt 4.7.3 +qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.3 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/test/standalone-eclipse-integration.qdocconf b/tools/qdoc3/test/standalone-eclipse-integration.qdocconf index 96c2c98..850a2db 100644 --- a/tools/qdoc3/test/standalone-eclipse-integration.qdocconf +++ b/tools/qdoc3/test/standalone-eclipse-integration.qdocconf @@ -5,7 +5,7 @@ macro.TheEclipseIntegration = The Qt Eclipse Integration HTML.footer = "<p /><address><hr /><div align=\"center\">\n" \ "<table width=\"100%\" cellspacing=\"0\" border=\"0\"><tr class=\"address\">\n" \ - "<td width=\"30%\" align=\"left\">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \ + "<td width=\"30%\" align=\"left\">Copyright © 2011 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \ "<td width=\"40%\" align=\"center\"><a href=\"http://qt.nokia.com/doc/trademarks.html\">Trademarks</a></td>\n" \ "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt Eclipse Integration 1.5.3</div></td>\n" \ "</tr></table></div></address>" diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp index eec6578..fb4e9f5 100644 --- a/tools/qdoc3/tree.cpp +++ b/tools/qdoc3/tree.cpp @@ -1544,8 +1544,72 @@ bool Tree::generateIndexSection(QXmlStreamWriter &writer, return true; } + /*! - */ + Returns true if the node \a n1 is less than node \a n2. + The comparison is performed by comparing properties of the nodes in order + of increasing complexity. +*/ +bool compareNodes(const Node *n1, const Node *n2) +{ + // Private nodes can occur in any order since they won't normally be + // written to the index. + if (n1->access() == Node::Private && n2->access() == Node::Private) + return true; + + if (n1->location().filePath() < n2->location().filePath()) + return true; + else if (n1->location().filePath() > n2->location().filePath()) + return false; + + if (n1->type() < n2->type()) + return true; + else if (n1->type() > n2->type()) + return false; + + if (n1->name() < n2->name()) + return true; + else if (n1->name() > n2->name()) + return false; + + if (n1->access() < n2->access()) + return true; + else if (n1->access() > n2->access()) + return false; + + if (n1->type() == Node::Function && n2->type() == Node::Function) { + const FunctionNode *f1 = static_cast<const FunctionNode *>(n1); + const FunctionNode *f2 = static_cast<const FunctionNode *>(n2); + + if (f1->isConst() < f2->isConst()) + return true; + else if (f1->isConst() > f2->isConst()) + return false; + + if (f1->signature() < f2->signature()) + return true; + else if (f1->signature() > f2->signature()) + return false; + } + + if (n1->type() == Node::Fake && n2->type() == Node::Fake) { + const FakeNode *f1 = static_cast<const FakeNode *>(n1); + const FakeNode *f2 = static_cast<const FakeNode *>(n2); + if (f1->fullTitle() < f2->fullTitle()) + return true; + else if (f1->fullTitle() > f2->fullTitle()) + return false; + } + + return false; +} + +/*! + Generate index sections for the child nodes of the given \a node + using the \a writer specified. If \a generateInternalNodes is true, + nodes marked as internal will be included in the index; otherwise, + they will be omitted. +*/ void Tree::generateIndexSections(QXmlStreamWriter &writer, const Node *node, bool generateInternalNodes) const @@ -1555,7 +1619,10 @@ void Tree::generateIndexSections(QXmlStreamWriter &writer, if (node->isInnerNode()) { const InnerNode *inner = static_cast<const InnerNode *>(node); - foreach (const Node *child, inner->childNodes()) { + NodeList cnodes = inner->childNodes(); + qSort(cnodes.begin(), cnodes.end(), compareNodes); + + foreach (const Node *child, cnodes) { /* Don't generate anything for a QML property group node. It is just a place holder for a collection of QML property diff --git a/tools/qml/texteditautoresizer_maemo5.h b/tools/qml/texteditautoresizer_maemo5.h index e82d006..71dbce0 100644 --- a/tools/qml/texteditautoresizer_maemo5.h +++ b/tools/qml/texteditautoresizer_maemo5.h @@ -41,7 +41,7 @@ #include <QtGui/qplaintextedit.h> #include <QtGui/qtextedit.h> -#include <QtGui/qabstractkineticscroller.h> +#include <QtGui/qscroller.h> #include <QtGui/qscrollarea.h> #include <QtDebug> @@ -102,11 +102,11 @@ void TextEditAutoResizer::textEditChanged() QPoint scrollto = area->widget()->mapFrom(edit, cursor.center()); QPoint margin(10 + cursor.width(), 2 * cursor.height()); - if (QAbstractKineticScroller *scroller = area->property("kineticScroller").value<QAbstractKineticScroller *>()) { - scroller->ensureVisible(scrollto, margin.x(), margin.y()); - } else { - area->ensureVisible(scrollto.x(), scrollto.y(), margin.x(), margin.y()); - } +#ifdef Q_WS_MAEMO_5 + QScroller::scroller(area)->ensureVisible(scrollto, margin.x(), margin.y()); +#else + area->ensureVisible(scrollto.x(), scrollto.y(), margin.x(), margin.y()); +#endif } } diff --git a/tools/qtconfig/colorbutton.cpp b/tools/qtconfig/colorbutton.cpp index 1a98897..33c1b25 100644 --- a/tools/qtconfig/colorbutton.cpp +++ b/tools/qtconfig/colorbutton.cpp @@ -52,19 +52,20 @@ QT_BEGIN_NAMESPACE ColorButton::ColorButton(QWidget *parent) - : QAbstractButton(parent), mousepressed(false) + : QAbstractButton(parent) + , col(Qt::black) + , mousepressed(false) { setAcceptDrops(true); - col = Qt::black; connect(this, SIGNAL(clicked()), SLOT(changeColor())); } ColorButton::ColorButton(const QColor &c, QWidget *parent) : QAbstractButton(parent) + , col(c) { setAcceptDrops(true); - col = c; connect(this, SIGNAL(clicked()), SLOT(changeColor())); } @@ -182,7 +183,7 @@ void ColorButton::mouseReleaseEvent(QMouseEvent *e) void ColorButton::mouseMoveEvent(QMouseEvent *e) { - if (! mousepressed) + if (!mousepressed) return; if ((presspos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { diff --git a/tools/qtconfig/main.cpp b/tools/qtconfig/main.cpp index 3c17511..38435d9 100644 --- a/tools/qtconfig/main.cpp +++ b/tools/qtconfig/main.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include "ui_previewwidgetbase.h" #include "mainwindow.h" #include <QApplication> #include <QLibraryInfo> diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index a7c37f7..059adb3 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -40,6 +40,8 @@ ****************************************************************************/ #include "mainwindow.h" +#include "ui_mainwindow.h" + #include "colorbutton.h" #include "previewframe.h" #include "paletteeditoradvanced.h" @@ -59,10 +61,10 @@ #include <QMessageBox> #include <QStyle> #include <QtEvents> -#include <Q3ValueList> #include <QInputContext> #include <QInputContextFactory> #include <QtDebug> +#include <QPixmap> #include <stdlib.h> @@ -154,36 +156,20 @@ static const char *phonon_text = QT_TRANSLATE_NOOP("MainWindow", "<p>It is reccommended to leave all settings on \"Auto\" to let " "Phonon determine your settings automatically."); -static QColorGroup::ColorRole centralFromItem( int item ) -{ - switch( item ) { - case 0: return QColorGroup::Window; - case 1: return QColorGroup::WindowText; - case 2: return QColorGroup::Button; - case 3: return QColorGroup::Base; - case 4: return QColorGroup::Text; - case 5: return QColorGroup::BrightText; - case 6: return QColorGroup::ButtonText; - case 7: return QColorGroup::Highlight; - case 8: return QColorGroup::HighlightedText; - default: return QColorGroup::NColorRoles; - } -} - -static QColorGroup::ColorRole effectFromItem( int item ) +QPalette::ColorGroup MainWindow::groupFromIndex(int item) { - switch( item ) { - case 0: return QColorGroup::Light; - case 1: return QColorGroup::Midlight; - case 2: return QColorGroup::Mid; - case 3: return QColorGroup::Dark; - case 4: return QColorGroup::Shadow; - default: return QColorGroup::NColorRoles; + switch (item) { + case 0: + default: + return QPalette::Active; + case 1: + return QPalette::Inactive; + case 2: + return QPalette::Disabled; } } - static void setStyleHelper(QWidget *w, QStyle *s) { const QObjectList children = w->children(); @@ -195,99 +181,141 @@ static void setStyleHelper(QWidget *w, QStyle *s) w->setStyle(s); } - MainWindow::MainWindow() - : MainWindowBase(0, "main window"), - editPalette(palette()), previewPalette(palette()), previewstyle(0) -{ + : ui(new Ui::MainWindow), + editPalette(palette()), + previewPalette(palette()), + previewstyle(0) +{ + ui->setupUi(this); + statusBar(); + + // signals and slots connections + connect(ui->fontPathLineEdit, SIGNAL(returnPressed()), SLOT(addFontpath())); + connect(ui->addFontPathButton, SIGNAL(clicked()), SLOT(addFontpath())); + connect(ui->addSubstitutionButton, SIGNAL(clicked()), SLOT(addSubstitute())); + connect(ui->browseFontPathButton, SIGNAL(clicked()), SLOT(browseFontpath())); + connect(ui->fontStyleCombo, SIGNAL(activated(int)), SLOT(buildFont())); + connect(ui->pointSizeCombo, SIGNAL(activated(int)), SLOT(buildFont())); + connect(ui->downFontpathButton, SIGNAL(clicked()), SLOT(downFontpath())); + connect(ui->downSubstitutionButton, SIGNAL(clicked()), SLOT(downSubstitute())); + connect(ui->fontFamilyCombo, SIGNAL(activated(QString)), SLOT(familySelected(QString))); + connect(ui->fileExitAction, SIGNAL(triggered()), SLOT(fileExit())); + connect(ui->fileSaveAction, SIGNAL(triggered()), SLOT(fileSave())); + connect(ui->helpAboutAction, SIGNAL(triggered()), SLOT(helpAbout())); + connect(ui->helpAboutQtAction, SIGNAL(triggered()), SLOT(helpAboutQt())); + connect(ui->mainTabWidget, SIGNAL(currentChanged(int)), SLOT(pageChanged(int))); + connect(ui->paletteCombo, SIGNAL(activated(int)), SLOT(paletteSelected(int))); + connect(ui->removeFontpathButton, SIGNAL(clicked()), SLOT(removeFontpath())); + connect(ui->removeSubstitutionButton, SIGNAL(clicked()), SLOT(removeSubstitute())); + connect(ui->toolBoxEffectCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->doubleClickIntervalSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->cursorFlashTimeSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->wheelScrollLinesSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->menuEffectCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->comboEffectCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->audiosinkCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->videomodeCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->toolTipEffectCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->strutWidthSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->strutHeightSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->effectsCheckBox, SIGNAL(toggled(bool)), SLOT(somethingModified())); + connect(ui->resolveLinksCheckBox, SIGNAL(toggled(bool)), SLOT(somethingModified())); + connect(ui->fontEmbeddingCheckBox, SIGNAL(clicked()), SLOT(somethingModified())); + connect(ui->rtlExtensionsCheckBox, SIGNAL(toggled(bool)), SLOT(somethingModified())); + connect(ui->inputStyleCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->inputMethodCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->guiStyleCombo, SIGNAL(activated(QString)), SLOT(styleSelected(QString))); + connect(ui->familySubstitutionCombo, SIGNAL(activated(QString)), SLOT(substituteSelected(QString))); + connect(ui->tunePaletteButton, SIGNAL(clicked()), SLOT(tunePalette())); + connect(ui->upFontpathButton, SIGNAL(clicked()), SLOT(upFontpath())); + connect(ui->upSubstitutionButton, SIGNAL(clicked()), SLOT(upSubstitute())); + modified = true; desktopThemeName = tr("Desktop Settings (Default)"); + setWindowIcon(QPixmap(":/trolltech/qtconfig/images/appicon.png")); QStringList gstyles = QStyleFactory::keys(); gstyles.sort(); - gstylecombo->addItem(desktopThemeName); - gstylecombo->setItemData(gstylecombo->findText(desktopThemeName), - tr("Choose style and palette based on your desktop settings."), Qt::ToolTipRole); - gstylecombo->insertStringList(gstyles); + ui->guiStyleCombo->addItem(desktopThemeName); + ui->guiStyleCombo->setItemData(ui->guiStyleCombo->findText(desktopThemeName), + tr("Choose style and palette based on your desktop settings."), + Qt::ToolTipRole); + ui->guiStyleCombo->addItems(gstyles); QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); QString currentstyle = settings.value(QLatin1String("style")).toString(); if (currentstyle.isEmpty()) { - gstylecombo->setCurrentItem(gstylecombo->findText(desktopThemeName)); - currentstyle = QLatin1String(QApplication::style()->name()); + ui->guiStyleCombo->setCurrentIndex(ui->guiStyleCombo->findText(desktopThemeName)); + currentstyle = QApplication::style()->objectName(); } else { - int index = gstylecombo->findText(currentstyle, Qt::MatchFixedString); + int index = ui->guiStyleCombo->findText(currentstyle, Qt::MatchFixedString); if (index != -1) { - gstylecombo->setCurrentItem(index); + ui->guiStyleCombo->setCurrentIndex(index); } else { // we give up - gstylecombo->insertItem(QLatin1String("Unknown")); - gstylecombo->setCurrentItem(gstylecombo->count() - 1); + ui->guiStyleCombo->addItem(tr("Unknown")); + ui->guiStyleCombo->setCurrentIndex(ui->guiStyleCombo->count() - 1); } } - buttonMainColor->setColor(palette().color(QPalette::Active, - QColorGroup::Button)); - buttonMainColor2->setColor(palette().color(QPalette::Active, - QColorGroup::Window)); - connect(buttonMainColor, SIGNAL(colorChanged(QColor)), - this, SLOT(buildPalette())); - connect(buttonMainColor2, SIGNAL(colorChanged(QColor)), - this, SLOT(buildPalette())); + ui->buttonMainColor->setColor(palette().color(QPalette::Active, QPalette::Button)); + ui->buttonWindowColor->setColor(palette().color(QPalette::Active, QPalette::Window)); + connect(ui->buttonMainColor, SIGNAL(colorChanged(QColor)), SLOT(buildPalette())); + connect(ui->buttonWindowColor, SIGNAL(colorChanged(QColor)), SLOT(buildPalette())); if (X11->desktopEnvironment == DE_KDE) - colorConfig->hide(); + ui->colorConfig->hide(); else - labelKDENote->hide(); + ui->kdeNoteLabel->hide(); QFontDatabase db; QStringList families = db.families(); - familycombo->insertStringList(families); + ui->fontFamilyCombo->addItems(families); QStringList fs = families; QStringList fs2 = QFont::substitutions(); QStringList::Iterator fsit = fs2.begin(); while (fsit != fs2.end()) { - if (! fs.contains(*fsit)) + if (!fs.contains(*fsit)) fs += *fsit; fsit++; } fs.sort(); - familysubcombo->insertStringList(fs); + ui->familySubstitutionCombo->addItems(fs); - choosesubcombo->insertStringList(families); - Q3ValueList<int> sizes = db.standardSizes(); - Q3ValueList<int>::Iterator it = sizes.begin(); - while (it != sizes.end()) - psizecombo->insertItem(QString::number(*it++)); + ui->chooseSubstitutionCombo->addItems(families); + QList<int> sizes = db.standardSizes(); + foreach(int i, sizes) + ui->pointSizeCombo->addItem(QString::number(i)); - dcispin->setValue(QApplication::doubleClickInterval()); - cfispin->setValue(QApplication::cursorFlashTime()); - wslspin->setValue(QApplication::wheelScrollLines()); + ui->doubleClickIntervalSpinBox->setValue(QApplication::doubleClickInterval()); + ui->cursorFlashTimeSpinBox->setValue(QApplication::cursorFlashTime()); + ui->wheelScrollLinesSpinBox->setValue(QApplication::wheelScrollLines()); // ############# -// resolvelinks->setChecked(qt_resolve_symlinks); + // resolveLinksCheckBox->setChecked(qt_resolve_symlinks); - effectcheckbox->setChecked(QApplication::isEffectEnabled(Qt::UI_General)); - effectbase->setEnabled(effectcheckbox->isChecked()); + ui->effectsCheckBox->setChecked(QApplication::isEffectEnabled(Qt::UI_General)); + ui->effectsFrame->setEnabled(ui->effectsCheckBox->isChecked()); if (QApplication::isEffectEnabled(Qt::UI_FadeMenu)) - menueffect->setCurrentItem(2); + ui->menuEffectCombo->setCurrentIndex(2); else if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) - menueffect->setCurrentItem(1); + ui->menuEffectCombo->setCurrentIndex(1); if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo)) - comboeffect->setCurrentItem(1); + ui->comboEffectCombo->setCurrentIndex(1); if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)) - tooltipeffect->setCurrentItem(2); + ui->toolTipEffectCombo->setCurrentIndex(2); else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip)) - tooltipeffect->setCurrentItem(1); + ui->toolTipEffectCombo->setCurrentIndex(1); - if ( QApplication::isEffectEnabled( Qt::UI_AnimateToolBox ) ) - toolboxeffect->setCurrentItem( 1 ); + if (QApplication::isEffectEnabled(Qt::UI_AnimateToolBox)) + ui->toolBoxEffectCombo->setCurrentIndex(1); QSize globalStrut = QApplication::globalStrut(); - strutwidth->setValue(globalStrut.width()); - strutheight->setValue(globalStrut.height()); + ui->strutWidthSpinBox->setValue(globalStrut.width()); + ui->strutHeightSpinBox->setValue(globalStrut.height()); // find the default family QStringList::Iterator sit = families.begin(); @@ -306,10 +334,10 @@ MainWindow::MainWindow() if (i == -1) // no clue about the current font i = 0; - familycombo->setCurrentItem(i); + ui->fontFamilyCombo->setCurrentIndex(i); - QStringList styles = db.styles(familycombo->currentText()); - stylecombo->insertStringList(styles); + QStringList styles = db.styles(ui->fontFamilyCombo->currentText()); + ui->fontStyleCombo->addItems(styles); QString stylestring = db.styleString(QApplication::font()); sit = styles.begin(); @@ -328,91 +356,98 @@ MainWindow::MainWindow() i = possible; if (i == -1) // no clue about the current font i = 0; - stylecombo->setCurrentItem(i); + ui->fontStyleCombo->setCurrentIndex(i); i = 0; - for (int psize = QApplication::font().pointSize(); i < psizecombo->count(); ++i) { - const int sz = psizecombo->text(i).toInt(); + for (int psize = QApplication::font().pointSize(); i < ui->pointSizeCombo->count(); ++i) { + const int sz = ui->pointSizeCombo->itemText(i).toInt(); if (sz == psize) { - psizecombo->setCurrentItem(i); + ui->pointSizeCombo->setCurrentIndex(i); break; } else if(sz > psize) { - psizecombo->insertItem(i, QString::number(psize)); - psizecombo->setCurrentItem(i); + ui->pointSizeCombo->insertItem(i, QString::number(psize)); + ui->pointSizeCombo->setCurrentIndex(i); break; } } - QStringList subs = QFont::substitutes(familysubcombo->currentText()); - sublistbox->clear(); - sublistbox->insertStringList(subs); + QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); - rtlExtensions->setChecked(settings.value(QLatin1String("useRtlExtensions"), false).toBool()); + ui->rtlExtensionsCheckBox->setChecked(settings.value(QLatin1String("useRtlExtensions"), false) + .toBool()); #ifdef Q_WS_X11 - inputStyle->setCurrentText(settings.value(QLatin1String("XIMInputStyle"), trUtf8("On The Spot")).toString()); + QString settingsInputStyle = settings.value(QLatin1String("XIMInputStyle")).toString(); + if (!settingsInputStyle.isEmpty()) + ui->inputStyleCombo->setCurrentIndex(ui->inputStyleCombo->findText(settingsInputStyle)); #else - inputStyle->hide(); - inputStyleLabel->hide(); + ui->inputStyleCombo->hide(); + ui->inputStyleComboLabel->hide(); #endif #if defined(Q_WS_X11) && !defined(QT_NO_XIM) - QStringList inputMethods = QInputContextFactory::keys(); - int inputMethodIndex = -1; + QStringList inputMethodCombo = QInputContextFactory::keys(); + int inputMethodComboIndex = -1; QString defaultInputMethod = settings.value(QLatin1String("DefaultInputMethod"), QLatin1String("xim")).toString(); - for (int i = inputMethods.size()-1; i >= 0; --i) { - const QString &im = inputMethods.at(i); + for (int i = inputMethodCombo.size()-1; i >= 0; --i) { + const QString &im = inputMethodCombo.at(i); if (im.contains(QLatin1String("imsw"))) { - inputMethods.removeAt(i); - if (inputMethodIndex > i) - --inputMethodIndex; + inputMethodCombo.removeAt(i); + if (inputMethodComboIndex > i) + --inputMethodComboIndex; } else if (im == defaultInputMethod) { - inputMethodIndex = i; + inputMethodComboIndex = i; } } - if (inputMethodIndex == -1 && !inputMethods.isEmpty()) - inputMethodIndex = 0; - inputMethod->addItems(inputMethods); - inputMethod->setCurrentIndex(inputMethodIndex); + if (inputMethodComboIndex == -1 && !inputMethodCombo.isEmpty()) + inputMethodComboIndex = 0; + ui->inputMethodCombo->addItems(inputMethodCombo); + ui->inputMethodCombo->setCurrentIndex(inputMethodComboIndex); #else - inputMethod->hide(); - inputMethodLabel->hide(); + ui->inputMethodCombo->hide(); + ui->inputMethodComboLabel->hide(); #endif - fontembeddingcheckbox->setChecked(settings.value(QLatin1String("embedFonts"), true).toBool()); + ui->fontEmbeddingCheckBox->setChecked(settings.value(QLatin1String("embedFonts"), true) + .toBool()); fontpaths = settings.value(QLatin1String("fontPath")).toStringList(); - fontpathlistbox->insertStringList(fontpaths); - - audiosinkCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); - audiosinkCombo->setItemData(audiosinkCombo->findText(tr("Auto (default)")), - tr("Choose audio output automatically."), Qt::ToolTipRole); - audiosinkCombo->addItem(tr("aRts"), QLatin1String("artssink")); - audiosinkCombo->setItemData(audiosinkCombo->findText(tr("aRts")), - tr("Experimental aRts support for GStreamer."), Qt::ToolTipRole); + ui->fontpathListBox->insertItems(0, fontpaths); + + ui->audiosinkCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); + ui->audiosinkCombo->setItemData(ui->audiosinkCombo->findText(tr("Auto (default)")), + tr("Choose audio output automatically."), Qt::ToolTipRole); + ui->audiosinkCombo->addItem(tr("aRts"), QLatin1String("artssink")); + ui->audiosinkCombo->setItemData(ui->audiosinkCombo->findText(tr("aRts")), + tr("Experimental aRts support for GStreamer."), + Qt::ToolTipRole); #ifdef HAVE_PHONON - phononVersionLabel->setText(QLatin1String(Phonon::phononVersion())); + ui->phononVersionLabel->setText(QLatin1String(Phonon::phononVersion())); #endif #ifndef QT_NO_GSTREAMER if (gst_init_check(0, 0, 0)) { gchar *versionString = gst_version_string(); - gstversionLabel->setText(QLatin1String(versionString)); + ui->gstVersionLabel->setText(QLatin1String(versionString)); g_free(versionString); - GList* factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); + GList *factoryList = gst_registry_get_feature_list(gst_registry_get_default(), + GST_TYPE_ELEMENT_FACTORY); QString name, klass, description; - for (GList* iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { + for (GList *iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); klass = QLatin1String(gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature))); if (klass == QLatin1String("Sink/Audio")) { name = QLatin1String(GST_PLUGIN_FEATURE_NAME(feature)); if (name == QLatin1String("sfsink")) - continue; //useless to output audio to file when you cannot set the file path + continue; // useless to output audio to file when you cannot set the file path else if (name == QLatin1String("autoaudiosink")) continue; //This is used implicitly from the auto setting GstElement *sink = gst_element_factory_make (qPrintable(name), NULL); if (sink) { - description = QLatin1String(gst_element_factory_get_description (GST_ELEMENT_FACTORY(feature))); - audiosinkCombo->addItem(name, name); - audiosinkCombo->setItemData(audiosinkCombo->findText(name), description, Qt::ToolTipRole); + description = QLatin1String(gst_element_factory_get_description(GST_ELEMENT_FACTORY(feature))); + ui->audiosinkCombo->addItem(name, name); + ui->audiosinkCombo->setItemData(ui->audiosinkCombo->findText(name), description, + Qt::ToolTipRole); gst_object_unref (sink); } } @@ -420,39 +455,43 @@ MainWindow::MainWindow() g_list_free(factoryList); } #else - tab4->setEnabled(false); - phononLabel->setText(tr("Phonon GStreamer backend not available.")); + ui->phononTab->setEnabled(false); + ui->phononLabel->setText(tr("Phonon GStreamer backend not available.")); #endif - videomodeCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); - videomodeCombo->setItemData(videomodeCombo->findText(tr("Auto (default)")), tr("Choose render method automatically"), Qt::ToolTipRole); + ui->videomodeCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); + ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("Auto (default)")), + tr("Choose render method automatically"), Qt::ToolTipRole); #ifdef Q_WS_X11 - videomodeCombo->addItem(tr("X11"), QLatin1String("X11")); - videomodeCombo->setItemData(videomodeCombo->findText(tr("X11")), tr("Use X11 Overlays"), Qt::ToolTipRole); + ui->videomodeCombo->addItem(tr("X11"), QLatin1String("X11")); + ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("X11")), + tr("Use X11 Overlays"), Qt::ToolTipRole); #endif #ifndef QT_NO_OPENGL - videomodeCombo->addItem(tr("OpenGL"), QLatin1String("OpenGL")); - videomodeCombo->setItemData(videomodeCombo->findText(tr("OpenGL")), tr("Use OpenGL if available"), Qt::ToolTipRole); + ui->videomodeCombo->addItem(tr("OpenGL"), QLatin1String("OpenGL")); + ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("OpenGL")), + tr("Use OpenGL if available"), Qt::ToolTipRole); #endif - videomodeCombo->addItem(tr("Software"), QLatin1String("Software")); - videomodeCombo->setItemData(videomodeCombo->findText(tr("Software")), tr("Use simple software rendering"), Qt::ToolTipRole); + ui->videomodeCombo->addItem(tr("Software"), QLatin1String("Software")); + ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("Software")), + tr("Use simple software rendering"), Qt::ToolTipRole); QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString(); QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString(); - audiosinkCombo->setCurrentItem(audiosinkCombo->findData(audioSink)); - videomodeCombo->setCurrentItem(videomodeCombo->findData(videoMode)); + ui->audiosinkCombo->setCurrentIndex(ui->audiosinkCombo->findData(audioSink)); + ui->videomodeCombo->setCurrentIndex(ui->videomodeCombo->findData(videoMode)); settings.endGroup(); // Qt - helpview->setText(tr(appearance_text)); + ui->helpView->setText(tr(appearance_text)); setModified(false); updateStyleLayout(); } - MainWindow::~MainWindow() { + delete ui; } #ifdef Q_WS_X11 @@ -472,23 +511,23 @@ void MainWindow::fileSave() QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); QFontDatabase db; - QFont font = db.font(familycombo->currentText(), - stylecombo->currentText(), - psizecombo->currentText().toInt()); + QFont font = db.font(ui->fontFamilyCombo->currentText(), + ui->fontStyleCombo->currentText(), + ui->pointSizeCombo->currentText().toInt()); QStringList actcg, inactcg, discg; - bool overrideDesktopSettings = (gstylecombo->currentText() != desktopThemeName); + bool overrideDesktopSettings = (ui->guiStyleCombo->currentText() != desktopThemeName); if (overrideDesktopSettings) { int i; - for (i = 0; i < QColorGroup::NColorRoles; i++) + for (i = 0; i < QPalette::NColorRoles; i++) actcg << editPalette.color(QPalette::Active, - (QColorGroup::ColorRole) i).name(); - for (i = 0; i < QColorGroup::NColorRoles; i++) + QPalette::ColorRole(i)).name(); + for (i = 0; i < QPalette::NColorRoles; i++) inactcg << editPalette.color(QPalette::Inactive, - (QColorGroup::ColorRole) i).name(); - for (i = 0; i < QColorGroup::NColorRoles; i++) + QPalette::ColorRole(i)).name(); + for (i = 0; i < QPalette::NColorRoles; i++) discg << editPalette.color(QPalette::Disabled, - (QColorGroup::ColorRole) i).name(); + QPalette::ColorRole(i)).name(); } settings.setValue(QLatin1String("font"), font.toString()); @@ -497,59 +536,63 @@ void MainWindow::fileSave() settings.setValue(QLatin1String("Palette/disabled"), discg); settings.setValue(QLatin1String("fontPath"), fontpaths); - settings.setValue(QLatin1String("embedFonts"), fontembeddingcheckbox->isChecked()); - settings.setValue(QLatin1String("style"), overrideDesktopSettings ? gstylecombo->currentText() : QString()); + settings.setValue(QLatin1String("embedFonts"), ui->fontEmbeddingCheckBox->isChecked()); + settings.setValue(QLatin1String("style"), + overrideDesktopSettings ? ui->guiStyleCombo->currentText() : QString()); - settings.setValue(QLatin1String("doubleClickInterval"), dcispin->value()); - settings.setValue(QLatin1String("cursorFlashTime"), cfispin->value() == 9 ? 0 : cfispin->value() ); - settings.setValue(QLatin1String("wheelScrollLines"), wslspin->value()); - settings.setValue(QLatin1String("resolveSymlinks"), resolvelinks->isChecked()); + settings.setValue(QLatin1String("doubleClickInterval"), ui->doubleClickIntervalSpinBox->value()); + settings.setValue(QLatin1String("cursorFlashTime"), + ui->cursorFlashTimeSpinBox->value() == 9 ? 0 : ui->cursorFlashTimeSpinBox->value()); + settings.setValue(QLatin1String("wheelScrollLines"), ui->wheelScrollLinesSpinBox->value()); + settings.setValue(QLatin1String("resolveSymlinks"), ui->resolveLinksCheckBox->isChecked()); - QSize strut(strutwidth->value(), strutheight->value()); + QSize strut(ui->strutWidthSpinBox->value(), ui->strutHeightSpinBox->value()); settings.setValue(QLatin1String("globalStrut/width"), strut.width()); settings.setValue(QLatin1String("globalStrut/height"), strut.height()); - settings.setValue(QLatin1String("useRtlExtensions"), rtlExtensions->isChecked()); + settings.setValue(QLatin1String("useRtlExtensions"), ui->rtlExtensionsCheckBox->isChecked()); #ifdef Q_WS_X11 - QString style = inputStyle->currentText(); + QString style = ui->inputStyleCombo->currentText(); QString str = QLatin1String("On The Spot"); - if ( style == trUtf8( "Over The Spot" ) ) + if (style == tr("Over The Spot")) str = QLatin1String("Over The Spot"); - else if ( style == trUtf8( "Off The Spot" ) ) + else if (style == tr("Off The Spot")) str = QLatin1String("Off The Spot"); - else if ( style == trUtf8( "Root" ) ) + else if (style == tr("Root")) str = QLatin1String("Root"); - settings.setValue( QLatin1String("XIMInputStyle"), str ); + settings.setValue(QLatin1String("XIMInputStyle"), str); #endif #if defined(Q_WS_X11) && !defined(QT_NO_XIM) - settings.setValue(QLatin1String("DefaultInputMethod"), inputMethod->currentText()); + settings.setValue(QLatin1String("DefaultInputMethod"), ui->inputMethodCombo->currentText()); #endif QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString(); QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString(); - settings.setValue(QLatin1String("audiosink"), audiosinkCombo->itemData(audiosinkCombo->currentIndex())); - settings.setValue(QLatin1String("videomode"), videomodeCombo->itemData(videomodeCombo->currentIndex())); + settings.setValue(QLatin1String("audiosink"), + ui->audiosinkCombo->itemData(ui->audiosinkCombo->currentIndex())); + settings.setValue(QLatin1String("videomode"), + ui->videomodeCombo->itemData(ui->videomodeCombo->currentIndex())); QStringList effects; - if (effectcheckbox->isChecked()) { + if (ui->effectsCheckBox->isChecked()) { effects << QLatin1String("general"); - switch (menueffect->currentItem()) { + switch (ui->menuEffectCombo->currentIndex()) { case 1: effects << QLatin1String("animatemenu"); break; case 2: effects << QLatin1String("fademenu"); break; } - switch (comboeffect->currentItem()) { + switch (ui->comboEffectCombo->currentIndex()) { case 1: effects << QLatin1String("animatecombo"); break; } - switch (tooltipeffect->currentItem()) { + switch (ui->toolTipEffectCombo->currentIndex()) { case 1: effects << QLatin1String("animatetooltip"); break; case 2: effects << QLatin1String("fadetooltip"); break; } - switch ( toolboxeffect->currentItem() ) { + switch (ui->toolBoxEffectCombo->currentIndex()) { case 1: effects << QLatin1String("animatetoolbox"); break; } } else @@ -573,189 +616,63 @@ void MainWindow::fileSave() #endif // Q_WS_X11 setModified(false); - statusBar()->showMessage(QLatin1String("Saved changes.")); + statusBar()->showMessage(tr("Saved changes.")); } - void MainWindow::fileExit() { qApp->closeAllWindows(); } - void MainWindow::setModified(bool m) { if (modified == m) return; modified = m; - fileSaveAction->setEnabled(m); + ui->fileSaveAction->setEnabled(m); } - void MainWindow::buildPalette() { - int i; - QColorGroup cg; - QColor btn = buttonMainColor->color(); - QColor back = buttonMainColor2->color(); - QPalette automake( btn, back ); - - for (i = 0; i<9; i++) - cg.setColor( centralFromItem(i), automake.active().color( centralFromItem(i) ) ); - - editPalette.setActive( cg ); - buildActiveEffect(); - - cg = editPalette.inactive(); - - QPalette temp( editPalette.active().color( QColorGroup::Button ), - editPalette.active().color( QColorGroup::Window ) ); - - for (i = 0; i<9; i++) - cg.setColor( centralFromItem(i), temp.inactive().color( centralFromItem(i) ) ); - - editPalette.setInactive( cg ); - buildInactiveEffect(); - - cg = editPalette.disabled(); - - for (i = 0; i<9; i++) - cg.setColor( centralFromItem(i), temp.disabled().color( centralFromItem(i) ) ); - - editPalette.setDisabled( cg ); - buildDisabledEffect(); + QPalette temp(ui->buttonMainColor->color(), ui->buttonWindowColor->color()); + for (int i = 0; i < QPalette::NColorGroups; i++) + temp = PaletteEditorAdvanced::buildEffect(QPalette::ColorGroup(i), temp); + editPalette = temp; + setPreviewPalette(editPalette); updateColorButtons(); setModified(true); } - -void MainWindow::buildActiveEffect() -{ - QColorGroup cg = editPalette.active(); - QColor btn = cg.color( QColorGroup::Button ); - - QPalette temp( btn, btn ); - - for (int i = 0; i<5; i++) - cg.setColor( effectFromItem(i), temp.active().color( effectFromItem(i) ) ); - - editPalette.setActive( cg ); - setPreviewPalette( editPalette ); - - updateColorButtons(); -} - - -void MainWindow::buildInactive() +void MainWindow::setPreviewPalette(const QPalette &pal) { - editPalette.setInactive( editPalette.active() ); - buildInactiveEffect(); -} - + QPalette::ColorGroup colorGroup = groupFromIndex(ui->paletteCombo->currentIndex()); -void MainWindow::buildInactiveEffect() -{ - QColorGroup cg = editPalette.inactive(); - - QColor light, midlight, mid, dark, shadow; - QColor btn = cg.color( QColorGroup::Button ); - - light = btn.light(150); - midlight = btn.light(115); - mid = btn.dark(150); - dark = btn.dark(); - shadow = Qt::black; - - cg.setColor( QColorGroup::Light, light ); - cg.setColor( QColorGroup::Midlight, midlight ); - cg.setColor( QColorGroup::Mid, mid ); - cg.setColor( QColorGroup::Dark, dark ); - cg.setColor( QColorGroup::Shadow, shadow ); - - editPalette.setInactive( cg ); - setPreviewPalette( editPalette ); - updateColorButtons(); -} - - -void MainWindow::buildDisabled() -{ - QColorGroup cg = editPalette.active(); - cg.setColor( QColorGroup::ButtonText, Qt::darkGray ); - cg.setColor( QColorGroup::WindowText, Qt::darkGray ); - cg.setColor( QColorGroup::Text, Qt::darkGray ); - cg.setColor( QColorGroup::HighlightedText, Qt::darkGray ); - editPalette.setDisabled( cg ); - - buildDisabledEffect(); -} - - -void MainWindow::buildDisabledEffect() -{ - QColorGroup cg = editPalette.disabled(); - - QColor light, midlight, mid, dark, shadow; - QColor btn = cg.color( QColorGroup::Button ); - - light = btn.light(150); - midlight = btn.light(115); - mid = btn.dark(150); - dark = btn.dark(); - shadow = Qt::black; - - cg.setColor( QColorGroup::Light, light ); - cg.setColor( QColorGroup::Midlight, midlight ); - cg.setColor( QColorGroup::Mid, mid ); - cg.setColor( QColorGroup::Dark, dark ); - cg.setColor( QColorGroup::Shadow, shadow ); - - editPalette.setDisabled( cg ); - setPreviewPalette( editPalette ); - updateColorButtons(); -} - - -void MainWindow::setPreviewPalette( const QPalette& pal ) -{ - QColorGroup cg; - - switch (paletteCombo->currentItem()) { - case 0: - default: - cg = pal.active(); - break; - case 1: - cg = pal.inactive(); - break; - case 2: - cg = pal.disabled(); - break; + for (int i = 0; i < QPalette::NColorGroups; i++) { + for (int j = 0; j < QPalette::NColorRoles; j++) { + QPalette::ColorGroup targetGroup = QPalette::ColorGroup(i); + QPalette::ColorRole targetRole = QPalette::ColorRole(j); + previewPalette.setColor(targetGroup, targetRole, pal.color(colorGroup, targetRole)); + } } - previewPalette.setActive( cg ); - previewPalette.setInactive( cg ); - previewPalette.setDisabled( cg ); - previewFrame->setPreviewPalette(previewPalette); + ui->previewFrame->setPreviewPalette(previewPalette); } - void MainWindow::updateColorButtons() { - buttonMainColor->setColor( editPalette.active().color( QColorGroup::Button )); - buttonMainColor2->setColor( editPalette.active().color( QColorGroup::Window )); + ui->buttonMainColor->setColor(editPalette.color(QPalette::Active, QPalette::Button)); + ui->buttonWindowColor->setColor(editPalette.color(QPalette::Active, QPalette::Window)); } - void MainWindow::tunePalette() { bool ok; QPalette pal = PaletteEditorAdvanced::getPalette(&ok, editPalette, - backgroundMode(), this); - if (! ok) + backgroundRole(), this); + if (!ok) return; editPalette = pal; @@ -763,7 +680,6 @@ void MainWindow::tunePalette() setModified(true); } - void MainWindow::paletteSelected(int) { setPreviewPalette(editPalette); @@ -771,10 +687,10 @@ void MainWindow::paletteSelected(int) void MainWindow::updateStyleLayout() { - QString currentStyle = gstylecombo->currentText(); + QString currentStyle = ui->guiStyleCombo->currentText(); bool autoStyle = (currentStyle == desktopThemeName); - previewFrame->setPreviewVisible(!autoStyle); - groupAutoPalette->setEnabled(currentStyle.toLower() != QLatin1String("gtk") && !autoStyle); + ui->previewFrame->setPreviewVisible(!autoStyle); + ui->buildPaletteGroup->setEnabled(currentStyle.toLower() != QLatin1String("gtk") && !autoStyle); } void MainWindow::styleSelected(const QString &stylename) @@ -786,7 +702,7 @@ void MainWindow::styleSelected(const QString &stylename) style = QStyleFactory::create(stylename); if (!style) return; - setStyleHelper(previewFrame, style); + setStyleHelper(ui->previewFrame, style); delete previewstyle; previewstyle = style; setModified(true); @@ -794,210 +710,191 @@ void MainWindow::styleSelected(const QString &stylename) updateStyleLayout(); } - void MainWindow::familySelected(const QString &family) { QFontDatabase db; QStringList styles = db.styles(family); - stylecombo->clear(); - stylecombo->insertStringList(styles); - familysubcombo->insertItem(family); + ui->fontStyleCombo->clear(); + ui->fontStyleCombo->addItems(styles); + ui->familySubstitutionCombo->addItem(family); buildFont(); } - void MainWindow::buildFont() { QFontDatabase db; - QFont font = db.font(familycombo->currentText(), - stylecombo->currentText(), - psizecombo->currentText().toInt()); - samplelineedit->setFont(font); + QFont font = db.font(ui->fontFamilyCombo->currentText(), + ui->fontStyleCombo->currentText(), + ui->pointSizeCombo->currentText().toInt()); + ui->sampleLineEdit->setFont(font); setModified(true); } - void MainWindow::substituteSelected(const QString &family) { QStringList subs = QFont::substitutes(family); - sublistbox->clear(); - sublistbox->insertStringList(subs); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); } - void MainWindow::removeSubstitute() { - if (sublistbox->currentItem() < 0 || - uint(sublistbox->currentItem()) > sublistbox->count()) + if (!ui->substitutionsListBox->currentItem()) return; - int item = sublistbox->currentItem(); - QStringList subs = QFont::substitutes(familysubcombo->currentText()); - subs.removeAt(sublistbox->currentItem()); - sublistbox->clear(); - sublistbox->insertStringList(subs); - if (uint(item) > sublistbox->count()) - item = int(sublistbox->count()) - 1; - sublistbox->setCurrentItem(item); - QFont::removeSubstitution(familysubcombo->currentText()); - QFont::insertSubstitutions(familysubcombo->currentText(), subs); + int row = ui->substitutionsListBox->currentRow(); + QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); + subs.removeAt(ui->substitutionsListBox->currentRow()); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); + if (row > ui->substitutionsListBox->count()) + row = ui->substitutionsListBox->count() - 1; + ui->substitutionsListBox->setCurrentRow(row); + QFont::removeSubstitution(ui->familySubstitutionCombo->currentText()); + QFont::insertSubstitutions(ui->familySubstitutionCombo->currentText(), subs); setModified(true); } - void MainWindow::addSubstitute() { - if (sublistbox->currentItem() < 0 || - uint(sublistbox->currentItem()) > sublistbox->count()) { - QFont::insertSubstitution(familysubcombo->currentText(), choosesubcombo->currentText()); - QStringList subs = QFont::substitutes(familysubcombo->currentText()); - sublistbox->clear(); - sublistbox->insertStringList(subs); + if (!ui->substitutionsListBox->currentItem()) { + QFont::insertSubstitution(ui->familySubstitutionCombo->currentText(), + ui->chooseSubstitutionCombo->currentText()); + QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); setModified(true); return; } - int item = sublistbox->currentItem(); - QFont::insertSubstitution(familysubcombo->currentText(), choosesubcombo->currentText()); - QStringList subs = QFont::substitutes(familysubcombo->currentText()); - sublistbox->clear(); - sublistbox->insertStringList(subs); - sublistbox->setCurrentItem(item); + int row = ui->substitutionsListBox->currentRow(); + QFont::insertSubstitution(ui->familySubstitutionCombo->currentText(), ui->chooseSubstitutionCombo->currentText()); + QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); + ui->substitutionsListBox->setCurrentRow(row); setModified(true); } - void MainWindow::downSubstitute() { - if (sublistbox->currentItem() < 0 || - uint(sublistbox->currentItem()) >= sublistbox->count()) + if (!ui->substitutionsListBox->currentItem() || ui->substitutionsListBox->currentRow() >= ui->substitutionsListBox->count()) return; - int item = sublistbox->currentItem(); - QStringList subs = QFont::substitutes(familysubcombo->currentText()); - QString fam = subs.at(item); - subs.removeAt(item); - subs.insert(item+1, fam); - sublistbox->clear(); - sublistbox->insertStringList(subs); - sublistbox->setCurrentItem(item + 1); - QFont::removeSubstitution(familysubcombo->currentText()); - QFont::insertSubstitutions(familysubcombo->currentText(), subs); + int row = ui->substitutionsListBox->currentRow(); + QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); + QString fam = subs.at(row); + subs.removeAt(row); + subs.insert(row + 1, fam); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); + ui->substitutionsListBox->setCurrentRow(row + 1); + QFont::removeSubstitution(ui->familySubstitutionCombo->currentText()); + QFont::insertSubstitutions(ui->familySubstitutionCombo->currentText(), subs); setModified(true); } - void MainWindow::upSubstitute() { - if (sublistbox->currentItem() < 1) + if (!ui->substitutionsListBox->currentItem() || ui->substitutionsListBox->currentRow() < 1) return; - int item = sublistbox->currentItem(); - QStringList subs = QFont::substitutes(familysubcombo->currentText()); - QString fam = subs.at(item); - subs.removeAt(item); - subs.insert(item-1, fam); - sublistbox->clear(); - sublistbox->insertStringList(subs); - sublistbox->setCurrentItem(item - 1); - QFont::removeSubstitution(familysubcombo->currentText()); - QFont::insertSubstitutions(familysubcombo->currentText(), subs); + int row = ui->substitutionsListBox->currentRow(); + QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); + QString fam = subs.at(row); + subs.removeAt(row); + subs.insert(row-1, fam); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); + ui->substitutionsListBox->setCurrentRow(row - 1); + QFont::removeSubstitution(ui->familySubstitutionCombo->currentText()); + QFont::insertSubstitutions(ui->familySubstitutionCombo->currentText(), subs); setModified(true); } - void MainWindow::removeFontpath() { - if (fontpathlistbox->currentItem() < 0 || - uint(fontpathlistbox->currentItem()) > fontpathlistbox->count()) + if (!ui->fontpathListBox->currentItem()) return; - int item = fontpathlistbox->currentItem(); - fontpaths.removeAt(fontpathlistbox->currentItem()); - fontpathlistbox->clear(); - fontpathlistbox->insertStringList(fontpaths); - if (uint(item) > fontpathlistbox->count()) - item = int(fontpathlistbox->count()) - 1; - fontpathlistbox->setCurrentItem(item); + int row = ui->fontpathListBox->currentRow(); + fontpaths.removeAt(row); + ui->fontpathListBox->clear(); + ui->fontpathListBox->insertItems(0, fontpaths); + if (row > ui->fontpathListBox->count()) + row = ui->fontpathListBox->count() - 1; + ui->fontpathListBox->setCurrentRow(row); setModified(true); } - void MainWindow::addFontpath() { - if (fontpathlineedit->text().isEmpty()) + if (ui->fontPathLineEdit->text().isEmpty()) return; - if (fontpathlistbox->currentItem() < 0 || - uint(fontpathlistbox->currentItem()) > fontpathlistbox->count()) { - fontpaths.append(fontpathlineedit->text()); - fontpathlistbox->clear(); - fontpathlistbox->insertStringList(fontpaths); + if (!ui->fontpathListBox->currentItem()) { + fontpaths.append(ui->fontPathLineEdit->text()); + ui->fontpathListBox->clear(); + ui->fontpathListBox->insertItems(0, fontpaths); setModified(true); return; } - int item = fontpathlistbox->currentItem(); - fontpaths.insert(fontpathlistbox->currentItem()+1, - fontpathlineedit->text()); - fontpathlistbox->clear(); - fontpathlistbox->insertStringList(fontpaths); - fontpathlistbox->setCurrentItem(item); + int row = ui->fontpathListBox->currentRow(); + fontpaths.insert(row + 1, ui->fontPathLineEdit->text()); + ui->fontpathListBox->clear(); + ui->fontpathListBox->insertItems(0, fontpaths); + ui->fontpathListBox->setCurrentRow(row); setModified(true); } - void MainWindow::downFontpath() { - if (fontpathlistbox->currentItem() < 0 || - uint(fontpathlistbox->currentItem()) >= fontpathlistbox->count() - 1) + if (!ui->fontpathListBox->currentItem() + || ui->fontpathListBox->currentRow() >= (ui->fontpathListBox->count() - 1)) { return; + } - int item = fontpathlistbox->currentItem(); - QString fam = fontpaths.at(item); - fontpaths.removeAt(item); - fontpaths.insert(item+1, fam); - fontpathlistbox->clear(); - fontpathlistbox->insertStringList(fontpaths); - fontpathlistbox->setCurrentItem(item + 1); + int row = ui->fontpathListBox->currentRow(); + QString fam = fontpaths.at(row); + fontpaths.removeAt(row); + fontpaths.insert(row + 1, fam); + ui->fontpathListBox->clear(); + ui->fontpathListBox->insertItems(0, fontpaths); + ui->fontpathListBox->setCurrentRow(row + 1); setModified(true); } - void MainWindow::upFontpath() { - if (fontpathlistbox->currentItem() < 1) + if (!ui->fontpathListBox->currentItem() || ui->fontpathListBox->currentRow() < 1) return; - int item = fontpathlistbox->currentItem(); - QString fam = fontpaths.at(item); - fontpaths.removeAt(item); - fontpaths.insert(item-1, fam); - fontpathlistbox->clear(); - fontpathlistbox->insertStringList(fontpaths); - fontpathlistbox->setCurrentItem(item - 1); + int row = ui->fontpathListBox->currentRow(); + QString fam = fontpaths.at(row); + fontpaths.removeAt(row); + fontpaths.insert(row - 1, fam); + ui->fontpathListBox->clear(); + ui->fontpathListBox->insertItems(0, fontpaths); + ui->fontpathListBox->setCurrentRow(row - 1); setModified(true); } - void MainWindow::browseFontpath() { - QString dirname = QFileDialog::getExistingDirectory(QString(), this, 0, - tr("Select a Directory")); + QString dirname = QFileDialog::getExistingDirectory(this, tr("Select a Directory")); if (dirname.isNull()) return; - fontpathlineedit->setText(dirname); + ui->fontPathLineEdit->setText(dirname); } - void MainWindow::somethingModified() { setModified(true); } - void MainWindow::helpAbout() { QMessageBox box(this); @@ -1010,44 +907,43 @@ void MainWindow::helpAbout() box.exec(); } - void MainWindow::helpAboutQt() { QMessageBox::aboutQt(this, tr("Qt Configuration")); } - -void MainWindow::pageChanged(QWidget *page) +void MainWindow::pageChanged(int pageNumber) { - if (page == tab) - helpview->setText(tr(interface_text)); - else if (page == tab1) - helpview->setText(tr(appearance_text)); - else if (page == tab2) - helpview->setText(tr(font_text)); - else if (page == tab3) - helpview->setText(tr(printer_text)); - else if (page == tab4) - helpview->setText(tr(phonon_text)); + QWidget *page = ui->mainTabWidget->widget(pageNumber); + if (page == ui->interfaceTab) + ui->helpView->setText(tr(interface_text)); + else if (page == ui->appearanceTab) + ui->helpView->setText(tr(appearance_text)); + else if (page == ui->fontsTab) + ui->helpView->setText(tr(font_text)); + else if (page == ui->printerTab) + ui->helpView->setText(tr(printer_text)); + else if (page == ui->phononTab) + ui->helpView->setText(tr(phonon_text)); } - void MainWindow::closeEvent(QCloseEvent *e) { if (modified) { - switch(QMessageBox::warning(this, tr("Save Changes"), - tr("Save changes to settings?"), - tr("&Yes"), tr("&No"), tr("&Cancel"), 0, 2)) { - case 0: // save + switch (QMessageBox::warning(this, tr("Save Changes"), + tr("Save changes to settings?"), + (QMessageBox::Yes | QMessageBox::No + | QMessageBox::Cancel))) { + case QMessageBox::Yes: // save qApp->processEvents(); fileSave(); // fall through intended - case 1: // don't save + case QMessageBox::No: // don't save e->accept(); break; - case 2: // cancel + case QMessageBox::Cancel: // cancel e->ignore(); break; diff --git a/tools/qtconfig/mainwindow.h b/tools/qtconfig/mainwindow.h index cc7d597..6f4c8a5 100644 --- a/tools/qtconfig/mainwindow.h +++ b/tools/qtconfig/mainwindow.h @@ -42,11 +42,15 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include "mainwindowbase.h" +#include <QtGui/QMainWindow> QT_BEGIN_NAMESPACE -class MainWindow : public MainWindowBase +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow { Q_OBJECT @@ -56,7 +60,6 @@ public: void closeEvent(QCloseEvent *); - public slots: virtual void buildPalette(); virtual void buildFont(); @@ -79,25 +82,21 @@ public slots: virtual void somethingModified(); virtual void helpAbout(); virtual void helpAboutQt(); - virtual void pageChanged(QWidget *); + virtual void pageChanged(int); private: - void buildActive(); - void buildActiveEffect(); - void buildInactive(); - void buildInactiveEffect(); - void buildDisabled(); - void buildDisabledEffect(); - void updateColorButtons(); void updateFontSample(); void updateStyleLayout(); + static QPalette::ColorGroup groupFromIndex(int); + void setPreviewPalette(const QPalette &); void setModified(bool); + Ui::MainWindow *ui; QString desktopThemeName; QPalette editPalette, previewPalette; QStyle *previewstyle; diff --git a/tools/qtconfig/mainwindowbase.ui b/tools/qtconfig/mainwindow.ui index c5b4470..d906800 100644 --- a/tools/qtconfig/mainwindowbase.ui +++ b/tools/qtconfig/mainwindow.ui @@ -40,8 +40,8 @@ ** $QT_END_LICENSE$ ** *********************************************************************</comment> - <class>MainWindowBase</class> - <widget class="Q3MainWindow" name="MainWindowBase"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> @@ -54,20 +54,12 @@ <string>Qt Configuration</string> </property> <widget class="QWidget" name="widget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>26</y> - <width>815</width> - <height>690</height> - </rect> - </property> <layout class="QGridLayout" name="gridLayout"> <property name="margin"> <number>8</number> </property> <item row="0" column="0"> - <widget class="QTextEdit" name="helpview"> + <widget class="QTextEdit" name="helpView"> <property name="minimumSize"> <size> <width>200</width> @@ -80,17 +72,17 @@ </widget> </item> <item row="0" column="1"> - <widget class="QTabWidget" name="TabWidget3"> + <widget class="QTabWidget" name="mainTabWidget"> <property name="currentIndex"> <number>0</number> </property> - <widget class="QWidget" name="tab1"> + <widget class="QWidget" name="appearanceTab"> <attribute name="title"> <string>Appearance</string> </attribute> <layout class="QGridLayout" name="gridLayout_5"> <item row="0" column="0"> - <widget class="QGroupBox" name="GroupBox40"> + <widget class="QGroupBox" name="guiStyleGroup"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -114,7 +106,7 @@ <number>8</number> </property> <item> - <widget class="QLabel" name="gstylebuddy"> + <widget class="QLabel" name="guiStyleLabel"> <property name="minimumSize"> <size> <width>0</width> @@ -125,18 +117,18 @@ <string>Select GUI &Style:</string> </property> <property name="buddy"> - <cstring>gstylecombo</cstring> + <cstring>guiStyleCombo</cstring> </property> </widget> </item> <item> - <widget class="QComboBox" name="gstylecombo"/> + <widget class="QComboBox" name="guiStyleCombo"/> </item> </layout> </widget> </item> <item row="3" column="0"> - <widget class="QGroupBox" name="groupPreview"> + <widget class="QGroupBox" name="previewGroup"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <horstretch>0</horstretch> @@ -148,7 +140,7 @@ </property> <layout class="QGridLayout" name="gridLayout_4"> <item row="0" column="0"> - <widget class="QLabel" name="TextLabel1"> + <widget class="QLabel" name="paletteLabel"> <property name="text"> <string>Select &Palette:</string> </property> @@ -196,7 +188,7 @@ </widget> </item> <item row="1" column="0"> - <widget class="QGroupBox" name="groupAutoPalette"> + <widget class="QGroupBox" name="buildPaletteGroup"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> <horstretch>0</horstretch> @@ -222,7 +214,7 @@ <item> <widget class="QLabel" name="labelMainColor"> <property name="text"> - <string>&3-D Effects:</string> + <string>&Button Background:</string> </property> <property name="buddy"> <cstring>buttonMainColor</cstring> @@ -233,7 +225,7 @@ <widget class="ColorButton" name="buttonMainColor" native="true"/> </item> <item> - <widget class="QLabel" name="labelMainColor2"> + <widget class="QLabel" name="labelWindowColor"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> <horstretch>0</horstretch> @@ -262,12 +254,12 @@ <number>0</number> </property> <property name="buddy"> - <cstring>buttonMainColor2</cstring> + <cstring>buttonWindowColor</cstring> </property> </widget> </item> <item> - <widget class="ColorButton" name="buttonMainColor2" native="true"/> + <widget class="ColorButton" name="buttonWindowColor" native="true"/> </item> <item> <spacer name="spacer"> @@ -286,7 +278,7 @@ </spacer> </item> <item> - <widget class="QPushButton" name="btnAdvanced"> + <widget class="QPushButton" name="tunePaletteButton"> <property name="text"> <string>&Tune Palette...</string> </property> @@ -296,7 +288,7 @@ </widget> </item> <item> - <widget class="QLabel" name="labelKDENote"> + <widget class="QLabel" name="kdeNoteLabel"> <property name="text"> <string>Please use the KDE Control Center to set the palette.</string> </property> @@ -307,13 +299,13 @@ </item> </layout> </widget> - <widget class="QWidget" name="tab2"> + <widget class="QWidget" name="fontsTab"> <attribute name="title"> <string>Fonts</string> </attribute> <layout class="QVBoxLayout"> <item> - <widget class="QGroupBox" name="GroupBox1"> + <widget class="QGroupBox" name="defaultFontGroup"> <property name="title"> <string>Default Font</string> </property> @@ -325,7 +317,7 @@ <number>4</number> </property> <item row="1" column="1"> - <widget class="QComboBox" name="stylecombo"> + <widget class="QComboBox" name="fontStyleCombo"> <property name="autoCompletion"> <bool>true</bool> </property> @@ -335,7 +327,7 @@ </widget> </item> <item row="0" column="1"> - <widget class="QComboBox" name="familycombo"> + <widget class="QComboBox" name="fontFamilyCombo"> <property name="autoCompletion"> <bool>true</bool> </property> @@ -345,7 +337,7 @@ </widget> </item> <item row="2" column="1"> - <widget class="QComboBox" name="psizecombo"> + <widget class="QComboBox" name="pointSizeCombo"> <property name="editable"> <bool>true</bool> </property> @@ -358,37 +350,37 @@ </widget> </item> <item row="1" column="0"> - <widget class="QLabel" name="stylebuddy"> + <widget class="QLabel" name="fontStyleLabel"> <property name="text"> <string>&Style:</string> </property> <property name="buddy"> - <cstring>stylecombo</cstring> + <cstring>fontStyleCombo</cstring> </property> </widget> </item> <item row="2" column="0"> - <widget class="QLabel" name="psizebuddy"> + <widget class="QLabel" name="pointSizeLabel"> <property name="text"> <string>&Point Size:</string> </property> <property name="buddy"> - <cstring>psizecombo</cstring> + <cstring>pointSizeCombo</cstring> </property> </widget> </item> <item row="0" column="0"> - <widget class="QLabel" name="familybuddy"> + <widget class="QLabel" name="fontFamilyLabel"> <property name="text"> <string>F&amily:</string> </property> <property name="buddy"> - <cstring>familycombo</cstring> + <cstring>fontFamilyCombo</cstring> </property> </widget> </item> <item row="3" column="0" colspan="2"> - <widget class="QLineEdit" name="samplelineedit"> + <widget class="QLineEdit" name="sampleLineEdit"> <property name="text"> <string>Sample Text</string> </property> @@ -401,7 +393,7 @@ </widget> </item> <item> - <widget class="QGroupBox" name="GroupBox2"> + <widget class="QGroupBox" name="fontSubstitutionGroup"> <property name="title"> <string>Font Substitution</string> </property> @@ -421,17 +413,17 @@ <number>0</number> </property> <item> - <widget class="QLabel" name="famsubbuddy"> + <widget class="QLabel" name="familySubstitutionLabel"> <property name="text"> <string>S&elect or Enter a Family:</string> </property> <property name="buddy"> - <cstring>familysubcombo</cstring> + <cstring>familySubstitutionCombo</cstring> </property> </widget> </item> <item> - <widget class="QComboBox" name="familysubcombo"> + <widget class="QComboBox" name="familySubstitutionCombo"> <property name="editable"> <bool>true</bool> </property> @@ -459,14 +451,14 @@ </widget> </item> <item> - <widget class="QLabel" name="TextLabel5"> + <widget class="QLabel" name="substitutionsLabel"> <property name="text"> <string>Current Substitutions:</string> </property> </widget> </item> <item> - <widget class="Q3ListBox" name="sublistbox"/> + <widget class="QListWidget" name="substitutionsListBox"/> </item> <item> <layout class="QHBoxLayout"> @@ -477,21 +469,21 @@ <number>0</number> </property> <item> - <widget class="QPushButton" name="PushButton2"> + <widget class="QPushButton" name="upSubstitutionButton"> <property name="text"> <string>Up</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="PushButton3"> + <widget class="QPushButton" name="downSubstitutionButton"> <property name="text"> <string>Down</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="PushButton4"> + <widget class="QPushButton" name="removeSubstitutionButton"> <property name="text"> <string>Remove</string> </property> @@ -521,17 +513,17 @@ <number>0</number> </property> <item> - <widget class="QLabel" name="choosebuddy"> + <widget class="QLabel" name="chooseSubstitutionLabel"> <property name="text"> <string>Select s&ubstitute Family:</string> </property> <property name="buddy"> - <cstring>choosesubcombo</cstring> + <cstring>chooseSubstitutionCombo</cstring> </property> </widget> </item> <item> - <widget class="QComboBox" name="choosesubcombo"> + <widget class="QComboBox" name="chooseSubstitutionCombo"> <property name="autoCompletion"> <bool>true</bool> </property> @@ -541,7 +533,7 @@ </widget> </item> <item> - <widget class="QPushButton" name="PushButton1"> + <widget class="QPushButton" name="addSubstitutionButton"> <property name="text"> <string>Add</string> </property> @@ -554,13 +546,13 @@ </item> </layout> </widget> - <widget class="QWidget" name="tab"> + <widget class="QWidget" name="interfaceTab"> <attribute name="title"> <string>Interface</string> </attribute> <layout class="QVBoxLayout"> <item> - <widget class="QGroupBox" name="GroupBox4"> + <widget class="QGroupBox" name="feelSettingsGroup"> <property name="title"> <string>Feel Settings</string> </property> @@ -572,7 +564,7 @@ <number>4</number> </property> <item row="0" column="1"> - <widget class="QSpinBox" name="dcispin"> + <widget class="QSpinBox" name="doubleClickIntervalSpinBox"> <property name="suffix"> <string> ms</string> </property> @@ -585,17 +577,17 @@ </widget> </item> <item row="0" column="0"> - <widget class="QLabel" name="dcibuddy"> + <widget class="QLabel" name="doubleClickIntervalLabel"> <property name="text"> <string>&Double Click Interval:</string> </property> <property name="buddy"> - <cstring>dcispin</cstring> + <cstring>doubleClickIntervalSpinBox</cstring> </property> </widget> </item> <item row="1" column="1"> - <widget class="QSpinBox" name="cfispin"> + <widget class="QSpinBox" name="cursorFlashTimeSpinBox"> <property name="specialValueText"> <string>No blinking</string> </property> @@ -611,17 +603,17 @@ </widget> </item> <item row="1" column="0"> - <widget class="QLabel" name="cfibuddy"> + <widget class="QLabel" name="cursorFlashTimeLabel"> <property name="text"> <string>&Cursor Flash Time:</string> </property> <property name="buddy"> - <cstring>cfispin</cstring> + <cstring>cursorFlashTimeSpinBox</cstring> </property> </widget> </item> <item row="2" column="1"> - <widget class="QSpinBox" name="wslspin"> + <widget class="QSpinBox" name="wheelScrollLinesSpinBox"> <property name="suffix"> <string> lines</string> </property> @@ -634,17 +626,17 @@ </widget> </item> <item row="2" column="0"> - <widget class="QLabel" name="wslbuddy"> + <widget class="QLabel" name="wheelScrollLinesLabel"> <property name="text"> <string>Wheel &Scroll Lines:</string> </property> <property name="buddy"> - <cstring>wslspin</cstring> + <cstring>wheelScrollLinesSpinBox</cstring> </property> </widget> </item> <item row="3" column="0" colspan="2"> - <widget class="QCheckBox" name="resolvelinks"> + <widget class="QCheckBox" name="resolveLinksCheckBox"> <property name="text"> <string>Resolve symlinks in URLs</string> </property> @@ -654,7 +646,7 @@ </widget> </item> <item> - <widget class="QGroupBox" name="GroupBox3"> + <widget class="QGroupBox" name="guiEffectsGroup"> <property name="title"> <string>GUI Effects</string> </property> @@ -666,7 +658,7 @@ <number>8</number> </property> <item> - <widget class="QCheckBox" name="effectcheckbox"> + <widget class="QCheckBox" name="effectsCheckBox"> <property name="text"> <string>&Enable</string> </property> @@ -676,62 +668,53 @@ </widget> </item> <item> - <widget class="Q3Frame" name="effectbase"> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> + <widget class="QFrame" name="effectsFrame"> <layout class="QGridLayout"> - <property name="margin"> - <number>0</number> - </property> <property name="spacing"> <number>4</number> </property> <item row="0" column="0"> - <widget class="QLabel" name="meffectbuddy"> + <widget class="QLabel" name="menuEffectLabel"> <property name="text"> <string>&Menu Effect:</string> </property> <property name="buddy"> - <cstring>menueffect</cstring> + <cstring>menuEffectCombo</cstring> </property> </widget> </item> <item row="1" column="0"> - <widget class="QLabel" name="ceffectbuddy"> + <widget class="QLabel" name="comboEffectLabel"> <property name="text"> <string>C&omboBox Effect:</string> </property> <property name="buddy"> - <cstring>comboeffect</cstring> + <cstring>comboEffectCombo</cstring> </property> </widget> </item> <item row="2" column="0"> - <widget class="QLabel" name="teffectbuddy"> + <widget class="QLabel" name="toolTipEffectLabel"> <property name="text"> <string>&ToolTip Effect:</string> </property> <property name="buddy"> - <cstring>tooltipeffect</cstring> + <cstring>toolTipEffectCombo</cstring> </property> </widget> </item> <item row="3" column="0"> - <widget class="QLabel" name="beffectbuddy"> + <widget class="QLabel" name="toolBoxEffectLabel"> <property name="text"> <string>Tool&Box Effect:</string> </property> <property name="buddy"> - <cstring>toolboxeffect</cstring> + <cstring>toolBoxEffectCombo</cstring> </property> </widget> </item> <item row="0" column="1"> - <widget class="QComboBox" name="menueffect"> + <widget class="QComboBox" name="menuEffectCombo"> <property name="currentIndex"> <number>0</number> </property> @@ -756,7 +739,7 @@ </widget> </item> <item row="1" column="1"> - <widget class="QComboBox" name="comboeffect"> + <widget class="QComboBox" name="comboEffectCombo"> <item> <property name="text"> <string>Disable</string> @@ -770,7 +753,7 @@ </widget> </item> <item row="2" column="1"> - <widget class="QComboBox" name="tooltipeffect"> + <widget class="QComboBox" name="toolTipEffectCombo"> <item> <property name="text"> <string>Disable</string> @@ -789,7 +772,7 @@ </widget> </item> <item row="3" column="1"> - <widget class="QComboBox" name="toolboxeffect"> + <widget class="QComboBox" name="toolBoxEffectCombo"> <item> <property name="text"> <string>Disable</string> @@ -809,7 +792,7 @@ </widget> </item> <item> - <widget class="QGroupBox" name="GroupBox5"> + <widget class="QGroupBox" name="globalStrutGroup"> <property name="title"> <string>Global Strut</string> </property> @@ -821,27 +804,27 @@ <number>4</number> </property> <item row="0" column="0"> - <widget class="QLabel" name="swbuddy"> + <widget class="QLabel" name="strutWidthLabel"> <property name="text"> <string>Minimum &Width:</string> </property> <property name="buddy"> - <cstring>strutwidth</cstring> + <cstring>strutWidthSpinBox</cstring> </property> </widget> </item> <item row="1" column="0"> - <widget class="QLabel" name="shbuddy"> + <widget class="QLabel" name="strutHeightLabel"> <property name="text"> <string>Minimum Hei&ght:</string> </property> <property name="buddy"> - <cstring>strutheight</cstring> + <cstring>strutHeightSpinBox</cstring> </property> </widget> </item> <item row="0" column="1"> - <widget class="QSpinBox" name="strutwidth"> + <widget class="QSpinBox" name="strutWidthSpinBox"> <property name="suffix"> <string> pixels</string> </property> @@ -851,7 +834,7 @@ </widget> </item> <item row="1" column="1"> - <widget class="QSpinBox" name="strutheight"> + <widget class="QSpinBox" name="strutHeightSpinBox"> <property name="suffix"> <string> pixels</string> </property> @@ -864,7 +847,7 @@ </widget> </item> <item> - <widget class="QCheckBox" name="rtlExtensions"> + <widget class="QCheckBox" name="rtlExtensionsCheckBox"> <property name="text"> <string>Enhanced support for languages written right-to-left</string> </property> @@ -878,7 +861,7 @@ </widget> </item> <item> - <widget class="QComboBox" name="inputStyle"> + <widget class="QComboBox" name="inputStyleCombo"> <property name="currentIndex"> <number>0</number> </property> @@ -912,7 +895,7 @@ </widget> </item> <item> - <widget class="QComboBox" name="inputMethod"> + <widget class="QComboBox" name="inputMethodCombo"> <property name="currentIndex"> <number>-1</number> </property> @@ -936,13 +919,13 @@ </item> </layout> </widget> - <widget class="QWidget" name="tab3"> + <widget class="QWidget" name="printerTab"> <attribute name="title"> <string>Printer</string> </attribute> <layout class="QVBoxLayout"> <item> - <widget class="QCheckBox" name="fontembeddingcheckbox"> + <widget class="QCheckBox" name="fontEmbeddingCheckBox"> <property name="text"> <string>Enable Font embedding</string> </property> @@ -952,7 +935,7 @@ </widget> </item> <item> - <widget class="QGroupBox" name="GroupBox10"> + <widget class="QGroupBox" name="fontPathsGroup"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <horstretch>0</horstretch> @@ -978,28 +961,28 @@ <number>4</number> </property> <item row="1" column="0"> - <widget class="QPushButton" name="PushButton11"> + <widget class="QPushButton" name="upFontpathButton"> <property name="text"> <string>Up</string> </property> </widget> </item> <item row="1" column="2"> - <widget class="QPushButton" name="PushButton13"> + <widget class="QPushButton" name="removeFontpathButton"> <property name="text"> <string>Remove</string> </property> </widget> </item> <item row="1" column="1"> - <widget class="QPushButton" name="PushButton12"> + <widget class="QPushButton" name="downFontpathButton"> <property name="text"> <string>Down</string> </property> </widget> </item> <item row="0" column="0" colspan="3"> - <widget class="Q3ListBox" name="fontpathlistbox"/> + <widget class="QListWidget" name="fontpathListBox"/> </item> </layout> </item> @@ -1028,28 +1011,28 @@ </spacer> </item> <item row="2" column="2"> - <widget class="QPushButton" name="PushButton15"> + <widget class="QPushButton" name="addFontPathButton"> <property name="text"> <string>Add</string> </property> </widget> </item> <item row="2" column="1"> - <widget class="QPushButton" name="PushButton14"> + <widget class="QPushButton" name="browseFontPathButton"> <property name="text"> <string>Browse...</string> </property> </widget> </item> <item row="0" column="0" colspan="3"> - <widget class="QLabel" name="TextLabel15_2"> + <widget class="QLabel" name="browseFontPathLabel"> <property name="text"> <string>Press the <b>Browse</b> button or enter a directory and press Enter to add them to the list.</string> </property> </widget> </item> <item row="1" column="0" colspan="3"> - <widget class="QLineEdit" name="fontpathlineedit"/> + <widget class="QLineEdit" name="fontPathLineEdit"/> </item> </layout> </item> @@ -1058,19 +1041,19 @@ </item> </layout> </widget> - <widget class="QWidget" name="tab4"> + <widget class="QWidget" name="phononTab"> <attribute name="title"> <string>Phonon</string> </attribute> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QGroupBox" name="groupBox_4"> + <widget class="QGroupBox" name="aboutPhononGroup"> <property name="title"> <string>About Phonon</string> </property> <layout class="QGridLayout" name="gridLayout_2"> <item row="0" column="0"> - <widget class="QLabel" name="label_7"> + <widget class="QLabel" name="phononVersionBuddyLabel"> <property name="text"> <string>Current Version:</string> </property> @@ -1084,20 +1067,16 @@ </widget> </item> <item row="1" column="0"> - <widget class="QLabel" name="label_5"> + <widget class="QLabel" name="phononWebsiteBuddyLabel"> <property name="text"> <string>Website:</string> </property> </widget> </item> <item row="1" column="1"> - <widget class="QLabel" name="gstversionLabel_3"> + <widget class="QLabel" name="phononWebsiteLabel"> <property name="text"> - <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://phonon.kde.org"><span style=" text-decoration: underline; color:#0000ff;">http://phonon.kde.org</span></a></p></body></html></string> + <string><a href="http://phonon.kde.org">http://phonon.kde.org/</a></string> </property> <property name="openExternalLinks"> <bool>true</bool> @@ -1108,40 +1087,36 @@ p, li { white-space: pre-wrap; } </widget> </item> <item> - <widget class="QGroupBox" name="groupBox_3"> + <widget class="QGroupBox" name="aboutGStreamerGroup"> <property name="title"> <string>About GStreamer</string> </property> <layout class="QGridLayout"> <item row="0" column="0"> - <widget class="QLabel" name="label_3"> + <widget class="QLabel" name="gstVersionBuddyLabel"> <property name="text"> <string>Current Version:</string> </property> </widget> </item> <item row="0" column="1"> - <widget class="QLabel" name="gstversionLabel"> + <widget class="QLabel" name="gstVersionLabel"> <property name="text"> <string>Not available</string> </property> </widget> </item> <item row="1" column="0"> - <widget class="QLabel" name="label_4"> + <widget class="QLabel" name="gstWebsiteBuddyLabel"> <property name="text"> <string>Website:</string> </property> </widget> </item> <item row="1" column="1"> - <widget class="QLabel" name="gstversionLabel_2"> + <widget class="QLabel" name="gstWebsiteLabel"> <property name="text"> - <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://gstreamer.freedesktop.org/"><span style=" text-decoration: underline; color:#0000ff;">http://gstreamer.freedesktop.org/</span></a></p></body></html></string> + <string><a href="http://gstreamer.freedesktop.org/">http://gstreamer.freedesktop.org/</a></string> </property> <property name="openExternalLinks"> <bool>true</bool> @@ -1152,13 +1127,13 @@ p, li { white-space: pre-wrap; } </widget> </item> <item> - <widget class="QGroupBox" name="groupBox"> + <widget class="QGroupBox" name="gstBackendGroup"> <property name="title"> <string>GStreamer backend settings</string> </property> <layout class="QGridLayout" name="gridLayout_3"> <item row="0" column="0"> - <widget class="QLabel" name="label"> + <widget class="QLabel" name="audiosinkLabel"> <property name="text"> <string>Preferred audio sink:</string> </property> @@ -1171,7 +1146,7 @@ p, li { white-space: pre-wrap; } <widget class="QComboBox" name="audiosinkCombo"/> </item> <item row="1" column="0"> - <widget class="QLabel" name="label_2"> + <widget class="QLabel" name="videomodeLabel"> <property name="text"> <string>Preferred render method:</string> </property> @@ -1184,7 +1159,7 @@ p, li { white-space: pre-wrap; } <widget class="QComboBox" name="videomodeCombo"/> </item> <item row="2" column="0" colspan="2"> - <widget class="QLabel" name="label_6"> + <widget class="QLabel" name="gstBackendNoteLabel"> <property name="text"> <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> @@ -1235,41 +1210,38 @@ p, li { white-space: pre-wrap; } </item> </layout> </widget> - <widget class="QMenuBar" name="menubar"> + <widget class="QMenuBar" name="mainMenu"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>815</width> - <height>26</height> + <height>19</height> </rect> </property> - <widget class="QMenu" name="PopupMenu"> + <widget class="QMenu" name="fileMenu"> <property name="geometry"> <rect> - <x>0</x> - <y>0</y> - <width>123</width> - <height>92</height> + <x>203</x> + <y>114</y> + <width>161</width> + <height>110</height> </rect> </property> <property name="title"> <string>&File</string> </property> - <action name=""/> - <action name=""/> - <action name=""/> <addaction name="fileSaveAction"/> <addaction name="separator"/> <addaction name="fileExitAction"/> </widget> - <widget class="QMenu" name="PopupMenu_2"> + <widget class="QMenu" name="saveMenu"> <property name="geometry"> <rect> - <x>0</x> - <y>0</y> - <width>123</width> - <height>90</height> + <x>543</x> + <y>98</y> + <width>161</width> + <height>106</height> </rect> </property> <property name="title"> @@ -1278,12 +1250,9 @@ p, li { white-space: pre-wrap; } <addaction name="helpAboutAction"/> <addaction name="helpAboutQtAction"/> </widget> - <action name=""/> - <action name=""/> - <action name=""/> - <addaction name="PopupMenu"/> + <addaction name="fileMenu"/> <addaction name="separator"/> - <addaction name="PopupMenu_2"/> + <addaction name="saveMenu"/> </widget> <action name="fileSaveAction"> <property name="text"> @@ -1304,7 +1273,7 @@ p, li { white-space: pre-wrap; } <string>Exit</string> </property> <property name="shortcut"> - <string/> + <string>Ctrl+Q</string> </property> </action> <action name="helpAboutAction"> @@ -1329,23 +1298,6 @@ p, li { white-space: pre-wrap; } </widget> <customwidgets> <customwidget> - <class>Q3Frame</class> - <extends>QFrame</extends> - <header>Qt3Support/Q3Frame</header> - <container>1</container> - </customwidget> - <customwidget> - <class>Q3MainWindow</class> - <extends>QWidget</extends> - <header>q3mainwindow.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>Q3ListBox</class> - <extends>Q3Frame</extends> - <header>q3listbox.h</header> - </customwidget> - <customwidget> <class>ColorButton</class> <extends></extends> <header>colorbutton.h</header> @@ -1357,28 +1309,80 @@ p, li { white-space: pre-wrap; } </customwidget> </customwidgets> <tabstops> - <tabstop>helpview</tabstop> - <tabstop>familycombo</tabstop> - <tabstop>stylecombo</tabstop> - <tabstop>psizecombo</tabstop> - <tabstop>samplelineedit</tabstop> - <tabstop>familysubcombo</tabstop> - <tabstop>PushButton2</tabstop> - <tabstop>PushButton3</tabstop> - <tabstop>PushButton4</tabstop> - <tabstop>choosesubcombo</tabstop> - <tabstop>PushButton1</tabstop> - <tabstop>dcispin</tabstop> - <tabstop>cfispin</tabstop> - <tabstop>wslspin</tabstop> - <tabstop>effectcheckbox</tabstop> - <tabstop>menueffect</tabstop> - <tabstop>comboeffect</tabstop> - <tabstop>tooltipeffect</tabstop> - <tabstop>strutwidth</tabstop> - <tabstop>strutheight</tabstop> - <tabstop>sublistbox</tabstop> + <tabstop>helpView</tabstop> + <tabstop>mainTabWidget</tabstop> + <tabstop>guiStyleCombo</tabstop> + <tabstop>tunePaletteButton</tabstop> + <tabstop>paletteCombo</tabstop> + <tabstop>fontFamilyCombo</tabstop> + <tabstop>fontStyleCombo</tabstop> + <tabstop>pointSizeCombo</tabstop> + <tabstop>sampleLineEdit</tabstop> + <tabstop>familySubstitutionCombo</tabstop> + <tabstop>substitutionsListBox</tabstop> + <tabstop>upSubstitutionButton</tabstop> + <tabstop>downSubstitutionButton</tabstop> + <tabstop>removeSubstitutionButton</tabstop> + <tabstop>chooseSubstitutionCombo</tabstop> + <tabstop>addSubstitutionButton</tabstop> + <tabstop>doubleClickIntervalSpinBox</tabstop> + <tabstop>cursorFlashTimeSpinBox</tabstop> + <tabstop>wheelScrollLinesSpinBox</tabstop> + <tabstop>resolveLinksCheckBox</tabstop> + <tabstop>effectsCheckBox</tabstop> + <tabstop>menuEffectCombo</tabstop> + <tabstop>comboEffectCombo</tabstop> + <tabstop>toolTipEffectCombo</tabstop> + <tabstop>toolBoxEffectCombo</tabstop> + <tabstop>strutWidthSpinBox</tabstop> + <tabstop>strutHeightSpinBox</tabstop> + <tabstop>rtlExtensionsCheckBox</tabstop> + <tabstop>inputStyleCombo</tabstop> + <tabstop>inputMethodCombo</tabstop> + <tabstop>fontEmbeddingCheckBox</tabstop> + <tabstop>fontpathListBox</tabstop> + <tabstop>upFontpathButton</tabstop> + <tabstop>downFontpathButton</tabstop> + <tabstop>removeFontpathButton</tabstop> + <tabstop>fontPathLineEdit</tabstop> + <tabstop>browseFontPathButton</tabstop> + <tabstop>addFontPathButton</tabstop> + <tabstop>audiosinkCombo</tabstop> + <tabstop>videomodeCombo</tabstop> </tabstops> <resources/> - <connections/> + <connections> + <connection> + <sender>effectsCheckBox</sender> + <signal>toggled(bool)</signal> + <receiver>effectsFrame</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>417</x> + <y>257</y> + </hint> + <hint type="destinationlabel"> + <x>578</x> + <y>379</y> + </hint> + </hints> + </connection> + <connection> + <sender>fontEmbeddingCheckBox</sender> + <signal>toggled(bool)</signal> + <receiver>fontPathsGroup</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>449</x> + <y>69</y> + </hint> + <hint type="destinationlabel"> + <x>447</x> + <y>94</y> + </hint> + </hints> + </connection> + </connections> </ui> diff --git a/tools/qtconfig/mainwindowbase.cpp b/tools/qtconfig/mainwindowbase.cpp deleted file mode 100644 index efca58b..0000000 --- a/tools/qtconfig/mainwindowbase.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications 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 "mainwindowbase.h" -#include "colorbutton.h" -#include "previewframe.h" - -#include <QVariant> -#include <QImage> -#include <QPixmap> - -QT_BEGIN_NAMESPACE - -/* - * Constructs a MainWindowBase as a child of 'parent', with the - * name 'name' and widget flags set to 'f'. - * - */ -MainWindowBase::MainWindowBase(QWidget* parent, const char* name, Qt::WindowFlags fl) - : Q3MainWindow(parent, name, fl) -{ - setupUi(this); - - (void)statusBar(); - - // signals and slots connections - connect(fontpathlineedit, SIGNAL(returnPressed()), this, SLOT(addFontpath())); - connect(PushButton15, SIGNAL(clicked()), this, SLOT(addFontpath())); - connect(PushButton1, SIGNAL(clicked()), this, SLOT(addSubstitute())); - connect(PushButton14, SIGNAL(clicked()), this, SLOT(browseFontpath())); - connect(stylecombo, SIGNAL(activated(int)), this, SLOT(buildFont())); - connect(psizecombo, SIGNAL(activated(int)), this, SLOT(buildFont())); - connect(PushButton12, SIGNAL(clicked()), this, SLOT(downFontpath())); - connect(PushButton3, SIGNAL(clicked()), this, SLOT(downSubstitute())); - connect(familycombo, SIGNAL(activated(QString)), this, SLOT(familySelected(QString))); - connect(fileExitAction, SIGNAL(activated()), this, SLOT(fileExit())); - connect(fileSaveAction, SIGNAL(activated()), this, SLOT(fileSave())); - connect(helpAboutAction, SIGNAL(activated()), this, SLOT(helpAbout())); - connect(helpAboutQtAction, SIGNAL(activated()), this, SLOT(helpAboutQt())); - connect(TabWidget3, SIGNAL(currentChanged(QWidget*)), this, SLOT(pageChanged(QWidget*))); - connect(paletteCombo, SIGNAL(activated(int)), this, SLOT(paletteSelected(int))); - connect(PushButton13, SIGNAL(clicked()), this, SLOT(removeFontpath())); - connect(PushButton4, SIGNAL(clicked()), this, SLOT(removeSubstitute())); - connect(effectcheckbox, SIGNAL(toggled(bool)), effectbase, SLOT(setEnabled(bool))); - connect(fontembeddingcheckbox, SIGNAL(toggled(bool)), GroupBox10, SLOT(setEnabled(bool))); - connect(toolboxeffect, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(dcispin, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); - connect(cfispin, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); - connect(wslspin, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); - connect(menueffect, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(comboeffect, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(audiosinkCombo, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(videomodeCombo, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(tooltipeffect, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(strutwidth, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); - connect(strutheight, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); - connect(effectcheckbox, SIGNAL(toggled(bool)), this, SLOT(somethingModified())); - connect(resolvelinks, SIGNAL(toggled(bool)), this, SLOT(somethingModified())); - connect(fontembeddingcheckbox, SIGNAL(clicked()), this, SLOT(somethingModified())); - connect(rtlExtensions, SIGNAL(toggled(bool)), this, SLOT(somethingModified())); - connect(inputStyle, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(inputMethod, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(gstylecombo, SIGNAL(activated(QString)), this, SLOT(styleSelected(QString))); - connect(familysubcombo, SIGNAL(activated(QString)), this, SLOT(substituteSelected(QString))); - connect(btnAdvanced, SIGNAL(clicked()), this, SLOT(tunePalette())); - connect(PushButton11, SIGNAL(clicked()), this, SLOT(upFontpath())); - connect(PushButton2, SIGNAL(clicked()), this, SLOT(upSubstitute())); - init(); -} - -/* - * Destroys the object and frees any allocated resources - */ -MainWindowBase::~MainWindowBase() -{ - destroy(); - // no need to delete child widgets, Qt does it all for us -} - -/* - * Sets the strings of the subwidgets using the current - * language. - */ -void MainWindowBase::languageChange() -{ - retranslateUi(this); -} - -void MainWindowBase::init() -{ -} - -void MainWindowBase::destroy() -{ -} - -void MainWindowBase::addFontpath() -{ - qWarning("MainWindowBase::addFontpath(): Not implemented yet"); -} - -void MainWindowBase::addSubstitute() -{ - qWarning("MainWindowBase::addSubstitute(): Not implemented yet"); -} - -void MainWindowBase::browseFontpath() -{ - qWarning("MainWindowBase::browseFontpath(): Not implemented yet"); -} - -void MainWindowBase::buildFont() -{ - qWarning("MainWindowBase::buildFont(): Not implemented yet"); -} - -void MainWindowBase::buildPalette() -{ - qWarning("MainWindowBase::buildPalette(): Not implemented yet"); -} - -void MainWindowBase::downFontpath() -{ - qWarning("MainWindowBase::downFontpath(): Not implemented yet"); -} - -void MainWindowBase::downSubstitute() -{ - qWarning("MainWindowBase::downSubstitute(): Not implemented yet"); -} - -void MainWindowBase::familySelected( const QString &) -{ - qWarning("MainWindowBase::familySelected( const QString &): Not implemented yet"); -} - -void MainWindowBase::fileExit() -{ - qWarning("MainWindowBase::fileExit(): Not implemented yet"); -} - -void MainWindowBase::fileSave() -{ - qWarning("MainWindowBase::fileSave(): Not implemented yet"); -} - -void MainWindowBase::helpAbout() -{ - qWarning("MainWindowBase::helpAbout(): Not implemented yet"); -} - -void MainWindowBase::helpAboutQt() -{ - qWarning("MainWindowBase::helpAboutQt(): Not implemented yet"); -} - -void MainWindowBase::new_slot() -{ - qWarning("MainWindowBase::new_slot(): Not implemented yet"); -} - -void MainWindowBase::pageChanged( QWidget *) -{ - qWarning("MainWindowBase::pageChanged( QWidget *): Not implemented yet"); -} - -void MainWindowBase::paletteSelected(int) -{ - qWarning("MainWindowBase::paletteSelected(int): Not implemented yet"); -} - -void MainWindowBase::removeFontpath() -{ - qWarning("MainWindowBase::removeFontpath(): Not implemented yet"); -} - -void MainWindowBase::removeSubstitute() -{ - qWarning("MainWindowBase::removeSubstitute(): Not implemented yet"); -} - -void MainWindowBase::somethingModified() -{ - qWarning("MainWindowBase::somethingModified(): Not implemented yet"); -} - -void MainWindowBase::styleSelected( const QString &) -{ - qWarning("MainWindowBase::styleSelected( const QString &): Not implemented yet"); -} - -void MainWindowBase::substituteSelected( const QString &) -{ - qWarning("MainWindowBase::substituteSelected( const QString &): Not implemented yet"); -} - -void MainWindowBase::tunePalette() -{ - qWarning("MainWindowBase::tunePalette(): Not implemented yet"); -} - -void MainWindowBase::upFontpath() -{ - qWarning("MainWindowBase::upFontpath(): Not implemented yet"); -} - -void MainWindowBase::upSubstitute() -{ - qWarning("MainWindowBase::upSubstitute(): Not implemented yet"); -} - -QT_END_NAMESPACE diff --git a/tools/qtconfig/mainwindowbase.h b/tools/qtconfig/mainwindowbase.h deleted file mode 100644 index 97c6716..0000000 --- a/tools/qtconfig/mainwindowbase.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications 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 MAINWINDOWBASE_H -#define MAINWINDOWBASE_H - -#include "ui_mainwindowbase.h" -#include <QVariant> - -QT_BEGIN_NAMESPACE - -class ColorButton; -class PreviewFrame; - -class MainWindowBase : public Q3MainWindow, public Ui::MainWindowBase -{ - Q_OBJECT - -public: - MainWindowBase(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = Qt::Window); - ~MainWindowBase(); - -public slots: - virtual void addFontpath(); - virtual void addSubstitute(); - virtual void browseFontpath(); - virtual void buildFont(); - virtual void buildPalette(); - virtual void downFontpath(); - virtual void downSubstitute(); - virtual void familySelected( const QString & ); - virtual void fileExit(); - virtual void fileSave(); - virtual void helpAbout(); - virtual void helpAboutQt(); - virtual void new_slot(); - virtual void pageChanged( QWidget * ); - virtual void paletteSelected( int ); - virtual void removeFontpath(); - virtual void removeSubstitute(); - virtual void somethingModified(); - virtual void styleSelected( const QString & ); - virtual void substituteSelected( const QString & ); - virtual void tunePalette(); - virtual void upFontpath(); - virtual void upSubstitute(); - -protected slots: - virtual void languageChange(); - - virtual void init(); - virtual void destroy(); -}; - -QT_END_NAMESPACE - -#endif // MAINWINDOWBASE_H diff --git a/tools/qtconfig/paletteeditoradvanced.cpp b/tools/qtconfig/paletteeditoradvanced.cpp index 5f28413..4797ead 100644 --- a/tools/qtconfig/paletteeditoradvanced.cpp +++ b/tools/qtconfig/paletteeditoradvanced.cpp @@ -38,58 +38,74 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +#include "ui_paletteeditoradvanced.h" #include "paletteeditoradvanced.h" #include "colorbutton.h" -#include <QCheckBox> -#include <QComboBox> -#include <QApplication> -#include <QPushButton> -#include <QPainter> -#include <QGroupBox> - QT_BEGIN_NAMESPACE -PaletteEditorAdvanced::PaletteEditorAdvanced( QWidget * parent, - const char * name, bool modal, Qt::WindowFlags f ) - : PaletteEditorAdvancedBase( parent, name, modal, f ), selectedPalette(0) +PaletteEditorAdvanced::PaletteEditorAdvanced(QWidget *parent) + : QDialog(parent), ui(new Ui::PaletteEditorAdvanced), selectedPalette(0) { - // work around buggy UI file - comboEffect->setEnabled(false); + ui->setupUi(this); + + // create a ColorButton's + buttonCentral = new ColorButton(ui->groupCentral); + buttonCentral->setToolTip(tr("Choose a color")); + buttonCentral->setWhatsThis(tr("Choose a color for the selected central color role.")); + ui->layoutCentral->addWidget(buttonCentral); + ui->labelCentral->setBuddy(buttonCentral); + + buttonEffect = new ColorButton(ui->groupEffect); + buttonEffect->setToolTip(tr("Choose a color")); + buttonEffect->setWhatsThis(tr("Choose a color for the selected effect color role.")); buttonEffect->setEnabled(false); + ui->layoutEffect->addWidget(buttonEffect); + ui->labelEffect->setBuddy(buttonEffect); + + // signals and slots connections + connect(ui->paletteCombo, SIGNAL(activated(int)), SLOT(paletteSelected(int))); + connect(ui->comboCentral, SIGNAL(activated(int)), SLOT(onCentral(int))); + connect(buttonCentral, SIGNAL(clicked()), SLOT(onChooseCentralColor())); + connect(buttonEffect, SIGNAL(clicked()), SLOT(onChooseEffectColor())); + connect(ui->comboEffect, SIGNAL(activated(int)), SLOT(onEffect(int))); + connect(ui->checkBuildEffect, SIGNAL(toggled(bool)), SLOT(onToggleBuildEffects(bool))); + connect(ui->checkBuildEffect, SIGNAL(toggled(bool)), buttonEffect, SLOT(setDisabled(bool))); + connect(ui->checkBuildInactive, SIGNAL(toggled(bool)), SLOT(onToggleBuildInactive(bool))); + connect(ui->checkBuildDisabled, SIGNAL(toggled(bool)), SLOT(onToggleBuildDisabled(bool))); + onToggleBuildEffects(true); editPalette = QApplication::palette(); - setPreviewPalette( editPalette ); } PaletteEditorAdvanced::~PaletteEditorAdvanced() { + delete ui; } -void PaletteEditorAdvanced::onToggleBuildInactive( bool v ) +void PaletteEditorAdvanced::onToggleBuildInactive(bool v) { if (selectedPalette == 1) { - groupCentral->setDisabled(v); - groupEffect->setDisabled(v); + ui->groupCentral->setDisabled(v); + ui->groupEffect->setDisabled(v); } if (v) { - buildInactive(); + build(QPalette::Inactive); updateColorButtons(); } } -void PaletteEditorAdvanced::onToggleBuildDisabled( bool v ) +void PaletteEditorAdvanced::onToggleBuildDisabled(bool v) { if (selectedPalette == 2) { - groupCentral->setDisabled(v); - groupEffect->setDisabled(v); + ui->groupCentral->setDisabled(v); + ui->groupEffect->setDisabled(v); } if (v) { - buildDisabled(); + build(QPalette::Disabled); updateColorButtons(); } } @@ -99,402 +115,204 @@ void PaletteEditorAdvanced::paletteSelected(int p) selectedPalette = p; if(p == 1) { // inactive - groupCentral->setDisabled(checkBuildInactive->isChecked()); - groupEffect->setDisabled(checkBuildInactive->isChecked()); - } - else if (p == 2) { // disabled - groupCentral->setDisabled(checkBuildDisabled->isChecked()); - groupEffect->setDisabled(checkBuildDisabled->isChecked()); - } - else { - groupCentral->setEnabled(true); - groupEffect->setEnabled(true); + ui->groupCentral->setDisabled(ui->checkBuildInactive->isChecked()); + ui->groupEffect->setDisabled(ui->checkBuildInactive->isChecked()); + } else if (p == 2) { // disabled + ui->groupCentral->setDisabled(ui->checkBuildDisabled->isChecked()); + ui->groupEffect->setDisabled(ui->checkBuildDisabled->isChecked()); + } else { + ui->groupCentral->setEnabled(true); + ui->groupEffect->setEnabled(true); } updateColorButtons(); } void PaletteEditorAdvanced::onChooseCentralColor() { - switch(selectedPalette) { - case 0: - default: - mapToActiveCentralRole( buttonCentral->color() ); - break; - case 1: - mapToInactiveCentralRole( buttonCentral->color() ); - break; - case 2: - mapToDisabledCentralRole( buttonCentral->color() ); - break; + QPalette::ColorGroup group = groupFromIndex(selectedPalette); + editPalette.setColor(group, centralFromIndex(ui->comboCentral->currentIndex()), + buttonCentral->color()); + + buildEffect(group); + if (group == QPalette::Active) { + if(ui->checkBuildInactive->isChecked()) + build(QPalette::Inactive); + if(ui->checkBuildDisabled->isChecked()) + build(QPalette::Disabled); } + updateColorButtons(); } void PaletteEditorAdvanced::onChooseEffectColor() { - switch(selectedPalette) { - case 0: - default: - mapToActiveEffectRole( buttonEffect->color() ); - break; - case 1: - mapToInactiveEffectRole( buttonEffect->color() ); - break; - case 2: - mapToDisabledEffectRole( buttonEffect->color() ); - break; + QPalette::ColorGroup group = groupFromIndex(selectedPalette); + editPalette.setColor(group, effectFromIndex(ui->comboEffect->currentIndex()), + buttonEffect->color()); + + if (group == QPalette::Active) { + if(ui->checkBuildInactive->isChecked()) + build(QPalette::Inactive); + if(ui->checkBuildDisabled->isChecked()) + build(QPalette::Disabled); } - updateColorButtons(); -} -void PaletteEditorAdvanced::onToggleBuildEffects( bool on ) -{ - if (!on) return; - buildActiveEffect(); - buildInactiveEffect(); - buildDisabledEffect(); + updateColorButtons(); } -QColorGroup::ColorRole PaletteEditorAdvanced::centralFromItem( int item ) +void PaletteEditorAdvanced::onToggleBuildEffects(bool on) { - switch( item ) { - case 0: - return QColorGroup::Window; - case 1: - return QColorGroup::WindowText; - case 2: - return QColorGroup::Button; - case 3: - return QColorGroup::Base; - case 4: - return QColorGroup::Text; - case 5: - return QColorGroup::BrightText; - case 6: - return QColorGroup::ButtonText; - case 7: - return QColorGroup::Highlight; - case 8: - return QColorGroup::HighlightedText; - default: - return QColorGroup::NColorRoles; + if (on) { + for (int i = 0; i < QPalette::NColorGroups; i++) + buildEffect(QPalette::ColorGroup(i)); } } -QColorGroup::ColorRole PaletteEditorAdvanced::effectFromItem( int item ) - +QPalette::ColorGroup PaletteEditorAdvanced::groupFromIndex(int item) { - switch( item ) { + switch (item) { case 0: - return QColorGroup::Light; + default: + return QPalette::Active; case 1: - return QColorGroup::Midlight; + return QPalette::Inactive; case 2: - return QColorGroup::Mid; - case 3: - return QColorGroup::Dark; - case 4: - return QColorGroup::Shadow; - default: - return QColorGroup::NColorRoles; + return QPalette::Disabled; } } -void PaletteEditorAdvanced::onCentral( int item ) +QPalette::ColorRole PaletteEditorAdvanced::centralFromIndex(int item) { - QColor c; - - switch(selectedPalette) { + switch (item) { case 0: - default: - c = editPalette.active().color( centralFromItem(item) ); - break; + return QPalette::Window; case 1: - c = editPalette.inactive().color( centralFromItem(item) ); - break; + return QPalette::WindowText; case 2: - c = editPalette.disabled().color( centralFromItem(item) ); - break; + return QPalette::Base; + case 3: + return QPalette::AlternateBase; + case 4: + return QPalette::ToolTipBase; + case 5: + return QPalette::ToolTipText; + case 6: + return QPalette::Text; + case 7: + return QPalette::Button; + case 8: + return QPalette::ButtonText; + case 9: + return QPalette::BrightText; + case 10: + return QPalette::Highlight; + case 11: + return QPalette::HighlightedText; + case 12: + return QPalette::Link; + case 13: + return QPalette::LinkVisited; + default: + return QPalette::NoRole; } - - buttonCentral->setColor(c); } -void PaletteEditorAdvanced::onEffect( int item ) +QPalette::ColorRole PaletteEditorAdvanced::effectFromIndex(int item) { - QColor c; - switch(selectedPalette) { + switch (item) { case 0: - default: - c = editPalette.active().color( effectFromItem(item) ); - break; + return QPalette::Light; case 1: - editPalette.inactive().color( effectFromItem(item) ); - break; + return QPalette::Midlight; case 2: - editPalette.disabled().color( effectFromItem(item) ); - break; + return QPalette::Mid; + case 3: + return QPalette::Dark; + case 4: + return QPalette::Shadow; + default: + return QPalette::NoRole; } - buttonEffect->setColor(c); -} - -void PaletteEditorAdvanced::mapToActiveCentralRole( const QColor& c ) -{ - QColorGroup cg = editPalette.active(); - cg.setColor( centralFromItem(comboCentral->currentItem()), c ); - editPalette.setActive( cg ); - - buildActiveEffect(); - if(checkBuildInactive->isChecked()) - buildInactive(); - if(checkBuildDisabled->isChecked()) - buildDisabled(); - - setPreviewPalette( editPalette ); -} - -void PaletteEditorAdvanced::mapToActiveEffectRole( const QColor& c ) -{ - QColorGroup cg = editPalette.active(); - cg.setColor( effectFromItem(comboEffect->currentItem()), c ); - editPalette.setActive( cg ); - - if(checkBuildInactive->isChecked()) - buildInactive(); - if(checkBuildDisabled->isChecked()) - buildDisabled(); - - setPreviewPalette( editPalette ); -} - -void PaletteEditorAdvanced::mapToActivePixmapRole( const QPixmap& pm ) -{ - QColorGroup::ColorRole role = centralFromItem(comboCentral->currentItem()); - QColorGroup cg = editPalette.active(); - if ( !pm.isNull() ) - cg.setBrush( role, QBrush( cg.color( role ), pm ) ); - else - cg.setBrush( role, QBrush( cg.color( role ) ) ); - editPalette.setActive( cg ); - - - buildActiveEffect(); - if(checkBuildInactive->isChecked()) - buildInactive(); - if(checkBuildDisabled->isChecked()) - buildDisabled(); - - setPreviewPalette( editPalette ); -} - -void PaletteEditorAdvanced::mapToInactiveCentralRole( const QColor& c ) -{ - QColorGroup cg = editPalette.inactive(); - cg.setColor( centralFromItem(comboCentral->currentItem()), c ); - editPalette.setInactive( cg ); - - buildInactiveEffect(); - - setPreviewPalette( editPalette ); } -void PaletteEditorAdvanced::mapToInactiveEffectRole( const QColor& c ) +void PaletteEditorAdvanced::onCentral(int item) { - QColorGroup cg = editPalette.inactive(); - cg.setColor( effectFromItem(comboEffect->currentItem()), c ); - editPalette.setInactive( cg ); - - setPreviewPalette( editPalette ); -} - -void PaletteEditorAdvanced::mapToInactivePixmapRole( const QPixmap& pm ) -{ - QColorGroup::ColorRole role = centralFromItem(comboCentral->currentItem()); - QColorGroup cg = editPalette.inactive(); - if ( !pm.isNull() ) - cg.setBrush( role, QBrush( cg.color( role ), pm ) ); - else - cg.setBrush( role, QBrush( cg.color( role ) ) ); - editPalette.setInactive( cg ); - - setPreviewPalette( editPalette ); -} - -void PaletteEditorAdvanced::mapToDisabledCentralRole( const QColor& c ) -{ - QColorGroup cg = editPalette.disabled(); - cg.setColor( centralFromItem(comboCentral->currentItem()), c ); - editPalette.setDisabled( cg ); - - buildDisabledEffect(); - - setPreviewPalette( editPalette ); -} - -void PaletteEditorAdvanced::mapToDisabledEffectRole( const QColor& c ) -{ - QColorGroup cg = editPalette.disabled(); - cg.setColor( effectFromItem(comboEffect->currentItem()), c ); - editPalette.setDisabled( cg ); - - setPreviewPalette( editPalette ); + QColor c = editPalette.color(groupFromIndex(selectedPalette), centralFromIndex(item)); + buttonCentral->setColor(c); } -void PaletteEditorAdvanced::mapToDisabledPixmapRole( const QPixmap& pm ) +void PaletteEditorAdvanced::onEffect(int item) { - QColorGroup::ColorRole role = centralFromItem(comboCentral->currentItem()); - QColorGroup cg = editPalette.disabled(); - if ( !pm.isNull() ) - cg.setBrush( role, QBrush( cg.color( role ), pm ) ); - else - cg.setBrush( role, QBrush( cg.color( role ) ) ); - - editPalette.setDisabled( cg ); - - setPreviewPalette( editPalette ); + QColor c = editPalette.color(groupFromIndex(selectedPalette), effectFromIndex(item)); + buttonEffect->setColor(c); } -void PaletteEditorAdvanced::buildActiveEffect() +QPalette PaletteEditorAdvanced::buildEffect(QPalette::ColorGroup colorGroup, + const QPalette &basePalette) { - QColorGroup cg = editPalette.active(); - QColor btn = cg.color( QColorGroup::Button ); - - QPalette temp( btn, btn ); - - for (int i = 0; i<5; i++) - cg.setColor( effectFromItem(i), temp.active().color( effectFromItem(i) ) ); + QPalette result(basePalette); - editPalette.setActive( cg ); - setPreviewPalette( editPalette ); + if (colorGroup == QPalette::Active) { + QPalette calculatedPalette(basePalette.color(colorGroup, QPalette::Button), + basePalette.color(colorGroup, QPalette::Window)); - updateColorButtons(); -} + for (int i = 0; i < 5; i++) { + QPalette::ColorRole effectRole = effectFromIndex(i); + result.setColor(colorGroup, effectRole, + calculatedPalette.color(colorGroup, effectRole)); + } + } else { + QColor btn = basePalette.color(colorGroup, QPalette::Button); -void PaletteEditorAdvanced::buildInactive() -{ - editPalette.setInactive( editPalette.active() ); - if ( checkBuildEffect->isChecked() ) - buildInactiveEffect(); - else { - setPreviewPalette( editPalette ); - updateColorButtons(); + result.setColor(colorGroup, QPalette::Light, btn.lighter()); + result.setColor(colorGroup, QPalette::Midlight, btn.lighter(115)); + result.setColor(colorGroup, QPalette::Mid, btn.darker(150)); + result.setColor(colorGroup, QPalette::Dark, btn.darker()); + result.setColor(colorGroup, QPalette::Shadow, Qt::black); } + return result; } -void PaletteEditorAdvanced::buildInactiveEffect() +void PaletteEditorAdvanced::buildEffect(QPalette::ColorGroup colorGroup) { - QColorGroup cg = editPalette.inactive(); - - QColor light, midlight, mid, dark, shadow; - QColor btn = cg.color( QColorGroup::Button ); - - light = btn.light(150); - midlight = btn.light(115); - mid = btn.dark(150); - dark = btn.dark(); - shadow = Qt::black; - - cg.setColor( QColorGroup::Light, light ); - cg.setColor( QColorGroup::Midlight, midlight ); - cg.setColor( QColorGroup::Mid, mid ); - cg.setColor( QColorGroup::Dark, dark ); - cg.setColor( QColorGroup::Shadow, shadow ); - - editPalette.setInactive( cg ); - setPreviewPalette( editPalette ); + editPalette = buildEffect(colorGroup, editPalette); updateColorButtons(); } -void PaletteEditorAdvanced::buildDisabled() +void PaletteEditorAdvanced::build(QPalette::ColorGroup colorGroup) { - QColorGroup cg = editPalette.active(); - cg.setColor( QColorGroup::ButtonText, Qt::darkGray ); - cg.setColor( QColorGroup::WindowText, Qt::darkGray ); - cg.setColor( QColorGroup::Text, Qt::darkGray ); - cg.setColor( QColorGroup::HighlightedText, Qt::darkGray ); - editPalette.setDisabled( cg ); - - if ( checkBuildEffect->isChecked() ) - buildDisabledEffect(); - else { - setPreviewPalette( editPalette ); - updateColorButtons(); - } -} - -void PaletteEditorAdvanced::buildDisabledEffect() -{ - QColorGroup cg = editPalette.disabled(); - - QColor light, midlight, mid, dark, shadow; - QColor btn = cg.color( QColorGroup::Button ); - - light = btn.light(150); - midlight = btn.light(115); - mid = btn.dark(150); - dark = btn.dark(); - shadow = Qt::black; + if (colorGroup != QPalette::Active) { + for (int i = 0; i < QPalette::NColorRoles; i++) + editPalette.setColor(colorGroup, QPalette::ColorRole(i), + editPalette.color(QPalette::Active, QPalette::ColorRole(i))); - cg.setColor( QColorGroup::Light, light ); - cg.setColor( QColorGroup::Midlight, midlight ); - cg.setColor( QColorGroup::Mid, mid ); - cg.setColor( QColorGroup::Dark, dark ); - cg.setColor( QColorGroup::Shadow, shadow ); + if (colorGroup == QPalette::Disabled) { + editPalette.setColor(colorGroup, QPalette::ButtonText, Qt::darkGray); + editPalette.setColor(colorGroup, QPalette::WindowText, Qt::darkGray); + editPalette.setColor(colorGroup, QPalette::Text, Qt::darkGray); + editPalette.setColor(colorGroup, QPalette::HighlightedText, Qt::darkGray); + } - editPalette.setDisabled( cg ); - setPreviewPalette( editPalette ); - updateColorButtons(); -} - -void PaletteEditorAdvanced::setPreviewPalette( const QPalette& pal ) -{ - QColorGroup cg; - - switch (selectedPalette) { - case 0: - default: - cg = pal.active(); - break; - case 1: - cg = pal.inactive(); - break; - case 2: - cg = pal.disabled(); - break; + if (ui->checkBuildEffect->isChecked()) + buildEffect(colorGroup); + else + updateColorButtons(); } - previewPalette.setActive( cg ); - previewPalette.setInactive( cg ); - previewPalette.setDisabled( cg ); } void PaletteEditorAdvanced::updateColorButtons() { - QColor central, effect; - switch (selectedPalette) { - case 0: - default: - central = editPalette.active().color( centralFromItem( comboCentral->currentItem() ) ); - effect = editPalette.active().color( effectFromItem( comboEffect->currentItem() ) ); - break; - case 1: - central = editPalette.inactive().color( centralFromItem( comboCentral->currentItem() ) ); - effect = editPalette.inactive().color( effectFromItem( comboEffect->currentItem() ) ); - break; - case 2: - central = editPalette.disabled().color( centralFromItem( comboCentral->currentItem() ) ); - effect = editPalette.disabled().color( effectFromItem( comboEffect->currentItem() ) ); - break; - } - - buttonCentral->setColor(central); - buttonEffect->setColor(effect); + QPalette::ColorGroup colorGroup = groupFromIndex(selectedPalette); + buttonCentral->setColor(editPalette.color(colorGroup, + centralFromIndex(ui->comboCentral->currentIndex()))); + buttonEffect->setColor(editPalette.color(colorGroup, + effectFromIndex(ui->comboEffect->currentIndex()))); } -void PaletteEditorAdvanced::setPal( const QPalette& pal ) +void PaletteEditorAdvanced::setPal(const QPalette &pal) { editPalette = pal; - setPreviewPalette( pal ); updateColorButtons(); } @@ -503,51 +321,51 @@ QPalette PaletteEditorAdvanced::pal() const return editPalette; } -void PaletteEditorAdvanced::setupBackgroundMode( Qt::BackgroundMode mode ) +void PaletteEditorAdvanced::setupBackgroundRole(QPalette::ColorRole role) { int initRole = 0; - switch( mode ) { - case Qt::PaletteBackground: + switch (role) { + case QPalette::Window: initRole = 0; break; - case Qt::PaletteForeground: + case QPalette::WindowText: initRole = 1; break; - case Qt::PaletteButton: + case QPalette::Base: initRole = 2; break; - case Qt::PaletteBase: + case QPalette::AlternateBase: initRole = 3; break; - case Qt::PaletteText: + case QPalette::ToolTipBase: initRole = 4; break; - case Qt::PaletteBrightText: + case QPalette::ToolTipText: initRole = 5; break; - case Qt::PaletteButtonText: + case QPalette::Text: initRole = 6; break; - case Qt::PaletteHighlight: + case QPalette::Button: initRole = 7; break; - case Qt::PaletteHighlightedText: + case QPalette::ButtonText: initRole = 8; break; - case Qt::PaletteLight: + case QPalette::BrightText: initRole = 9; break; - case Qt::PaletteMidlight: + case QPalette::Highlight: initRole = 10; break; - case Qt::PaletteDark: + case QPalette::HighlightedText: initRole = 11; break; - case Qt::PaletteMid: + case QPalette::Link: initRole = 12; break; - case Qt::PaletteShadow: + case QPalette::LinkVisited: initRole = 13; break; default: @@ -555,36 +373,27 @@ void PaletteEditorAdvanced::setupBackgroundMode( Qt::BackgroundMode mode ) break; } - if ( initRole <= -1 ) return; - - if (initRole > 8 ) { - comboEffect->setCurrentItem( initRole - 9 ); - } - else { - comboCentral->setCurrentItem( initRole ); - } + if (initRole != -1) + ui->comboCentral->setCurrentIndex(initRole); } -QPalette PaletteEditorAdvanced::getPalette( bool *ok, const QPalette &init, - Qt::BackgroundMode mode, QWidget* parent, - const char* name ) +QPalette PaletteEditorAdvanced::getPalette(bool *ok, const QPalette &init, + QPalette::ColorRole backgroundRole, QWidget *parent) { - PaletteEditorAdvanced* dlg = new PaletteEditorAdvanced( parent, name, true ); - dlg->setupBackgroundMode( mode ); + PaletteEditorAdvanced *dlg = new PaletteEditorAdvanced(parent); + dlg->setupBackgroundRole(backgroundRole); - if ( init != QPalette() ) - dlg->setPal( init ); + if (init != QPalette()) + dlg->setPal(init); int resultCode = dlg->exec(); QPalette result = init; - if ( resultCode == QDialog::Accepted ) { - if ( ok ) - *ok = true; + if (resultCode == QDialog::Accepted) result = dlg->pal(); - } else { - if ( ok ) - *ok = false; - } + + if (ok) + *ok = resultCode; + delete dlg; return result; } diff --git a/tools/qtconfig/paletteeditoradvanced.h b/tools/qtconfig/paletteeditoradvanced.h index 83bcebb..4f61676 100644 --- a/tools/qtconfig/paletteeditoradvanced.h +++ b/tools/qtconfig/paletteeditoradvanced.h @@ -42,69 +42,65 @@ #ifndef PALETTEEDITORADVANCED_H #define PALETTEEDITORADVANCED_H -#include "paletteeditoradvancedbase.h" +#include <QtGui/QDialog> QT_BEGIN_NAMESPACE -class PaletteEditorAdvanced : public PaletteEditorAdvancedBase +namespace Ui { + class PaletteEditorAdvanced; +} + +class ColorButton; + +class PaletteEditorAdvanced : public QDialog { Q_OBJECT public: - PaletteEditorAdvanced( QWidget * parent=0, const char * name=0, - bool modal=false, Qt::WindowFlags f=0 ); + PaletteEditorAdvanced(QWidget *parent = 0); ~PaletteEditorAdvanced(); - static QPalette getPalette( bool *ok, const QPalette &pal, Qt::BackgroundMode mode = Qt::PaletteBackground, - QWidget* parent = 0, const char* name = 0 ); + static QPalette getPalette(bool *ok, const QPalette &pal, + QPalette::ColorRole backgroundRole = QPalette::Window, + QWidget *parent = 0); + + static QPalette buildEffect(QPalette::ColorGroup colorGroup, const QPalette &basePalette); protected slots: void paletteSelected(int); - void onCentral( int ); - void onEffect( int ); + void onCentral(int); + void onEffect(int); void onChooseCentralColor(); void onChooseEffectColor(); - void onToggleBuildEffects( bool ); - void onToggleBuildInactive( bool ); - void onToggleBuildDisabled( bool ); + void onToggleBuildEffects(bool); + void onToggleBuildInactive(bool); + void onToggleBuildDisabled(bool); protected: - void mapToActiveCentralRole( const QColor& ); - void mapToActiveEffectRole( const QColor& ); - void mapToActivePixmapRole( const QPixmap& ); - void mapToInactiveCentralRole( const QColor& ); - void mapToInactiveEffectRole( const QColor& ); - void mapToInactivePixmapRole( const QPixmap& ); - void mapToDisabledCentralRole( const QColor& ); - void mapToDisabledEffectRole( const QColor& ); - void mapToDisabledPixmapRole( const QPixmap& ); - - - void buildPalette(); - void buildActiveEffect(); - void buildInactive(); - void buildInactiveEffect(); - void buildDisabled(); - void buildDisabledEffect(); + void buildEffect(QPalette::ColorGroup); + void build(QPalette::ColorGroup); private: - void setPreviewPalette( const QPalette& ); void updateColorButtons(); - void setupBackgroundMode( Qt::BackgroundMode ); + void setupBackgroundRole(QPalette::ColorRole); QPalette pal() const; - void setPal( const QPalette& ); + void setPal(const QPalette &); - QColorGroup::ColorRole centralFromItem( int ); - QColorGroup::ColorRole effectFromItem( int ); + static QPalette::ColorGroup groupFromIndex(int); + static QPalette::ColorRole centralFromIndex(int); + static QPalette::ColorRole effectFromIndex(int); QPalette editPalette; - QPalette previewPalette; + + Ui::PaletteEditorAdvanced *ui; int selectedPalette; + ColorButton *buttonCentral; + ColorButton *buttonEffect; }; QT_END_NAMESPACE -#endif +#endif // PALETTEEDITORADVANCED_H diff --git a/tools/qtconfig/paletteeditoradvanced.ui b/tools/qtconfig/paletteeditoradvanced.ui new file mode 100644 index 0000000..0b4ae66 --- /dev/null +++ b/tools/qtconfig/paletteeditoradvanced.ui @@ -0,0 +1,416 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <comment>********************************************************************* +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools applications 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$ +** +*********************************************************************</comment> + <class>PaletteEditorAdvanced</class> + <widget class="QDialog" name="PaletteEditorAdvanced"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>239</width> + <height>344</height> + </rect> + </property> + <property name="windowTitle"> + <string>Tune Palette</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="paletteComboLabel"> + <property name="text"> + <string>Select &Palette:</string> + </property> + <property name="buddy"> + <cstring>paletteCombo</cstring> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="paletteCombo"> + <item> + <property name="text"> + <string>Active Palette</string> + </property> + </item> + <item> + <property name="text"> + <string>Inactive Palette</string> + </property> + </item> + <item> + <property name="text"> + <string>Disabled Palette</string> + </property> + </item> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QGroupBox" name="autoGroupBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Auto</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QCheckBox" name="checkBuildInactive"> + <property name="text"> + <string>Build inactive palette from active</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBuildDisabled"> + <property name="text"> + <string>Build disabled palette from active</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupCentral"> + <property name="title"> + <string>Central color &roles</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QComboBox" name="comboCentral"> + <property name="toolTip"> + <string>Choose central color role</string> + </property> + <property name="whatsThis"> + <string><b>Select a color role.</b><p>Available central roles are: <ul> <li>Window - general background color.</li> <li>WindowText - general foreground color. </li> <li>Base - used as background color for e.g. text entry widgets, usually white or another light color. </li> <li>Text - the foreground color used with Base. Usually this is the same as WindowText, in what case it must provide good contrast both with Window and Base. </li> <li>Button - general button background color, where buttons need a background different from Window, as in the Macintosh style. </li> <li>ButtonText - a foreground color used with the Button color. </li> <li>Highlight - a color to indicate a selected or highlighted item. </li> <li>HighlightedText - a text color that contrasts to Highlight. </li> <li>BrightText - a text color that is very different from WindowText and contrasts well with e.g. black. </li> </ul> </p></string> + </property> + <item> + <property name="text"> + <string>Window</string> + </property> + </item> + <item> + <property name="text"> + <string>WindowText</string> + </property> + </item> + <item> + <property name="text"> + <string>Base</string> + </property> + </item> + <item> + <property name="text"> + <string>AlternateBase</string> + </property> + </item> + <item> + <property name="text"> + <string>ToolTipBase</string> + </property> + </item> + <item> + <property name="text"> + <string>ToolTipText</string> + </property> + </item> + <item> + <property name="text"> + <string>Text</string> + </property> + </item> + <item> + <property name="text"> + <string>Button</string> + </property> + </item> + <item> + <property name="text"> + <string>ButtonText</string> + </property> + </item> + <item> + <property name="text"> + <string>BrightText</string> + </property> + </item> + <item> + <property name="text"> + <string>Highlight</string> + </property> + </item> + <item> + <property name="text"> + <string>HighlightedText</string> + </property> + </item> + <item> + <property name="text"> + <string>Link</string> + </property> + </item> + <item> + <property name="text"> + <string>LinkVisited</string> + </property> + </item> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="layoutCentral"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="labelCentral"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>&Select Color:</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupEffect"> + <property name="title"> + <string>3-D shadow &effects</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QCheckBox" name="checkBuildEffect"> + <property name="toolTip"> + <string>Generate shadings</string> + </property> + <property name="whatsThis"> + <string>Check to let 3D-effect colors be calculated from button-color.</string> + </property> + <property name="text"> + <string>Build &from button color</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboEffect"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>Choose 3D-effect color role</string> + </property> + <property name="whatsThis"> + <string><b>Select a color role.</b><p>Available effect roles are: <ul> <li>Light - lighter than Button color. </li> <li>Midlight - between Button and Light. </li> <li>Mid - between Button and Dark. </li> <li>Dark - darker than Button. </li> <li>Shadow - a very dark color. </li> </ul></string> + </property> + <item> + <property name="text"> + <string>Light</string> + </property> + </item> + <item> + <property name="text"> + <string>Midlight</string> + </property> + </item> + <item> + <property name="text"> + <string>Mid</string> + </property> + </item> + <item> + <property name="text"> + <string>Dark</string> + </property> + </item> + <item> + <property name="text"> + <string>Shadow</string> + </property> + </item> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="layoutEffect"> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="labelEffect"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Select Co&lor:</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>PaletteEditorAdvanced</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>238</x> + <y>384</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>PaletteEditorAdvanced</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>306</x> + <y>390</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>checkBuildEffect</sender> + <signal>toggled(bool)</signal> + <receiver>comboEffect</receiver> + <slot>setDisabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>82</x> + <y>262</y> + </hint> + <hint type="destinationlabel"> + <x>190</x> + <y>262</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/tools/qtconfig/paletteeditoradvancedbase.cpp b/tools/qtconfig/paletteeditoradvancedbase.cpp deleted file mode 100644 index 55a03b7..0000000 --- a/tools/qtconfig/paletteeditoradvancedbase.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications 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 "paletteeditoradvancedbase.h" -#include "colorbutton.h" - -#include <QVariant> - -QT_BEGIN_NAMESPACE - -/* - * Constructs a PaletteEditorAdvancedBase as a child of 'parent', with the - * name 'name' and widget flags set to 'f'. - * - * The dialog will by default be modeless, unless you set 'modal' to - * true to construct a modal dialog. - */ -PaletteEditorAdvancedBase::PaletteEditorAdvancedBase(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl) - : QDialog(parent, name, modal, fl) -{ - setupUi(this); - - - // signals and slots connections - connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); - connect(paletteCombo, SIGNAL(activated(int)), this, SLOT(paletteSelected(int))); - connect(comboCentral, SIGNAL(activated(int)), this, SLOT(onCentral(int))); - connect(buttonCentral, SIGNAL(clicked()), this, SLOT(onChooseCentralColor())); - connect(buttonEffect, SIGNAL(clicked()), this, SLOT(onChooseEffectColor())); - connect(comboEffect, SIGNAL(activated(int)), this, SLOT(onEffect(int))); - connect(checkBuildEffect, SIGNAL(toggled(bool)), this, SLOT(onToggleBuildEffects(bool))); - connect(checkBuildEffect, SIGNAL(toggled(bool)), comboEffect, SLOT(setDisabled(bool))); - connect(checkBuildEffect, SIGNAL(toggled(bool)), buttonEffect, SLOT(setDisabled(bool))); - connect(checkBuildInactive, SIGNAL(toggled(bool)), this, SLOT(onToggleBuildInactive(bool))); - connect(checkBuildDisabled, SIGNAL(toggled(bool)), this, SLOT(onToggleBuildDisabled(bool))); - init(); -} - -/* - * Destroys the object and frees any allocated resources - */ -PaletteEditorAdvancedBase::~PaletteEditorAdvancedBase() -{ - destroy(); - // no need to delete child widgets, Qt does it all for us -} - -/* - * Sets the strings of the subwidgets using the current - * language. - */ -void PaletteEditorAdvancedBase::languageChange() -{ - retranslateUi(this); -} - -void PaletteEditorAdvancedBase::init() -{ -} - -void PaletteEditorAdvancedBase::destroy() -{ -} - -void PaletteEditorAdvancedBase::onCentral(int) -{ - qWarning("PaletteEditorAdvancedBase::onCentral(int): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::onChooseCentralColor() -{ - qWarning("PaletteEditorAdvancedBase::onChooseCentralColor(): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::onChooseEffectColor() -{ - qWarning("PaletteEditorAdvancedBase::onChooseEffectColor(): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::onEffect(int) -{ - qWarning("PaletteEditorAdvancedBase::onEffect(int): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::onToggleBuildDisabled(bool) -{ - qWarning("PaletteEditorAdvancedBase::onToggleBuildDisabled(bool): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::onToggleBuildEffects(bool) -{ - qWarning("PaletteEditorAdvancedBase::onToggleBuildEffects(bool): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::onToggleBuildInactive(bool) -{ - qWarning("PaletteEditorAdvancedBase::onToggleBuildInactive(bool): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::paletteSelected(int) -{ - qWarning("PaletteEditorAdvancedBase::paletteSelected(int): Not implemented yet"); -} - -QT_END_NAMESPACE diff --git a/tools/qtconfig/paletteeditoradvancedbase.ui b/tools/qtconfig/paletteeditoradvancedbase.ui deleted file mode 100644 index 8965960..0000000 --- a/tools/qtconfig/paletteeditoradvancedbase.ui +++ /dev/null @@ -1,617 +0,0 @@ -<ui version="4.0" stdsetdef="1" > - <author></author> - <comment>********************************************************************* -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications 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$ -** -*********************************************************************</comment> - <exportmacro></exportmacro> - <class>PaletteEditorAdvancedBase</class> - <widget class="QDialog" name="PaletteEditorAdvancedBase" > - <property name="objectName" > - <string notr="true" >PaletteEditorAdvancedBase</string> - </property> - <property name="enabled" > - <bool>true</bool> - </property> - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>295</width> - <height>346</height> - </rect> - </property> - <property name="windowTitle" > - <string>Tune Palette</string> - </property> - <property name="sizeGripEnabled" > - <bool>true</bool> - </property> - <property name="whatsThis" stdset="0" > - <string><b>Edit Palette</b><p>Change the palette of the current widget or form.</p><p>Use a generated palette or select colors for each color group and each color role.</p><p>The palette can be tested with different widget layouts in the preview section.</p></string> - </property> - <layout class="QVBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>11</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QHBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="TextLabel1" > - <property name="objectName" > - <string notr="true" >TextLabel1</string> - </property> - <property name="text" > - <string>Select &Palette:</string> - </property> - <property name="buddy" stdset="0" > - <cstring>paletteCombo</cstring> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="paletteCombo" > - <property name="objectName" > - <string notr="true" >paletteCombo</string> - </property> - <item> - <property name="text" > - <string>Active Palette</string> - </property> - </item> - <item> - <property name="text" > - <string>Inactive Palette</string> - </property> - </item> - <item> - <property name="text" > - <string>Disabled Palette</string> - </property> - </item> - </widget> - </item> - </layout> - </item> - <item> - <widget class="Q3ButtonGroup" name="ButtonGroup1" > - <property name="objectName" > - <string notr="true" >ButtonGroup1</string> - </property> - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>4</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title" > - <string>Auto</string> - </property> - <layout class="QVBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>11</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QCheckBox" name="checkBuildInactive" > - <property name="objectName" > - <string notr="true" >checkBuildInactive</string> - </property> - <property name="text" > - <string>Build inactive palette from active</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBuildDisabled" > - <property name="objectName" > - <string notr="true" >checkBuildDisabled</string> - </property> - <property name="text" > - <string>Build disabled palette from active</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="Q3GroupBox" name="groupCentral" > - <property name="objectName" > - <string notr="true" >groupCentral</string> - </property> - <property name="title" > - <string>Central color &roles</string> - </property> - <layout class="QVBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>11</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QComboBox" name="comboCentral" > - <property name="objectName" > - <string notr="true" >comboCentral</string> - </property> - <property name="toolTip" stdset="0" > - <string>Choose central color role</string> - </property> - <property name="whatsThis" stdset="0" > - <string><b>Select a color role.</b><p>Available central roles are: <ul> <li>Window - general background color.</li> <li>WindowText - general foreground color. </li> <li>Base - used as background color for e.g. text entry widgets, usually white or another light color. </li> <li>Text - the foreground color used with Base. Usually this is the same as WindowText, in what case it must provide good contrast both with Window and Base. </li> <li>Button - general button background color, where buttons need a background different from Window, as in the Macintosh style. </li> <li>ButtonText - a foreground color used with the Button color. </li> <li>Highlight - a color to indicate a selected or highlighted item. </li> <li>HighlightedText - a text color that contrasts to Highlight. </li> <li>BrightText - a text color that is very different from WindowText and contrasts well with e.g. black. </li> </ul> </p></string> - </property> - <item> - <property name="text" > - <string>Window</string> - </property> - </item> - <item> - <property name="text" > - <string>WindowText</string> - </property> - </item> - <item> - <property name="text" > - <string>Button</string> - </property> - </item> - <item> - <property name="text" > - <string>Base</string> - </property> - </item> - <item> - <property name="text" > - <string>Text</string> - </property> - </item> - <item> - <property name="text" > - <string>BrightText</string> - </property> - </item> - <item> - <property name="text" > - <string>ButtonText</string> - </property> - </item> - <item> - <property name="text" > - <string>Highlight</string> - </property> - </item> - <item> - <property name="text" > - <string>HighlightedText</string> - </property> - </item> - </widget> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <spacer name="Horizontal_Spacing1" > - <property name="sizeHint" > - <size> - <width>20</width> - <height>20</height> - </size> - </property> - <property name="sizeType" > - <enum>Expanding</enum> - </property> - <property name="orientation" > - <enum>Horizontal</enum> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="labelCentral" > - <property name="objectName" > - <string notr="true" >labelCentral</string> - </property> - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>1</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize" > - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="text" > - <string>&Select Color:</string> - </property> - <property name="buddy" stdset="0" > - <cstring>buttonCentral</cstring> - </property> - </widget> - </item> - <item> - <widget class="ColorButton" name="buttonCentral" > - <property name="objectName" > - <string notr="true" >buttonCentral</string> - </property> - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="focusPolicy" > - <enum>Qt::TabFocus</enum> - </property> - <property name="toolTip" stdset="0" > - <string>Choose a color</string> - </property> - <property name="whatsThis" stdset="0" > - <string>Choose a color for the selected central color role.</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="Q3GroupBox" name="groupEffect" > - <property name="objectName" > - <string notr="true" >groupEffect</string> - </property> - <property name="title" > - <string>3-D shadow &effects</string> - </property> - <layout class="QVBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>11</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QHBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QCheckBox" name="checkBuildEffect" > - <property name="objectName" > - <string notr="true" >checkBuildEffect</string> - </property> - <property name="text" > - <string>Build &from button color</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - <property name="toolTip" stdset="0" > - <string>Generate shadings</string> - </property> - <property name="whatsThis" stdset="0" > - <string>Check to let 3D-effect colors be calculated from button-color.</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboEffect" > - <property name="objectName" > - <string notr="true" >comboEffect</string> - </property> - <property name="toolTip" stdset="0" > - <string>Choose 3D-effect color role</string> - </property> - <property name="whatsThis" stdset="0" > - <string><b>Select a color role.</b><p>Available effect roles are: <ul> <li>Light - lighter than Button color. </li> <li>Midlight - between Button and Light. </li> <li>Mid - between Button and Dark. </li> <li>Dark - darker than Button. </li> <li>Shadow - a very dark color. </li> </ul></string> - </property> - <item> - <property name="text" > - <string>Light</string> - </property> - </item> - <item> - <property name="text" > - <string>Midlight</string> - </property> - </item> - <item> - <property name="text" > - <string>Mid</string> - </property> - </item> - <item> - <property name="text" > - <string>Dark</string> - </property> - </item> - <item> - <property name="text" > - <string>Shadow</string> - </property> - </item> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <spacer name="Horizontal_Spacing3" > - <property name="sizeHint" > - <size> - <width>20</width> - <height>20</height> - </size> - </property> - <property name="sizeType" > - <enum>Expanding</enum> - </property> - <property name="orientation" > - <enum>Horizontal</enum> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="labelEffect" > - <property name="objectName" > - <string notr="true" >labelEffect</string> - </property> - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>1</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize" > - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="text" > - <string>Select Co&lor:</string> - </property> - <property name="buddy" stdset="0" > - <cstring>buttonEffect</cstring> - </property> - </widget> - </item> - <item> - <widget class="ColorButton" name="buttonEffect" > - <property name="objectName" > - <string notr="true" >buttonEffect</string> - </property> - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="focusPolicy" > - <enum>Qt::TabFocus</enum> - </property> - <property name="toolTip" stdset="0" > - <string>Choose a color</string> - </property> - <property name="whatsThis" stdset="0" > - <string>Choose a color for the selected effect color role.</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <spacer name="Horizontal_Spacing2" > - <property name="sizeHint" > - <size> - <width>20</width> - <height>20</height> - </size> - </property> - <property name="sizeType" > - <enum>Expanding</enum> - </property> - <property name="orientation" > - <enum>Horizontal</enum> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="buttonOk" > - <property name="objectName" > - <string notr="true" >buttonOk</string> - </property> - <property name="text" > - <string>OK</string> - </property> - <property name="autoDefault" > - <bool>true</bool> - </property> - <property name="default" > - <bool>true</bool> - </property> - <property name="whatsThis" stdset="0" > - <string>Close dialog and apply all changes.</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="buttonCancel" > - <property name="objectName" > - <string notr="true" >buttonCancel</string> - </property> - <property name="text" > - <string>Cancel</string> - </property> - <property name="autoDefault" > - <bool>true</bool> - </property> - <property name="whatsThis" stdset="0" > - <string>Close dialog and discard all changes.</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <pixmapfunction></pixmapfunction> - <customwidgets> - <customwidget> - <class>ColorButton</class> - <extends></extends> - <header location="local" >colorbutton.h</header> - <sizehint> - <width>40</width> - <height>25</height> - </sizehint> - <container>0</container> - <sizepolicy> - <hordata>5</hordata> - <verdata>5</verdata> - </sizepolicy> - <pixmap>image0</pixmap> - <properties> - <property type="Color" >color</property> - <property type="Pixmap" >pixmap</property> - </properties> - </customwidget> - </customwidgets> - <tabstops> - <tabstop>buttonOk</tabstop> - <tabstop>buttonCancel</tabstop> - <tabstop>paletteCombo</tabstop> - <tabstop>checkBuildInactive</tabstop> - <tabstop>checkBuildDisabled</tabstop> - <tabstop>comboCentral</tabstop> - <tabstop>buttonCentral</tabstop> - <tabstop>checkBuildEffect</tabstop> - <tabstop>comboEffect</tabstop> - <tabstop>buttonEffect</tabstop> - </tabstops> - <images> - <image name="image0" > - <data format="XPM.GZ" length="646" >789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> - </image> - </images> -</ui> diff --git a/tools/qtconfig/previewframe.cpp b/tools/qtconfig/previewframe.cpp index 2d7b113..c6df899 100644 --- a/tools/qtconfig/previewframe.cpp +++ b/tools/qtconfig/previewframe.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "previewframe.h" +#include "previewwidget.h" #include <QBoxLayout> #include <QPainter> @@ -47,8 +48,8 @@ QT_BEGIN_NAMESPACE -PreviewFrame::PreviewFrame( QWidget *parent, const char *name ) - : QFrame( parent, name ) +PreviewFrame::PreviewFrame(QWidget *parent) + : QFrame(parent) { setMinimumSize(200, 200); setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); @@ -82,23 +83,22 @@ void PreviewFrame::setPreviewVisible(bool visible) workspace->viewport()->update(); } -Workspace::Workspace(PreviewFrame* parent, const char* name) +Workspace::Workspace(PreviewFrame *parent) : QMdiArea(parent) { previewFrame = parent; PreviewWidget *previewWidget = previewFrame->widget(); - setObjectName(QLatin1String(name)); QMdiSubWindow *frame = addSubWindow(previewWidget, Qt::Window); - frame->move(10,10); + frame->move(10, 10); frame->show(); } -void Workspace::paintEvent( QPaintEvent* ) +void Workspace::paintEvent(QPaintEvent *) { - QPainter p (viewport()); + QPainter p(viewport()); p.fillRect(rect(), palette().color(backgroundRole()).dark()); - p.setPen( QPen( Qt::white ) ); - p.drawText ( 0, height() / 2, width(), height(), Qt::AlignHCenter, previewFrame->previewText()); + p.setPen(QPen(Qt::white)); + p.drawText(0, height() / 2, width(), height(), Qt::AlignHCenter, previewFrame->previewText()); } QT_END_NAMESPACE diff --git a/tools/qtconfig/previewframe.h b/tools/qtconfig/previewframe.h index cd7bd0b..5cb0d59 100644 --- a/tools/qtconfig/previewframe.h +++ b/tools/qtconfig/previewframe.h @@ -42,8 +42,6 @@ #ifndef PREVIEWFRAME_H #define PREVIEWFRAME_H -#include "previewwidget.h" - #include <QMdiArea> QT_BEGIN_NAMESPACE @@ -54,28 +52,29 @@ class Workspace : public QMdiArea Q_OBJECT public: - Workspace( PreviewFrame* parent = 0, const char* name = 0 ); + Workspace(PreviewFrame *parent = 0); ~Workspace() {} protected: - void paintEvent( QPaintEvent* ); + void paintEvent(QPaintEvent *); private: PreviewFrame *previewFrame; }; +class PreviewWidget; class PreviewFrame : public QFrame { Q_OBJECT public: - PreviewFrame( QWidget *parent = 0, const char *name = 0 ); + PreviewFrame(QWidget *parent = 0); void setPreviewPalette(QPalette); void setPreviewVisible(bool val); QString previewText() const; PreviewWidget *widget() const { return previewWidget; } private: - Workspace *workspace; - PreviewWidget *previewWidget; + Workspace *workspace; + PreviewWidget *previewWidget; QString m_previewWindowText; }; diff --git a/tools/qtconfig/previewwidget.cpp b/tools/qtconfig/previewwidget.cpp index 71cef23..66ebb92 100644 --- a/tools/qtconfig/previewwidget.cpp +++ b/tools/qtconfig/previewwidget.cpp @@ -40,32 +40,32 @@ ****************************************************************************/ #include "previewwidget.h" +#include "ui_previewwidget.h" #include <QtEvents> QT_BEGIN_NAMESPACE -PreviewWidget::PreviewWidget( QWidget *parent, const char *name ) - : PreviewWidgetBase( parent, name ) +PreviewWidget::PreviewWidget(QWidget *parent) + : QWidget(parent), ui(new Ui::PreviewWidget) { + ui->setupUi(this); + // install event filter on child widgets - QObjectList l = queryList("QWidget"); - for (int i = 0; i < l.size(); ++i) { - QObject * obj = l.at(i); - obj->installEventFilter(this); - ((QWidget*)obj)->setFocusPolicy(Qt::NoFocus); + QList<QWidget *> l = findChildren<QWidget *>(); + foreach(QWidget *w, l) { + w->installEventFilter(this); + w->setFocusPolicy(Qt::NoFocus); } } - -void PreviewWidget::closeEvent(QCloseEvent *e) +PreviewWidget::~PreviewWidget() { - e->ignore(); + delete ui; } - bool PreviewWidget::eventFilter(QObject *, QEvent *e) { - switch ( e->type() ) { + switch (e->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseButtonDblClick: @@ -81,4 +81,9 @@ bool PreviewWidget::eventFilter(QObject *, QEvent *e) return false; } +void PreviewWidget::closeEvent(QCloseEvent *e) +{ + e->ignore(); +} + QT_END_NAMESPACE diff --git a/tools/qtconfig/previewwidget.h b/tools/qtconfig/previewwidget.h index a6ec5b3..d39fd75 100644 --- a/tools/qtconfig/previewwidget.h +++ b/tools/qtconfig/previewwidget.h @@ -42,21 +42,29 @@ #ifndef PREVIEWWIDGET_H #define PREVIEWWIDGET_H -#include "previewwidgetbase.h" +#include <QtGui/QWidget> QT_BEGIN_NAMESPACE -class PreviewWidget : public PreviewWidgetBase +namespace Ui { + class PreviewWidget; +} + + +class PreviewWidget : public QWidget { Q_OBJECT public: - PreviewWidget( QWidget *parent = 0, const char *name = 0 ); + PreviewWidget(QWidget *parent = 0); + ~PreviewWidget(); - void closeEvent(QCloseEvent *); bool eventFilter(QObject *, QEvent *); +private: + void closeEvent(QCloseEvent *); + Ui::PreviewWidget *ui; }; QT_END_NAMESPACE -#endif +#endif // PREVIEWWIDGET_H diff --git a/tools/qtconfig/previewwidget.ui b/tools/qtconfig/previewwidget.ui new file mode 100644 index 0000000..fac4b6c --- /dev/null +++ b/tools/qtconfig/previewwidget.ui @@ -0,0 +1,252 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <comment>********************************************************************* +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the tools applications 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$ +** +*********************************************************************</comment> + <class>PreviewWidget</class> + <widget class="QWidget" name="PreviewWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>398</width> + <height>282</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle"> + <string>Preview Window</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QGroupBox" name="GroupBox1"> + <property name="title"> + <string>GroupBox</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QRadioButton" name="RadioButton1"> + <property name="text"> + <string>RadioButton1</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="RadioButton2"> + <property name="text"> + <string>RadioButton2</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="RadioButton3"> + <property name="text"> + <string>RadioButton3</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="GroupBox2"> + <property name="title"> + <string>GroupBox2</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>11</number> + </property> + <item> + <widget class="QCheckBox" name="CheckBox1"> + <property name="text"> + <string>CheckBox1</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="CheckBox2"> + <property name="text"> + <string>CheckBox2</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QProgressBar" name="ProgressBar1"> + <property name="value"> + <number>50</number> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QLineEdit" name="LineEdit1"> + <property name="text"> + <string>LineEdit</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="ComboBox1"> + <item> + <property name="text"> + <string>ComboBox</string> + </property> + </item> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="QSpinBox" name="SpinBox1"/> + </item> + <item> + <widget class="QPushButton" name="PushButton1"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QScrollBar" name="ScrollBar1"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="Slider1"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QTextEdit" name="textView"> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>55</height> + </size> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="html"> + <string><p><a href="http://qt.nokia.com">http://qt.nokia.com</a></p> +<p><a href="http://www.kde.org">http://www.kde.org</a></p></string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <spacer name="Spacer2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tools/qtconfig/previewwidgetbase.ui b/tools/qtconfig/previewwidgetbase.ui deleted file mode 100644 index bd8a5f3..0000000 --- a/tools/qtconfig/previewwidgetbase.ui +++ /dev/null @@ -1,340 +0,0 @@ -<ui version="4.0" stdsetdef="1" > - <author></author> - <comment>********************************************************************* -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the tools applications 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$ -** -*********************************************************************</comment> - <exportmacro></exportmacro> - <class>PreviewWidgetBase</class> - <widget class="QWidget" name="PreviewWidgetBase" > - <property name="objectName" > - <string notr="true" >PreviewWidgetBase</string> - </property> - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>378</width> - <height>236</height> - </rect> - </property> - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>1</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="windowTitle" > - <string>Preview Window</string> - </property> - <layout class="QVBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>11</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QHBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QVBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="Q3ButtonGroup" name="ButtonGroup1" > - <property name="objectName" > - <string notr="true" >ButtonGroup1</string> - </property> - <property name="title" > - <string>ButtonGroup</string> - </property> - <layout class="QVBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>11</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QRadioButton" name="RadioButton1" > - <property name="objectName" > - <string notr="true" >RadioButton1</string> - </property> - <property name="text" > - <string>RadioButton1</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="RadioButton2" > - <property name="objectName" > - <string notr="true" >RadioButton2</string> - </property> - <property name="text" > - <string>RadioButton2</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="RadioButton3" > - <property name="objectName" > - <string notr="true" >RadioButton3</string> - </property> - <property name="text" > - <string>RadioButton3</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="Q3ButtonGroup" name="ButtonGroup2" > - <property name="objectName" > - <string notr="true" >ButtonGroup2</string> - </property> - <property name="title" > - <string>ButtonGroup2</string> - </property> - <layout class="QVBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>11</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QCheckBox" name="CheckBox1" > - <property name="objectName" > - <string notr="true" >CheckBox1</string> - </property> - <property name="text" > - <string>CheckBox1</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="CheckBox2" > - <property name="objectName" > - <string notr="true" >CheckBox2</string> - </property> - <property name="text" > - <string>CheckBox2</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QProgressBar" name="ProgressBar1" > - <property name="objectName" > - <string notr="true" >ProgressBar1</string> - </property> - <property name="value" > - <number>50</number> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLineEdit" name="LineEdit1" > - <property name="objectName" > - <string notr="true" >LineEdit1</string> - </property> - <property name="text" > - <string>LineEdit</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="ComboBox1" > - <property name="objectName" > - <string notr="true" >ComboBox1</string> - </property> - <item> - <property name="text" > - <string>ComboBox</string> - </property> - </item> - </widget> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="objectName" > - <string notr="true" >unnamed</string> - </property> - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QSpinBox" name="SpinBox1" > - <property name="objectName" > - <string notr="true" >SpinBox1</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="PushButton1" > - <property name="objectName" > - <string notr="true" >PushButton1</string> - </property> - <property name="text" > - <string>PushButton</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QScrollBar" name="ScrollBar1" > - <property name="objectName" > - <string notr="true" >ScrollBar1</string> - </property> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <widget class="QSlider" name="Slider1" > - <property name="objectName" > - <string notr="true" >Slider1</string> - </property> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <widget class="QTextEdit" name="textView" > - <property name="objectName" > - <string notr="true" >textView</string> - </property> - <property name="maximumSize" > - <size> - <width>32767</width> - <height>50</height> - </size> - </property> - <property name="readOnly" > - <bool>true</bool> - </property> - <property name="text" > - <string><p> -<a href="http://qt.nokia.com">http://qt.nokia.com</a> -</p> -<p> -<a href="http://www.kde.org">http://www.kde.org</a> -</p></string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <spacer name="Spacer2" > - <property name="sizeHint" > - <size> - <width>20</width> - <height>20</height> - </size> - </property> - <property name="sizeType" > - <enum>Expanding</enum> - </property> - <property name="orientation" > - <enum>Vertical</enum> - </property> - </spacer> - </item> - </layout> - </widget> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> -</ui> diff --git a/tools/qtconfig/qtconfig.pro b/tools/qtconfig/qtconfig.pro index d1fd320..cb06e5a 100644 --- a/tools/qtconfig/qtconfig.pro +++ b/tools/qtconfig/qtconfig.pro @@ -1,11 +1,10 @@ TEMPLATE = app -CONFIG += qt warn_on x11 +CONFIG += qt warn_on x11 build_all:!build_pass { CONFIG -= build_all CONFIG += release } LANGUAGE = C++ -QT += qt3support contains(QT_CONFIG, gstreamer):LIBS += $$QT_LIBS_GSTREAMER -lgstinterfaces-0.10 -lgstvideo-0.10 -lgstbase-0.10 contains(QT_CONFIG, gstreamer):QMAKE_CXXFLAGS += $$QT_CFLAGS_GSTREAMER @@ -13,19 +12,17 @@ contains(QT_CONFIG, phonon) { QT += phonon DEFINES += HAVE_PHONON } -SOURCES += colorbutton.cpp main.cpp previewframe.cpp previewwidget.cpp mainwindow.cpp paletteeditoradvanced.cpp \ - mainwindowbase.cpp paletteeditoradvancedbase.cpp previewwidgetbase.cpp -HEADERS += colorbutton.h previewframe.h previewwidget.h mainwindow.h paletteeditoradvanced.h \ - mainwindowbase.h paletteeditoradvancedbase.h previewwidgetbase.h +SOURCES += colorbutton.cpp main.cpp previewframe.cpp previewwidget.cpp mainwindow.cpp paletteeditoradvanced.cpp +HEADERS += colorbutton.h previewframe.h previewwidget.h mainwindow.h paletteeditoradvanced.h -FORMS = mainwindowbase.ui paletteeditoradvancedbase.ui previewwidgetbase.ui +FORMS = mainwindow.ui paletteeditoradvanced.ui previewwidget.ui RESOURCES = qtconfig.qrc PROJECTNAME = Qt Configuration -TARGET = qtconfig -DESTDIR = ../../bin +TARGET = qtconfig +DESTDIR = ../../bin target.path=$$[QT_INSTALL_BINS] INSTALLS += target -INCLUDEPATH += . -DBFILE = qtconfig.db +INCLUDEPATH += . +DBFILE = qtconfig.db diff --git a/tools/qtestlib/wince/cetest/bootstrapped.pri b/tools/qtestlib/wince/cetest/bootstrapped.pri index b9c4b2b..56c8ab7 100644 --- a/tools/qtestlib/wince/cetest/bootstrapped.pri +++ b/tools/qtestlib/wince/cetest/bootstrapped.pri @@ -4,11 +4,14 @@ SOURCES += \ $$QT_SOURCE_TREE/src/corelib/tools/qstringlist.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfile.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qdir.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_win.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemiterator_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qabstractfileengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfileinfo.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qtemporaryfile.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qdiriterator.cpp \ diff --git a/tools/qtestlib/wince/cetest/deployment.cpp b/tools/qtestlib/wince/cetest/deployment.cpp index 4c1bf5b..cd6ce28 100644 --- a/tools/qtestlib/wince/cetest/deployment.cpp +++ b/tools/qtestlib/wince/cetest/deployment.cpp @@ -227,9 +227,9 @@ void DeploymentHandler::initProjectDeploy(QMakeProject* project, DeploymentList return; for (int it = 0; it < list.size(); ++it) { - QString argSource = list.at(it) + QString(".sources"); + QString argSource = list.at(it); QString argPath = list.at(it) + QString(".path"); - if ((project->values(argSource).isEmpty() || project->values(argPath).isEmpty()) && list.at(it) != "deploy") { + if (((project->values(argSource + QString(".files")).isEmpty() && project->values(argSource + QString(".sources")).isEmpty()) || project->values(argPath).isEmpty()) && list.at(it) != "deploy") { debugOutput(QString::fromLatin1("cannot deploy \"%1\" because of missing data.").arg(list.at(it)), 0); continue; } @@ -240,7 +240,7 @@ void DeploymentHandler::initProjectDeploy(QMakeProject* project, DeploymentList if (!addPath.startsWith("/") && !addPath.startsWith(QLatin1String("\\"))) addPath = targetPath + "/" + addPath; - QStringList addSources = project->values(argSource); + QStringList addSources = project->values(argSource + QString(".files")) + project->values(argSource + QString(".sources")); addSources.replaceInStrings(QLatin1String("/"), QLatin1String("\\")); for(int index=0; index < addSources.size(); ++index) { QString dirstr = qmake_getpwd(); @@ -264,7 +264,7 @@ void DeploymentHandler::initProjectDeploy(QMakeProject* project, DeploymentList continue; } QString appendedQmakeDeploy = QString::fromLatin1("_q_make_additional_deploy_%1").arg(addQMakeDeployCounter++); - project->parse(appendedQmakeDeploy + QLatin1String(".sources = \"") + wildInfo.absoluteFilePath()); + project->parse(appendedQmakeDeploy + QLatin1String(".files = \"") + wildInfo.absoluteFilePath()); project->parse(appendedQmakeDeploy + QLatin1String(".path = \"") + addPath); list.append(appendedQmakeDeploy); } @@ -276,7 +276,7 @@ void DeploymentHandler::initProjectDeploy(QMakeProject* project, DeploymentList QStringList additionalEntries = additionalDir.entryList(QDir::NoDotAndDotDot | QDir::AllEntries | QDir::NoSymLinks); foreach(QString item, additionalEntries) { QString appendedDeploy = QString::fromLatin1("_q_make_additional_deploy_%1").arg(addQMakeDeployCounter++); - project->parse(appendedDeploy + QLatin1String(".sources = \"") + Option::fixPathToLocalOS(additionalDir.absoluteFilePath(item)) + QLatin1String("\"")); + project->parse(appendedDeploy + QLatin1String(".files = \"") + Option::fixPathToLocalOS(additionalDir.absoluteFilePath(item)) + QLatin1String("\"")); QString appendTargetPath = project->values(argPath).join(QLatin1String(" ")); if (appendTargetPath == QLatin1String(".")) appendTargetPath = filestr; diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp index 9390fb4..5281544 100644 --- a/tools/runonphone/main.cpp +++ b/tools/runonphone/main.cpp @@ -56,12 +56,13 @@ void printUsage(QTextStream& outstream, QString exeName) { outstream << exeName << " [options] [program] [program arguments]" << endl - << "-s, --sis <file> specify sis file to install" << endl + << "-s, --sis <local file> specify sis file to install" << endl << "-p, --portname <COMx> specify COM port to use by device name" << endl << "-f, --portfriendlyname <substring> specify COM port to use by friendly name" << endl << "-t, --timeout <milliseconds> terminate test if timeout occurs" << endl << "-v, --verbose show debugging output" << endl << "-q, --quiet hide progress messages" << endl + << "-u, --upload <local file> upload executable file to phone" << endl << "-d, --download <remote file> <local file> copy file from phone to PC after running test" << endl << "--nocrashlog Don't capture call stack if test crashes" << endl << "--crashlogpath <dir> Path to save crash logs (default=working dir)" << endl @@ -84,6 +85,7 @@ int main(int argc, char *argv[]) QStringList args = QCoreApplication::arguments(); QTextStream outstream(stdout); QTextStream errstream(stderr); + QString uploadLocalFile; QString downloadRemoteFile; QString downloadLocalFile; int loglevel=1; @@ -112,6 +114,18 @@ int main(int argc, char *argv[]) return 1; } } + else if (arg == "--upload" || arg == "-u") { + CHECK_PARAMETER_EXISTS + uploadLocalFile = it.next(); + if (!QFileInfo(uploadLocalFile).exists()) { + errstream << "Executable file (" << uploadLocalFile << ") doesn't exist" << endl; + return 1; + } + if (!(QFileInfo(uploadLocalFile).suffix() == "exe")) { + errstream << "File (" << uploadLocalFile << ") must be an executable" << endl; + return 1; + } + } else if (arg == "--download" || arg == "-d") { CHECK_PARAMETER_EXISTS downloadRemoteFile = it.next(); @@ -147,12 +161,18 @@ int main(int argc, char *argv[]) } } - if (exeFile.isEmpty() && sisFile.isEmpty() && + if (exeFile.isEmpty() && sisFile.isEmpty() && uploadLocalFile.isEmpty() && (downloadLocalFile.isEmpty() || downloadRemoteFile.isEmpty())) { printUsage(outstream, args[0]); return 1; } + if (!uploadLocalFile.isEmpty() && (!downloadLocalFile.isEmpty() || !downloadRemoteFile.isEmpty())) { + errstream << "Upload option can't be used together with download" << endl; + printUsage(outstream, args[0]); + return 1; + } + if (serialPortName.isEmpty()) { if (loglevel > 0) outstream << "Detecting serial ports" << endl; @@ -182,19 +202,20 @@ int main(int argc, char *argv[]) QScopedPointer<trk::Launcher> launcher; launcher.reset(new trk::Launcher(trk::Launcher::ActionPingOnly)); - QFileInfo info(exeFile); + QFileInfo exeInfo(exeFile); + QFileInfo uploadInfo(uploadLocalFile); if (!sisFile.isEmpty()) { launcher->addStartupActions(trk::Launcher::ActionCopyInstall); launcher->setCopyFileName(sisFile, "c:\\data\\testtemp.sis"); launcher->setInstallFileName("c:\\data\\testtemp.sis"); } - else if (info.exists()) { + else if (!uploadLocalFile.isEmpty() && uploadInfo.exists()) { launcher->addStartupActions(trk::Launcher::ActionCopy); - launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + info.fileName()); + launcher->setCopyFileName(uploadLocalFile, QString("c:\\sys\\bin\\") + uploadInfo.fileName()); } if (!exeFile.isEmpty()) { launcher->addStartupActions(trk::Launcher::ActionRun); - launcher->setFileName(QString("c:\\sys\\bin\\") + info.fileName()); + launcher->setFileName(QString("c:\\sys\\bin\\") + exeInfo.fileName()); launcher->setCommandLineArgs(cmdLine); } if (!downloadRemoteFile.isEmpty() && !downloadLocalFile.isEmpty()) { diff --git a/tools/runonphone/serenum_unix.cpp b/tools/runonphone/serenum_unix.cpp index 9b768f7..8cc0b82 100644 --- a/tools/runonphone/serenum_unix.cpp +++ b/tools/runonphone/serenum_unix.cpp @@ -100,7 +100,7 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel) // data transmission. // the extra info stores that as a index for the interface if (buf[0] >= 5 && buf[1] == 36 && buf[2] == 6) { // CDC Union - for (int i = 4; i < buf[0]; i++) + for (int i = 3; i < buf[0]; i++) usableInterfaces.append((int) buf[i]); } size -= buf[0]; @@ -146,37 +146,22 @@ QList<SerialPortId> enumerateSerialPorts(int loglevel) // second loop to find the actual data interface. foreach (int i, usableInterfaces) { - for (int m = 0; m < usbConfig.bNumInterfaces; ++m) { - for (int o = 0; o < usbConfig.interface[m].num_altsetting; ++o) { - struct usb_interface_descriptor &descriptor = usbConfig.interface[m].altsetting[o]; - if (descriptor.bInterfaceNumber != i) - continue; - if (descriptor.bInterfaceClass == 10) { // "CDC Data" - if (loglevel > 1) { - qDebug() << " found the data port" - << "bus:" << bus->dirname - << "device" << device->filename - << "interface" << descriptor.bInterfaceNumber; - } #ifdef Q_OS_MAC - eligibleInterfaces << QString("^cu\\.usbmodem.*%1$") - .arg(QString("%1").arg(descriptor.bInterfaceNumber, 1, 16).toUpper()); + eligibleInterfaces << QString("^cu\\.usbmodem.*%1$") + .arg(QString("%1").arg(descriptor.bInterfaceNumber, 1, 16).toUpper()); #else - // ### manufacturer and product strings are only readable as root :( - if (!manufacturerString.isEmpty() && !productString.isEmpty()) { - eligibleInterfaces << QString("usb-%1_%2-if%3") - .arg(manufacturerString.replace(QChar(' '), QChar('_'))) - .arg(productString.replace(QChar(' '), QChar('_'))) - .arg(i, 2, 16, QChar('0')); - } else { - eligibleInterfaces << QString("if%1").arg(i, 2, 16, QChar('0')); // fix! - } -#endif - eligibleInterfacesInfo << InterfaceInfo(manufacturerString, productString, device->descriptor.idVendor, device->descriptor.idProduct); - } - } + // ### manufacturer and product strings are only readable as root :( + if (!manufacturerString.isEmpty() && !productString.isEmpty()) { + eligibleInterfaces << QString("usb-%1_%2-if%3") + .arg(manufacturerString.replace(QChar(' '), QChar('_'))) + .arg(productString.replace(QChar(' '), QChar('_'))) + .arg(i, 2, 16, QChar('0')); + } else { + eligibleInterfaces << QString("if%1").arg(i, 2, 16, QChar('0')); // fix! } +#endif } + eligibleInterfacesInfo << InterfaceInfo(manufacturerString, productString, device->descriptor.idVendor, device->descriptor.idProduct); } } } diff --git a/tools/shared/qtpropertybrowser/qtpropertybrowserutils.pri b/tools/shared/qtpropertybrowser/qtpropertybrowserutils.pri new file mode 100644 index 0000000..1755448 --- /dev/null +++ b/tools/shared/qtpropertybrowser/qtpropertybrowserutils.pri @@ -0,0 +1,4 @@ +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD +SOURCES += $$PWD/qtpropertybrowserutils.cpp +HEADERS += $$PWD/qtpropertybrowserutils_p.h diff --git a/tools/shared/qtpropertybrowser/qtvariantproperty.cpp b/tools/shared/qtpropertybrowser/qtvariantproperty.cpp index 752959c..9647b3a 100644 --- a/tools/shared/qtpropertybrowser/qtvariantproperty.cpp +++ b/tools/shared/qtpropertybrowser/qtvariantproperty.cpp @@ -549,7 +549,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QKeySequence &val) { QVariant v; - qVariantSetValue(v, val); + v.setValue(val); valueChanged(property, v); } @@ -636,7 +636,7 @@ void QtVariantPropertyManagerPrivate::slotEnumIconsChanged(QtProperty *property, { if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { QVariant v; - qVariantSetValue(v, enumIcons); + v.setValue(enumIcons); emit q_ptr->attributeChanged(varProp, m_enumIconsAttribute, v); } } @@ -1488,7 +1488,7 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co return enumManager->enumNames(internProp); if (attribute == d_ptr->m_enumIconsAttribute) { QVariant v; - qVariantSetValue(v, enumManager->enumIcons(internProp)); + v.setValue(enumManager->enumIcons(internProp)); return v; } return QVariant(); @@ -1568,73 +1568,73 @@ void QtVariantPropertyManager::setValue(QtProperty *property, const QVariant &va QtAbstractPropertyManager *manager = internProp->propertyManager(); if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { - intManager->setValue(internProp, qVariantValue<int>(val)); + intManager->setValue(internProp, qvariant_cast<int>(val)); return; } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { - doubleManager->setValue(internProp, qVariantValue<double>(val)); + doubleManager->setValue(internProp, qvariant_cast<double>(val)); return; } else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) { - boolManager->setValue(internProp, qVariantValue<bool>(val)); + boolManager->setValue(internProp, qvariant_cast<bool>(val)); return; } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { - stringManager->setValue(internProp, qVariantValue<QString>(val)); + stringManager->setValue(internProp, qvariant_cast<QString>(val)); return; } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { - dateManager->setValue(internProp, qVariantValue<QDate>(val)); + dateManager->setValue(internProp, qvariant_cast<QDate>(val)); return; } else if (QtTimePropertyManager *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) { - timeManager->setValue(internProp, qVariantValue<QTime>(val)); + timeManager->setValue(internProp, qvariant_cast<QTime>(val)); return; } else if (QtDateTimePropertyManager *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) { - dateTimeManager->setValue(internProp, qVariantValue<QDateTime>(val)); + dateTimeManager->setValue(internProp, qvariant_cast<QDateTime>(val)); return; } else if (QtKeySequencePropertyManager *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) { - keySequenceManager->setValue(internProp, qVariantValue<QKeySequence>(val)); + keySequenceManager->setValue(internProp, qvariant_cast<QKeySequence>(val)); return; } else if (QtCharPropertyManager *charManager = qobject_cast<QtCharPropertyManager *>(manager)) { - charManager->setValue(internProp, qVariantValue<QChar>(val)); + charManager->setValue(internProp, qvariant_cast<QChar>(val)); return; } else if (QtLocalePropertyManager *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) { - localeManager->setValue(internProp, qVariantValue<QLocale>(val)); + localeManager->setValue(internProp, qvariant_cast<QLocale>(val)); return; } else if (QtPointPropertyManager *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) { - pointManager->setValue(internProp, qVariantValue<QPoint>(val)); + pointManager->setValue(internProp, qvariant_cast<QPoint>(val)); return; } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { - pointFManager->setValue(internProp, qVariantValue<QPointF>(val)); + pointFManager->setValue(internProp, qvariant_cast<QPointF>(val)); return; } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { - sizeManager->setValue(internProp, qVariantValue<QSize>(val)); + sizeManager->setValue(internProp, qvariant_cast<QSize>(val)); return; } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { - sizeFManager->setValue(internProp, qVariantValue<QSizeF>(val)); + sizeFManager->setValue(internProp, qvariant_cast<QSizeF>(val)); return; } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { - rectManager->setValue(internProp, qVariantValue<QRect>(val)); + rectManager->setValue(internProp, qvariant_cast<QRect>(val)); return; } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { - rectFManager->setValue(internProp, qVariantValue<QRectF>(val)); + rectFManager->setValue(internProp, qvariant_cast<QRectF>(val)); return; } else if (QtColorPropertyManager *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) { - colorManager->setValue(internProp, qVariantValue<QColor>(val)); + colorManager->setValue(internProp, qvariant_cast<QColor>(val)); return; } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { - enumManager->setValue(internProp, qVariantValue<int>(val)); + enumManager->setValue(internProp, qvariant_cast<int>(val)); return; } else if (QtSizePolicyPropertyManager *sizePolicyManager = qobject_cast<QtSizePolicyPropertyManager *>(manager)) { - sizePolicyManager->setValue(internProp, qVariantValue<QSizePolicy>(val)); + sizePolicyManager->setValue(internProp, qvariant_cast<QSizePolicy>(val)); return; } else if (QtFontPropertyManager *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) { - fontManager->setValue(internProp, qVariantValue<QFont>(val)); + fontManager->setValue(internProp, qvariant_cast<QFont>(val)); return; #ifndef QT_NO_CURSOR } else if (QtCursorPropertyManager *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) { - cursorManager->setValue(internProp, qVariantValue<QCursor>(val)); + cursorManager->setValue(internProp, qvariant_cast<QCursor>(val)); return; #endif } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { - flagManager->setValue(internProp, qVariantValue<int>(val)); + flagManager->setValue(internProp, qvariant_cast<int>(val)); return; } } @@ -1672,69 +1672,69 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property, QtAbstractPropertyManager *manager = internProp->propertyManager(); if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) - intManager->setMaximum(internProp, qVariantValue<int>(value)); + intManager->setMaximum(internProp, qvariant_cast<int>(value)); else if (attribute == d_ptr->m_minimumAttribute) - intManager->setMinimum(internProp, qVariantValue<int>(value)); + intManager->setMinimum(internProp, qvariant_cast<int>(value)); else if (attribute == d_ptr->m_singleStepAttribute) - intManager->setSingleStep(internProp, qVariantValue<int>(value)); + intManager->setSingleStep(internProp, qvariant_cast<int>(value)); return; } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) - doubleManager->setMaximum(internProp, qVariantValue<double>(value)); + doubleManager->setMaximum(internProp, qvariant_cast<double>(value)); if (attribute == d_ptr->m_minimumAttribute) - doubleManager->setMinimum(internProp, qVariantValue<double>(value)); + doubleManager->setMinimum(internProp, qvariant_cast<double>(value)); if (attribute == d_ptr->m_singleStepAttribute) - doubleManager->setSingleStep(internProp, qVariantValue<double>(value)); + doubleManager->setSingleStep(internProp, qvariant_cast<double>(value)); if (attribute == d_ptr->m_decimalsAttribute) - doubleManager->setDecimals(internProp, qVariantValue<int>(value)); + doubleManager->setDecimals(internProp, qvariant_cast<int>(value)); return; } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { if (attribute == d_ptr->m_regExpAttribute) - stringManager->setRegExp(internProp, qVariantValue<QRegExp>(value)); + stringManager->setRegExp(internProp, qvariant_cast<QRegExp>(value)); return; } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) - dateManager->setMaximum(internProp, qVariantValue<QDate>(value)); + dateManager->setMaximum(internProp, qvariant_cast<QDate>(value)); if (attribute == d_ptr->m_minimumAttribute) - dateManager->setMinimum(internProp, qVariantValue<QDate>(value)); + dateManager->setMinimum(internProp, qvariant_cast<QDate>(value)); return; } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { if (attribute == d_ptr->m_decimalsAttribute) - pointFManager->setDecimals(internProp, qVariantValue<int>(value)); + pointFManager->setDecimals(internProp, qvariant_cast<int>(value)); return; } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) - sizeManager->setMaximum(internProp, qVariantValue<QSize>(value)); + sizeManager->setMaximum(internProp, qvariant_cast<QSize>(value)); if (attribute == d_ptr->m_minimumAttribute) - sizeManager->setMinimum(internProp, qVariantValue<QSize>(value)); + sizeManager->setMinimum(internProp, qvariant_cast<QSize>(value)); return; } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) - sizeFManager->setMaximum(internProp, qVariantValue<QSizeF>(value)); + sizeFManager->setMaximum(internProp, qvariant_cast<QSizeF>(value)); if (attribute == d_ptr->m_minimumAttribute) - sizeFManager->setMinimum(internProp, qVariantValue<QSizeF>(value)); + sizeFManager->setMinimum(internProp, qvariant_cast<QSizeF>(value)); if (attribute == d_ptr->m_decimalsAttribute) - sizeFManager->setDecimals(internProp, qVariantValue<int>(value)); + sizeFManager->setDecimals(internProp, qvariant_cast<int>(value)); return; } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { if (attribute == d_ptr->m_constraintAttribute) - rectManager->setConstraint(internProp, qVariantValue<QRect>(value)); + rectManager->setConstraint(internProp, qvariant_cast<QRect>(value)); return; } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { if (attribute == d_ptr->m_constraintAttribute) - rectFManager->setConstraint(internProp, qVariantValue<QRectF>(value)); + rectFManager->setConstraint(internProp, qvariant_cast<QRectF>(value)); if (attribute == d_ptr->m_decimalsAttribute) - rectFManager->setDecimals(internProp, qVariantValue<int>(value)); + rectFManager->setDecimals(internProp, qvariant_cast<int>(value)); return; } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { if (attribute == d_ptr->m_enumNamesAttribute) - enumManager->setEnumNames(internProp, qVariantValue<QStringList>(value)); + enumManager->setEnumNames(internProp, qvariant_cast<QStringList>(value)); if (attribute == d_ptr->m_enumIconsAttribute) - enumManager->setEnumIcons(internProp, qVariantValue<QtIconMap>(value)); + enumManager->setEnumIcons(internProp, qvariant_cast<QtIconMap>(value)); return; } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { if (attribute == d_ptr->m_flagNamesAttribute) - flagManager->setFlagNames(internProp, qVariantValue<QStringList>(value)); + flagManager->setFlagNames(internProp, qvariant_cast<QStringList>(value)); return; } } @@ -1997,87 +1997,87 @@ QtVariantEditorFactory::~QtVariantEditorFactory() */ void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager *manager) { - QList<QtIntPropertyManager *> intPropertyManagers = qFindChildren<QtIntPropertyManager *>(manager); + QList<QtIntPropertyManager *> intPropertyManagers = manager->findChildren<QtIntPropertyManager *>(); QListIterator<QtIntPropertyManager *> itInt(intPropertyManagers); while (itInt.hasNext()) d_ptr->m_spinBoxFactory->addPropertyManager(itInt.next()); - QList<QtDoublePropertyManager *> doublePropertyManagers = qFindChildren<QtDoublePropertyManager *>(manager); + QList<QtDoublePropertyManager *> doublePropertyManagers = manager->findChildren<QtDoublePropertyManager *>(); QListIterator<QtDoublePropertyManager *> itDouble(doublePropertyManagers); while (itDouble.hasNext()) d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itDouble.next()); - QList<QtBoolPropertyManager *> boolPropertyManagers = qFindChildren<QtBoolPropertyManager *>(manager); + QList<QtBoolPropertyManager *> boolPropertyManagers = manager->findChildren<QtBoolPropertyManager *>(); QListIterator<QtBoolPropertyManager *> itBool(boolPropertyManagers); while (itBool.hasNext()) d_ptr->m_checkBoxFactory->addPropertyManager(itBool.next()); - QList<QtStringPropertyManager *> stringPropertyManagers = qFindChildren<QtStringPropertyManager *>(manager); + QList<QtStringPropertyManager *> stringPropertyManagers = manager->findChildren<QtStringPropertyManager *>(); QListIterator<QtStringPropertyManager *> itString(stringPropertyManagers); while (itString.hasNext()) d_ptr->m_lineEditFactory->addPropertyManager(itString.next()); - QList<QtDatePropertyManager *> datePropertyManagers = qFindChildren<QtDatePropertyManager *>(manager); + QList<QtDatePropertyManager *> datePropertyManagers = manager->findChildren<QtDatePropertyManager *>(); QListIterator<QtDatePropertyManager *> itDate(datePropertyManagers); while (itDate.hasNext()) d_ptr->m_dateEditFactory->addPropertyManager(itDate.next()); - QList<QtTimePropertyManager *> timePropertyManagers = qFindChildren<QtTimePropertyManager *>(manager); + QList<QtTimePropertyManager *> timePropertyManagers = manager->findChildren<QtTimePropertyManager *>(); QListIterator<QtTimePropertyManager *> itTime(timePropertyManagers); while (itTime.hasNext()) d_ptr->m_timeEditFactory->addPropertyManager(itTime.next()); - QList<QtDateTimePropertyManager *> dateTimePropertyManagers = qFindChildren<QtDateTimePropertyManager *>(manager); + QList<QtDateTimePropertyManager *> dateTimePropertyManagers = manager->findChildren<QtDateTimePropertyManager *>(); QListIterator<QtDateTimePropertyManager *> itDateTime(dateTimePropertyManagers); while (itDateTime.hasNext()) d_ptr->m_dateTimeEditFactory->addPropertyManager(itDateTime.next()); - QList<QtKeySequencePropertyManager *> keySequencePropertyManagers = qFindChildren<QtKeySequencePropertyManager *>(manager); + QList<QtKeySequencePropertyManager *> keySequencePropertyManagers = manager->findChildren<QtKeySequencePropertyManager *>(); QListIterator<QtKeySequencePropertyManager *> itKeySequence(keySequencePropertyManagers); while (itKeySequence.hasNext()) d_ptr->m_keySequenceEditorFactory->addPropertyManager(itKeySequence.next()); - QList<QtCharPropertyManager *> charPropertyManagers = qFindChildren<QtCharPropertyManager *>(manager); + QList<QtCharPropertyManager *> charPropertyManagers = manager->findChildren<QtCharPropertyManager *>(); QListIterator<QtCharPropertyManager *> itChar(charPropertyManagers); while (itChar.hasNext()) d_ptr->m_charEditorFactory->addPropertyManager(itChar.next()); - QList<QtLocalePropertyManager *> localePropertyManagers = qFindChildren<QtLocalePropertyManager *>(manager); + QList<QtLocalePropertyManager *> localePropertyManagers = manager->findChildren<QtLocalePropertyManager *>(); QListIterator<QtLocalePropertyManager *> itLocale(localePropertyManagers); while (itLocale.hasNext()) d_ptr->m_comboBoxFactory->addPropertyManager(itLocale.next()->subEnumPropertyManager()); - QList<QtPointPropertyManager *> pointPropertyManagers = qFindChildren<QtPointPropertyManager *>(manager); + QList<QtPointPropertyManager *> pointPropertyManagers = manager->findChildren<QtPointPropertyManager *>(); QListIterator<QtPointPropertyManager *> itPoint(pointPropertyManagers); while (itPoint.hasNext()) d_ptr->m_spinBoxFactory->addPropertyManager(itPoint.next()->subIntPropertyManager()); - QList<QtPointFPropertyManager *> pointFPropertyManagers = qFindChildren<QtPointFPropertyManager *>(manager); + QList<QtPointFPropertyManager *> pointFPropertyManagers = manager->findChildren<QtPointFPropertyManager *>(); QListIterator<QtPointFPropertyManager *> itPointF(pointFPropertyManagers); while (itPointF.hasNext()) d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itPointF.next()->subDoublePropertyManager()); - QList<QtSizePropertyManager *> sizePropertyManagers = qFindChildren<QtSizePropertyManager *>(manager); + QList<QtSizePropertyManager *> sizePropertyManagers = manager->findChildren<QtSizePropertyManager *>(); QListIterator<QtSizePropertyManager *> itSize(sizePropertyManagers); while (itSize.hasNext()) d_ptr->m_spinBoxFactory->addPropertyManager(itSize.next()->subIntPropertyManager()); - QList<QtSizeFPropertyManager *> sizeFPropertyManagers = qFindChildren<QtSizeFPropertyManager *>(manager); + QList<QtSizeFPropertyManager *> sizeFPropertyManagers = manager->findChildren<QtSizeFPropertyManager *>(); QListIterator<QtSizeFPropertyManager *> itSizeF(sizeFPropertyManagers); while (itSizeF.hasNext()) d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itSizeF.next()->subDoublePropertyManager()); - QList<QtRectPropertyManager *> rectPropertyManagers = qFindChildren<QtRectPropertyManager *>(manager); + QList<QtRectPropertyManager *> rectPropertyManagers = manager->findChildren<QtRectPropertyManager *>(); QListIterator<QtRectPropertyManager *> itRect(rectPropertyManagers); while (itRect.hasNext()) d_ptr->m_spinBoxFactory->addPropertyManager(itRect.next()->subIntPropertyManager()); - QList<QtRectFPropertyManager *> rectFPropertyManagers = qFindChildren<QtRectFPropertyManager *>(manager); + QList<QtRectFPropertyManager *> rectFPropertyManagers = manager->findChildren<QtRectFPropertyManager *>(); QListIterator<QtRectFPropertyManager *> itRectF(rectFPropertyManagers); while (itRectF.hasNext()) d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itRectF.next()->subDoublePropertyManager()); - QList<QtColorPropertyManager *> colorPropertyManagers = qFindChildren<QtColorPropertyManager *>(manager); + QList<QtColorPropertyManager *> colorPropertyManagers = manager->findChildren<QtColorPropertyManager *>(); QListIterator<QtColorPropertyManager *> itColor(colorPropertyManagers); while (itColor.hasNext()) { QtColorPropertyManager *manager = itColor.next(); @@ -2085,12 +2085,12 @@ void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager *ma d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager()); } - QList<QtEnumPropertyManager *> enumPropertyManagers = qFindChildren<QtEnumPropertyManager *>(manager); + QList<QtEnumPropertyManager *> enumPropertyManagers = manager->findChildren<QtEnumPropertyManager *>(); QListIterator<QtEnumPropertyManager *> itEnum(enumPropertyManagers); while (itEnum.hasNext()) d_ptr->m_comboBoxFactory->addPropertyManager(itEnum.next()); - QList<QtSizePolicyPropertyManager *> sizePolicyPropertyManagers = qFindChildren<QtSizePolicyPropertyManager *>(manager); + QList<QtSizePolicyPropertyManager *> sizePolicyPropertyManagers = manager->findChildren<QtSizePolicyPropertyManager *>(); QListIterator<QtSizePolicyPropertyManager *> itSizePolicy(sizePolicyPropertyManagers); while (itSizePolicy.hasNext()) { QtSizePolicyPropertyManager *manager = itSizePolicy.next(); @@ -2098,7 +2098,7 @@ void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager *ma d_ptr->m_comboBoxFactory->addPropertyManager(manager->subEnumPropertyManager()); } - QList<QtFontPropertyManager *> fontPropertyManagers = qFindChildren<QtFontPropertyManager *>(manager); + QList<QtFontPropertyManager *> fontPropertyManagers = manager->findChildren<QtFontPropertyManager *>(); QListIterator<QtFontPropertyManager *> itFont(fontPropertyManagers); while (itFont.hasNext()) { QtFontPropertyManager *manager = itFont.next(); @@ -2108,12 +2108,12 @@ void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager *ma d_ptr->m_checkBoxFactory->addPropertyManager(manager->subBoolPropertyManager()); } - QList<QtCursorPropertyManager *> cursorPropertyManagers = qFindChildren<QtCursorPropertyManager *>(manager); + QList<QtCursorPropertyManager *> cursorPropertyManagers = manager->findChildren<QtCursorPropertyManager *>(); QListIterator<QtCursorPropertyManager *> itCursor(cursorPropertyManagers); while (itCursor.hasNext()) d_ptr->m_cursorEditorFactory->addPropertyManager(itCursor.next()); - QList<QtFlagPropertyManager *> flagPropertyManagers = qFindChildren<QtFlagPropertyManager *>(manager); + QList<QtFlagPropertyManager *> flagPropertyManagers = manager->findChildren<QtFlagPropertyManager *>(); QListIterator<QtFlagPropertyManager *> itFlag(flagPropertyManagers); while (itFlag.hasNext()) d_ptr->m_checkBoxFactory->addPropertyManager(itFlag.next()->subBoolPropertyManager()); @@ -2141,87 +2141,87 @@ QWidget *QtVariantEditorFactory::createEditor(QtVariantPropertyManager *manager, */ void QtVariantEditorFactory::disconnectPropertyManager(QtVariantPropertyManager *manager) { - QList<QtIntPropertyManager *> intPropertyManagers = qFindChildren<QtIntPropertyManager *>(manager); + QList<QtIntPropertyManager *> intPropertyManagers = manager->findChildren<QtIntPropertyManager *>(); QListIterator<QtIntPropertyManager *> itInt(intPropertyManagers); while (itInt.hasNext()) d_ptr->m_spinBoxFactory->removePropertyManager(itInt.next()); - QList<QtDoublePropertyManager *> doublePropertyManagers = qFindChildren<QtDoublePropertyManager *>(manager); + QList<QtDoublePropertyManager *> doublePropertyManagers = manager->findChildren<QtDoublePropertyManager *>(); QListIterator<QtDoublePropertyManager *> itDouble(doublePropertyManagers); while (itDouble.hasNext()) d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itDouble.next()); - QList<QtBoolPropertyManager *> boolPropertyManagers = qFindChildren<QtBoolPropertyManager *>(manager); + QList<QtBoolPropertyManager *> boolPropertyManagers = manager->findChildren<QtBoolPropertyManager *>(); QListIterator<QtBoolPropertyManager *> itBool(boolPropertyManagers); while (itBool.hasNext()) d_ptr->m_checkBoxFactory->removePropertyManager(itBool.next()); - QList<QtStringPropertyManager *> stringPropertyManagers = qFindChildren<QtStringPropertyManager *>(manager); + QList<QtStringPropertyManager *> stringPropertyManagers = manager->findChildren<QtStringPropertyManager *>(); QListIterator<QtStringPropertyManager *> itString(stringPropertyManagers); while (itString.hasNext()) d_ptr->m_lineEditFactory->removePropertyManager(itString.next()); - QList<QtDatePropertyManager *> datePropertyManagers = qFindChildren<QtDatePropertyManager *>(manager); + QList<QtDatePropertyManager *> datePropertyManagers = manager->findChildren<QtDatePropertyManager *>(); QListIterator<QtDatePropertyManager *> itDate(datePropertyManagers); while (itDate.hasNext()) d_ptr->m_dateEditFactory->removePropertyManager(itDate.next()); - QList<QtTimePropertyManager *> timePropertyManagers = qFindChildren<QtTimePropertyManager *>(manager); + QList<QtTimePropertyManager *> timePropertyManagers = manager->findChildren<QtTimePropertyManager *>(); QListIterator<QtTimePropertyManager *> itTime(timePropertyManagers); while (itTime.hasNext()) d_ptr->m_timeEditFactory->removePropertyManager(itTime.next()); - QList<QtDateTimePropertyManager *> dateTimePropertyManagers = qFindChildren<QtDateTimePropertyManager *>(manager); + QList<QtDateTimePropertyManager *> dateTimePropertyManagers = manager->findChildren<QtDateTimePropertyManager *>(); QListIterator<QtDateTimePropertyManager *> itDateTime(dateTimePropertyManagers); while (itDateTime.hasNext()) d_ptr->m_dateTimeEditFactory->removePropertyManager(itDateTime.next()); - QList<QtKeySequencePropertyManager *> keySequencePropertyManagers = qFindChildren<QtKeySequencePropertyManager *>(manager); + QList<QtKeySequencePropertyManager *> keySequencePropertyManagers = manager->findChildren<QtKeySequencePropertyManager *>(); QListIterator<QtKeySequencePropertyManager *> itKeySequence(keySequencePropertyManagers); while (itKeySequence.hasNext()) d_ptr->m_keySequenceEditorFactory->removePropertyManager(itKeySequence.next()); - QList<QtCharPropertyManager *> charPropertyManagers = qFindChildren<QtCharPropertyManager *>(manager); + QList<QtCharPropertyManager *> charPropertyManagers = manager->findChildren<QtCharPropertyManager *>(); QListIterator<QtCharPropertyManager *> itChar(charPropertyManagers); while (itChar.hasNext()) d_ptr->m_charEditorFactory->removePropertyManager(itChar.next()); - QList<QtLocalePropertyManager *> localePropertyManagers = qFindChildren<QtLocalePropertyManager *>(manager); + QList<QtLocalePropertyManager *> localePropertyManagers = manager->findChildren<QtLocalePropertyManager *>(); QListIterator<QtLocalePropertyManager *> itLocale(localePropertyManagers); while (itLocale.hasNext()) d_ptr->m_comboBoxFactory->removePropertyManager(itLocale.next()->subEnumPropertyManager()); - QList<QtPointPropertyManager *> pointPropertyManagers = qFindChildren<QtPointPropertyManager *>(manager); + QList<QtPointPropertyManager *> pointPropertyManagers = manager->findChildren<QtPointPropertyManager *>(); QListIterator<QtPointPropertyManager *> itPoint(pointPropertyManagers); while (itPoint.hasNext()) d_ptr->m_spinBoxFactory->removePropertyManager(itPoint.next()->subIntPropertyManager()); - QList<QtPointFPropertyManager *> pointFPropertyManagers = qFindChildren<QtPointFPropertyManager *>(manager); + QList<QtPointFPropertyManager *> pointFPropertyManagers = manager->findChildren<QtPointFPropertyManager *>(); QListIterator<QtPointFPropertyManager *> itPointF(pointFPropertyManagers); while (itPointF.hasNext()) d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itPointF.next()->subDoublePropertyManager()); - QList<QtSizePropertyManager *> sizePropertyManagers = qFindChildren<QtSizePropertyManager *>(manager); + QList<QtSizePropertyManager *> sizePropertyManagers = manager->findChildren<QtSizePropertyManager *>(); QListIterator<QtSizePropertyManager *> itSize(sizePropertyManagers); while (itSize.hasNext()) d_ptr->m_spinBoxFactory->removePropertyManager(itSize.next()->subIntPropertyManager()); - QList<QtSizeFPropertyManager *> sizeFPropertyManagers = qFindChildren<QtSizeFPropertyManager *>(manager); + QList<QtSizeFPropertyManager *> sizeFPropertyManagers = manager->findChildren<QtSizeFPropertyManager *>(); QListIterator<QtSizeFPropertyManager *> itSizeF(sizeFPropertyManagers); while (itSizeF.hasNext()) d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itSizeF.next()->subDoublePropertyManager()); - QList<QtRectPropertyManager *> rectPropertyManagers = qFindChildren<QtRectPropertyManager *>(manager); + QList<QtRectPropertyManager *> rectPropertyManagers = manager->findChildren<QtRectPropertyManager *>(); QListIterator<QtRectPropertyManager *> itRect(rectPropertyManagers); while (itRect.hasNext()) d_ptr->m_spinBoxFactory->removePropertyManager(itRect.next()->subIntPropertyManager()); - QList<QtRectFPropertyManager *> rectFPropertyManagers = qFindChildren<QtRectFPropertyManager *>(manager); + QList<QtRectFPropertyManager *> rectFPropertyManagers = manager->findChildren<QtRectFPropertyManager *>(); QListIterator<QtRectFPropertyManager *> itRectF(rectFPropertyManagers); while (itRectF.hasNext()) d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itRectF.next()->subDoublePropertyManager()); - QList<QtColorPropertyManager *> colorPropertyManagers = qFindChildren<QtColorPropertyManager *>(manager); + QList<QtColorPropertyManager *> colorPropertyManagers = manager->findChildren<QtColorPropertyManager *>(); QListIterator<QtColorPropertyManager *> itColor(colorPropertyManagers); while (itColor.hasNext()) { QtColorPropertyManager *manager = itColor.next(); @@ -2229,12 +2229,12 @@ void QtVariantEditorFactory::disconnectPropertyManager(QtVariantPropertyManager d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager()); } - QList<QtEnumPropertyManager *> enumPropertyManagers = qFindChildren<QtEnumPropertyManager *>(manager); + QList<QtEnumPropertyManager *> enumPropertyManagers = manager->findChildren<QtEnumPropertyManager *>(); QListIterator<QtEnumPropertyManager *> itEnum(enumPropertyManagers); while (itEnum.hasNext()) d_ptr->m_comboBoxFactory->removePropertyManager(itEnum.next()); - QList<QtSizePolicyPropertyManager *> sizePolicyPropertyManagers = qFindChildren<QtSizePolicyPropertyManager *>(manager); + QList<QtSizePolicyPropertyManager *> sizePolicyPropertyManagers = manager->findChildren<QtSizePolicyPropertyManager *>(); QListIterator<QtSizePolicyPropertyManager *> itSizePolicy(sizePolicyPropertyManagers); while (itSizePolicy.hasNext()) { QtSizePolicyPropertyManager *manager = itSizePolicy.next(); @@ -2242,7 +2242,7 @@ void QtVariantEditorFactory::disconnectPropertyManager(QtVariantPropertyManager d_ptr->m_comboBoxFactory->removePropertyManager(manager->subEnumPropertyManager()); } - QList<QtFontPropertyManager *> fontPropertyManagers = qFindChildren<QtFontPropertyManager *>(manager); + QList<QtFontPropertyManager *> fontPropertyManagers = manager->findChildren<QtFontPropertyManager *>(); QListIterator<QtFontPropertyManager *> itFont(fontPropertyManagers); while (itFont.hasNext()) { QtFontPropertyManager *manager = itFont.next(); @@ -2252,12 +2252,12 @@ void QtVariantEditorFactory::disconnectPropertyManager(QtVariantPropertyManager d_ptr->m_checkBoxFactory->removePropertyManager(manager->subBoolPropertyManager()); } - QList<QtCursorPropertyManager *> cursorPropertyManagers = qFindChildren<QtCursorPropertyManager *>(manager); + QList<QtCursorPropertyManager *> cursorPropertyManagers = manager->findChildren<QtCursorPropertyManager *>(); QListIterator<QtCursorPropertyManager *> itCursor(cursorPropertyManagers); while (itCursor.hasNext()) d_ptr->m_cursorEditorFactory->removePropertyManager(itCursor.next()); - QList<QtFlagPropertyManager *> flagPropertyManagers = qFindChildren<QtFlagPropertyManager *>(manager); + QList<QtFlagPropertyManager *> flagPropertyManagers = manager->findChildren<QtFlagPropertyManager *>(); QListIterator<QtFlagPropertyManager *> itFlag(flagPropertyManagers); while (itFlag.hasNext()) d_ptr->m_checkBoxFactory->removePropertyManager(itFlag.next()->subBoolPropertyManager()); diff --git a/tools/tools.pro b/tools/tools.pro index 8f23fe4..f090b86 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -20,7 +20,7 @@ TEMPLATE = subdirs SUBDIRS += designer } } - unix:!mac:!embedded:contains(QT_CONFIG, qt3support):SUBDIRS += qtconfig + unix:!symbian:!mac:!embedded:!qpa:SUBDIRS += qtconfig win32:!wince*:SUBDIRS += activeqt } contains(QT_CONFIG, declarative):SUBDIRS += qml diff --git a/tools/xmlpatterns/main.cpp b/tools/xmlpatterns/main.cpp index 5c118ed..552a13f 100644 --- a/tools/xmlpatterns/main.cpp +++ b/tools/xmlpatterns/main.cpp @@ -145,14 +145,14 @@ protected: } /* The value.isNull() check ensures we can bind variables whose value is an empty string. */ - return qVariantFromValue(Parameter(name, value.isNull() ? QString(QLatin1String("")) : value )); + return QVariant::fromValue(Parameter(name, value.isNull() ? QString(QLatin1String("")) : value )); } else if(arg.name() == QLatin1String("output")) { QFile *const f = new QFile(input); if(f->open(QIODevice::WriteOnly)) - return qVariantFromValue(static_cast<QIODevice *>(f)); + return QVariant::fromValue(static_cast<QIODevice *>(f)); else { message(QXmlPatternistCLI::tr("Failed to open file %1 for writing: %2").arg(f->fileName(), f->errorString())); @@ -168,7 +168,7 @@ protected: return QVariant(); } else - return qVariantFromValue(name); + return QVariant::fromValue(name); } else return QApplicationArgumentParser::convertToValue(arg, input); @@ -200,7 +200,7 @@ protected: out->open(stdout, QIODevice::WriteOnly); #endif - return qVariantFromValue(static_cast<QIODevice *>(out)); + return QVariant::fromValue(static_cast<QIODevice *>(out)); } else return QApplicationArgumentParser::defaultValue(argument); @@ -317,7 +317,7 @@ int main(int argc, char **argv) QXmlQuery query(lang, namePool); - query.setInitialTemplateName(qVariantValue<QXmlName>(parser.value(initialTemplateName))); + query.setInitialTemplateName(qvariant_cast<QXmlName>(parser.value(initialTemplateName))); /* Bind external variables. */ { @@ -329,7 +329,7 @@ int main(int argc, char **argv) for(int i = 0; i < len; ++i) { - const Parameter p(qVariantValue<Parameter>(parameters.at(i))); + const Parameter p(qvariant_cast<Parameter>(parameters.at(i))); if(usedParameters.contains(p.first)) { @@ -359,7 +359,7 @@ int main(int argc, char **argv) query.setQuery(effectiveURI); - const QPatternist::AutoPtr<QIODevice> outDevice(qVariantValue<QIODevice *>(parser.value(output))); + const QPatternist::AutoPtr<QIODevice> outDevice(qvariant_cast<QIODevice *>(parser.value(output))); Q_ASSERT(outDevice); Q_ASSERT(outDevice->isWritable()); |