mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-30 05:06:14 -05:00
Fix connection selection being lost after renaming connection
This commit is contained in:
@@ -133,6 +133,32 @@ Connection *GetConnectionByName(const std::string &name)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::weak_ptr<Connection> GetWeakConnectionByName(const std::string &name)
|
||||
{
|
||||
for (const auto &c : switcher->connections) {
|
||||
if (c->Name() == name) {
|
||||
std::weak_ptr<Connection> wp =
|
||||
std::dynamic_pointer_cast<Connection>(c);
|
||||
return wp;
|
||||
}
|
||||
}
|
||||
return std::weak_ptr<Connection>();
|
||||
}
|
||||
|
||||
std::weak_ptr<Connection> GetWeakConnectionByQString(const QString &name)
|
||||
{
|
||||
return GetWeakConnectionByName(name.toStdString());
|
||||
}
|
||||
|
||||
std::string GetWeakConnectionName(std::weak_ptr<Connection> connection)
|
||||
{
|
||||
auto con = connection.lock();
|
||||
if (!con) {
|
||||
return "invalid connection selection";
|
||||
}
|
||||
return con->Name();
|
||||
}
|
||||
|
||||
bool ConnectionNameAvailable(const QString &name)
|
||||
{
|
||||
return !GetConnectionByName(name);
|
||||
@@ -187,6 +213,18 @@ void ConnectionSelection::SetConnection(const std::string &con)
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionSelection::SetConnection(
|
||||
const std::weak_ptr<Connection> &connection_)
|
||||
{
|
||||
const QSignalBlocker blocker(_selection);
|
||||
auto connection = connection_.lock();
|
||||
if (connection) {
|
||||
SetConnection(connection->Name());
|
||||
} else {
|
||||
_selection->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
ConnectionSettingsDialog::ConnectionSettingsDialog(QWidget *parent,
|
||||
const Connection &settings)
|
||||
: ItemSettingsDialog(settings, switcher->connections,
|
||||
|
||||
Reference in New Issue
Block a user