Add compilation to edit tag dialog

This commit is contained in:
Jonas Kvinge
2020-09-23 00:52:41 +02:00
parent 3166ca2127
commit 9e3508134b
4 changed files with 239 additions and 52 deletions

View File

@@ -71,19 +71,21 @@ ExtendedEditor::ExtendedEditor(QWidget *widget, int extra_right_padding, bool dr
reset_button_->setFocusPolicy(Qt::NoFocus);
reset_button_->hide();
widget->connect(clear_button_, SIGNAL(clicked()), widget, SLOT(clear()));
widget->connect(clear_button_, SIGNAL(clicked()), widget, SLOT(setFocus()));
if (qobject_cast<QLineEdit*>(widget) || qobject_cast<QPlainTextEdit*>(widget) || qobject_cast<QSpinBox*>(widget)) {
widget->connect(clear_button_, SIGNAL(clicked()), widget, SLOT(clear()));
}
UpdateButtonGeometry();
}
void ExtendedEditor::set_hint(const QString& hint) {
void ExtendedEditor::set_hint(const QString &hint) {
hint_ = hint;
widget_->update();
}
void ExtendedEditor::set_clear_button(bool visible) {
void ExtendedEditor::set_clear_button(const bool visible) {
has_clear_button_ = visible;
clear_button_->setVisible(visible);
UpdateButtonGeometry();
@@ -93,7 +95,7 @@ bool ExtendedEditor::has_reset_button() const {
return reset_button_->isVisible();
}
void ExtendedEditor::set_reset_button(bool visible) {
void ExtendedEditor::set_reset_button(const bool visible) {
reset_button_->setVisible(visible);
UpdateButtonGeometry();
}
@@ -161,7 +163,7 @@ LineEdit::LineEdit(QWidget *parent) : QLineEdit(parent), ExtendedEditor(this) {
connect(this, SIGNAL(textChanged(QString)), SLOT(text_changed(QString)));
}
void LineEdit::text_changed(const QString& text) {
void LineEdit::text_changed(const QString &text) {
if (text.isEmpty()) {
// Consider empty string as LTR
@@ -222,8 +224,26 @@ void SpinBox::resizeEvent(QResizeEvent *e) {
Resize();
}
CheckBox::CheckBox(QWidget *parent)
: QCheckBox(parent), ExtendedEditor(this, 14, false)
{
connect(reset_button_, SIGNAL(clicked()), SIGNAL(Reset()));
}
void CheckBox::paintEvent(QPaintEvent *e) {
QCheckBox::paintEvent(e);
Paint(this);
}
void CheckBox::resizeEvent(QResizeEvent *e) {
QCheckBox::resizeEvent(e);
Resize();
}
QString SpinBox::textFromValue(int val) const {
if (val <= 0 && !hint_.isEmpty())
return "-";
return QSpinBox::textFromValue(val);
}