summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-09-14 17:22:44 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-09-15 10:27:54 +0000
commit3c9315592180e8ae0404bccd4a843bac977c589c (patch)
tree351997366c214953be0f5e09b4068a716d9ca998
parentc73abc317a7970740aabfb5a11b0af3970a577e0 (diff)
Assistant: fix build with QT_NO_CLIPBOARD
Fixes: QTBUG-86598 Change-Id: I02348fc3b3b8e842a2aaaac6f98078f86ba2a767 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 979f7fe10b2c2a921efa483afe887c7d17297fc7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/assistant/assistant/centralwidget.cpp4
-rw-r--r--src/assistant/assistant/centralwidget.h4
-rw-r--r--src/assistant/assistant/globalactions.cpp8
-rw-r--r--src/assistant/assistant/globalactions.h18
-rw-r--r--src/assistant/assistant/helpviewer.h2
-rw-r--r--src/assistant/assistant/helpviewer_qtb.cpp12
-rw-r--r--src/assistant/assistant/helpviewer_qwv.cpp6
-rw-r--r--src/assistant/assistant/mainwindow.cpp6
-rw-r--r--src/assistant/assistant/searchwidget.cpp8
9 files changed, 49 insertions, 19 deletions
diff --git a/src/assistant/assistant/centralwidget.cpp b/src/assistant/assistant/centralwidget.cpp
index bac8f6fc8..7c0a1adbc 100644
--- a/src/assistant/assistant/centralwidget.cpp
+++ b/src/assistant/assistant/centralwidget.cpp
@@ -330,7 +330,7 @@ void CentralWidget::connectTabBar()
// -- public slots
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void CentralWidget::copy()
{
TRACE_OBJ
@@ -597,8 +597,10 @@ void CentralWidget::connectSignals(HelpViewer *page)
connect(page, &HelpViewer::printRequested,
this, &CentralWidget::print);
#endif
+#if QT_CONFIG(clipboard)
connect(page, &HelpViewer::copyAvailable,
this, &CentralWidget::copyAvailable);
+#endif
connect(page, &HelpViewer::forwardAvailable,
this, &CentralWidget::forwardAvailable);
connect(page, &HelpViewer::backwardAvailable,
diff --git a/src/assistant/assistant/centralwidget.h b/src/assistant/assistant/centralwidget.h
index 4943c2ff3..425d2294c 100644
--- a/src/assistant/assistant/centralwidget.h
+++ b/src/assistant/assistant/centralwidget.h
@@ -94,7 +94,7 @@ public:
void connectTabBar();
public slots:
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void copy();
#endif
void home();
@@ -127,7 +127,9 @@ public slots:
signals:
void currentViewerChanged();
+#if QT_CONFIG(clipboard)
void copyAvailable(bool yes);
+#endif
void sourceChanged(const QUrl &url);
void highlighted(const QUrl &link);
void forwardAvailable(bool available);
diff --git a/src/assistant/assistant/globalactions.cpp b/src/assistant/assistant/globalactions.cpp
index 6accd6dcd..0bab9c793 100644
--- a/src/assistant/assistant/globalactions.cpp
+++ b/src/assistant/assistant/globalactions.cpp
@@ -105,6 +105,7 @@ GlobalActions::GlobalActions(QObject *parent) : QObject(parent)
separator->setSeparator(true);
m_actionList << separator;
+#if QT_CONFIG(clipboard)
m_copyAction = new QAction(tr("&Copy selected Text"), parent);
m_copyAction->setPriority(QAction::LowPriority);
m_copyAction->setIconText("&Copy");
@@ -113,6 +114,7 @@ GlobalActions::GlobalActions(QObject *parent) : QObject(parent)
m_copyAction->setEnabled(false);
connect(m_copyAction, &QAction::triggered, centralWidget, &CentralWidget::copy);
m_actionList << m_copyAction;
+#endif
m_printAction = new QAction(tr("&Print..."), parent);
m_printAction->setPriority(QAction::LowPriority);
@@ -133,7 +135,9 @@ GlobalActions::GlobalActions(QObject *parent) : QObject(parent)
m_nextAction->setIcon(QIcon::fromTheme(QStringLiteral("go-next") , m_nextAction->icon()));
m_zoomInAction->setIcon(QIcon::fromTheme(QStringLiteral("zoom-in") , m_zoomInAction->icon()));
m_zoomOutAction->setIcon(QIcon::fromTheme(QStringLiteral("zoom-out") , m_zoomOutAction->icon()));
+#if QT_CONFIG(clipboard)
m_copyAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy") , m_copyAction->icon()));
+#endif
m_findAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-find") , m_findAction->icon()));
m_homeAction->setIcon(QIcon::fromTheme(QStringLiteral("go-home") , m_homeAction->icon()));
m_printAction->setIcon(QIcon::fromTheme(QStringLiteral("document-print") , m_printAction->icon()));
@@ -144,16 +148,20 @@ void GlobalActions::updateActions()
{
TRACE_OBJ
CentralWidget *centralWidget = CentralWidget::instance();
+#if QT_CONFIG(clipboard)
m_copyAction->setEnabled(centralWidget->hasSelection());
+#endif
m_nextAction->setEnabled(centralWidget->isForwardAvailable());
m_backAction->setEnabled(centralWidget->isBackwardAvailable());
}
+#if QT_CONFIG(clipboard)
void GlobalActions::setCopyAvailable(bool available)
{
TRACE_OBJ
m_copyAction->setEnabled(available);
}
+#endif
#if defined(BROWSER_QTWEBKIT)
diff --git a/src/assistant/assistant/globalactions.h b/src/assistant/assistant/globalactions.h
index a3a4dec63..ad59c435a 100644
--- a/src/assistant/assistant/globalactions.h
+++ b/src/assistant/assistant/globalactions.h
@@ -26,11 +26,12 @@
**
****************************************************************************/
-#ifndef GLOBALACTION_H
-#define GLOBALACTION_H
+#ifndef GLOBALACTIONS_H
+#define GLOBALACTIONS_H
#include <QtCore/QList>
#include <QtCore/QObject>
+#include <QtGui/qtguiglobal.h>
QT_BEGIN_NAMESPACE
@@ -50,12 +51,17 @@ public:
QAction *homeAction() const { return m_homeAction; }
QAction *zoomInAction() const { return m_zoomInAction; }
QAction *zoomOutAction() const { return m_zoomOutAction; }
+#if QT_CONFIG(clipboard)
QAction *copyAction() const { return m_copyAction; }
+#endif
QAction *printAction() const { return m_printAction; }
QAction *findAction() const { return m_findAction; }
- Q_SLOT void updateActions();
- Q_SLOT void setCopyAvailable(bool available);
+public slots:
+#if QT_CONFIG(clipboard)
+ void setCopyAvailable(bool available);
+#endif
+ void updateActions();
#if defined(BROWSER_QTWEBKIT)
private slots:
@@ -77,7 +83,9 @@ private:
QAction *m_homeAction;
QAction *m_zoomInAction;
QAction *m_zoomOutAction;
+#if QT_CONFIG(clipboard)
QAction *m_copyAction;
+#endif
QAction *m_printAction;
QAction *m_findAction;
@@ -89,4 +97,4 @@ private:
QT_END_NAMESPACE
-#endif // GLOBALACTION_H
+#endif // GLOBALACTIONS_H
diff --git a/src/assistant/assistant/helpviewer.h b/src/assistant/assistant/helpviewer.h
index acd38c66e..f291da215 100644
--- a/src/assistant/assistant/helpviewer.h
+++ b/src/assistant/assistant/helpviewer.h
@@ -101,7 +101,7 @@ public:
static bool launchWithExternalApp(const QUrl &url);
public slots:
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void copy();
#endif
void home() TEXTBROWSER_OVERRIDE;
diff --git a/src/assistant/assistant/helpviewer_qtb.cpp b/src/assistant/assistant/helpviewer_qtb.cpp
index 3d64f772d..7b9a99e49 100644
--- a/src/assistant/assistant/helpviewer_qtb.cpp
+++ b/src/assistant/assistant/helpviewer_qtb.cpp
@@ -39,7 +39,7 @@
#include <QtGui/QContextMenuEvent>
#include <QtWidgets/QMenu>
#include <QtWidgets/QScrollBar>
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
#include <QtGui/QClipboard>
#endif
#include <QtWidgets/QApplication>
@@ -238,7 +238,7 @@ bool HelpViewer::findText(const QString &text, FindFlags flags, bool incremental
// -- public slots
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void HelpViewer::copy()
{
TRACE_OBJ
@@ -345,7 +345,9 @@ void HelpViewer::contextMenuEvent(QContextMenuEvent *event)
QMenu menu(QString(), nullptr);
QUrl link;
+#if QT_CONFIG(clipboard)
QAction *copyAnchorAction = nullptr;
+#endif
if (d->hasAnchorAt(this, event->pos())) {
link = anchorAt(event->pos());
if (link.isRelative())
@@ -353,17 +355,19 @@ void HelpViewer::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(tr("Open Link"), d, &HelpViewerPrivate::openLink);
menu.addAction(tr("Open Link in New Tab\tCtrl+LMB"), d, &HelpViewerPrivate::openLinkInNewPage);
+#if QT_CONFIG(clipboard)
if (!link.isEmpty() && link.isValid())
copyAnchorAction = menu.addAction(tr("Copy &Link Location"));
+#endif
} else if (!selectedText().isEmpty()) {
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
menu.addAction(tr("Copy"), this, &HelpViewer::copy);
#endif
} else {
menu.addAction(tr("Reload"), this, &HelpViewer::reload);
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
if (copyAnchorAction == menu.exec(event->globalPos()))
QApplication::clipboard()->setText(link.toString());
#endif
diff --git a/src/assistant/assistant/helpviewer_qwv.cpp b/src/assistant/assistant/helpviewer_qwv.cpp
index 5f2c5583a..7ed073eb8 100644
--- a/src/assistant/assistant/helpviewer_qwv.cpp
+++ b/src/assistant/assistant/helpviewer_qwv.cpp
@@ -101,7 +101,7 @@ void HelpPage::triggerAction(WebAction action, bool checked)
break;
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
if (action == CopyLinkToClipboard || action == CopyImageUrlToClipboard) {
const QString link = QApplication::clipboard()->text();
QApplication::clipboard()->setText(HelpEngineWrapper::instance().findFile(link).toString());
@@ -291,7 +291,7 @@ bool HelpViewer::findText(const QString &text, FindFlags flags, bool incremental
// -- public slots
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void HelpViewer::copy()
{
TRACE_OBJ
@@ -317,7 +317,7 @@ void HelpViewer::keyPressEvent(QKeyEvent *e)
{
TRACE_OBJ
// TODO: remove this once we support multiple keysequences per command
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
if (e->key() == Qt::Key_Insert && e->modifiers() == Qt::CTRL) {
if (!selectedText().isEmpty())
copy();
diff --git a/src/assistant/assistant/mainwindow.cpp b/src/assistant/assistant/mainwindow.cpp
index 7c0b5de7f..1c5de9b85 100644
--- a/src/assistant/assistant/mainwindow.cpp
+++ b/src/assistant/assistant/mainwindow.cpp
@@ -555,7 +555,9 @@ void MainWindow::setupActions()
tmp->setMenuRole(QAction::QuitRole);
menu = menuBar()->addMenu(tr("&Edit"));
+#if QT_CONFIG(clipboard)
menu->addAction(globalActions->copyAction());
+#endif
menu->addAction(globalActions->findAction());
QAction *findNextAction = menu->addAction(tr("Find &Next"),
@@ -649,7 +651,9 @@ void MainWindow::setupActions()
navigationBar->addAction(globalActions->homeAction());
navigationBar->addAction(m_syncAction);
navigationBar->addSeparator();
+#if QT_CONFIG(clipboard)
navigationBar->addAction(globalActions->copyAction());
+#endif
navigationBar->addAction(globalActions->printAction());
navigationBar->addAction(globalActions->findAction());
navigationBar->addSeparator();
@@ -667,8 +671,10 @@ void MainWindow::setupActions()
#endif
// content viewer connections
+#if QT_CONFIG(clipboard)
connect(m_centralWidget, &CentralWidget::copyAvailable,
globalActions, &GlobalActions::setCopyAvailable);
+#endif
connect(m_centralWidget, &CentralWidget::currentViewerChanged,
globalActions, &GlobalActions::updateActions);
connect(m_centralWidget, &CentralWidget::forwardAvailable,
diff --git a/src/assistant/assistant/searchwidget.cpp b/src/assistant/assistant/searchwidget.cpp
index ae7b58f2c..d6466b1cc 100644
--- a/src/assistant/assistant/searchwidget.cpp
+++ b/src/assistant/assistant/searchwidget.cpp
@@ -38,7 +38,7 @@
#include <QtWidgets/QMenu>
#include <QtWidgets/QLayout>
#include <QtGui/QKeyEvent>
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
#include <QtGui/QClipboard>
#endif
#include <QtWidgets/QApplication>
@@ -184,15 +184,15 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent)
QUrl link = browser->anchorAt(point);
QKeySequence keySeq;
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
keySeq = QKeySequence::Copy;
QAction *copyAction = menu.addAction(tr("&Copy") + QLatin1Char('\t') +
keySeq.toString(QKeySequence::NativeText));
copyAction->setEnabled(QTextCursor(browser->textCursor()).hasSelection());
-#endif
QAction *copyAnchorAction = menu.addAction(tr("Copy &Link Location"));
copyAnchorAction->setEnabled(!link.isEmpty() && link.isValid());
+#endif
keySeq = QKeySequence(Qt::CTRL);
QAction *newTabAction = menu.addAction(tr("Open Link in New Tab") +
@@ -207,7 +207,7 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent)
QLatin1Char('\t') + keySeq.toString(QKeySequence::NativeText));
QAction *usedAction = menu.exec(mapToGlobal(contextMenuEvent->pos()));
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
if (usedAction == copyAction) {
QTextCursor cursor = browser->textCursor();
if (!cursor.isNull() && cursor.hasSelection()) {