3 Copyright (c) 2012 Jakob Leben & Tim Blechmann
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef SCIDE_WIDGETS_MAIN_WINDOW_HPP_INCLUDED
22 #define SCIDE_WIDGETS_MAIN_WINDOW_HPP_INCLUDED
25 #include <QMainWindow>
27 #include <QSignalMapper>
35 class TextFindReplacePanel
;
41 class DocumentsDialog
;
44 class StatusClockLabel
;
46 namespace Settings
{ class Manager
; }
48 class MainWindow
: public QMainWindow
71 OpenSessionSwitchDialog
,
105 explicit MainWindow(Main
*);
107 QAction
*action( ActionRole
);
111 void saveWindowState();
112 void restoreWindowState();
114 static MainWindow
*instance() { return mInstance
; }
116 static bool close( Document
* );
117 static bool save( Document
*, bool forceChoose
= false );
118 static bool reload( Document
* );
122 void saveCurrentSessionAs();
123 void openSessionsDialog();
128 void saveDocumentAs();
129 void saveAllDocuments();
130 void reloadDocument();
131 void closeDocument();
132 void closeAllDocuments();
136 void showReplaceTool();
137 void showGoToLineTool();
143 void evaluateCode( const QString
&, bool silent
= true );
146 void showStatusMessage( QString
const & string
);
149 void switchSession( Session
*session
);
150 void saveSession( Session
*session
);
152 void openDocumentation();
153 void onInterpreterStateChanged( QProcess::ProcessState
);
154 void onServerStatusReply(int ugens
, int synths
, int groups
, int synthDefs
, float avgCPU
, float peakCPU
);
155 void onServerRunningChanged( bool running
, QString
const & hostName
, int port
);
157 void onCurrentDocumentChanged( Document
* );
158 void onDocumentChangedExternally( Document
* );
159 void onDocDialogFinished();
160 void updateRecentDocsMenu();
161 void onRecentDocAction( QAction
* );
162 void onOpenSessionAction( QAction
* );
163 void updateWindowTitle();
164 void toggleFullScreen();
165 void openDefinition();
166 void lookupDefinition();
167 void lookupDocumentation();
168 void findReferences();
169 void lookupReferences();
170 void toggleServerRunning();
171 void applySettings( Settings::Manager
* );
172 void showSwitchSessionDialog();
175 virtual void closeEvent(QCloseEvent
*event
);
176 virtual void dragEnterEvent( QDragEnterEvent
* );
177 virtual void dropEvent( QDropEvent
* );
180 void createActions();
182 bool promptSaveDocs();
183 void updateSessionsMenu();
184 void updateClockWidget( bool isFullScreen
);
185 void openSession( QString
const & sessionName
);
189 QAction
* mActions
[ActionCount
];
190 QMenu
* mRecentDocsMenu
;
191 QMenu
* mSessionsMenu
;
193 MultiEditor
*mEditors
;
198 GoToLineTool
*mGoToLineTool
;
199 TextFindReplacePanel
*mFindReplaceTool
;
202 QStatusBar
*mStatusBar
;
203 StatusLabel
*mLangStatus
;
204 StatusLabel
*mServerStatus
;
205 StatusClockLabel
*mClockLabel
;
208 PostDock
* mPostDock
;
209 DocumentsDock
*mDocListDock
;
211 QSignalMapper mCodeEvalMapper
;
212 DocumentsDialog
* mDocDialog
;
214 static MainWindow
*mInstance
;
217 class StatusLabel
: public QLabel
220 StatusLabel(QWidget
*parent
= 0);
221 void setBackground(const QBrush
&);
222 void setTextColor(const QColor
&);
225 class StatusClockLabel
: public StatusLabel
228 StatusClockLabel (QWidget
* parent
= 0);
232 void timerEvent(QTimerEvent
*);