mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-04-07 14:09:22 +08:00
Merge branch 'feature/launch-from-editor-window' into develop
This commit is contained in:
@ -422,8 +422,9 @@ li.menu-item {
|
||||
}
|
||||
|
||||
.cicon {
|
||||
padding: 3px 0 0 0;
|
||||
padding: 3px 0 0 10px;
|
||||
text-align: center;
|
||||
width: 55px;
|
||||
}
|
||||
|
||||
.cell-tools {
|
||||
|
||||
@ -578,8 +578,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;
|
||||
}
|
||||
}
|
||||
@ -594,9 +594,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));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,8 +326,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) ) {
|
||||
@ -857,7 +857,17 @@ void CAscApplicationManagerWrapper::startApp()
|
||||
}
|
||||
#endif
|
||||
|
||||
handleInputCmd(InputArgs::arguments());
|
||||
std::vector<std::wstring> 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();
|
||||
|
||||
@ -1030,7 +1040,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?"))) {
|
||||
|
||||
@ -166,7 +166,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");
|
||||
|
||||
@ -3,6 +3,9 @@
|
||||
#include "defines.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
|
||||
#define QSTRING_FROM_WSTR(s) QString::fromStdWString(s)
|
||||
@ -116,6 +119,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) {
|
||||
@ -129,8 +134,48 @@ 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
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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 QColor button_normal_opacity = QColor(255,255,255,255);
|
||||
@ -45,6 +47,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 QColor button_normal_opacity = QColor(255,255,255,255);
|
||||
@ -70,6 +74,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 QColor button_normal_opacity = QColor(255,255,255,200);
|
||||
@ -90,6 +96,8 @@ public:
|
||||
, ecrTabSlideActive
|
||||
, ecrTabSimpleActiveBackground
|
||||
, ecrTabSimpleActiveText
|
||||
, ecrTabDefaultActiveBackground
|
||||
, ecrTabDefaultActiveText
|
||||
};
|
||||
public:
|
||||
CThemes();
|
||||
@ -108,6 +116,11 @@ public:
|
||||
auto isCurrentDark() -> bool;
|
||||
auto isThemeDark(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;
|
||||
CThemesPrivate * m_priv = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user