forked from flameshot-org/flameshot
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from namecheap/feature/RND-600-flameshot-custo…
…m-hotkeys-for-tools Add configurable shortcuts for drawing tools
- Loading branch information
Showing
40 changed files
with
4,725 additions
and
1,149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "setshortcutwidget.h" | ||
#include <QKeyEvent> | ||
#include <QLayout> | ||
#include <QLabel> | ||
#include <QIcon> | ||
#include <QPixmap> | ||
|
||
SetShortcutDialog::SetShortcutDialog(QDialog *parent) : QDialog(parent) | ||
{ | ||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); | ||
setWindowIcon(QIcon(":img/app/flameshot.svg")); | ||
setWindowTitle(tr("Set Shortcut")); | ||
m_ks = QKeySequence(); | ||
|
||
m_layout = new QVBoxLayout(this); | ||
m_layout->setAlignment(Qt::AlignHCenter); | ||
|
||
QLabel *infoTop = new QLabel(tr("Enter new shortcut to change ")); | ||
infoTop->setMargin(10); | ||
infoTop->setAlignment(Qt::AlignCenter); | ||
m_layout->addWidget(infoTop); | ||
|
||
QLabel *infoIcon = new QLabel(); | ||
infoIcon->setAlignment(Qt::AlignCenter); | ||
infoIcon->setPixmap(QPixmap(":/img/app/keyboard.svg")); | ||
m_layout->addWidget(infoIcon); | ||
|
||
m_layout->addWidget(infoIcon); | ||
|
||
QLabel *infoBottom = new QLabel(tr("Press Esc to cancel or Backspace to disable the keyboard shortcut.")); | ||
infoBottom->setMargin(10); | ||
infoBottom->setAlignment(Qt::AlignCenter); | ||
m_layout->addWidget(infoBottom); | ||
} | ||
|
||
const QKeySequence& SetShortcutDialog::shortcut() { | ||
return m_ks; | ||
} | ||
|
||
void SetShortcutDialog::keyPressEvent(QKeyEvent *ke) { | ||
if (ke->modifiers() & Qt::ShiftModifier) | ||
m_modifier += "Shift+"; | ||
if (ke->modifiers() & Qt::ControlModifier) | ||
m_modifier += "Ctrl+"; | ||
if (ke->modifiers() & Qt::AltModifier) | ||
m_modifier += "Alt+"; | ||
if (ke->modifiers() & Qt::MetaModifier) | ||
m_modifier += "Meta+"; | ||
|
||
QString key = QKeySequence(ke->key()).toString(); | ||
m_ks = QKeySequence(m_modifier + key); | ||
} | ||
|
||
void SetShortcutDialog::keyReleaseEvent(QKeyEvent *event) { | ||
if (m_ks == QKeySequence(Qt::Key_Escape)) { | ||
reject(); | ||
} | ||
accept(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef SETSHORTCUTWIDGET_H | ||
#define SETSHORTCUTWIDGET_H | ||
|
||
#include <QObject> | ||
#include <QDialog> | ||
#include <QKeySequence> | ||
|
||
class QVBoxLayout; | ||
|
||
|
||
class SetShortcutDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit SetShortcutDialog(QDialog *parent = nullptr); | ||
const QKeySequence& shortcut(); | ||
|
||
public: | ||
void keyPressEvent(QKeyEvent *); | ||
void keyReleaseEvent(QKeyEvent *event); | ||
|
||
signals: | ||
|
||
private: | ||
QVBoxLayout *m_layout; | ||
QString m_modifier; | ||
QKeySequence m_ks; | ||
}; | ||
|
||
#endif // SETSHORTCUTWIDGET_H |
Oops, something went wrong.