-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Refactor details widget #1338
Refactor details widget #1338
Conversation
src/gui/DetailsWidget.cpp
Outdated
{ | ||
if (!selectedEntry) { |
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.
Why removing this single check and adding checks in every update function?
Also, in theory m_currentEntry
should never be equal to nullptr
but in such case I prefer hiding the detailsView instead of having it blank
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.
I was planning to make some changes to the logic of the widget displaying (in my opinion it is better that widget was always visible, and the fields cleared when there are no selected items), but it's probably better to discuss this in another PR. I'll revert some changes in the next hour :)
Great work! 👍 for the ElidedLabel. Just a note, see my comment above |
This PR is huge. I won't be able to review it before beginning of next year. |
src/gui/widgets/ElidedLabel.h
Outdated
Q_PROPERTY(QString displayText READ displayText WRITE setDisplayText NOTIFY displayTextChanged) | ||
Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged) | ||
public: | ||
explicit ElidedLabel(QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags()); |
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.
Q_NULLPTR
-> nullptr
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.
Done
3ef5004
to
2958762
Compare
src/gui/DetailsWidget.cpp
Outdated
} else { | ||
m_ui->passwordLabel->setText("****"); | ||
m_ui->entryPasswordLabel->setDisplayText("****"); | ||
m_ui->entryPasswordLabel->setToolTip(QString()); |
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.
Use ""
.
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.
What are the reasons for using an empty string but not a null string?
Qt docs -> distinction between null and empty strings
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.
You can also use {} instead, which will be a null string.
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.
You can also use {} instead, which will be a null string.
done
src/gui/widgets/ElidedLabel.cpp
Outdated
emit elideModeChanged(m_elideMode); | ||
} | ||
|
||
void ElidedLabel::setDisplayText(const QString& elidedText) |
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.
Shouldn't this be called setRawText()
?
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.
Done
src/gui/DetailsWidget.cpp
Outdated
} | ||
|
||
DetailsWidget::~DetailsWidget() | ||
{ | ||
} | ||
|
||
void DetailsWidget::getSelectedEntry(Entry* selectedEntry) | ||
void DetailsWidget::setEntry(Entry* selectedEntry) |
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.
You should also update the entry if the currently selected one was changed.
updateEntryAttachmentsTab(); | ||
updateEntryAutotypeTab(); | ||
|
||
setVisible(!config()->get("GUI/HideDetailsView").toBool()); |
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.
This shouldn't really be a setting with a checkbox IMHO. The widget has a close button right now, but it's extremely frustrating, because the panel comes back as soon as I select another entry. This setting should be set to false whenever I click the close button and instead of a checkbox in the application settings, there should be a little toolbar button at the bottom edge of the screen to restore a previously closed panel (effectively setting this back to true).
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.
There are currently 3 ways to hide the detailsView:
- Permanently in the settings (some user asked for this a while back since the option was available in KeePassX 0.4)
- Dragging down the details panel, you can restore it by dragging it up (the case you are describing, also available in KeePassX 0.4)
- Clicking the close button (hiding it temporary)
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.
The first two are completely unnecessary if the third one would do what I expect it to do.
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.
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.
As I said: I find that totally unnecessary. It only adds additional complexity although it could be as simple as hiding and restoring it in place with the state being remembered. I wouldn't use KeePassX 0.4 as a guideline for how things have to be.
Dragging it down is also not discoverable. And if it's hidden that way, it's gone completely with no indication left that there was once a panel.
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.
@phoerious @TheZ3ro guys can you describe what changes I need to make?
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.
I would prefer it as I described above. Remove the settings checkbox and instead use the setting to automatically remember the panel state. Add a tool button at the bottom to toggle panel visibility.
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.
It might be better to add a show/hide button to the toolbar? KeePassXC doesn't have as many panels as IntelliJ IDEA
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.
Maybe we can fix it in a follow-up PR when we decide a better method to hide it
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.
I can offer to add this to the 'View' menu, scheduled as follow-up for PR #1305:
bbcb82b
to
cd79289
Compare
cd79289
to
26a9dac
Compare
src/gui/DetailsWidget.cpp
Outdated
if (hasTotp) { | ||
m_step = m_currentEntry->totpStep(); | ||
updateTotp(); | ||
m_totpTimer->start(m_step * 10); |
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.
m_timer->start(m_step * 1000);
(As fixed in #1414).
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.
m_timer->start(m_step * 1000);
@adolfogc @TheZ3ro @phoerious
As for me, there's a bug. If we select an element at the twentieth second of the current round (the whole round takes for example 30 seconds), then first ten seconds will be correct and next twentieth not.
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.
Then you should use that as an offset. But letting the timer time out every few milliseconds is just a waste of processing power.
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.
I will try to fix it tomorrow
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.
I'd also be okay with running it unconditionally every second, but m_step * 10 makes no sense.
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.
Done. I set the timer for one second
src/gui/DetailsWidget.h
Outdated
|
||
private: | ||
void setTabEnabled(QTabWidget *tabWidget, QWidget* widget, bool enabled); |
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.
QTabWidget *tabWidget
-> QTabWidget* tabWidget
.
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.
done
This needs to be merged in 2.3.0, @frostasm are you still working on this? |
@TheZ3ro unfotrunately got no time to finish changes, will try to do it by the end of this week |
26a9dac
to
139f779
Compare
What's the status on this? Will you be able to finish towards the end of the week? |
139f779
to
c7880c8
Compare
@phoerious if we consider this patch just as a refactoring of the code base, then I think he's already completed |
c7880c8
to
ce2ef52
Compare
@phoerious I would prefer to leave this patch in its current state (do not change the behavior of a widget to be displayed) |
I'm okay with that. Could you rebase to release/2.3.0 please? |
yes |
ce2ef52
to
6b051c4
Compare
GitHub still shows it as being out of date. Are you sure you rebased to release/2.3.0? |
sorry, I forgot to pull the changes from upstream. I need few minutes. |
6b051c4
to
b264614
Compare
Thanks! |
- Add support for KDBX 4.0, Argon2 and ChaCha20 [#148, #1179, #1230, #1494] - Add SSH Agent feature [#1098, #1450, #1463] - Add preview panel with details of the selected entry [#879, #1338] - Add more and configurable columns to entry table and allow copying of values by double click [#1305] - Add KeePassXC-Browser API as a replacement for KeePassHTTP [#608] - Deprecate KeePassHTTP [#1392] - Add support for Steam one-time passwords [#1206] - Add support for multiple Auto-Type sequences for a single entry [#1390] - Adjust YubiKey HMAC-SHA1 challenge-response key generation for KDBX 4.0 [#1060] - Replace qHttp with cURL for website icon downloads [#1460] - Remove lock file [#1231] - Add option to create backup file before saving [#1385] - Ask to save a generated password before closing the entry password generator [#1499] - Resolve placeholders recursively [#1078] - Add Auto-Type button to the toolbar [#1056] - Improve window focus handling for Auto-Type dialogs [#1204, #1490] - Auto-Type dialog and password generator can now be exited with ESC [#1252, #1412] - Add optional dark tray icon [#1154] - Add new "Unsafe saving" option to work around saving problems with file sync services [#1385] - Add IBus support to AppImage and additional image formats to Windows builds [#1534, #1537] - Add diceware password generator to CLI [#1406] - Add --key-file option to CLI [#816, #824] - Add DBus interface for opening and closing KeePassXC databases [#283] - Add KDBX compression options to database settings [#1419] - Discourage use of old fixed-length key files in favor of arbitrary files [#1326, #1327] - Correct reference resolution in entry fields [#1486] - Fix window state and recent databases not being remembered on exit [#1453] - Correct history item generation when configuring TOTP for an entry [#1446] - Correct multiple TOTP bugs [#1414] - Automatic saving after every change is now a default [#279] - Allow creation of new entries during search [#1398] - Correct menu issues on macOS [#1335] - Allow compilation on OpenBSD [#1328] - Improve entry attachments view [#1139, #1298] - Fix auto lock for Gnome and Xfce [#910, #1249] - Don't remember key files in file dialogs when the setting is disabled [#1188] - Improve database merging and conflict resolution [#807, #1165] - Fix macOS pasteboard issues [#1202] - Improve startup times on some platforms [#1205] - Hide the notes field by default [#1124] - Toggle main window by clicking tray icon with the middle mouse button [#992] - Fix custom icons not copied over when databases are merged [#1008] - Allow use of DEL key to delete entries [#914] - Correct intermittent crash due to stale history items [#1527] - Sanitize newline characters in title, username and URL fields [#1502] - Reopen previously opened databases in correct order [#774] - Use system's zxcvbn library if available [#701] - Implement various i18n improvements [#690, #875, #1436]
Refactor details widget
Description
Motivation and context
The attempt to simplify the codebase :)
How has this been tested?
Manually
Screenshots (if appropriate):
Types of changes
Checklist:
-DWITH_ASAN=ON
. [REQUIRED]