~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to kaboodle/userinterface.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com>
 
2
// Copyright (C) 1999 Charles Samuels <charles@kde.org>
 
3
//
 
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:
 
10
//
 
11
// The above copyright notice and this permission notice shall be included in
 
12
// all copies or substantial portions of the Software.
 
13
//
 
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.
 
20
//
 
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).
 
24
 
 
25
#include <arts/kplayobjectfactory.h>
 
26
#include <kconfig.h>
 
27
#include <kdialog.h>
 
28
#include <kfiledialog.h>
 
29
#include <kglobal.h>
 
30
#include <kiconloader.h>
 
31
#include <klocale.h>
 
32
#include <kmenubar.h>
 
33
#include <kpropertiesdialog.h>
 
34
#include <kstatusbar.h>
 
35
#include <kstdaction.h>
 
36
#include <kurldrag.h>
 
37
#include <qdragobject.h>
 
38
#include <qlayout.h>
 
39
#include <qlcdnumber.h>
 
40
#include <qvbox.h>
 
41
#include <kkeydialog.h>
 
42
#include <kvideowidget.h>
 
43
 
 
44
#include "conf.h"
 
45
#include "kaboodleapp.h"
 
46
#include "kaboodle_factory.h"
 
47
#include "player.h"
 
48
#include "view.h"
 
49
#include "userinterface.h"
 
50
 
 
51
Kaboodle::UserInterface::UserInterface(QWidget *parent, const KURL &initialFile)
 
52
        : KParts::MainWindow(parent)
 
53
{
 
54
        setAcceptDrops(true);
 
55
        setStandardToolBarMenuEnabled(true);
 
56
 
 
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() );
 
61
 
 
62
        menubarAction = KStdAction::showMenubar(this, SLOT(showMenubar()), actionCollection());
 
63
        propertiesAction = new KAction(i18n("Properties"), 0, this, SLOT(properties()), actionCollection(), "properties");
 
64
        propertiesAction->setEnabled(false);
 
65
 
 
66
        part = new Player(this, "KaboodlePlayer", this, "KaboodleView");
 
67
        part->view()->setButtons(KMediaPlayer::View::Seeker);
 
68
 
 
69
        setCentralWidget(part->view());
 
70
        createGUI(part);
 
71
        delete toolBar("mainToolBar");
 
72
 
 
73
        statusBar()->show();
 
74
 
 
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)));
 
77
 
 
78
        setIcon(SmallIcon("kaboodle"));
 
79
 
 
80
        resize(320, minimumHeight());
 
81
        applyMainWindowSettings(KGlobal::config());
 
82
        menubarAction->setChecked(!menuBar()->isHidden());
 
83
 
 
84
        applySettings();
 
85
 
 
86
        if(!initialFile.isEmpty())
 
87
        {
 
88
                part->openURL(initialFile);
 
89
                propertiesAction->setEnabled(true);
 
90
        }
 
91
 
 
92
        show();
 
93
}
 
94
 
 
95
void Kaboodle::UserInterface::slotConfigureKeys()
 
96
{
 
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();
 
103
}
 
104
 
 
105
Kaboodle::UserInterface::~UserInterface(void)
 
106
{
 
107
        saveMainWindowSettings(KGlobal::config());
 
108
}
 
109
 
 
110
void Kaboodle::UserInterface::fileOpen(void)
 
111
{
 
112
        KURL file(KFileDialog::getOpenURL(QString::null, KDE::PlayObjectFactory::mimeTypes().join(" "), this, i18n("Select File to Play")));
 
113
        if(file.isValid())
 
114
        {
 
115
                part->openURL(file);
 
116
                propertiesAction->setEnabled(true);
 
117
        }
 
118
}
 
119
 
 
120
void Kaboodle::UserInterface::dragEnterEvent(QDragEnterEvent *event)
 
121
{
 
122
    // accept uri drops only
 
123
    event->accept(KURLDrag::canDecode(event));
 
124
}
 
125
 
 
126
void Kaboodle::UserInterface::dropEvent(QDropEvent *event)
 
127
{
 
128
        KURL::List list;
 
129
        if (KURLDrag::decode(event, list))
 
130
        {
 
131
                if (!list.isEmpty())
 
132
                        part->openURL(list.first());
 
133
        }
 
134
}
 
135
 
 
136
void Kaboodle::UserInterface::playerPreferences(void)
 
137
{
 
138
        Conf dlg(this);
 
139
        dlg.exec();
 
140
        applySettings();
 
141
}
 
142
 
 
143
void Kaboodle::UserInterface::applySettings(void)
 
144
{
 
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));
 
150
}
 
151
 
 
152
void Kaboodle::UserInterface::showMenubar(void)
 
153
{
 
154
        if(menubarAction->isChecked())
 
155
                menuBar()->show();
 
156
        else
 
157
                menuBar()->hide();
 
158
}
 
159
 
 
160
void Kaboodle::UserInterface::updateTitle(const QString &text)
 
161
{
 
162
        setCaption(text);
 
163
        statusBar()->message(text);
 
164
}
 
165
 
 
166
void Kaboodle::UserInterface::properties(void)
 
167
{
 
168
        if(!part->currentURL().isEmpty())
 
169
                (void)new KPropertiesDialog(part->currentURL());
 
170
}
 
171
 
 
172
void Kaboodle::UserInterface::adaptSize(int newViewWidth, int newViewHeight)
 
173
{
 
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);
 
179
}
 
180
 
 
181
#include "userinterface.moc"
 
182