Add radioitembutton feature
This commit is contained in:
parent
4c9aecfa24
commit
f919fd6d00
|
@ -156,16 +156,16 @@ void WlanListItem::refreshIcon()
|
|||
switch (m_data->m_signalStrength / STEP + 1) {
|
||||
case FULL_SIGNAL:
|
||||
case EXCELLENT_SIGNAL:
|
||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic", QIcon(":/res/w/wifi-full.png")));
|
||||
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic", QIcon(":/res/w/wifi-full.png")));
|
||||
break;
|
||||
case GOOD_SIGNAL:
|
||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-good-symbolic", QIcon(":/res/w/wifi-high.png")));
|
||||
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-good-symbolic", QIcon(":/res/w/wifi-high.png")));
|
||||
break;
|
||||
case OK_SIGNAL:
|
||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-ok", QIcon(":/res/w/wifi-medium.png")));
|
||||
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-ok", QIcon(":/res/w/wifi-medium.png")));
|
||||
break;
|
||||
case LOW_SIGNAL:
|
||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-low", QIcon(":/res/w/wifi-low.png")));
|
||||
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-low", QIcon(":/res/w/wifi-low.png")));
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Set wlan(without passwd) icon failed, signal = " << m_data->m_signalStrength << Q_FUNC_INFO << __LINE__;
|
||||
|
@ -176,16 +176,16 @@ void WlanListItem::refreshIcon()
|
|||
switch (m_data->m_signalStrength / STEP + 1) {
|
||||
case FULL_SIGNAL:
|
||||
case EXCELLENT_SIGNAL:
|
||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-secure-symbolic", QIcon(":/res/w/wifi-full-pwd.png")));
|
||||
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-excellent-secure-symbolic", QIcon(":/res/w/wifi-full-pwd.png")));
|
||||
break;
|
||||
case GOOD_SIGNAL:
|
||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-good-secure-symbolic", QIcon(":/res/w/wifi-high-pwd.png")));
|
||||
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-good-secure-symbolic", QIcon(":/res/w/wifi-high-pwd.png")));
|
||||
break;
|
||||
case OK_SIGNAL:
|
||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-ok-secure-symbolic", QIcon(":/res/w/wifi-medium-pwd.png")));
|
||||
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-ok-secure-symbolic", QIcon(":/res/w/wifi-medium-pwd.png")));
|
||||
break;
|
||||
case LOW_SIGNAL:
|
||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-low-secure-symbolic", QIcon(":/res/w/wifi-low-pwd.png")));
|
||||
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-low-secure-symbolic", QIcon(":/res/w/wifi-low-pwd.png")));
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Set wlan(with passwd) icon failed, signal = " << m_data->m_signalStrength << Q_FUNC_INFO << __LINE__;
|
||||
|
@ -237,6 +237,7 @@ void WlanListItem::onNetButtonClicked()
|
|||
|
||||
if (m_data->m_isConfigured) {
|
||||
m_connoperation->activeWirelessConnect(m_wlanDevice,m_data->m_connectUuid);
|
||||
// m_netButton->startLoading();
|
||||
qDebug()<<"Has configuration, will be activated. ssid = " << m_data->m_NetSsid << Q_FUNC_INFO << __LINE__;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ void WlanPage::initWlanUI()
|
|||
{
|
||||
m_titleLabel->setText(tr("WLAN"));
|
||||
m_activatedNetLabel->setText(tr("Activated WLAN"));
|
||||
m_inactivatedNetLabel->setText(tr("Inactivated WLAN"));
|
||||
m_inactivatedNetLabel->setText(tr("Other WLAN"));
|
||||
|
||||
//一些独有控件
|
||||
m_inactivatedWlanListAreaCentralWidget = new QFrame(m_inactivatedNetListArea);
|
||||
|
|
|
@ -53,3 +53,9 @@ bool InfoButton::eventFilter(QObject *w, QEvent *e)
|
|||
}
|
||||
return QPushButton::eventFilter(w, e);
|
||||
}
|
||||
|
||||
void InfoButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
|
||||
return QPushButton::paintEvent(event);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#include "radioitembutton.h"
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
#define BUTTON_SIZE 32,32
|
||||
#define ICON_SIZE 16,16
|
||||
|
||||
RadioItemButton::RadioItemButton(bool isActivated, QWidget *parent) : QPushButton(parent)
|
||||
{
|
||||
|
@ -8,8 +11,14 @@ RadioItemButton::RadioItemButton(bool isActivated, QWidget *parent) : QPushButto
|
|||
m_isActivated = isActivated;
|
||||
this->setAutoFillBackground(false);
|
||||
m_iconLabel = new QLabel(this);
|
||||
m_iconLabel->setScaledContents(true);
|
||||
|
||||
this->setFixedSize(BUTTON_SIZE);
|
||||
m_iconLabel->setFixedSize(BUTTON_SIZE);
|
||||
m_iconLabel->setAlignment(Qt::AlignCenter);
|
||||
|
||||
//JXJ_TODO loading动画
|
||||
// switchTimer = new QTimer(this);
|
||||
// connect(switchTimer, &QTimer::timeout, this, &RadioItemButton::onLoadingStarted);
|
||||
}
|
||||
|
||||
void RadioItemButton::startLoading()
|
||||
|
@ -38,20 +47,72 @@ void RadioItemButton::setReleased()
|
|||
;
|
||||
}
|
||||
|
||||
void RadioItemButton::setButtonIcon(QIcon *icon)
|
||||
void RadioItemButton::setButtonIcon(const QIcon &icon)
|
||||
{
|
||||
if (!icon) {
|
||||
if (icon.isNull()) {
|
||||
return;
|
||||
}
|
||||
//ZJP_TODO 绘制圆形按钮
|
||||
m_iconLabel->setPixmap(icon->pixmap(this->size()));
|
||||
m_iconLabel->setPixmap(icon.pixmap(ICON_SIZE));
|
||||
}
|
||||
void RadioItemButton::onLoadingStarted()
|
||||
{
|
||||
//ZJP_TODO 开始播放转圈动画
|
||||
// switchTimer->start(FRAMESPEED);
|
||||
// QString qpmQss = ":/res/s/conning-b/";
|
||||
// qpmQss.append(QString::number(this->currentPage));
|
||||
// qpmQss.append(".png");
|
||||
// m_iconLabel->setPixmap(QPixmap(qpmQss));
|
||||
//// m_iconLabel->setProperty("useIconHighlightEffect", true);
|
||||
//// m_iconLabel->setProperty("iconHighlightEffectMode", true);
|
||||
|
||||
// this->currentPage --;
|
||||
|
||||
// if (this->currentPage < 1) {
|
||||
// this->currentPage = 12; //循环播放
|
||||
// }
|
||||
// this->countCurrentTime += FRAMESPEED;
|
||||
// //达到一定的时间退出。应该是收到连接成功或者失败的信号断开
|
||||
// if (this->countCurrentTime >= ALLTIME) {
|
||||
// emit this->onLoadingStopped();
|
||||
// }
|
||||
}
|
||||
|
||||
void RadioItemButton::onLoadingStopped()
|
||||
{
|
||||
//ZJP_TODO 停止播放转圈动画
|
||||
this->switchTimer->stop();
|
||||
|
||||
}
|
||||
|
||||
void RadioItemButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
pal.setColor(QPalette::Base, QColor(0,0,0,0));
|
||||
pal.setColor(QPalette::Text, QColor(230,230,230,255));
|
||||
|
||||
QPainterPath cPath;
|
||||
cPath.addRect(0, 0, this->width(), this->height());
|
||||
cPath.addEllipse(0, 0, this->width(), this->width());
|
||||
|
||||
QPainterPath innerPath;
|
||||
innerPath.addEllipse(0, 0, this->width(), this->width());
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
painter.setBrush(pal.color(QPalette::Base));
|
||||
painter.drawPath(cPath);
|
||||
|
||||
painter.fillPath(innerPath, pal.color(QPalette::Text));
|
||||
|
||||
// QRect iconRect;
|
||||
// iconRect = this->rect();
|
||||
// iconRect.adjust(8,8,-8,-8);
|
||||
// QPixmap pixmap = this->icon().pixmap(32,32);
|
||||
// painter.drawPixmap(iconRect, pixmap);
|
||||
|
||||
// return QPushButton::paintEvent(event);
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QPushButton>
|
||||
#include <QIcon>
|
||||
#include <QLabel>
|
||||
#include<QTimer>
|
||||
#define ACTIVATED true
|
||||
#define INACTIVATED false
|
||||
|
||||
|
@ -16,15 +17,20 @@ public:
|
|||
void stopLoading();
|
||||
void setPressed();
|
||||
void setReleased();
|
||||
void setButtonIcon(QIcon *);
|
||||
void setButtonIcon(const QIcon &icon);
|
||||
|
||||
signals:
|
||||
void requestStartLoading();
|
||||
void requestStopLoading();
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
bool m_isActivated = INACTIVATED;
|
||||
QLabel * m_iconLabel = nullptr;
|
||||
QTimer * switchTimer = nullptr;
|
||||
|
||||
int currentPage;
|
||||
int countCurrentTime;
|
||||
|
||||
private slots:
|
||||
void onLoadingStarted();
|
||||
|
|
Loading…
Reference in New Issue