mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Shell layout designer dialog
This commit is contained in:
parent
18b2b5240b
commit
4f21afac0f
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
57
python/gui/layout/qgslayoutdesignerinterface.sip
Normal file
57
python/gui/layout/qgslayoutdesignerinterface.sip
Normal file
@ -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 *
|
||||
************************************************************************/
|
@ -344,6 +344,23 @@ Adds a widget to the user input tool bar.
|
||||
.. seealso:: openComposer()
|
||||
%End
|
||||
|
||||
virtual QList<QgsLayoutDesignerInterface *> 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
|
||||
|
@ -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
|
||||
|
150
src/app/layout/qgslayoutdesignerdialog.cpp
Normal file
150
src/app/layout/qgslayoutdesignerdialog.cpp
Normal file
@ -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<QToolBar *> toolbars = findChildren<QToolBar *>();
|
||||
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" );
|
||||
}
|
||||
}
|
||||
|
||||
|
115
src/app/layout/qgslayoutdesignerdialog.h
Normal file
115
src/app/layout/qgslayoutdesignerdialog.h
Normal file
@ -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
|
||||
|
@ -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() );
|
||||
|
@ -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<QgsComposer *> printComposers() const {return mPrintComposers;}
|
||||
|
||||
/**
|
||||
* Returns the active layout designers.
|
||||
*/
|
||||
QSet<QgsLayoutDesignerDialog *> 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<QgsComposer *> mPrintComposers;
|
||||
|
||||
//! Print composers of this project, accessible by id string
|
||||
QSet<QgsLayoutDesignerDialog *> mLayoutDesignerDialogs;
|
||||
|
||||
//! QGIS-internal vector feature clipboard
|
||||
QgsClipboard *mInternalClipboard = nullptr;
|
||||
//! Flag to indicate how the project properties dialog was summoned
|
||||
|
@ -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<QgsLayoutDesignerInterface *> QgisAppInterface::openLayoutDesigners()
|
||||
{
|
||||
QList<QgsLayoutDesignerInterface *> designerInterfaceList;
|
||||
if ( qgis )
|
||||
{
|
||||
const QSet<QgsLayoutDesignerDialog *> designerList = qgis->layoutDesigners();
|
||||
QSet<QgsLayoutDesignerDialog *>::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 );
|
||||
|
@ -208,6 +208,10 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
|
||||
QList<QgsComposerInterface *> openComposers() override;
|
||||
QgsComposerInterface *openComposer( QgsComposition *composition ) override;
|
||||
void closeComposer( QgsComposition *composition ) override;
|
||||
|
||||
QList<QgsLayoutDesignerInterface *> 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
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -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
|
||||
|
64
src/gui/layout/qgslayoutdesignerinterface.h
Normal file
64
src/gui/layout/qgslayoutdesignerinterface.h
Normal file
@ -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 <QObject>
|
||||
|
||||
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
|
@ -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<QgsLayoutDesignerInterface *> 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
|
||||
*/
|
||||
|
@ -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})
|
||||
|
111
src/ui/layout/qgslayoutdesignerbase.ui
Normal file
111
src/ui/layout/qgslayoutdesignerbase.ui
Normal file
@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QgsLayoutDesignerBase</class>
|
||||
<widget class="QMainWindow" name="QgsLayoutDesignerBase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1083</width>
|
||||
<height>609</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<property name="mouseTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="mViewFrame">
|
||||
<property name="mouseTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="mStatusBar"/>
|
||||
<widget class="QToolBar" name="mLayoutToolbar">
|
||||
<property name="windowTitle">
|
||||
<string>Composer</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mItemToolbar">
|
||||
<property name="windowTitle">
|
||||
<string>Toolbox</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1083</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuLayout">
|
||||
<property name="title">
|
||||
<string>&Layout</string>
|
||||
</property>
|
||||
<addaction name="mActionClose"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuItems">
|
||||
<property name="title">
|
||||
<string>&Items</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuLayout"/>
|
||||
<addaction name="menuItems"/>
|
||||
</widget>
|
||||
<action name="mActionClose">
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Close designer</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
x
Reference in New Issue
Block a user