refacto ring button
the button triggering the file selection now stays in a
correct shape when canceling the selection
Change-Id: I4384f3f815ec6ded857cf1e2d2b8901ae1f7f27d
Reviewed-by: Anthony Léonard <anthony.leonard@savoirfairelinux.com>
diff --git a/ringbutton.cpp b/ringbutton.cpp
index 7d7b56c..6de7a40 100644
--- a/ringbutton.cpp
+++ b/ringbutton.cpp
@@ -36,11 +36,20 @@
void
RingButton::setText(const QString& text)
{
- ui->button->setText(text);
- ui->button->resize(ui->button->sizeHint().width(),
- ui->button->sizeHint().height());
+ if (! text.isEmpty() && ! text.isNull()) {
+ ui->button->setText(text);
+ ui->button->resize(ui->button->sizeHint().width(),
+ ui->button->sizeHint().height());
+ path_ = text;
+ }
}
+QString RingButton::text()
+{
+ return path_;
+}
+
+
void
RingButton::mousePressEvent(QMouseEvent* event)
{
diff --git a/ringbutton.h b/ringbutton.h
index 547a6c8..cada219 100644
--- a/ringbutton.h
+++ b/ringbutton.h
@@ -31,12 +31,12 @@
explicit RingButton(QWidget* parent = 0);
~RingButton();
void setText(const QString& text);
-
-protected:
- void mousePressEvent(QMouseEvent* event);
+ QString text();
private:
Ui::RingButton* ui;
+ QString path_ {};
+ void mousePressEvent(QMouseEvent* event);
signals:
void clicked() const;