~ubuntu-branches/ubuntu/feisty/kdetv/feisty

« back to all changes in this revision

Viewing changes to kdetv/clients/kpart/kdetvpart.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-09-17 23:25:16 UTC
  • Revision ID: james.westby@ubuntu.com-20050917232516-9wdsn3ckagbqieh8
Tags: upstream-0.8.8
ImportĀ upstreamĀ versionĀ 0.8.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2002 Richard Moore <rich@kde.org>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify 
 
5
 *   it under the terms of the GNU General Public License as published by 
 
6
 *   the Free Software Foundation; either version 2 of the License, or
 
7
 *   (at your option) any later version.
 
8
 *
 
9
 */
 
10
 
 
11
#include <qtimer.h>
 
12
 
 
13
#include <kaboutapplication.h>
 
14
#include <kaboutdata.h>
 
15
#include <kaction.h>
 
16
#include <kapplication.h>
 
17
#include <kcmenumngr.h>
 
18
#include <kdebug.h>
 
19
#include <kglobal.h>
 
20
#include <klocale.h>
 
21
#include <kpopupmenu.h>
 
22
#include <kstandarddirs.h>
 
23
#include <kxmlguifactory.h>
 
24
 
 
25
#include <kparts/genericfactory.h>
 
26
 
 
27
#include "actions.h"
 
28
#include "kdetvwidget.h"
 
29
#include "libkdetvactions.h"
 
30
#include "kdetv.h"
 
31
#include "viewmanager.h"
 
32
 
 
33
#include "kdetvpart.h"
 
34
 
 
35
typedef KParts::GenericFactory<KdetvPart> KdetvPartFactory;
 
36
K_EXPORT_COMPONENT_FACTORY( libkdetvpart, KdetvPartFactory );
 
37
 
 
38
KdetvPart::KdetvPart( QWidget *wparent, const char *wname,
 
39
                      QObject *parent, const char *name,
 
40
                      const QStringList &/*args*/ )
 
41
    : KParts::ReadOnlyPart( parent ? parent : wparent, name ? name : "kdetv_part" ),
 
42
      autoStart(true)
 
43
{
 
44
    kdDebug() << "Creating KdetvPart" << endl;
 
45
 
 
46
    setInstance( KdetvPartFactory::instance() );
 
47
 
 
48
    // Create TV Widget
 
49
    tv = new KdetvWidget( wparent, wname ? wname : 0 );
 
50
    setWidget( tv );
 
51
 
 
52
    kdDebug() << "KdetvPart: Created TV widget" << endl;
 
53
 
 
54
    // Kdetv actions
 
55
    actions = new LibKdetvActions( tv->driver() );
 
56
    actions->createActions( actionCollection() );
 
57
 
 
58
    // Setup Action Collection
 
59
    actionCollection()->setHighlightingEnabled( true );
 
60
 
 
61
    // Define UI
 
62
    setXMLFile( "kdetvpartui.rc" );
 
63
 
 
64
    QTimer::singleShot( 0, this, SLOT(maybeStart()) );
 
65
    kdDebug() << "KdetvPart: Created" << endl;
 
66
}
 
67
 
 
68
KdetvPart::~KdetvPart()
 
69
{
 
70
}
 
71
 
 
72
void KdetvPart::start()
 
73
{
 
74
    tv->driver()->start();
 
75
    addContextMenu( tv->view() );
 
76
}
 
77
 
 
78
void KdetvPart::maybeStart()
 
79
{
 
80
    if ( autoStart )
 
81
        start();
 
82
}
 
83
 
 
84
KAboutData *KdetvPart::createAboutData()
 
