mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 23:15:59 +00:00
global shortcuts with loading from .json map
This commit is contained in:
@@ -22,6 +22,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
#include "application.h"
|
||||
#include "style.h"
|
||||
|
||||
#include "shortcuts.h"
|
||||
|
||||
#include "pspecific.h"
|
||||
#include "fileuploader.h"
|
||||
#include "mainwidget.h"
|
||||
@@ -47,52 +49,6 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
class EventFilterForKeys : public QObject {
|
||||
public:
|
||||
|
||||
EventFilterForKeys(QObject *parent) : QObject(parent) {
|
||||
}
|
||||
bool eventFilter(QObject *o, QEvent *e) {
|
||||
if (e->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *ev = static_cast<QKeyEvent*>(e);
|
||||
if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
|
||||
if (ev->key() == Qt::Key_W && (ev->modifiers() & Qt::ControlModifier)) {
|
||||
Ui::hideWindowNoQuit();
|
||||
return true;
|
||||
} else if (ev->key() == Qt::Key_M && (ev->modifiers() & Qt::ControlModifier)) {
|
||||
App::wnd()->setWindowState(Qt::WindowMinimized);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ((ev->key() == Qt::Key_W || ev->key() == Qt::Key_F4) && (ev->modifiers() & Qt::ControlModifier)) {
|
||||
if (cWorkMode() == dbiwmTrayOnly || cWorkMode() == dbiwmWindowAndTray) {
|
||||
App::wnd()->minimizeToTray();
|
||||
return true;
|
||||
} else {
|
||||
App::wnd()->close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ev->key() == Qt::Key_MediaPlay) {
|
||||
if (App::main()) App::main()->player()->playPressed();
|
||||
} else if (ev->key() == Qt::Key_MediaPause) {
|
||||
if (App::main()) App::main()->player()->pausePressed();
|
||||
} else if (ev->key() == Qt::Key_MediaTogglePlayPause) {
|
||||
if (App::main()) App::main()->player()->playPausePressed();
|
||||
} else if (ev->key() == Qt::Key_MediaStop) {
|
||||
if (App::main()) App::main()->player()->stopPressed();
|
||||
} else if (ev->key() == Qt::Key_MediaPrevious) {
|
||||
if (App::main()) App::main()->player()->prevPressed();
|
||||
} else if (ev->key() == Qt::Key_MediaNext) {
|
||||
if (App::main()) App::main()->player()->nextPressed();
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(o, e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
QChar _toHex(ushort v) {
|
||||
v = v & 0x000F;
|
||||
return QChar::fromLatin1((v >= 10) ? ('a' + (v - 10)) : ('0' + v));
|
||||
@@ -708,8 +664,6 @@ AppClass::AppClass() : QObject()
|
||||
return;
|
||||
}
|
||||
|
||||
application()->installEventFilter(new EventFilterForKeys(this));
|
||||
|
||||
if (cRetina()) {
|
||||
cSetConfigScale(dbisOne);
|
||||
cSetRealScale(dbisOne);
|
||||
@@ -767,6 +721,8 @@ AppClass::AppClass() : QObject()
|
||||
|
||||
DEBUG_LOG(("Application Info: window created.."));
|
||||
|
||||
Shortcuts::start();
|
||||
|
||||
initImageLinkManager();
|
||||
App::initMedia();
|
||||
|
||||
@@ -807,6 +763,13 @@ AppClass::AppClass() : QObject()
|
||||
}
|
||||
|
||||
_window->updateIsActive(Global::OnlineFocusTimeout());
|
||||
|
||||
if (!Shortcuts::errors().isEmpty()) {
|
||||
const QStringList &errors(Shortcuts::errors());
|
||||
for (QStringList::const_iterator i = errors.cbegin(), e = errors.cend(); i != e; ++i) {
|
||||
LOG(("Shortcuts Error: %1").arg(*i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AppClass::regPhotoUpdate(const PeerId &peer, const FullMsgId &msgId) {
|
||||
@@ -1070,6 +1033,8 @@ void AppClass::checkMapVersion() {
|
||||
}
|
||||
|
||||
AppClass::~AppClass() {
|
||||
Shortcuts::finish();
|
||||
|
||||
if (Window *w = _window) {
|
||||
_window = 0;
|
||||
delete w;
|
||||
|
Reference in New Issue
Block a user