aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLibravatar Keshav Bhatt <keshavnrj@gmail.com>2022-06-16 16:25:19 +0530
committerLibravatar Keshav Bhatt <keshavnrj@gmail.com>2022-06-16 16:25:19 +0530
commitdba5a9bcf89a0a8e050ce50e8400856ed6ce0bd5 (patch)
tree7fe07ef178adb26d0b80e132132aeb73bd73e4dd /src
parent92382d7bd5d4130cfbda395520d198954eded4d1 (diff)
downloadwhatsie-dba5a9bcf89a0a8e050ce50e8400856ed6ce0bd5.tar.gz
whatsie-dba5a9bcf89a0a8e050ce50e8400856ed6ce0bd5.zip
chore: use Ctrl+W to hide window to tray
- replace Ctrl+H with Ctrl+W to hide window to tray - fix the minimize behavior
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp17
-rw-r--r--src/settingswidget.cpp8
2 files changed, 17 insertions, 8 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 913ca0d..8b00d80 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3,6 +3,7 @@
#include <QInputDialog>
#include <QRandomGenerator>
#include <QRegularExpression>
+#include <QShortcut>
#include <QStyleHints>
#include <QUrlQuery>
#include <QWebEngineNotification>
@@ -511,24 +512,26 @@ void MainWindow::notify(QString title, QString message) {
void MainWindow::createActions() {
openUrlAction = new QAction("New Chat", this);
- this->addAction(openUrlAction);
openUrlAction->setShortcut(QKeySequence(Qt::Modifier::CTRL + Qt::Key_N));
connect(openUrlAction, &QAction::triggered, this, &MainWindow::newChat);
+ addAction(openUrlAction);
fullscreenAction = new QAction(tr("Fullscreen"), this);
fullscreenAction->setShortcut(Qt::Key_F11);
connect(fullscreenAction, &QAction::triggered, fullscreenAction,
[=]() { setWindowState(windowState() ^ Qt::WindowFullScreen); });
- this->addAction(fullscreenAction);
+ addAction(fullscreenAction);
minimizeAction = new QAction(tr("Mi&nimize to tray"), this);
- minimizeAction->setShortcut(QKeySequence(Qt::Modifier::CTRL + Qt::Key_H));
- connect(minimizeAction, &QAction::triggered, this, &QWidget::hide);
+ connect(minimizeAction, &QAction::triggered, this, &QMainWindow::hide);
addAction(minimizeAction);
- this->addAction(minimizeAction);
+
+ QShortcut *minimizeShortcut = new QShortcut(
+ QKeySequence(Qt::Modifier::CTRL + Qt::Key_W), this, SLOT(hide()));
+ minimizeShortcut->setAutoRepeat(false);
restoreAction = new QAction(tr("&Restore"), this);
- connect(restoreAction, &QAction::triggered, this, &QWidget::show);
+ connect(restoreAction, &QAction::triggered, this, &QMainWindow::show);
addAction(restoreAction);
reloadAction = new QAction(tr("Re&load"), this);
@@ -540,7 +543,6 @@ void MainWindow::createActions() {
lockAction->setShortcut(QKeySequence(Qt::Modifier::CTRL + Qt::Key_L));
connect(lockAction, &QAction::triggered, this, &MainWindow::lockApp);
addAction(lockAction);
- this->addAction(lockAction);
settingsAction = new QAction(tr("&Settings"), this);
connect(settingsAction, &QAction::triggered, this, &MainWindow::showSettings);
@@ -552,7 +554,6 @@ void MainWindow::createActions() {
quitAction->setShortcut(QKeySequence(Qt::Modifier::CTRL + Qt::Key_Q));
connect(quitAction, &QAction::triggered, this, &MainWindow::quitApp);
addAction(quitAction);
- this->addAction(quitAction);
}
void MainWindow::quitApp() {
diff --git a/src/settingswidget.cpp b/src/settingswidget.cpp
index fcc348d..8e61b38 100644
--- a/src/settingswidget.cpp
+++ b/src/settingswidget.cpp
@@ -486,6 +486,14 @@ void SettingsWidget::on_showShortcutsButton_clicked() {
label->setAlignment(Qt::AlignHCenter);
layout->addWidget(label);
}
+ // handle special case for minimize to try action
+ if (action->text().contains("minimize", Qt::CaseInsensitive) ||
+ action->text().contains("Mi&nimize to tray")) {
+ QLabel *label = new QLabel(
+ action->text().remove("&") + " | " + "Ctrl+W", sheet);
+ label->setAlignment(Qt::AlignHCenter);
+ layout->addWidget(label);
+ }
}
}
sheet->setAttribute(Qt::WA_DeleteOnClose);