EditTagDialog: Make reset feedback work by calling
`set_reset_button()` in `UpdateModifiedField()` and catering for non-text in `IsValueModified()` (-1 original being same as 0); use new `ExtendedEditor::set_font()`; connect reset for "rating". Make "comment" `tabChangesFocus` to keep tab chain. ExtendedEditor: New `set_font()` to get emboldened font to work and make reset feedback work for `CheckBox` and `RatingBox` by overriding `Resize()`. RatingWidget: Allow tabbed focus and implement keyboard input.
This commit is contained in:
@@ -113,6 +113,7 @@ RatingWidget::RatingWidget(QWidget *parent) : QWidget(parent), rating_(0.0), hov
|
||||
|
||||
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
setMouseTracking(true);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
}
|
||||
|
||||
@@ -173,3 +174,31 @@ void RatingWidget::leaveEvent(QEvent *e) {
|
||||
update();
|
||||
|
||||
}
|
||||
|
||||
void RatingWidget::keyPressEvent(QKeyEvent *e) {
|
||||
|
||||
constexpr float arrow_incr = 0.5f / RatingPainter::kStarCount;
|
||||
|
||||
float rating = -1.0f;
|
||||
|
||||
if (e->key() >= Qt::Key_0 && e->key() <= Qt::Key_9) {
|
||||
rating = qBound(0.0f, static_cast<float>(e->key() - Qt::Key_0) / RatingPainter::kStarCount, 1.0f);
|
||||
}
|
||||
else if (e->key() == Qt::Key_Left) {
|
||||
rating = qBound(0.0f, rating_ - arrow_incr, 1.0f);
|
||||
}
|
||||
else if (e->key() == Qt::Key_Right) {
|
||||
rating = qBound(0.0f, rating_ + arrow_incr, 1.0f);
|
||||
}
|
||||
|
||||
if (rating != -1.0f) {
|
||||
if (rating != rating_) {
|
||||
rating_ = rating;
|
||||
Q_EMIT RatingChanged(rating_);
|
||||
}
|
||||
}
|
||||
else {
|
||||
QWidget::keyPressEvent(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user