From c4bf81c2a9f82ec063bc023c55497d5f5f0f7dbd Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Fri, 27 Oct 2023 12:55:57 +0300 Subject: [PATCH 1/2] [win-nix] added command to change portal's tab color --- win-linux/src/ccefeventstransformer.cpp | 3 +++ win-linux/src/components/asctabwidget.cpp | 14 ++++++------- win-linux/src/components/asctabwidget.h | 2 +- win-linux/src/windows/cmainwindow.cpp | 24 +++++++++++++++++++---- win-linux/src/windows/cmainwindow.h | 1 + 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/win-linux/src/ccefeventstransformer.cpp b/win-linux/src/ccefeventstransformer.cpp index 59c33a11f..ae662429e 100644 --- a/win-linux/src/ccefeventstransformer.cpp +++ b/win-linux/src/ccefeventstransformer.cpp @@ -210,6 +210,9 @@ void CCefEventsTransformer::OnEvent(QObject * target, NSEditorApi::CAscCefMenuEv // if ( !(cmd.find(L"files:check") == std::wstring::npos) ) { // QMetaObject::invokeMethod( target, "onLocalFilesCheck", Qt::QueuedConnection, // Q_ARG(QString, QString::fromStdWString(pData->get_Param())) ); + if ( cmd.compare(L"portal:uitheme") == 0 ) { + QMetaObject::invokeMethod(target, "onPortalUITheme", Qt::QueuedConnection, Q_ARG(std::wstring, pData->get_Param())); + } else if ( !(cmd.find(L"files:explore") == std::wstring::npos) ) { QMetaObject::invokeMethod( target, "onLocalFileLocation", Qt::QueuedConnection, Q_ARG(QString, QString::fromStdWString(pData->get_Param())) ); diff --git a/win-linux/src/components/asctabwidget.cpp b/win-linux/src/components/asctabwidget.cpp index ca9a21346..e4207de5e 100644 --- a/win-linux/src/components/asctabwidget.cpp +++ b/win-linux/src/components/asctabwidget.cpp @@ -513,15 +513,15 @@ void CAscTabWidget::setTabActiveColor(int index, const std::wstring& color) { } -void CAscTabWidget::setTabThemeType(int index, const QString& type) +void CAscTabWidget::setTabTheme(int index, const QString& type, const QString& color) { if ( !(index < 0) && index < count() ) { - if ( type == "dark" ) { - m_pBar->setActiveTabColor(index, "#333"); - m_pBar->setTabThemeType(index, CTabBar::DarkTab); - } else { - m_pBar->setActiveTabColor(index, "#fff"); - m_pBar->setTabThemeType(index, CTabBar::LightTab); + if ( !type.isEmpty() ) { + m_pBar->setTabThemeType(index, type == "dark" ? CTabBar::DarkTab : CTabBar::LightTab); + } + + if ( !color.isEmpty() ) { + m_pBar->setActiveTabColor(index, color); } } } diff --git a/win-linux/src/components/asctabwidget.h b/win-linux/src/components/asctabwidget.h index bdaa57da1..50a8cdd44 100644 --- a/win-linux/src/components/asctabwidget.h +++ b/win-linux/src/components/asctabwidget.h @@ -184,7 +184,7 @@ class CAscTabWidget : public QStackedWidget, public CScalingWrapper void setTabIcons(CTabIconSet&); void reloadTabIcons(); void setTabActiveColor(int index, const std::wstring& color); - void setTabThemeType(int index, const QString& type); + void setTabTheme(int index, const QString& type, const QString& color); void setFocusedView(int index = -1); void setFullScreen(bool, int id = -1); QWidget * fullScreenWidget(); diff --git a/win-linux/src/windows/cmainwindow.cpp b/win-linux/src/windows/cmainwindow.cpp index 9daf52c7d..9e22d95c4 100644 --- a/win-linux/src/windows/cmainwindow.cpp +++ b/win-linux/src/windows/cmainwindow.cpp @@ -697,11 +697,27 @@ void CMainWindow::onPortalLogin(int viewid, const std::wstring &json) if( jerror.error == QJsonParseError::NoError ) { QJsonObject objRoot = jdoc.object(); QString _ui_theme = objRoot["uiTheme"].toString(); - if ( !_ui_theme.isEmpty() ) { -// onFileLocation(vid, _url); - if ( _ui_theme == "default-dark" ) - m_pTabs->setTabThemeType(m_pTabs->tabIndexByView(viewid), "dark"); + if ( !_ui_theme.isEmpty() ) + onPortalUITheme(viewid, _ui_theme.toStdWString()); + } + } +} + +void CMainWindow::onPortalUITheme(int viewid, const std::wstring& json) +{ + if ( !json.empty() ) { + if ( json.rfind(L"default-", 0) == 0 ) { + if ( json.compare(L"default-dark") == 0 ) + m_pTabs->setTabTheme(m_pTabs->tabIndexByView(viewid), "dark", "#333"); + else m_pTabs->setTabTheme(m_pTabs->tabIndexByView(viewid), "light", "#fff"); + } else { + QJsonParseError jerror; + QJsonDocument jdoc = QJsonDocument::fromJson(QString::fromStdWString(json).toLatin1(), &jerror); + + if( jerror.error == QJsonParseError::NoError ) { + QJsonObject objRoot = jdoc.object(); + m_pTabs->setTabTheme(m_pTabs->tabIndexByView(viewid), objRoot["type"].toString(), objRoot["color"].toString()); } } } diff --git a/win-linux/src/windows/cmainwindow.h b/win-linux/src/windows/cmainwindow.h index 0f826a69b..77e04e2c7 100644 --- a/win-linux/src/windows/cmainwindow.h +++ b/win-linux/src/windows/cmainwindow.h @@ -137,6 +137,7 @@ public slots: void onPortalOpen(QString); void onPortalLogout(std::wstring portal); void onPortalLogin(int viewid, const std::wstring& json); + void onPortalUITheme(int viewid, const std::wstring& json); void onPortalNew(QString); void onPortalCreate(); void onOutsideAuth(QString); From 2dbb61dfdc18028ab3352dc43bde0549a890abe8 Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Tue, 31 Oct 2023 21:26:23 +0300 Subject: [PATCH 2/2] [win-nix] fix bug 64479 --- win-linux/src/casctabdata.cpp | 3 +++ win-linux/src/windows/ceditorwindow_p.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/win-linux/src/casctabdata.cpp b/win-linux/src/casctabdata.cpp index b524da9a9..e3309c043 100644 --- a/win-linux/src/casctabdata.cpp +++ b/win-linux/src/casctabdata.cpp @@ -176,6 +176,9 @@ void CAscTabData::setFeatures(const wstring& fs) if ( _str_readonly.isEmpty() ) _str_readonly = " (" + QObject::tr("Read only") + ")"; + } else + if ( hasFeature(L"readonly\":false") ) { + _is_readonly = false; } } diff --git a/win-linux/src/windows/ceditorwindow_p.h b/win-linux/src/windows/ceditorwindow_p.h index 7c4a0f16a..f809ebf78 100644 --- a/win-linux/src/windows/ceditorwindow_p.h +++ b/win-linux/src/windows/ceditorwindow_p.h @@ -769,7 +769,7 @@ class CEditorWindowPrivate : public CCefEventsGate iconCrypted(); } - if ( is_read_only != panel()->data()->hasFeature(L"readonly\":") && boxtitlelabel ) { + if ( is_read_only != panel()->data()->hasFeature(L"readonly\":true") && boxtitlelabel ) { window->setWindowTitle(m_panel->data()->title()); window->m_boxTitleBtns->repaint(); }