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_MAIN_HPP_INCLUDED
22 #define SCIDE_MAIN_HPP_INCLUDED
27 #include <QtNetwork/QLocalSocket>
28 #include <QtNetwork/QLocalServer>
30 #include "sc_process.hpp"
31 #include "sc_server.hpp"
32 #include "doc_manager.hpp"
33 #include "settings/manager.hpp"
39 // scide instances have a LocalServer. when called with an argument, it will try to reconnect
40 // to the instance with the lowest number.
41 class SingleInstanceGuard
:
47 bool tryConnect(QStringList
const & arguments
);
50 void onNewIpcConnection()
52 mIpcSocket
= mIpcServer
->nextPendingConnection();
53 connect(mIpcSocket
, SIGNAL(disconnected()), mIpcSocket
, SLOT(deleteLater()));
54 connect(mIpcSocket
, SIGNAL(readyRead()), this, SLOT(onIpcData()));
60 QLocalServer
* mIpcServer
;
61 QLocalSocket
* mIpcSocket
;
70 static Main
* instance(void)
72 static Main
* singleton
= new Main
;
76 static SCProcess
* scProcess() { return instance()->mSCProcess
; }
77 static ScServer
* scServer() { return instance()->mSCServer
; }
78 static ScResponder
* scResponder() { return instance()->mSCResponder
; }
79 static SessionManager
* sessionManager() { return instance()->mSessionManager
; }
80 static DocumentManager
* documentManager() { return instance()->mDocManager
; }
81 static Settings::Manager
*settings() { return instance()->mSettings
; }
83 static void evaluateCode(QString
const & text
, bool silent
= false)
85 instance()->scProcess()->evaluateCode(text
, silent
);
88 static bool openDocumentation(const QString
& string
)
90 // LATER: move to a new ScLanguage class
92 QString symbol
= string
.trimmed();
96 QString code
= QString("HelpBrowser.openHelpFor(\"%1\")").arg(symbol
);
97 evaluateCode(code
, true);
101 static bool openDocumentationForMethod(const QString
& className
, const QString
& methodName
)
103 QString code
= QString("HelpBrowser.openHelpForMethod( %1.findMethod(\\%2) )").arg(className
, methodName
);
104 evaluateCode(code
, true);
108 static void openDefinition(const QString
&string
, QWidget
* parent
);
109 static void findReferences(const QString
&string
, QWidget
* parent
);
112 void storeSettings() {
113 Q_EMIT(storeSettingsRequest(mSettings
));
117 void applySettings() {
118 Q_EMIT(applySettingsRequest(mSettings
));
124 void storeSettingsRequest(Settings::Manager
*);
125 void applySettingsRequest(Settings::Manager
*);
129 bool eventFilter(QObject
*obj
, QEvent
*event
);
131 Settings::Manager
*mSettings
;
132 ScResponder
* mSCResponder
;
133 SCProcess
* mSCProcess
;
134 ScServer
* mSCServer
;
135 DocumentManager
*mDocManager
;
136 SessionManager
*mSessionManager
;