Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add win32 native implementation, and new openFileExplorerAndSelectFile
method to QgsNative Opens the desktop file explorer at the folder containing path, and (if possible) scrolls to and pre-selects the file at path itself. The default implementation just calls the QDesktopServices method to open the folder, without selecting the specified file. Use this to automatically select the exported layout file when clicking the message bar success message in layouts (on Windows)
- Loading branch information
Showing
with
133 additions
and 12 deletions.
- +4 −6 src/app/layout/qgslayoutdesignerdialog.cpp
- +3 −3 src/app/qgsprojectproperties.cpp
- +3 −0 src/gui/CMakeLists.txt
- +4 −0 src/gui/qgsgui.cpp
- +8 −2 src/gui/qgsmessagebaritem.cpp
- +24 −1 src/native/CMakeLists.txt
- +11 −0 src/native/qgsnative.cpp
- +13 −0 src/native/qgsnative.h
- +31 −0 src/native/win/qgswinnative.cpp
- +32 −0 src/native/win/qgswinnative.h
@@ -0,0 +1,31 @@ | ||
/*************************************************************************** | ||
qgswinnative.cpp - abstracted interface to native system calls | ||
------------------- | ||
begin : January 2017 | ||
copyright : (C) 2017 by Matthias Kuhn | ||
email : matthias@opengis.ch | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* 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 "qgswinnative.h" | ||
#include <QString> | ||
#include <QDir> | ||
|
||
void QgsWinNative::openFileExplorerAndSelectFile( const QString &path ) | ||
{ | ||
const QString nativePath = QDir::toNativeSeparators( path ); | ||
ITEMIDLIST *pidl = ILCreateFromPath( nativePath.toUtf8().constData() ); | ||
if ( pidl ) | ||
{ | ||
SHOpenFolderAndSelectItems( pidl, 0, 0, 0 ); | ||
ILFree( pidl ); | ||
} | ||
} |
@@ -0,0 +1,32 @@ | ||
/*************************************************************************** | ||
qgswinnative.h - abstracted interface to native Mac objective-c | ||
------------------- | ||
begin : January 2014 | ||
copyright : (C) 2014 by Larry Shaffer | ||
email : larrys at dakotacarto 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 QGSMACNATIVE_H | ||
#define QGSMACNATIVE_H | ||
|
||
#include "qgsnative.h" | ||
#include <windows.h> | ||
#include <shlobj.h> | ||
#pragma comment(lib,"Shell32.lib") | ||
|
||
class NATIVE_EXPORT QgsWinNative : public QgsNative | ||
{ | ||
public: | ||
void openFileExplorerAndSelectFile( const QString &path ) override; | ||
}; | ||
|
||
#endif // QGSMACNATIVE_H |