QGIS API Documentation 3.41.0-Master (af5edcb665c)
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#ifdef SIP_RUN
57 if ( qobject_cast<QgsExternalResourceWidget *>( sipCpp ) )
58 sipType = sipType_QgsExternalResourceWidget;
59 else
60 sipType = NULL;
62#endif
63
64 Q_OBJECT
65 Q_PROPERTY( bool fileWidgetVisible READ fileWidgetVisible WRITE setFileWidgetVisible )
66 Q_PROPERTY( DocumentViewerContent documentViewerContent READ documentViewerContent WRITE setDocumentViewerContent )
67 Q_PROPERTY( int documentViewerHeight READ documentViewerHeight WRITE setDocumentViewerHeight )
68 Q_PROPERTY( int documentViewerWidth READ documentViewerWidth WRITE setDocumentViewerWidth )
69 Q_PROPERTY( QgsFileWidget::RelativeStorage relativeStorage READ relativeStorage WRITE setRelativeStorage )
70 Q_PROPERTY( QString defaultRoot READ defaultRoot WRITE setDefaultRoot )
71
72 public:
74 {
78 Audio, // since QGIS 3.30
79 Video, // since QGIS 3.30
80 };
81
87 explicit QgsExternalResourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
88
93 QVariant documentPath( QMetaType::Type type = QMetaType::Type::QString ) const;
94
100 Q_DECL_DEPRECATED QVariant documentPath( QVariant::Type type ) const SIP_DEPRECATED;
101
102 void setDocumentPath( const QVariant &documentPath );
103
107 QgsExternalStorageFileWidget *fileWidget();
108
110 bool fileWidgetVisible() const;
112 void setFileWidgetVisible( bool visible );
113
115 QgsExternalResourceWidget::DocumentViewerContent documentViewerContent() const;
117 void setDocumentViewerContent( QgsExternalResourceWidget::DocumentViewerContent content );
118
120 int documentViewerHeight() const;
121
126 void setDocumentViewerHeight( int height );
128 int documentViewerWidth() const;
129
134 void setDocumentViewerWidth( int width );
135
137 void setReadOnly( bool readOnly );
138
143 QgsFileWidget::RelativeStorage relativeStorage() const;
144
149 void setRelativeStorage( QgsFileWidget::RelativeStorage relativeStorage );
150
151
156 QString defaultRoot() const;
157
162 void setDefaultRoot( const QString &defaultRoot );
163
170 void setStorageType( const QString &storageType );
171
178 QString storageType() const;
179
185 void setStorageAuthConfigId( const QString &authCfg );
186
191 QString storageAuthConfigId() const;
192
197 void setMessageBar( QgsMessageBar *messageBar );
198
203 QgsMessageBar *messageBar() const;
204
205 signals:
207 void valueChanged( const QString &value );
208
209 private slots:
210 void loadDocument( const QString &path );
211 void onFetchFinished();
212
213 private:
214 void updateDocumentViewer();
215
219 void updateDocumentContent( const QString &filePath );
220
224 void clearContent();
225
226 QString resolvePath( const QString &path );
227
229 bool mFileWidgetVisible = true;
230
231 DocumentViewerContent mDocumentViewerContent = NoContent;
232 int mDocumentViewerHeight = 0;
233 int mDocumentViewerWidth = 0;
234
236 QString mDefaultRoot; // configured default root path for QgsFileWidget::RelativeStorage::RelativeDefaultPath
237
239 QgsExternalStorageFileWidget *mFileWidget = nullptr;
240 QgsPixmapLabel *mPixmapLabel = nullptr;
241#ifdef WITH_QTWEBKIT
243 QWebView *mWebView = nullptr;
244#endif
245 QgsMediaWidget *mMediaWidget = nullptr;
246
247 QLabel *mLoadingLabel = nullptr;
248 QLabel *mErrorLabel = nullptr;
249 QMovie *mLoadingMovie = nullptr;
250 QPointer<QgsExternalStorageFetchedContent> mContent;
251
252 friend class TestQgsExternalResourceWidgetWrapper;
253};
254
255#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 &value)
Emitted 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:191
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_END
Definition qgis_sip.h:208