diff options
Diffstat (limited to 'src/ui/metadatadialog.cpp')
-rw-r--r-- | src/ui/metadatadialog.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/ui/metadatadialog.cpp b/src/ui/metadatadialog.cpp index 348f225..1235603 100644 --- a/src/ui/metadatadialog.cpp +++ b/src/ui/metadatadialog.cpp @@ -1,11 +1,22 @@ #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() @@ -13,6 +24,14 @@ 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); @@ -29,3 +48,29 @@ 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()); +} |