* [package] Add QtSvg support DLLs for Windows.
* [Simulator] Add images/css resources for new version; Create SimulatorIcon and SimulatorStyle classes; Build with SVG support, remove unused bitmaps.
* [Simulator] Improve and simplify VirtualJoystickWidget resize event (sticks maintain X/Y position) & improve values layout w/out trims.
* [Simulator] Refactor Trainer simulator to use VirtualJoystickWidget, gains lock/hold buttons and X/Y position readout.
* [Simulator] More compact layout for Telemetry simulator, reduces min. width and adds scrolling columns to allow smaller window sizes.
* [Simulator] Add new SimulatorMainWindow and RadioOutputsWidget UI classes.
* [storage] Add non-persistent sessionId() to AppData for tracking currently active radio profile ID.
* [Simulator] Major UI updates:
* Use a MainWindow interface with dockable/floatable windows, proper toolbar & menu;
* Persistent size/layout state of all windows/docks/etc between uses, per radio profile;
* Completely separate radio Outputs window with configurable layout (also persistent between uses);
* Translations now enabled in standalone Simulator, follows main Companion setting (they need a lot of updates);
* New custom icons throughout, toolbar icon sizes adhere to user preference in Companion.
* [Simulator] Debug Output console updates:
* New filter feature with optional full RegEx support, can work in inclusive or exclusive modes (full help text is included in UI);
* Up to 50 user-defined filters are saved to permanent settings, also a few predefined filters are provided;
* Saves/restores the last filter used and if it was en/disabled;
* Added word wrap and clear screen features;
* Configurable scroll-back buffer size;
* Increased efficiency & performance of the buffering/printing process.
* [Simulator][OSX] Visual UI tweaks for OS X.
* [Simulator] Fix some debug console settings not being restored properly.
* [Simulator] Add ability to hide/show menu bar; Persist view state of menu bar and radio title bar; Reduce font size on OS X; Other small visual tweaks and improvements.
* [build] Add QtSvg to Linux build scripts (a guess for Dockerfile).
* [build] Fix for Qt 5.3.
* Add OpenTx headers to new files.
* [Companion][storage] Update GeneralSettings() initializer to use current sessionId for profile data retrieval, removes workaround for standalone Simulator being started with arbitrary profile; AppData: always update sessionId when global id() changes.
* [X10] Fixes for new simulator
165 lines
4.7 KiB
C++
165 lines
4.7 KiB
C++
/*
|
|
* Copyright (C) OpenTX
|
|
*
|
|
* Based on code named
|
|
* th9x - http://code.google.com/p/th9x
|
|
* er9x - http://code.google.com/p/er9x
|
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
|
*
|
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#ifndef RADIOUIACTION_H
|
|
#define RADIOUIACTION_H
|
|
|
|
#include <QtCore>
|
|
#include <QWidget>
|
|
#include <QKeyEvent>
|
|
|
|
/*
|
|
* This class is somewhat like a QAction but specific for the radio UI.
|
|
* Actions can have one or more keyboard shortcuts associated with them (currently single-key only, w/out modifiers).
|
|
*/
|
|
class RadioUiAction : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
/*
|
|
* @param index Typically this is the hardware array index corresponding to button on current radio model,
|
|
* but it could be anything. Use -1 or any other negative value for non-hardware indices.
|
|
* @param key An optional Qt:Key code for shortcut.
|
|
* @param parent Parent widget, required for handling keyboard events.
|
|
* @param text Optional title for this action. The text and description are currently used in generated help text.
|
|
* @param descript Optional longer description text for this action.
|
|
*/
|
|
RadioUiAction(int index = -1, int key = 0, QWidget * parent = NULL, const QString &text = "", const QString &descript = ""):
|
|
m_hwIndex(index),
|
|
m_active(false),
|
|
m_keys(QList<int>()),
|
|
m_text(text),
|
|
m_description(descript),
|
|
m_parent(parent)
|
|
{
|
|
if (key)
|
|
m_keys.append(key);
|
|
|
|
init();
|
|
}
|
|
/*
|
|
* @param keys QList of Qt:Key codes to use as shortcuts.
|
|
* [See above for other params.]
|
|
*/
|
|
RadioUiAction(int index, QList<int> keys, QWidget * parent = NULL, const QString &text = "", const QString &descript = ""):
|
|
m_hwIndex(index),
|
|
m_active(false),
|
|
m_keys(keys),
|
|
m_text(text),
|
|
m_description(descript),
|
|
m_parent(parent)
|
|
{
|
|
init();
|
|
}
|
|
|
|
void init()
|
|
{
|
|
if (m_keys.size())
|
|
addShortcut();
|
|
}
|
|
|
|
void addShortcut()
|
|
{
|
|
if (m_parent)
|
|
m_parent->installEventFilter(this);
|
|
}
|
|
|
|
void setDescription(const QString & description) { m_description = description; }
|
|
void setText(QPair<QString, QString> name_descript) { setText(name_descript.first, name_descript.second); }
|
|
|
|
void setText(const QString & text, const QString & description = "")
|
|
{
|
|
m_text = text;
|
|
if (!description.isEmpty())
|
|
setDescription(description);
|
|
}
|
|
|
|
int getIndex() const { return m_hwIndex; }
|
|
bool isActive() const { return m_active; }
|
|
QString getDescription() const { return m_description; }
|
|
QString getText() const { return m_text; }
|
|
|
|
bool eventFilter(QObject * obj, QEvent * event)
|
|
{
|
|
if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
|
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
|
if ((!keyEvent->modifiers() || keyEvent->modifiers() == Qt::KeypadModifier) && m_keys.contains(keyEvent->key())) {
|
|
trigger(event->type() == QEvent::KeyPress);
|
|
return true;
|
|
}
|
|
}
|
|
return QObject::eventFilter(obj, event);
|
|
}
|
|
|
|
public slots:
|
|
|
|
// "toggle" is the most basic way to set the action status and emits only one "toggled" signal
|
|
bool toggle(bool active = true)
|
|
{
|
|
if (active != m_active) {
|
|
m_active = active;
|
|
emit toggled(m_hwIndex, active);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// "trigger" indicates a user-initiated action and emits more signals than "toggle" does
|
|
void trigger(bool active = true)
|
|
{
|
|
if (toggle(active)) {
|
|
emit triggered(m_hwIndex, active);
|
|
if (active) {
|
|
emit pushed(m_hwIndex);
|
|
emit pushed();
|
|
}
|
|
}
|
|
}
|
|
|
|
private:
|
|
|
|
int m_hwIndex;
|
|
bool m_active;
|
|
QList<int> m_keys;
|
|
QString m_text;
|
|
QString m_description;
|
|
QWidget * m_parent;
|
|
|
|
|
|
signals:
|
|
void toggled(int index, bool active); // on programmatic or user interaction change
|
|
void triggered(int index, bool active); // on user interaction change only
|
|
void pushed(int index); // only emitted on user interaction && when 'active' is true
|
|
void pushed();
|
|
};
|
|
|
|
#endif // RADIOUIACTION_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|