[win-linux] add feature: RTL mode

This commit is contained in:
SimplestStudio
2023-12-20 10:35:29 +02:00
parent 581b0271f6
commit c9f20a073d
43 changed files with 325 additions and 26 deletions

View File

@ -93,8 +93,10 @@ QPushButton#toolButtonMain {
font-size: 10px;
font-family: 'Open Sans',sans-serif;
font-weight: bold;
border-left: 0px;
border-right: 1px solid #f1f1f1;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-right: 0px; border-left: 1px solid #f1f1f1;}
/*QPushButton#toolButtonMain[theme=light] {*/
/* border: 1px solid #b6b6b6;*/
@ -117,8 +119,9 @@ QPushButton#toolButtonMain[class=normal],
QPushButton#toolButtonMain[class=normal]
{
background: #f1f1f1;
border-right-color: #dfdfdf;
border-color: #dfdfdf;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain[class=normal] {border-color: #dfdfdf;}
QPushButton#toolButtonMain[class=normal]:hover {
background: #cecece;
@ -145,7 +148,8 @@ QPushButton::menu-indicator {width: 0px; height: 0px;}
/*border-image: url(:/res/icons/menu-indicator-dark.png) 0 10 0 0 repeat repeat;*/
/*}*/
QPushButton#toolButtonDownload {border-right: 1px solid #dfdfdf; max-width: 40px; width: 40px; max-height: 28px; height: 28px;}
QPushButton#toolButtonDownload {border-left: 0px; border-right: 1px solid #dfdfdf; max-width: 40px; width: 40px; max-height: 28px; height: 28px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-right: 0px; border-left: 1px solid #dfdfdf;}
/**************************/
/* dark theme definitions */
@ -162,7 +166,7 @@ QPushButton#toolButtonDownload {border-right: 1px solid #dfdfdf; max-width: 40px
#mainPanel[uitheme=theme-dark] QPushButton#toolButtonDownload {border-color: #505050;}
#mainPanel[uitheme=theme-dark] QPushButton#toolButtonMain {
border-right-color: #333;
border-color: #333;
}
#mainPanel[uitheme=theme-dark] QPushButton#toolButtonMain[class=active] {
@ -171,7 +175,7 @@ QPushButton#toolButtonDownload {border-right: 1px solid #dfdfdf; max-width: 40px
#mainPanel[uitheme=theme-dark] QPushButton#toolButtonMain[class=normal] {
background: #404040;
border-right-color: #505050;
border-color: #505050;
}
#mainPanel[uitheme=theme-dark] QPushButton#toolButtonMain[class=normal]:hover {
@ -225,12 +229,12 @@ QPushButton#toolButtonDownload {border-right: 1px solid #dfdfdf; max-width: 40px
#mainPanel[uitheme=theme-contrast-dark] QPushButton#toolButtonDownload {border-color: #414141;}
#mainPanel[uitheme=theme-contrast-dark] QPushButton#toolButtonMain {
border-right-color: #1e1e1e;
border-color: #1e1e1e;
}
#mainPanel[uitheme=theme-contrast-dark] QPushButton#toolButtonMain[class=normal] {
background: #2a2a2a;
border-right-color: #414141;
border-color: #414141;
}
#mainPanel[uitheme=theme-contrast-dark] QPushButton#toolButtonMain[class=normal]:hover {
@ -250,11 +254,11 @@ QPushButton#toolButtonDownload {border-right: 1px solid #dfdfdf; max-width: 40px
#mainPanel[uitheme=theme-classic-light] QPushButton#toolButtonDownload {border-color: #cbcbcb;}
#mainPanel[uitheme=theme-classic-light] QPushButton#toolButtonMain {
border-right-color: #f1f1f1;
border-color: #f1f1f1;
}
#mainPanel[uitheme=theme-classic-light] QPushButton#toolButtonMain[class=normal] {
border-right-color: #cbcbcb;
border-color: #cbcbcb;
}

View File

@ -25,6 +25,7 @@ QPushButton#toolButtonMaximize[kde=true], QPushButton#toolButtonMinimize[kde=tru
QPushButton#toolButtonMain {
border-right-width: 1px;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-left-width: 1px;}
QPushButton#toolButtonMain[theme=light] {
border-width: 1px;
@ -38,6 +39,7 @@ QPushButton#toolButtonMain[class=normal],
}
QPushButton#toolButtonDownload {border-right-width: 1px; max-width: 50px; width: 50px; max-height: 35px; height: 35px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-left-width: 1px;}
/* ToolTip*/

View File

@ -26,6 +26,7 @@ QPushButton#toolButtonMain {
/*font-size: 20px;*/
border-right-width: 2px;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-left-width: 2px;}
QPushButton#toolButtonMain[theme=light] {
border-width: 2px;
@ -39,6 +40,7 @@ QPushButton#toolButtonMain[class=normal],
}
QPushButton#toolButtonDownload {border-right-width: 2px; max-width: 60px; width: 60px; max-height: 42px; height: 42px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-left-width: 2px;}
/* ToolTip*/

View File

@ -26,6 +26,7 @@ QPushButton#toolButtonMain {
/*font-size: 20px;*/
border-right-width: 2px;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-left-width: 2px;}
QPushButton#toolButtonMain[theme=light] {
border-width: 2px;
@ -39,6 +40,7 @@ QPushButton#toolButtonMain[class=normal],
}
QPushButton#toolButtonDownload {border-right-width: 2px; max-width: 70px; width: 70px; max-height: 49px; height: 49px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-left-width: 2px;}
/* ToolTip*/

View File

@ -11,11 +11,13 @@ QPushButton#toolButtonMaximize[kde=true], QPushButton#toolButtonMinimize[kde=tru
QPushButton#toolButtonClose[kde=true] {padding: 5px 0px 15px;}
QPushButton#toolButtonMain {font-size: 23px; border-right-width: 2px;}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-left-width: 2px;}
QPushButton#toolButtonMain[theme=light] {border-width: 2px; border-bottom: 0 none;}
QPushButton#toolButtonMain[class=normal],
QPushButton#toolButtonMain[class=normal]:hover {border-bottom-width: 2px;}
QPushButton#toolButtonDownload {border-right-width: 2px; max-width: 90px; width: 90px; max-height: 63px; height: 63px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-left-width: 2px;}
/* ToolTip*/

View File

@ -26,6 +26,7 @@ QPushButton#toolButtonMain {
font-size: 25px;
border-right-width: 3px;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-left-width: 3px;}
QPushButton#toolButtonMain[theme=light] {
border-width: 3px;
@ -39,6 +40,7 @@ QPushButton#toolButtonMain[class=normal],
}
QPushButton#toolButtonDownload {border-right-width: 3px; max-width: 100px; width: 100px; max-height: 70px; height: 70px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-left-width: 3px;}
/* ToolTip*/

View File

@ -26,6 +26,7 @@ QPushButton#toolButtonMain {
font-size: 28px;
border-right-width: 3px;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-left-width: 3px;}
QPushButton#toolButtonMain[theme=light] {
border-width: 3px;
@ -39,6 +40,7 @@ QPushButton#toolButtonMain[class=normal],
}
QPushButton#toolButtonDownload {border-right-width: 3px; max-width: 110px; width: 110px; max-height: 77px; height: 77px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-left-width: 3px;}
/* ToolTip*/

View File

@ -26,6 +26,7 @@ QPushButton#toolButtonMain {
font-size: 20px;
border-right-width: 2px;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-left-width: 2px;}
QPushButton#toolButtonMain[theme=light] {
border-width: 2px;
@ -39,6 +40,7 @@ QPushButton#toolButtonMain[class=normal],
}
QPushButton#toolButtonDownload {border-right-width: 2px; max-width: 80px; width: 80px; max-height: 56px; height: 56px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-left-width: 2px;}
/* ToolTip*/

View File

@ -26,6 +26,7 @@ QPushButton#toolButtonMain {
font-size: 35px;
border-right-width: 4px;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-left-width: 4px;}
QPushButton#toolButtonMain[theme=light] {
border-width: 4px;
@ -39,6 +40,7 @@ QPushButton#toolButtonMain[class=normal],
}
QPushButton#toolButtonDownload {border-right-width: 4px; max-width: 140px; width: 140px; max-height: 98px; height: 98px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-left-width: 4px;}
/* ToolTip*/

View File

@ -26,6 +26,7 @@ QPushButton#toolButtonMain {
font-size: 30px;
border-right-width: 3px;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-left-width: 3px;}
QPushButton#toolButtonMain[theme=light] {
border-width: 3px;
@ -39,6 +40,7 @@ QPushButton#toolButtonMain[class=normal],
}
QPushButton#toolButtonDownload {border-right-width: 3px; max-width: 120px; width: 120px; max-height: 84px; height: 84px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-left-width: 3px;}
/* ToolTip*/

View File

@ -26,6 +26,7 @@ QPushButton#toolButtonMain {
font-size: 45px;
border-right-width: 5px;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-left-width: 5px;}
QPushButton#toolButtonMain[theme=light] {
border-width: 5px;
@ -39,6 +40,7 @@ QPushButton#toolButtonMain[class=normal],
}
QPushButton#toolButtonDownload {border-right-width: 5px; max-width: 180px; width: 180px; max-height: 126px; height: 126px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-left-width: 5px;}
/* ToolTip*/

View File

@ -26,6 +26,7 @@ QPushButton#toolButtonMain {
font-size: 40px;
border-right-width: 4px;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-left-width: 4px;}
QPushButton#toolButtonMain[theme=light] {
border-width: 4px;
@ -39,6 +40,7 @@ QPushButton#toolButtonMain[class=normal],
}
QPushButton#toolButtonDownload {border-right-width: 4px; max-width: 160px; width: 160px; max-height: 112px; height: 112px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-left-width: 4px;}
/* ToolTip*/

View File

@ -26,6 +26,7 @@ QPushButton#toolButtonMain {
font-size: 50px;
border-right-width: 5px;
}
#mainPanel[rtl=true] QPushButton#toolButtonMain {border-left-width: 5px;}
QPushButton#toolButtonMain[theme=light] {
border-width: 5px;
@ -39,6 +40,7 @@ QPushButton#toolButtonMain[class=normal],
}
QPushButton#toolButtonDownload {border-right-width: 5px; max-width: 200px; width: 200px; max-height: 140px; height: 140px;}
#mainPanel[rtl=true] QPushButton#toolButtonDownload {border-left-width: 5px;}
/* ToolTip*/

View File

