Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/app/GUI/Expressions/expressiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,10 @@ QWidget *ExpressionDialog::setupPresetsUi()
mPresetsCombo->setFocusPolicy(Qt::ClickFocus);
mPresetsCombo->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Preferred);
mPresetsCombo->setToolTip(tr("Select a Preset from the list to fill Bindings, Definitions\n"
"and Calculate fields. In case there is no Preset available,\n"
"you can create a new one by clicking on the '+' button."));
const QString genericPresetTooltip = tr("Select a Preset from the list to fill Bindings, Definitions\n"
"and Calculate fields. In case there is no Preset available,\n"
"you can create a new one by clicking on the '+' button.");
mPresetsCombo->setToolTip(genericPresetTooltip);

const auto presetLabel = new QLabel(tr("Preset"), this);

Expand Down Expand Up @@ -759,13 +760,32 @@ QWidget *ExpressionDialog::setupPresetsUi()
fixLeaveEvent(mPresetsCombo);
});

const auto updatePresetTooltip = [this, genericPresetTooltip](int index) {
const QString id = mPresetsCombo->itemData(index).toString();
if (id.isEmpty()) {
mPresetsCombo->setToolTip(genericPresetTooltip);
return;
}
const QString header = "Preset description:";
const auto expr = mSettings->fExpressions.getExpr(id);
const QString separator = QString(20, '-');
mPresetsCombo->setToolTip(QString("%1\n%2\n\n%3\n\n%4")
.arg(header,
expr.description,
separator,
genericPresetTooltip));
};

connect(mPresetsCombo,
QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this](int index) {
this, [this, updatePresetTooltip](int index) {
const QString id = mPresetsCombo->itemData(index).toString();
if (!id.isEmpty()) { applyPreset(id); }
updatePresetTooltip(index);
});

updatePresetTooltip(mPresetsCombo->currentIndex());

connect(editPresetBtn,
&QPushButton::released,
this, [this]() {
Expand Down