Sort list of placeholders and show tooltips. #193
This commit is contained in:
parent
de7239c53b
commit
86ee89414a
|
@ -89,6 +89,7 @@ DialogEditLabel::DialogEditLabel(const VAbstractPattern *doc, const VContainer *
|
||||||
InitPlaceholdersMenu();
|
InitPlaceholdersMenu();
|
||||||
|
|
||||||
m_placeholdersMenu->setStyleSheet(QStringLiteral("QMenu { menu-scrollable: 1; }"));
|
m_placeholdersMenu->setStyleSheet(QStringLiteral("QMenu { menu-scrollable: 1; }"));
|
||||||
|
m_placeholdersMenu->setToolTipsVisible(true);
|
||||||
ui->pushButtonInsert->setMenu(m_placeholdersMenu);
|
ui->pushButtonInsert->setMenu(m_placeholdersMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,15 +473,29 @@ void DialogEditLabel::SetupControls()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEditLabel::InitPlaceholdersMenu()
|
auto DialogEditLabel::SortedActions() const -> QMap<QString, QString>
|
||||||
{
|
{
|
||||||
|
QMap<QString, QString> sortedActions;
|
||||||
QChar per('%');
|
QChar per('%');
|
||||||
auto i = m_placeholders.constBegin();
|
auto i = m_placeholders.constBegin();
|
||||||
while (i != m_placeholders.constEnd())
|
while (i != m_placeholders.constEnd())
|
||||||
{
|
{
|
||||||
auto value = i.value();
|
sortedActions.insert(i.value().first, per + i.key() + per);
|
||||||
QAction *action = m_placeholdersMenu->addAction(value.first);
|
++i;
|
||||||
action->setData(per + i.key() + per);
|
}
|
||||||
|
return sortedActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogEditLabel::InitPlaceholdersMenu()
|
||||||
|
{
|
||||||
|
QMap<QString, QString> sortedActions = SortedActions();
|
||||||
|
auto i = sortedActions.constBegin();
|
||||||
|
while (i != sortedActions.constEnd())
|
||||||
|
{
|
||||||
|
QAction *action = m_placeholdersMenu->addAction(i.key());
|
||||||
|
action->setData(i.value());
|
||||||
|
action->setToolTip(i.value());
|
||||||
connect(action, &QAction::triggered, this, &DialogEditLabel::InsertPlaceholder);
|
connect(action, &QAction::triggered, this, &DialogEditLabel::InsertPlaceholder);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ private:
|
||||||
QMap<QString, QPair<QString, QString>> m_placeholders;
|
QMap<QString, QPair<QString, QString>> m_placeholders;
|
||||||
|
|
||||||
void SetupControls();
|
void SetupControls();
|
||||||
|
auto SortedActions() const -> QMap<QString, QString>;
|
||||||
void InitPlaceholdersMenu();
|
void InitPlaceholdersMenu();
|
||||||
void InitPlaceholders();
|
void InitPlaceholders();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user