Skip to content
Permalink
Browse files

[FEATURE] Double clicking a style .xml in the browser now opens

the manager dialog, allowing browsing and non-edit actions for the
style.
  • Loading branch information
nyalldawson committed Jan 16, 2019
1 parent 2c22bea commit 701a29fd6ed7a505a6601ad38105a0c8bc712b41
Showing with 31 additions and 6 deletions.
  1. +27 −6 src/app/qgsappbrowserproviders.cpp
  2. +4 −0 src/app/qgsappbrowserproviders.h
@@ -19,6 +19,8 @@
#include "qgsstyle.h"
#include "qgslayertreenode.h"
#include "qgslayertree.h"
#include "qgsstylemanagerdialog.h"
#include "qgsguiutils.h"
#include <QDesktopServices>

//
@@ -309,24 +311,43 @@ QgsMimeDataUtils::Uri QgsStyleXmlDataItem::mimeUri() const

bool QgsStyleXmlDataItem::handleDoubleClick()
{
QgsStyleExportImportDialog dlg( QgsStyle::defaultStyle(), QgisApp::instance(), QgsStyleExportImportDialog::Import );
dlg.setImportFilePath( mPath );
dlg.exec();

browseStyle( mPath );
return true;
}

QList<QAction *> QgsStyleXmlDataItem::actions( QWidget *parent )
{
QAction *importAction = new QAction( tr( "&Import Style…" ), parent );
QAction *browseAction = new QAction( tr( "&Open Style…" ), parent );
const QString path = mPath;
connect( browseAction, &QAction::triggered, this, [path]
{
browseStyle( path );
} );

QAction *importAction = new QAction( tr( "&Import Style…" ), parent );
connect( importAction, &QAction::triggered, this, [path]
{
QgsStyleExportImportDialog dlg( QgsStyle::defaultStyle(), QgisApp::instance(), QgsStyleExportImportDialog::Import );
dlg.setImportFilePath( path );
dlg.exec();
} );
return QList<QAction *>() << importAction;
return QList<QAction *>() << browseAction << importAction;
}

void QgsStyleXmlDataItem::browseStyle( const QString &xmlPath )
{
QgsStyle s;
s.createMemoryDatabase();

auto cursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
if ( s.importXml( xmlPath ) )
{
cursorOverride.reset();
QgsStyleManagerDialog dlg( &s, QgisApp::instance(), Qt::WindowFlags(), true );
dlg.setSmartGroupsVisible( false );
dlg.setFavoritesGroupVisible( false );
dlg.exec();
}
}

//
@@ -163,6 +163,10 @@ class QgsStyleXmlDataItem : public QgsDataItem
bool handleDoubleClick() override;
QList< QAction * > actions( QWidget *parent ) override;

private:

static void browseStyle( const QString &xmlPath );

};

/**

0 comments on commit 701a29f

Please sign in to comment.
You can’t perform that action at this time.