lineedit 右键菜单适配亮主题

This commit is contained in:
jzxc95 2021-12-16 15:04:46 +08:00
parent b4b36d8bfd
commit 2c9ac22657
13 changed files with 77 additions and 54 deletions

View File

@ -5,6 +5,8 @@
#include <QPalette>
#include <QComboBox>
#include <QAbstractItemView>
#include <QMenu>
#include <QContextMenuEvent>
#include "kywirelessnetitem.h"
#include "kylinconnectresource.h"
#include "kylinactiveconnectresource.h"
@ -33,6 +35,23 @@ enum TtlsInnerType
GTC_EAP
};
class LineEdit : public QLineEdit
{
Q_OBJECT
public:
explicit LineEdit(QWidget *parent = nullptr) : QLineEdit(parent) {}
~LineEdit() {}
protected:
void contextMenuEvent(QContextMenuEvent *event) {
QMenu *menu = createStandardContextMenu();//默认的标准右键菜单,如果不需要刻意完全自己实现
menu->setPalette(this->palette());
menu->exec(event->globalPos());
delete menu;
}
};
class ConInfo {
public:
QString strConName;
@ -70,9 +89,10 @@ public:
};
static void setFramePalette(QFrame *widget, QPalette &pal) {
QList<QLineEdit *> lineEditList = widget->findChildren<QLineEdit *>();
QList<LineEdit *> lineEditList = widget->findChildren<LineEdit *>();
for (int i = 0; i < lineEditList.count(); ++i) {
lineEditList.at(i)->setPalette(pal);
lineEditList.at(i)->setContextMenuPolicy(Qt::DefaultContextMenu);
}
QList<QComboBox *> comboBoxList = widget->findChildren<QComboBox *>();
for (int i = 0; i < comboBoxList.count(); ++i) {

View File

@ -11,14 +11,14 @@ CreatNetPage::CreatNetPage(QWidget *parent):QFrame(parent)
void CreatNetPage::initUI()
{
connNameEdit = new QLineEdit(this);
connNameEdit = new LineEdit(this);
connNameEdit->setMaxLength(MAX_NAME_LENGTH);
ipv4ConfigCombox = new QComboBox(this);
ipv4addressEdit = new QLineEdit(this);
netMaskEdit = new QLineEdit(this);
gateWayEdit = new QLineEdit(this);
firstDnsEdit = new QLineEdit(this);
secondDnsEdit = new QLineEdit(this);
ipv4addressEdit = new LineEdit(this);
netMaskEdit = new LineEdit(this);
gateWayEdit = new LineEdit(this);
firstDnsEdit = new LineEdit(this);
secondDnsEdit = new LineEdit(this);
m_connNameLabel = new QLabel(this);
m_configLabel = new QLabel(this);

View File

@ -22,13 +22,13 @@ public:
void constructIpv4Info(KyConnectSetting &setting);
private:
QLineEdit *connNameEdit;
LineEdit *connNameEdit;
QComboBox *ipv4ConfigCombox;
QLineEdit *ipv4addressEdit;
QLineEdit *netMaskEdit;
QLineEdit *gateWayEdit;
QLineEdit *firstDnsEdit;
QLineEdit *secondDnsEdit;
LineEdit *ipv4addressEdit;
LineEdit *netMaskEdit;
LineEdit *gateWayEdit;
LineEdit *firstDnsEdit;
LineEdit *secondDnsEdit;
private:
QFormLayout *m_detailLayout;

View File

@ -13,7 +13,7 @@ DetailPage::DetailPage(bool isWlan, bool isCreate, QWidget *parent)
this->setMaximumWidth(960);
initUI();
if (isCreate) {
connect(mSSIDEdit, &QLineEdit::textEdited, this, &DetailPage::setEnableOfSaveBtn);
connect(mSSIDEdit, &LineEdit::textEdited, this, &DetailPage::setEnableOfSaveBtn);
}
}
@ -122,7 +122,7 @@ void DetailPage::initUI() {
// mSSID->setFocusPolicy(Qt::NoFocus);
} else {
// mSSID->setStyleSheet("border-width:1px;;border-style:solid;border-color:black;border-radius:2px");
mSSIDEdit = new QLineEdit(this);
mSSIDEdit = new LineEdit(this);
mSSIDEdit->setMaximumWidth(MAX_LABEL_WIDTH);
mSSIDEdit->setAlignment(Qt::AlignRight);
mSSIDEdit->setStyleSheet("border-top:0px solid;border-bottom:1px solid;border-left:0px solid;border-right: 0px solid;background:transparent");

View File

@ -52,7 +52,7 @@ public:
DetailWidget * m_ipv6Widget = nullptr;
DetailWidget * m_macWidget = nullptr;
QLineEdit *mSSIDEdit;
LineEdit *mSSIDEdit;
FixLabel *mSSIDLabel;
QLabel *mProtocol;
QLabel *mSecType;

View File

@ -10,11 +10,11 @@ Ipv4Page::Ipv4Page(QWidget *parent):QFrame(parent)
void Ipv4Page::initUI() {
ipv4ConfigCombox = new QComboBox(this);
ipv4addressEdit = new QLineEdit(this);
netMaskEdit = new QLineEdit(this);
gateWayEdit = new QLineEdit(this);
firstDnsEdit = new QLineEdit(this);
secondDnsEdit = new QLineEdit(this);
ipv4addressEdit = new LineEdit(this);
netMaskEdit = new LineEdit(this);
gateWayEdit = new LineEdit(this);
firstDnsEdit = new LineEdit(this);
secondDnsEdit = new LineEdit(this);
m_configLabel = new QLabel(this);
m_addressLabel = new QLabel(this);

View File

@ -30,11 +30,11 @@ public:
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
private:
QComboBox *ipv4ConfigCombox;
QLineEdit *ipv4addressEdit;
QLineEdit *netMaskEdit;
QLineEdit *gateWayEdit;
QLineEdit *firstDnsEdit;
QLineEdit *secondDnsEdit;
LineEdit *ipv4addressEdit;
LineEdit *netMaskEdit;
LineEdit *gateWayEdit;
LineEdit *firstDnsEdit;
LineEdit *secondDnsEdit;
private:
QFormLayout *m_detailLayout;

View File

@ -91,11 +91,11 @@ bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
void Ipv6Page::initUI() {
ipv6ConfigCombox = new QComboBox(this);
ipv6AddressEdit = new QLineEdit(this);
lengthEdit = new QLineEdit(this);
gateWayEdit = new QLineEdit(this);
firstDnsEdit = new QLineEdit(this);
secondDnsEdit = new QLineEdit(this);
ipv6AddressEdit = new LineEdit(this);
lengthEdit = new LineEdit(this);
gateWayEdit = new LineEdit(this);
firstDnsEdit = new LineEdit(this);
secondDnsEdit = new LineEdit(this);
m_configLabel = new QLabel(this);
m_addressLabel = new QLabel(this);

View File

@ -33,11 +33,11 @@ public:
public:
QComboBox *ipv6ConfigCombox;
QLineEdit *ipv6AddressEdit;
QLineEdit *lengthEdit;
QLineEdit *gateWayEdit;
QLineEdit *firstDnsEdit;
QLineEdit *secondDnsEdit;
LineEdit *ipv6AddressEdit;
LineEdit *lengthEdit;
LineEdit *gateWayEdit;
LineEdit *firstDnsEdit;
LineEdit *secondDnsEdit;
private:
QFormLayout *m_detailLayout;
QLabel *m_configLabel;

View File

@ -8,6 +8,7 @@
#define COLOR_THEME "styleName"
#include <QEvent>
#include <QMenu>
#define WINDOW_WIDTH 520
#define WINDOW_HEIGHT 590

View File

@ -135,4 +135,7 @@ signals:
void detailPageClose(bool on);
void createPageClose(QString);
};
#endif // NETDETAIL_H

View File

@ -33,21 +33,21 @@ void SecurityPage::initUI()
userPwdFlagLabel = new QLabel(this);
secuTypeCombox = new QComboBox(this);
pwdEdit = new QLineEdit(this);
pwdEdit = new LineEdit(this);
eapTypeCombox = new QComboBox(this);
//TLS
identityEdit = new QLineEdit(this);
domainEdit = new QLineEdit(this);
identityEdit = new LineEdit(this);
domainEdit = new LineEdit(this);
caCertPathCombox = new QComboBox(this);
caNeedBox = new QCheckBox(this);
clientCertPathCombox = new QComboBox(this);
clientPrivateKeyCombox = new QComboBox(this);
clientPrivateKeyPwdEdit = new QLineEdit(this);
clientPrivateKeyPwdEdit = new LineEdit(this);
//PEAP && TTLS
eapMethodCombox = new QComboBox(this);
userNameEdit = new QLineEdit(this);
userPwdEdit = new QLineEdit(this);
userNameEdit = new LineEdit(this);
userPwdEdit = new LineEdit(this);
userPwdFlagBox = new QCheckBox(this);
@ -193,17 +193,17 @@ void SecurityPage::initConnect()
this, &SecurityPage::onClientPrivateKeyComboxIndexChanged);
connect(secuTypeCombox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(pwdEdit, &QLineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(pwdEdit, &LineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(eapTypeCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
connect(identityEdit, &QLineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(identityEdit, &LineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(caCertPathCombox, SIGNAL(currentTextChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(caNeedBox, &QCheckBox::stateChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(clientCertPathCombox, SIGNAL(currentTextChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(clientPrivateKeyCombox, SIGNAL(currentTextChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(clientPrivateKeyPwdEdit, &QLineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(clientPrivateKeyPwdEdit, &LineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(eapMethodCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
connect(userNameEdit, &QLineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(userPwdEdit, &QLineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(userNameEdit, &LineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(userPwdEdit, &LineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
}

View File

@ -10,7 +10,6 @@
#include "coninfo.h"
class SecurityPage : public QFrame
{
Q_OBJECT
@ -57,21 +56,21 @@ private:
QLabel *userPwdFlagLabel;
QComboBox *secuTypeCombox;
QLineEdit *pwdEdit;
LineEdit *pwdEdit;
QComboBox *eapTypeCombox;
//TLS
QLineEdit *identityEdit;
QLineEdit *domainEdit;
LineEdit *identityEdit;
LineEdit *domainEdit;
QComboBox *caCertPathCombox;
QCheckBox *caNeedBox;
QComboBox *clientCertPathCombox;
QComboBox *clientPrivateKeyCombox;
QLineEdit *clientPrivateKeyPwdEdit;
LineEdit *clientPrivateKeyPwdEdit;
//PEAP && TTLS
QComboBox *eapMethodCombox;
QLineEdit *userNameEdit;
QLineEdit *userPwdEdit;
LineEdit *userNameEdit;
LineEdit *userPwdEdit;
QCheckBox *userPwdFlagBox;
QCheckBox *pwdBox;