move LayoutWidget,ClickableWidget to controls (#23207)

old-commit-hash: d4b8cba0f6
commatwo_master
Dean Lee 4 years ago committed by GitHub
parent 87ca19c8fd
commit b462e5584f
  1. 15
      selfdrive/ui/qt/util.cc
  2. 26
      selfdrive/ui/qt/util.h
  3. 14
      selfdrive/ui/qt/widgets/controls.cc
  4. 24
      selfdrive/ui/qt/widgets/controls.h

@ -98,21 +98,6 @@ void initApp() {
}
}
ClickableWidget::ClickableWidget(QWidget *parent) : QWidget(parent) { }
void ClickableWidget::mouseReleaseEvent(QMouseEvent *event) {
emit clicked();
}
// Fix stylesheets
void ClickableWidget::paintEvent(QPaintEvent *) {
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
static std::map<QtMsgType, int> levels = {
{QtMsgType::QtDebugMsg, CLOUDLOG_DEBUG},

@ -4,7 +4,6 @@
#include <QDateTime>
#include <QLayout>
#include <QMouseEvent>
#include <QPainter>
#include <QSurfaceFormat>
#include <QWidget>
@ -21,28 +20,3 @@ QString timeAgo(const QDateTime &date);
void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
void initApp();
QWidget* topWidget (QWidget* widget);
// convenience class for wrapping layouts
class LayoutWidget : public QWidget {
Q_OBJECT
public:
LayoutWidget(QLayout *l, QWidget *parent = nullptr) : QWidget(parent) {
setLayout(l);
};
};
class ClickableWidget : public QWidget {
Q_OBJECT
public:
ClickableWidget(QWidget *parent = nullptr);
protected:
void mouseReleaseEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *) override;
signals:
void clicked();
};

@ -121,3 +121,17 @@ void ElidedLabel::paintEvent(QPaintEvent *event) {
opt.initFrom(this);
style()->drawItemText(&painter, contentsRect(), alignment(), opt.palette, isEnabled(), elidedText_, foregroundRole());
}
ClickableWidget::ClickableWidget(QWidget *parent) : QWidget(parent) { }
void ClickableWidget::mouseReleaseEvent(QMouseEvent *event) {
emit clicked();
}
// Fix stylesheets
void ClickableWidget::paintEvent(QPaintEvent *) {
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

@ -161,3 +161,27 @@ private:
QVBoxLayout outer_layout;
QVBoxLayout inner_layout;
};
// convenience class for wrapping layouts
class LayoutWidget : public QWidget {
Q_OBJECT
public:
LayoutWidget(QLayout *l, QWidget *parent = nullptr) : QWidget(parent) {
setLayout(l);
};
};
class ClickableWidget : public QWidget {
Q_OBJECT
public:
ClickableWidget(QWidget *parent = nullptr);
protected:
void mouseReleaseEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *) override;
signals:
void clicked();
};

Loading…
Cancel
Save