Skip to content
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

Merged

Conversation

frostasm
Copy link
Contributor

@frostasm frostasm commented Dec 29, 2017

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

  • ✅ New feature (non-breaking change which adds functionality)

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]
  • ❌ My change requires a change to the documentation and I have updated it accordingly.
  • ❌ I have added tests to cover my changes.

{
if (!selectedEntry) {
Copy link
Contributor

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

Copy link
Contributor Author

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 :)

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Dec 29, 2017

Great work! 👍 for the ElidedLabel. Just a note, see my comment above

@phoerious
Copy link
Member

This PR is huge. I won't be able to review it before beginning of next year.

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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q_NULLPTR -> nullptr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

} else {
m_ui->passwordLabel->setText("****");
m_ui->entryPasswordLabel->setDisplayText("****");
m_ui->entryPasswordLabel->setToolTip(QString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use "".

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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

emit elideModeChanged(m_elideMode);
}

void ElidedLabel::setDisplayText(const QString& elidedText)
Copy link
Member

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()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

DetailsWidget::~DetailsWidget()
{
}

void DetailsWidget::getSelectedEntry(Entry* selectedEntry)
void DetailsWidget::setEntry(Entry* selectedEntry)
Copy link
Member

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());
Copy link
Member

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).

Copy link
Contributor

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)

Copy link
Member

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing missing it's an option in the menubar like KeePassX 0.4 below

istantanea_2018-01-06_21-02-18_2

Copy link
Member

@phoerious phoerious Jan 6, 2018

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor

@fonic fonic Jan 14, 2018

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:

screenshot_20180114_071144

@phoerious phoerious added this to the v2.3.0 milestone Jan 6, 2018
@frostasm frostasm force-pushed the refactor-details-widget branch 2 times, most recently from bbcb82b to cd79289 Compare January 14, 2018 12:21
@TheZ3ro
Copy link
Contributor

TheZ3ro commented Jan 22, 2018

@frostasm please align this PR to the DetailsWidget changes made in #1414
after that I think we can merge this

if (hasTotp) {
m_step = m_currentEntry->totpStep();
updateTotp();
m_totpTimer->start(m_step * 10);
Copy link
Contributor

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).

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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


private:
void setTabEnabled(QTabWidget *tabWidget, QWidget* widget, bool enabled);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QTabWidget *tabWidget -> QTabWidget* tabWidget.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Jan 30, 2018

This needs to be merged in 2.3.0, @frostasm are you still working on this?

@frostasm
Copy link
Contributor Author

@TheZ3ro unfotrunately got no time to finish changes, will try to do it by the end of this week

@phoerious phoerious changed the base branch from develop to release/2.3.0 February 1, 2018 20:41
@phoerious
Copy link
Member

phoerious commented Feb 1, 2018

What's the status on this? Will you be able to finish towards the end of the week?

@frostasm
Copy link
Contributor Author

frostasm commented Feb 1, 2018

@phoerious if we consider this patch just as a refactoring of the code base, then I think he's already completed

@frostasm
Copy link
Contributor Author

frostasm commented Feb 2, 2018

@phoerious I would prefer to leave this patch in its current state (do not change the behavior of a widget to be displayed)

@phoerious
Copy link
Member

I'm okay with that. Could you rebase to release/2.3.0 please?

@frostasm
Copy link
Contributor Author

frostasm commented Feb 4, 2018

yes

@phoerious
Copy link
Member

GitHub still shows it as being out of date. Are you sure you rebased to release/2.3.0?

@frostasm
Copy link
Contributor Author

frostasm commented Feb 4, 2018

sorry, I forgot to pull the changes from upstream. I need few minutes.

@phoerious phoerious merged commit 90eea14 into keepassxreboot:release/2.3.0 Feb 4, 2018
@phoerious
Copy link
Member

Thanks!

phoerious added a commit that referenced this pull request Feb 27, 2018
- 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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants