Making installable
[baulk.git] / src / Baulk / baulk.cpp
blobe48b94eae07d145c0a32d3fa5bb95fd6704a06ca
1 // Baulk
2 //
3 // Baulk - Copyright (C) 2008 - Jacob Alexander
4 //
5 // Baulk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // any later version, including version 3 of the License.
9 //
10 // Baulk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "baulk.h"
20 // Constructor ************************************************************************************
21 Baulk::Baulk( QWidget *parent ) : QMainWindow( parent ) {
22 QString serverListenName = "BaulkServ"; // TODO Put in config
24 // Start Daemon - Automatically closes if Daemon is already running
25 QString program;
26 if ( QFile::exists("./baulkServ") )
27 program = QString("./baulkServ %1").arg( serverListenName );
28 else
29 program = QString("baulkServ %1").arg( serverListenName );
31 QProcess::startDetached( program );
32 QTest::qSleep(100); // Leave Time for the Daemon to start
34 // Setup Controller Instance
35 LibraryLoader *library = new LibraryLoader( "BaulkControl", this );
36 controller = library->loadBaulkWidget( "mainWidget", (BaulkWidget*)this );
37 controller->setServerListenName( serverListenName );
38 setCentralWidget( controller );
40 // Window Settings
41 setWindowTitle( tr("Baulk - %1").arg( serverListenName ) );
42 connect( controller, SIGNAL( windowTitleNameSet( QString ) ), this, SLOT( setWindowTitleName( QString ) ) );
45 // Window Close Event *****************************************************************************
46 void Baulk::closeEvent( QCloseEvent *event ) {
47 //event->ignore();
49 // TODO - Send Event to Controller for quit/save message
50 // Use controller infoClient inorder to determine whether or not to kill the server
52 qDebug("Closing");
53 event->accept();
56 // Log Update *************************************************************************************
57 bool Baulk::updateMsgLogs( QStringList msgLogs ) {
58 if ( controller != 0 ) {
59 controller->setMsgLogs( msgLogs );
60 return true;
63 return false;
66 // SLOTS ******************************************************************************************
67 void Baulk::setWindowTitleName( QString windowTitle ) {
68 setWindowTitle( windowTitle );