QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsexternalresourcewidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsexternalresourcewidget.h
3
4 ---------------------
5 begin : 16.12.2015
6 copyright : (C) 2015 by Denis Rouzaud
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSEXTERNALRESOURCEWIDGET_H
18#define QGSEXTERNALRESOURCEWIDGET_H
19
20class QWebView;
21class QgsPixmapLabel;
22class QgsMediaWidget;
23class QgsMessageBar;
26
27#include "qgis_gui.h"
28#include "qgis_sip.h"
29#include "qgsfilewidget.h"
30
31#include <QPointer>
32#include <QVariant>
33#include <QWidget>
34
35#ifdef SIP_RUN
36//%ModuleHeaderCode
37// fix to allow compilation with sip that for some reason
38// doesn't add this include to the file where the code from
39// ConvertToSubClassCode goes.
41
43//%End
44#endif
45
46
52class GUI_EXPORT QgsExternalResourceWidget : public QWidget
53{
54#ifdef SIP_RUN
56 if ( qobject_cast<QgsExternalResourceWidget *>( sipCpp ) )
57 sipType = sipType_QgsExternalResourceWidget;
58 else
59 sipType = NULL;
61#endif
62
63 Q_OBJECT
68 Q_PROPERTY( QgsFileWidget::RelativeStorage relativeStorage READ relativeStorage WRITE setRelativeStorage )
69 Q_PROPERTY( QString defaultRoot READ defaultRoot WRITE setDefaultRoot )
70
71 public:
73 {
77 Audio, // since QGIS 3.30
78 Video, // since QGIS 3.30
79 };
80
86 explicit QgsExternalResourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
87
92 QVariant documentPath( QMetaType::Type type = QMetaType::Type::QString ) const;
93
99 Q_DECL_DEPRECATED QVariant documentPath( QVariant::Type type ) const SIP_DEPRECATED;
100
101 void setDocumentPath( const QVariant &documentPath );
102
106 QgsExternalStorageFileWidget *fileWidget();
107
109 bool fileWidgetVisible() const;
111 void setFileWidgetVisible( bool visible );
112
114 QgsExternalResourceWidget::DocumentViewerContent documentViewerContent() const;
116 void setDocumentViewerContent( QgsExternalResourceWidget::DocumentViewerContent content );
117
119 int documentViewerHeight() const;
120
125 void setDocumentViewerHeight( int height );
127 int documentViewerWidth() const;
128
133 void setDocumentViewerWidth( int width );
134
136 void setReadOnly( bool readOnly );
137
142 QgsFileWidget::RelativeStorage relativeStorage() const;
143
148 void setRelativeStorage( QgsFileWidget::RelativeStorage relativeStorage );
149
150
155 QString defaultRoot() const;
156
161 void setDefaultRoot( const QString &defaultRoot );
162
169 void setStorageType( const QString &storageType );
170
177 QString storageType() const;
178
184 void setStorageAuthConfigId( const QString &authCfg );
185
190 QString storageAuthConfigId() const;
191
196 void setMessageBar( QgsMessageBar *messageBar );
197
202 QgsMessageBar *messageBar() const;
203
204 signals:
206 void valueChanged( const QString &value );
207
208 private slots:
209 void loadDocument( const QString &path );
210 void onFetchFinished();
211
212 private:
213 void updateDocumentViewer();
214
218 void updateDocumentContent( const QString &filePath );
219
223 void clearContent();
224
225 QString resolvePath( const QString &path );
226
228 bool mFileWidgetVisible = true;
229
230 DocumentViewerContent mDocumentViewerContent = NoContent;
231 int mDocumentViewerHeight = 0;
232 int mDocumentViewerWidth = 0;
233
235 QString mDefaultRoot; // configured default root path for QgsFileWidget::RelativeStorage::RelativeDefaultPath
236
238 QgsExternalStorageFileWidget *mFileWidget = nullptr;
239 QgsPixmapLabel *mPixmapLabel = nullptr;
240#ifdef WITH_QTWEBKIT
242 QWebView *mWebView = nullptr;
243#endif
244 QgsMediaWidget *mMediaWidget = nullptr;
245
246 QLabel *mLoadingLabel = nullptr;
247 QLabel *mErrorLabel = nullptr;
248 QMovie *mLoadingMovie = nullptr;
249 QPointer<QgsExternalStorageFetchedContent> mContent;
250
252};
253
254#endif // QGSEXTERNALRESOURCEWIDGET_H
Widget to display file path with a push button for an "open file" dialog It can also be used to displ...
QgsExternalResourceWidget(QWidget *parent=nullptr)
QgsExternalResourceWidget creates a widget with a file widget and a document viewer Both part of the ...
void setRelativeStorage(QgsFileWidget::RelativeStorage relativeStorage)
Configures if paths are handled absolute or relative and if relative, which should be the base path.
void setDocumentViewerHeight(int height)
setDocumentViewerWidth set the height of the document viewer.
void setDocumentViewerContent(QgsExternalResourceWidget::DocumentViewerContent content)
setDocumentViewerContent defines the type of content to be shown. Widget will be adapted accordingly
DocumentViewerContent documentViewerContent
void setDefaultRoot(const QString &defaultRoot)
Configures the base path which should be used if the relativeStorage property is set to QgsFileWidget...
QgsFileWidget::RelativeStorage relativeStorage
void setDocumentViewerWidth(int width)
setDocumentViewerWidth set the width of the document viewer.
void setFileWidgetVisible(bool visible)
Sets the visibility of the file widget in the layout.
void valueChanged(const QString &value)
Emitted as soon as the current document changes.
Abstract base class for QgsExternalStorage fetched content.
A widget for selecting a file or a folder and optionally storing it to an external storage backend.
A widget for selecting a file or a folder.
RelativeStorage
The RelativeStorage enum determines if path is absolute, relative to the current project path or rela...
A widget for playing back audio and video media files.
A bar for displaying non-blocking messages to the user.
Shows a pixmap and adjusts its size to the space given to the widget by the layout and keeping its as...
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:199
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_END
Definition qgis_sip.h:216