diff --git a/src/ui/form/controls/clickablemenu.cpp b/src/ui/form/controls/clickablemenu.cpp index 42928a2c..5ac42c1b 100644 --- a/src/ui/form/controls/clickablemenu.cpp +++ b/src/ui/form/controls/clickablemenu.cpp @@ -9,9 +9,9 @@ ClickableMenu::ClickableMenu(QWidget *parent) : QMenu(parent) void ClickableMenu::mousePressEvent(QMouseEvent *event) { - QMenu::mousePressEvent(event); - m_pressed = true; + + QMenu::mousePressEvent(event); } void ClickableMenu::mouseReleaseEvent(QMouseEvent *event) diff --git a/src/ui/form/controls/lineedit.cpp b/src/ui/form/controls/lineedit.cpp index ef5298b9..021ccb0f 100644 --- a/src/ui/form/controls/lineedit.cpp +++ b/src/ui/form/controls/lineedit.cpp @@ -4,6 +4,12 @@ LineEdit::LineEdit(QWidget *parent) : QLineEdit(parent) { } +void LineEdit::setStartText(const QString &v) +{ + setText(v); + setCursorPosition(0); +} + bool LineEdit::event(QEvent *event) { switch (event->type()) { diff --git a/src/ui/form/controls/lineedit.h b/src/ui/form/controls/lineedit.h index 0a9ae2d7..78d40b67 100644 --- a/src/ui/form/controls/lineedit.h +++ b/src/ui/form/controls/lineedit.h @@ -10,6 +10,8 @@ class LineEdit : public QLineEdit public: explicit LineEdit(QWidget *parent = nullptr); + void setStartText(const QString &v); + bool event(QEvent *event) override; }; diff --git a/src/ui/form/prog/programeditdialog.cpp b/src/ui/form/prog/programeditdialog.cpp index e0f9b553..dd3b3b17 100644 --- a/src/ui/form/prog/programeditdialog.cpp +++ b/src/ui/form/prog/programeditdialog.cpp @@ -155,7 +155,7 @@ void ProgramEditDialog::initializePathField(bool isSingleSelection, bool isPathE void ProgramEditDialog::initializeNameField(bool isSingleSelection) { - m_editName->setText(isSingleSelection ? m_appRow.appName : QString()); + m_editName->setStartText(isSingleSelection ? m_appRow.appName : QString()); m_editName->setEnabled(isSingleSelection); m_editName->setClearButtonEnabled(isSingleSelection); @@ -177,7 +177,7 @@ void ProgramEditDialog::initializeRuleField(bool isSingleSelection) { VariantUtil::setUserData(m_editRuleName, m_appRow.ruleId); - m_editRuleName->setText(isSingleSelection ? m_appRow.ruleName : QString()); + m_editRuleName->setStartText(isSingleSelection ? m_appRow.ruleName : QString()); m_editRuleName->setEnabled(isSingleSelection); m_editRuleName->setClearButtonEnabled(isSingleSelection); @@ -717,7 +717,7 @@ void ProgramEditDialog::fillEditName() appName = IoC()->appName(appPath); } - m_editName->setText(appName); + m_editName->setStartText(appName); } bool ProgramEditDialog::save() @@ -860,7 +860,7 @@ void ProgramEditDialog::selectRuleDialog() connect(rulesDialog, &RulesWindow::ruleSelected, this, [&](const RuleRow &ruleRow) { VariantUtil::setUserData(m_editRuleName, ruleRow.ruleId); - m_editRuleName->setText(ruleRow.ruleName); + m_editRuleName->setStartText(ruleRow.ruleName); }); } diff --git a/src/ui/form/rule/ruleeditdialog.cpp b/src/ui/form/rule/ruleeditdialog.cpp index 4d47e1f3..9b401c9e 100644 --- a/src/ui/form/rule/ruleeditdialog.cpp +++ b/src/ui/form/rule/ruleeditdialog.cpp @@ -44,7 +44,7 @@ void RuleEditDialog::initialize(const RuleRow &ruleRow) retranslateUi(); - m_editName->setText(ruleRow.ruleName); + m_editName->setStartText(ruleRow.ruleName); m_editName->setClearButtonEnabled(true); m_labelEditNotes->setPixmap(IconCache::file(":/icons/script.png")); @@ -260,6 +260,7 @@ QLayout *RuleEditDialog::setupRuleSetHeaderLayout() { m_btAddPresetRule = ControlUtil::createFlatToolButton(":/icons/add.png", [&] { // TODO + m_ruleSetView->setVisible(true); }); m_btRemovePresetRule = ControlUtil::createFlatToolButton(":/icons/delete.png", [&] { // TODO diff --git a/src/ui/form/zone/zoneeditdialog.cpp b/src/ui/form/zone/zoneeditdialog.cpp index 9bdbc8dd..dbfb3314 100644 --- a/src/ui/form/zone/zoneeditdialog.cpp +++ b/src/ui/form/zone/zoneeditdialog.cpp @@ -38,7 +38,7 @@ void ZoneEditDialog::initialize(const ZoneRow &zoneRow) const QString sourceCode = isEmpty() ? ZoneSourceWrapper::textSourceCode() : zoneRow.sourceCode; const ZoneSourceWrapper zoneSource(zoneListModel()->zoneSourceByCode(sourceCode)); - m_editName->setText(zoneRow.zoneName); + m_editName->setStartText(zoneRow.zoneName); m_comboSources->setCurrentIndex(zoneSource.index()); m_cbEnabled->setChecked(zoneRow.enabled);