Merge pull request 'Fix bug 58026' (#205) from fix/bug-58026 into develop

Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/desktop-apps/pulls/205
This commit is contained in:
Oleg Kozhukharenko
2025-02-25 12:30:28 +00:00
6 changed files with 20 additions and 7 deletions

View File

@ -217,11 +217,8 @@ public:
opts.parent_id = event.m_nSenderId;
opts.name = QString::fromStdWString(data.get_Name());
// TODO: remove for ver 8.2 if unused
// if ( CCefView * _v = m_appmanager.GetViewById(opts.id) ) {
// bringEditorToFront(_v->GetId());
// } else openDocument(opts);
openDocument(opts);
if ( !bringEditorToFront(QString::fromStdWString(opts.wurl)) )
openDocument(opts);
return true;
}

View File

@ -680,7 +680,7 @@ int CAscTabWidget::tabIndexByUrl(const wstring& url)
for (int i(count()); !(--i < 0);) {
doc = panel(i)->data();
if (doc && doc->url().compare(url) == 0)
if (doc && Utils::normalizeAppProtocolUrl(doc->url()).compare(Utils::normalizeAppProtocolUrl(url)) == 0)
return i;
}
}

View File

@ -66,6 +66,7 @@
#define APP_DEFAULT_SYSTEM_LOCALE 1
#define APP_USER_MODEL_ID "ASC.Documents.5"
#define APP_SIMPLE_WINDOW_TITLE "ONLYOFFICE Editor"
#define APP_PROTOCOL "oo-office"
#define FILE_PREFIX "onlyoffice_"
#define URL_SITE "http://www.onlyoffice.com"

View File

@ -42,6 +42,7 @@
#include <QApplication>
#include <QDesktopWidget>
#include <QUrl>
#include <QUrlQuery>
#include <QJsonDocument>
#include <QJsonObject>
#include <QScreen>
@ -856,6 +857,18 @@ QString Utils::replaceBackslash(const QString& path)
return QString(path).replace(QRegularExpression("\\\\"), "/");
}
std::wstring Utils::normalizeAppProtocolUrl(const std::wstring &url)
{
QUrl _url(QString::fromStdWString(url));
if (_url.scheme() == APP_PROTOCOL) {
QUrlQuery query(_url);
query.addQueryItem("placement", "desktop");
_url.setQuery(query);
return _url.toString(QUrl::RemoveScheme).toStdWString();
}
return url;
}
void Utils::replaceAll(std::wstring& subject, const std::wstring& search, const std::wstring& replace)
{
size_t pos = 0;

View File

@ -103,6 +103,7 @@ public:
static double getScreenDpiRatioByWidget(QWidget*);
static QScreen * screenAt(const QPoint&);
static QString replaceBackslash(const QString&);
static std::wstring normalizeAppProtocolUrl(const std::wstring &url);
static void replaceAll(std::wstring& subject, const std::wstring& search, const std::wstring& replace);
static bool isFileLocal(const QString&);
static QString uniqFileName(const QString& path);

View File

@ -164,7 +164,8 @@ bool CEditorWindow::modified() const
bool CEditorWindow::holdView(const std::wstring& portal) const
{
return qobject_cast<CTabPanel *>(m_pMainView)->data()->url().find(portal) != std::wstring::npos;
auto url = qobject_cast<CTabPanel*>(m_pMainView)->data()->url();
return Utils::normalizeAppProtocolUrl(url).find(Utils::normalizeAppProtocolUrl(portal)) != std::wstring::npos;
}
void CEditorWindow::undock(bool maximized)