diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 31347505a14..083e8fefcf1 100755 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -123,6 +123,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/gui/editorwidgets/core ${CMAKE_SOURCE_DIR}/src/gui/effects ${CMAKE_SOURCE_DIR}/src/gui/layertree + ${CMAKE_SOURCE_DIR}/src/gui/layout ${CMAKE_SOURCE_DIR}/src/gui/locator ${CMAKE_SOURCE_DIR}/src/plugins diff --git a/python/core/layout/qgslayoutitem.sip b/python/core/layout/qgslayoutitem.sip index 87bc28f29bd..ce332739cde 100644 --- a/python/core/layout/qgslayoutitem.sip +++ b/python/core/layout/qgslayoutitem.sip @@ -46,6 +46,11 @@ Return correct graphics item type. @param painter destination QPainter %End + virtual void draw( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) = 0; +%Docstring + Draws the item's contents on a specified ``painter``. +%End + }; diff --git a/python/gui/gui_auto.sip b/python/gui/gui_auto.sip index 3684a5a59a8..5cb16d4334c 100644 --- a/python/gui/gui_auto.sip +++ b/python/gui/gui_auto.sip @@ -273,6 +273,7 @@ %Include layertree/qgslayertreemapcanvasbridge.sip %Include layertree/qgslayertreeview.sip %Include layertree/qgslayertreeviewdefaultactions.sip +%Include layout/qgslayoutdesignerinterface.sip %Include locator/qgslocator.sip %Include locator/qgslocatorfilter.sip %Include locator/qgslocatorwidget.sip diff --git a/python/gui/layout/qgslayoutdesignerinterface.sip b/python/gui/layout/qgslayoutdesignerinterface.sip new file mode 100644 index 00000000000..f7ee9efd4b0 --- /dev/null +++ b/python/gui/layout/qgslayoutdesignerinterface.sip @@ -0,0 +1,57 @@ +/************************************************************************ + * This file has been generated automatically from * + * * + * src/gui/layout/qgslayoutdesignerinterface.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ + + + + +class QgsLayoutDesignerInterface: QObject +{ +%Docstring + A common interface for layout designer dialogs and widgets. + + Provides a common interface and stable API for layout designer dialogs and widgets. + This interface can be used by plugins and scripts to interact with + open layout designer dialogs. + +.. versionadded:: 3.0 +%End + +%TypeHeaderCode +#include "qgslayoutdesignerinterface.h" +%End + public: + + QgsLayoutDesignerInterface( QObject *parent /TransferThis/ = 0 ); +%Docstring + Constructor for QgsLayoutDesignerInterface. +%End + + virtual ~QgsLayoutDesignerInterface(); + + virtual QgsLayout *layout() = 0; +%Docstring + Returns the layout displayed in the designer. + :rtype: QgsLayout +%End + + public slots: + + virtual void close() = 0; +%Docstring + Closes the layout designer. +%End + +}; + +/************************************************************************ + * This file has been generated automatically from * + * * + * src/gui/layout/qgslayoutdesignerinterface.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ diff --git a/python/gui/qgisinterface.sip b/python/gui/qgisinterface.sip index 6b52be648ca..3b4279fd19a 100644 --- a/python/gui/qgisinterface.sip +++ b/python/gui/qgisinterface.sip @@ -344,6 +344,23 @@ Adds a widget to the user input tool bar. .. seealso:: openComposer() %End + virtual QList openLayoutDesigners() = 0; +%Docstring + Returns all currently open layout designers. +.. versionadded:: 3.0 + :rtype: list of QgsLayoutDesignerInterface +%End + + virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsLayout *layout ) = 0; +%Docstring + Opens a new layout designer dialog for the specified ``layout``, or + brings an already open designer window to the foreground if one + is already created for the layout. +.. versionadded:: 3.0 +.. seealso:: closeComposer() + :rtype: QgsLayoutDesignerInterface +%End + virtual void showOptionsDialog( QWidget *parent = 0, const QString ¤tPage = QString() ) = 0; %Docstring Opens the options dialog. The ``currentPage`` argument can be used to force diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index d421cee52a3..4f377f6be48 100755 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -156,6 +156,8 @@ SET(QGIS_APP_SRCS composer/qgscompositionwidget.cpp composer/qgsatlascompositionwidget.cpp + layout/qgslayoutdesignerdialog.cpp + locator/qgsinbuiltlocatorfilters.cpp locator/qgslocatoroptionswidget.cpp @@ -337,6 +339,8 @@ SET (QGIS_APP_MOC_HDRS composer/qgscompositionwidget.h composer/qgsatlascompositionwidget.h + layout/qgslayoutdesignerdialog.h + locator/qgsinbuiltlocatorfilters.h locator/qgslocatoroptionswidget.h @@ -484,6 +488,7 @@ ENDIF(PEDANTIC) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/app ${CMAKE_SOURCE_DIR}/src/app/composer + ${CMAKE_SOURCE_DIR}/src/app/layout ${CMAKE_SOURCE_DIR}/src/app/pluginmanager ${CMAKE_SOURCE_DIR}/src/app/gps ${CMAKE_SOURCE_DIR}/src/app/openstreetmap @@ -544,6 +549,7 @@ INCLUDE_DIRECTORIES( ../core/composer ../core/dxf ../core/geometry + ../core/layout ../core/metadata ../core/layertree ../core/providers/memory @@ -558,6 +564,7 @@ INCLUDE_DIRECTORIES( ../gui/editorwidgets ../gui/editorwidgets/core ../gui/layertree + ../gui/layout ../plugins ../python gps diff --git a/src/app/layout/qgslayoutdesignerdialog.cpp b/src/app/layout/qgslayoutdesignerdialog.cpp new file mode 100644 index 00000000000..5af208239a2 --- /dev/null +++ b/src/app/layout/qgslayoutdesignerdialog.cpp @@ -0,0 +1,150 @@ +/*************************************************************************** + qgslayoutdesignerdialog.cpp + --------------------------- + begin : July 2017 + copyright : (C) 2017 by Nyall Dawson + email : nyall dot dawson at gmail dot com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "qgslayoutdesignerdialog.h" +#include "qgssettings.h" +#include "qgisapp.h" +#include "qgslogger.h" + +QgsAppLayoutDesignerInterface::QgsAppLayoutDesignerInterface( QgsLayoutDesignerDialog *dialog ) + : QgsLayoutDesignerInterface( dialog ) + , mDesigner( dialog ) +{} + +QgsLayout *QgsAppLayoutDesignerInterface::layout() +{ + return mDesigner->currentLayout(); +} + +void QgsAppLayoutDesignerInterface::close() +{ + mDesigner->close(); +} + + +QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFlags flags ) + : QMainWindow( parent, flags ) + , mInterface( new QgsAppLayoutDesignerInterface( this ) ) +{ + QgsSettings settings; + int size = settings.value( QStringLiteral( "IconSize" ), QGIS_ICON_SIZE ).toInt(); + setIconSize( QSize( size, size ) ); + setStyleSheet( QgisApp::instance()->styleSheet() ); + setWindowTitle( tr( "QGIS Layout Designer" ) ); + + setupUi( this ); + + setAttribute( Qt::WA_DeleteOnClose ); +#if QT_VERSION >= 0x050600 + setDockOptions( dockOptions() | QMainWindow::GroupedDragging ) ; +#endif + + connect( mActionClose, &QAction::triggered, this, &QWidget::close ); + + restoreWindowState(); +} + +QgsAppLayoutDesignerInterface *QgsLayoutDesignerDialog::iface() +{ + return mInterface; +} + +QgsLayout *QgsLayoutDesignerDialog::currentLayout() +{ + return mLayout; +} + +void QgsLayoutDesignerDialog::setCurrentLayout( QgsLayout *layout ) +{ + mLayout = layout; + +} + +void QgsLayoutDesignerDialog::setIconSizes( int size ) +{ + //Set the icon size of for all the toolbars created in the future. + setIconSize( QSize( size, size ) ); + + //Change all current icon sizes. + QList toolbars = findChildren(); + Q_FOREACH ( QToolBar *toolbar, toolbars ) + { + toolbar->setIconSize( QSize( size, size ) ); + } +} + +void QgsLayoutDesignerDialog::open() +{ + show(); + activate(); +#if 0 // TODO + zoomFull(); // zoomFull() does not work properly until we have called show() + if ( mView ) + { + mView->updateRulers(); + } +#endif +} + +void QgsLayoutDesignerDialog::activate() +{ + // bool shown = isVisible(); + show(); + raise(); + setWindowState( windowState() & ~Qt::WindowMinimized ); + activateWindow(); + +#if 0 // TODO + if ( !shown ) + { + on_mActionZoomAll_triggered(); + } +#endif +} + +void QgsLayoutDesignerDialog::closeEvent( QCloseEvent * ) +{ + emit aboutToClose(); + saveWindowState(); +} + +void QgsLayoutDesignerDialog::saveWindowState() +{ + QgsSettings settings; + settings.setValue( QStringLiteral( "LayoutDesigner/geometry" ), saveGeometry() ); + // store the toolbar/dock widget settings using Qt settings API + settings.setValue( QStringLiteral( "LayoutDesigner/state" ), saveState() ); +} + +void QgsLayoutDesignerDialog::restoreWindowState() +{ + // restore the toolbar and dock widgets positions using Qt settings API + QgsSettings settings; + + //TODO - defaults + if ( !restoreState( settings.value( QStringLiteral( "LayoutDesigner/state" ) /*, QByteArray::fromRawData( ( char * )defaultComposerUIstate, sizeof defaultComposerUIstate ) */ ).toByteArray() ) ) + { + QgsDebugMsg( "restore of layout UI state failed" ); + } + // restore window geometry + if ( !restoreGeometry( settings.value( QStringLiteral( "LayoutDesigner/geometry" ) /*, QByteArray::fromRawData( ( char * )defaultComposerUIgeometry, sizeof defaultComposerUIgeometry ) */ ).toByteArray() ) ) + { + QgsDebugMsg( "restore of layout UI geometry failed" ); + } +} + + diff --git a/src/app/layout/qgslayoutdesignerdialog.h b/src/app/layout/qgslayoutdesignerdialog.h new file mode 100644 index 00000000000..2fba0bd413d --- /dev/null +++ b/src/app/layout/qgslayoutdesignerdialog.h @@ -0,0 +1,115 @@ +/*************************************************************************** + qgslayoutdesignerdialog.h + ------------------------- + begin : July 2017 + copyright : (C) 2017 by Nyall Dawson + email : nyall dot dawson at gmail dot com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef QGSLAYOUTDESIGNERDIALOG_H +#define QGSLAYOUTDESIGNERDIALOG_H + +#include "ui_qgslayoutdesignerbase.h" +#include "qgslayoutdesignerinterface.h" + +class QgsLayoutDesignerDialog; + +class QgsAppLayoutDesignerInterface : public QgsLayoutDesignerInterface +{ + Q_OBJECT + + public: + QgsAppLayoutDesignerInterface( QgsLayoutDesignerDialog *dialog ); + QgsLayout *layout() override; + + public slots: + + void close() override; + + private: + + QgsLayoutDesignerDialog *mDesigner = nullptr; +}; + +/** + * \ingroup app + * \brief A window for designing layouts. + */ +class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesignerBase +{ + Q_OBJECT + + public: + + QgsLayoutDesignerDialog( QWidget *parent = nullptr, Qt::WindowFlags flags = 0 ); + + /** + * Returns the designer interface for the dialog. + */ + QgsAppLayoutDesignerInterface *iface(); + + /** + * Returns the current layout associated with the designer. + * \see setCurrentLayout() + */ + QgsLayout *currentLayout(); + + /** + * Sets the current \a layout to edit in the designer. + * \see currentLayout() + */ + void setCurrentLayout( QgsLayout *layout ); + + /** + * Sets the icon \a size for the dialog. + */ + void setIconSizes( int size ); + + public slots: + + /** + * Opens the dialog, and sets default view. + */ + void open(); + + /** + * Raise, unminimize and activate this window. + */ + void activate(); + + signals: + + /** + * Emitted when the dialog is about to close. + */ + void aboutToClose(); + + protected: + + virtual void closeEvent( QCloseEvent * ) override; + + private: + + QgsAppLayoutDesignerInterface *mInterface = nullptr; + + QgsLayout *mLayout = nullptr; + + //! Save window state + void saveWindowState(); + + //! Restore the window and toolbar state + void restoreWindowState(); + + +}; + +#endif // QGSLAYOUTDESIGNERDIALOG_H + diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index ebb05d6a16c..5fdf7874926 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -188,6 +188,7 @@ Q_GUI_EXPORT extern int qt_defaultDpiX(); #include "qgslayertreeutils.h" #include "qgslayertreeview.h" #include "qgslayertreeviewdefaultactions.h" +#include "qgslayoutdesignerdialog.h" #include "qgslayoutmanager.h" #include "qgslocatorwidget.h" #include "qgslocator.h" @@ -2104,6 +2105,10 @@ void QgisApp::setAppStyleSheet( const QString &stylesheet ) { c->setStyleSheet( stylesheet ); } + Q_FOREACH ( QgsLayoutDesignerDialog *d, mLayoutDesignerDialogs ) + { + d->setStyleSheet( stylesheet ); + } } int QgisApp::messageTimeout() @@ -2763,6 +2768,10 @@ void QgisApp::setIconSizes( int size ) { c->setIconSizes( size ); } + Q_FOREACH ( QgsLayoutDesignerDialog *d, mLayoutDesignerDialogs ) + { + d->setIconSizes( size ); + } } void QgisApp::setTheme( const QString &themeName ) @@ -7165,6 +7174,40 @@ QgsComposer *QgisApp::openComposer( QgsComposition *composition ) return newComposerObject; } +QgsLayoutDesignerDialog *QgisApp::openLayoutDesignerDialog( QgsLayout *layout ) +{ + // maybe a designer already open for this layout + Q_FOREACH ( QgsLayoutDesignerDialog *designer, mLayoutDesignerDialogs ) + { + if ( designer->currentLayout() == layout ) + { + designer->show(); + designer->activate(); + designer->raise(); + return designer; + } + } + + //nope, so make a new one + QgsLayoutDesignerDialog *newDesigner = new QgsLayoutDesignerDialog( this ); + newDesigner->setCurrentLayout( layout ); + connect( newDesigner, &QgsLayoutDesignerDialog::aboutToClose, this, [this, newDesigner] + { + emit layoutDesignerWillBeClosed( newDesigner->iface() ); + mLayoutDesignerDialogs.remove( newDesigner ); + emit layoutDesignerClosed(); + } ); + + //add it to the map of existing print designers + mLayoutDesignerDialogs.insert( newDesigner ); + + newDesigner->open(); + emit layoutDesignerOpened( newDesigner->iface() ); + //connect( newDesigner, &QgsLayoutDesignerDialog::atlasPreviewFeatureChanged, this, &QgisApp::refreshMapCanvas ); + + return newDesigner; +} + void QgisApp::deleteComposer( QgsComposer *c ) { emit composerWillBeClosed( c->iface() ); diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 7aca1ab03ac..88a8ddb1879 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -61,6 +61,9 @@ class QgsFeatureStore; class QgsGeometry; class QgsLayerTreeMapCanvasBridge; class QgsLayerTreeView; +class QgsLayout; +class QgsLayoutDesignerDialog; +class QgsLayoutDesignerInterface; class QgsMapCanvas; class QgsMapCanvasDockWidget; class QgsMapLayer; @@ -318,6 +321,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow //! Returns the print composers QSet printComposers() const {return mPrintComposers;} + /** + * Returns the active layout designers. + */ + QSet layoutDesigners() const { return mLayoutDesignerDialogs; } + /** Get a unique title from user for new and duplicate composers * \param acceptEmpty whether to accept empty titles (one will be generated) * \param currentTitle base name for initial title choice @@ -332,6 +340,12 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow */ QgsComposer *openComposer( QgsComposition *composition ); + /** + * Opens a layout designer dialog for an existing \a layout. + * If a designer already exists for this layout then it will be activated. + */ + QgsLayoutDesignerDialog *openLayoutDesignerDialog( QgsLayout *layout ); + //! Deletes a composer and removes entry from Set void deleteComposer( QgsComposer *c ); @@ -1522,6 +1536,30 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow */ void composerClosed( QgsComposerInterface *composer ); + /** + * This signal is emitted when a new layout \a designer has been opened. + * \since QGIS 3.0 + * \see layoutDesignerWillBeClosed() + */ + void layoutDesignerOpened( QgsLayoutDesignerInterface *designer ); + + /** + * This signal is emitted before a layout \a designer is going to be closed + * and deleted. + * \since QGIS 3.0 + * \see layoutDesignerClosed() + * \see layoutDesignerOpened() + */ + void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer ); + + /** + * This signal is emitted after a layout designer window is closed. + * \since QGIS 3.0 + * \see layoutDesignerWillBeClosed() + * \see layoutDesignerOpened() + */ + void layoutDesignerClosed(); + //! This signal is emitted when QGIS' initialization is complete void initializationCompleted(); @@ -1856,6 +1894,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow //! Print composers of this project, accessible by id string QSet mPrintComposers; + + //! Print composers of this project, accessible by id string + QSet mLayoutDesignerDialogs; + //! QGIS-internal vector feature clipboard QgsClipboard *mInternalClipboard = nullptr; //! Flag to indicate how the project properties dialog was summoned diff --git a/src/app/qgisappinterface.cpp b/src/app/qgisappinterface.cpp index 5d3f085c064..8582c468fe2 100644 --- a/src/app/qgisappinterface.cpp +++ b/src/app/qgisappinterface.cpp @@ -37,6 +37,7 @@ #include "qgsmapcanvas.h" #include "qgsproject.h" #include "qgslayertreeview.h" +#include "qgslayoutdesignerdialog.h" #include "qgsshortcutsmanager.h" #include "qgsattributedialog.h" #include "qgsfields.h" @@ -61,6 +62,11 @@ QgisAppInterface::QgisAppInterface( QgisApp *_qgis ) connect( qgis, &QgisApp::composerOpened, this, &QgisAppInterface::composerOpened ); connect( qgis, &QgisApp::composerWillBeClosed, this, &QgisAppInterface::composerWillBeClosed ); connect( qgis, &QgisApp::composerClosed, this, &QgisAppInterface::composerClosed ); + + connect( qgis, &QgisApp::layoutDesignerOpened, this, &QgisAppInterface::layoutDesignerOpened ); + connect( qgis, &QgisApp::layoutDesignerWillBeClosed, this, &QgisAppInterface::layoutDesignerWillBeClosed ); + connect( qgis, &QgisApp::layoutDesignerClosed, this, &QgisAppInterface::layoutDesignerClosed ); + connect( qgis, &QgisApp::initializationCompleted, this, &QgisInterface::initializationCompleted ); connect( qgis, &QgisApp::newProject, @@ -421,6 +427,38 @@ void QgisAppInterface::closeComposer( QgsComposition *composition ) } } +QList QgisAppInterface::openLayoutDesigners() +{ + QList designerInterfaceList; + if ( qgis ) + { + const QSet designerList = qgis->layoutDesigners(); + QSet::const_iterator it = designerList.constBegin(); + for ( ; it != designerList.constEnd(); ++it ) + { + if ( *it ) + { + QgsLayoutDesignerInterface *v = ( *it )->iface(); + if ( v ) + { + designerInterfaceList << v; + } + } + } + } + return designerInterfaceList; +} + +QgsLayoutDesignerInterface *QgisAppInterface::openLayoutDesigner( QgsLayout *layout ) +{ + QgsLayoutDesignerDialog *designer = qgis->openLayoutDesignerDialog( layout ); + if ( designer ) + { + return designer->iface(); + } + return nullptr; +} + void QgisAppInterface::showOptionsDialog( QWidget *parent, const QString ¤tPage ) { return qgis->showOptionsDialog( parent, currentPage ); diff --git a/src/app/qgisappinterface.h b/src/app/qgisappinterface.h index 56991a187f4..d659533d50c 100644 --- a/src/app/qgisappinterface.h +++ b/src/app/qgisappinterface.h @@ -208,6 +208,10 @@ class APP_EXPORT QgisAppInterface : public QgisInterface QList openComposers() override; QgsComposerInterface *openComposer( QgsComposition *composition ) override; void closeComposer( QgsComposition *composition ) override; + + QList openLayoutDesigners() override; + QgsLayoutDesignerInterface *openLayoutDesigner( QgsLayout *layout ) override; + virtual void showOptionsDialog( QWidget *parent = nullptr, const QString ¤tPage = QString() ) override; //! Return changeable options built from settings and/or defaults diff --git a/src/core/layout/qgslayoutitem.h b/src/core/layout/qgslayoutitem.h index 6fdc254e905..5f75051ec06 100644 --- a/src/core/layout/qgslayoutitem.h +++ b/src/core/layout/qgslayoutitem.h @@ -56,13 +56,13 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt */ virtual void drawDebugRect( QPainter *painter ); - private: - /** * Draws the item's contents on a specified \a painter. */ virtual void draw( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) = 0; + private: + //! Prepares a painter by setting rendering flags void preparePainter( QPainter *painter ); diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index c975adf45d8..59c74fbd9ce 100755 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -617,6 +617,8 @@ SET(QGIS_GUI_MOC_HDRS layertree/qgslayertreeview.h layertree/qgslayertreeviewdefaultactions.h + layout/qgslayoutdesignerinterface.h + locator/qgslocator.h locator/qgslocatorfilter.h locator/qgslocatorwidget.h @@ -769,6 +771,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/gui/editorwidgets ${CMAKE_SOURCE_DIR}/src/gui/editorwidgets/core ${CMAKE_SOURCE_DIR}/src/gui/layertree + ${CMAKE_SOURCE_DIR}/src/gui/layout ${CMAKE_SOURCE_DIR}/src/gui/effects ${CMAKE_SOURCE_DIR}/src/core ${CMAKE_SOURCE_DIR}/src/core/annotations @@ -777,6 +780,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/core/fieldformatter ${CMAKE_SOURCE_DIR}/src/core/geometry ${CMAKE_SOURCE_DIR}/src/core/layertree + ${CMAKE_SOURCE_DIR}/src/core/layout ${CMAKE_SOURCE_DIR}/src/core/locator ${CMAKE_SOURCE_DIR}/src/core/metadata ${CMAKE_SOURCE_DIR}/src/core/providers/memory diff --git a/src/gui/layout/qgslayoutdesignerinterface.h b/src/gui/layout/qgslayoutdesignerinterface.h new file mode 100644 index 00000000000..d8c694036d6 --- /dev/null +++ b/src/gui/layout/qgslayoutdesignerinterface.h @@ -0,0 +1,64 @@ +/*************************************************************************** + qgscomposerinterface.h + --------------------- + Date : July 2017 + Copyright : (C) 2017 Nyall Dawson + Email : nyall dot dawson at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSLAYOUTDESIGNERINTERFACE_H +#define QGSLAYOUTDESIGNERINTERFACE_H + +#include "qgis_gui.h" +#include "qgis_sip.h" +#include + +class QgsLayout; + +/** \ingroup gui + * \class QgsLayoutDesignerInterface + * A common interface for layout designer dialogs and widgets. + * + * Provides a common interface and stable API for layout designer dialogs and widgets. + * This interface can be used by plugins and scripts to interact with + * open layout designer dialogs. + * + * \since QGIS 3.0 + */ +class GUI_EXPORT QgsLayoutDesignerInterface: public QObject +{ + Q_OBJECT + + public: + + /** + * Constructor for QgsLayoutDesignerInterface. + */ + QgsLayoutDesignerInterface( QObject *parent SIP_TRANSFERTHIS = 0 ) + : QObject( parent ) + {} + + virtual ~QgsLayoutDesignerInterface() = default; + + /** + * Returns the layout displayed in the designer. + */ + virtual QgsLayout *layout() = 0; + + public slots: + + /** + * Closes the layout designer. + */ + virtual void close() = 0; + +}; + +#endif // QGSLAYOUTDESIGNERINTERFACE_H diff --git a/src/gui/qgisinterface.h b/src/gui/qgisinterface.h index c85c8cb891f..d46abe7c343 100644 --- a/src/gui/qgisinterface.h +++ b/src/gui/qgisinterface.h @@ -32,6 +32,8 @@ class QgsCustomDropHandler; class QgsFeature; class QgsLayerTreeMapCanvasBridge; class QgsLayerTreeView; +class QgsLayout; +class QgsLayoutDesignerInterface; class QgsMapCanvas; class QgsMapLayer; class QgsMapLayerConfigWidgetFactory; @@ -295,6 +297,21 @@ class GUI_EXPORT QgisInterface : public QObject */ virtual void closeComposer( QgsComposition *composition ) = 0; + /** + * Returns all currently open layout designers. + * \since QGIS 3.0 + */ + virtual QList openLayoutDesigners() = 0; + + /** + * Opens a new layout designer dialog for the specified \a layout, or + * brings an already open designer window to the foreground if one + * is already created for the layout. + * \since QGIS 3.0 + * \see closeComposer() + */ + virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsLayout *layout ) = 0; + /** * Opens the options dialog. The \a currentPage argument can be used to force * the dialog to open at a specific page. @@ -721,6 +738,30 @@ class GUI_EXPORT QgisInterface : public QObject */ void composerClosed( QgsComposerInterface *composer ); + /** + * This signal is emitted when a new layout \a designer has been opened. + * \since QGIS 3.0 + * \see layoutDesignerWillBeClosed() + */ + void layoutDesignerOpened( QgsLayoutDesignerInterface *designer ); + + /** + * This signal is emitted before a layout \a designer is going to be closed + * and deleted. + * \since QGIS 3.0 + * \see layoutDesignerClosed() + * \see layoutDesignerOpened() + */ + void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer ); + + /** + * This signal is emitted after a layout designer window is closed. + * \since QGIS 3.0 + * \see layoutDesignerWillBeClosed() + * \see layoutDesignerOpened() + */ + void layoutDesignerClosed(); + /** * This signal is emitted when the initialization is complete */ diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 9eca03027b0..ece33c16162 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -4,10 +4,11 @@ FILE(GLOB SYMBOLLAYER_UIS "${CMAKE_CURRENT_SOURCE_DIR}/symbollayer/*.ui") FILE(GLOB EDITORWIDGET_UIS "${CMAKE_CURRENT_SOURCE_DIR}/editorwidgets/*.ui") FILE(GLOB PAINTEFFECT_UIS "${CMAKE_CURRENT_SOURCE_DIR}/effects/*.ui") FILE(GLOB COMPOSER_UIS "${CMAKE_CURRENT_SOURCE_DIR}/composer/*.ui") +FILE(GLOB LAYOUT_UIS "${CMAKE_CURRENT_SOURCE_DIR}/layout/*.ui") FILE(GLOB AUTH_UIS "${CMAKE_CURRENT_SOURCE_DIR}/auth/*.ui") FILE(GLOB RASTER_UIS "${CMAKE_CURRENT_SOURCE_DIR}/raster/*.ui") FILE(GLOB STYLEDOCK_UIS "${CMAKE_CURRENT_SOURCE_DIR}/styledock/*.ui") -QT5_WRAP_UI(QGIS_UIS_H ${QGIS_UIS} ${SYMBOLLAYER_UIS} ${EDITORWIDGET_UIS} ${PAINTEFFECT_UIS} ${COMPOSER_UIS} ${AUTH_UIS} ${RASTER_UIS} ${STYLEDOCK_UIS}) +QT5_WRAP_UI(QGIS_UIS_H ${QGIS_UIS} ${SYMBOLLAYER_UIS} ${EDITORWIDGET_UIS} ${PAINTEFFECT_UIS} ${COMPOSER_UIS} ${AUTH_UIS} ${RASTER_UIS} ${STYLEDOCK_UIS} ${LAYOUT_UIS}) ADD_CUSTOM_TARGET(ui ALL DEPENDS ${QGIS_UIS_H}) diff --git a/src/ui/layout/qgslayoutdesignerbase.ui b/src/ui/layout/qgslayoutdesignerbase.ui new file mode 100644 index 00000000000..ff3602a8d9c --- /dev/null +++ b/src/ui/layout/qgslayoutdesignerbase.ui @@ -0,0 +1,111 @@ + + + QgsLayoutDesignerBase + + + + 0 + 0 + 1083 + 609 + + + + true + + + MainWindow + + + + true + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + true + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + Composer + + + TopToolBarArea + + + false + + + + + Toolbox + + + TopToolBarArea + + + true + + + + + + 0 + 0 + 1083 + 25 + + + + + &Layout + + + + + + &Items + + + + + + + + &Close + + + Close designer + + + Ctrl+Q + + + + + +