added escape key handler (#461)

Added escape key handler for drawer2type
This commit is contained in:
Nethius 2024-02-28 19:39:28 +07:00 committed by GitHub
parent 6dbdb85aaf
commit b05ad2392b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 90 additions and 8 deletions

View file

@ -77,7 +77,16 @@ void PageController::closeWindow()
void PageController::keyPressEvent(Qt::Key key)
{
switch (key) {
case Qt::Key_Back: emit closePage();
case Qt::Key_Back:
case Qt::Key_Escape: {
if (m_drawerDepth) {
emit closeTopDrawer();
setDrawerDepth(getDrawerDepth() - 1);
} else {
emit escapePressed();
}
break;
}
default: return;
}
}
@ -132,3 +141,15 @@ void PageController::closeApplication()
{
qApp->quit();
}
void PageController::setDrawerDepth(const int depth)
{
if (depth >= 0) {
m_drawerDepth = depth;
}
}
int PageController::getDrawerDepth()
{
return m_drawerDepth;
}

View file

@ -87,6 +87,9 @@ public slots:
void closeApplication();
void setDrawerDepth(const int depth);
int getDrawerDepth();
signals:
void goToPage(PageLoader::PageEnum page, bool slide = true);
void goToStartPage();
@ -105,7 +108,7 @@ signals:
void showNotificationMessage(const QString &message);
void showBusyIndicator(bool visible);
void enableTabBar(bool enabled);
void disableControls(bool disabled);
void hideMainWindow();
void raiseMainWindow();
@ -113,12 +116,17 @@ signals:
void showPassphraseRequestDrawer();
void passphraseRequestDrawerClosed(QString passphrase);
void escapePressed();
void closeTopDrawer();
private:
QSharedPointer<ServersModel> m_serversModel;
std::shared_ptr<Settings> m_settings;
bool m_isTriggeredByConnectButton;
int m_drawerDepth;
};
#endif // PAGECONTROLLER_H