2
#include <pluginloader.h>
6
#include <qpushbutton.h>
8
#include <qpushbutton.h>
12
#include <klistview.h>
13
#include <qsplitter.h>
15
#include <qdragobject.h>
16
#include <kurlrequester.h>
17
#include <kfiledialog.h>
20
#include <qtextview.h>
21
#include <qwhatsthis.h>
23
#include "mimetypetree.h"
25
template<class T1, class T2> struct Dual
27
Dual(const T1 &l, const T2 &r) : left(l), right(r) {}
29
Dual(const Dual<T1, T2> &d) : left(d.left), right(d.right) {}
33
typedef Dual<QString, QString> StringDual;
35
static QString infoPane(const QString &title, const QValueList<StringDual> &prop)
37
static const int cols=1;
41
str+="<font size=\"+2\"><b>";
43
str+="</b></font>\n\n<table cols=";
44
str+=QString::number(2);
45
str+=" width=\"100%\"><tr>";
47
// set up the properties table
49
QValueList<StringDual>::ConstIterator i;
56
for (int perRow=prop.count()/cols; i!=prop.end() && perRow!=0; perRow--)
74
class MimeListItem : public QCheckListItem
77
MimeListItem(KListView *list, const QString &mime, const QString &extension,
78
const QString &author, const QString &url, const QString &name);
81
QString mime() const { return mMime; }
82
QString extension() const { return mExtension; }
83
QString author() const { return mAuthor; }
84
QString url() const { return mUrl; }
85
QString name() const { return mName; }
88
QString mMime, mExtension, mAuthor, mUrl, mName;
92
MimeListItem::MimeListItem(KListView *list, const QString &mime, const QString &extension,
93
const QString &author, const QString &url,
95
: QCheckListItem(list, name, QCheckListItem::CheckBox)
97
setText(1, extension);
100
mExtension=extension;
105
Types::Types(QObject *parent) : CModule(i18n("File Types"), i18n("Configure Mime Types"), parent), first(true)
113
QGridLayout *layout=new QGridLayout(this);
115
mimes=new MimeTypeTree(this);
116
mimes->setFixedWidth(120);
117
layout->addMultiCellWidget(mimes, 0, 1, 0, 0);
119
list=new KListView(this);
120
layout->addWidget(list, 0, 1);
122
connect(list, SIGNAL(currentChanged(QListViewItem*)), SLOT(selectionChanged(QListViewItem*)));
125
list->addColumn(i18n("Name"));
126
list->addColumn(i18n("Extension"));
127
list->setSorting(-1);
132
list->setItemsMovable(true);
133
list->setDragEnabled(true);
134
list->setAcceptDrops(true);
135
// if (!q.supports("Interface","Arts::PlayObject"))
138
text=new QTextView(this);
139
layout->addWidget(text, 1, 1);
141
text->setFixedHeight(150);
148
std::vector<Arts::TraderOffer> *results = q.query();
149
for (std::vector<Arts::TraderOffer>::iterator i=results->begin(); i != results->end(); i++)
151
QString name=commaVector(&*i, "Interface", true);
152
QString author=commaVector(&*i, "Author");
153
QString url=commaVector(&*i, "URL");
154
QString extension=commaVector(&*i, "Extension");
155
QString mime=commaVector(&*i, "MimeType");
156
if (author.isNull() || url.isNull() || extension.isNull() || mime.isNull())
159
new MimeListItem(list, mime, extension, author, url, name);
163
selectionChanged(list->firstChild());
166
void Types::selectionChanged(QListViewItem *item)
168
MimeListItem *type=static_cast<MimeListItem*>(item);
169
QValueList<StringDual> bleh;
171
bleh.append(StringDual(i18n("Author"), type->author()));
172
bleh.append(StringDual(i18n("Web Site"), type->url()));
173
bleh.append(StringDual(i18n("Extension"), type->extension()));
174
bleh.append(StringDual(i18n("Mimetype"), type->mime()));
176
text->setText(infoPane(type->name(),bleh));
179
QString Types::commaVector(Arts::TraderOffer *t, const char *field, bool limit)
181
std::vector<std::string> *prop=t->getProperty(field);
185
for (std::vector<std::string>::iterator i=prop->begin(); i != prop->end(); i++)
187
if (!(*i).length()) continue;
209
/*****************************************************************
211
*****************************************************************/
213
General::General(QObject *parent) : CModule(i18n("Options"), i18n("General Options"), parent)
215
mLoopList=new QCheckBox(i18n("&Return to Start of Playlist on Finish"), this);
216
mLoopList->setChecked(napp->loopList());
217
QWhatsThis::add(mLoopList, i18n("When the playlist is done playing, return to the start, but don't start playing."));
219
mAutoPlay=new QCheckBox(i18n("&Automatically Play First File"), this);
220
mAutoPlay->setChecked(napp->autoPlay());
221
QWhatsThis::add(mAutoPlay, i18n("Start playing the playlist as soon as Noatun is started."));
223
mOneInstance=new QCheckBox(i18n("&Allow Only One Instance of Noatun"), this);
224
mOneInstance->setChecked(napp->oneInstance());
225
QWhatsThis::add(mOneInstance, i18n("Starting noatun a second time will cause it to just append items from the start to the current instance."));
227
mClearOnOpen = new QCheckBox(i18n("Clear playlist when opening a file"), this);
228
mClearOnOpen->setChecked(napp->clearOnOpen());
229
QWhatsThis::add(mClearOnOpen, i18n("Opening a file with the global Open menu item will clear the playlist first."));
231
mHackUpPlaylist = new QCheckBox(i18n("Process Playlist Items for Display"), this);
232
mHackUpPlaylist->setChecked(napp->hackUpPlaylist());
234
QWhatsThis::add(mHackUpPlaylist, i18n("Process filenames (e.g. removing spaces and the filename extension) and set them as the playlist item titles."));
236
mFastVolume=new QCheckBox(i18n("Use Fast Hardware Volume Control"), this);
237
mFastVolume->setChecked(napp->fastMixer());
238
QWhatsThis::add(mFastVolume, i18n("Use the hardware mixer instead of aRts's. It affects all streams, not just Noatun's, but is a little faster."));
240
QFrame *dlSaverFrame = new QFrame(this);
241
QLabel *dlsaver=new QLabel(i18n("&Download Directory"), dlSaverFrame);
242
mDlSaver=new KURLRequester(napp->saveDirectory(), dlSaverFrame);
243
dlsaver->setBuddy(mDlSaver);
244
connect( mDlSaver, SIGNAL( openFileDialog( KURLRequester * )),
245
this, SLOT( slotRequesterClicked( KURLRequester * )));
246
QWhatsThis::add(mDlSaver, i18n("When opening a non-local file, download it to the selected directory."));
248
QVBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
249
layout->addWidget(mLoopList);
250
layout->addWidget(mAutoPlay);
251
layout->addWidget(mOneInstance);
252
layout->addWidget(mClearOnOpen);
253
layout->addWidget(mHackUpPlaylist);
254
layout->addWidget(mFastVolume);
255
layout->addWidget(dlSaverFrame);
256
layout->addStretch();
258
QHBoxLayout *layoutSaver = new QHBoxLayout(dlSaverFrame, KDialog::marginHint(), KDialog::spacingHint());
259
layoutSaver->addWidget(dlsaver);
260
layoutSaver->addWidget(mDlSaver);
265
napp->setLoopList(mLoopList->isChecked());
266
napp->setAutoPlay(mAutoPlay->isChecked());
267
napp->setOneInstance(mOneInstance->isChecked());
268
napp->setClearOnOpen(mClearOnOpen->isChecked());
269
napp->setSaveDirectory(mDlSaver->url());
270
napp->setHackUpPlaylist(mHackUpPlaylist->isChecked());
271
napp->setFastMixer(mFastVolume->isChecked());
274
void General::slotRequesterClicked( KURLRequester * )
276
mDlSaver->fileDialog()->setMode(
277
(KFile::Mode)(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly));
280
#include "cmodule.moc"