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

« back to all changes in this revision

Viewing changes to noatun/library/pref.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
#include "pref.h"
 
2
 
 
3
#include <klocale.h>
 
4
#include <kglobal.h>
 
5
#include <kiconloader.h>
 
6
#include <kdebug.h>
 
7
#include <qlayout.h>
 
8
//#include <qlabel.h>
 
9
#include "cmodule.h"
 
10
 
 
11
NoatunPreferences::NoatunPreferences(QWidget *parent)
 
12
    : KDialogBase(TreeList, i18n("Preferences - Noatun"),
 
13
                  Ok|Apply|Cancel|Help, Ok, parent, "NoatunPreferences", false, true)
 
14
{
 
15
        resize(640, 480); // KDE is required to support 800x600 min.
 
16
        setShowIconsInTreeList(true);
 
17
        setRootIsDecorated(false);
 
18
}
 
19
 
 
20
void NoatunPreferences::slotOk()
 
21
{
 
22
        slotApply();
 
23
        hide();
 
24
}
 
25
 
 
26
void NoatunPreferences::show()
 
27
{
 
28
        for (CModule *i=mModules.first(); i != 0; i=mModules.next())
 
29
                i->reopen();
 
30
        KDialogBase::show();
 
31
}
 
32
 
 
33
void NoatunPreferences::show(CModule *page)
 
34
{
 
35
        int index = pageIndex( static_cast<QWidget *>(page->parent()) );
 
36
        if (index != -1)
 
37
                showPage(index);
 
38
        show();
 
39
}
 
40
 
 
41
void NoatunPreferences::slotApply()
 
42
{
 
43
        for (CModule *i=mModules.first(); i != 0; i=mModules.next())
 
44
                i->save();
 
45
}
 
46
 
 
47
void NoatunPreferences::add(CModule *page)
 
48
{
 
49
        mModules.append(page);
 
50
}
 
51
 
 
52
void NoatunPreferences::remove(CModule *page)
 
53
{
 
54
        mModules.removeRef(page);
 
55
}
 
56
 
 
57
CModule::CModule(const QString &name, const QString &description, const QString &icon, QObject *owner)
 
58
        : QWidget(napp->preferencesBox()->addPage(name, description, KGlobal::iconLoader()->loadIcon(
 
59
                icon, KIcon::Small,0, KIcon::DefaultState,0, true)))
 
60
{
 
61
        if (owner)
 
62
                connect(owner, SIGNAL(destroyed()), SLOT(ownerDeleted()));
 
63
 
 
64
        //kdDebug(66666) << k_funcinfo << "name = " << name << endl;
 
65
 
 
66
        napp->preferencesBox()->add(this);
 
67
 
 
68
        QFrame *page=static_cast<QFrame*>(parent());
 
69
        (new QHBoxLayout(page))->addWidget(this);
 
70
}
 
71
 
 
72
CModule::~CModule()
 
73
{
 
74
        //kdDebug(66666) << k_funcinfo << endl;
 
75
#if QT_VERSION < 0x030102 && KDE_VERSION < KDE_MAKE_VERSION( 3, 1, 90 )
 
76
        // Due to a bug in Qt 3.1 and 3.1.1 no close events are sent to hidden
 
77
        // widgets, causing the KJanusWidget to crash. This workaround is
 
78
        // rather intrusive and should be used only in the affected versions
 
79
        // to avoid hard to track bugs in the future. KDE HEAD (to become 3.2)
 
80
        // has a workaround for this problem, and additionally it's fixed in
 
81
        // Qt 3.1.2.
 
82
        napp->sendPostedEvents();
 
83
#endif
 
84
 
 
85
        napp->preferencesBox()->remove(this);
 
86
}
 
87
 
 
88
void CModule::ownerDeleted()
 
89
{
 
90
        QObject *p=parent();
 
91
        delete this;
 
92
        p->deleteLater();
 
93
}
 
94
 
 
95
#include "pref.moc"