summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2010-06-02 13:50:05 +0200
committerkh1 <qt-info@nokia.com>2010-06-02 13:51:09 +0200
commit65cedbf9872bbf8e64ff03c49abce09a292d7ec0 (patch)
tree6a876264f725962e798504b7643dfe0bac817d6a /tools
parent2573227b32597f3ae1ab861f0724765662e41174 (diff)
Backport open pages switcher from Qt Creator.
Reviewed-by: ck
Diffstat (limited to 'tools')
-rw-r--r--tools/assistant/tools/assistant/assistant.pro6
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp13
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.cpp98
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.h11
-rw-r--r--tools/assistant/tools/assistant/openpagesswitcher.cpp194
-rw-r--r--tools/assistant/tools/assistant/openpagesswitcher.h85
-rw-r--r--tools/assistant/tools/assistant/openpageswidget.cpp22
-rw-r--r--tools/assistant/tools/assistant/openpageswidget.h4
8 files changed, 403 insertions, 30 deletions
diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro
index af306a551b..97d88dc1b1 100644
--- a/tools/assistant/tools/assistant/assistant.pro
+++ b/tools/assistant/tools/assistant/assistant.pro
@@ -47,7 +47,8 @@ HEADERS += aboutdialog.h \
openpagesmodel.h \
globalactions.h \
openpageswidget.h \
- openpagesmanager.h
+ openpagesmanager.h \
+ openpagesswitcher.h
win32:HEADERS += remotecontrol_win.h
SOURCES += aboutdialog.cpp \
@@ -78,7 +79,8 @@ SOURCES += aboutdialog.cpp \
openpagesmodel.cpp \
globalactions.cpp \
openpageswidget.cpp \
- openpagesmanager.cpp
+ openpagesmanager.cpp \
+ openpagesswitcher.cpp
contains(QT_CONFIG, webkit) {
SOURCES += helpviewer_qwv.cpp
} else {
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index ca10d381cf..e4362018bb 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -79,6 +79,7 @@
#include <QtGui/QMenuBar>
#include <QtGui/QMessageBox>
#include <QtGui/QProgressBar>
+#include <QtGui/QShortcut>
#include <QtGui/QStatusBar>
#include <QtGui/QToolBar>
#include <QtGui/QToolButton>
@@ -516,6 +517,18 @@ void MainWindow::setupActions()
tmp->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("Ctrl+Alt+Left"))
<< QKeySequence(Qt::CTRL + Qt::Key_PageUp));
+#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()->takeBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks")));
menu = menuBar()->addMenu(tr("&Help"));
diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp
index 490fdddf83..6b08c466e9 100644
--- a/tools/assistant/tools/assistant/openpagesmanager.cpp
+++ b/tools/assistant/tools/assistant/openpagesmanager.cpp
@@ -38,20 +38,25 @@
** $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)
{
@@ -70,25 +75,43 @@ OpenPagesManager *OpenPagesManager::instance()
OpenPagesManager::OpenPagesManager(QObject *parent, bool defaultCollection,
const QUrl &cmdLineUrl)
- : QObject(parent), m_model(new OpenPagesModel(this)),
- m_openPagesWidget(new OpenPagesWidget(m_model))
+ : 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)
{
@@ -145,6 +168,7 @@ void OpenPagesManager::setupInitialPages(bool defaultCollection,
for (int i = 0; i < m_model->rowCount(); ++i)
CentralWidget::instance()->addPage(m_model->pageAt(i));
setCurrentPage(initialPage);
+ m_openPagesSwitcher->selectCurrentPage();
}
HelpViewer *OpenPagesManager::createPage()
@@ -202,13 +226,12 @@ void OpenPagesManager::reloadPages(const QString &nameSpace)
{
TRACE_OBJ
closeOrReloadPages(nameSpace, true);
- selectCurrentPage();
+ 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)
@@ -234,27 +257,15 @@ bool OpenPagesManager::pagesOpenForNamespace(const QString &nameSpace) const
void OpenPagesManager::setCurrentPage(const QModelIndex &index)
{
TRACE_OBJ
- if (!index.isValid())
- return;
- HelpViewer * const page = m_model->pageAt(index.row());
- CentralWidget::instance()->setCurrentPage(page);
+ if (index.isValid())
+ setCurrentPage(index.row());
}
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());
+ m_openPagesWidget->selectCurrentPage();
}
void OpenPagesManager::removePage(int index)
@@ -262,7 +273,7 @@ void OpenPagesManager::removePage(int index)
TRACE_OBJ
CentralWidget::instance()->removePage(index);
m_model->removePage(index);
- selectCurrentPage();
+ m_openPagesWidget->selectCurrentPage();
}
@@ -294,12 +305,36 @@ void OpenPagesManager::nextPage()
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
@@ -307,6 +342,19 @@ void OpenPagesManager::nextOrPreviousPage(int offset)
+ m_model->rowCount()) % m_model->rowCount());
}
-OpenPagesManager *OpenPagesManager::m_instance = 0;
+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
index 0ae3180995..56a1ce74ee 100644
--- a/tools/assistant/tools/assistant/openpagesmanager.h
+++ b/tools/assistant/tools/assistant/openpagesmanager.h
@@ -52,6 +52,7 @@ class QUrl;
class HelpViewer;
class OpenPagesModel;
+class OpenPagesSwitcher;
class OpenPagesWidget;
class OpenPagesManager : public QObject
@@ -76,8 +77,11 @@ public slots:
HelpViewer *createNewPageFromSearch(const QUrl &url);
HelpViewer *createPage();
void closeCurrentPage();
+
void nextPage();
+ void nextPageWithSwitcher();
void previousPage();
+ void previousPageWithSwitcher();
private slots:
void setCurrentPage(const QModelIndex &index);
@@ -87,13 +91,18 @@ private slots:
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 selectCurrentPage();
void removePage(int index);
+
void nextOrPreviousPage(int offset);
+ void showSwitcherOrSelectPage() const;
+
OpenPagesModel *m_model;
OpenPagesWidget *m_openPagesWidget;
+ OpenPagesSwitcher *m_openPagesSwitcher;
static OpenPagesManager *m_instance;
};
diff --git a/tools/assistant/tools/assistant/openpagesswitcher.cpp b/tools/assistant/tools/assistant/openpagesswitcher.cpp
new file mode 100644
index 0000000000..d4b7d82229
--- /dev/null
+++ b/tools/assistant/tools/assistant/openpagesswitcher.cpp
@@ -0,0 +1,194 @@
+/****************************************************************************
+**
+** 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 "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/assistant/tools/assistant/openpagesswitcher.h b/tools/assistant/tools/assistant/openpagesswitcher.h
new file mode 100644
index 0000000000..e27db6bd6e
--- /dev/null
+++ b/tools/assistant/tools/assistant/openpagesswitcher.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** 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 OPENPAGESSWITCHER_H
+#define OPENPAGESSWITCHER_H
+
+#include <QtGui/QFrame>
+
+QT_BEGIN_NAMESPACE
+
+class OpenPagesModel;
+class OpenPagesWidget;
+class QModelIndex;
+
+class OpenPagesSwitcher : public QFrame
+{
+ Q_OBJECT
+
+public:
+ OpenPagesSwitcher(OpenPagesModel *model);
+ ~OpenPagesSwitcher();
+
+ void gotoNextPage();
+ void gotoPreviousPage();
+
+ void selectAndHide();
+ void selectCurrentPage();
+
+ void setVisible(bool visible);
+ void focusInEvent(QFocusEvent *event);
+ bool eventFilter(QObject *object, QEvent *event);
+
+signals:
+ void closePage(const QModelIndex &index);
+ void setCurrentPage(const QModelIndex &index);
+
+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
index 1a5c2929d7..a68da23d70 100644
--- a/tools/assistant/tools/assistant/openpageswidget.cpp
+++ b/tools/assistant/tools/assistant/openpageswidget.cpp
@@ -41,6 +41,7 @@
#include "openpageswidget.h"
+#include "centralwidget.h"
#include "openpagesmodel.h"
#include "tracer.h"
@@ -90,15 +91,16 @@ void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt
}
}
+// -- OpenPagesWidget
OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model)
+ : m_allowContextMenu(true)
{
TRACE_OBJ
setModel(model);
setIndentation(0);
setItemDelegate((m_delegate = new OpenPagesDelegate(this)));
- setFrameStyle(QFrame::NoFrame);
setTextElideMode(Qt::ElideMiddle);
setAttribute(Qt::WA_MacShowFocusRect, false);
@@ -129,11 +131,27 @@ OpenPagesWidget::~OpenPagesWidget()
TRACE_OBJ
}
+void OpenPagesWidget::selectCurrentPage()
+{
+ TRACE_OBJ
+ QItemSelectionModel * const selModel = selectionModel();
+ selModel->clearSelection();
+ selModel->select(model()->index(CentralWidget::instance()->currentIndex(), 0),
+ QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+ 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())
+ if (!index.isValid() || !m_allowContextMenu)
return;
if (index.column() == 1)
diff --git a/tools/assistant/tools/assistant/openpageswidget.h b/tools/assistant/tools/assistant/openpageswidget.h
index 46c0022afe..4b972f3d4c 100644
--- a/tools/assistant/tools/assistant/openpageswidget.h
+++ b/tools/assistant/tools/assistant/openpageswidget.h
@@ -67,6 +67,9 @@ public:
OpenPagesWidget(OpenPagesModel *model);
~OpenPagesWidget();
+ void selectCurrentPage();
+ void allowContextMenu(bool ok);
+
signals:
void setCurrentPage(const QModelIndex &index);
void closePage(const QModelIndex &index);
@@ -80,6 +83,7 @@ private slots:
private:
bool eventFilter(QObject *obj, QEvent *event);
+ bool m_allowContextMenu;
OpenPagesDelegate *m_delegate;
};