mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-21 22:12:05 +08:00
ui: clickable ElidedLabel (#21773)
* ElidedButton * rename to ClickableLabel * move to ElidedLabel
This commit is contained in:
@@ -249,12 +249,12 @@ void WifiUI::refresh() {
|
||||
hlayout->setSpacing(50);
|
||||
|
||||
// Clickable SSID label
|
||||
QPushButton *ssidLabel = new QPushButton(network.ssid);
|
||||
ElidedLabel *ssidLabel = new ElidedLabel(network.ssid);
|
||||
ssidLabel->setObjectName("ssidLabel");
|
||||
ssidLabel->setEnabled(network.security_type != SecurityType::UNSUPPORTED);
|
||||
ssidLabel->setProperty("disconnected", network.connected == ConnectedType::DISCONNECTED);
|
||||
if (network.connected == ConnectedType::DISCONNECTED) {
|
||||
QObject::connect(ssidLabel, &QPushButton::clicked, this, [=]() { emit connectToNetwork(network); });
|
||||
QObject::connect(ssidLabel, &ElidedLabel::clicked, this, [=]() { emit connectToNetwork(network); });
|
||||
}
|
||||
hlayout->addWidget(ssidLabel, network.connected == ConnectedType::CONNECTING ? 0 : 1);
|
||||
|
||||
|
||||
@@ -13,16 +13,21 @@ QFrame *horizontal_line(QWidget *parent = nullptr);
|
||||
class ElidedLabel : public QLabel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit ElidedLabel(QWidget *parent = 0);
|
||||
explicit ElidedLabel(const QString &text, QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override { emit clicked(); }
|
||||
QString lastText_, elidedText_;
|
||||
};
|
||||
|
||||
|
||||
class AbstractControl : public QFrame {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user