From d3f793bf262f4ed714d83b83f533fcfe304aebf5 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Fri, 11 Jun 2021 23:18:52 +0300 Subject: [PATCH 1/6] [start page] changed icon's alignment on page 'connect' --- common/loginpage/src/styles.less | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/loginpage/src/styles.less b/common/loginpage/src/styles.less index 29ca17a96..7b432c85f 100644 --- a/common/loginpage/src/styles.less +++ b/common/loginpage/src/styles.less @@ -409,8 +409,9 @@ li.menu-item { } .cicon { - padding: 3px 0 0 0; + padding: 3px 0 0 10px; text-align: center; + width: 55px; } .cell-tools { From dc8ad21db433d069cd0b1f6cfe2c0b59cfc243cf Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 16 Jun 2021 15:51:59 +0300 Subject: [PATCH 2/6] [win-nix] extended theme info parsing --- .../src/cascapplicationmanagerwrapper.cpp | 4 ++-- win-linux/src/cthemes.cpp | 20 +++++++++++++++++++ win-linux/src/cthemes.h | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/win-linux/src/cascapplicationmanagerwrapper.cpp b/win-linux/src/cascapplicationmanagerwrapper.cpp index 7f8876c82..874afabfc 100644 --- a/win-linux/src/cascapplicationmanagerwrapper.cpp +++ b/win-linux/src/cascapplicationmanagerwrapper.cpp @@ -327,8 +327,8 @@ bool CAscApplicationManagerWrapper::processCommonEvent(NSEditorApi::CAscCefMenuE mainWindow()->mainPanel()->createLocalFile(AscAppManager::newFileName(_f), _f); return true; } else - if ( !(cmd.find(L"theme:changed") == std::wstring::npos) ) { - applyTheme(pData->get_Param()); + if ( !(cmd.find(L"uitheme:changed") == std::wstring::npos) ) { + applyTheme( themes().parseThemeName(pData->get_Param()) ); return true; } else if ( !(cmd.find(L"files:check") == std::wstring::npos) ) { diff --git a/win-linux/src/cthemes.cpp b/win-linux/src/cthemes.cpp index bd482a354..8e4f8dcfe 100644 --- a/win-linux/src/cthemes.cpp +++ b/win-linux/src/cthemes.cpp @@ -3,6 +3,8 @@ #include "defines.h" #include +#include +#include #include #define QSTRING_FROM_WSTR(s) QString::fromStdWString(s) @@ -124,3 +126,21 @@ auto CThemes::value(const std::wstring& theme, ColorRole r) -> std::wstring return L""; } + +auto CThemes::parseThemeName(const std::wstring& wjson) -> std::wstring +{ + size_t pos = wjson.find(L"name\":"); // check if json in params + if ( pos != std::wstring::npos ) { + QJsonParseError jerror; + QByteArray stringdata = QString::fromStdWString(wjson).toUtf8(); + QJsonDocument jdoc = QJsonDocument::fromJson(stringdata, &jerror); + + if( jerror.error == QJsonParseError::NoError ) { + QJsonObject obj = jdoc.object(); + + return obj.contains("name") ? obj["name"].toString().toStdWString() : NSThemeClassicLight::theme_id; + } + } + + return wjson; +} diff --git a/win-linux/src/cthemes.h b/win-linux/src/cthemes.h index 87b26c254..a27920a6c 100644 --- a/win-linux/src/cthemes.h +++ b/win-linux/src/cthemes.h @@ -103,6 +103,7 @@ public: auto setCurrent(const std::wstring&) -> void; auto isCurrent(const std::wstring& name) -> bool; + auto parseThemeName(const std::wstring&) -> std::wstring; private: class CThemesPrivate; CThemesPrivate * m_priv = nullptr; From 234fedf9cf5882ff4acff90e5706c45f18bcf48d Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Fri, 18 Jun 2021 00:10:11 +0300 Subject: [PATCH 3/6] [win-nix] changed start color for new tab --- win-linux/src/asctabwidget.cpp | 10 +++++----- win-linux/src/cthemes.cpp | 25 +++++++++++++++++++++++++ win-linux/src/cthemes.h | 12 ++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/win-linux/src/asctabwidget.cpp b/win-linux/src/asctabwidget.cpp index ad4e0f595..ab6f092a5 100644 --- a/win-linux/src/asctabwidget.cpp +++ b/win-linux/src/asctabwidget.cpp @@ -572,8 +572,8 @@ void CAscTabWidget::updateTabIcon(int index) break; default: tab_type = etUndefined; - active_tab_color = QString::fromStdWString(AscAppManager::themes().value(theme_name, CThemes::ColorRole::ecrTabSimpleActiveBackground)); - tab_theme = CTabBar::LightTab; + active_tab_color = QString::fromStdWString(AscAppManager::themes().value(theme_name, CThemes::ColorRole::ecrTabDefaultActiveBackground)); + tab_theme = AscAppManager::themes().isColorDark(active_tab_color) ? CTabBar::DarkTab : CTabBar::LightTab; break; } } @@ -588,9 +588,9 @@ void CAscTabWidget::updateTabIcon(int index) tabbar.setActiveTabColor(active_tab_color); // ((CTabBar *)tabBar())->setUseTabCustomPalette( !(tab_type == etPortal || tab_type == etUndefined) ); - if ( tab_type == etPortal || tab_type == etNewPortal || tab_type == etUndefined ) - tabbar.setTabTextColor(QPalette::Active, AscAppManager::themes().color(theme_name, CThemes::ColorRole::ecrTabSimpleActiveText)); - else tabbar.setTabTextColor(QPalette::Active, AscAppManager::themes().color(theme_name, CThemes::ColorRole::ecrTextPressed)); + tabbar.setTabTextColor(QPalette::Active, AscAppManager::themes().isColorDark(active_tab_color) ? + AscAppManager::themes().color(theme_name, CThemes::ColorRole::ecrTextPressed) : + AscAppManager::themes().color(theme_name, CThemes::ColorRole::ecrTabSimpleActiveText)); } } diff --git a/win-linux/src/cthemes.cpp b/win-linux/src/cthemes.cpp index 8e4f8dcfe..4da0e957f 100644 --- a/win-linux/src/cthemes.cpp +++ b/win-linux/src/cthemes.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #define QSTRING_FROM_WSTR(s) QString::fromStdWString(s) @@ -108,6 +109,8 @@ auto CThemes::value(const std::wstring& theme, ColorRole r) -> std::wstring case ColorRole::ecrTabSlideActive: return NSThemeDark::color_brand_slide; case ColorRole::ecrTabSimpleActiveBackground: return NSThemeDark::color_tab_simple_active_background; case ColorRole::ecrTabSimpleActiveText: return NSThemeDark::color_tab_simple_active_text; + case ColorRole::ecrTabDefaultActiveBackground: return NSThemeDark::color_tab_default_active_background; + case ColorRole::ecrTabDefaultActiveText: return NSThemeDark::color_tab_default_active_text; } } else { switch (r) { @@ -121,12 +124,34 @@ auto CThemes::value(const std::wstring& theme, ColorRole r) -> std::wstring case ColorRole::ecrTabSlideActive: return NSThemeLight::color_brand_slide; case ColorRole::ecrTabSimpleActiveBackground: return NSThemeLight::color_tab_simple_active_background; case ColorRole::ecrTabSimpleActiveText: return NSThemeLight::color_tab_simple_active_text; + case ColorRole::ecrTabDefaultActiveBackground: return NSThemeLight::color_tab_default_active_background; + case ColorRole::ecrTabDefaultActiveText: return NSThemeLight::color_tab_default_active_text; } } return L""; } +auto CThemes::isColorDark(ColorRole role) -> bool +{ + return isColorDark(value(role)); +} + +auto CThemes::isColorDark(const std::wstring& color) -> bool +{ + return isColorDark(QString::fromStdWString(color)); +} + +auto CThemes::isColorDark(const QString& color) -> bool +{ + int r, g, b; + QColor(color).getRgb(&r, &g, &b); + + int luma = int(0.2126f * r) + int(0.7152f * g) + int(0.0722f * b); + + return luma < 128; +} + auto CThemes::parseThemeName(const std::wstring& wjson) -> std::wstring { size_t pos = wjson.find(L"name\":"); // check if json in params diff --git a/win-linux/src/cthemes.h b/win-linux/src/cthemes.h index a27920a6c..f7b41ca1d 100644 --- a/win-linux/src/cthemes.h +++ b/win-linux/src/cthemes.h @@ -23,6 +23,8 @@ namespace NSThemeLight { static const std::wstring color_tab_active_background = L"#fff"; static const std::wstring color_tab_simple_active_background = L"#fff"; static const std::wstring color_tab_simple_active_text = L"#444"; + static const std::wstring color_tab_default_active_background = L"#fff"; + static const std::wstring color_tab_default_active_text = L"#444"; static const std::wstring color_tab_divider = L"#a5a5a5"; static const std::wstring color_logo = L"dark"; @@ -44,6 +46,8 @@ namespace NSThemeClassicLight { static const std::wstring color_tab_active_background = L"#fff"; static const std::wstring color_tab_simple_active_background = L"#fff"; static const std::wstring color_tab_simple_active_text = L"#444"; + static const std::wstring color_tab_default_active_background = L"#fff"; + static const std::wstring color_tab_default_active_text = L"#444"; static const std::wstring color_tab_divider = L"#a5a5a5"; static const std::wstring color_logo = L"dark"; @@ -68,6 +72,8 @@ namespace NSThemeDark { static const std::wstring color_tab_active_background = L"#333"; static const std::wstring color_tab_simple_active_background = L"#fff"; static const std::wstring color_tab_simple_active_text = L"#444"; + static const std::wstring color_tab_default_active_background = L"#333"; + static const std::wstring color_tab_default_active_text = L"#fff"; static const std::wstring color_tab_divider = L"#505050"; static const std::wstring color_logo = L"light"; @@ -87,6 +93,8 @@ public: , ecrTabSlideActive , ecrTabSimpleActiveBackground , ecrTabSimpleActiveText + , ecrTabDefaultActiveBackground + , ecrTabDefaultActiveText }; public: CThemes(); @@ -103,6 +111,10 @@ public: auto setCurrent(const std::wstring&) -> void; auto isCurrent(const std::wstring& name) -> bool; + auto isColorDark(ColorRole) -> bool; + auto isColorDark(const std::wstring&) -> bool; + auto isColorDark(const QString&) -> bool; + auto parseThemeName(const std::wstring&) -> std::wstring; private: class CThemesPrivate; From d1c3bb486baee96662826a8461fc98328bf47eb4 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 23 Jun 2021 00:04:12 +0300 Subject: [PATCH 4/6] [win-nix] show "Home" button in editor's window title bar --- win-linux/src/ceditorwindow_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win-linux/src/ceditorwindow_p.h b/win-linux/src/ceditorwindow_p.h index 93aa529e1..6d93bcfad 100644 --- a/win-linux/src/ceditorwindow_p.h +++ b/win-linux/src/ceditorwindow_p.h @@ -164,7 +164,8 @@ public: leftboxbuttons->layout()->setSpacing(0); leftboxbuttons->layout()->setMargin(0); - if ( false && !InputArgs::contains(L"--single-window-app") ) { +// if ( false && !InputArgs::contains(L"--single-window-app") ) + { CSVGPushButton * btnHome = new CSVGPushButton; btnHome->setProperty("class", "normal"); btnHome->setProperty("act", "tool"); From 18384496f3d4c8b76c03434421632da8d8fbf27b Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 23 Jun 2021 00:06:35 +0300 Subject: [PATCH 5/6] [win-nix] close "Main" window independently editor's window --- win-linux/src/cascapplicationmanagerwrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win-linux/src/cascapplicationmanagerwrapper.cpp b/win-linux/src/cascapplicationmanagerwrapper.cpp index 874afabfc..d1b3b6165 100644 --- a/win-linux/src/cascapplicationmanagerwrapper.cpp +++ b/win-linux/src/cascapplicationmanagerwrapper.cpp @@ -1004,7 +1004,7 @@ void CAscApplicationManagerWrapper::closeMainWindow() APP_CAST(_app) if ( _app.m_pMainWindow ) { - if ( false && !_app.m_vecEditors.empty() ) { + if ( /*false &&*/ !_app.m_vecEditors.empty() ) { CMessage m(mainWindow()->handle(), CMessageOpts::moButtons::mbYesNo); m.setButtons({"Close all", "Current only", "Cancel"}); switch (m.warning(tr("Do you want to close all editor windows?"))) { From 26f30947b4d47fc3f91b2ba67812f7a7dd890e3a Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 23 Jun 2021 00:07:47 +0300 Subject: [PATCH 6/6] [win-nix] open new doc editor's window if no args --- win-linux/src/cascapplicationmanagerwrapper.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/win-linux/src/cascapplicationmanagerwrapper.cpp b/win-linux/src/cascapplicationmanagerwrapper.cpp index d1b3b6165..c38487943 100644 --- a/win-linux/src/cascapplicationmanagerwrapper.cpp +++ b/win-linux/src/cascapplicationmanagerwrapper.cpp @@ -831,7 +831,17 @@ void CAscApplicationManagerWrapper::startApp() } #endif - handleInputCmd(InputArgs::arguments()); + std::vector in_args{InputArgs::arguments()}; + bool open_in_new_window = std::find(in_args.begin(), in_args.end(), L"--force-use-window") != std::end(in_args); + bool files_in_args = std::find_if(in_args.begin(), in_args.end(), + [](const std::wstring& arg){ + return arg.rfind(L"--", 0); + }) != std::end(in_args); + if ( !files_in_args && open_in_new_window ) { + in_args.push_back(L"--new:word"); + } + + handleInputCmd(in_args); if ( _app.m_vecEditors.empty() && !_app.m_pMainWindow ) { // _app.m_private->createStartPanel();