-
Notifications
You must be signed in to change notification settings - Fork 60
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
Allow to remove account folder with Delete or Backspace keystroke #588
Allow to remove account folder with Delete or Backspace keystroke #588
Conversation
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 think this is a good idea, I just have an alternative proposal for the QTreeViewWithKeyEvents
class.
Also, should we make the keyboard shortcut more discoverable? We could add a tooltip to the delete button that mentions the keyboard shortcuts.
typedef void ( * TreeViewKeyPressedEvent)(void * handle, QKeyEvent * event); | ||
|
||
/** | ||
* A QTreeView that allow to define listener of keyEvent received | ||
*/ | ||
class QTreeViewWithKeyEvents : public QTreeView { | ||
Q_OBJECT | ||
|
||
public: | ||
explicit QTreeViewWithKeyEvents(QWidget *parent = NULL); | ||
|
||
public slots: | ||
void onKeyPressed(void * handleUsed, TreeViewKeyPressedEvent callback); | ||
|
||
protected: | ||
void keyPressEvent(QKeyEvent * event) override; | ||
|
||
private: | ||
TreeViewKeyPressedEvent mCallback; | ||
void * mHandle; | ||
}; |
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.
How about we just use the Qt event system instead of building our own, that way we can avoid some casts and manually storing listeners.
typedef void ( * TreeViewKeyPressedEvent)(void * handle, QKeyEvent * event); | |
/** | |
* A QTreeView that allow to define listener of keyEvent received | |
*/ | |
class QTreeViewWithKeyEvents : public QTreeView { | |
Q_OBJECT | |
public: | |
explicit QTreeViewWithKeyEvents(QWidget *parent = NULL); | |
public slots: | |
void onKeyPressed(void * handleUsed, TreeViewKeyPressedEvent callback); | |
protected: | |
void keyPressEvent(QKeyEvent * event) override; | |
private: | |
TreeViewKeyPressedEvent mCallback; | |
void * mHandle; | |
}; | |
/** | |
* A QTreeView that allow to define listener of keyEvent received. | |
*/ | |
class QTreeViewWithKeyEvents : public QTreeView { | |
Q_OBJECT | |
public: | |
explicit QTreeViewWithKeyEvents(QWidget* parent = nullptr); | |
signals: | |
void onKeyPressed(QKeyEvent* event); | |
protected: | |
void keyPressEvent(QKeyEvent* event) override; | |
}; |
with
void QTreeViewWithKeyEvents::keyPressEvent( QKeyEvent *event )
{
emit onKeyPressed(event);
QTreeView::keyPressEvent(event);
}
and
connect(treeAccounts, &QTreeViewWithKeyEvents::onKeyPressed, this, &DialogSettings::onKeyPressedOnTreeAccount);
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.
Looks fine with me. I mean, those are rare operations, hardly worthy optimizing, but as you wish :)
Yes i can had a tooltip in another PR !
Yes, i have search if such signal exist in qt component and because i doesn't exist i have had own listener and i admit i've don't think to reuse signal system, i can follow your recommandation in another PR (Because it's already merged) ! |
See comments in review : * gyunaev#588 (comment)
…tion with keystroke See comments in review : * gyunaev#588 (review)
When you have a large number of accounts/folder to monitor, it's quite useful to enable deletion with a keystroke on the keyboard instead of clicking a button, so this PR is made for that.