Grey out Apply button when there are no changes#1702
Grey out Apply button when there are no changes#1702phoerious merged 2 commits intokeepassxreboot:developfrom
Conversation
|
The base functionality of #1181 (warn when unsaved changes exist) should be ported into this PR. I like this implementation better for detecting when something is changed. |
|
You can block signals for trivial updates. The button shouldn't be enabled for non-modifying changes. |
|
@droidmonkey What do you mean by "porting functionality"? Should I create a merge commit between my branch and frostasm's branch |
|
@phoerious Is it ok to use classes from Qt 5.3? Asking because of |
|
You could copy paste the relevant dialog code or implement your own variant. Definitely don't merge the branches. |
64f78ef to
7e927e0
Compare
|
@droidmonkey @phoerious Changes implemented. This PR is now composed of 3 commits:
Let me know what you think! |
7e927e0 to
8c3c9aa
Compare
|
BTW: Amended the commits to change to my personal email. |
phoerious
left a comment
There was a problem hiding this comment.
A few style nitpicks, rest looks good to me.
src/gui/EditWidgetIcons.cpp
Outdated
| connect(m_ui->defaultIconsRadio, SIGNAL(toggled(bool)), this, SIGNAL(widgetUpdated())); | ||
| connect(m_ui->defaultIconsRadio, SIGNAL(toggled(bool)), this, SIGNAL(widgetUpdated())); | ||
| connect(m_ui->defaultIconsView->selectionModel(), | ||
| SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), |
There was a problem hiding this comment.
No space before (please change that everywhere)
There was a problem hiding this comment.
You mean the newline? So should it be like:
connect(m_ui->defaultIconsView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
this, SIGNAL(widgetUpdated()));
or like this:
connect(m_ui->defaultIconsView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SIGNAL(widgetUpdated()));
src/gui/entry/EditEntryWidget.cpp
Outdated
| #ifdef WITH_XC_SSHAGENT | ||
| // SSH Agent tab | ||
| if (config()->get("SSHAgent", false).toBool()) | ||
| { |
src/gui/entry/EditEntryWidget.cpp
Outdated
| } | ||
|
|
||
| if (!m_saved) | ||
| { |
src/gui/entry/EditEntryWidget.cpp
Outdated
| } | ||
| } | ||
|
|
||
| void EditEntryWidget::setUnsavedChanges(bool anyUnsaved) |
There was a problem hiding this comment.
I would call the parameter hasUnsaved
|
I think ultimately we should change the button state based on the actual entry data, not based on widget edits. But for now it's okay IMHO. |
|
Hmm. The changes seem to hang the GUI tests. Please check what's wrong there. I would assume it's not finishing, because it can't click the button or so. |
|
I restarted the builds. Second rounds seems to go through, but it's quite slow. One build with tests takes 5-6 minutes now instead of 2. |
|
@phoerious Pushed the format and space changes (and added a comment as I'm not sure I got one of your comments right). About the tests, I could run |
|
Just pushed another commit for a problem I noticed a moment ago. Do you use squash&merge or you want me to squash my commits in my branch before merging the PR? |
|
I would do a merge commit for this since there are multiple fixes. |
|
Ok, if it's ok for you, I'd like to squash some of the commits in my branch to clean a bit the story of the repository when the PR gets merged, instead of 5 commits I can leave 2 commits, one per fix. |
|
Yah you can squash the intermediate ones |
eeeb60c to
dbfc6eb
Compare
|
Done 👍 |
|
I meant no space before &. Github swallowed my unescaped ampersand. Compile and run tests with -DWITH_GUI_TESTS=ON. They don't finish on TC. |
|
I found two problems:
Not sure if it fails for you too or it's because I'm in Ubuntu+KDE Plasma (the test fails when clicking an entry, and then pressing Ctrl + clicking another entry, then expects 2 entries to be selected, but finds only 1 is selected). |
|
master tests passed: https://ci.keepassxc.org/viewLog.html?buildId=9321&buildTypeId=KeepassXC_TeamCityCi |
938c5b6 to
301649f
Compare
|
Fixed test that had broken by the new functionality. And fixed the extra spaces before the About the other test that fails, should be something in my machine then. If I follow by myself the same steps that the test case does, they work as expected. |
|
I stopped the old tests. They were jamming the queue. |
|
Noticed this PR status says "Changes requested", but there is no pending change, so letting you know in case there is still something needed. |
|
No, you just need to rebase to the current branch head. |
Resolves keepassxreboot#1313 What this commit does: * Whenever the Apply button is pressed, and if the save was successful, then the Apply button is disabled. * Each subwidget used by EditEntryWidget has now a signal called `widgetUpdated` that is emitted when the widgets' internal content changes. The EditEntryWidget subscribes to that signal to know when to enable the Apply button (by calling `entryUpdated()`). * There are some views that are not isolated in their own widgets (`m_advancedUi`, for example) so in those cases I invoked `entryUpdated()` directly whenever I detected an update: * some updates occur directly in a Qt widget like when editing the text of a QLineItem, so in that case I connected the widget's signals directly to the `entryUpdated()` slot. * some updates occur in EditEntryWidget, so in those cases the invocation to `entryUpdated()` is made as soon as the change is detected (for example when the user has confirmed an action in a dialog). A known problem: there are some situations when the Apply button will get enabled even if there are no changes, this is because the app changes the value of a field by itself so it's considered an update (for example, clicking on the "Reveal" button changes the text shown in a text field). The solution to this can be a bit complicated: disabling temporarily the `entryUpdated()` whenever the app is going to do an action with such side-effects. So I preferred to let the Apply button get enabled in those cases.
301649f to
240939c
Compare
|
@phoerious Done, rebased on top of the current |
|
Thanks! |
|
Just checking... this change is not yet in the latest release, right? |
|
It is, but I think its broken because as soon as you open an entry it determines there are unsaved changes. |
|
Thanks @droidmonkey! I didn't realize there is a newer version until I saw your response. I got the new version via Brew and now I can see that the Apply button is working as expected. I don't see the erroneous behavior that you are describing. Perhaps it is a corner case bug? Is it happening for you for all entries? |
|
The case I am describing is if you try to lock the database with the entry edit view open, it asks if you want to save the entry before closing instead of properly determining if it is "dirty" or not. I thought that applied to the apply button as well, but it does not. |
When the user clicks on the Apply button, it will get disabled. When changes are made, it's enabled again.
Description
widgetUpdatedthat is emitted when the widgets' internal content changes. The EditEntryWidget subscribes to that signal to know when to enable the Apply button (by callingentryUpdated()).m_advancedUi, for example) so in those cases I invokedentryUpdated()directly whenever I detected an update:entryUpdated()slot.entryUpdated()is made as soon as the change is detected (for example when the user has confirmed an action in a dialog).Motivation and context
Resolves #1313
Resolves #1181
How has this been tested?
I tested it manually, not sure if I need to write an automated test.
Types of changes
Checklist:
-DWITH_ASAN=ON. [REQUIRED]