@ -16,10 +16,11 @@ CTabBar #tabScroll>#rightButton:disabled {image: url(:/tabbar/icons/scrolltab_rd
CTabBar #tabScroll>#rightButton:hover {image: url(:/tabbar/icons/scrolltab_rh.svg);}
CTabBar #tabScroll>#rightButton:pressed {image: url(:/tabbar/icons/scrolltab_rp.svg);}
Tab {background: #f1f1f1; border: none; border-right: 1px solid #dfdfdf; margin: 0px; padding: 0px;}
Tab {background: #f1f1f1; border: none; border-left: 0px; border-right: 1px solid #dfdfdf; margin: 0px; padding: 0px;}
Tab #tabIcon {background: transparent;}
Tab #tabText {background: transparent; font-family: "Arial", "Helvetica", "Helvetica Neue", sans-serif;}
Tab #tabButton {border: none; margin-top: 0px; image: none; background: transparent;}
#mainPanel[rtl=true] Tab {border-right: 0px; border-left: 1px solid #dfdfdf;}
Tab[selected=true] {background: #446995; border-color: #446995;}
@ -31,9 +32,11 @@ CTabBar[active=false] Tab[selected=true][hovered=true] {background: #cecece;}
/* light */
#mainPanel[uitheme=theme-light] Tab {border-right-color: #dfdfdf;}
#mainPanel[uitheme=theme-light][rtl=true] Tab {border-left-color: #dfdfdf;}
/* classic light */
#mainPanel[uitheme=theme-classic-light] Tab {border-right-color: #cbcbcb;}
#mainPanel[uitheme=theme-classic-light][rtl=true] Tab {border-left-color: #cbcbcb;}
/* dark */
#mainPanel[uitheme=theme-dark] CTabBar {background: #404040;}
@ -45,6 +48,7 @@ CTabBar[active=false] Tab[selected=true][hovered=true] {background: #cecece;}
#mainPanel[uitheme=theme-dark] CTabBar[active=false] Tab[selected=true] {background: #404040; border-color: #505050;}
#mainPanel[uitheme=theme-dark] Tab[selected=false][hovered=true],
#mainPanel[uitheme=theme-dark] CTabBar[active=false] Tab[selected=true][hovered=true] {background: #555;}
#mainPanel[uitheme=theme-dark][rtl=true] Tab {border-left-color: #505050;}
/* contrast-dark */
#mainPanel[uitheme=theme-contrast-dark] CTabBar {background: #2a2a2a;}
@ -56,6 +60,7 @@ CTabBar[active=false] Tab[selected=true][hovered=true] {background: #cecece;}
#mainPanel[uitheme=theme-contrast-dark] CTabBar[active=false] Tab[selected=true] {background: #2a2a2a; border-color: #414141;}
#mainPanel[uitheme=theme-contrast-dark] Tab[selected=false][hovered=true],
#mainPanel[uitheme=theme-contrast-dark] CTabBar[active=false] Tab[selected=true][hovered=true] {background: #424242;}
#mainPanel[uitheme=theme-contrast-dark][rtl=true] Tab {border-left-color: #414141;}
/* portal */
@ -109,6 +114,7 @@ Tab #tabButton {width: 16px; max-width: 16px; max-height: 16px; border-width: 2p
#mainPanel[zoom="1.25x"] Tab #tabIcon {padding-left: 8px; padding-right: 8px; min-width: 19px; min-height: 19px; max-width: 19px; max-height: 19px;}
#mainPanel[zoom="1.25x"] Tab #tabText {font-size: 14px;}
#mainPanel[zoom="1.25x"] Tab #tabButton {width: 20px; max-width: 20px; max-height: 20px; border-width: 2px;}
#mainPanel[zoom="1.25x"][rtl=true] Tab {border-left-width: 1px;}
/* 1.5x */
#mainPanel[zoom="1.5x"] CTabBar #tabScroll {min-width: 48px; max-width: 48px;}
@ -117,6 +123,7 @@ Tab #tabButton {width: 16px; max-width: 16px; max-height: 16px; border-width: 2p
#mainPanel[zoom="1.5x"] Tab #tabIcon {padding-left: 8px; padding-right: 8px; min-width: 24px; min-height: 24px; max-width: 24px; max-height: 24px;}
#mainPanel[zoom="1.5x"] Tab #tabText {font-size: 15px;}
#mainPanel[zoom="1.5x"] Tab #tabButton {width: 24px; max-width: 24px; max-height: 24px; border-width: 2px;}
#mainPanel[zoom="1.5x"][rtl=true] Tab {border-left-width: 2px;}
/* 1.75x */
#mainPanel[zoom="1.75x"] CTabBar #tabScroll {min-width: 64px; max-width: 64px;}
@ -125,6 +132,7 @@ Tab #tabButton {width: 16px; max-width: 16px; max-height: 16px; border-width: 2p
#mainPanel[zoom="1.75x"] Tab #tabIcon {padding-left: 8px; padding-right: 8px; min-width: 28px; min-height: 28px; max-width: 28px; max-height: 28px;}
#mainPanel[zoom="1.75x"] Tab #tabText {font-size: 18px;}
#mainPanel[zoom="1.75x"] Tab #tabButton {width: 28px; max-width: 28px; max-height: 28px; border-width: 2px;}
#mainPanel[zoom="1.75x"][rtl=true] Tab {border-left-width: 2px;}
/* 2x */
#mainPanel[zoom="2x"] CTabBar #tabScroll {min-width: 64px; max-width: 64px;}
@ -133,6 +141,7 @@ Tab #tabButton {width: 16px; max-width: 16px; max-height: 16px; border-width: 2p
#mainPanel[zoom="2x"] Tab #tabIcon {padding-left: 8px; padding-right: 8px; min-width: 32px; min-height: 32px; max-width: 32px; max-height: 32px;}
#mainPanel[zoom="2x"] Tab #tabText {font-size: 20px;}
#mainPanel[zoom="2x"] Tab #tabButton {width: 32px; max-width: 32px; max-height: 32px; border-width: 2px;}
#mainPanel[zoom="2x"][rtl=true] Tab {border-left-width: 2px;}
/* 2.25x */
#mainPanel[zoom="2.25x"] CTabBar #tabScroll {min-width: 72px; max-width: 72px;}
@ -141,6 +150,7 @@ Tab #tabButton {width: 16px; max-width: 16px; max-height: 16px; border-width: 2p
#mainPanel[zoom="2.25x"] Tab #tabIcon {padding-left: 9px; padding-right: 9px; min-width: 36px; min-height: 36px; max-width: 36px; max-height: 36px;}
#mainPanel[zoom="2.25x"] Tab #tabText {font-size: 23px;}
#mainPanel[zoom="2.25x"] Tab #tabButton {width: 36px; max-width: 36px; max-height: 36px; border-width: 2px;}
#mainPanel[zoom="2.25x"][rtl=true] Tab {border-left-width: 2px;}
/* 2.5x */
#mainPanel[zoom="2.5x"] CTabBar #tabScroll {min-width: 80px; max-width: 80px;}
@ -149,6 +159,7 @@ Tab #tabButton {width: 16px; max-width: 16px; max-height: 16px; border-width: 2p
#mainPanel[zoom="2.5x"] Tab #tabIcon {padding-left: 8px; padding-right: 8px; min-width: 40px; min-height: 40px; max-width: 40px; max-height: 40px;}
#mainPanel[zoom="2.5x"] Tab #tabText {font-size: 25px;}
#mainPanel[zoom="2.5x"] Tab #tabButton {width: 40px; max-width: 40px; max-height: 40px; border-width: 2px;}
#mainPanel[zoom="2.5x"][rtl=true] Tab {border-left-width: 3px;}
/* 2.75x */
#mainPanel[zoom="2.75x"] CTabBar #tabScroll {min-width: 88px; max-width: 88px;}
@ -157,6 +168,7 @@ Tab #tabButton {width: 16px; max-width: 16px; max-height: 16px; border-width: 2p
#mainPanel[zoom="2.75x"] Tab #tabIcon {padding-left: 8px; padding-right: 8px; min-width: 44px; min-height: 44px; max-width: 44px; max-height: 44px;}
#mainPanel[zoom="2.75x"] Tab #tabText {font-size: 28px;}
#mainPanel[zoom="2.75x"] Tab #tabButton {width: 44px; max-width: 44px; max-height: 44px; border-width: 2px;}
#mainPanel[zoom="2.75x"][rtl=true] Tab {border-left-width: 3px;}
/* 3x */
#mainPanel[zoom="3x"] CTabBar #tabScroll {min-width: 96px; max-width: 96px;}
@ -165,6 +177,7 @@ Tab #tabButton {width: 16px; max-width: 16px; max-height: 16px; border-width: 2p
#mainPanel[zoom="3x"] Tab #tabIcon {padding-left: 8px; padding-right: 8px; min-width: 48px; min-height: 48px; max-width: 48px; max-height: 48px;}
#mainPanel[zoom="3x"] Tab #tabText {font-size: 30px;}
#mainPanel[zoom="3x"] Tab #tabButton {width: 48px; max-width: 48px; max-height: 48px; border-width: 2px;}
#mainPanel[zoom="3x"][rtl=true] Tab {border-left-width: 3px;}
/* 3.5x */
#mainPanel[zoom="3.5x"] CTabBar #tabScroll {min-width: 112px; max-width: 112px;}
@ -173,6 +186,7 @@ Tab #tabButton {width: 16px; max-width: 16px; max-height: 16px; border-width: 2p
#mainPanel[zoom="3.5x"] Tab #tabIcon {padding-left: 8px; padding-right: 8px; min-width: 56px; min-height: 56px; max-width: 56px; max-height: 56px;}
#mainPanel[zoom="3.5x"] Tab #tabText {font-size: 35px;}
#mainPanel[zoom="3.5x"] Tab #tabButton {width: 56px; max-width: 56px; max-height: 56px; border-width: 2px;}
#mainPanel[zoom="3.5x"][rtl=true] Tab {border-left-width: 4px;}
/* 4x */
#mainPanel[zoom="4x"] CTabBar #tabScroll {min-width: 128px; max-width: 128px;}
@ -181,6 +195,7 @@ Tab #tabButton {width: 16px; max-width: 16px; max-height: 16px; border-width: 2p
#mainPanel[zoom="4x"] Tab #tabIcon {padding-left: 8px; padding-right: 8px; min-width: 64px; min-height: 64px; max-width: 64px; max-height: 64px;}
#mainPanel[zoom="4x"] Tab #tabText {font-size: 40px;}
#mainPanel[zoom="4x"] Tab #tabButton {width: 64px; max-width: 64px; max-height: 64px; border-width: 2px;}
#mainPanel[zoom="4x"][rtl=true] Tab {border-left-width: 4px;}
/* 4.5x */
#mainPanel[zoom="4.5x"] CTabBar #tabScroll {min-width: 144px; max-width: 144px;}
@ -189,6 +204,7 @@ Tab #tabButton {width: 16px; max-width: 16px; max-height: 16px; border-width: 2p
#mainPanel[zoom="4.5x"] Tab #tabIcon {padding-left: 8px; padding-right: 8px; min-width: 72px; min-height: 72px; max-width: 72px; max-height: 72px;}
#mainPanel[zoom="4.5x"] Tab #tabText {font-size: 45px;}
#mainPanel[zoom="4.5x"] Tab #tabButton {width: 72px; max-width: 72px; max-height: 72px; border-width: 2px;}
#mainPanel[zoom="4.5x"][rtl=true] Tab {border-left-width: 5px;}
/* 5x */
#mainPanel[zoom="5x"] CTabBar #tabScroll {min-width: 160px; max-width: 160px;}
@ -197,3 +213,4 @@ Tab #tabButton {width: 16px; max-width: 16px; max-height: 16px; border-width: 2p
#mainPanel[zoom="5x"] Tab #tabIcon {padding-left: 8px; padding-right: 8px; min-width: 80px; min-height: 80px; max-width: 80px; max-height: 80px;}
#mainPanel[zoom="5x"] Tab #tabText {font-size: 50px;}
#mainPanel[zoom="5x"] Tab #tabButton {width: 80px; max-width: 80px; max-height: 80px; border-width: 2px;}
#mainPanel[zoom="5x"][rtl=true] Tab {border-left-width: 5px;}

View File

@ -54,6 +54,8 @@ using namespace std;
using namespace std::placeholders;
bool CAscApplicationManagerWrapper::m_rtlEnabled = false;
CAscApplicationManagerWrapper::CAscApplicationManagerWrapper(CAscApplicationManagerWrapper const&)
{
@ -1174,6 +1176,11 @@ void CAscApplicationManagerWrapper::initializeApp()
if ( !local_themes_array.isEmpty() )
EditorJSVariables::setVariable("localthemes", local_themes_array);
const bool _is_rtl = reg_user.contains("forcedRtl") ? reg_user.value("forcedRtl", false).toBool() :
CLangater::isRtlLanguage(CLangater::getCurrentLangCode());
AscAppManager::setRtlEnabled(_is_rtl);
EditorJSVariables::setVariable("rtl", _is_rtl ? "yes" : "no");
EditorJSVariables::setVariable("lang", CLangater::getCurrentLangCode());
EditorJSVariables::applyVariable("theme", {
{"type", _app.m_themes->current().stype()},
@ -1652,6 +1659,28 @@ bool CAscApplicationManagerWrapper::event(QEvent *event)
return QObject::event(event);
}
void CAscApplicationManagerWrapper::setRtlEnabled(bool state)
{
if (m_rtlEnabled != state) {
m_rtlEnabled = state;
Qt::LayoutDirection direct = m_rtlEnabled ? Qt::RightToLeft : Qt::LeftToRight;
APP_CAST(_app);
if (_app.m_pMainWindow)
_app.m_pMainWindow->setLayoutDirection(direct);
for (auto const &r : _app.m_winsReporter)
r.second->setLayoutDirection(direct);
for (auto const &e : _app.m_vecEditors) {
CEditorWindow *editor = reinterpret_cast<CEditorWindow*>(e);
editor->setLayoutDirection(direct);
}
}
}
bool CAscApplicationManagerWrapper::isRtlEnabled()
{
return m_rtlEnabled;
}
bool CAscApplicationManagerWrapper::applySettings(const wstring& wstrjson)
{
QJsonParseError jerror;
@ -1704,6 +1733,16 @@ bool CAscApplicationManagerWrapper::applySettings(const wstring& wstrjson)
setUserSettings(L"spell-check-input-mode", objRoot["spellcheckdetect"].toString() == "off" ? L"0" : L"default");
}
if ( objRoot.contains("rtl") ) {
_reg_user.setValue("forcedRtl", objRoot["rtl"].toBool(false));
/*
* show message and relaunch app
*/
} else {
_reg_user.remove("forcedRtl");
}
wstring params = QString("lang=%1&username=%3&location=%2")
.arg(_lang_id, Utils::systemLocationCode(), QUrl::toPercentEncoding(_user_newname)).toStdWString();

View File

@ -120,6 +120,7 @@ private:
CMainWindow * m_pMainWindow = nullptr;
std::shared_ptr<CThemes> m_themes;
static bool m_rtlEnabled;
public:
CWindowsQueue<sWinTag>& closeQueue();
@ -201,6 +202,8 @@ public:
static void closeAppWindows(); // TODO: combine with launchAppClose
static void cancelClose();
static void setRtlEnabled(bool);
static bool isRtlEnabled();
uint logoutCount(const std::wstring& portal) const;
void Logout(const std::wstring& portal);

View File

@ -304,3 +304,8 @@ void CLangater::addTranslation(const QString& dir)
{
addTranslation(dir, getInstance()->m_lang);
}
bool CLangater::isRtlLanguage(const QString &lang) {
QLocale loc = lang.isEmpty() ? QLocale::system() : QLocale(lang);
return loc.textDirection() == Qt::LayoutDirection::RightToLeft;
}

View File

@ -20,6 +20,7 @@ public:
static QString getLangName(const QString& code = QString());
static void addTranslation(const QString& dir, const QString& name);
static void addTranslation(const QString& dir);
static bool isRtlLanguage(const QString &lang = QString());
static QJsonObject availableLangsToJson();

View File

@ -187,6 +187,23 @@ CAscTabWidget::CAscTabWidget(QWidget *parent, CTabBar *_pBar)
removeWidget(wgt);
insertWidget(to, wgt);
});
QObject::connect(m_pBar, &CTabBar::tabsSwapped, this, [=](int from, int to) {
if (from == to || !indexIsValid(from) || !indexIsValid(to))
return;
auto wgt_from = widget(from);
auto wgt_to = widget(to);
blockSignals(true);
removeWidget(wgt_from);
removeWidget(wgt_to);
insertWidget(from < to ? from : to, from < to ? wgt_to : wgt_from);
insertWidget(from < to ? to : from, from < to ? wgt_from : wgt_to);
if (from == m_pBar->currentIndex())
QStackedWidget::setCurrentIndex(to);
else
if (to == m_pBar->currentIndex())
QStackedWidget::setCurrentIndex(from);
blockSignals(false);
});
}
CTabPanel * CAscTabWidget::panel(int index) const
@ -220,7 +237,7 @@ int CAscTabWidget::addEditor(const COpenOptions& opts)
pView->initAsEditor();
int tab_index = -1;
int tab_index = AscAppManager::isRtlEnabled() ? 0 : -1;
bool res_open = true;
if (opts.srctype == etLocalFile) {
pView->openLocalFile(opts.wurl, file_format, L"");
@ -247,8 +264,8 @@ int CAscTabWidget::addEditor(const COpenOptions& opts)
data->setChanged(opts.srctype == etRecoveryFile);
pView->setData(data);
tab_index = addWidget(panelwidget);
m_pBar->addTab(data->title());
tab_index = insertWidget(tab_index, panelwidget);
m_pBar->insertTab(tab_index, data->title());
m_pBar->setTabToolTip(tab_index, data->title());
m_pBar->tabStartLoading(tab_index);
@ -367,7 +384,7 @@ int CAscTabWidget::addPortal(const QString& url, const QString& name, const QStr
data->setUrl(_url);
pView->setData(data);
int tab_index = -1;
int tab_index = AscAppManager::isRtlEnabled() ? 0 : -1;
tab_index = insertWidget(tab_index, panelwidget);
m_pBar->insertTab(tab_index, portal);
@ -408,7 +425,7 @@ int CAscTabWidget::addOAuthPortal(const QString& portal, const QString& type, co
data->setUrl(portal);
pView->setData(data);
int tab_index = -1;
int tab_index = AscAppManager::isRtlEnabled() ? 0 : -1;
tab_index = insertWidget(tab_index, panelwidget);
m_pBar->insertTab(tab_index, _portal);
@ -423,7 +440,7 @@ int CAscTabWidget::addOAuthPortal(const QString& portal, const QString& type, co
int CAscTabWidget::insertPanel(QWidget * panel, int index)
{
int tabindex = -1;
int tabindex = AscAppManager::isRtlEnabled() ? 0 : -1;
CTabPanel * _panel = dynamic_cast<CTabPanel *>(panel);
Q_ASSERT(_panel != nullptr);
@ -432,6 +449,8 @@ int CAscTabWidget::insertPanel(QWidget * panel, int index)
QWidget * panelwidget = createTabPanel(this, _panel);
if (index < 0 && AscAppManager::isRtlEnabled())
index = 0;
tabindex = insertWidget(index, panelwidget);
m_pBar->insertTab(tabindex, tabdata->title());
m_pBar->setTabToolTip(tabindex, tabdata->title());

View File

@ -171,6 +171,7 @@ CDownloadWidget::CDownloadWidget(QWidget *parent)
QLabel *labelTitle = new QLabel(m_titleFrame);
labelTitle->setObjectName("labelTitle");
labelTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
labelTitle->setAlignment((AscAppManager::isRtlEnabled() ? Qt::AlignRight : Qt::AlignLeft) | Qt::AlignAbsolute);
labelTitle->setText(tr("Downloads"));
m_titleFrame->layout()->addWidget(labelTitle);
@ -206,8 +207,10 @@ CDownloadWidget::CDownloadWidget(QWidget *parent)
connect(m_pToolButton, &QPushButton::clicked, this, [=]() {
polish();
show();
QPoint offset(-1 * MAIN_WINDOW_BORDER_WIDTH * m_dpiRatio, (TITLE_HEIGHT + MAIN_WINDOW_BORDER_WIDTH) * m_dpiRatio);
QPoint pos = parent->geometry().topRight() - QPoint(WIDGET_MAX_WIDTH, 0) + offset + QPoint(qRound(SHADOW - MARGINS/3), qRound(-SHADOW + MARGINS/3));
QPoint pos = AscAppManager::isRtlEnabled() ? parent->geometry().topLeft() : parent->geometry().topRight() - QPoint(WIDGET_MAX_WIDTH, 0);
QPoint brd_offset((AscAppManager::isRtlEnabled() ? 1 : -1) * MAIN_WINDOW_BORDER_WIDTH * m_dpiRatio, (TITLE_HEIGHT + MAIN_WINDOW_BORDER_WIDTH) * m_dpiRatio);
QPoint shd_offset((AscAppManager::isRtlEnabled() ? -1 : 1) * qRound(SHADOW - MARGINS/3), qRound(-SHADOW + MARGINS/3));
pos += brd_offset + shd_offset;
move(pos);
int prefHeight = m_mapDownloads.size() * ITEM_MAX_HEIGHT + 74 * m_dpiRatio;
setGeometry(QRect(pos, QSize(WIDGET_MAX_WIDTH, (prefHeight > WIDGET_MAX_HEIGHT) ? WIDGET_MAX_HEIGHT : prefHeight)));
@ -244,6 +247,7 @@ QWidget * CDownloadWidget::addFile(const QString& fn, int id)
CElipsisLabel * name = new CElipsisLabel(fn);
name->setObjectName("labelName");
name->setEllipsisMode(Qt::ElideRight);
name->setAlignment((AscAppManager::isRtlEnabled() ? Qt::AlignRight : Qt::AlignLeft) | Qt::AlignAbsolute);
name->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
grid->addWidget(name, 0, 0, 1, 1);
@ -269,6 +273,7 @@ QWidget * CDownloadWidget::addFile(const QString& fn, int id)
CElipsisLabel * info = new CElipsisLabel(QString("0 %1").arg(tr("kBps")));
info->setObjectName("labelInfo");
info->setEllipsisMode(Qt::ElideRight);
info->setAlignment((AscAppManager::isRtlEnabled() ? Qt::AlignRight : Qt::AlignLeft) | Qt::AlignAbsolute);
info->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
grid->addWidget(info, 2, 0, 1, 2);
@ -321,6 +326,7 @@ void CDownloadWidget::downloadProcess(void * info)
}
QLabel *size_label = new QLabel;
size_label->setObjectName("labelSize");
size_label->setAlignment((AscAppManager::isRtlEnabled() ? Qt::AlignRight : Qt::AlignLeft) | Qt::AlignAbsolute);
size_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
size_label->setText(getFileSize(QString::fromStdWString(pData->get_FilePath())));
lut->addWidget(size_label, 1, 0, 1, 2);
@ -498,6 +504,22 @@ void CDownloadWidget::applyTheme(const QString &theme)
polish();
}
void CDownloadWidget::onLayoutDirectionChanged()
{
setLayoutDirection(AscAppManager::isRtlEnabled() ? Qt::RightToLeft : Qt::LeftToRight);
if (QLabel *labelTitle = m_titleFrame->findChild<QLabel*>("labelTitle"))
labelTitle->setAlignment((AscAppManager::isRtlEnabled() ? Qt::AlignRight : Qt::AlignLeft) | Qt::AlignAbsolute);
for (int i = 0; i < m_pContentArea->layout()->count(); ++i) {
auto item = m_pContentArea->layout()->itemAt(i);
if (item && item->widget()) {
const auto lb_list = item->widget()->findChildren<QLabel*>();
for (QLabel *lb : lb_list) {
lb->setAlignment((AscAppManager::isRtlEnabled() ? Qt::AlignRight : Qt::AlignLeft) | Qt::AlignAbsolute);
}
}
}
}
void CDownloadWidget::onStart()
{
if (!m_pToolButton->isVisible())

View File

@ -52,6 +52,7 @@ public:
QPushButton * toolButton();
void updateScalingFactor(double);
void applyTheme(const QString&);
void onLayoutDirectionChanged();
protected:
virtual void closeEvent(QCloseEvent *) final;

View File

@ -85,6 +85,18 @@ auto CElipsisLabel::setEllipsisMode(Qt::TextElideMode mode) -> void
elide_mode = mode;
}
auto CElipsisLabel::textWidth() -> int
{
QString elt = ellipsis_text_(this, orig_text, elide_mode);
QFontMetrics fm(font());
#if (QT_VERSION < QT_VERSION_CHECK(5,11,0))
int textWidth = fm.width(elt);
#else
int textWidth = fm.horizontalAdvance(elt);
#endif
return textWidth;
}
auto CElipsisLabel::updateText() -> void
{
QString elt = ellipsis_text_(this, orig_text, elide_mode);

View File

@ -46,6 +46,7 @@ public:
auto setText(const QString&) -> void;
auto setEllipsisMode(Qt::TextElideMode) -> void;
auto updateText() -> void;
auto textWidth() -> int;
signals:
void onResize(QSize size, int textWidth);

View File

@ -122,6 +122,7 @@ Tab::Tab(QWidget *parent) :
text_label = new QLabel(this);
text_label->setObjectName("tabText");
text_label->setAlignment((AscAppManager::isRtlEnabled() ? Qt::AlignRight : Qt::AlignLeft) | Qt::AlignVCenter | Qt::AlignAbsolute);
text_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
lut->addWidget(text_label);
@ -472,6 +473,8 @@ void CTabBar::CTabBarPrivate::slide(int from, int to, int offset, int animation_
void CTabBar::CTabBarPrivate::scrollToDirection(int direction)
{
if (AscAppManager::isRtlEnabled())
direction = (direction == Direction::Left) ? Direction::Right : Direction::Left;
while (animationInProgress)
PROCESSEVENTS();
@ -559,7 +562,10 @@ void CTabBar::CTabBarPrivate::changeScrollerState()
break;
}
}
leftButton->setEnabled(allowScroll);
if (AscAppManager::isRtlEnabled())
rightButton->setEnabled(allowScroll);
else
leftButton->setEnabled(allowScroll);
allowScroll = false;
for (int i = 0; i < tabList.size(); i++) {
@ -568,7 +574,10 @@ void CTabBar::CTabBarPrivate::changeScrollerState()
break;
}
}
rightButton->setEnabled(allowScroll);
if (AscAppManager::isRtlEnabled())
leftButton->setEnabled(allowScroll);
else
rightButton->setEnabled(allowScroll);
}
void CTabBar::CTabBarPrivate::reorderIndexes()
@ -624,8 +633,8 @@ CTabBar::CTabBar(QWidget *parent) :
d->leftButton = new QToolButton(d->scrollFrame);
d->rightButton = new QToolButton(d->scrollFrame);
d->leftButton->setObjectName("leftButton");
d->rightButton->setObjectName("rightButton");
d->leftButton->setObjectName(AscAppManager::isRtlEnabled() ? "rightButton" : "leftButton");
d->rightButton->setObjectName(AscAppManager::isRtlEnabled() ? "leftButton" : "rightButton");
scrollLayout->addWidget(d->leftButton);
scrollLayout->addWidget(d->rightButton);
@ -723,6 +732,27 @@ int CTabBar::insertTab(int index, const QIcon &icon, const QString &text)
return actual_index;
}
void CTabBar::swapTabs(int from, int to)
{
while (d->animationInProgress)
PROCESSEVENTS();
if (from == to || !d->indexIsValid(from) || !d->indexIsValid(to))
return;
int posX = d->_tabRect(from).x();
d->tabList[from]->move(d->_tabRect(to).x(), 0);
d->tabList[to]->move(posX, 0);
int from_index = d->tabIndex(from);
d->tabIndex(from) = d->tabIndex(to);
d->tabIndex(to) = from_index;
std::swap(d->tabList[from], d->tabList[to]);
emit tabsSwapped(from, to);
if (from == d->currentIndex)
d->onCurrentChanged(to);
else
if (to == d->currentIndex)
d->onCurrentChanged(from);
}
void CTabBar::removeTab(int index)
{
while (d->animationInProgress)
@ -1080,7 +1110,8 @@ bool CTabBar::eventFilter(QObject *watched, QEvent *event)
}
}
}
if (!d->tabArea->rect().contains(me->pos()) && d->tabArea->rect().right() >= me->x()) {
bool undockDirectionIsValid = AscAppManager::isRtlEnabled() ? d->tabArea->rect().left() <= me->x() : d->tabArea->rect().right() >= me->x();
if (!d->tabArea->rect().contains(me->pos()) && undockDirectionIsValid) {
if (d->currentIndex != d->movedTabIndex)
d->reorderIndexes();
bool accepted = false;
@ -1189,6 +1220,22 @@ bool CTabBar::eventFilter(QObject *watched, QEvent *event)
case QEvent::Leave:
QApplication::postEvent(d->tabArea, new QMouseEvent(QEvent::MouseButtonRelease, QCursor::pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier));
break;
case QEvent::LayoutDirectionChange: {
SKIP_EVENTS_QUEUE([=]() {
for (int i = 0; i < d->tabList.size(); i++) {
d->tabList[i]->polish();
d->tabList[i]->text_label->setAlignment((AscAppManager::isRtlEnabled() ? Qt::AlignRight : Qt::AlignLeft) | Qt::AlignVCenter | Qt::AlignAbsolute);
}
d->leftButton->setObjectName(AscAppManager::isRtlEnabled() ? "rightButton" : "leftButton");
d->rightButton->setObjectName(AscAppManager::isRtlEnabled() ? "leftButton" : "rightButton");
d->leftButton->style()->polish(d->leftButton);
d->rightButton->style()->polish(d->rightButton);
int n = count();
for (int i = 0; i < n/2; i++)
swapTabs(i, n - i - 1);
});
break;
}
default:
break;
}

View File

@ -56,7 +56,7 @@ public:
QSize iconSize() const;
int insertTab(int index, const QString &text);
int insertTab(int index, const QIcon &icon, const QString &text);
// void moveTab(int from, int to);
void swapTabs(int from, int to);
void removeTab(int index);
void setElideMode(Qt::TextElideMode mode);
void setIconSize(const QSize &size);
@ -92,6 +92,7 @@ signals:
// void tabBarDoubleClicked(int index);
void tabCloseRequested(int index);
void tabMoved(int from, int to);
void tabsSwapped(int from, int to);
void tabUndock(int index, bool &accepted);
protected:

View File

@ -3,6 +3,7 @@
#include <glib.h>
#include "gtkutils.h"
#include "gtkfilechooser.h"
#include "cascapplicationmanagerwrapper.h"
#include <gdk/gdkx.h>
@ -82,6 +83,9 @@ static void nativeFileDialog(const Window &parent_xid,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
};
if (AscAppManager::isRtlEnabled())
gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);
GtkWidget *dialog = NULL;
dialog = gtk_file_chooser_dialog_new(title,
NULL,

View File

@ -36,6 +36,7 @@
#include <gtk/gtkcheckbutton.h>
#include <gtk/gtktogglebutton.h>
#include "gtkmessage.h"
#include "cascapplicationmanagerwrapper.h"
#include <gdk/gdkx.h>
@ -84,6 +85,8 @@ int GtkMsg::showMessage(QWidget *parent,
GtkDialogFlags flags;
flags = (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT);
if (AscAppManager::isRtlEnabled())
gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);
GtkWidget *dialog = NULL;
dialog = gtk_message_dialog_new(NULL,
flags,

View File

@ -3,6 +3,7 @@
#include "gtkutils.h"
#include "gtkprintdialog.h"
#include "components/cmessage.h"
#include "cascapplicationmanagerwrapper.h"
#include <string>
#include <algorithm>
#include <gdk/gdkx.h>
@ -369,6 +370,8 @@ QDialog::DialogCode GtkPrintDialog::exec()
}
// Init dialog
if (AscAppManager::isRtlEnabled())
gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);
GtkWidget *dialog;
dialog = gtk_print_unix_dialog_new(m_title.toUtf8().data(), NULL);
gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);

View File

@ -36,6 +36,7 @@
#include "utils.h"
#include <gtk/gtkmessagedialog.h>
#include "updatedialog.h"
#include "cascapplicationmanagerwrapper.h"
#include <gdk/gdkx.h>
//extern "C" {
//#include "gtk_resources.h"
@ -77,6 +78,9 @@ int WinDlg::showDialog(QWidget *parent,
gtk_init(NULL, NULL);
GtkDialogFlags flags;
flags = (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT);
if (AscAppManager::isRtlEnabled())
gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);
GtkWidget *dialog = NULL;
dialog = gtk_message_dialog_new(NULL,
flags,

View File

@ -33,6 +33,7 @@
#include <QTextDocumentFragment>
#include "message.h"
#include "utils.h"
#include "cascapplicationmanagerwrapper.h"
#include <string.h>
#include <Windows.h>
#include <QTimer>
@ -172,6 +173,8 @@ int WinMsg::showMessage(QWidget *parent,
config.dwFlags = TDF_POSITION_RELATIVE_TO_WINDOW |
TDF_ALLOW_DIALOG_CANCELLATION |
TDF_SIZE_TO_CONTENT;
if (AscAppManager::isRtlEnabled())
config.dwFlags |= TDF_RTL_LAYOUT;
config.hwndParent = parent_hwnd;
config.hInstance = GetModuleHandle(NULL);
config.pfCallback = (PFTASKDIALOGCALLBACK)Pftaskdialogcallback;

View File

@ -33,6 +33,7 @@
#include <QTextDocumentFragment>
#include "updatedialog.h"
#include "platform_win/resource.h"
#include "cascapplicationmanagerwrapper.h"
#include "defines.h"
#include "utils.h"
#include <string.h>
@ -152,6 +153,8 @@ int WinDlg::showDialog(QWidget *parent,
config.dwFlags = TDF_ENABLE_HYPERLINKS |
TDF_POSITION_RELATIVE_TO_WINDOW |
TDF_ALLOW_DIALOG_CANCELLATION;
if (AscAppManager::isRtlEnabled())
config.dwFlags |= TDF_RTL_LAYOUT;
config.hwndParent = parent_hwnd;
config.hInstance = GetModuleHandle(NULL);
config.pfCallback = (PFTASKDIALOGCALLBACK)Pftaskdialogcallback;

View File

@ -98,6 +98,8 @@ void CMainWindowImpl::refreshAboutVersion()
GET_REGISTRY_USER(reg_user);
_json_obj["editorwindowmode"] = reg_user.value("editorWindowMode",false).toBool();
_json_obj["rtl"] = reg_user.contains("forcedRtl") ? reg_user.value("forcedRtl", false).toBool() :
CLangater::isRtlLanguage(CLangater::getCurrentLangCode());
// Read update settings
#ifdef _UPDMODULE

View File

@ -457,3 +457,8 @@ void CEditorWindow::closeEvent(QCloseEvent * e)
AscAppManager::getInstance().closeQueue().enter(sWinTag{CLOSE_QUEUE_WIN_TYPE_EDITOR, size_t(this)});
e->ignore();
}
void CEditorWindow::onLayoutDirectionChanged()
{
d_ptr->onLayoutDirectionChanged();
}

View File

@ -67,6 +67,7 @@ public:
protected:
void closeEvent(QCloseEvent *) override;
virtual void onLayoutDirectionChanged() final;
private:
QWidget * createMainPanel(QWidget *, const QString&);

View File

@ -66,6 +66,7 @@
#define TOP_PANEL_OFFSET 6*TOOLBTN_WIDTH
#define ICON_SPACER_WIDTH 9
#define ICON_SIZE QSize(20,20)
#define MARGINS 6
using namespace NSEditorApi;
@ -219,10 +220,36 @@ public:
}
}
QMargins mrg(0, 0, 0, 2*dpiRatio);
diffW > 0 ? mrg.setRight(diffW) : mrg.setLeft(-diffW);
if (AscAppManager::isRtlEnabled())
diffW > 0 ? mrg.setLeft(diffW) : mrg.setRight(-diffW);
else
diffW > 0 ? mrg.setRight(diffW) : mrg.setLeft(-diffW);
boxtitlelabel->setContentsMargins(mrg);
}
auto onLayoutDirectionChanged()->void
{
if (boxtitlelabel) {
QMargins mrg = boxtitlelabel->contentsMargins();
if (AscAppManager::isRtlEnabled()) {
mrg.setLeft(mrg.right());
mrg.setRight(0);
} else {
mrg.setRight(mrg.left());
mrg.setLeft(0);
}
boxtitlelabel->setContentsMargins(mrg);
}
if (iconcrypted) {
QSize size = window->m_labelTitle->size();
int offset = window->m_labelTitle->textWidth()/2 + MARGINS * window->m_dpiRatio;
int x = size.width()/2;
x += AscAppManager::isRtlEnabled() ? offset : -offset - ICON_SIZE.width() * window->m_dpiRatio;
int y = (size.height() - ICON_SIZE.height() * window->m_dpiRatio)/2;
iconcrypted->move(x, y);
}
}
void onEditorConfig(int, std::wstring cfg) override
{
// if ( id == window->holdView(id) )
@ -763,7 +790,9 @@ public:
iconcrypted->move(0, y);
connect(window->m_labelTitle, &CElipsisLabel::onResize, this, [=](QSize size, int textWidth) {
if (iconcrypted) {
int x = (size.width() - textWidth)/2 - ((ICON_SIZE.width() + 6) * window->m_dpiRatio);
int offset = textWidth/2 + MARGINS * window->m_dpiRatio;
int x = size.width()/2;
x += AscAppManager::isRtlEnabled() ? offset : -offset - ICON_SIZE.width() * window->m_dpiRatio;
int y = (size.height() - ICON_SIZE.height() * window->m_dpiRatio)/2;
iconcrypted->move(x, y);
}

View File

@ -147,6 +147,8 @@ int CMainWindow::attachEditor(QWidget * panel, int index)
int CMainWindow::attachEditor(QWidget * panel, const QPoint& pt)
{
QPoint _pt_local = tabWidget()->tabBar()->mapFromGlobal(pt);
if (AscAppManager::isRtlEnabled())
_pt_local -= QPoint(32 * m_dpiRatio, 0); // Minus tabScroll width
#ifdef Q_OS_WIN
# if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
QPoint _tl = windowRect().topLeft();
@ -176,7 +178,9 @@ bool CMainWindow::pointInTabs(const QPoint& pt)
{
QRect _rc_title(m_pMainPanel->geometry());
_rc_title.setHeight(tabWidget()->tabBar()->height());
_rc_title.adjust(m_pButtonMain->width(), 1, -3*int(TITLEBTN_WIDTH*m_dpiRatio), 0);
int dx1 = (AscAppManager::isRtlEnabled()) ? 3 * int(TITLEBTN_WIDTH * m_dpiRatio) : m_pButtonMain->width();
int dx2 = (AscAppManager::isRtlEnabled()) ? -1 * m_pButtonMain->width() : -3 * int(TITLEBTN_WIDTH * m_dpiRatio);
_rc_title.adjust(dx1, 1, dx2, 0);
return _rc_title.contains(mapFromGlobal(pt));
}
@ -367,6 +371,7 @@ QWidget* CMainWindow::createMainPanel(QWidget *parent)
{
QWidget *mainPanel = new QWidget(parent);
mainPanel->setObjectName("mainPanel");
mainPanel->setProperty("rtl", AscAppManager::isRtlEnabled());
QGridLayout *_pMainGridLayout = new QGridLayout(mainPanel);
_pMainGridLayout->setSpacing(0);
_pMainGridLayout->setObjectName(QString::fromUtf8("mainGridLayout"));
@ -1013,6 +1018,7 @@ void CMainWindow::onDocumentDownload(void * info)
});
QHBoxLayout * layoutBtns = qobject_cast<QHBoxLayout *>(m_boxTitleBtns->layout());
layoutBtns->insertWidget(1, m_pWidgetDownload->toolButton());
m_pWidgetDownload->setLayoutDirection(AscAppManager::isRtlEnabled() ? Qt::RightToLeft : Qt::LeftToRight);
m_pWidgetDownload->setStyleSheet(Utils::readStylesheets(":/styles/download.qss"));
m_pWidgetDownload->applyTheme(m_pMainPanel->property("uitheme").toString());
m_pWidgetDownload->updateScalingFactor(m_dpiRatio);
@ -1498,3 +1504,12 @@ void CMainWindow::cancelClose()
{
m_isCloseAll && (m_isCloseAll = false);
}
void CMainWindow::onLayoutDirectionChanged()
{
m_pButtonMain->style()->polish(m_pButtonMain);
if (m_pWidgetDownload && m_pWidgetDownload->toolButton()) {
m_pWidgetDownload->onLayoutDirectionChanged();
m_pWidgetDownload->toolButton()->style()->polish(m_pWidgetDownload->toolButton());
}
}

View File

@ -106,6 +106,7 @@ public:
protected:
virtual QString getSaveMessage() const;
virtual void refreshAboutVersion() {};
virtual void onLayoutDirectionChanged() final;
void closeEvent(QCloseEvent *) override;
void showEvent(QShowEvent *) override;

View File

@ -99,6 +99,11 @@ void CPresenterWindow::closeEvent(QCloseEvent *e)
e->ignore();
}
void CPresenterWindow::onLayoutDirectionChanged()
{
}
/** Private **/
QWidget * CPresenterWindow::createMainPanel(QWidget * parent, const QString& title, QWidget * view)

View File

@ -52,6 +52,7 @@ public:
protected:
void closeEvent(QCloseEvent *) final;
virtual void onLayoutDirectionChanged() final;
private:
QWidget * createMainPanel(QWidget *, const QString&, QWidget * view = nullptr);

View File

@ -49,6 +49,8 @@ CWindowPlatform::CWindowPlatform(const QRect &rect) :
CWindowBase(rect),
CX11Decoration(this)
{
if (AscAppManager::isRtlEnabled())
setLayoutDirection(Qt::RightToLeft);
if (isCustomWindowStyle()) {
if (QX11Info::isCompositingManagerRunning())
setAttribute(Qt::WA_TranslucentBackground);
@ -120,6 +122,12 @@ bool CWindowPlatform::event(QEvent * event)
if (event->type() == QEvent::HoverLeave) {
if (m_boxTitleBtns)
m_boxTitleBtns->setCursor(QCursor(Qt::ArrowCursor));
} else
if (event->type() == QEvent::LayoutDirectionChange) {
if (m_pMainPanel) {
m_pMainPanel->setProperty("rtl", AscAppManager::isRtlEnabled());
onLayoutDirectionChanged();
}
}
return CWindowBase::event(event);
}

View File

@ -54,6 +54,7 @@ protected:
virtual bool nativeEvent(const QByteArray&, void*, long*) final;
virtual void setScreenScalingFactor(double, bool resize = true) override;
virtual void paintEvent(QPaintEvent *event) override;
virtual void onLayoutDirectionChanged() = 0;
private:
virtual void mouseMoveEvent(QMouseEvent *) final;

View File

@ -55,6 +55,8 @@ CWindowPlatform::CWindowPlatform(const QRect &rect) :
m_isResizeable(true),
m_allowMaximize(true)
{
if (AscAppManager::isRtlEnabled())
setLayoutDirection(Qt::RightToLeft);
setWindowFlags(windowFlags() | Qt::Window | Qt::FramelessWindowHint
| Qt::WindowSystemMenuHint | Qt::WindowMaximizeButtonHint
|Qt::WindowMinimizeButtonHint | Qt::MSWindowsFixedSizeDialogHint);
@ -151,6 +153,17 @@ bool CWindowPlatform::isSessionInProgress()
return m_isSessionInProgress;
}
bool CWindowPlatform::event(QEvent * event)
{
if (event->type() == QEvent::LayoutDirectionChange) {
if (m_pMainPanel) {
m_pMainPanel->setProperty("rtl", AscAppManager::isRtlEnabled());
onLayoutDirectionChanged();
}
}
return CWindowBase::event(event);
}
/** Private **/
bool CWindowPlatform::isTaskbarAutoHideOn()

View File

@ -54,6 +54,8 @@ public:
protected:
bool isSessionInProgress();
virtual bool event(QEvent *event) override;
virtual void onLayoutDirectionChanged() = 0;
private:
bool isTaskbarAutoHideOn();