Skip to content

Commit

Permalink
Move handling of layout manager from qgisapp -> QgsAppWindowManager
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 14, 2018
1 parent cb178a7 commit 3b64c34
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
9 changes: 1 addition & 8 deletions src/app/qgisapp.cpp
Expand Up @@ -210,7 +210,6 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
#include "qgslayoutcustomdrophandler.h"
#include "qgslayoutdesignerdialog.h"
#include "qgslayoutmanager.h"
#include "qgslayoutmanagerdialog.h"
#include "qgslayoutqptdrophandler.h"
#include "qgslayoutapputils.h"
#include "qgslocatorwidget.h"
Expand Down Expand Up @@ -10587,13 +10586,7 @@ void QgisApp::reloadConnections()

void QgisApp::showLayoutManager()
{
if ( !mLayoutManagerDialog )
{
mLayoutManagerDialog = new QgsLayoutManagerDialog( this, Qt::Window );
mLayoutManagerDialog->setAttribute( Qt::WA_DeleteOnClose );
}
mLayoutManagerDialog->show();
mLayoutManagerDialog->activate();
static_cast< QgsAppWindowManager * >( QgsGui::windowManager() )->openApplicationDialog( QgsAppWindowManager::DialogLayoutManager );
}

QgsVectorLayer *QgisApp::addVectorLayer( const QString &vectorLayerPath, const QString &name, const QString &providerKey )
Expand Down
3 changes: 0 additions & 3 deletions src/app/qgisapp.h
Expand Up @@ -64,7 +64,6 @@ class QgsMasterLayoutInterface;
class QgsLayoutCustomDropHandler;
class QgsLayoutDesignerDialog;
class QgsLayoutDesignerInterface;
class QgsLayoutManagerDialog;
class QgsMapCanvas;
class QgsMapCanvasDockWidget;
class QgsMapLayer;
Expand Down Expand Up @@ -2202,8 +2201,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsDockWidget *mMapStylingDock = nullptr;
QgsLayerStylingWidget *mMapStyleWidget = nullptr;

QPointer< QgsLayoutManagerDialog > mLayoutManagerDialog;

//! Persistent tile scale slider
QgsTileScaleWidget *mpTileScaleWidget = nullptr;

Expand Down
23 changes: 22 additions & 1 deletion src/app/qgsappwindowmanager.cpp
Expand Up @@ -17,12 +17,14 @@
#include "qgsstylemanagerdialog.h"
#include "qgsstyle.h"
#include "qgisapp.h"

#include "qgslayoutmanagerdialog.h"

QgsAppWindowManager::~QgsAppWindowManager()
{
if ( mStyleManagerDialog )
delete mStyleManagerDialog;
if ( mLayoutManagerDialog )
delete mLayoutManagerDialog;
}

QWidget *QgsAppWindowManager::openStandardDialog( QgsWindowManagerInterface::StandardDialog dialog )
Expand All @@ -43,3 +45,22 @@ QWidget *QgsAppWindowManager::openStandardDialog( QgsWindowManagerInterface::Sta
}
return nullptr;
}

QWidget *QgsAppWindowManager::openApplicationDialog( QgsAppWindowManager::ApplicationDialog dialog )
{
switch ( dialog )
{
case DialogLayoutManager:
{
if ( !mLayoutManagerDialog )
{
mLayoutManagerDialog = new QgsLayoutManagerDialog( QgisApp::instance(), Qt::Window );
mLayoutManagerDialog->setAttribute( Qt::WA_DeleteOnClose );
}
mLayoutManagerDialog->show();
mLayoutManagerDialog->activate();
}
return nullptr;
}
return nullptr;
}
19 changes: 19 additions & 0 deletions src/app/qgsappwindowmanager.h
Expand Up @@ -21,6 +21,7 @@
#include <QPointer>

class QgsStyleManagerDialog;
class QgsLayoutManagerDialog;

/**
* \ingroup gui
Expand All @@ -30,13 +31,31 @@ class QgsAppWindowManager : public QgsWindowManagerInterface
{
public:

//! Application-only QGIS dialogs
enum ApplicationDialog
{
DialogLayoutManager = 0, //!< Layout manager dialog
};

QgsAppWindowManager() = default;
~QgsAppWindowManager();

QWidget *openStandardDialog( QgsWindowManagerInterface::StandardDialog dialog ) override;

/**
* Opens an instance of a application QGIS dialog. Depending on the dialog,
* this may either open a new instance of the dialog or bring an
* existing instance to the foreground.
*
* Returns the dialog if shown, or nullptr if the dialog either could not be
* created.
*/
QWidget *openApplicationDialog( ApplicationDialog dialog );

private:
QPointer< QgsStyleManagerDialog > mStyleManagerDialog;
QPointer< QgsLayoutManagerDialog > mLayoutManagerDialog;

};


Expand Down

0 comments on commit 3b64c34

Please sign in to comment.