~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/systray/cmodule.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// cmodule.cpp
 
2
//
 
3
// Copyright (C) 2001 Neil Stevens <multivac@fcmail.com>
 
4
//
 
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
6
// of this software and associated documentation files (the "Software"), to deal
 
7
// in the Software without restriction, including without limitation the rights
 
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
9
// copies of the Software, and to permit persons to whom the Software is
 
10
// furnished to do so, subject to the following conditions:
 
11
// 
 
12
// The above copyright notice and this permission notice shall be included in
 
13
// all copies or substantial portions of the Software.
 
14
// 
 
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
18
// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
19
// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
20
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
21
// 
 
22
// Except as contained in this notice, the name(s) of the author(s) shall not be
 
23
// used in advertising or otherwise to promote the sale, use or other dealings
 
24
// in this Software without prior written authorization from the author(s).
 
25
 
 
26
#include <kconfig.h>
 
27
#include <kdialog.h>
 
28
#include <kglobal.h>
 
29
#include <klocale.h>
 
30
#include <qbuttongroup.h>
 
31
#include <qcheckbox.h>
 
32
#include <qlayout.h>
 
33
#include <qradiobutton.h>
 
34
 
 
35
#include <noatunapp.h>
 
36
#include <pluginloader.h>
 
37
 
 
38
#include "cmodule.h"
 
39
#include "systray.h"
 
40
 
 
41
YHModule::YHModule(QObject *_parent)
 
42
        : CModule(i18n("Young Hickory"), i18n("Configure The System Tray Icon"), _parent)
 
43
{
 
44
        QVBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
 
45
 
 
46
        tip = new QCheckBox(i18n("Show a tooltip for the current track"), this);
 
47
 
 
48
        icon = new QButtonGroup(1, Horizontal, this);
 
49
        icon->setExclusive(true);
 
50
        new QRadioButton(i18n("Blink the icon for the current state"), icon);
 
51
        new QRadioButton(i18n("Show the icon for the current state"), icon);
 
52
        new QRadioButton(i18n("Do neither"), icon);
 
53
 
 
54
        layout->addWidget(tip);
 
55
        layout->addWidget(icon);
 
56
        layout->addStretch();
 
57
 
 
58
        reopen();
 
59
        save();
 
60
}
 
61
 
 
62
void YHModule::save(void)
 
63
{
 
64
        KConfig &config = *(KGlobal::config());
 
65
        config.setGroup("Young Hickory");
 
66
        int iconPressed = icon->id(icon->selected());
 
67
        config.writeEntry("icon", iconPressed);
 
68
        config.writeEntry("tip", tip->isChecked());
 
69
        config.sync();
 
70
 
 
71
        NoatunSystray *yh = NoatunSystray::jasonkb;
 
72
        if(yh)
 
73
        {
 
74
                yh->setBlink((NoatunSystray::Blink)iconPressed);
 
75
                yh->setTip(tip->isChecked());
 
76
        }
 
77
}
 
78
 
 
79
void YHModule::reopen(void)
 
80
{
 
81
        KConfig &config = *(KGlobal::config());
 
82
        config.setGroup("Young Hickory");
 
83
        static_cast<QRadioButton *>(icon->find(config.readLongNumEntry("icon", 0)))->setChecked(true);
 
84
        tip->setChecked(config.readBoolEntry("tip", true));
 
85
}
 
86
 
 
87
#include "cmodule.moc"