diff --git a/lib/utils/action-queue.cpp b/lib/utils/action-queue.cpp index f228a81e..2ed761ad 100644 --- a/lib/utils/action-queue.cpp +++ b/lib/utils/action-queue.cpp @@ -239,13 +239,11 @@ static bool AskForSettingsWrapper(QWidget *parent, Item &settings) void ActionQueueSelection::SetActionQueue( const std::weak_ptr &queue_) { - const QSignalBlocker blocker(_selection); auto queue = queue_.lock(); if (queue) { - _selection->setCurrentText( - QString::fromStdString(queue->Name())); + SetItem(queue->Name()); } else { - _selection->setCurrentIndex(-1); + SetItem(""); } } diff --git a/lib/utils/item-selection-helpers.cpp b/lib/utils/item-selection-helpers.cpp index 47358674..f7b23e1b 100644 --- a/lib/utils/item-selection-helpers.cpp +++ b/lib/utils/item-selection-helpers.cpp @@ -88,9 +88,12 @@ ItemSelection::ItemSelection(std::deque> &items, void ItemSelection::SetItem(const std::string &item) { - const QSignalBlocker blocker(_selection); if (!!GetItemByName(item, _items)) { _selection->setCurrentText(QString::fromStdString(item)); + if (_selection->lineEdit()) { + _selection->lineEdit()->setText( + QString::fromStdString(item)); + } } else { _selection->setCurrentIndex(-1); } @@ -111,7 +114,6 @@ void ItemSelection::ChangeSelection(const QString &sel) return; } _items.emplace_back(item); - const QSignalBlocker b(_selection); const QString name = QString::fromStdString(item->_name); AddItem(name); _selection->setCurrentText(name); @@ -195,6 +197,7 @@ void ItemSelection::RenameItem() const auto oldName = item->_name; item->_name = name; + SetItem(name); emit ItemRenamed(QString::fromStdString(oldName), QString::fromStdString(name)); } @@ -205,7 +208,11 @@ void ItemSelection::RenameItem(const QString &oldName, const QString &name) if (idx == -1) { return; } + auto currentText = _selection->currentText(); _selection->setItemText(idx, name); + if (oldName == currentText) { + SetItem(name.toStdString()); + } } void ItemSelection::AddItem(const QString &name) @@ -240,9 +247,10 @@ void ItemSelection::RemoveItem() void ItemSelection::RemoveItem(const QString &name) { + auto currentText = _selection->currentText(); const int idx = _selection->findText(name); - if (idx == _selection->currentIndex()) { - _selection->setCurrentIndex(-1); + if (currentText == name) { + SetItem(""); } _selection->removeItem(idx); } diff --git a/lib/utils/item-selection-helpers.hpp b/lib/utils/item-selection-helpers.hpp index 709dbac2..fe5aaeb6 100644 --- a/lib/utils/item-selection-helpers.hpp +++ b/lib/utils/item-selection-helpers.hpp @@ -95,7 +95,7 @@ signals: void ItemRemoved(const QString &); void ItemRenamed(const QString &oldName, const QString &name); -protected: +private: Item *GetCurrentItem(); FilterComboBox *_selection; diff --git a/lib/variables/variable.cpp b/lib/variables/variable.cpp index b6c64054..1aefc275 100644 --- a/lib/variables/variable.cpp +++ b/lib/variables/variable.cpp @@ -285,22 +285,20 @@ VariableSelection::VariableSelection(QWidget *parent) void VariableSelection::SetVariable(const std::string &variable) { - const QSignalBlocker blocker(_selection); if (!!GetVariableByName(variable)) { - _selection->setCurrentText(QString::fromStdString(variable)); + SetItem(variable); } else { - _selection->setCurrentIndex(-1); + SetItem(""); } } void VariableSelection::SetVariable(const std::weak_ptr &variable_) { - const QSignalBlocker blocker(_selection); auto var = variable_.lock(); if (var) { - SetVariable(var->Name()); + SetItem(var->Name()); } else { - _selection->setCurrentIndex(-1); + SetItem(""); } } diff --git a/plugins/base/utils/connection-manager.cpp b/plugins/base/utils/connection-manager.cpp index 485e1cdc..30dfcb7c 100644 --- a/plugins/base/utils/connection-manager.cpp +++ b/plugins/base/utils/connection-manager.cpp @@ -298,23 +298,21 @@ ConnectionSelection::ConnectionSelection(QWidget *parent) void ConnectionSelection::SetConnection(const std::string &con) { - const QSignalBlocker blocker(_selection); if (!!GetConnectionByName(con)) { - _selection->setCurrentText(QString::fromStdString(con)); + SetItem(con); } else { - _selection->setCurrentIndex(-1); + SetItem(""); } } void ConnectionSelection::SetConnection( const std::weak_ptr &connection_) { - const QSignalBlocker blocker(_selection); auto connection = connection_.lock(); if (connection) { - SetConnection(connection->Name()); + SetItem(connection->Name()); } else { - _selection->setCurrentIndex(-1); + SetItem(""); } } diff --git a/plugins/twitch/token.cpp b/plugins/twitch/token.cpp index b1dc2de4..f11c32ba 100644 --- a/plugins/twitch/token.cpp +++ b/plugins/twitch/token.cpp @@ -397,23 +397,21 @@ TwitchConnectionSelection::TwitchConnectionSelection(QWidget *parent) void TwitchConnectionSelection::SetToken(const std::string &token) { - const QSignalBlocker blocker(_selection); if (!!GetTwitchTokenByName(token)) { - _selection->setCurrentText(QString::fromStdString(token)); + SetItem(token); } else { - _selection->setCurrentIndex(-1); + SetItem(""); } } void TwitchConnectionSelection::SetToken( const std::weak_ptr &token_) { - const QSignalBlocker blocker(_selection); auto token = token_.lock(); if (token) { - SetToken(token->Name()); + SetItem(token->Name()); } else { - _selection->setCurrentIndex(-1); + SetItem(""); } }