85
{
 
86
    // the non-i18n name here must be the same as the directory in
 
87
    // which the part's rc file is installed ('partrcdir' in the
 
88
    // Makefile)
 
89
    KAboutData *about = new KAboutData( "kdetv", I18N_NOOP("kdetv"),
 
90
                                        "Development post 0.8.0",
 
91
                                        I18N_NOOP("TV for KDE"),
 
92
                                        KAboutData::License_LGPL,
 
93
                                        I18N_NOOP("(c) 2002-2004 The kdetv Developers"),
 
94
                                        0, "http://www.kdetv.org/");
 
95
    about->addAuthor("George Staikos", I18N_NOOP("Primary author and maintainer"), "staikos@kde.org");
 
96
    about->addAuthor("Richard Moore", I18N_NOOP("GUI design, channel plugins"), "rich@kde.org");
 
97
    about->addAuthor("Kevin Hessels", I18N_NOOP("Configuration dialog"), "khessels@shaw.ca");
 
98
    about->addAuthor("Stefan Hellwig", I18N_NOOP("Webmaster, developer"), "stefan@stefanhellwig.de");
 
99
    about->addAuthor("Rizsanyi Zsolt", I18N_NOOP("Infrared remote support, developer"), "rizsanyi@myrealbox.com");
 
100
    about->addAuthor("Dawit Alemayehu", I18N_NOOP("Developer"), "adawit@kde.org");
 
101
 
 
102
    return about;
 
103
}
 
104
 
 
105
void KdetvPart::addContextMenu( bool xmlgui )
 
106
{
 
107
   tv->addContextMenu( createContextMenu( xmlgui ) );
 
108
}
 
109
 
 
110
KPopupMenu *KdetvPart::createContextMenu( bool xmlgui ) 
 
111
{
 
112
    KPopupMenu *pop = 0;
 
113
    if ( xmlgui ) {
 
114
        pop = createContextMenu( createContextMenu(QString("screen_context_popup")) );
 
115
        if ( pop )
 
116
            return pop;
 
117
    }
 
118
 
 
119
    // Fall back to manual menu creation
 
120
    pop = new KPopupMenu;
 
121
 
 
122
    actions->channel()->plug( pop );
 
123
    actions->channelUp()->plug( pop );
 
124
    actions->channelDown()->plug( pop );
 
125
    actions->volumeSlider()->plug( pop );
 
126
    actions->volumeMute()->plug( pop );
 
127
    pop->insertSeparator();
 
128
 
 
129
    return pop;
 
130
}
 
131
 
 
132
KPopupMenu *KdetvPart::createContextMenu( const QString &name ) 
 
133
{
 
134
    kdDebug() << "KdetvPart: createContextMenu(...)" << endl;
 
135
 
 
136
    KXMLGUIFactory *fact = factory();
 
137
    if ( !fact )
 
138
        return 0;
 
139
 
 
140
    QWidget *w = fact->container( name.isNull() ? QString("screen_context_popup") : name, this );
 
141
    if ( !w )
 
142
        return 0;
 
143
 
 
144
    KPopupMenu *pop = static_cast<KPopupMenu *>( w );
 
145
    pop->insertTitle( i18n("kdetv"), -1, 0 );
 
146
    return pop;
 
147
}
 
148
 
 
149
bool KdetvPart::openFile()
 
150
{
 
151
    kdDebug() << "KdetvPart::openFile() '" << filename() << "'" << endl;
 
152
 
 
153
    kdDebug() << "KdetvPart::openFile(): Extend Kdetv interface to cover loading" << endl;
 
154
 
 
155
    return false;
 
156
}
 
157
 
 
158
void KdetvPart::about()
 
159
{
 
160
    KAboutApplication dlg( createAboutData() );
 
161
    dlg.exec();
 
162
}
 
163
 
 
164
void KdetvPart::help()
 
165
{
 
166
    KApplication::kApplication()->invokeHelp( QString::null, QString("kdetv") );
 
167
}
 
168
 
 
169
 
 
170
void KdetvPart::preferences()
 
171
{
 
172
    Kdetv *ktv = tv->driver();
 
173
    if ( ktv )
 
174
        ktv->views()->launchSettings(0L);
 
175
}
 
176
 
 
177
void KdetvPart::reportBug()
 
178
{
 
179
    KApplication::kApplication()->invokeMailer( QString("kwintv@mail.kde.org"), QString::null );
 
180
}