feat(color): allow user to change key shortcut action; add Favorites quick menu (#6753)
Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,8 @@ project(generaledit)
|
||||
|
||||
set(${PROJECT_NAME}_NAMES
|
||||
generaledit
|
||||
generalfavorites
|
||||
generalkeyshortcuts
|
||||
generaloptions
|
||||
generalsetup
|
||||
hardware
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include "scrollarea.h"
|
||||
#include "compounditemmodels.h"
|
||||
#include "firmwares/edgetx/edgetxinterface.h"
|
||||
#include "generalfavorites.h"
|
||||
#include "generalkeyshortcuts.h"
|
||||
|
||||
GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * firmware) :
|
||||
QDialog(parent),
|
||||
@@ -56,6 +58,10 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * fir
|
||||
auto hwpnl = new HardwarePanel(this, generalSettings, firmware, editorItemModels);
|
||||
addTab(hwpnl, tr("Hardware"));
|
||||
addTab(new GeneralOptionsPanel(this, generalSettings, firmware), tr("Enabled Features"));
|
||||
if (firmware->getCapability(QMFavourites))
|
||||
addTab(new GeneralFavsPanel(this, generalSettings, firmware), tr("Favourites"));
|
||||
if (firmware->getCapability(KeyShortcuts))
|
||||
addTab(new GeneralKeysPanel(this, generalSettings, firmware), tr("Key Shortcuts"));
|
||||
|
||||
connect(hwpnl, &HardwarePanel::internalModuleChanged, this, [&] { intModChanged = true; });
|
||||
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "generalfavorites.h"
|
||||
#include "autocombobox.h"
|
||||
#include "compounditemmodels.h"
|
||||
#include "exclusivecombogroup.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QGridLayout>
|
||||
|
||||
GeneralFavsPanel::GeneralFavsPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
GeneralPanel(parent, generalSettings, firmware),
|
||||
board(firmware->getBoard()),
|
||||
params(new QList<QWidget *>),
|
||||
row(0),
|
||||
col(0)
|
||||
{
|
||||
grid = new QGridLayout(this);
|
||||
// All values except QM_NONE are mutually exclusive
|
||||
cboQMGrp = new ExclusiveComboGroup(this,
|
||||
[=](const QVariant &value) { return value == GeneralSettings::QM_NONE; });
|
||||
const int cnt = firmware->getCapability(QMFavourites);
|
||||
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
addLabel(tr("# %1").arg(i + 1));
|
||||
AutoComboBox *cbo = new AutoComboBox(this);
|
||||
// separate item model per combo box due to mutual exclusivity
|
||||
cbo->setModel(generalSettings.quickMenuItemModel(false));
|
||||
cbo->setField(generalSettings.qmFavorites[i], this);
|
||||
cboQMGrp->addCombo(cbo);
|
||||
params->append(cbo);
|
||||
addParams();
|
||||
}
|
||||
|
||||
addLine();
|
||||
|
||||
QPushButton *reset = new QPushButton(tr("Reset"));
|
||||
connect(reset, &QPushButton::clicked, [&] ()
|
||||
{
|
||||
generalSettings.setDefaultFavorites();
|
||||
|
||||
foreach(AutoComboBox *cb, findChildren<AutoComboBox*>())
|
||||
cb->updateValue();
|
||||
|
||||
initComboQMGroup();
|
||||
});
|
||||
params->append(reset);
|
||||
addParams();
|
||||
|
||||
initComboQMGroup();
|
||||
addVSpring(grid, 0, grid->rowCount());
|
||||
addHSpring(grid, grid->columnCount(), 0);
|
||||
disableMouseScrolling();
|
||||
}
|
||||
|
||||
GeneralFavsPanel::~GeneralFavsPanel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GeneralFavsPanel::addLabel(QString text)
|
||||
{
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setText(text);
|
||||
grid->addWidget(label, row, col);
|
||||
}
|
||||
|
||||
void GeneralFavsPanel::addLine()
|
||||
{
|
||||
QFrame *line = new QFrame(this);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
line->setLineWidth(1);
|
||||
line->setMidLineWidth(0);
|
||||
grid->addWidget(line, row++, 0, 1, grid->columnCount());
|
||||
}
|
||||
|
||||
void GeneralFavsPanel::addParams()
|
||||
{
|
||||
int col = 0;
|
||||
QGridLayout *subgrid = new QGridLayout();
|
||||
|
||||
for (int i = 0; i < params->size(); i++) {
|
||||
subgrid->addWidget(params->at(i), 0, col++);
|
||||
}
|
||||
|
||||
addHSpring(subgrid, col, 0);
|
||||
grid->addLayout(subgrid, row++, this->col + 1);
|
||||
params->clear();
|
||||
}
|
||||
|
||||
void GeneralFavsPanel::addSection(QString text)
|
||||
{
|
||||
addLabel(QString("<b>%1</b>").arg(text));
|
||||
row++;
|
||||
}
|
||||
|
||||
void GeneralFavsPanel::initComboQMGroup()
|
||||
{
|
||||
// force mutually exclusive update to lists
|
||||
for (int i = 0; i < cboQMGrp->getComboBoxes()->size(); i++) {
|
||||
QComboBox *cbo = cboQMGrp->getComboBoxes()->at(i);
|
||||
cboQMGrp->handleActivated(cbo, cbo->currentIndex());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "generaledit.h"
|
||||
|
||||
class ExclusiveComboGroup;
|
||||
class QGridLayout;
|
||||
|
||||
class GeneralFavsPanel : public GeneralPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GeneralFavsPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~GeneralFavsPanel();
|
||||
|
||||
private:
|
||||
Board::Type board;
|
||||
QGridLayout *grid;
|
||||
QList<QWidget *> *params;
|
||||
int row;
|
||||
int col;
|
||||
ExclusiveComboGroup *cboQMGrp;
|
||||
|
||||
void addLabel(QString text);
|
||||
void addLine();
|
||||
void addParams();
|
||||
void addSection(QString text);
|
||||
void initComboQMGroup();
|
||||
};
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "generalkeyshortcuts.h"
|
||||
#include "autocombobox.h"
|
||||
#include "compounditemmodels.h"
|
||||
#include "exclusivecombogroup.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QGridLayout>
|
||||
|
||||
GeneralKeysPanel::GeneralKeysPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
GeneralPanel(parent, generalSettings, firmware),
|
||||
board(firmware->getBoard()),
|
||||
params(new QList<QWidget *>),
|
||||
row(0),
|
||||
col(0)
|
||||
{
|
||||
grid = new QGridLayout(this);
|
||||
// All values except QM_NONE are mutually exclusive
|
||||
cboQMGrp = new ExclusiveComboGroup(this,
|
||||
[=](const QVariant &value) { return value == GeneralSettings::QM_NONE; });
|
||||
const int cnt = firmware->getCapability(KeyShortcuts);
|
||||
|
||||
const int split = 2;
|
||||
|
||||
for (int i = 0; i < split; i++) {
|
||||
if (i == 0) {
|
||||
addSection(tr("Short Press"));
|
||||
} else {
|
||||
addLine();
|
||||
addSection(tr("Long Press"));
|
||||
}
|
||||
|
||||
for (int j = 0; j < (cnt / split); j++) {
|
||||
addLabel(j == 0 ? tr("MDL") : (j == 1 ? tr("SYS") : tr("TELE")));
|
||||
AutoComboBox *cbo = new AutoComboBox(this);
|
||||
// separate item model per combo box due to mutual exclusivity
|
||||
cbo->setModel(generalSettings.quickMenuItemModel(true));
|
||||
cbo->setField(generalSettings.keyShortcuts[(i * (split + 1)) + j], this);
|
||||
cboQMGrp->addCombo(cbo);
|
||||
params->append(cbo);
|
||||
addParams();
|
||||
}
|
||||
}
|
||||
|
||||
addLine();
|
||||
|
||||
QPushButton *reset = new QPushButton(tr("Reset"));
|
||||
connect(reset, &QPushButton::clicked, [&] ()
|
||||
{
|
||||
generalSettings.setDefaultKeyShortcuts();
|
||||
|
||||
foreach(AutoComboBox *cb, findChildren<AutoComboBox*>())
|
||||
cb->updateValue();
|
||||
|
||||
initComboQMGroup();
|
||||
});
|
||||
params->append(reset);
|
||||
addParams();
|
||||
|
||||
initComboQMGroup();
|
||||
addVSpring(grid, 0, grid->rowCount());
|
||||
addHSpring(grid, grid->columnCount(), 0);
|
||||
disableMouseScrolling();
|
||||
}
|
||||
|
||||
GeneralKeysPanel::~GeneralKeysPanel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GeneralKeysPanel::addLabel(QString text)
|
||||
{
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setText(text);
|
||||
grid->addWidget(label, row, col);
|
||||
}
|
||||
|
||||
void GeneralKeysPanel::addLine()
|
||||
{
|
||||
QFrame *line = new QFrame(this);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
line->setLineWidth(1);
|
||||
line->setMidLineWidth(0);
|
||||
grid->addWidget(line, row++, 0, 1, grid->columnCount());
|
||||
}
|
||||
|
||||
void GeneralKeysPanel::addParams()
|
||||
{
|
||||
int col = 0;
|
||||
QGridLayout *subgrid = new QGridLayout();
|
||||
|
||||
for (int i = 0; i < params->size(); i++) {
|
||||
subgrid->addWidget(params->at(i), 0, col++);
|
||||
}
|
||||
|
||||
addHSpring(subgrid, col, 0);
|
||||
grid->addLayout(subgrid, row++, this->col + 1);
|
||||
params->clear();
|
||||
}
|
||||
|
||||
void GeneralKeysPanel::addSection(QString text)
|
||||
{
|
||||
addLabel(QString("<b>%1</b>").arg(text));
|
||||
row++;
|
||||
}
|
||||
|
||||
void GeneralKeysPanel::initComboQMGroup()
|
||||
{
|
||||
// force mutually exclusive update to lists
|
||||
for (int i = 0; i < cboQMGrp->getComboBoxes()->size(); i++) {
|
||||
QComboBox *cbo = cboQMGrp->getComboBoxes()->at(i);
|
||||
cboQMGrp->handleActivated(cbo, cbo->currentIndex());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "generaledit.h"
|
||||
|
||||
class ExclusiveComboGroup;
|
||||
class QGridLayout;
|
||||
|
||||
class GeneralKeysPanel : public GeneralPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GeneralKeysPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~GeneralKeysPanel();
|
||||
|
||||
private:
|
||||
Board::Type board;
|
||||
QGridLayout *grid;
|
||||
QList<QWidget *> *params;
|
||||
int row;
|
||||
int col;
|
||||
ExclusiveComboGroup *cboQMGrp;
|
||||
|
||||
void addLabel(QString text);
|
||||
void addLine();
|
||||
void addParams();
|
||||
void addSection(QString text);
|
||||
void initComboQMGroup();
|
||||
};
|
||||
Reference in New Issue
Block a user