File indexing completed on 2024-05-12 04:19:39
0001 // vim: set tabstop=4 shiftwidth=4 expandtab: 0002 /* 0003 Gwenview: an image viewer 0004 Copyright 2011 Aurélien Gâteau <agateau@kde.org> 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public License 0008 as published by the Free Software Foundation; either version 2 0009 of the License, or (at your option) any later version. 0010 0011 This program is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 GNU General Public License for more details. 0015 0016 You should have received a copy of the GNU General Public License 0017 along with this program; if not, write to the Free Software 0018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. 0019 0020 */ 0021 #ifndef DOCUMENTVIEWCONTAINER_H 0022 #define DOCUMENTVIEWCONTAINER_H 0023 0024 #include <lib/gwenviewlib_export.h> 0025 0026 // Local 0027 #include <lib/documentview/documentview.h> 0028 0029 // KF 0030 0031 // Qt 0032 #include <QGraphicsView> 0033 #include <QUrl> 0034 0035 namespace Gwenview 0036 { 0037 class DocumentView; 0038 0039 struct DocumentViewContainerPrivate; 0040 /** 0041 * A container for DocumentViews which will arrange them to make best use of 0042 * available space. 0043 * 0044 * All creations and deletions of DocumentViews/images use this class even if 0045 * only a single image is viewed. 0046 */ 0047 class GWENVIEWLIB_EXPORT DocumentViewContainer : public QGraphicsView 0048 { 0049 Q_OBJECT 0050 public: 0051 explicit DocumentViewContainer(QWidget *parent = nullptr); 0052 ~DocumentViewContainer() override; 0053 0054 /** 0055 * Create a DocumentView in the DocumentViewContainer scene 0056 */ 0057 DocumentView *createView(); 0058 0059 /** 0060 * Delete view. Note that the view will first be faded to black before 0061 * being destroyed. 0062 */ 0063 void deleteView(DocumentView *view); 0064 0065 /** 0066 * Immediately delete all views 0067 */ 0068 void reset(); 0069 0070 /** 0071 * Returns saved Setup configuration for a previously viewed document 0072 */ 0073 DocumentView::Setup savedSetup(const QUrl &url) const; 0074 0075 /** 0076 * Updates setupForUrl hash with latest setup values 0077 */ 0078 void updateSetup(DocumentView *view); 0079 0080 void showMessageWidget(QGraphicsWidget *, Qt::Alignment); 0081 0082 /** 0083 * Set palette on this and all document views 0084 */ 0085 void applyPalette(const QPalette &palette); 0086 0087 public Q_SLOTS: 0088 void updateLayout(); 0089 0090 protected: 0091 void showEvent(QShowEvent *) override; 0092 void resizeEvent(QResizeEvent *) override; 0093 0094 private: 0095 friend class ViewItem; 0096 DocumentViewContainerPrivate *const d; 0097 0098 private Q_SLOTS: 0099 void slotFadeInFinished(DocumentView *); 0100 void pretendFadeInFinished(); 0101 void slotConfigChanged(); 0102 }; 0103 0104 } // namespace 0105 0106 #endif /* DOCUMENTVIEWCONTAINER_H */