QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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 <QWidget>
28#include <QVariant>
29#include <QPointer>
30
31#include "qgsfilewidget.h"
32#include "qgis_gui.h"
33#include "qgis_sip.h"
34
35
36#ifdef SIP_RUN
37% ModuleHeaderCode
38// fix to allow compilation with sip that for some reason
39// doesn't add this include to the file where the code from
40// ConvertToSubClassCode goes.
42
44% End
45#endif
46
47
53class GUI_EXPORT QgsExternalResourceWidget : public QWidget
54{
55
56#ifdef SIP_RUN
58 if ( qobject_cast<QgsExternalResourceWidget *>( sipCpp ) )
59 sipType = sipType_QgsExternalResourceWidget;
60 else
61 sipType = NULL;
63#endif
64
65 Q_OBJECT
66 Q_PROPERTY( bool fileWidgetVisible READ fileWidgetVisible WRITE setFileWidgetVisible )
67 Q_PROPERTY( DocumentViewerContent documentViewerContent READ documentViewerContent WRITE setDocumentViewerContent )
68 Q_PROPERTY( int documentViewerHeight READ documentViewerHeight WRITE setDocumentViewerHeight )
69 Q_PROPERTY( int documentViewerWidth READ documentViewerWidth WRITE setDocumentViewerWidth )
70 Q_PROPERTY( QgsFileWidget::RelativeStorage relativeStorage READ relativeStorage WRITE setRelativeStorage )
71 Q_PROPERTY( QString defaultRoot READ defaultRoot WRITE setDefaultRoot )
72
73 public:
75 {
79 Audio, // since QGIS 3.30
80 Video, // since QGIS 3.30
81 };
82
88 explicit QgsExternalResourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
89
94 QVariant documentPath( QVariant::Type type = QVariant::String ) const;
95 void setDocumentPath( const QVariant &documentPath );
96
100 QgsExternalStorageFileWidget *fileWidget();
101
103 bool fileWidgetVisible() const;
105 void setFileWidgetVisible( bool visible );
106
108 QgsExternalResourceWidget::DocumentViewerContent documentViewerContent() const;
110 void setDocumentViewerContent( QgsExternalResourceWidget::DocumentViewerContent content );
111
113 int documentViewerHeight() const;
114
119 void setDocumentViewerHeight( int height );
121 int documentViewerWidth() const;
122
127 void setDocumentViewerWidth( int width );
128
130 void setReadOnly( bool readOnly );
131
136 QgsFileWidget::RelativeStorage relativeStorage() const;
137
142 void setRelativeStorage( QgsFileWidget::RelativeStorage relativeStorage );
143
144
149 QString defaultRoot() const;
150
155 void setDefaultRoot( const QString &defaultRoot );
156
163 void setStorageType( const QString &storageType );
164
171 QString storageType() const;
172
178 void setStorageAuthConfigId( const QString &authCfg );
179
184 QString storageAuthConfigId() const;
185
190 void setMessageBar( QgsMessageBar *messageBar );
191
196 QgsMessageBar *messageBar() const;
197
198 signals:
200 void valueChanged( const QString & );
201
202 private slots:
203 void loadDocument( const QString &path );
204 void onFetchFinished();
205
206 private:
207 void updateDocumentViewer();
208
212 void updateDocumentContent( const QString &filePath );
213
217 void clearContent();
218
219 QString resolvePath( const QString &path );
220
222 bool mFileWidgetVisible = true;
223
224 DocumentViewerContent mDocumentViewerContent = NoContent;
225 int mDocumentViewerHeight = 0;
226 int mDocumentViewerWidth = 0;
227
229 QString mDefaultRoot; // configured default root path for QgsFileWidget::RelativeStorage::RelativeDefaultPath
230
232 QgsExternalStorageFileWidget *mFileWidget = nullptr;
233 QgsPixmapLabel *mPixmapLabel = nullptr;
234#ifdef WITH_QTWEBKIT
236 QWebView *mWebView = nullptr;
237#endif
238 QgsMediaWidget *mMediaWidget = nullptr;
239
240 QLabel *mLoadingLabel = nullptr;
241 QLabel *mErrorLabel = nullptr;
242 QMovie *mLoadingMovie = nullptr;
243 QPointer<QgsExternalStorageFetchedContent> mContent;
244
245 friend class TestQgsExternalResourceWidgetWrapper;
246};
247
248#endif // QGSEXTERNALRESOURCEWIDGET_H
Widget to display file path with a push button for an "open file" dialog It can also be used to displ...
void valueChanged(const QString &)
emitteed as soon as the current document changes
Class for QgsExternalStorage fetched content.
The QgsExternalStorageFileWidget class creates a widget for selecting a file or a folder and stores i...
The QgsFileWidget class creates 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...
The QgsMediaWidget class creates a widget for playing back audio and video media files.
A bar for displaying non-blocking messages to the user.
The QgsPixmapLabel class shows a pixmap and adjusts its size to the space given to the widget by the ...
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:186
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_END
Definition qgis_sip.h:203