2012-06-10 16:50:54 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2025-01-24 00:11:17 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
|
|
|
|
* SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
2012-06-10 16:50:54 +00:00
|
|
|
*/
|
2025-01-24 00:11:17 +00:00
|
|
|
|
2024-10-06 13:03:26 +00:00
|
|
|
#pragma once
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2014-02-14 16:21:02 +00:00
|
|
|
#include <QPushButton>
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
#include "KeySequence.h"
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
class KeySequenceWidget : public QPushButton
|
|
|
|
|
{
|
2024-07-02 19:07:06 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
KeySequenceWidget(QWidget *parent, const KeySequence &seq = KeySequence());
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void keySequenceChanged();
|
|
|
|
|
|
|
|
|
|
public:
|
2024-10-17 18:04:35 +00:00
|
|
|
const QString &mousePrefix() const
|
|
|
|
|
{
|
|
|
|
|
return m_MousePrefix;
|
|
|
|
|
}
|
|
|
|
|
const QString &mousePostfix() const
|
|
|
|
|
{
|
|
|
|
|
return m_MousePostfix;
|
|
|
|
|
}
|
|
|
|
|
const QString &keyPrefix() const
|
|
|
|
|
{
|
|
|
|
|
return m_KeyPrefix;
|
|
|
|
|
}
|
|
|
|
|
const QString &keyPostfix() const
|
|
|
|
|
{
|
|
|
|
|
return m_KeyPostfix;
|
|
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
void setMousePrefix(const QString &s)
|
|
|
|
|
{
|
|
|
|
|
m_MousePrefix = s;
|
|
|
|
|
}
|
|
|
|
|
void setMousePostfix(const QString &s)
|
|
|
|
|
{
|
|
|
|
|
m_MousePostfix = s;
|
|
|
|
|
}
|
|
|
|
|
void setKeyPrefix(const QString &s)
|
|
|
|
|
{
|
|
|
|
|
m_KeyPrefix = s;
|
|
|
|
|
}
|
|
|
|
|
void setKeyPostfix(const QString &s)
|
|
|
|
|
{
|
|
|
|
|
m_KeyPostfix = s;
|
|
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
const KeySequence &keySequence() const
|
|
|
|
|
{
|
|
|
|
|
return m_KeySequence;
|
|
|
|
|
}
|
|
|
|
|
const KeySequence &backupSequence() const
|
|
|
|
|
{
|
|
|
|
|
return m_BackupSequence;
|
|
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
void setKeySequence(const KeySequence &seq);
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
bool valid() const
|
|
|
|
|
{
|
|
|
|
|
return keySequence().valid();
|
|
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
|
|
|
|
|
protected:
|
2025-04-28 01:27:48 +00:00
|
|
|
void mousePressEvent(QMouseEvent *) override;
|
|
|
|
|
void keyPressEvent(QKeyEvent *) override;
|
|
|
|
|
bool event(QEvent *event) override;
|
2024-07-02 19:07:06 +00:00
|
|
|
void appendToSequence(int key);
|
|
|
|
|
void updateOutput();
|
|
|
|
|
void startRecording();
|
|
|
|
|
void stopRecording();
|
|
|
|
|
|
|
|
|
|
private:
|
2024-10-17 18:04:35 +00:00
|
|
|
enum Status
|
|
|
|
|
{
|
|
|
|
|
Stopped,
|
|
|
|
|
Recording
|
|
|
|
|
};
|
|
|
|
|
void setStatus(Status s)
|
|
|
|
|
{
|
|
|
|
|
m_Status = s;
|
|
|
|
|
}
|
|
|
|
|
Status status() const
|
|
|
|
|
{
|
|
|
|
|
return m_Status;
|
|
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
KeySequence m_KeySequence;
|
|
|
|
|
KeySequence m_BackupSequence;
|
2025-05-22 22:22:20 +00:00
|
|
|
Status m_Status = Status::Stopped;
|
|
|
|
|
QString m_MousePrefix = QStringLiteral("mousebutton(");
|
|
|
|
|
QString m_MousePostfix = QStringLiteral(")");
|
|
|
|
|
QString m_KeyPrefix = QStringLiteral("keystroke(");
|
|
|
|
|
QString m_KeyPostfix = QStringLiteral(")");
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|