Changeset View
Changeset View
Standalone View
Standalone View
kded/passworddialog.cpp
Show All 22 Lines | |||||
23 | #include "passworddialog.h" | 23 | #include "passworddialog.h" | ||
24 | #include "ui_passworddialog.h" | 24 | #include "ui_passworddialog.h" | ||
25 | #include "uiutils.h" | 25 | #include "uiutils.h" | ||
26 | 26 | | |||
27 | #include <vpnuiplugin.h> | 27 | #include <vpnuiplugin.h> | ||
28 | 28 | | |||
29 | #include <NetworkManagerQt/WirelessSetting> | 29 | #include <NetworkManagerQt/WirelessSetting> | ||
30 | #include <NetworkManagerQt/VpnSetting> | 30 | #include <NetworkManagerQt/VpnSetting> | ||
31 | #include <NetworkManagerQt/Utils> | ||||
31 | 32 | | |||
32 | #include <KServiceTypeTrader> | 33 | #include <KServiceTypeTrader> | ||
33 | #include <KLocalizedString> | 34 | #include <KLocalizedString> | ||
34 | #include <KIconLoader> | 35 | #include <KIconLoader> | ||
35 | 36 | | |||
36 | #include <QIcon> | 37 | #include <QIcon> | ||
37 | #include <QPushButton> | 38 | #include <QPushButton> | ||
38 | 39 | | |||
Show All 25 Lines | 64 | { | |||
64 | m_ui = new Ui::PasswordDialog; | 65 | m_ui = new Ui::PasswordDialog; | ||
65 | m_ui->setupUi(this); | 66 | m_ui->setupUi(this); | ||
66 | // TODO fix this for high DPI | 67 | // TODO fix this for high DPI | ||
67 | m_ui->labelIcon->setPixmap(QIcon::fromTheme(QStringLiteral("dialog-password")).pixmap(KIconLoader::SizeHuge)); | 68 | m_ui->labelIcon->setPixmap(QIcon::fromTheme(QStringLiteral("dialog-password")).pixmap(KIconLoader::SizeHuge)); | ||
68 | m_ui->labelHeadline->setText(i18n("Authenticate %1", m_connectionSettings->id())); | 69 | m_ui->labelHeadline->setText(i18n("Authenticate %1", m_connectionSettings->id())); | ||
69 | 70 | | |||
70 | connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &PasswordDialog::accept); | 71 | connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &PasswordDialog::accept); | ||
71 | connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &PasswordDialog::reject); | 72 | connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &PasswordDialog::reject); | ||
73 | connect(m_ui->password, &PasswordField::textChanged, [this](const QString &text){ | ||||
74 | if (m_connectionSettings->connectionType() == NetworkManager::ConnectionSettings::Wireless) { | ||||
75 | NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting = | ||||
76 | m_connectionSettings->setting(NetworkManager::Setting::WirelessSecurity).staticCast<NetworkManager::WirelessSecuritySetting>(); | ||||
jgrulich: Last thing I would change is:
1) First check whether the connection type is NetworkManager… | |||||
77 | bool valid = true; | ||||
78 | | ||||
79 | if (wirelessSecuritySetting) { | ||||
80 | switch (wirelessSecuritySetting->keyMgmt()) { | ||||
81 | case NetworkManager::WirelessSecuritySetting::WpaPsk: | ||||
82 | valid = wpaPskIsValid(text); | ||||
83 | break; | ||||
84 | case NetworkManager::WirelessSecuritySetting::Wep: | ||||
85 | valid = wepKeyIsValid(text, wirelessSecuritySetting->wepKeyType()); | ||||
86 | break; | ||||
87 | default: | ||||
88 | break; | ||||
89 | } | ||||
90 | } | ||||
91 | | ||||
92 | // disable button if key is not valid | ||||
93 | m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDisabled(!valid); | ||||
It shouldn't definitely be hiding buttons, you can make the "OK" button just disabled. jgrulich: It shouldn't definitely be hiding buttons, you can make the "OK" button just disabled. | |||||
94 | } | ||||
95 | }); | ||||
72 | 96 | | |||
73 | if (m_connectionSettings->connectionType() != NetworkManager::ConnectionSettings::Vpn) { | 97 | if (m_connectionSettings->connectionType() != NetworkManager::ConnectionSettings::Vpn) { | ||
74 | NetworkManager::Setting::Ptr setting = m_connectionSettings->setting(m_settingName); | 98 | NetworkManager::Setting::Ptr setting = m_connectionSettings->setting(m_settingName); | ||
75 | m_neededSecrets = setting->needSecrets(m_flags & SecretAgent::RequestNew); | 99 | m_neededSecrets = setting->needSecrets(m_flags & SecretAgent::RequestNew); | ||
76 | 100 | | |||
77 | if (m_neededSecrets.isEmpty()) { | 101 | if (m_neededSecrets.isEmpty()) { | ||
78 | qCWarning(PLASMA_NM) << "list of secrets is empty!!!"; | 102 | qCWarning(PLASMA_NM) << "list of secrets is empty!!!"; | ||
79 | m_hasError = true; | 103 | m_hasError = true; | ||
▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines |
Last thing I would change is: