1
// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com>
2
// Copyright (C) 1999 Charles Samuels <charles@kde.org>
4
// Permission is hereby granted, free of charge, to any person obtaining a copy
5
// of this software and associated documentation files (the "Software"), to deal
6
// in the Software without restriction, including without limitation the rights
7
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
// copies of the Software, and to permit persons to whom the Software is
9
// furnished to do so, subject to the following conditions:
11
// The above copyright notice and this permission notice shall be included in
12
// all copies or substantial portions of the Software.
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18
// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
// Except as contained in this notice, the name(s) of the author(s) shall not be
22
// used in advertising or otherwise to promote the sale, use or other dealings
23
// in this Software without prior written authorization from the author(s).
25
#include <arts/kplayobjectfactory.h>
28
#include <kfiledialog.h>
30
#include <kiconloader.h>
33
#include <kpropertiesdialog.h>
34
#include <kstatusbar.h>
35
#include <kstdaction.h>
37
#include <qdragobject.h>
39
#include <qlcdnumber.h>
41
#include <kkeydialog.h>
42
#include <kvideowidget.h>
45
#include "kaboodleapp.h"
46
#include "kaboodle_factory.h"
49
#include "userinterface.h"
51
Kaboodle::UserInterface::UserInterface(QWidget *parent, const KURL &initialFile)
52
: KParts::MainWindow(parent)
55
setStandardToolBarMenuEnabled(true);
57
KStdAction::open(this, SLOT(fileOpen()), actionCollection());
58
KStdAction::quit(kapp, SLOT(quit()), actionCollection());
59
KStdAction::preferences(this, SLOT(playerPreferences()), actionCollection());
60
KStdAction::keyBindings( this, SLOT( slotConfigureKeys() ), actionCollection() );
62
menubarAction = KStdAction::showMenubar(this, SLOT(showMenubar()), actionCollection());
63
propertiesAction = new KAction(i18n("Properties"), 0, this, SLOT(properties()), actionCollection(), "properties");
64
propertiesAction->setEnabled(false);
66
part = new Player(this, "KaboodlePlayer", this, "KaboodleView");
67
part->view()->setButtons(KMediaPlayer::View::Seeker);
69
setCentralWidget(part->view());
71
delete toolBar("mainToolBar");
75
connect(part, SIGNAL(setWindowCaption(const QString &)), this, SLOT(updateTitle(const QString &)));
76
connect(part->view(), SIGNAL(adaptSize(int, int)), this, SLOT(adaptSize(int, int)));
78
setIcon(SmallIcon("kaboodle"));
80
resize(320, minimumHeight());
81
applyMainWindowSettings(KGlobal::config());
82
menubarAction->setChecked(!menuBar()->isHidden());
86
if(!initialFile.isEmpty())
88
part->openURL(initialFile);
89
propertiesAction->setEnabled(true);
95
void Kaboodle::UserInterface::slotConfigureKeys()
97
KKeyDialog dialog(this, 0);
98
dialog.insert(actionCollection(), KaboodleFactory::instance()->aboutData()->programName() );
99
dialog.insert(part->actionCollection(), i18n("Player") );
100
View *view = static_cast<View*>( part->view() );
101
dialog.insert(view->videoWidget()->actionCollection(), i18n("Video"));
102
(void) dialog.configure();
105
Kaboodle::UserInterface::~UserInterface(void)
107
saveMainWindowSettings(KGlobal::config());
110
void Kaboodle::UserInterface::fileOpen(void)
112
KURL file(KFileDialog::getOpenURL(QString::null, KDE::PlayObjectFactory::mimeTypes().join(" "), this, i18n("Select File to Play")));
116
propertiesAction->setEnabled(true);
120
void Kaboodle::UserInterface::dragEnterEvent(QDragEnterEvent *event)
122
// accept uri drops only
123
event->accept(KURLDrag::canDecode(event));
126
void Kaboodle::UserInterface::dropEvent(QDropEvent *event)
129
if (KURLDrag::decode(event, list))
132
part->openURL(list.first());
136
void Kaboodle::UserInterface::playerPreferences(void)
143
void Kaboodle::UserInterface::applySettings(void)
145
View *view = static_cast<View *>(part->view());
146
KConfig &config = *KGlobal::config();
147
config.setGroup("core");
148
view->setAutoPlay(config.readBoolEntry("autoPlay", true));
149
view->setQuitAfterPlaying(config.readBoolEntry("quitAfterPlaying", true));
152
void Kaboodle::UserInterface::showMenubar(void)
154
if(menubarAction->isChecked())
160
void Kaboodle::UserInterface::updateTitle(const QString &text)
163
statusBar()->message(text);
166
void Kaboodle::UserInterface::properties(void)
168
if(!part->currentURL().isEmpty())
169
(void)new KPropertiesDialog(part->currentURL());
172
void Kaboodle::UserInterface::adaptSize(int newViewWidth, int newViewHeight)
174
if(!newViewWidth) return;
175
View *view = static_cast<View *>(part->view());
176
int extraWidth = width() - view->width();
177
int extraHeight = height() - view->height();
178
resize(newViewWidth + extraWidth, newViewHeight + extraHeight);
181
#include "userinterface.moc"