-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With implementation in app. This allows GUI library classes to re-use standard dialogs which are created in app. The initial use-case is to allow the GUI library symbol list widget to focus/open an existing Style Manager dialog (created in app), instead of opening a new modal style manager dialog. Side benefit - moves some code out of the monolithic qgisapp.cpp file.
- Loading branch information
1 parent
9bcd21f
commit cb178a7
Showing
13 changed files
with
274 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
python/gui/auto_generated/qgswindowmanagerinterface.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgswindowmanagerinterface.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsWindowManagerInterface | ||
{ | ||
%Docstring | ||
Interface for window manager. | ||
|
||
An implementation of the window manager interface is usually retrieved from | ||
the QgsGui instance, via :py:func:`QgsGui.windowManager()` | ||
|
||
.. note:: | ||
|
||
This is not considered stable API and may change in future QGIS versions. | ||
|
||
.. versionadded:: 3.4 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgswindowmanagerinterface.h" | ||
%End | ||
public: | ||
|
||
enum StandardDialog | ||
{ | ||
DialogStyleManager, | ||
}; | ||
|
||
virtual ~QgsWindowManagerInterface(); | ||
|
||
virtual QWidget *openStandardDialog( StandardDialog dialog ) = 0; | ||
%Docstring | ||
Opens an instance of a standard QGIS dialog. Depending on the window manager | ||
implementation, this may either open a new instance of the dialog or bring an | ||
existing instance to the foreground. | ||
|
||
Returns the dialog if shown, or None if the dialog either could not be | ||
created or is not supported by the window manager implementation. | ||
%End | ||
|
||
}; | ||
|
||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgswindowmanagerinterface.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*************************************************************************** | ||
qgswindowmanagerinterface.cpp | ||
----------------------------- | ||
Date : September 2018 | ||
Copyright : (C) 2018 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 "qgsappwindowmanager.h" | ||
#include "qgsstylemanagerdialog.h" | ||
#include "qgsstyle.h" | ||
#include "qgisapp.h" | ||
|
||
|
||
QgsAppWindowManager::~QgsAppWindowManager() | ||
{ | ||
if ( mStyleManagerDialog ) | ||
delete mStyleManagerDialog; | ||
} | ||
|
||
QWidget *QgsAppWindowManager::openStandardDialog( QgsWindowManagerInterface::StandardDialog dialog ) | ||
{ | ||
switch ( dialog ) | ||
{ | ||
case QgsWindowManagerInterface::DialogStyleManager: | ||
{ | ||
if ( !mStyleManagerDialog ) | ||
{ | ||
mStyleManagerDialog = new QgsStyleManagerDialog( QgsStyle::defaultStyle(), QgisApp::instance(), Qt::Window ); | ||
mStyleManagerDialog->setAttribute( Qt::WA_DeleteOnClose ); | ||
} | ||
mStyleManagerDialog->show(); | ||
mStyleManagerDialog->activate(); | ||
return mStyleManagerDialog; | ||
} | ||
} | ||
return nullptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/*************************************************************************** | ||
qgswindowmanagerinterface.h | ||
--------------------------- | ||
Date : September 2018 | ||
Copyright : (C) 2018 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 QGSAPPWINDOWMANAGER_H | ||
#define QGSAPPWINDOWMANAGER_H | ||
|
||
#include "qgis.h" | ||
#include "qgswindowmanagerinterface.h" | ||
#include <QPointer> | ||
|
||
class QgsStyleManagerDialog; | ||
|
||
/** | ||
* \ingroup gui | ||
* \brief Implementation of QgsWindowManagerInterface for the QGIS application. | ||
*/ | ||
class QgsAppWindowManager : public QgsWindowManagerInterface | ||
{ | ||
public: | ||
|
||
QgsAppWindowManager() = default; | ||
~QgsAppWindowManager(); | ||
|
||
QWidget *openStandardDialog( QgsWindowManagerInterface::StandardDialog dialog ) override; | ||
|
||
private: | ||
QPointer< QgsStyleManagerDialog > mStyleManagerDialog; | ||
}; | ||
|
||
|
||
#endif // QGSAPPWINDOWMANAGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/*************************************************************************** | ||
qgswindowmanagerinterface.h | ||
--------------------------- | ||
Date : September 2018 | ||
Copyright : (C) 2018 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 QGSWINDOWMANAGERINTERFACE_H | ||
#define QGSWINDOWMANAGERINTERFACE_H | ||
|
||
#include "qgis.h" | ||
#include "qgis_gui.h" | ||
|
||
///@cond NOT_STABLE | ||
|
||
/** | ||
* \ingroup gui | ||
* \brief Interface for window manager. | ||
* | ||
* An implementation of the window manager interface is usually retrieved from | ||
* the QgsGui instance, via QgsGui::windowManager(). | ||
* | ||
* \note This is not considered stable API and may change in future QGIS versions. | ||
* \since QGIS 3.4 | ||
*/ | ||
class GUI_EXPORT QgsWindowManagerInterface | ||
{ | ||
public: | ||
|
||
//! Standard QGIS dialogs | ||
enum StandardDialog | ||
{ | ||
DialogStyleManager = 0, //!< Style manager dialog | ||
}; | ||
|
||
virtual ~QgsWindowManagerInterface() = default; | ||
|
||
/** | ||
* Opens an instance of a standard QGIS dialog. Depending on the window manager | ||
* implementation, 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 or is not supported by the window manager implementation. | ||
*/ | ||
virtual QWidget *openStandardDialog( StandardDialog dialog ) = 0; | ||
|
||
}; | ||
|
||
///@endcond | ||
|
||
#endif // QGSWINDOWMANAGERINTERFACE_H |
Oops, something went wrong.