File indexing completed on 2024-05-12 17:11:44

0001 /*************************************************************************
0002  *     Copyright (C) 2007 by Romain Campioni                             *
0003  *     Copyright (C) 2009 by Renaud Guezennec                            *
0004  *     Copyright (C) 2010 by Berenger Morel                              *
0005  *     Copyright (C) 2011 by Joseph Boudou                               *
0006  *                                                                       *
0007  *     https://rolisteam.org/                                         *
0008  *                                                                       *
0009  *   Rolisteam is free software; you can redistribute it and/or modify   *
0010  *   it under the terms of the GNU General Public License as published   *
0011  *   by the Free Software Foundation; either version 2 of the License,   *
0012  *   or (at your option) any later version.                              *
0013  *                                                                       *
0014  *   This program is distributed in the hope that it will be useful,     *
0015  *   but WITHOUT ANY WARRANTY; without even the implied warranty of      *
0016  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
0017  *   GNU General Public License for more details.                        *
0018  *                                                                       *
0019  *   You should have received a copy of the GNU General Public License   *
0020  *   along with this program; if not, write to the                       *
0021  *   Free Software Foundation, Inc.,                                     *
0022  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           *
0023  *************************************************************************/
0024 
0025 #ifndef MAIN_WINDOW_H
0026 #define MAIN_WINDOW_H
0027 
0028 #include "rwidgets/mediacontainers/mediacontainer.h"
0029 #include <QAction>
0030 #include <QMainWindow>
0031 #include <QMdiSubWindow>
0032 #include <QMenu>
0033 #include <QStackedWidget>
0034 #include <QTextEdit>
0035 #include <QUndoStack>
0036 #include <memory>
0037 
0038 #include "network/networkreceiver.h"
0039 #include "core/include/preferences/preferencesmanager.h"
0040 
0041 #include "rwidgets/customs/vmap.h"
0042 #include "rwidgets/docks/vmaptoolbar.h"
0043 #include "rwidgets/mediacontainers/vmapframe.h"
0044 #include "rwidgets/toolbars/vtoolbar.h"
0045 
0046 #include "rwidgets/dialogs/selectconnectionprofiledialog.h"
0047 
0048 #ifndef NULL_PLAYER
0049 #include "rwidgets/docks/audioPlayer.h"
0050 #endif
0051 
0052 #include "rwidgets/docks/channellistpanel.h"
0053 
0054 #include "controller/gamecontroller.h"
0055 #include "rwidgets/docks/playerspanel.h"
0056 
0057 namespace Ui
0058 {
0059 class MainWindow;
0060 }
0061 
0062 struct FileInfo
0063 {
0064     QString path;
0065     Core::ContentType type;
0066 };
0067 
0068 namespace campaign
0069 {
0070 class CampaignDock;
0071 class AntagonistBoard;
0072 } // namespace campaign
0073 
0074 // class ChatListWidget;
0075 class Image;
0076 class NetworkLink;
0077 class PreferencesDialog;
0078 class Player;
0079 class PlayersListWidget;
0080 class Workspace;
0081 class TextEdit;
0082 class SessionDock;
0083 class CharacterSheetWindow;
0084 class GameMasterTool;
0085 class LogPanel;
0086 class NotificationZone;
0087 
0088 struct CommandLineProfile
0089 {
0090     QString m_ip;
0091     int m_port;
0092     QByteArray m_pass;
0093 };
0094 /**
0095  * @brief Main widget for rolisteam, it herits from QMainWindow.
0096  */
0097 class MainWindow : public QMainWindow
0098 {
0099     Q_OBJECT
0100 public:
0101     /**
0102      * @brief MainWindow
0103      */
0104     MainWindow(GameController* game, const QStringList& args);
0105     /**
0106      * @brief ~MainWindow
0107      */
0108     virtual ~MainWindow();
0109     /**
0110      * @brief
0111      */
0112     void updateWorkspace();
0113     /**
0114      * @brief setupUi
0115      */
0116     void setupUi();
0117     /**
0118      * @brief readSettings
0119      */
0120     void readSettings();
0121     /**
0122      * @brief writeSettings
0123      */
0124     void writeSettings();
0125     /**
0126      * @brief setUpNetworkConnection
0127      */
0128     void setUpNetworkConnection();
0129     /**
0130      * @brief parseCommandLineArguments
0131      */
0132     void parseCommandLineArguments(const QStringList&);
0133     void openRecentScenario();
0134     void updateRecentScenarioAction();
0135     void openGenericContent();
0136     void openImage();
0137 public slots:
0138     /**
0139      * @brief
0140      * @param
0141      */
0142     bool mayBeSaved(bool connectionLost= false);
0143     /**
0144      * @brief updateUi
0145      */
0146     void updateUi();
0147     /**
0148      * @brief updateWindowTitle
0149      */
0150     void updateWindowTitle();
0151     /**
0152      * @brief closeAllImagesAndMap - remove all maps and Pictures
0153      */
0154     void closeAllMediaContainer();
0155     /**
0156      * @brief postConnection
0157      */
0158     void postConnection();
0159     /**
0160      * @brief openImageAs
0161      * @param pix
0162      * @param type
0163      */
0164     void openImageAs(const QPixmap& pix, Core::ContentType type);
0165     void makeVisible(bool value);
0166 
0167 protected:
0168     /**
0169      * @brief closeEvent
0170      * @param event
0171      */
0172     void closeEvent(QCloseEvent* event);
0173     virtual void focusInEvent(QFocusEvent* event);
0174     virtual void focusOutEvent(QFocusEvent* event);
0175     /**
0176      * @brief dropEvent
0177      * @param event
0178      */
0179     void dropEvent(QDropEvent* event);
0180     /**
0181      * @brief dragEnterEvent
0182      * @param ev
0183      */
0184     void dragEnterEvent(QDragEnterEvent* ev);
0185     void processSharedNoteMessage(NetworkMessageReader* msg);
0186     void showTipChecker();
0187     virtual void mouseMoveEvent(QMouseEvent* event);
0188     void createPostSettings();
0189 
0190 private slots:
0191     void cleanUpData();
0192     void showSupportPage();
0193     void userNatureChange();
0194     void openCampaign();
0195     /**
0196      * @brief showUpdateNotification
0197      */
0198     void showUpdateNotification();
0199     /**
0200      * @brief stopReconnection
0201      */
0202     void stopReconnection();
0203     void updateFileHistoryMenu();
0204     void openFileFromHistory();
0205     /**
0206      * @brief helpOnLine
0207      */
0208     void helpOnLine();
0209     /**
0210      * @brief saveStory - saves all media contener into the current story file.
0211      */
0212     bool saveStory(bool saveAs);
0213     /**
0214      * @brief notifyAboutAddedPlayer
0215      * @param player
0216      */
0217     void notifyAboutAddedPlayer(Player* player) const;
0218     /**
0219      * @brief notifyAboutDeletedPlayer
0220      * @param player
0221      */
0222     void notifyAboutDeletedPlayer(Player* player) const;
0223     void showShortCutEditor();
0224     void newVMap();
0225 
0226 private:
0227     /**
0228      * @brief createNotificationZone
0229      */
0230     void createNotificationZone();
0231     /**
0232      * @brief linkActionToMenu
0233      */
0234     void linkActionToMenu();
0235     /**
0236      * @brief findCharacterSheetWindowById
0237      * @param id
0238      * @return
0239      */
0240     CharacterSheetWindow* findCharacterSheetWindowById(const QString& idMedia, const QString& idSheet);
0241 
0242 private:
0243     QPointer<GameController> m_gameController;
0244 #ifndef NULL_PLAYER
0245     std::unique_ptr<AudioPlayer> m_audioPlayer;
0246 #endif
0247     std::unique_ptr<NotificationZone> m_dockLogUtil;
0248     std::unique_ptr<CommandLineProfile> m_commandLineProfile;
0249     std::unique_ptr<campaign::CampaignDock> m_campaignDock;
0250     std::unique_ptr<campaign::AntagonistBoard> m_antagonistWidget;
0251     std::unique_ptr<QSystemTrayIcon> m_systemTray;
0252     std::unique_ptr<Workspace> m_mdiArea;
0253 
0254     // subwindow
0255     Ui::MainWindow* m_ui;
0256     QPointer<PreferencesDialog> m_preferencesDialog;
0257     PreferencesManager* m_preferences;
0258 
0259     // Recent files managment
0260     int m_maxSizeRecentFile;
0261     QList<QAction*> m_recentFileActs;
0262     std::vector<QAction*> m_recentScenarioActions;
0263     QStringList m_recentScenarios;
0264     QAction* m_separatorAction;
0265     std::vector<FileInfo> m_recentFiles;
0266     QList<GameMasterTool*> m_gmToolBoxList;
0267     QDockWidget* m_roomPanelDockWidget;
0268     ChannelListPanel* m_roomPanel;
0269 
0270     bool m_isOut= false;
0271 };
0272 
0273 #endif