-
Notifications
You must be signed in to change notification settings - Fork 0
/
streaminfodialog.cpp
66 lines (63 loc) · 1.68 KB
/
streaminfodialog.cpp
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
#include "streaminfodialog.h"
#include "ui_streaminfodialog.h"
#include "config.h"
#include <QSettings>
#include <QMessageBox>
StreamInfoDialog::StreamInfoDialog(QWidget* parent)
: QDialog(parent),
ui(new Ui::StreamInfoDialog)
{
ui->setupUi(this);
}
StreamInfoDialog::~StreamInfoDialog()
{
delete ui;
}
void StreamInfoDialog::setStreamInfo(const QString& name)
{
QSettings s;
s.beginGroup("stream");
s.beginGroup(name);
ui->edName->setText(name);
ui->edName->setReadOnly(true);
if (s.contains("genre")) {
ui->edGenre->setText(s.value("genre").toString());
}
if (s.contains("description")) {
ui->edDescription->setText(s.value("description").toString());
}
if (s.contains("url")) {
ui->edUrl->setText(s.value("url").toString());
}
if (s.contains("icq")) {
ui->edIcq->setText(s.value("icq").toString());
}
if (s.contains("irc")) {
ui->edIrc->setText(s.value("irc").toString());
}
s.endGroup();
s.endGroup();
}
void StreamInfoDialog::accept()
{
if (ui->edName->text().isEmpty() || ui->edName->text().isNull()) {
QMessageBox b;
b.setText("Name can't be empty");
b.exec();
return;
}
QSettings s;
s.beginGroup("stream");
s.beginGroup(ui->edName->text());
{
s.setValue("genre", ui->edGenre->text());
s.setValue("description", ui->edDescription->toPlainText());
s.setValue("url", ui->edUrl->text());
s.setValue("icq", ui->edIcq->text());
s.setValue("irc", ui->edIrc->text());
s.setValue("agent", QString(PROJECT_NAME));
}
s.endGroup();
s.endGroup();
this->done(QDialog::Accepted);
}