2009-11-04 00:33:42 +01:00
|
|
|
/***************************************************************************
|
2014-08-15 02:11:43 -07:00
|
|
|
* Copyright (C) 2008-2009 by Heiko Koehn - KoehnHeiko@googlemail.com *
|
|
|
|
|
* Copyright (C) 2014 by Ahmed Charles - acharles@outlook.com *
|
2022-01-21 04:50:50 +00:00
|
|
|
* Copyright (C) 2019, 2022 by Stephen Lyons - slysven@virginmedia.com *
|
2009-11-04 00:33:42 +01:00
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* 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. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "dlgTriggerPatternEdit.h"
|
|
|
|
|
|
Improve: Reduce pattern lines in trigger editor (#8239)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Reduce blank pattern widget lines to only show used ones + 1. New
trigger start with two.
When you delete the last one, it reduces back to always used + 1 blank
Works good with import triggers and legacy multiple lines triggers.,
improves keyboard navigation:
modified order of tab navigation to go from name to patterns, then
continue,
add control+f to go first pattern line, and control+L last.. hint under
pattern lines
Up/down arrows to move between pattern lines
#### Motivation for adding to Mudlet
Enhanced tab navigation on the trigger editor menu , priority to useful
displays, etc.
better experiencie for screen readers users , less objects to navigate.
#### Other info (issues closed, discussion etc)
replace #8215
<img width="1860" height="681" alt="image"
src="https://github.com/user-attachments/assets/9bcc9cb4-dc52-4ff9-b4a1-0ad65dbb2e48"
/>
<img width="1825" height="825" alt="image"
src="https://github.com/user-attachments/assets/abc393f2-4ad3-4eac-9bdb-848c27dbc9e9"
/>
https://github.com/user-attachments/assets/69acf69e-15a2-4439-93da-ea98c39958c6
---------
Signed-off-by: SammerPetria <sammerpetria@gmail.com>
2025-10-30 13:57:24 -03:00
|
|
|
#include <QAbstractButton>
|
|
|
|
|
#include <QAbstractItemView>
|
|
|
|
|
#include <QAbstractScrollArea>
|
|
|
|
|
#include <QAbstractSpinBox>
|
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
|
#include <QColor>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QPalette>
|
|
|
|
|
#include <QWidget>
|
2019-03-11 18:24:25 +01:00
|
|
|
#include <QAction>
|
2021-02-03 11:03:46 +01:00
|
|
|
#include <QDebug>
|
2014-08-15 02:11:43 -07:00
|
|
|
|
2022-11-14 10:14:16 +01:00
|
|
|
dlgTriggerPatternEdit::dlgTriggerPatternEdit(QWidget* pParentWidget)
|
|
|
|
|
: QWidget(pParentWidget)
|
2009-11-04 00:33:42 +01:00
|
|
|
{
|
|
|
|
|
// init generated dialog
|
|
|
|
|
setupUi(this);
|
Improve: Reduce pattern lines in trigger editor (#8239)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Reduce blank pattern widget lines to only show used ones + 1. New
trigger start with two.
When you delete the last one, it reduces back to always used + 1 blank
Works good with import triggers and legacy multiple lines triggers.,
improves keyboard navigation:
modified order of tab navigation to go from name to patterns, then
continue,
add control+f to go first pattern line, and control+L last.. hint under
pattern lines
Up/down arrows to move between pattern lines
#### Motivation for adding to Mudlet
Enhanced tab navigation on the trigger editor menu , priority to useful
displays, etc.
better experiencie for screen readers users , less objects to navigate.
#### Other info (issues closed, discussion etc)
replace #8215
<img width="1860" height="681" alt="image"
src="https://github.com/user-attachments/assets/9bcc9cb4-dc52-4ff9-b4a1-0ad65dbb2e48"
/>
<img width="1825" height="825" alt="image"
src="https://github.com/user-attachments/assets/abc393f2-4ad3-4eac-9bdb-848c27dbc9e9"
/>
https://github.com/user-attachments/assets/69acf69e-15a2-4439-93da-ea98c39958c6
---------
Signed-off-by: SammerPetria <sammerpetria@gmail.com>
2025-10-30 13:57:24 -03:00
|
|
|
|
|
|
|
|
mDefaultPalette = palette();
|
|
|
|
|
mDefaultPatternNumberPalette = label_patternNumber->palette();
|
|
|
|
|
mDefaultPromptPalette = label_prompt->palette();
|
|
|
|
|
mDefaultComboPalette = comboBox_patternType->palette();
|
|
|
|
|
mDefaultSpinPalette = spinBox_lineSpacer->palette();
|
|
|
|
|
mDefaultForegroundButtonPalette = pushButton_fgColor->palette();
|
|
|
|
|
mDefaultBackgroundButtonPalette = pushButton_bgColor->palette();
|
|
|
|
|
mDefaultPatternEditPalette = singleLineTextEdit_pattern->palette();
|
|
|
|
|
if (auto* patternViewport = singleLineTextEdit_pattern->viewport()) {
|
|
|
|
|
mDefaultPatternEditViewportPalette = patternViewport->palette();
|
|
|
|
|
mDefaultPatternEditViewportAutoFillBackground = patternViewport->autoFillBackground();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-03 11:03:46 +01:00
|
|
|
// delay the connection so the pattern type is available for the slot
|
|
|
|
|
connect(comboBox_patternType, qOverload<int>(&QComboBox::currentIndexChanged), this, &dlgTriggerPatternEdit::slot_triggerTypeComboBoxChanged, Qt::QueuedConnection);
|
2019-03-11 18:24:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void dlgTriggerPatternEdit::slot_triggerTypeComboBoxChanged(const int index)
|
|
|
|
|
{
|
2020-12-28 10:01:28 +01:00
|
|
|
label_colorIcon->setPixmap(comboBox_patternType->itemIcon(index).pixmap(15, 15));
|
Improve: Reduce pattern lines in trigger editor (#8239)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Reduce blank pattern widget lines to only show used ones + 1. New
trigger start with two.
When you delete the last one, it reduces back to always used + 1 blank
Works good with import triggers and legacy multiple lines triggers.,
improves keyboard navigation:
modified order of tab navigation to go from name to patterns, then
continue,
add control+f to go first pattern line, and control+L last.. hint under
pattern lines
Up/down arrows to move between pattern lines
#### Motivation for adding to Mudlet
Enhanced tab navigation on the trigger editor menu , priority to useful
displays, etc.
better experiencie for screen readers users , less objects to navigate.
#### Other info (issues closed, discussion etc)
replace #8215
<img width="1860" height="681" alt="image"
src="https://github.com/user-attachments/assets/9bcc9cb4-dc52-4ff9-b4a1-0ad65dbb2e48"
/>
<img width="1825" height="825" alt="image"
src="https://github.com/user-attachments/assets/abc393f2-4ad3-4eac-9bdb-848c27dbc9e9"
/>
https://github.com/user-attachments/assets/69acf69e-15a2-4439-93da-ea98c39958c6
---------
Signed-off-by: SammerPetria <sammerpetria@gmail.com>
2025-10-30 13:57:24 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void dlgTriggerPatternEdit::applyThemePalette(const QPalette& editorPalette)
|
|
|
|
|
{
|
|
|
|
|
const QColor baseColor = editorPalette.color(QPalette::Base);
|
|
|
|
|
const QColor textColor = editorPalette.color(QPalette::Text);
|
|
|
|
|
|
|
|
|
|
if (!baseColor.isValid() || !textColor.isValid()) {
|
|
|
|
|
resetThemePalette();
|
2021-02-03 11:03:46 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
Improve: Reduce pattern lines in trigger editor (#8239)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Reduce blank pattern widget lines to only show used ones + 1. New
trigger start with two.
When you delete the last one, it reduces back to always used + 1 blank
Works good with import triggers and legacy multiple lines triggers.,
improves keyboard navigation:
modified order of tab navigation to go from name to patterns, then
continue,
add control+f to go first pattern line, and control+L last.. hint under
pattern lines
Up/down arrows to move between pattern lines
#### Motivation for adding to Mudlet
Enhanced tab navigation on the trigger editor menu , priority to useful
displays, etc.
better experiencie for screen readers users , less objects to navigate.
#### Other info (issues closed, discussion etc)
replace #8215
<img width="1860" height="681" alt="image"
src="https://github.com/user-attachments/assets/9bcc9cb4-dc52-4ff9-b4a1-0ad65dbb2e48"
/>
<img width="1825" height="825" alt="image"
src="https://github.com/user-attachments/assets/abc393f2-4ad3-4eac-9bdb-848c27dbc9e9"
/>
https://github.com/user-attachments/assets/69acf69e-15a2-4439-93da-ea98c39958c6
---------
Signed-off-by: SammerPetria <sammerpetria@gmail.com>
2025-10-30 13:57:24 -03:00
|
|
|
setPalette(editorPalette);
|
|
|
|
|
setAutoFillBackground(false);
|
|
|
|
|
|
|
|
|
|
auto applyToWidget = [&](QWidget* widget) {
|
|
|
|
|
if (!widget) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
widget->setPalette(editorPalette);
|
|
|
|
|
|
|
|
|
|
if (auto* spinBox = qobject_cast<QAbstractSpinBox*>(widget)) {
|
|
|
|
|
if (auto* lineEdit = spinBox->findChild<QLineEdit*>()) {
|
|
|
|
|
lineEdit->setPalette(editorPalette);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (auto* comboBox = qobject_cast<QComboBox*>(widget)) {
|
|
|
|
|
if (auto* view = comboBox->view()) {
|
|
|
|
|
view->setPalette(editorPalette);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (auto* button = qobject_cast<QAbstractButton*>(widget)) {
|
|
|
|
|
button->setAutoFillBackground(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (auto* plainTextEdit = qobject_cast<QPlainTextEdit*>(widget)) {
|
|
|
|
|
if (auto* viewport = plainTextEdit->viewport()) {
|
|
|
|
|
viewport->setPalette(editorPalette);
|
|
|
|
|
viewport->setAutoFillBackground(true);
|
|
|
|
|
}
|
|
|
|
|
} else if (auto* scrollArea = qobject_cast<QAbstractScrollArea*>(widget)) {
|
|
|
|
|
if (auto* viewport = scrollArea->viewport()) {
|
|
|
|
|
viewport->setPalette(editorPalette);
|
|
|
|
|
viewport->setAutoFillBackground(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
applyToWidget(label_colorIcon);
|
|
|
|
|
applyToWidget(label_patternNumber);
|
|
|
|
|
applyToWidget(label_prompt);
|
|
|
|
|
applyToWidget(comboBox_patternType);
|
|
|
|
|
applyToWidget(spinBox_lineSpacer);
|
|
|
|
|
applyToWidget(pushButton_fgColor);
|
|
|
|
|
applyToWidget(pushButton_bgColor);
|
|
|
|
|
applyToWidget(singleLineTextEdit_pattern);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void dlgTriggerPatternEdit::resetThemePalette()
|
|
|
|
|
{
|
|
|
|
|
setAutoFillBackground(false);
|
|
|
|
|
setPalette(mDefaultPalette);
|
|
|
|
|
|
|
|
|
|
label_patternNumber->setPalette(mDefaultPatternNumberPalette);
|
|
|
|
|
label_prompt->setPalette(mDefaultPromptPalette);
|
|
|
|
|
comboBox_patternType->setPalette(mDefaultComboPalette);
|
|
|
|
|
spinBox_lineSpacer->setPalette(mDefaultSpinPalette);
|
|
|
|
|
pushButton_fgColor->setPalette(mDefaultForegroundButtonPalette);
|
|
|
|
|
pushButton_bgColor->setPalette(mDefaultBackgroundButtonPalette);
|
|
|
|
|
singleLineTextEdit_pattern->setPalette(mDefaultPatternEditPalette);
|
|
|
|
|
|
|
|
|
|
if (auto* patternViewport = singleLineTextEdit_pattern->viewport()) {
|
|
|
|
|
patternViewport->setPalette(mDefaultPatternEditViewportPalette);
|
|
|
|
|
patternViewport->setAutoFillBackground(mDefaultPatternEditViewportAutoFillBackground);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (auto* spinBoxLineEdit = spinBox_lineSpacer->findChild<QLineEdit*>()) {
|
|
|
|
|
spinBoxLineEdit->setPalette(mDefaultSpinPalette);
|
2021-02-03 11:03:46 +01:00
|
|
|
}
|
Improve: Reduce pattern lines in trigger editor (#8239)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Reduce blank pattern widget lines to only show used ones + 1. New
trigger start with two.
When you delete the last one, it reduces back to always used + 1 blank
Works good with import triggers and legacy multiple lines triggers.,
improves keyboard navigation:
modified order of tab navigation to go from name to patterns, then
continue,
add control+f to go first pattern line, and control+L last.. hint under
pattern lines
Up/down arrows to move between pattern lines
#### Motivation for adding to Mudlet
Enhanced tab navigation on the trigger editor menu , priority to useful
displays, etc.
better experiencie for screen readers users , less objects to navigate.
#### Other info (issues closed, discussion etc)
replace #8215
<img width="1860" height="681" alt="image"
src="https://github.com/user-attachments/assets/9bcc9cb4-dc52-4ff9-b4a1-0ad65dbb2e48"
/>
<img width="1825" height="825" alt="image"
src="https://github.com/user-attachments/assets/abc393f2-4ad3-4eac-9bdb-848c27dbc9e9"
/>
https://github.com/user-attachments/assets/69acf69e-15a2-4439-93da-ea98c39958c6
---------
Signed-off-by: SammerPetria <sammerpetria@gmail.com>
2025-10-30 13:57:24 -03:00
|
|
|
|
|
|
|
|
if (auto* comboBoxView = comboBox_patternType->view()) {
|
|
|
|
|
comboBoxView->setPalette(mDefaultComboPalette);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pushButton_fgColor->setAutoFillBackground(false);
|
|
|
|
|
pushButton_bgColor->setAutoFillBackground(false);
|
2009-11-04 00:33:42 +01:00
|
|
|
}
|