-
Notifications
You must be signed in to change notification settings - Fork 0
Remove Preferences dialog width restriction #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: wasm-qtkeychain
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
| // Copyright (C) 2019 The MMapper Authors | ||
|
|
||
| #include "ManagePasswordDialog.h" | ||
|
|
||
| #include "../global/ConfigConsts-Computed.h" | ||
| #include "../global/ConfigEnums.h" | ||
| #include "ui_ManagePasswordDialog.h" | ||
|
|
||
| #include <QLineEdit> | ||
| #include <QPushButton> | ||
|
|
||
| ManagePasswordDialog::ManagePasswordDialog(QWidget *parent) | ||
| : QDialog(parent) | ||
| , ui(new Ui::ManagePasswordDialog) | ||
| { | ||
| ui->setupUi(this); | ||
|
|
||
| if constexpr (CURRENT_PLATFORM == PlatformEnum::Wasm) { | ||
| setWindowTitle("Manage Account"); | ||
| ui->label_2->hide(); | ||
| ui->accountPassword->hide(); | ||
| ui->showPassword->hide(); | ||
| ui->deleteButton->hide(); | ||
| } else { | ||
| connect(ui->showPassword, &QToolButton::toggled, this, [this](bool checked) { | ||
| ui->accountPassword->setEchoMode(checked ? QLineEdit::Normal : QLineEdit::Password); | ||
| }); | ||
|
|
||
| connect(ui->deleteButton, &QPushButton::clicked, this, [this]() { | ||
| emit sig_deleteRequested(); | ||
| ui->accountPassword->clear(); | ||
| ui->deleteButton->setEnabled(false); | ||
|
Comment on lines
+30
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question (bug_risk): Delete button stays disabled for the lifetime of the dialog after first use After a delete, the button remains disabled for that dialog instance. If the user edits the password field again in the same session, they can’t delete without closing and reopening the dialog. If multi-step edits should be allowed, consider re‑enabling the button when |
||
| }); | ||
| } | ||
| } | ||
|
|
||
| ManagePasswordDialog::~ManagePasswordDialog() | ||
| { | ||
| delete ui; | ||
| } | ||
|
|
||
| void ManagePasswordDialog::setAccountName(const QString &name) | ||
| { | ||
| ui->accountName->setText(name); | ||
| } | ||
|
|
||
| QString ManagePasswordDialog::accountName() const | ||
| { | ||
| return ui->accountName->text(); | ||
| } | ||
|
|
||
| void ManagePasswordDialog::setPassword(const QString &password) | ||
| { | ||
| ui->accountPassword->setText(password); | ||
| if constexpr (CURRENT_PLATFORM != PlatformEnum::Wasm) { | ||
| ui->deleteButton->setEnabled(!password.isEmpty()); | ||
| } | ||
| } | ||
|
|
||
| QString ManagePasswordDialog::password() const | ||
| { | ||
| return ui->accountPassword->text(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #pragma once | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
| // Copyright (C) 2019 The MMapper Authors | ||
|
|
||
| #include "../global/macros.h" | ||
|
|
||
| #include <QDialog> | ||
|
|
||
| namespace Ui { | ||
| class ManagePasswordDialog; | ||
| } | ||
|
|
||
| class NODISCARD_QOBJECT ManagePasswordDialog final : public QDialog | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| private: | ||
| Ui::ManagePasswordDialog *const ui; | ||
|
|
||
| public: | ||
| explicit ManagePasswordDialog(QWidget *parent = nullptr); | ||
| ~ManagePasswordDialog() final; | ||
|
|
||
| void setAccountName(const QString &name); | ||
| NODISCARD QString accountName() const; | ||
|
|
||
| void setPassword(const QString &password); | ||
| NODISCARD QString password() const; | ||
|
|
||
| signals: | ||
| void sig_deleteRequested(); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>ManagePasswordDialog</class> | ||
| <widget class="QDialog" name="ManagePasswordDialog"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>350</width> | ||
| <height>180</height> | ||
| </rect> | ||
| </property> | ||
| <property name="windowTitle"> | ||
| <string>Manage Password</string> | ||
| </property> | ||
| <layout class="QVBoxLayout" name="verticalLayout"> | ||
| <item> | ||
| <layout class="QGridLayout" name="gridLayout"> | ||
| <item row="0" column="0"> | ||
| <widget class="QLabel" name="label"> | ||
| <property name="text"> | ||
| <string>Account:</string> | ||
| </property> | ||
| <property name="buddy"> | ||
| <cstring>accountName</cstring> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="0"> | ||
| <widget class="QLabel" name="label_2"> | ||
| <property name="text"> | ||
| <string>Password:</string> | ||
| </property> | ||
| <property name="buddy"> | ||
| <cstring>accountPassword</cstring> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="1" colspan="2"> | ||
| <widget class="QLineEdit" name="accountName"/> | ||
| </item> | ||
| <item row="1" column="1"> | ||
| <widget class="QLineEdit" name="accountPassword"> | ||
| <property name="echoMode"> | ||
| <enum>QLineEdit::Password</enum> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="2"> | ||
| <widget class="QToolButton" name="showPassword"> | ||
| <property name="text"> | ||
| <string>View</string> | ||
| </property> | ||
| <property name="checkable"> | ||
| <bool>true</bool> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </item> | ||
| <item> | ||
| <layout class="QHBoxLayout" name="horizontalLayout"> | ||
| <item> | ||
| <widget class="QPushButton" name="deleteButton"> | ||
| <property name="text"> | ||
| <string>Delete</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QDialogButtonBox" name="buttonBox"> | ||
| <property name="orientation"> | ||
| <enum>Qt::Horizontal</enum> | ||
| </property> | ||
| <property name="standardButtons"> | ||
| <set>QDialogButtonBox::Ok</set> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <resources/> | ||
| <connections> | ||
| <connection> | ||
| <sender>buttonBox</sender> | ||
| <signal>accepted()</signal> | ||
| <receiver>ManagePasswordDialog</receiver> | ||
| <slot>accept()</slot> | ||
| </connection> | ||
| </connections> | ||
| </ui> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: handleError lambda returns a bool that is never consumed
Since all callers ignore the bool this lambda returns, the value is effectively dead and makes the intent less clear. Either change it to return void, or add the branching logic that uses the bool if you plan to act on it later.