summaryrefslogtreecommitdiffstats
path: root/noatun/library/cmodule.cpp
blob: a624fb644d3dc297de644df0f0e3a4d34d0b197a (plain)
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
126
127
128
129
130
131
#include <cmodule.h>
#include <noatun/pluginloader.h>
#include <common.h>
#include <noatun/app.h>

#include <qpushbutton.h>
#include <qbuttongroup.h>
#include <qradiobutton.h>
#include <qcheckbox.h>
#include <qlayout.h>
#include <klocale.h>
#include <kdebug.h>
#include <klistview.h>
#include <qsplitter.h>
#include <qlabel.h>
#include <qdragobject.h>
#include <kurlrequester.h>
#include <kfiledialog.h>
#include <kdialog.h>
#include <klineedit.h>

#include <qtextview.h>
#include <qwhatsthis.h>

#include "mimetypetree.h"

/*****************************************************************
 * General options
 *****************************************************************/

General::General(QObject *parent)
	: CModule(i18n("General"), i18n("General Options"), "configure", parent)
{
	mLoopList=new QCheckBox(i18n("&Return to start of playlist on finish"), this);
	mLoopList->setChecked(napp->loopList());
	QWhatsThis::add(mLoopList, i18n("When the playlist is finished playing, return to the start, but do not start playing."));

	mOneInstance=new QCheckBox(i18n("Allow only one &instance of Noatun"), this);
	mOneInstance->setChecked(napp->oneInstance());
	QWhatsThis::add(mOneInstance, i18n("Starting noatun a second time will cause it to just append items from the start to the current instance."));

	mClearOnOpen = new QCheckBox(i18n("Clear playlist &when opening a file"), this);
	mClearOnOpen->setChecked(napp->clearOnOpen());
	QWhatsThis::add(mClearOnOpen, i18n("Opening a file with the global Open menu item will clear the playlist first."));

	mFastVolume=new QCheckBox(i18n("&Use fast hardware volume control"), this);
	mFastVolume->setChecked(napp->fastMixer());
	QWhatsThis::add(mFastVolume, i18n("Use the hardware mixer instead of aRts'. It affects all streams, not just Noatun's, but is a little faster."));

	mRemaining=new QCheckBox(i18n("Display &remaining play time"), this);
	mRemaining->setChecked(napp->displayRemaining());
	QWhatsThis::add(mRemaining, i18n("Counters count down towards zero, showing remaining time instead of elapsed time."));

	QLabel *titleLabel=new QLabel(i18n("Title &format:"), this);
	mTitleFormat=new KLineEdit(this);
	titleLabel->setBuddy(mTitleFormat);
	mTitleFormat->setText(napp->titleFormat());
	QWhatsThis::add(mTitleFormat, i18n(
			"Select a title to use for each file (in the playlist and user interface). "
			"Each element such as $(title) is replaced with the property with the name "
			"as given in the parentheses. The properties include, but are not limited to: "
			"title, author, date, comments and album."));

	QLabel *dlsaver=new QLabel(i18n("&Download folder:"), this);
	mDlSaver=new KURLRequester(napp->saveDirectory(), this);
	dlsaver->setBuddy(mDlSaver);
	connect( mDlSaver, SIGNAL( openFileDialog( KURLRequester * )),
		 this, SLOT( slotRequesterClicked( KURLRequester * )));
	QWhatsThis::add(mDlSaver, i18n("When opening a non-local file, download it to the selected folder."));

	mPlayOnStartup = new QButtonGroup(1, Horizontal, i18n("Play Behavior on Startup"), this);
	mPlayOnStartup->setExclusive(true);
	mPlayOnStartup->insert(
			new QRadioButton(i18n("Restore &play state"), mPlayOnStartup),
			NoatunApp::Restore
		);
	mPlayOnStartup->insert(
			new QRadioButton(i18n("Automatically play &first file"), mPlayOnStartup),
			NoatunApp::Play
		);
	mPlayOnStartup->insert(
			new QRadioButton(i18n("&Do not start playing"), mPlayOnStartup),
			NoatunApp::DontPlay
		);

	if (QButton* b = mPlayOnStartup->find(napp->startupPlayMode()))
	{
		b->toggle();
	}

	QGridLayout *layout = new QGridLayout(this, 0, KDialog::spacingHint());
	layout->setSpacing(KDialog::spacingHint());

	layout->addMultiCellWidget(mLoopList, 0, 0, 0, 1);
	layout->addMultiCellWidget(mOneInstance, 2, 2, 0, 1);
	layout->addMultiCellWidget(mClearOnOpen, 4, 4, 0, 1);
	layout->addMultiCellWidget(mFastVolume, 5, 5, 0, 1);
	layout->addMultiCellWidget(mRemaining, 6, 6, 0, 1);

	layout->addWidget(titleLabel, 7, 0);
	layout->addWidget(mTitleFormat, 7, 1);

	layout->addWidget(dlsaver, 8, 0);
	layout->addWidget(mDlSaver, 8, 1);

	layout->addMultiCellWidget(mPlayOnStartup, 9, 9, 0, 1);

	layout->setRowStretch(10, 1);
}


void General::save()
{
	napp->setLoopList(mLoopList->isChecked());
	napp->setOneInstance(mOneInstance->isChecked());
	napp->setClearOnOpen(mClearOnOpen->isChecked());
	napp->setSaveDirectory(mDlSaver->url());
	napp->setFastMixer(mFastVolume->isChecked());
	napp->setTitleFormat(mTitleFormat->text());
	napp->setDisplayRemaining(mRemaining->isChecked());
	napp->setStartupPlayMode(mPlayOnStartup->selectedId());
}


void General::slotRequesterClicked( KURLRequester * )
{
	mDlSaver->fileDialog()->setMode(
		(KFile::Mode)(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly));
}

#include "cmodule.moc"