Bible HTML rendering to text browser on display
[kworship.git] / kworship / KwApplication.cpp
blob4b7c2d1908aecbc0e7da7f59b495234e8febf2f9
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * KWorship 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 * (at your option) any later version. *
9 * *
10 * KWorship 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. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 /**
21 * @file KwApplication.cpp
22 * @brief Application global data.
23 * @author James Hogan <james@albanarts.com>
26 #include "KwApplication.h"
27 #include "kworship.h"
28 #include "KwPluginManager.h"
29 #include "KwBiblePlugin.h"
31 #include <KCmdLineArgs>
34 * Static singleton data
37 /// Singleton application.
38 KwApplication* KwApplication::s_self = 0;
41 * Singletonhood
44 /// Get the singleton application object.
45 KwApplication* KwApplication::self()
47 return s_self;
51 * Constructors + destructor
54 /// Primary constructor.
55 KwApplication::KwApplication()
56 : m_app()
57 , m_mainWindow(0) // soon to be initialised
58 , m_pluginManager(new KwPluginManager())
60 // Application must be lone.
61 Q_ASSERT(0 == s_self);
62 s_self = this;
64 // Set up the main window
65 kworship *widget = new kworship;
66 m_mainWindow = widget;
68 // Set up the plugin manager
69 m_pluginManager->loadPlugin(new KwBiblePlugin());
71 // see if we are starting with session management
72 if (m_app.isSessionRestored())
74 RESTORE(kworship);
76 else
78 widget->show();
79 // no session.. just start up normally
80 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
81 if (args->count() > 0)
83 KUrl arg = args->arg(0);
84 KUrl url = KCmdLineArgs::cwd();
85 if (arg.isRelative())
87 url.addPath(arg.path());
89 else
91 url = arg;
93 widget->loadPlaylist(url);
95 args->clear();
99 /// Destructor.
100 KwApplication::~KwApplication()
102 Q_ASSERT(this == s_self);
103 s_self = 0;
105 delete m_pluginManager;
109 * Main interface
112 /// Execute the application.
113 int KwApplication::exec()
115 return m_app.exec();
119 * Accessors
122 /// Get the main window widget.
123 kworship* KwApplication::mainWindow()
125 return m_mainWindow;