2020-12-09 10:09:29 +08:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-09-12 15:38:33 +08:00
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
|
|
#include "shortcut.h"
|
|
|
|
|
|
2020-09-21 17:23:32 +08:00
|
|
|
DoubleCtrlShortcut::DoubleCtrlShortcut(QObject *parent) : QObject(parent),
|
2020-09-20 21:58:38 +08:00
|
|
|
m_timer(new QTimer),
|
|
|
|
|
m_isActive(false)
|
2020-09-12 15:38:33 +08:00
|
|
|
{
|
2020-09-13 01:49:36 +08:00
|
|
|
#ifdef Q_OS_LINUX
|
2020-09-21 17:23:32 +08:00
|
|
|
this->m_shortcut = new ShortcutPrivateX11();
|
|
|
|
|
auto signal_address = &ShortcutPrivateX11::activated;
|
2020-09-21 23:27:43 +08:00
|
|
|
#endif
|
2020-12-21 16:09:51 +08:00
|
|
|
|
2021-07-23 16:42:17 +08:00
|
|
|
QObject::connect(this->m_timer, &QTimer::timeout, [this](void) {
|
2020-09-20 21:58:38 +08:00
|
|
|
this->m_isActive = false;
|
|
|
|
|
this->m_timer->stop();
|
|
|
|
|
});
|
2020-09-21 17:23:32 +08:00
|
|
|
QObject::connect(this->m_shortcut, signal_address, this, [this](void) {
|
2020-09-20 21:58:38 +08:00
|
|
|
if (this->m_isActive)
|
|
|
|
|
emit this->activated();
|
|
|
|
|
|
|
|
|
|
this->m_isActive = true;
|
|
|
|
|
if (this->m_timer->isActive())
|
|
|
|
|
this->m_timer->stop();
|
|
|
|
|
|
|
|
|
|
/* Record Press */
|
|
|
|
|
this->m_timer->start(300);
|
|
|
|
|
});
|
2020-09-12 15:38:33 +08:00
|
|
|
}
|