Skip to content

Commit

Permalink
QgsSettingsTree widget refresh setting list on show
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 committed Apr 26, 2021
1 parent 1def5e7 commit 79393b6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/app/qgssettingstree.cpp
Expand Up @@ -48,6 +48,7 @@
#include "qgssettingsentry.h"
#include "qgssettingsregistrycore.h"
#include "qgsapplication.h"
#include "qgsguiutils.h"

#include <QMenu>
#include <QMessageBox>
Expand Down Expand Up @@ -80,14 +81,14 @@ QgsSettingsTree::QgsSettingsTree( QWidget *parent )

void QgsSettingsTree::setSettingsObject( QgsSettings *settings )
{
delete this->mSettings;
this->mSettings = settings;
mSettings = settings;
clear();

if ( settings )
if ( mSettings )
{
settings->setParent( this );
refresh();
mSettings->setParent( this );
if ( isVisible() )
refresh();
if ( mAutoRefresh )
mRefreshTimer.start();
}
Expand All @@ -104,18 +105,16 @@ QSize QgsSettingsTree::sizeHint() const

void QgsSettingsTree::setAutoRefresh( bool autoRefresh )
{
this->mAutoRefresh = autoRefresh;
if ( mSettings )
mAutoRefresh = autoRefresh;
if ( mAutoRefresh )
{
if ( autoRefresh )
{
maybeRefresh();
maybeRefresh();
if ( mSettings )
mRefreshTimer.start();
}
else
{
mRefreshTimer.stop();
}
}
else
{
mRefreshTimer.stop();
}
}

Expand Down Expand Up @@ -162,6 +161,12 @@ bool QgsSettingsTree::event( QEvent *event )
return QTreeWidget::event( event );
}

void QgsSettingsTree::showEvent( QShowEvent * )
{
QgsTemporaryCursorOverride waitCursor( Qt::BusyCursor );
refresh();
}

void QgsSettingsTree::updateSetting( QTreeWidgetItem *item )
{
QString key = itemKey( item );
Expand Down
1 change: 1 addition & 0 deletions src/app/qgssettingstree.h
Expand Up @@ -83,6 +83,7 @@ class QgsSettingsTree : public QTreeWidget

protected:
bool event( QEvent *event ) override;
void showEvent( QShowEvent * ) override;

private slots:
void updateSetting( QTreeWidgetItem *item );
Expand Down
6 changes: 6 additions & 0 deletions src/core/settings/qgssettingsentry.cpp
Expand Up @@ -85,6 +85,12 @@ QString QgsSettingsEntryBase::key( const QStringList &dynamicKeyPartList ) const

bool QgsSettingsEntryBase::keyIsValid( const QString &key ) const
{
if ( !hasDynamicKey() )
{
if ( !key.contains( definitionKey() ) )
return false;
}

// Key to check
QString completeKeyToCheck = key;

Expand Down

0 comments on commit 79393b6

Please sign in to comment.