improve layouts elements interaction in config

--use DoubleClick to change ShowInMenu
--dont change Activities when Activities combobox
loses focus, only when the user has really clicked
an element
--select user-set backgrounds properly when showing
the combobox backgrounds popup
pull/2/head
Michail Vourlakos 7 years ago
parent 55c373a9e1
commit 64f036dadd

@ -44,7 +44,12 @@ ActivityCmbBoxDelegate::ActivityCmbBoxDelegate(QObject *parent)
QWidget *ActivityCmbBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QComboBox *editor = new QComboBox(parent);
QComboBox *editor = new QComboBox(parent);
//! use focusPolicy as flag in order to update activities only when the user is clicking in the popup
//! it was the only way I found to communicate between the activated (const) signal and the
//! setEditorData (const) function
editor->setFocusPolicy(Qt::StrongFocus);
QStringList assignedActivities = index.model()->data(index, Qt::UserRole).toStringList();
QStringList availableActivities = m_settingsDialog->availableActivities();
@ -74,6 +79,7 @@ QWidget *ActivityCmbBoxDelegate::createEditor(QWidget *parent, const QStyleOptio
}
connect(editor, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), [ = ](int index) {
editor->setFocusPolicy(Qt::ClickFocus);
editor->clearFocus();
});
@ -98,6 +104,12 @@ void ActivityCmbBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *m
{
QComboBox *comboBox = static_cast<QComboBox *>(editor);
if (editor->focusPolicy() != Qt::ClickFocus) {
return;
}
editor->setFocusPolicy(Qt::StrongFocus);
QStringList assignedActivities = index.model()->data(index, Qt::UserRole).toStringList();
QString selectedActivity = comboBox->currentData().toString();

@ -61,7 +61,7 @@ bool CheckBoxDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, con
// return false;
// make sure that we have the right event type
if (event->type() == QEvent::MouseButtonRelease) {
if (event->type() == QEvent::MouseButtonDblClick) {
if (!option.rect.contains(static_cast<QMouseEvent *>(event)->pos()))
return false;
} else if (event->type() == QEvent::KeyPress) {

@ -107,7 +107,7 @@ void ColorCmbBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &inde
int pos = Colors.indexOf(value);
if (pos == -1 && value.startsWith("/")) {
comboBox->setCurrentIndex(Colors.count() - 1);
comboBox->setCurrentIndex(Colors.count());
} else {
comboBox->setCurrentIndex(Colors.indexOf(value));
}

Loading…
Cancel
Save