summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Holzammer <andreas.holzammer.qnx@kdab.com>2012-04-20 10:21:10 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-20 10:40:04 +0200
commit0b526b2baed013c23cf856da8816e38e89f34dbf (patch)
treeadfd137bb45a1b07048b3ee151b5401652360a7f
parentd25d0f9bf91bef3c2ac179c76569dd47121e09b3 (diff)
downloadqttools-0b526b2baed013c23cf856da8816e38e89f34dbf.tar.gz
Fix build of designer components with QT_NO_CLIPBOARD
Change-Id: I8bfcb5baed75a481c279e6114ae95b62dc252dc4 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
-rw-r--r--src/designer/src/components/formeditor/formwindow.cpp18
-rw-r--r--src/designer/src/components/formeditor/formwindow.h4
-rw-r--r--src/designer/src/components/formeditor/formwindowmanager.cpp20
-rw-r--r--src/designer/src/components/formeditor/formwindowmanager.h4
-rw-r--r--src/designer/src/components/propertyeditor/designerpropertymanager.cpp10
5 files changed, 50 insertions, 6 deletions
diff --git a/src/designer/src/components/formeditor/formwindow.cpp b/src/designer/src/components/formeditor/formwindow.cpp
index 0a1808762..5d086f74b 100644
--- a/src/designer/src/components/formeditor/formwindow.cpp
+++ b/src/designer/src/components/formeditor/formwindow.cpp
@@ -92,7 +92,9 @@
#include <QtWidgets/QMenu>
#include <QtWidgets/QAction>
#include <QtWidgets/QActionGroup>
+#ifndef QT_NO_CLIPBOARD
#include <QtGui/QClipboard>
+#endif
#include <QtWidgets/QUndoGroup>
#include <QtWidgets/QScrollArea>
#include <QtWidgets/QRubberBand>
@@ -1660,6 +1662,7 @@ QString FormWindow::contents() const
return QString::fromUtf8(b.buffer());
}
+#ifndef QT_NO_CLIPBOARD
void FormWindow::copy()
{
QBuffer b;
@@ -1682,6 +1685,12 @@ void FormWindow::cut()
deleteWidgets();
}
+void FormWindow::paste()
+{
+ paste(PasteAll);
+}
+#endif
+
// for cases like QMainWindow (central widget is an inner container) or QStackedWidget (page is an inner container)
QWidget *FormWindow::innerContainer(QWidget *outerContainer) const
{
@@ -1737,11 +1746,7 @@ QWidget *FormWindow::containerForPaste() const
return w;
}
-void FormWindow::paste()
-{
- paste(PasteAll);
-}
-
+#ifndef QT_NO_CLIPBOARD
// Construct DomUI from clipboard (paste) and determine number of widgets/actions.
static inline DomUI *domUIFromClipboard(int *widgetCount, int *actionCount)
{
@@ -1782,6 +1787,7 @@ static inline DomUI *domUIFromClipboard(int *widgetCount, int *actionCount)
}
return ui;
}
+#endif
static inline QString pasteCommandDescription(int widgetCount, int actionCount)
{
@@ -1824,6 +1830,7 @@ static void positionPastedWidgetsAtMousePosition(FormWindow *fw, const QPoint &c
(*it)->move((*it)->pos() + offset);
}
+#ifndef QT_NO_CLIPBOARD
void FormWindow::paste(PasteMode pasteMode)
{
// Avoid QDesignerResource constructing widgets that are not used as
@@ -1886,6 +1893,7 @@ void FormWindow::paste(PasteMode pasteMode)
} while (false);
delete ui;
}
+#endif
// Draw a dotted frame around containers
bool FormWindow::frameNeeded(QWidget *w) const
diff --git a/src/designer/src/components/formeditor/formwindow.h b/src/designer/src/components/formeditor/formwindow.h
index d84c6de2f..04e31d0db 100644
--- a/src/designer/src/components/formeditor/formwindow.h
+++ b/src/designer/src/components/formeditor/formwindow.h
@@ -206,7 +206,9 @@ public:
// Initialize and return a popup menu for a managed widget
QMenu *initializePopupMenu(QWidget *managedWidget);
+#ifndef QT_NO_CLIPBOARD
virtual void paste(PasteMode pasteMode);
+#endif
virtual QEditorFormBuilder *createFormBuilder();
bool eventFilter(QObject *watched, QEvent *event);
@@ -218,9 +220,11 @@ public slots:
void deleteWidgets();
void raiseWidgets();
void lowerWidgets();
+#ifndef QT_NO_CLIPBOARD
void copy();
void cut();
void paste();
+#endif
void selectAll();
void createLayout(int type, QWidget *container = 0);
diff --git a/src/designer/src/components/formeditor/formwindowmanager.cpp b/src/designer/src/components/formeditor/formwindowmanager.cpp
index bddbe4d9b..0fe4a9aa4 100644
--- a/src/designer/src/components/formeditor/formwindowmanager.cpp
+++ b/src/designer/src/components/formeditor/formwindowmanager.cpp
@@ -79,7 +79,9 @@
#include <QtGui/QMouseEvent>
#include <QtWidgets/QApplication>
#include <QtWidgets/QSizeGrip>
+#ifndef QT_NO_CLIPBOARD
#include <QtGui/QClipboard>
+#endif
#include <QtWidgets/QMdiArea>
#include <QtWidgets/QMdiSubWindow>
#include <QtWidgets/QDesktopWidget>
@@ -168,7 +170,9 @@ bool FormWindowManager::eventFilter(QObject *o, QEvent *e)
case QEvent::ChildAdded:
case QEvent::ChildPolished:
case QEvent::ChildRemoved:
+#ifndef QT_NO_CLIPBOARD
case QEvent::Clipboard:
+#endif
case QEvent::ContentsRectChange:
case QEvent::DeferredDelete:
case QEvent::FileOpen:
@@ -360,6 +364,7 @@ QWidget *FormWindowManager::findManagedWidget(FormWindow *fw, QWidget *w)
void FormWindowManager::setupActions()
{
+#ifndef QT_NO_CLIPBOARD
m_actionCut = new QAction(createIconSet(QStringLiteral("editcut.png")), tr("Cu&t"), this);
m_actionCut->setObjectName(QStringLiteral("__qt_cut_action"));
m_actionCut->setShortcut(QKeySequence::Cut);
@@ -383,6 +388,7 @@ void FormWindowManager::setupActions()
m_actionPaste->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Paste")));
connect(m_actionPaste, SIGNAL(triggered()), this, SLOT(slotActionPasteActivated()));
m_actionPaste->setEnabled(false);
+#endif
m_actionDelete = new QAction(tr("&Delete"), this);
m_actionDelete->setObjectName(QStringLiteral("__qt_delete_action"));
@@ -520,9 +526,11 @@ void FormWindowManager::setupActions()
m_actionShowFormWindowSettingsDialog->setEnabled(false);
#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
+#ifndef QT_NO_CLIPBOARD
m_actionCopy->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"), m_actionCopy->icon()));
m_actionCut->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut"), m_actionCut->icon()));
m_actionPaste->setIcon(QIcon::fromTheme(QStringLiteral("edit-paste"), m_actionPaste->icon()));
+#endif
m_actionDelete->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete"), m_actionDelete->icon()));
// These do not currently exist, but will allow theme authors to fill in the gaps
@@ -536,6 +544,7 @@ void FormWindowManager::setupActions()
#endif
}
+#ifndef QT_NO_CLIPBOARD
void FormWindowManager::slotActionCutActivated()
{
m_activeFormWindow->cut();
@@ -551,6 +560,7 @@ void FormWindowManager::slotActionPasteActivated()
{
m_activeFormWindow->paste();
}
+#endif
void FormWindowManager::slotActionDeleteActivated()
{
@@ -825,7 +835,9 @@ void FormWindowManager::slotUpdateActions()
int selectedWidgetCount = 0;
int laidoutWidgetCount = 0;
int unlaidoutWidgetCount = 0;
+#ifndef QT_NO_CLIPBOARD
bool pasteAvailable = false;
+#endif
bool layoutAvailable = false;
bool breakAvailable = false;
bool simplifyAvailable = false;
@@ -841,7 +853,9 @@ void FormWindowManager::slotUpdateActions()
QWidgetList simplifiedSelection = m_activeFormWindow->selectedWidgets();
selectedWidgetCount = simplifiedSelection.count();
+#ifndef QT_NO_CLIPBOARD
pasteAvailable = qApp->clipboard()->mimeData() && qApp->clipboard()->mimeData()->hasText();
+#endif
m_activeFormWindow->simplifySelection(&simplifiedSelection);
QWidget *mainContainer = m_activeFormWindow->mainContainer();
@@ -909,13 +923,15 @@ void FormWindowManager::slotUpdateActions()
}
} while(false);
+#ifndef QT_NO_CLIPBOARD
m_actionCut->setEnabled(selectedWidgetCount > 0);
m_actionCopy->setEnabled(selectedWidgetCount > 0);
+ m_actionPaste->setEnabled(pasteAvailable);
+#endif
m_actionDelete->setEnabled(selectedWidgetCount > 0);
m_actionLower->setEnabled(canChangeZOrder && selectedWidgetCount > 0);
m_actionRaise->setEnabled(canChangeZOrder && selectedWidgetCount > 0);
- m_actionPaste->setEnabled(pasteAvailable);
m_actionSelectAll->setEnabled(m_activeFormWindow != 0);
@@ -1003,12 +1019,14 @@ void FormWindowManager::slotActionShowFormWindowSettingsDialog()
QAction *FormWindowManager::action(Action action) const
{
switch (action) {
+#ifndef QT_NO_CLIPBOARD
case QDesignerFormWindowManagerInterface::CutAction:
return m_actionCut;
case QDesignerFormWindowManagerInterface::CopyAction:
return m_actionCopy;
case QDesignerFormWindowManagerInterface::PasteAction:
return m_actionPaste;
+#endif
case QDesignerFormWindowManagerInterface::DeleteAction:
return m_actionDelete;
case QDesignerFormWindowManagerInterface::SelectAllAction:
diff --git a/src/designer/src/components/formeditor/formwindowmanager.h b/src/designer/src/components/formeditor/formwindowmanager.h
index 0e3b3e206..401de07a8 100644
--- a/src/designer/src/components/formeditor/formwindowmanager.h
+++ b/src/designer/src/components/formeditor/formwindowmanager.h
@@ -103,9 +103,11 @@ public slots:
void deviceProfilesChanged();
private slots:
+#ifndef QT_NO_CLIPBOARD
void slotActionCutActivated();
void slotActionCopyActivated();
void slotActionPasteActivated();
+#endif
void slotActionDeleteActivated();
void slotActionSelectAllActivated();
void slotActionLowerActivated();
@@ -142,9 +144,11 @@ private:
QWidget *m_morphLayoutContainer;
// edit actions
+#ifndef QT_NO_CLIPBOARD
QAction *m_actionCut;
QAction *m_actionCopy;
QAction *m_actionPaste;
+#endif
QAction *m_actionSelectAll;
QAction *m_actionDelete;
QAction *m_actionLower;
diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp
index 999782766..34fdef7fa 100644
--- a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp
+++ b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp
@@ -60,7 +60,9 @@
#include <QtWidgets/QToolButton>
#include <QtWidgets/QHBoxLayout>
#include <QtCore/QFileInfo>
+#ifndef QT_NO_CLIPBOARD
#include <QtGui/QClipboard>
+#endif
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QPushButton>
@@ -525,9 +527,11 @@ private slots:
void resourceActionActivated();
void fileActionActivated();
void themeActionActivated();
+#ifndef QT_NO_CLIPBOARD
void copyActionActivated();
void pasteActionActivated();
void clipboardDataChanged();
+#endif
private:
void updateLabels();
bool m_iconThemeModeEnabled;
@@ -588,13 +592,17 @@ PixmapEditor::PixmapEditor(QDesignerFormEditorInterface *core, QWidget *parent)
connect(m_resourceAction, SIGNAL(triggered()), this, SLOT(resourceActionActivated()));
connect(m_fileAction, SIGNAL(triggered()), this, SLOT(fileActionActivated()));
connect(m_themeAction, SIGNAL(triggered()), this, SLOT(themeActionActivated()));
+#ifndef QT_NO_CLIPBOARD
connect(m_copyAction, SIGNAL(triggered()), this, SLOT(copyActionActivated()));
connect(m_pasteAction, SIGNAL(triggered()), this, SLOT(pasteActionActivated()));
+#endif
setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored));
setFocusProxy(m_button);
+#ifndef QT_NO_CLIPBOARD
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
clipboardDataChanged();
+#endif
}
void PixmapEditor::setPixmapCache(DesignerPixmapCache *cache)
@@ -715,6 +723,7 @@ void PixmapEditor::themeActionActivated()
}
}
+#ifndef QT_NO_CLIPBOARD
void PixmapEditor::copyActionActivated()
{
QClipboard *clipboard = QApplication::clipboard();
@@ -753,6 +762,7 @@ void PixmapEditor::clipboardDataChanged()
const QString text = clipboard->text(subtype);
m_pasteAction->setEnabled(!text.isNull());
}
+#endif
// --------------- ResetWidget
class ResetWidget : public QWidget