1 /***************************************************************************
2 * Copyright (C) 2008 by James Hogan *
3 * james@albanarts.com *
5 * This program 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. *
10 * This program 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, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
23 #include "kworshipview.h"
25 #include "KwDisplayManager.h"
27 #include "KwLocalDisplayPreview.h"
28 #include "KwPlaylistList.h"
29 #include "KwPlaylistNote.h"
30 #include "KwPlaylistText.h"
31 #include "KwPlaylistModel.h"
34 #include <QtGui/QDropEvent>
35 #include <QtGui/QPainter>
37 #include <kconfigdialog.h>
38 #include <kstatusbar.h>
41 #include <kactioncollection.h>
42 #include <kstandardaction.h>
44 #include <KDE/KLocale>
48 , m_view(new kworshipView(this))
59 // tell the KXmlGuiWindow that this is indeed the main widget
60 setCentralWidget(m_view
);
62 // then, setup our actions
68 // a call to KXmlGuiWindow::setupGUI() populates the GUI
69 // with actions, using KXMLGUI.
70 // It also applies the saved mainwindow settings, if any, and ask the
71 // mainwindow to automatically save settings if changed: window size,
72 // toolbar position, icon size, etc.
76 addDockWidget(Qt::LeftDockWidgetArea
, m_view
->dockPresentation
);
77 tabifyDockWidget(m_view
->dockPresentation
, m_view
->dockBible
);
78 tabifyDockWidget(m_view
->dockPresentation
, m_view
->dockSongs
);
79 addDockWidget(Qt::RightDockWidgetArea
, m_view
->dockPreview
);
80 addDockWidget(Qt::RightDockWidgetArea
, m_view
->dockLyrics
);
81 addDockWidget(Qt::BottomDockWidgetArea
, m_view
->dockThemes
);
83 // Setup some stuff in the tree
85 #define TREE_ITEM(name, string, parent) QTreeWidgetItem* name = new QTreeWidgetItem(parent); name->setText(0, tr(string));
87 TREE_ITEM(song1
, "Our God is a great big God", m_view
->treeWidget
);
88 TREE_ITEM(song1_style
, "(style)", song1
);
89 TREE_ITEM(song1_style_1
, "Mode", song1_style
);
90 TREE_ITEM(song1_v1
, "Our God is a great big God,\nOur God is a great big God,\nOur God is a great big God,\nAnd He holds us in his hands.", song1
);
91 TREE_ITEM(song1_v2
, "He's higher than a skyscraper\nAnd he's deeper than a submarine.", song1
);
92 TREE_ITEM(song1_v3
, "He's wider than the universe\nAnd beyond my wildest dreams.", song1
);
98 m_primaryPlaylist
= new KwPlaylistList();
99 m_primaryPlaylist
->addItem(new KwPlaylistNote("This is a note #1a#"));
100 m_primaryPlaylist
->addItem(new KwPlaylistNote("This is a note #2a#"));
101 m_primaryPlaylist
->addItem(new KwPlaylistNote("This is a note #3a#"));
103 KwPlaylistItem
* song
;
104 m_primaryPlaylist
->addItem(song
= new KwPlaylistText("Our God is a great big God", QStringList()
105 << "Our God is a great big God,\nOur God is a great big God,\nOur God is a great big God,\nAnd He holds us in his hands."
106 << "He's higher than a skyscraper\nAnd he's deeper than a submarine.\nHe's wider than the universe\nAnd beyond my wildest dreams."
107 << "And He's known me and He's loved me\nSince before the world began.\nHow wonderful\nto be a part\nof God's amazing plan"
110 KwPlaylistList
* list1
= new KwPlaylistList();
111 m_primaryPlaylist
->addItem(list1
);
112 list1
->addItem(new KwPlaylistNote("This is a note #1b"));
113 list1
->addItem(new KwPlaylistNote("This is a note #2b"));
114 list1
->addItem(new KwPlaylistNote("This is a note #3b"));
116 m_playlistModel
= new KwPlaylistModel
;
117 m_playlistModel
->setRootNode(m_primaryPlaylist
->getNode(0));
118 m_view
->treePlaylist
->setModel(m_playlistModel
);
119 m_view
->treePlaylist
->setExpandsOnDoubleClick(false);
121 m_displayManager
= new KwDisplayManager(&m_displayController
);
123 m_displayManager
->background
.setImage(QPixmap("/home/james/media/images/projector/misc/love-god-light.jpg"));
125 m_displayManager
->text
.setText("Ziperty-do-dah, Ziperty-ay!\nMy oh my what a wonderful day!");
127 m_previewDisplay
= new KwLocalDisplayPreview
;
128 m_view
->layoutPreview
->addWidget(m_previewDisplay
);
129 m_displayController
.attachChild(m_previewDisplay
);
132 connect(m_view
->treePlaylist
, SIGNAL(doubleClicked(QModelIndex
)), this, SLOT(playlist_doubleClicked(QModelIndex
)));
135 kworship::~kworship()
139 void kworship::setupActions()
141 KStandardAction::openNew(this, SLOT(fileNew()), actionCollection());
142 KStandardAction::quit(qApp
, SLOT(quit()), actionCollection());
144 KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
146 // custom menu and menu item - the slot is in the class kworshipView
147 //KAction *custom = new KAction(KIcon("colorize"), i18n("Swi&tch Colors"), this);
148 //actionCollection()->addAction( QLatin1String("switch_action"), custom );
149 //connect(custom, SIGNAL(triggered(bool)), m_view, SLOT(switchColors()));
152 void kworship::fileNew()
154 // this slot is called whenever the File->New menu is selected,
155 // the New shortcut is pressed (usually CTRL+N) or the New toolbar
158 // create a new window
159 //(new kworship)->show();
160 bool newlyCreated
= (0 == m_mainDisplay
);
163 m_mainDisplay
= new KwLocalDisplayPreview
;
164 m_mainDisplay
->setPrimary(true);
165 m_displayController
.attachChild(m_mainDisplay
);
167 m_mainDisplay
->showFullScreen();
168 // m_mainDisplay->show();
171 void kworship::optionsPreferences()
173 // The preference dialog is derived from prefs_base.ui
175 // compare the names of the widgets in the .ui file
176 // to the names of the variables in the .kcfg file
177 //avoid to have 2 dialogs shown
178 if ( KConfigDialog::showDialog( "settings" ) ) {
181 KConfigDialog
*dialog
= new KConfigDialog(this, "settings", Settings::self());
182 QWidget
*generalSettingsDlg
= new QWidget
;
183 ui_prefs_base
.setupUi(generalSettingsDlg
);
184 dialog
->addPage(generalSettingsDlg
, i18n("General"), "package_setting");
185 connect(dialog
, SIGNAL(settingsChanged(QString
)), m_view
, SLOT(settingsChanged()));
186 dialog
->setAttribute( Qt::WA_DeleteOnClose
);
190 void kworship::playlist_doubleClicked(QModelIndex index
)
192 KwPlaylistNode
* node
= m_playlistModel
->itemFromIndex(index
);
193 node
->activate(m_displayManager
);
196 #include "kworship.moc"