summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-09-14 17:22:44 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2020-09-15 10:35:12 +0200
commit979f7fe10b2c2a921efa483afe887c7d17297fc7 (patch)
tree0c0739f8c9a0a2cf8f67a3073be11f6981d5a4df
parent8f746d1d467854c05e8c9edb9ef8c8a3c12662df (diff)
Assistant: fix build with QT_NO_CLIPBOARD
Fixes: QTBUG-86598 Pick-to: 5.15 Change-Id: I02348fc3b3b8e842a2aaaac6f98078f86ba2a767 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-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 52e1cd4c6..4f3d749f4 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 f3d8837ce..6962c9931 100644
--- a/src/assistant/assistant/centralwidget.h
+++ b/src/assistant/assistant/centralwidget.h
@@ -95,7 +95,7 @@ public:
void connectTabBar();
public slots:
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void copy();
#endif
void home();
@@ -128,7 +128,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 20123f1e8..4e7b73784 100644
--- a/src/assistant/assistant/globalactions.cpp
+++ b/src/assistant/assistant/globalactions.cpp
@@ -106,6 +106,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");
@@ -114,6 +115,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);
@@ -134,7 +136,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()));
@@ -145,16 +149,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 aeae503ce..84ab800c3 100644
--- a/src/assistant/assistant/helpviewer.h
+++ b/src/assistant/assistant/helpviewer.h
@@ -105,7 +105,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 59785ecbb..e8eb27338 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>
@@ -245,7 +245,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
@@ -352,7 +352,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())
@@ -360,17 +362,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 b4492b6bf..3436e352e 100644
--- a/src/assistant/assistant/mainwindow.cpp
+++ b/src/assistant/assistant/mainwindow.cpp
@@ -556,7 +556,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"),
@@ -650,7 +652,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();
@@ -668,8 +672,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()) {