1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
//
//
// C++ Implementation: cpp
//
// Description:
//
//
// Author: Eray Ozkural (exa) <erayo@cs.bilkent.edu.tr>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include <kconfig.h>
#include <kdialog.h>
#include <kglobal.h>
#include <klocale.h>
#include <kurlrequester.h>
#include <kdebug.h>
#include <tqbuttongroup.h>
#include <tqcheckbox.h>
#include <tqlayout.h>
#include <tqradiobutton.h>
#include "dubconfigmodule.h"
DubConfigModule::DubConfigModule(TQObject* parent)
: CModule(i18n("Dub"), i18n("Folder-Based Playlist"), "noatun", parent)
, playMode(oneDir)
, playOrder(normal)
{
TQVBoxLayout *vbox = new TQVBoxLayout(this);
vbox->setAutoAdd(true);
vbox->setSpacing( 0 );
vbox->setMargin( 0 );
prefs = new DubPrefs(this);
prefs->mediaDirectory->setMode(KFile::Directory);
reopen();
}
DubConfigModule::~DubConfigModule()
{
}
void DubConfigModule::save(void)
{
KConfig* config(KGlobal::config());
config->setGroup("DubPlaylist");
mediaDirectory = prefs->mediaDirectory->url();
TQButton* selectedMode = prefs->playMode->selected();
if (selectedMode==prefs->allFiles)
playMode = DubConfigModule::allFiles;
else
if (selectedMode==prefs->recursiveDir)
playMode = DubConfigModule::recursiveDir;
else
playMode = DubConfigModule::oneDir;
TQButton* selectedOrder = prefs->playOrder->selected();
if (selectedOrder==prefs->shuffle)
playOrder = DubConfigModule::shuffle;
else
if (selectedOrder==prefs->repeat)
playOrder = DubConfigModule::repeat;
else
if (selectedOrder==prefs->single)
playOrder = DubConfigModule::single;
else
playOrder = DubConfigModule::normal;
config->writePathEntry("MediaDirectory", mediaDirectory);
config->writeEntry("PlayMode", (int) playMode);
config->writeEntry("PlayOrder", (int) playOrder);
}
void DubConfigModule::reopen(void)
{
kdDebug(90010) << "dubconfig: reopen" << endl;
KConfig* config(KGlobal::config());
config->setGroup("DubPlaylist");
mediaDirectory = config->readPathEntry("MediaDirectory", "~/");
kdDebug(90010) << "dub: media home is " << mediaDirectory << endl;
playMode = (PlayMode) config->readNumEntry("PlayMode", DubConfigModule::oneDir);
playOrder = (PlayOrder) config->readNumEntry("PlayOrder", DubConfigModule::normal);
apply();
}
void DubConfigModule::apply()
{
prefs->mediaDirectory->setURL(mediaDirectory);
// what a horrible repetition, but it's not worthwhile doing any better ;)
switch (playMode) {
case allFiles:
prefs->playMode->setButton(prefs->playMode->id(prefs->allFiles));
break;
case oneDir:
prefs->playMode->setButton(prefs->playMode->id(prefs->oneDir));
break;
case recursiveDir:
prefs->playMode->setButton(prefs->playMode->id(prefs->recursiveDir));
break;
}
switch (playOrder) {
case normal:
prefs->playOrder->setButton(prefs->playOrder->id(prefs->normal));
break;
case shuffle:
prefs->playOrder->setButton(prefs->playOrder->id(prefs->shuffle));
break;
case repeat:
prefs->playOrder->setButton(prefs->playOrder->id(prefs->repeat));
break;
case single:
prefs->playOrder->setButton(prefs->playOrder->id(prefs->single));
break;
}
}
#include "dubconfigmodule.moc"
|