File indexing completed on 2024-05-12 17:12:41
0001 /*************************************************************************** 0002 * Copyright (C) 2007 by Romain Campioni * 0003 * Copyright (C) 2009 by Renaud Guezennec * 0004 * https://rolisteam.org/contact * 0005 * * 0006 * rolisteam is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (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 * 0018 * Free Software Foundation, Inc., * 0019 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0020 ***************************************************************************/ 0021 #ifndef WORKSPACE_AMELIORE_H 0022 #define WORKSPACE_AMELIORE_H 0023 0024 #include <QImage> 0025 #include <QMdiArea> 0026 #include <QPaintEvent> 0027 #include <QPointer> 0028 #include <QToolBar> 0029 #include <QWidget> 0030 0031 #include "mediacontainers/mediacontainer.h" 0032 #include "rwidgets_global.h" 0033 0034 class RWIDGET_EXPORT PreventClosing : public QObject 0035 { 0036 Q_OBJECT 0037 public: 0038 PreventClosing(QObject* watched, QObject* parent= nullptr); 0039 0040 protected: 0041 bool eventFilter(QObject* obj, QEvent* event); 0042 0043 signals: 0044 void visibilityObjectChanged(bool); 0045 0046 private: 0047 QPointer<QObject> m_watched; 0048 }; 0049 0050 class ContentController; 0051 class ImageController; 0052 class VectorialMapController; 0053 class CharacterSheetController; 0054 class WebpageController; 0055 class SharedNoteController; 0056 class MapController; 0057 class PdfController; 0058 class NoteController; 0059 class InstantMessagingController; 0060 class MindMapController; 0061 /** 0062 * @brief The ImprovedWorkspace class 0063 */ 0064 class RWIDGET_EXPORT Workspace : public QMdiArea 0065 { 0066 Q_OBJECT 0067 public: 0068 enum Positioning 0069 { 0070 TopLeft, 0071 BottomLeft, 0072 Center, 0073 TopRight, 0074 BottomRight, 0075 Scaled, 0076 Filled, 0077 Repeated 0078 }; 0079 Workspace(QToolBar* toolbar, ContentController* ctrl, InstantMessagingController* instantCtrl, 0080 QWidget* parent= nullptr); 0081 ~Workspace(); 0082 0083 QString backgroundImagePath() const; 0084 0085 void addContainerMedia(MediaContainer* mediac); 0086 void preferencesHasChanged(const QString&); 0087 void removeMediaContainer(MediaContainer* mediac); 0088 QVector<QMdiSubWindow*> getAllSubWindowFromId(const QString& id) const; 0089 bool closeAllSubs(); 0090 signals: 0091 void removedAction(QAction*); 0092 void vmapActive(); 0093 0094 public slots: 0095 void setTabbedMode(bool); 0096 void addWidgetToMdi(MediaContainer*, const QString& title); 0097 void closeActiveSub(); 0098 0099 protected slots: 0100 void addMedia(MediaControllerBase* ctrl); 0101 void addImage(ImageController* ctrl); 0102 void addVectorialMap(VectorialMapController* ctrl); 0103 void addCharacterSheet(CharacterSheetController* ctrl); 0104 void addWebpage(WebpageController* ctrl); 0105 void addSharedNote(SharedNoteController* ctrl); 0106 void addNote(NoteController* ctrl); 0107 void addMindMap(MindMapController* ctrl); 0108 void addPdf(PdfController* ctrl); 0109 0110 protected: 0111 void resizeEvent(QResizeEvent* event); 0112 bool eventFilter(QObject* object, QEvent* event); 0113 bool updateTitleTab(); 0114 bool closeSub(MediaContainer* container); 0115 0116 private: 0117 void updateBackGround(); 0118 void updateActiveMediaContainer(QMdiSubWindow* window); 0119 void addWindowAction(const QString& name, MediaContainer* window); 0120 0121 private: 0122 QPointer<ContentController> m_ctrl; 0123 std::vector<std::unique_ptr<MediaContainer>> m_mediaContainers; 0124 QPixmap m_backgroundPicture; 0125 QPixmap m_variableSizeBackground; 0126 QPointer<QToolBar> m_toolbar; 0127 QHash<QMdiSubWindow*, QString> m_titleBar; 0128 QPointer<MediaContainer> m_activeMediaContainer; 0129 QPointer<QMdiSubWindow> m_instantMessageView; 0130 bool m_visible= false; 0131 std::unique_ptr<PreventClosing> m_prevent; 0132 }; 0133 0134 #endif