-
Notifications
You must be signed in to change notification settings - Fork 48
feat: add item move support and secret agent improvements #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -105,16 +105,10 @@ | |||||||||||||||||||||||||||||||||
| return (childPos < getChildrenNumber() ? m_children[childPos] : nullptr); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| int NetItemPrivate::getChildIndex(const NetItem *child) const | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| int index = 0; | ||||||||||||||||||||||||||||||||||
| for (auto it = m_children.cbegin(); it != m_children.cend(); it++, index++) { | ||||||||||||||||||||||||||||||||||
| if (*it == child) { | ||||||||||||||||||||||||||||||||||
| return index; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| return -1; | ||||||||||||||||||||||||||||||||||
| auto it = std::find(m_children.begin(), m_children.end(), child); | ||||||||||||||||||||||||||||||||||
| return it == m_children.end() ? -1 : it - m_children.begin(); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| bool NetItemPrivate::addChild(NetItemPrivate *child, int index) | ||||||||||||||||||||||||||||||||||
|
|
@@ -134,19 +128,35 @@ | |||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| void NetItemPrivate::removeChild(NetItemPrivate *child) | ||||||||||||||||||||||||||||||||||
| bool NetItemPrivate::removeChild(NetItemPrivate *child) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| int index = 0; | ||||||||||||||||||||||||||||||||||
| for (auto it = m_children.begin(); it != m_children.end(); it++, index++) { | ||||||||||||||||||||||||||||||||||
| if (*it == child->item()) { | ||||||||||||||||||||||||||||||||||
| Q_EMIT m_item->childAboutToBeRemoved(m_item, index); | ||||||||||||||||||||||||||||||||||
| m_children.erase(it); | ||||||||||||||||||||||||||||||||||
| child->m_parent = nullptr; | ||||||||||||||||||||||||||||||||||
| Q_EMIT m_item->childRemoved(child->item()); | ||||||||||||||||||||||||||||||||||
| Q_EMIT m_item->childrenChanged(); | ||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| auto it = std::find(m_children.begin(), m_children.end(), child->item()); | ||||||||||||||||||||||||||||||||||
| if (it == m_children.end()) { | ||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| Q_EMIT m_item->childAboutToBeRemoved(m_item, it - m_children.begin()); | ||||||||||||||||||||||||||||||||||
| m_children.erase(it); | ||||||||||||||||||||||||||||||||||
| child->m_parent = nullptr; | ||||||||||||||||||||||||||||||||||
| Q_EMIT m_item->childRemoved(child->item()); | ||||||||||||||||||||||||||||||||||
| Q_EMIT m_item->childrenChanged(); | ||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| bool NetItemPrivate::moveChild(NetItemPrivate *child, NetItemPrivate *newParent) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| if (!child || !newParent || child->m_parent == newParent->item()) { | ||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| auto it = std::find(m_children.begin(), m_children.end(), child->item()); | ||||||||||||||||||||||||||||||||||
| if (it == m_children.end()) { | ||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Q_EMIT m_item->childAboutToBeMoved(m_item, it - m_children.begin(), newParent->item(), newParent->getChildrenNumber()); | ||||||||||||||||||||||||||||||||||
| removeChild(child); | ||||||||||||||||||||||||||||||||||
| newParent->addChild(child); | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+155
to
+157
|
||||||||||||||||||||||||||||||||||
| Q_EMIT m_item->childAboutToBeMoved(m_item, it - m_children.begin(), newParent->item(), newParent->getChildrenNumber()); | |
| removeChild(child); | |
| newParent->addChild(child); | |
| const int oldIndex = static_cast<int>(it - m_children.begin()); | |
| const int newIndex = newParent->getChildrenNumber(); | |
| Q_EMIT m_item->childAboutToBeMoved(m_item, oldIndex, newParent->item(), newIndex); | |
| // Perform the move without emitting add/remove signals. | |
| m_children.erase(it); | |
| child->m_parent = newParent->item(); | |
| newParent->m_children.push_back(child->item()); | |
| // Notify both parents that their children collections changed. | |
| Q_EMIT m_item->childrenChanged(); | |
| Q_EMIT newParent->item()->childrenChanged(); |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -63,7 +63,11 @@ NetworkSecretAgent::NetworkSecretAgent(QObject *parent) | |||||||||
| : NetworkManager::SecretAgent(QStringLiteral("com.deepin.system.network.SecretAgent"), parent) | ||||||||||
| , m_callNextId(0) | ||||||||||
| , m_secretService(new SecretService(this)) | ||||||||||
| , m_waitClientTimer(new QTimer(this)) | ||||||||||
| { | ||||||||||
| m_waitClientTimer->setSingleShot(true); | ||||||||||
| m_waitClientTimer->setInterval(5000); | ||||||||||
| connect(m_waitClientTimer, &QTimer::timeout, this, &NetworkSecretAgent::waitClientTimeOut); | ||||||||||
| m_server = new QLocalServer(this); | ||||||||||
| connect(m_server, &QLocalServer::newConnection, this, &NetworkSecretAgent::newConnectionHandler); | ||||||||||
| m_server->setSocketOptions(QLocalServer::WorldAccessOption); | ||||||||||
|
|
@@ -203,24 +207,12 @@ void NetworkSecretAgent::askPasswords(SecretsRequest &request, const QStringList | |||||||||
| QString reqJSON = QJsonDocument(req).toJson(QJsonDocument::Compact); | ||||||||||
| qCDebug(DSM()) << "reqJSON:" << reqJSON; | ||||||||||
| request.inputCache = reqJSON.toUtf8(); | ||||||||||
| // 无线网密码拉起任务栏网络面板,其他使用密码输入弹窗 | ||||||||||
| if (connType == "802-11-wireless" && !m_clients.isEmpty()) { | ||||||||||
| for (auto &&client : m_clients) { | ||||||||||
| client->write("\nrequestSecrets:" + reqJSON.toUtf8() + "\n"); | ||||||||||
| } | ||||||||||
| if (connType == "802-11-wireless" && m_clients.isEmpty()) { | ||||||||||
| // 启动定时器,等待 | ||||||||||
| request.status = SecretsRequest::WaitClient; | ||||||||||
| m_waitClientTimer->start(); | ||||||||||
|
Comment on lines
+210
to
+213
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (bug_risk): A single shared wait timer for all wireless requests can lead to surprising behavior when multiple requests are pending Using a single Suggested implementation: request.inputCache = reqJSON.toUtf8();
// For wireless connections, only allow one request to be in WaitClient state at a time.
// If m_waitClientTimer is already active, we skip the wait and immediately fall back
// to the normal handling path to avoid starving earlier pending requests.
if (connType == "802-11-wireless" && m_clients.isEmpty() && !m_waitClientTimer->isActive()) {
// 启动定时器,等待
request.status = SecretsRequest::WaitClient;
m_waitClientTimer->start();
} else {
If you prefer true queuing (i.e. multiple wireless requests all going through a client-wait phase in order), you will need to:
|
||||||||||
| m_waitClientTimer->start(); | |
| if (!m_waitClientTimer->isActive()) { | |
| m_waitClientTimer->start(); | |
| } |
Uh oh!
There was an error while loading. Please reload this page.