blob: 123560350a6911673c3ce993f8a3479a4f829ab9 (
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
|
#include "ui/metadatadialog.h"
#include "ui_metadatadialog.h"
#include "debugtools.h"
#include <QPushButton>
MetadataDialog::MetadataDialog(QWidget *parent) :
QDialog(parent),
_ui(new Ui::MetadataDialog)
{
_ui->setupUi(this);
QPushButton *button = _ui->buttonBox->button(QDialogButtonBox::Ok);
if (button != 0) {
button->setEnabled(false);
} else {
debug_err("failed to get ok button");
}
}
MetadataDialog::~MetadataDialog()
{
delete _ui;
}
/*** public methods ***/
bool MetadataDialog::isValid() const
{
return !title().trimmed().isEmpty()
&& !author().trimmed().isEmpty();
}
void MetadataDialog::setMetadata(const QString& title, const QString& author)
{
_ui->titleEdit->setText(title);
_ui->authorEdit->setText(author);
}
QString MetadataDialog::title() const
{
return _ui->titleEdit->text();
}
QString MetadataDialog::author() const
{
return _ui->authorEdit->text();
}
/*** private slots ***/
void MetadataDialog::on_titleEdit_textChanged()
{
QPushButton *button = _ui->buttonBox->button(QDialogButtonBox::Ok);
if (button == 0) {
debug_err("failed to get ok button");
return;
}
button->setEnabled(isValid());
}
void MetadataDialog::on_authorEdit_textChanged()
{
QPushButton *button = _ui->buttonBox->button(QDialogButtonBox::Ok);
if (button == 0) {
debug_err("failed to get ok button");
return;
}
button->setEnabled(isValid());
}
|