1 // 2 // FLApp.h 3 // 4 // Created by Sarah Denoux on 12/04/13. 5 // Copyright (c) 2013 __MyCompanyName__. All rights reserved. 6 // 7 8 // FLApp is the centerpiece of FaustLive. 9 // Its role is to be a communication center between the menus, dialogs, windows, etc. 10 // It handles the main event loop 11 12 #ifndef _FLApp_h 13 #define _FLApp_h 14 15 #include <map> 16 17 #include <QApplication> 18 #include <QtGui> 19 #include <QMenu> 20 #include <QMenuBar> 21 #include <QProgressBar> 22 23 #ifdef REMOTE 24 class remote_dsp_server; 25 #endif 26 27 #define numberWindows 60 28 #define kMAXRECENT 4 29 #define kMaxSHAFolders 100 30 31 class FLServerHttp; 32 class FLErrorWindow; 33 class FLHelpWindow; 34 class FLPresentationWindow; 35 class FLPreferenceWindow; 36 class FLWindow; 37 class FLWinSettings; 38 class AudioCreator; 39 40 using namespace std; 41 42 class FLApp : public QApplication 43 { 44 45 private: 46 47 Q_OBJECT 48 49 //-------Menu Bar and it's sub-Menus------------------------ 50 51 QMenuBar* fMenuBar; 52 53 QMenu* create_FileMenu(); 54 QMenu* create_ExampleMenu(); 55 QMenu* create_RecentFileMenu(); 56 57 QMenu* create_LoadSessionMenu(bool recallOrImport); //@param recallOrImport : true = Recall ||| false = Import 58 QMenu* create_NavigateMenu(); 59 QMenu* create_HelpMenu(); 60 61 QAction** fRecentFileAction; 62 QAction** fRrecentSessionAction; 63 QAction** fIrecentSessionAction; 64 65 QMenu* fNavigateMenu; 66 QMap<FLWindow*, QMenu*> fNavigateMenus; 67 QMap<QAction*, FLWindow*> fFrontWindow; 68 void updateNavigateMenus(); 69 70 void setup_Menu(); 71 72 //--------Artificial progress bar to print a goodbye message 73 QProgressBar* fPBar; 74 75 //--------Server that embbedes all HttpInterfaces in a droppable environnement 76 FLServerHttp* fServerHttp; 77 78 //--------List of windows currently running in the application 79 QList<FLWindow*> FLW_List; 80 81 //--------Screen parameters 82 int fScreenWidth; 83 int fScreenHeight; 84 85 //--------Handling window indexes 86 //To index the windows, the smallest index not used is given to the window 87 int find_smallest_index(QList<int> currentIndexes); 88 QList<int> get_currentIndexes(); 89 //With this index is calculate the place of the window on the screen 90 void calculate_position(int index, int* x, int* y); 91 92 //-----------------Application Parameters-------------------------- 93 94 QString fWindowBaseName; //Name of Application 95 96 //--------------- Current Session Management ------------------ 97 void create_Session_Hierarchy(); 98 99 QString fSessionFolder; //Path to currentSession Folder 100 QString fExamplesFolder; //Folder containing Examples copied from QResources 101 QString fHtmlFolder; //Folder containing the HTML pages copied from QResources 102 QString fDocFolder; //Folder containing the documentation copied from QResources 103 QString fLibsFolder; //Folder containing Libs copied from QResources 104 105 //Save/Recall the recent Files/Sessions in settings 106 void save_Recent(QList<QString>& recents, const QString& pathToSettings); 107 108 void recall_Recent(QList<QString>& recents, const QString& pathToSettings); 109 110 //Recent Files Parameters and functions 111 QList<QString> fRecentFiles; 112 void recall_Recent_Files(); 113 void save_Recent_Files(); 114 void set_Current_File(const QString& pathName); 115 void update_Recent_File(); 116 117 //Recent Sessions Parameters and functions 118 QList<QString> fRecentSessions; 119 void save_Recent_Sessions(); 120 void recall_Recent_Sessions(); 121 void set_Current_Session(const QString& pathName); 122 void update_Recent_Session(); 123 124 //---------------------- FLWindow creation ---------------------- 125 QString createWindowFolder(const QString& sessionFolder, int index); 126 QString copyWindowFolder(const QString& sessionNewFolder, int newIndex, const QString& sessionFolder, int index, map<int, int> indexChanges); 127 128 //When the application is launched without parameter, this timer will start a initialized window 129 QTimer* fInitTimer; 130 QTimer* fEndTimer; 131 132 //Preference Menu Objects and Functions 133 AudioCreator* fAudioCreator; 134 135 void update_AudioArchitecture(); 136 137 //Save and Recall Session actions 138 bool fRecalling; //True when recalling for the app not to close whith last window 139 140 //In case of drops on Application Icon, this event is called 141 virtual bool event(QEvent *ev); 142 143 //Functions of rehabilitation if sources disapears 144 bool recall_CurrentSession(); 145 void restoreSession(map<int, QString>); 146 147 //-----------------Questions about the current State 148 149 FLWindow* getActiveWin(); 150 151 //------- Remembering the last folder in which a file was openened 152 QString fLastOpened; 153 154 #ifdef REMOTE 155 // This server is a remote compilation service included in FaustLive 156 remote_dsp_server* fDSPServer; 157 #endif 158 159 private slots: 160 161 #ifdef REMOTE 162 void changeRemoteServerPort(); 163 #endif 164 165 //--------Http Server Response 166 FLWindow* httpPortToWin(int port); 167 void changeDropPort(); 168 void launch_Server(); 169 void compile_HttpData(const char* data, int port); 170 void stop_Server(); 171 172 //---------Drop on a window 173 174 void drop_Action(QList<QString>); 175 176 //---------Presentation Window Slots 177 178 void open_Example_Action(QString pathInQResource); 179 void openExampleAction(const QString& exampleName); 180 181 //---------File 182 void connectWindowSignals(FLWindow* win); 183 void create_Empty_Window(); 184 FLWindow* createWindow(int index, const QString& mySource, FLWinSettings* windowSettings, QString& error); 185 void open_New_Window(); 186 void open_Example_From_FileMenu(); 187 void open_Recent_File(); 188 void open_Recent_File(const QString& toto); 189 void open_Remote_Window(); // Not really implemented (checkout FLRemoteDSPScanner) 190 void common_shutAction(FLWindow* win); 191 void display_Progress(); 192 void close_Window_Action(); 193 194 void deleteComponent(); 195 //--Session 196 void take_Snapshot(); 197 void recall_Snapshot(const QString& filename, bool importOption); 198 void recallSnapshotFromMenu(); 199 void importSnapshotFromMenu(); 200 void recall_Recent_Session(); 201 void import_Recent_Session(); 202 203 //--------Navigate 204 void updateNavigateText(); 205 void frontShow(); 206 207 //--------Window 208 209 void duplicate(FLWindow* window); 210 void duplicate_Window(); 211 212 //---------Preferences 213 void styleClicked(const QString& style); 214 void Preferences(); 215 void audioPrefChanged(); 216 217 //---------Help 218 void open_FL_doc(); 219 void open_F_doc(); 220 void version_Action(); 221 void show_presentation_Action(); 222 223 //--------Timers 224 void init_Timer_Action(); 225 void update_ProgressBar(); 226 void updateGuis(); 227 228 //--------Long operations entertainment 229 void display_CompilingProgress(const QString& msg); 230 void StopProgressSlot(); 231 232 public : 233 234 FLApp(int& argc, char** argv); 235 virtual ~FLApp(); 236 237 public slots: 238 239 void create_New_Window(const QString& name); 240 241 virtual void closeAllWindows(); 242 void shut_AllWindows_FromMenu(); 243 void shut_AllWindows_FromWindow(); 244 245 void update_CurrentSession(); 246 void create_Component_Window(); 247 248 //--------Error received 249 void errorPrinting(const QString& msg); 250 251 }; 252 253 #endif 254