From bd9adf630d8f95cfb2cb18731ee581de4efda167 Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 6 Apr 2010 12:47:49 +0200 Subject: Assistant: Get rid of tabs. A QTabWidget is not the right widget if there are more than a handful of pages. Therefore, we now manage pages in a special widget. Reviewed-by: kh1 --- tools/assistant/tools/assistant/assistant.pro | 12 +- .../assistant/tools/assistant/assistant_images.qrc | 6 +- tools/assistant/tools/assistant/centralwidget.cpp | 456 +++------------------ tools/assistant/tools/assistant/centralwidget.h | 43 +- tools/assistant/tools/assistant/contentwindow.cpp | 5 +- tools/assistant/tools/assistant/globalactions.cpp | 163 ++++++++ tools/assistant/tools/assistant/globalactions.h | 91 ++++ tools/assistant/tools/assistant/helpviewer_qtb.cpp | 15 +- tools/assistant/tools/assistant/helpviewer_qtb.h | 7 +- tools/assistant/tools/assistant/helpviewer_qwv.cpp | 35 +- tools/assistant/tools/assistant/helpviewer_qwv.h | 5 +- .../tools/assistant/images/closebutton.png | Bin 0 -> 288 bytes .../tools/assistant/images/darkclosebutton.png | Bin 0 -> 319 bytes tools/assistant/tools/assistant/indexwindow.cpp | 3 +- tools/assistant/tools/assistant/mainwindow.cpp | 234 ++++------- tools/assistant/tools/assistant/mainwindow.h | 16 +- .../assistant/tools/assistant/openpagesmanager.cpp | 308 ++++++++++++++ tools/assistant/tools/assistant/openpagesmanager.h | 104 +++++ tools/assistant/tools/assistant/openpagesmodel.cpp | 120 ++++++ tools/assistant/tools/assistant/openpagesmodel.h | 76 ++++ .../assistant/tools/assistant/openpageswidget.cpp | 181 ++++++++ tools/assistant/tools/assistant/openpageswidget.h | 76 ++++ .../tools/assistant/preferencesdialog.cpp | 15 +- .../assistant/tools/assistant/preferencesdialog.h | 1 - tools/assistant/tools/assistant/remotecontrol.cpp | 10 +- 25 files changed, 1336 insertions(+), 646 deletions(-) create mode 100644 tools/assistant/tools/assistant/globalactions.cpp create mode 100644 tools/assistant/tools/assistant/globalactions.h create mode 100644 tools/assistant/tools/assistant/images/closebutton.png create mode 100644 tools/assistant/tools/assistant/images/darkclosebutton.png create mode 100644 tools/assistant/tools/assistant/openpagesmanager.cpp create mode 100644 tools/assistant/tools/assistant/openpagesmanager.h create mode 100644 tools/assistant/tools/assistant/openpagesmodel.cpp create mode 100644 tools/assistant/tools/assistant/openpagesmodel.h create mode 100644 tools/assistant/tools/assistant/openpageswidget.cpp create mode 100644 tools/assistant/tools/assistant/openpageswidget.h diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index ff0ecc5..78f48c1 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 @@ -42,7 +44,11 @@ HEADERS += aboutdialog.h \ topicchooser.h \ tracer.h \ xbelsupport.h \ - ../shared/collectionconfiguration.h + ../shared/collectionconfiguration.h \ + openpagesmodel.h \ + globalactions.h \ + openpageswidget.h \ + openpagesmanager.h win32:HEADERS += remotecontrol_win.h SOURCES += aboutdialog.cpp \ @@ -72,6 +78,10 @@ SOURCES += aboutdialog.cpp \ topicchooser.cpp \ xbelsupport.cpp \ ../shared/collectionconfiguration.cpp \ + openpagesmodel.cpp \ + globalactions.cpp \ + openpageswidget.cpp \ + openpagesmanager.cpp FORMS += bookmarkdialog.ui \ bookmarkmanagerwidget.ui \ 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 @@ - + images/trolltech-logo.png images/assistant-128.png images/assistant.png images/wrap.png images/bookmark.png -#mac images/mac/addtab.png images/mac/book.png images/mac/closetab.png @@ -19,7 +18,6 @@ images/mac/zoomin.png images/mac/zoomout.png images/mac/resetzoom.png -#win images/win/addtab.png images/win/book.png images/win/closetab.png @@ -33,5 +31,7 @@ images/win/zoomin.png images/win/zoomout.png images/win/resetzoom.png + images/closebutton.png + images/darkclosebutton.png diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index e562198..c5a46af 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -38,97 +38,49 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" #include "centralwidget.h" + #include "findwidget.h" #include "helpenginewrapper.h" #include "helpviewer_qtb.h" #include "helpviewer_qwv.h" -#include "searchwidget.h" -#include "mainwindow.h" +#include "tracer.h" #include "../shared/collectionconfiguration.h" #include -#include #include -#include -#include -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include #include QT_BEGIN_NAMESPACE namespace { - HelpViewer* helpViewerFromTabPosition(const QTabWidget *widget, - const QPoint &point) - { - TRACE_OBJ - QTabBar *tabBar = qFindChild(widget); - for (int i = 0; i < tabBar->count(); ++i) { - if (tabBar->tabRect(i).contains(point)) - return qobject_cast(widget->widget(i)); - } - return 0; - } CentralWidget *staticCentralWidget = 0; } // -- CentralWidget -CentralWidget::CentralWidget(MainWindow *parent) +CentralWidget::CentralWidget(QWidget *parent) : QWidget(parent) - , lastTabPage(0) - , tabWidget(0) , findWidget(0) , printer(0) - , usesDefaultCollection(parent->usesDefaultCollection()) { 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); + m_stackedWidget = new QStackedWidget(this); + vboxLayout->addWidget(m_stackedWidget); findWidget = new FindWidget(this); vboxLayout->addWidget(findWidget); @@ -140,14 +92,6 @@ CentralWidget::CentralWidget(MainWindow *parent) SLOT(find(QString, bool))); connect(findWidget, SIGNAL(escapePressed()), this, SLOT(activateTab())); - QTabBar *tabBar = qFindChild(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, @@ -167,18 +111,19 @@ CentralWidget::~CentralWidget() QStringList zoomFactors; QStringList currentPages; - for (int i = 0; i < tabWidget->count(); ++i) { - HelpViewer *viewer = qobject_cast(tabWidget->widget(i)); - if (viewer && viewer->source().isValid()) { - currentPages << viewer->source().toString(); + 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()); } } HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - helpEngine.setLastTabPage(tabWidget->currentIndex()); helpEngine.setLastShownPages(currentPages); helpEngine.setLastZoomFactors(zoomFactors); + helpEngine.setLastTabPage(m_stackedWidget->currentIndex()); } CentralWidget *CentralWidget::instance() @@ -187,16 +132,6 @@ CentralWidget *CentralWidget::instance() return staticCentralWidget; } -void CentralWidget::newTab() -{ - TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); -#if !defined(QT_NO_WEBKIT) - if (viewer->hasLoadFinished()) -#endif - setSourceInNewTab(viewer->source()); -} - void CentralWidget::zoomIn() { TRACE_OBJ @@ -209,110 +144,18 @@ void CentralWidget::zoomOut() currentHelpViewer()->scaleDown(); } -void CentralWidget::nextPage() -{ - TRACE_OBJ - int index = tabWidget->currentIndex() + 1; - if (index >= tabWidget->count()) - index = 0; - tabWidget->setCurrentIndex(index); -} - void CentralWidget::resetZoom() { TRACE_OBJ currentHelpViewer()->resetScale(); } -void CentralWidget::previousPage() -{ - TRACE_OBJ - int index = tabWidget->currentIndex() -1; - if (index < 0) - index = tabWidget->count() -1; - tabWidget->setCurrentIndex(index); -} - -void CentralWidget::closeTab() -{ - TRACE_OBJ - if (tabWidget->count() == 1) - return; - - HelpViewer *viewer = currentHelpViewer(); - tabWidget->removeTab(tabWidget->indexOf(viewer)); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); -} - void CentralWidget::setSource(const QUrl &url) { TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); - HelpViewer *lastViewer = - qobject_cast(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; - } - viewer->setSource(url); - currentPageChanged(lastTabPage); viewer->setFocus(Qt::OtherFocusReason); - tabWidget->setCurrentIndex(lastTabPage); - tabWidget->setTabText(lastTabPage, quoteTabTitle(viewer->documentTitle())); -} - -void CentralWidget::setupWidget() -{ - 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(); - } -} - -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); - - int tabToShow = helpEngine.lastTabPage(); - 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 <= tabToShow) - --tabToShow; - } - - tabWidget->setCurrentIndex(tabToShow); } bool CentralWidget::hasSelection() const @@ -434,78 +277,30 @@ void CentralWidget::backward() currentHelpViewer()->backward(); } - -QList CentralWidget::globalActions() const +void CentralWidget::connectSignals(HelpViewer *page) { TRACE_OBJ - return globalActionList; -} - -void CentralWidget::setGlobalActions(const QList &actions) -{ - TRACE_OBJ - globalActionList = actions; -} - -void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) -{ - TRACE_OBJ - - if (AbstractHelpViewer::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(); -} - -HelpViewer *CentralWidget::newEmptyTab() -{ - 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; -} - -void CentralWidget::connectSignals() -{ - TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - 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, + 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(viewer, SIGNAL(sourceChanged(QUrl)), this, - SLOT(setTabTitle(QUrl))); } HelpViewer* CentralWidget::viewerAt(int index) const { TRACE_OBJ - return qobject_cast(tabWidget->widget(index)); + return static_cast(m_stackedWidget->widget(index)); } HelpViewer* CentralWidget::currentHelpViewer() const { TRACE_OBJ - return qobject_cast(tabWidget->currentWidget()); + return static_cast(m_stackedWidget->currentWidget()); } void CentralWidget::activateTab() @@ -514,90 +309,6 @@ void CentralWidget::activateTab() currentHelpViewer()->setFocus(); } -void CentralWidget::setTabTitle(const QUrl &url) -{ - TRACE_OBJ - Q_UNUSED(url) -#if !defined(QT_NO_WEBKIT) - QTabBar *tabBar = qFindChild(tabWidget); - for (int tab = 0; tab < tabBar->count(); ++tab) { - HelpViewer *viewer = qobject_cast(tabWidget->widget(tab)); - if (viewer) { - tabWidget->setTabText(tab, - quoteTabTitle(viewer->documentTitle().trimmed())); - } - } -#else - HelpViewer *viewer = currentHelpViewer(); - tabWidget->setTabText(lastTabPage, - quoteTabTitle(viewer->documentTitle().trimmed())); -#endif -} - -void CentralWidget::currentPageChanged(int index) -{ - TRACE_OBJ - lastTabPage = index; - - QWidget *closeButton = tabWidget->cornerWidget(Qt::TopRightCorner); - closeButton->setEnabled(enableTabCloseAction()); - - emit currentViewerChanged(); -} - -void CentralWidget::showTabBarContextMenu(const QPoint &point) -{ - TRACE_OBJ - HelpViewer *viewer = helpViewerFromTabPosition(tabWidget, point); - if (!viewer) - return; - - QTabBar *tabBar = qFindChild(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(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()); -} - bool CentralWidget::eventFilter(QObject *object, QEvent *e) { TRACE_OBJ @@ -624,25 +335,6 @@ bool CentralWidget::eventFilter(QObject *object, QEvent *e) } } - if (qobject_cast(object)) { - const bool dblClick = e->type() == QEvent::MouseButtonDblClick; - if ((e->type() == QEvent::MouseButtonRelease) || dblClick) { - QMouseEvent *mouseEvent = static_cast(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); } @@ -782,31 +474,12 @@ bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward) void CentralWidget::updateBrowserFont() { TRACE_OBJ - const int count = tabWidget->count(); + const int count = m_stackedWidget->count(); const QFont &font = viewerAt(count - 1)->viewerFont(); for (int i = 0; i < count; ++i) viewerAt(i)->setViewerFont(font); } -int CentralWidget::availableHelpViewer() const -{ - TRACE_OBJ - return tabWidget->count(); -} - -bool CentralWidget::enableTabCloseAction() const -{ - TRACE_OBJ - return tabWidget->count() > 1; -} - -QString CentralWidget::quoteTabTitle(const QString &title) const -{ - TRACE_OBJ - QString s = title; - return s.replace(QLatin1Char('&'), QLatin1String("&&")); -} - void CentralWidget::setSourceFromSearch(const QUrl &url) { @@ -821,19 +494,6 @@ CentralWidget::setSourceFromSearch(const QUrl &url) } 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 -} - -void CentralWidget::highlightSearchTerms() { TRACE_OBJ @@ -900,48 +560,48 @@ CentralWidget::highlightSearchTerms() #endif } - -void CentralWidget::closeOrReloadTabs(const QList &indices, bool tryReload) +void CentralWidget::addPage(HelpViewer *page, bool fromSearch) { TRACE_OBJ - QList 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(tabWidget->widget(tab)); - if (HelpEngineWrapper::instance().findFile(viewer->source()).isValid()) { - viewer->reload(); - close = false; - } - } - if (close) - closeTabAt(tab); + page->installEventFilter(this); + page->setFocus(Qt::OtherFocusReason); + connectSignals(page); + m_stackedWidget->addWidget(page); + if (fromSearch) { +#if defined(QT_NO_WEBKIT) + highlightSearchTerms(); +#else + connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); +#endif } - if (availableHelpViewer() == 0) - setSource(QUrl(QLatin1String("about:blank"))); } -void CentralWidget::closeTabAt(int index) +void CentralWidget::removePage(int index) { TRACE_OBJ - HelpViewer *viewer = qobject_cast(tabWidget->widget(index)); - tabWidget->removeTab(index); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); + const bool currentChanged = index == currentIndex(); + m_stackedWidget->removeWidget(m_stackedWidget->widget(index)); + if (currentChanged) + emit currentViewerChanged(); } -QMap CentralWidget::currentSourceFileList() const +void CentralWidget::setCurrentPage(HelpViewer *page) { TRACE_OBJ - QMap sourceList; - for (int i = 0; i < tabWidget->count(); ++i) { - HelpViewer *viewer = qobject_cast(tabWidget->widget(i)); - if (viewer && viewer->source().isValid()) - sourceList.insert(i, viewer->source().host()); - } - return sourceList; + m_stackedWidget->setCurrentWidget(page); + emit currentViewerChanged(); +} + +int CentralWidget::currentIndex() const +{ + return m_stackedWidget->currentIndex(); +} + +void CentralWidget::handleSourceChanged(const QUrl &url) +{ + if (sender() == currentHelpViewer()) + emit sourceChanged(url); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 66d4142..9b8db30 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -48,45 +48,36 @@ QT_BEGIN_NAMESPACE class FindWidget; class HelpViewer; -class MainWindow; -class QHelpSearchEngine; -class QTabWidget; +class QStackedWidget; class CentralWidget : public QWidget { Q_OBJECT public: - CentralWidget(MainWindow *parent); + CentralWidget(QWidget *parent); ~CentralWidget(); - void setupWidget(); bool hasSelection() const; QUrl currentSource() const; QString currentTitle() const; bool isForwardAvailable() const; bool isBackwardAvailable() const; - QList globalActions() const; - void setGlobalActions(const QList &actions); HelpViewer *viewerAt(int index) const; HelpViewer *currentHelpViewer() const; - int availableHelpViewer() const; - bool enableTabCloseAction() const; - - void closeOrReloadTabs(const QList &indices, bool tryReload); - void closeTabAt(int index); - QMap currentSourceFileList() const; + void addPage(HelpViewer *page, bool fromSearch = false); + void removePage(int index); + void setCurrentPage(HelpViewer *page); + int currentIndex() const; static CentralWidget *instance(); public slots: void zoomIn(); void zoomOut(); - void nextPage(); void resetZoom(); - void previousPage(); void copySelection(); void showTextSearch(); void print(); @@ -94,8 +85,7 @@ public slots: void printPreview(); void updateBrowserFont(); void setSource(const QUrl &url); - void setSourceInNewTab(const QUrl &url, qreal zoom = 0.0); - HelpViewer *newEmptyTab(); + void setSourceFromSearch(const QUrl &url); void home(); void forward(); void backward(); @@ -106,9 +96,6 @@ public slots: void findPrevious(); void find(const QString &text, bool forward); - void setSourceFromSearch(const QUrl &url); - void setSourceFromSearchInNewTab(const QUrl &url); - signals: void currentViewerChanged(); void copyAvailable(bool yes); @@ -122,31 +109,21 @@ protected: void keyPressEvent(QKeyEvent *); 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 highlightSearchTerms(); + void handleSourceChanged(const QUrl &url); private: - void connectSignals(); + void connectSignals(HelpViewer *page); 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(); private: - int lastTabPage; - QList globalActionList; - - QTabWidget *tabWidget; + QStackedWidget *m_stackedWidget; FindWidget *findWidget; QPrinter *printer; - bool usesDefaultCollection; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index e0347c8..3af4d34 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -44,6 +44,7 @@ #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" +#include "openpagesmanager.h" #include #include @@ -145,7 +146,7 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e) if (contentModel) { QHelpContentItem *itm = contentModel->contentItemAt(index); if (itm && AbstractHelpViewer::canOpenPage(itm->url().path())) - CentralWidget::instance()->setSourceInNewTab(itm->url()); + OpenPagesManager::instance()->createPage(itm->url()); } } else if (button == Qt::LeftButton) { itemClicked(index); @@ -179,7 +180,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/globalactions.cpp b/tools/assistant/tools/assistant/globalactions.cpp new file mode 100644 index 0000000..75c57b6 --- /dev/null +++ b/tools/assistant/tools/assistant/globalactions.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "tracer.h" + +#include + +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; + + 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(copySelection())); + 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); +} + +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..e53e08f --- /dev/null +++ b/tools/assistant/tools/assistant/globalactions.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include + +QT_BEGIN_NAMESPACE + +class QAction; + +class GlobalActions : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(GlobalActions) +public: + static GlobalActions *instance(QObject *parent = 0); + + QList 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); + +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 m_actionList; +}; + +QT_END_NAMESPACE + +#endif // GLOBALACTION_H diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp index bba2850..f6df611 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -42,8 +42,9 @@ #if defined(QT_NO_WEBKIT) -#include "centralwidget.h" +#include "globalactions.h" #include "helpenginewrapper.h" +#include "openpagesmanager.h" #include "tracer.h" #include @@ -55,12 +56,10 @@ QT_BEGIN_NAMESPACE -HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) - : QTextBrowser(parent) - , zoomCount(zoom) +HelpViewer::HelpViewer(qreal zoom) + : zoomCount(zoom) , controlPressed(false) , lastAnchor(QString()) - , parentWidget(parent) , helpEngine(HelpEngineWrapper::instance()) , forceFont(false) { @@ -71,6 +70,7 @@ HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) QFont font = viewerFont(); font.setPointSize(int(font.pointSize() + zoom)); setViewerFont(font); + connect(this, SIGNAL(sourceChanged(QUrl), this, SIGNAL(titleChanged())); } HelpViewer::~HelpViewer() @@ -176,7 +176,7 @@ void HelpViewer::openLinkInNewTab() if(lastAnchor.isEmpty()) return; - parentWidget->setSourceInNewTab(QUrl(lastAnchor)); + OpenPagesManager::instance()->createNewTab(QUrl(lastAnchor)); lastAnchor.clear(); } @@ -222,7 +222,8 @@ void HelpViewer::contextMenuEvent(QContextMenuEvent *e) SLOT(openLinkInNewTab())); menu.addSeparator(); } - menu.addActions(parentWidget->globalActions()); + + menu.addActions(GlobalActions::instance()->actionList()); QAction *action = menu.exec(e->globalPos()); if (action == copyAnchorAction) QApplication::clipboard()->setText(link.toString()); diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.h b/tools/assistant/tools/assistant/helpviewer_qtb.h index 5b38870..b6ab903 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.h +++ b/tools/assistant/tools/assistant/helpviewer_qtb.h @@ -54,7 +54,6 @@ QT_BEGIN_NAMESPACE -class CentralWidget; class HelpEngineWrapper; class QContextMenuEvent; class QKeyEvent; @@ -65,7 +64,7 @@ class HelpViewer : public QTextBrowser, public AbstractHelpViewer Q_OBJECT public: - HelpViewer(CentralWidget *parent, qreal zoom = 0.0); + HelpViewer(qreal zoom = 0.0); ~HelpViewer(); QFont viewerFont() const; @@ -81,6 +80,9 @@ public: inline bool hasSelection() const { return textCursor().hasSelection(); } +signals: + void titleChanged(); + public Q_SLOTS: void home(); @@ -103,7 +105,6 @@ private: int zoomCount; bool controlPressed; QString lastAnchor; - CentralWidget* parentWidget; HelpEngineWrapper &helpEngine; bool forceFont; diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index 9bb66e1..934fb03 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -45,6 +45,7 @@ #include "centralwidget.h" #include "helpenginewrapper.h" +#include "openpagesmanager.h" #include "tracer.h" #include @@ -156,7 +157,7 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, class HelpPage : public QWebPage { public: - HelpPage(CentralWidget *central, QObject *parent); + HelpPage(QObject *parent); protected: virtual QWebPage *createWindow(QWebPage::WebWindowType); @@ -166,7 +167,6 @@ protected: const QNetworkRequest &request, NavigationType type); private: - CentralWidget *centralWidget; bool closeNewTabIfNeeded; friend class HelpViewer; @@ -174,9 +174,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) @@ -187,9 +186,8 @@ HelpPage::HelpPage(CentralWidget *central, QObject *parent) QWebPage *HelpPage::createWindow(QWebPage::WebWindowType) { TRACE_OBJ - HelpPage* newPage = static_cast(centralWidget->newEmptyTab()->page()); - if (newPage) - newPage->closeNewTabIfNeeded = closeNewTabIfNeeded; + HelpPage* newPage = static_cast(OpenPagesManager::instance()->createPage()->page()); + newPage->closeNewTabIfNeeded = closeNewTabIfNeeded; closeNewTabIfNeeded = false; return newPage; } @@ -216,18 +214,17 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, const QUrl &url = request.url(); if (AbstractHelpViewer::launchWithExternalApp(url)) { if (closeNewTab) - QMetaObject::invokeMethod(centralWidget, "closeTab"); + QMetaObject::invokeMethod(OpenPagesManager::instance(), "closeCurrentTab"); return false; } if (type == QWebPage::NavigationTypeLinkClicked && (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton)) { - if (HelpViewer* viewer = centralWidget->newEmptyTab()) - centralWidget->setSource(url); - m_pressedButtons = Qt::NoButton; - m_keyboardModifiers = Qt::NoModifier; - return false; + OpenPagesManager::instance()->createPage(url); + m_pressedButtons = Qt::NoButton; + m_keyboardModifiers = Qt::NoModifier; + return false; } return true; @@ -235,23 +232,18 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, // -- HelpViewer -HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) - : QWebView(parent) - , parentWidget(parent) - , loadFinished(false) +HelpViewer::HelpViewer(qreal zoom) + : loadFinished(false) , helpEngine(HelpEngineWrapper::instance()) { TRACE_OBJ setAcceptDrops(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); pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false); pageAction(QWebPage::DownloadImageToDisk)->setVisible(false); @@ -267,6 +259,7 @@ HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) SIGNAL(highlighted(QString))); connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); + connect(this, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged())); setFont(viewerFont()); setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom); diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h index fbfbaac..ea5ec78 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.h +++ b/tools/assistant/tools/assistant/helpviewer_qwv.h @@ -53,7 +53,6 @@ QT_BEGIN_NAMESPACE -class CentralWidget; class HelpEngineWrapper; class QMouseEvent; @@ -62,7 +61,7 @@ class HelpViewer : public QWebView, public AbstractHelpViewer Q_OBJECT public: - HelpViewer(CentralWidget *parent, qreal zoom = 0.0); + HelpViewer(qreal zoom = 0.0); ~HelpViewer(); QFont viewerFont() const; @@ -102,6 +101,7 @@ Q_SIGNALS: void backwardAvailable(bool enabled); void highlighted(const QString &); void sourceChanged(const QUrl &); + void titleChanged(); protected: virtual void wheelEvent(QWheelEvent *); @@ -113,7 +113,6 @@ private Q_SLOTS: void setLoadFinished(bool ok); private: - CentralWidget* parentWidget; bool loadFinished; HelpEngineWrapper &helpEngine; }; diff --git a/tools/assistant/tools/assistant/images/closebutton.png b/tools/assistant/tools/assistant/images/closebutton.png new file mode 100644 index 0000000..c978cf5 Binary files /dev/null and b/tools/assistant/tools/assistant/images/closebutton.png differ diff --git a/tools/assistant/tools/assistant/images/darkclosebutton.png b/tools/assistant/tools/assistant/images/darkclosebutton.png new file mode 100644 index 0000000..1077663 Binary files /dev/null and b/tools/assistant/tools/assistant/images/darkclosebutton.png differ diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp index 63ddbe4..7a47e85 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -44,6 +44,7 @@ #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" +#include "openpagesmanager.h" #include "topicchooser.h" #include @@ -222,7 +223,7 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index) if (!AbstractHelpViewer::canOpenPage(url.path())) CentralWidget::instance()->setSource(url); else - CentralWidget::instance()->setSourceInNewTab(url); + OpenPagesManager::instance()->createPage(url); } } diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 2605050..4c8a2dc 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -38,57 +38,55 @@ ** $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 -#include +#include #include #include -#include +#include #include #include -#include #include -#include +#include -#include #include -#include -#include +#include +#include +#include +#include +#include +#include #include -#include #include -#include -#include +#include +#include #include -#include -#include #include -#include +#include +#include #include -#include -#include -#include #include +#include #include +#include QT_BEGIN_NAMESPACE @@ -105,6 +103,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) TRACE_OBJ setToolButtonStyle(Qt::ToolButtonFollowStyle); + setDockOptions(ForceTabbedDocks); // Has no effect; Qt bug? QString collectionFile; if (usesDefaultCollection()) { @@ -146,12 +145,19 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) = 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(bookMarkManager, SIGNAL(escapePressed()), this, SLOT(activateCurrentCentralWidgetTab())); connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget, SLOT(setSource(QUrl))); - connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)), m_centralWidget, - SLOT(setSourceInNewTab(QUrl))); + connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)), + openPagesManager, SLOT(createPage(QUrl))); connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)), bookMarkManager, SLOT(addBookmark(QString, QString))); @@ -195,9 +201,11 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) } else { tabifyDockWidget(contentDock, indexDock); tabifyDockWidget(indexDock, bookmarkDock); - tabifyDockWidget(bookmarkDock, searchDock); + tabifyDockWidget(bookmarkDock, openPagesDock); + tabifyDockWidget(openPagesDock, searchDock); contentDock->raise(); - resize(QSize(1024, 768)); + const QRect screen = QApplication::desktop()->screenGeometry(); + resize(4*screen.width()/5, 4*screen.height()/5); } if (!helpEngineWrapper.hasFontSettings()) { @@ -261,6 +269,8 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) this, SLOT(documentationUpdated(QString))); } setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); + GlobalActions::instance()->updateActions(); + showNewAddress(); } MainWindow::~MainWindow() @@ -391,11 +401,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(); } @@ -418,18 +423,16 @@ 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_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"), m_centralWidget, - SLOT(closeTab())); + m_closeTabAction = menu->addAction(tr("&Close Tab"), + openPages, SLOT(closeCurrentPage())); m_closeTabAction->setShortcuts(QKeySequence::Close); QAction *tmp = menu->addAction(tr("&Quit"), this, SLOT(close())); @@ -441,19 +444,8 @@ void MainWindow::setupActions() #endif 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())); @@ -468,17 +460,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())); @@ -496,22 +479,13 @@ void MainWindow::setupActions() QKeySequence(tr("ALT+O"))); 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())); @@ -520,11 +494,11 @@ 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(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(tr("Ctrl+Alt+Left")) << QKeySequence(Qt::CTRL + Qt::Key_PageUp)); @@ -535,39 +509,25 @@ void MainWindow::setupActions() m_aboutAction->setMenuRole(QAction::AboutRole); #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_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_printAction->setIcon(QIcon::fromTheme("document-print" , m_printAction->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 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); @@ -577,16 +537,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))); @@ -605,10 +563,10 @@ void MainWindow::setupActions() SLOT(activateCurrentCentralWidgetTab())); // search window - connect(m_searchWindow, SIGNAL(requestShowLink(QUrl)), m_centralWidget, - SLOT(setSourceFromSearch(QUrl))); + connect(m_searchWindow, SIGNAL(requestShowLink(QUrl)), + CentralWidget::instance(), SLOT(setSourceFromSearch(QUrl))); connect(m_searchWindow, SIGNAL(requestShowLinkInNewTab(QUrl)), - m_centralWidget, SLOT(setSourceFromSearchInNewTab(QUrl))); + OpenPagesManager::instance(), SLOT(createNewPageFromSearch(QUrl))); #if defined(QT_NO_PRINTER) m_pageSetupAction->setVisible(false); @@ -733,20 +691,6 @@ void MainWindow::gotoAddress() m_centralWidget->setSource(m_addressLineEdit->text()); } -void MainWindow::updateNavigationItems() -{ - TRACE_OBJ - m_copyAction->setEnabled(m_centralWidget->hasSelection()); - m_nextAction->setEnabled(m_centralWidget->isForwardAvailable()); - m_backAction->setEnabled(m_centralWidget->isBackwardAvailable()); -} - -void MainWindow::updateTabCloseAction() -{ - TRACE_OBJ - m_closeTabAction->setEnabled(m_centralWidget->enableTabCloseAction()); -} - void MainWindow::showTopicChooser(const QMap &links, const QString &keyword) { @@ -780,12 +724,6 @@ void MainWindow::syncContents() qApp->restoreOverrideCursor(); } -void MainWindow::copyAvailable(bool yes) -{ - TRACE_OBJ - m_copyAction->setEnabled(yes); -} - void MainWindow::showAboutDialog() { TRACE_OBJ @@ -918,6 +856,12 @@ void MainWindow::showSearch() activateDockWidget(m_searchWindow); } +void MainWindow::showOpenPages() +{ + TRACE_OBJ + activateDockWidget(OpenPagesManager::instance()->openPagesWidget()); +} + void MainWindow::hideSearch() { TRACE_OBJ @@ -1071,17 +1015,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 6ac148e..93cc1ac 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -42,21 +42,23 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include #include #include QT_BEGIN_NAMESPACE class QAction; +class QComboBox; class QFileSystemWatcher; class QLineEdit; -class QComboBox; class QMenu; class CentralWidget; class CmdLineParser; class ContentWindow; class IndexWindow; +class OpenPagesWindow; class QtDocInstaller; class QHelpEngineCore; class QHelpEngine; @@ -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 &links, const QString &keyword); void updateApplicationFont(); @@ -148,17 +148,9 @@ private: 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..cd4460a --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesmanager.cpp @@ -0,0 +1,308 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 "helpviewer_qtb.h" +#include "helpviewer_qwv.h" +#include "openpagesmodel.h" +#include "openpageswidget.h" +#include "tracer.h" +#include "../shared/collectionconfiguration.h" + +#include + +QT_BEGIN_NAMESPACE + +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(new OpenPagesWidget(m_model)) +{ + TRACE_OBJ + 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))); + setupInitialPages(defaultCollection, cmdLineUrl); +} + +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); +} + +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 (AbstractHelpViewer::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) +{ + return createPage(url, true); +} + +void OpenPagesManager::closePage(const QModelIndex &index) +{ + 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); + 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()) + return; + HelpViewer * const page = m_model->pageAt(index.row()); + CentralWidget::instance()->setCurrentPage(page); +} + +void OpenPagesManager::setCurrentPage(int index) +{ + TRACE_OBJ + CentralWidget::instance()->setCurrentPage(m_model->pageAt(index)); + selectCurrentPage(); +} + +void OpenPagesManager::selectCurrentPage() +{ + TRACE_OBJ + QItemSelectionModel * const selModel = m_openPagesWidget->selectionModel(); + selModel->clearSelection(); + selModel->select(m_model->index(CentralWidget::instance()->currentIndex(), 0), + QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + m_openPagesWidget->scrollTo(m_openPagesWidget->currentIndex()); +} + +void OpenPagesManager::removePage(int index) +{ + TRACE_OBJ + CentralWidget::instance()->removePage(index); + m_model->removePage(index); + 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; + } +} + +QWidget *OpenPagesManager::openPagesWidget() const +{ + return m_openPagesWidget; +} + +void OpenPagesManager::nextPage() +{ + nextOrPreviousPage(1); +} + +void OpenPagesManager::previousPage() +{ + nextOrPreviousPage(-1); +} + +void OpenPagesManager::nextOrPreviousPage(int offset) +{ + setCurrentPage((CentralWidget::instance()->currentIndex() + offset + + m_model->rowCount()) % m_model->rowCount()); +} + +OpenPagesManager *OpenPagesManager::m_instance = 0; + +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..95bf247 --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesmanager.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 + +QT_BEGIN_NAMESPACE + +class QModelIndex; +class QUrl; +class QWidget; + +class HelpViewer; +class OpenPagesModel; +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); + + QWidget* openPagesWidget() const; + + int pageCount() const; + + public slots: + HelpViewer *createPage(const QUrl &url, bool fromSearch = false); + HelpViewer *createNewPageFromSearch(const QUrl &url); + HelpViewer *createPage(); + void closeCurrentPage(); + void nextPage(); + void previousPage(); + +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); + void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl); + void closeOrReloadPages(const QString &nameSpace, bool tryReload); + void setCurrentPage(int index); + void selectCurrentPage(); + void removePage(int index); + void nextOrPreviousPage(int offset); + + OpenPagesModel *m_model; + OpenPagesWidget *m_openPagesWidget; + + 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..9e31b84 --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesmodel.cpp @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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_qtb.h" +#include "helpviewer_qwv.h" +#include "tracer.h" + +#include +#include + +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())->documentTitle(); + 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(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/assistant/tools/assistant/openpagesmodel.h b/tools/assistant/tools/assistant/openpagesmodel.h new file mode 100644 index 0000000..64013a6 --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesmodel.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 OPENPAGESMODEL_H +#define OPENPAGESMODEL_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class HelpViewer; +class QUrl; + +class OpenPagesModel : public QAbstractTableModel +{ + Q_OBJECT +public: + 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; + + void addPage(const QUrl &url, qreal zoom = 0); + void removePage(int index); + HelpViewer *pageAt(int index) const; + +private slots: + void handleTitleChanged(); + +private: + QList m_pages; +}; + +QT_END_NAMESPACE + +#endif // OPENPAGESMODEL_H diff --git a/tools/assistant/tools/assistant/openpageswidget.cpp b/tools/assistant/tools/assistant/openpageswidget.cpp new file mode 100644 index 0000000..648ead8 --- /dev/null +++ b/tools/assistant/tools/assistant/openpageswidget.cpp @@ -0,0 +1,181 @@ +/************************************************************************** +** +** This file is part of the Assistant module of the Qt toolkit. +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "openpageswidget.h" + +#include "openpagesmodel.h" + +#include +#include +#include +#include +#include +#include + +#ifdef Q_WS_MAC +#include +#endif + +QT_BEGIN_NAMESPACE + +OpenPagesDelegate::OpenPagesDelegate(QObject *parent) + : QStyledItemDelegate(parent) +{ +} + +void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + 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 && 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(OpenPagesModel *model) +{ + setModel(model); + setIndentation(0); + setItemDelegate((m_delegate = new OpenPagesDelegate(this))); + + setFrameStyle(QFrame::NoFrame); + 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() +{ +} + +void OpenPagesWidget::contextMenuRequested(QPoint pos) +{ + const QModelIndex &index = indexAt(pos); + if (!index.isValid()) + return; + + 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) +{ + if (index.column() == 0) + emit setCurrentPage(index); + + if (index.column() == 1) + m_delegate->pressedIndex = index; +} + +void OpenPagesWidget::handleClicked(const QModelIndex &index) +{ + // 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) +{ + if (obj == this && event->type() == QEvent::KeyPress) { + if (currentIndex().isValid()) { + QKeyEvent *ke = static_cast(event); + const int key = ke->key(); + if ((key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Space) + && ke->modifiers() == 0) { + emit setCurrentPage(currentIndex()); + } else if ((key == Qt::Key_Delete || key == Qt::Key_Backspace) + && ke->modifiers() == 0 && model()->rowCount() > 1) { + emit closePage(currentIndex()); + } + } + } + return QWidget::eventFilter(obj, event); +} + +QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/openpageswidget.h b/tools/assistant/tools/assistant/openpageswidget.h new file mode 100644 index 0000000..5b35321 --- /dev/null +++ b/tools/assistant/tools/assistant/openpageswidget.h @@ -0,0 +1,76 @@ +/************************************************************************** +** +** This file is part of the Assistant module of the Qt toolkit. +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef OPENPAGESWIDGET_H +#define OPENPAGESWIDGET_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class OpenPagesModel; + +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: + OpenPagesWidget(OpenPagesModel *model); + ~OpenPagesWidget(); + +signals: + void setCurrentPage(const QModelIndex &index); + void closePage(const QModelIndex &index); + void closePagesExcept(const QModelIndex &index); + +private slots: + void contextMenuRequested(QPoint pos); + void handlePressed(const QModelIndex &index); + void handleClicked(const QModelIndex &index); + +private: + bool eventFilter(QObject *obj, QEvent *event); + + OpenPagesDelegate *m_delegate; +}; + +QT_END_NAMESPACE + +#endif // OPENPAGESWIDGET_H diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index 0e1d719..3535e5a 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 @@ -302,15 +303,12 @@ void PreferencesDialog::addDocumentationLocal() void PreferencesDialog::removeDocumentation() { TRACE_OBJ - bool foundBefore = false; - CentralWidget* widget = CentralWidget::instance(); - QMap openedDocList = widget->currentSourceFileList(); - QStringList values(openedDocList.values()); + bool foundBefore = false; QList 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,10 +371,10 @@ 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(); diff --git a/tools/assistant/tools/assistant/preferencesdialog.h b/tools/assistant/tools/assistant/preferencesdialog.h index 2894494..7a17275 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.h +++ b/tools/assistant/tools/assistant/preferencesdialog.h @@ -96,7 +96,6 @@ private: QStringList m_docsBackup; QStringList m_regDocs; QStringList m_unregDocs; - QList m_TabsToClose; FontPanel *m_appFontPanel; FontPanel *m_browserFontPanel; bool m_appFontChanged; diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index 5ecdd69..06e5602 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 #include @@ -323,8 +324,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(); } -- cgit v0.12