refactor: ActionDialog, use checkable list for screen selection
This commit is contained in:
parent
4db2b80d4e
commit
29eaa19d95
2 changed files with 33 additions and 44 deletions
|
|
@ -48,15 +48,16 @@ ActionDialog::ActionDialog(QWidget *parent, const ServerConfig &config, Hotkey &
|
||||||
ui->comboActionType->setCurrentIndex(m_action.type());
|
ui->comboActionType->setCurrentIndex(m_action.type());
|
||||||
ui->comboTriggerOn->setCurrentIndex(m_action.activeOnRelease());
|
ui->comboTriggerOn->setCurrentIndex(m_action.activeOnRelease());
|
||||||
|
|
||||||
ui->m_pGroupBoxScreens->setChecked(m_action.haveScreens());
|
|
||||||
|
|
||||||
for (const Screen &screen : config.screens()) {
|
for (const Screen &screen : config.screens()) {
|
||||||
if (screen.isNull())
|
if (screen.isNull())
|
||||||
continue;
|
continue;
|
||||||
QListWidgetItem *pListItem = new QListWidgetItem(screen.name());
|
auto *newListItem = new QListWidgetItem(screen.name());
|
||||||
ui->m_pListScreens->addItem(pListItem);
|
newListItem->setCheckState(Qt::Checked);
|
||||||
if (m_action.typeScreenNames().indexOf(screen.name()) != -1)
|
if ((m_action.typeScreenNames().indexOf(screen.name()) == -1) &&
|
||||||
ui->m_pListScreens->setCurrentItem(pListItem);
|
(m_action.haveScreens() && !m_action.typeScreenNames().isEmpty()))
|
||||||
|
newListItem->setCheckState(Qt::Unchecked);
|
||||||
|
|
||||||
|
ui->listScreens->addItem(newListItem);
|
||||||
|
|
||||||
ui->m_pComboSwitchToScreen->addItem(screen.name());
|
ui->m_pComboSwitchToScreen->addItem(screen.name());
|
||||||
if (screen.name() == m_action.switchScreenName())
|
if (screen.name() == m_action.switchScreenName())
|
||||||
|
|
@ -72,13 +73,24 @@ void ActionDialog::accept()
|
||||||
|
|
||||||
m_action.setKeySequence(ui->keySequenceWidget->keySequence());
|
m_action.setKeySequence(ui->keySequenceWidget->keySequence());
|
||||||
m_action.setType(ui->comboActionType->currentIndex());
|
m_action.setType(ui->comboActionType->currentIndex());
|
||||||
m_action.setHaveScreens(ui->m_pGroupBoxScreens->isChecked());
|
|
||||||
|
|
||||||
m_action.typeScreenNames().clear();
|
m_action.typeScreenNames().clear();
|
||||||
|
|
||||||
const auto &selection = ui->m_pListScreens->selectedItems();
|
int screenCount = ui->listScreens->count();
|
||||||
for (const QListWidgetItem *pItem : selection)
|
|
||||||
m_action.typeScreenNames().append(pItem->text());
|
for (int i = 0; i < ui->listScreens->count(); i++) {
|
||||||
|
const auto &item = ui->listScreens->item(i);
|
||||||
|
m_action.typeScreenNames().append(item->text());
|
||||||
|
if (item->checkState() == Qt::Unchecked) {
|
||||||
|
screenCount--;
|
||||||
|
m_action.typeScreenNames().removeLast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (screenCount == ui->listScreens->count())
|
||||||
|
m_action.typeScreenNames().clear();
|
||||||
|
|
||||||
|
m_action.setHaveScreens(screenCount);
|
||||||
|
|
||||||
m_action.setSwitchScreenName(ui->m_pComboSwitchToScreen->currentText());
|
m_action.setSwitchScreenName(ui->m_pComboSwitchToScreen->currentText());
|
||||||
m_action.setSwitchDirection(ui->m_pComboSwitchInDirection->currentIndex());
|
m_action.setSwitchDirection(ui->m_pComboSwitchInDirection->currentIndex());
|
||||||
|
|
@ -91,14 +103,13 @@ void ActionDialog::accept()
|
||||||
|
|
||||||
void ActionDialog::keySequenceChanged()
|
void ActionDialog::keySequenceChanged()
|
||||||
{
|
{
|
||||||
ui->m_pGroupBoxScreens->setEnabled(!ui->keySequenceWidget->keySequence().isMouseButton());
|
ui->listScreens->setEnabled(ui->keySequenceWidget->valid() && !ui->keySequenceWidget->keySequence().isMouseButton());
|
||||||
ui->m_pListScreens->setEnabled(!ui->keySequenceWidget->keySequence().isMouseButton());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionDialog::actionTypeChanged(int index)
|
void ActionDialog::actionTypeChanged(int index)
|
||||||
{
|
{
|
||||||
ui->keySequenceWidget->setEnabled(isKeyAction(index));
|
ui->keySequenceWidget->setEnabled(isKeyAction(index));
|
||||||
ui->m_pListScreens->setEnabled(isKeyAction(index) && ui->m_pGroupBoxScreens->isChecked());
|
ui->listScreens->setEnabled(isKeyAction(index));
|
||||||
ui->m_pComboSwitchToScreen->setEnabled(index == ActionTypes::SwitchTo);
|
ui->m_pComboSwitchToScreen->setEnabled(index == ActionTypes::SwitchTo);
|
||||||
ui->m_pComboSwitchInDirection->setEnabled(index == ActionTypes::SwitchInDirection);
|
ui->m_pComboSwitchInDirection->setEnabled(index == ActionTypes::SwitchInDirection);
|
||||||
ui->m_pComboLockCursorToScreen->setEnabled(index == ActionTypes::ModifyCursorLock);
|
ui->m_pComboLockCursorToScreen->setEnabled(index == ActionTypes::ModifyCursorLock);
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>375</width>
|
<width>521</width>
|
||||||
<height>528</height>
|
<height>428</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|
@ -97,40 +97,18 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="m_pGroupBoxScreens">
|
<widget class="QGroupBox" name="group_screens">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>only on these screens</string>
|
<string>Computers to recieve this event</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="flat">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout">
|
|
||||||
<item>
|
<item>
|
||||||
<spacer>
|
<widget class="QListWidget" name="listScreens">
|
||||||
<property name="orientation">
|
<property name="sizeAdjustPolicy">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="m_pListScreens">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>128</width>
|
|
||||||
<height>64</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="selectionMode">
|
<property name="selectionMode">
|
||||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
<enum>QAbstractItemView::NoSelection</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue