refactor: ActionDialog, Aaccess the keySequenceWidget only thru the ui member
This commit is contained in:
parent
0944d918b7
commit
c36c0f2938
3 changed files with 18 additions and 24 deletions
|
|
@ -35,6 +35,7 @@ ActionDialog::ActionDialog(QWidget *parent, const ServerConfig &config, Hotkey &
|
||||||
m_buttonGroupType(new QButtonGroup(this))
|
m_buttonGroupType(new QButtonGroup(this))
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
connect(ui->keySequenceWidget, &KeySequenceWidget::keySequenceChanged, this, &ActionDialog::keySequenceChanged);
|
||||||
|
|
||||||
// work around Qt Designer's lack of a QButtonGroup; we need it to get
|
// work around Qt Designer's lack of a QButtonGroup; we need it to get
|
||||||
// at the button id of the checked radio button
|
// at the button id of the checked radio button
|
||||||
|
|
@ -51,8 +52,8 @@ ActionDialog::ActionDialog(QWidget *parent, const ServerConfig &config, Hotkey &
|
||||||
for (unsigned int i = 0; i < sizeof(typeButtons) / sizeof(typeButtons[0]); i++)
|
for (unsigned int i = 0; i < sizeof(typeButtons) / sizeof(typeButtons[0]); i++)
|
||||||
m_buttonGroupType->addButton(typeButtons[i], i);
|
m_buttonGroupType->addButton(typeButtons[i], i);
|
||||||
|
|
||||||
ui->m_pKeySequenceWidgetHotkey->setText(m_action.keySequence().toString());
|
ui->keySequenceWidget->setText(m_action.keySequence().toString());
|
||||||
ui->m_pKeySequenceWidgetHotkey->setKeySequence(m_action.keySequence());
|
ui->keySequenceWidget->setKeySequence(m_action.keySequence());
|
||||||
m_buttonGroupType->button(m_action.type())->setChecked(true);
|
m_buttonGroupType->button(m_action.type())->setChecked(true);
|
||||||
ui->m_pComboSwitchInDirection->setCurrentIndex(m_action.switchDirection());
|
ui->m_pComboSwitchInDirection->setCurrentIndex(m_action.switchDirection());
|
||||||
ui->m_pComboLockCursorToScreen->setCurrentIndex(m_action.lockCursorMode());
|
ui->m_pComboLockCursorToScreen->setCurrentIndex(m_action.lockCursorMode());
|
||||||
|
|
@ -80,10 +81,10 @@ ActionDialog::ActionDialog(QWidget *parent, const ServerConfig &config, Hotkey &
|
||||||
|
|
||||||
void ActionDialog::accept()
|
void ActionDialog::accept()
|
||||||
{
|
{
|
||||||
if (!sequenceWidget()->valid() && m_buttonGroupType->checkedId() >= 0 && m_buttonGroupType->checkedId() < 3)
|
if (!ui->keySequenceWidget->valid() && m_buttonGroupType->checkedId() >= 0 && m_buttonGroupType->checkedId() < 3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_action.setKeySequence(sequenceWidget()->keySequence());
|
m_action.setKeySequence(ui->keySequenceWidget->keySequence());
|
||||||
m_action.setType(m_buttonGroupType->checkedId());
|
m_action.setType(m_buttonGroupType->checkedId());
|
||||||
m_action.setHaveScreens(ui->m_pGroupBoxScreens->isChecked());
|
m_action.setHaveScreens(ui->m_pGroupBoxScreens->isChecked());
|
||||||
|
|
||||||
|
|
@ -102,9 +103,9 @@ void ActionDialog::accept()
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionDialog::on_m_pKeySequenceWidgetHotkey_keySequenceChanged()
|
void ActionDialog::keySequenceChanged()
|
||||||
{
|
{
|
||||||
if (sequenceWidget()->keySequence().isMouseButton()) {
|
if (ui->keySequenceWidget->keySequence().isMouseButton()) {
|
||||||
ui->m_pGroupBoxScreens->setEnabled(false);
|
ui->m_pGroupBoxScreens->setEnabled(false);
|
||||||
ui->m_pListScreens->setEnabled(false);
|
ui->m_pListScreens->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -113,9 +114,4 @@ void ActionDialog::on_m_pKeySequenceWidgetHotkey_keySequenceChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const KeySequenceWidget *ActionDialog::sequenceWidget() const
|
|
||||||
{
|
|
||||||
return ui->m_pKeySequenceWidgetHotkey;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActionDialog::~ActionDialog() = default;
|
ActionDialog::~ActionDialog() = default;
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,10 @@ public:
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void accept() override;
|
void accept() override;
|
||||||
void on_m_pKeySequenceWidgetHotkey_keySequenceChanged();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
const KeySequenceWidget *sequenceWidget() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void keySequenceChanged();
|
||||||
|
|
||||||
std::unique_ptr<Ui::ActionDialog> ui;
|
std::unique_ptr<Ui::ActionDialog> ui;
|
||||||
Hotkey &m_hotkey;
|
Hotkey &m_hotkey;
|
||||||
Action &m_action;
|
Action &m_action;
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="KeySequenceWidget" name="m_pKeySequenceWidgetHotkey">
|
<widget class="KeySequenceWidget" name="keySequenceWidget">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>1</horstretch>
|
<horstretch>1</horstretch>
|
||||||
|
|
@ -345,7 +345,7 @@
|
||||||
<connection>
|
<connection>
|
||||||
<sender>m_pGroupType</sender>
|
<sender>m_pGroupType</sender>
|
||||||
<signal>toggled(bool)</signal>
|
<signal>toggled(bool)</signal>
|
||||||
<receiver>m_pKeySequenceWidgetHotkey</receiver>
|
<receiver>keySequenceWidget</receiver>
|
||||||
<slot>setDisabled(bool)</slot>
|
<slot>setDisabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
|
@ -361,7 +361,7 @@
|
||||||
<connection>
|
<connection>
|
||||||
<sender>m_pRadioSwitchInDirection</sender>
|
<sender>m_pRadioSwitchInDirection</sender>
|
||||||
<signal>toggled(bool)</signal>
|
<signal>toggled(bool)</signal>
|
||||||
<receiver>m_pKeySequenceWidgetHotkey</receiver>
|
<receiver>keySequenceWidget</receiver>
|
||||||
<slot>setDisabled(bool)</slot>
|
<slot>setDisabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
|
@ -377,7 +377,7 @@
|
||||||
<connection>
|
<connection>
|
||||||
<sender>m_pRadioLockCursorToScreen</sender>
|
<sender>m_pRadioLockCursorToScreen</sender>
|
||||||
<signal>toggled(bool)</signal>
|
<signal>toggled(bool)</signal>
|
||||||
<receiver>m_pKeySequenceWidgetHotkey</receiver>
|
<receiver>keySequenceWidget</receiver>
|
||||||
<slot>setDisabled(bool)</slot>
|
<slot>setDisabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
|
@ -393,7 +393,7 @@
|
||||||
<connection>
|
<connection>
|
||||||
<sender>m_pRadioRestartAllConnections</sender>
|
<sender>m_pRadioRestartAllConnections</sender>
|
||||||
<signal>toggled(bool)</signal>
|
<signal>toggled(bool)</signal>
|
||||||
<receiver>m_pKeySequenceWidgetHotkey</receiver>
|
<receiver>keySequenceWidget</receiver>
|
||||||
<slot>setDisabled(bool)</slot>
|
<slot>setDisabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
|
@ -409,7 +409,7 @@
|
||||||
<connection>
|
<connection>
|
||||||
<sender>m_pRadioPress</sender>
|
<sender>m_pRadioPress</sender>
|
||||||
<signal>toggled(bool)</signal>
|
<signal>toggled(bool)</signal>
|
||||||
<receiver>m_pKeySequenceWidgetHotkey</receiver>
|
<receiver>keySequenceWidget</receiver>
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
|
@ -425,7 +425,7 @@
|
||||||
<connection>
|
<connection>
|
||||||
<sender>m_pRadioRelease</sender>
|
<sender>m_pRadioRelease</sender>
|
||||||
<signal>toggled(bool)</signal>
|
<signal>toggled(bool)</signal>
|
||||||
<receiver>m_pKeySequenceWidgetHotkey</receiver>
|
<receiver>keySequenceWidget</receiver>
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
|
@ -441,7 +441,7 @@
|
||||||
<connection>
|
<connection>
|
||||||
<sender>m_pRadioPressAndRelease</sender>
|
<sender>m_pRadioPressAndRelease</sender>
|
||||||
<signal>toggled(bool)</signal>
|
<signal>toggled(bool)</signal>
|
||||||
<receiver>m_pKeySequenceWidgetHotkey</receiver>
|
<receiver>keySequenceWidget</receiver>
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
|
@ -617,7 +617,7 @@
|
||||||
<connection>
|
<connection>
|
||||||
<sender>m_pRadioSwitchToScreen</sender>
|
<sender>m_pRadioSwitchToScreen</sender>
|
||||||
<signal>toggled(bool)</signal>
|
<signal>toggled(bool)</signal>
|
||||||
<receiver>m_pKeySequenceWidgetHotkey</receiver>
|
<receiver>keySequenceWidget</receiver>
|
||||||
<slot>setDisabled(bool)</slot>
|
<slot>setDisabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue