QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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
7 email : denis.rouzaud@gmail.com
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( QMetaType::Type type = QMetaType::Type::QString ) const;
95
101 Q_DECL_DEPRECATED QVariant documentPath( QVariant::Type type ) const SIP_DEPRECATED;
102
103 void setDocumentPath( const QVariant &documentPath );
104
108 QgsExternalStorageFileWidget *fileWidget();
109
111 bool fileWidgetVisible() const;
113 void setFileWidgetVisible( bool visible );
114
116 QgsExternalResourceWidget::DocumentViewerContent documentViewerContent() const;
118 void setDocumentViewerContent( QgsExternalResourceWidget::DocumentViewerContent content );
119
121 int documentViewerHeight() const;
122
127 void setDocumentViewerHeight( int height );
129 int documentViewerWidth() const;
130
135 void setDocumentViewerWidth( int width );
136
138 void setReadOnly( bool readOnly );
139
144 QgsFileWidget::RelativeStorage relativeStorage() const;
145
150 void setRelativeStorage( QgsFileWidget::RelativeStorage relativeStorage );
151
152
157 QString defaultRoot() const;
158
163 void setDefaultRoot( const QString &defaultRoot );
164
171 void setStorageType( const QString &storageType );
172
179 QString storageType() const;
180
186 void setStorageAuthConfigId( const QString &authCfg );
187
192 QString storageAuthConfigId() const;
193
198 void setMessageBar( QgsMessageBar *messageBar );
199
204 QgsMessageBar *messageBar() const;
205
206 signals:
208 void valueChanged( const QString &value );
209
210 private slots:
211 void loadDocument( const QString &path );
212 void onFetchFinished();
213
214 private:
215 void updateDocumentViewer();
216
220 void updateDocumentContent( const QString &filePath );
221
225 void clearContent();
226
227 QString resolvePath( const QString &path );
228
230 bool mFileWidgetVisible = true;
231
232 DocumentViewerContent mDocumentViewerContent = NoContent;
233 int mDocumentViewerHeight = 0;
234 int mDocumentViewerWidth = 0;
235
237 QString mDefaultRoot; // configured default root path for QgsFileWidget::RelativeStorage::RelativeDefaultPath
238
240 QgsExternalStorageFileWidget *mFileWidget = nullptr;
241 QgsPixmapLabel *mPixmapLabel = nullptr;
242#ifdef WITH_QTWEBKIT
244 QWebView *mWebView = nullptr;
245#endif
246 QgsMediaWidget *mMediaWidget = nullptr;
247
248 QLabel *mLoadingLabel = nullptr;
249 QLabel *mErrorLabel = nullptr;
250 QMovie *mLoadingMovie = nullptr;
251 QPointer<QgsExternalStorageFetchedContent> mContent;
252
253 friend class TestQgsExternalResourceWidgetWrapper;
254};
255
256#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