mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
remove old method
This commit is contained in:
parent
72d106ece6
commit
4c67afa698
@ -27,7 +27,7 @@ A custom dock widget for code editors.
|
||||
#include "qgscodeeditordockwidget.h"
|
||||
%End
|
||||
public:
|
||||
QgsCodeEditorDockWidget( const QString &windowGeometrySettingsKey = QString(), bool usePersistentWidget = false );
|
||||
QgsCodeEditorDockWidget( const QString &dockId = QString(), bool usePersistentWidget = false );
|
||||
%Docstring
|
||||
Constructor for QgsCodeEditorDockWidget, with the specified window geometry settings key.
|
||||
|
||||
|
@ -27,7 +27,7 @@ A custom dock widget for code editors.
|
||||
#include "qgscodeeditordockwidget.h"
|
||||
%End
|
||||
public:
|
||||
QgsCodeEditorDockWidget( const QString &windowGeometrySettingsKey = QString(), bool usePersistentWidget = false );
|
||||
QgsCodeEditorDockWidget( const QString &dockId = QString(), bool usePersistentWidget = false );
|
||||
%Docstring
|
||||
Constructor for QgsCodeEditorDockWidget, with the specified window geometry settings key.
|
||||
|
||||
|
@ -367,7 +367,8 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
|
||||
onTotalPendingJobsCountChanged();
|
||||
|
||||
mDockableWidgetHelper = new QgsDockableWidgetHelper( isDocked, mCanvasName, this, QgisApp::instance() );
|
||||
mDockableWidgetHelper = new QgsDockableWidgetHelper( mCanvasName, this, QgisApp::instance(), mCanvasName, QStringList(), isDocked ? QgsDockableWidgetHelper::OpeningMode::ForceDocked : QgsDockableWidgetHelper::OpeningMode::RespectSetting );
|
||||
|
||||
if ( QDialog *dialog = mDockableWidgetHelper->dialog() )
|
||||
{
|
||||
QFontMetrics fm( font() );
|
||||
|
@ -457,7 +457,8 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name )
|
||||
} );
|
||||
setLayout( layout );
|
||||
|
||||
mDockableWidgetHelper = new QgsDockableWidgetHelper( true, mCanvasName, this, QgisApp::instance(), Qt::BottomDockWidgetArea, QStringList(), true );
|
||||
mDockableWidgetHelper = new QgsDockableWidgetHelper( mCanvasName, this, QgisApp::instance(), mCanvasName, QStringList(), QgsDockableWidgetHelper::OpeningMode::RespectSetting, false, Qt::DockWidgetArea::BottomDockWidgetArea, QgsDockableWidgetHelper::Option::RaiseTab );
|
||||
|
||||
QToolButton *toggleButton = mDockableWidgetHelper->createDockUndockToolButton();
|
||||
toggleButton->setToolTip( tr( "Dock Elevation Profile View" ) );
|
||||
toolBar->addWidget( toggleButton );
|
||||
|
@ -243,7 +243,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa
|
||||
|
||||
connect( QgsProject::instance()->mapThemeCollection(), &QgsMapThemeCollection::mapThemeRenamed, this, &QgsMapCanvasDockWidget::currentMapThemeRenamed );
|
||||
|
||||
mDockableWidgetHelper = new QgsDockableWidgetHelper( isDocked, mCanvasName, this, QgisApp::instance(), Qt::RightDockWidgetArea );
|
||||
mDockableWidgetHelper = new QgsDockableWidgetHelper( mCanvasName, this, QgisApp::instance(), mCanvasName, QStringList(), isDocked ? QgsDockableWidgetHelper::OpeningMode::ForceDocked : QgsDockableWidgetHelper::OpeningMode::RespectSetting );
|
||||
QToolButton *toggleButton = mDockableWidgetHelper->createDockUndockToolButton();
|
||||
toggleButton->setToolTip( tr( "Dock 2D Map View" ) );
|
||||
mToolbar->addWidget( toggleButton );
|
||||
|
@ -17,10 +17,24 @@
|
||||
#include "moc_qgscodeeditordockwidget.cpp"
|
||||
#include "qgsdockablewidgethelper.h"
|
||||
|
||||
QgsCodeEditorDockWidget::QgsCodeEditorDockWidget( const QString &windowGeometrySettingsKey, bool usePersistentWidget )
|
||||
QgsCodeEditorDockWidget::QgsCodeEditorDockWidget( const QString &dockId, bool usePersistentWidget )
|
||||
: QWidget( nullptr )
|
||||
{
|
||||
mDockableWidgetHelper = new QgsDockableWidgetHelper( true, tr( "Code Editor" ), this, QgsDockableWidgetHelper::sOwnerWindow, Qt::BottomDockWidgetArea, QStringList(), true, windowGeometrySettingsKey, usePersistentWidget );
|
||||
QgsDockableWidgetHelper::Options options = QgsDockableWidgetHelper::Option::RaiseTab;
|
||||
if ( usePersistentWidget )
|
||||
options.setFlag( QgsDockableWidgetHelper::Option::PermanentWidget );
|
||||
|
||||
mDockableWidgetHelper = new QgsDockableWidgetHelper(
|
||||
tr( "Code Editor" ),
|
||||
this,
|
||||
QgsDockableWidgetHelper::sOwnerWindow,
|
||||
dockId,
|
||||
QStringList(),
|
||||
QgsDockableWidgetHelper::OpeningMode::RespectSetting,
|
||||
true,
|
||||
Qt::BottomDockWidgetArea,
|
||||
options
|
||||
);
|
||||
|
||||
mDockToggleButton = mDockableWidgetHelper->createDockUndockToolButton();
|
||||
mDockToggleButton->setToolTip( tr( "Dock Code Editor" ) );
|
||||
|
@ -41,7 +41,7 @@ class GUI_EXPORT QgsCodeEditorDockWidget : public QWidget
|
||||
*
|
||||
* If \a usePersistentWidget is TRUE then the widget (either as a dock or window) cannot be destroyed and must be hidden instead.
|
||||
*/
|
||||
QgsCodeEditorDockWidget( const QString &windowGeometrySettingsKey = QString(), bool usePersistentWidget = false );
|
||||
QgsCodeEditorDockWidget( const QString &dockId = QString(), bool usePersistentWidget = false );
|
||||
~QgsCodeEditorDockWidget() override;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include "qgsdockwidget.h"
|
||||
#include "qgsapplication.h"
|
||||
#include "qgssettings.h"
|
||||
|
||||
#include <QLayout>
|
||||
#include <QAction>
|
||||
@ -27,30 +26,14 @@
|
||||
///@cond PRIVATE
|
||||
|
||||
const QgsSettingsEntryBool *QgsDockableWidgetHelper::sSettingsIsDocked = new QgsSettingsEntryBool( QStringLiteral( "is-docked" ), QgsDockableWidgetHelper::sTtreeDockConfigs, false );
|
||||
const QgsSettingsEntryVariant *QgsDockableWidgetHelper::sSettingsWindowGeometry = new QgsSettingsEntryVariant( QStringLiteral( "geometry" ), QgsDockableWidgetHelper::sTtreeDockConfigs );
|
||||
const QgsSettingsEntryEnumFlag<Qt::DockWidgetArea> *QgsDockableWidgetHelper::sSettingsDockArea = new QgsSettingsEntryEnumFlag<Qt::DockWidgetArea>( QStringLiteral( "area" ), QgsDockableWidgetHelper::sTtreeDockConfigs, Qt::RightDockWidgetArea );
|
||||
const QgsSettingsEntryVariant *QgsDockableWidgetHelper::sSettingsDockGeometry = new QgsSettingsEntryVariant( QStringLiteral( "dock-geometry" ), QgsDockableWidgetHelper::sTtreeDockConfigs );
|
||||
const QgsSettingsEntryVariant *QgsDockableWidgetHelper::sSettingsDialogGeometry = new QgsSettingsEntryVariant( QStringLiteral( "dialog-geometry" ), QgsDockableWidgetHelper::sTtreeDockConfigs );
|
||||
const QgsSettingsEntryEnumFlag<Qt::DockWidgetArea> *QgsDockableWidgetHelper::sSettingsDockArea = new QgsSettingsEntryEnumFlag<Qt::DockWidgetArea>( QStringLiteral( "dock-area" ), QgsDockableWidgetHelper::sTtreeDockConfigs, Qt::RightDockWidgetArea );
|
||||
|
||||
std::function<void( Qt::DockWidgetArea, QDockWidget *, const QStringList &, bool )> QgsDockableWidgetHelper::sAddTabifiedDockWidgetFunction = []( Qt::DockWidgetArea, QDockWidget *, const QStringList &, bool ) {};
|
||||
std::function<QString()> QgsDockableWidgetHelper::sAppStylesheetFunction = [] { return QString(); };
|
||||
QMainWindow *QgsDockableWidgetHelper::sOwnerWindow = nullptr;
|
||||
|
||||
QgsDockableWidgetHelper::QgsDockableWidgetHelper( bool isDocked, const QString &windowTitle, QWidget *widget, QMainWindow *ownerWindow, Qt::DockWidgetArea defaultDockArea, const QStringList &tabifyWith, bool raiseTab, const QString &windowGeometrySettingsKey, bool usePersistentWidget )
|
||||
: QObject( nullptr )
|
||||
, mWidget( widget )
|
||||
, mDialogGeometry( 0, 0, 0, 0 )
|
||||
, mIsDockFloating( defaultDockArea == Qt::DockWidgetArea::NoDockWidgetArea )
|
||||
, mDockArea( defaultDockArea == Qt::DockWidgetArea::NoDockWidgetArea ? Qt::DockWidgetArea::RightDockWidgetArea : defaultDockArea )
|
||||
, mWindowTitle( windowTitle )
|
||||
, mOwnerWindow( ownerWindow )
|
||||
, mTabifyWith( tabifyWith )
|
||||
, mWindowGeometrySettingsKey( windowGeometrySettingsKey )
|
||||
, mUuid( QUuid::createUuid().toString() )
|
||||
{
|
||||
mOptions.setFlag( Option::RaiseTab, raiseTab );
|
||||
mOptions.setFlag( Option::PermanentWidget, usePersistentWidget );
|
||||
toggleDockMode( isDocked );
|
||||
}
|
||||
|
||||
QgsDockableWidgetHelper::QgsDockableWidgetHelper( const QString &windowTitle, QWidget *widget, QMainWindow *ownerWindow, const QString &dockId, const QStringList &tabifyWith, OpeningMode openingMode, bool defaultIsDocked, Qt::DockWidgetArea defaultDockArea, Options options )
|
||||
: QObject( nullptr )
|
||||
, mWidget( widget )
|
||||
@ -79,7 +62,7 @@ QgsDockableWidgetHelper::~QgsDockableWidgetHelper()
|
||||
{
|
||||
mDockGeometry = mDock->geometry();
|
||||
if ( !mSettingKeyDockId.isEmpty() )
|
||||
sSettingsWindowGeometry->setValue( mDock->saveGeometry(), mSettingKeyDockId );
|
||||
sSettingsDockGeometry->setValue( mDock->saveGeometry(), mSettingKeyDockId );
|
||||
mIsDockFloating = mDock->isFloating();
|
||||
if ( mOwnerWindow )
|
||||
mDockArea = mOwnerWindow->dockWidgetArea( mDock );
|
||||
@ -96,12 +79,8 @@ QgsDockableWidgetHelper::~QgsDockableWidgetHelper()
|
||||
{
|
||||
mDialogGeometry = mDialog->geometry();
|
||||
|
||||
if ( !mWindowGeometrySettingsKey.isEmpty() )
|
||||
{
|
||||
QgsSettings().setValue( mWindowGeometrySettingsKey, mDialog->saveGeometry() );
|
||||
}
|
||||
if ( !mSettingKeyDockId.isEmpty() )
|
||||
sSettingsWindowGeometry->setValue( mDialog->saveGeometry(), mSettingKeyDockId );
|
||||
sSettingsDialogGeometry->setValue( mDialog->saveGeometry(), mSettingKeyDockId );
|
||||
|
||||
mDialog->layout()->removeWidget( mWidget );
|
||||
mDialog->deleteLater();
|
||||
@ -259,8 +238,8 @@ void QgsDockableWidgetHelper::toggleDockMode( bool docked )
|
||||
if ( mDialog )
|
||||
{
|
||||
// going from window -> dock, so save current window geometry
|
||||
if ( !mWindowGeometrySettingsKey.isEmpty() )
|
||||
QgsSettings().setValue( mWindowGeometrySettingsKey, mDialog->saveGeometry() );
|
||||
if ( !mSettingKeyDockId.isEmpty() )
|
||||
sSettingsDialogGeometry->setValue( mDialog->saveGeometry(), mSettingKeyDockId );
|
||||
|
||||
mDialogGeometry = mDialog->geometry();
|
||||
|
||||
@ -332,14 +311,9 @@ void QgsDockableWidgetHelper::toggleDockMode( bool docked )
|
||||
vl->setContentsMargins( 0, 0, 0, 0 );
|
||||
vl->addWidget( mWidget );
|
||||
|
||||
if ( !mWindowGeometrySettingsKey.isEmpty() )
|
||||
if ( !mSettingKeyDockId.isEmpty() )
|
||||
{
|
||||
QgsSettings settings;
|
||||
mDialog->restoreGeometry( settings.value( mWindowGeometrySettingsKey ).toByteArray() );
|
||||
}
|
||||
else if ( !mSettingKeyDockId.isEmpty() )
|
||||
{
|
||||
mDialog->restoreGeometry( sSettingsWindowGeometry->value( mSettingKeyDockId ).toByteArray() );
|
||||
mDialog->restoreGeometry( sSettingsDialogGeometry->value( mSettingKeyDockId ).toByteArray() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -455,8 +429,8 @@ void QgsDockableWidgetHelper::setupDockWidget( const QStringList &tabSiblings )
|
||||
// can only resize properly and set the dock geometry after pending events have been processed,
|
||||
// so queue the geometry setting on the end of the event loop
|
||||
QMetaObject::invokeMethod( mDock, [this] {
|
||||
if (mIsDockFloating && sSettingsWindowGeometry->exists(mSettingKeyDockId))
|
||||
mDock->restoreGeometry( sSettingsWindowGeometry->value(mSettingKeyDockId).toByteArray() );
|
||||
if (mIsDockFloating && sSettingsDockGeometry->exists( mSettingKeyDockId ) )
|
||||
mDock->restoreGeometry( sSettingsDockGeometry->value( mSettingKeyDockId ).toByteArray() );
|
||||
else
|
||||
mDock->setGeometry( mDockGeometry ); }, Qt::QueuedConnection );
|
||||
}
|
||||
|
@ -57,7 +57,8 @@ class GUI_EXPORT QgsDockableWidgetHelper : public QObject
|
||||
static inline QgsSettingsTreeNode *sTtreeDockConfigs = QgsGui::sTtreeWidgetGeometry->createNamedListNode( QStringLiteral( "docks" ) ) SIP_SKIP;
|
||||
|
||||
static const QgsSettingsEntryBool *sSettingsIsDocked SIP_SKIP;
|
||||
static const QgsSettingsEntryVariant *sSettingsWindowGeometry SIP_SKIP;
|
||||
static const QgsSettingsEntryVariant *sSettingsDockGeometry SIP_SKIP;
|
||||
static const QgsSettingsEntryVariant *sSettingsDialogGeometry SIP_SKIP;
|
||||
static const QgsSettingsEntryEnumFlag<Qt::DockWidgetArea> *sSettingsDockArea SIP_SKIP;
|
||||
|
||||
Q_OBJECT
|
||||
@ -77,14 +78,6 @@ class GUI_EXPORT QgsDockableWidgetHelper : public QObject
|
||||
Q_ENUM( Option )
|
||||
Q_DECLARE_FLAGS( Options, Option )
|
||||
|
||||
/**
|
||||
* Constructs an object that is responsible of making a docked widget or a window titled \a windowTitle that holds the \a widget
|
||||
* The ownership of \a widget is returned to \a ownerWindow once the object is destroyed.
|
||||
*
|
||||
* If \a usePersistentWidget is TRUE then the \a widget (either as a dock or window) cannot be destroyed and must be hidden instead.
|
||||
*/
|
||||
QgsDockableWidgetHelper( bool isDocked, const QString &windowTitle, QWidget *widget, QMainWindow *ownerWindow, Qt::DockWidgetArea defaultDockArea = Qt::NoDockWidgetArea, const QStringList &tabifyWith = QStringList(), bool raiseTab = false, const QString &windowGeometrySettingsKey = QString(), bool usePersistentWidget = false );
|
||||
|
||||
/**
|
||||
* Constructs an object that is responsible of making a docked widget or a window titled \a windowTitle that holds the \a widget
|
||||
* The ownership of \a widget is returned to \a ownerWindow once the object is destroyed.
|
||||
@ -193,8 +186,6 @@ class GUI_EXPORT QgsDockableWidgetHelper : public QObject
|
||||
QStringList mTabifyWith;
|
||||
Options mOptions;
|
||||
|
||||
QString mWindowGeometrySettingsKey;
|
||||
|
||||
// Unique identifier of dock
|
||||
QString mUuid;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user