From 9bcc71fe98ce30e590ef5f1f305de78eb3b3723a Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Fri, 28 Sep 2018 19:12:26 +0300 Subject: [PATCH] [win-nix] refactoring --- common/loginpage/src/component.less | 256 ++++++++++++++++++++++++++++ common/loginpage/src/styles.less | 145 +--------------- win-linux/src/clangater.cpp | 2 +- win-linux/src/clangater.h | 2 +- win-linux/src/cmainpanel.cpp | 4 +- win-linux/src/version.h | 4 +- win-linux/src/win/mainwindow.cpp | 2 +- 7 files changed, 264 insertions(+), 151 deletions(-) create mode 100644 common/loginpage/src/component.less diff --git a/common/loginpage/src/component.less b/common/loginpage/src/component.less new file mode 100644 index 000000000..c9bf303a6 --- /dev/null +++ b/common/loginpage/src/component.less @@ -0,0 +1,256 @@ +/* + button +*/ +button { + /*width: 135px;*/ + height: 36px; + color: #fff; + font-size: 14px; + outline: 0; + border: none 0; + cursor: pointer; + border-radius: @border-radius; + background-color: @color-gray-4; + padding: 0 36px; + + &.primary { + background-color: @color-blue-light; + + &:hover { + background-color: @color-blue-3; + } + + &:active { + background-color: @color-blue-2; + } + + &:disabled { + background-color: @color-blue-light; + color: #a7cff8; + } + } + + &:hover { + background-color: @color-gray-6; + } + + &:active { + background-color: @color-gray-5; + } + + &:disabled { + background-color: @color-gray-4; + cursor: default; + } + + .btn-quick { + background-color: transparent; + } +} + +/* + radio button style +*/ +@color1: #f4f4f4; +@color2: #3197EE; +@rb-height: 18px; + +input[type="radio"] { + position: absolute; + opacity: 0; + + + label:before { + content: ''; + background: @color1; + border-radius: 100%; + border: 1px solid darken(@color1, 25%); + display: inline-block; + width: @rb-height; + height: @rb-height; + position: relative; + /*top: -0.1em;*/ + margin-right: 1em; + vertical-align: top; + cursor: pointer; + text-align: center; + transition: all 250ms ease; + } + + &:checked { + + label:before { + background-color: @color2; + box-shadow: inset 0 0 0 3px @color1; + } + } + + &:focus { + + label:before { + outline: none; + border-color: @color2; + } + } + + &:disabled { + + label:before { + box-shadow: inset 0 0 0 3px @color1; + border-color: darken(@color1, 25%); + cursor: default; + } + + &:checked { + + label:before { + background: darken(@color1, 25%); + } + } + } + + + .label:empty:before { + margin-right: 0; + } +} + +/* + check box style +*/ +@switch-height: 20px; +@switch-width: 45px; + +.switch-labeled { + .onoffswitch { + margin-right: 20px; + } +} + +.onoffswitch { + /*display: none;*/ + + position: relative; + width: @switch-width; + -webkit-user-select:none; +} + +.onoffswitch__checkbox { + display: none; + + &:disabled { + + label { + cursor: default; + pointer-events: none; + opacity: 0.7; + } + } + + &:checked + .onoffswitch__label { + background-color: @color2; + } + + &:checked + .onoffswitch__label { + border-color: @color2; + + &:before { + border-color: @color2; + right: 0px; + } + } +} + +.onoffswitch__label { + display: block; + overflow: hidden; + cursor: pointer; + height: @switch-height; + padding: 0; + line-height: @switch-height; + border: 2px solid darken(@color1, 25%); + border-radius: @switch-height; + background-color: darken(@color1, 25%); + transition: all 0.25s ease-in; + box-sizing: content-box; + + &:before { + content: ""; + display: block; + width: @switch-height; + margin: 0px; + background: #FFF; + position: absolute; + top: 0; + bottom: 0; + right: @switch-width - 24; + border: 2px solid darken(@color1, 25%); + border-radius: @switch-height; + transition: all 0.25s ease-in 0s; + } +} + +/* + tooltip +*/ +[tooltip] { + &:before { + position : absolute; + content : attr(tooltip); + opacity : 0; + + color: #444; + border: 1px solid rgba(0, 0, 0, 0.15); + background: #fff; + border-radius: 4px; + box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); + padding: 5px 12px; + font-size: 11px; + z-index: 1; + transition: all .3s ease-in-out .25s; + pointer-events:none; + font-weight: normal; + } + + &[tooltip-pos=top]:before { + margin: -40px 0 0 -10px; + } +} + +[tooltip]:hover:before { + opacity : 1; +} + +/* + combo-box +*/ +.box-cmp-select { + display: inline-block; + + &:after { + content: ''; + border: solid @color-gray-light; + border-width: 0 2px 2px 0; + width: 8px; + height: 8px; + transform: rotate(45deg); + display: inline-block; + margin: 0 0 2px -30px; + cursor: pointer; + pointer-events:none; + } + + &:hover:after { + border-color: @color-gray; + } +} + +select { + -webkit-appearance: none; + height: 36px; + width: 150px; + outline: none; + border-radius: 3px; + color: @color-gray-dark; + border: 1px solid @color-gray-3; + padding: 0 15px; + font-size: 14px; + cursor: pointer; + + option { + padding: 10px 4px; + } +} \ No newline at end of file diff --git a/common/loginpage/src/styles.less b/common/loginpage/src/styles.less index 44aa28a40..77185f61a 100644 --- a/common/loginpage/src/styles.less +++ b/common/loginpage/src/styles.less @@ -21,6 +21,7 @@ @col-width: 287px; +@import 'component.less'; @import 'window.less'; @import '../vendor/bootstrap/variables.less'; @import '../vendor/bootstrap/dropdowns.less'; @@ -115,55 +116,6 @@ h4 { font-weight: 600; } -button { - /*width: 135px;*/ - height: 36px; - color: #fff; - font-size: 14px; - outline: 0; - border: none 0; - cursor: pointer; - border-radius: @border-radius; - background-color: @color-gray-4; - padding: 0 36px; - - &:hover { - background-color: @color-gray-6; - } - - &:active:not(:disabled) { - background-color: @color-gray-5; - } - - &:disabled { - background-color: @color-gray-4; - cursor: default; - color: @color-gray-2; - opacity: 0.5; - } - - &.primary { - background-color: @color-blue-light; - - &:hover { - background-color: @color-blue-3; - } - - &:active { - background-color: @color-blue-2; - } - - &:disabled { - background-color: @color-blue-light; - color: #a7cff8; - } - } - - .btn-quick { - background-color: transparent; - } -} - .text-sub { color: @color-gray; font-size: 12px; @@ -786,27 +738,6 @@ li.menu-item { margin: 0 auto; } -[tooltip]:before { - position : absolute; - content : attr(tooltip); - opacity : 0; - - color: #444; - border: 1px solid rgba(0, 0, 0, 0.15); - background: #fff; - border-radius: 4px; - box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); - padding: 5px 12px; - font-size: 11px; - z-index: 1; - transition: all .3s ease-in-out .25s; - pointer-events:none; -} - -[tooltip]:hover:before { - opacity : 1; -} - .logout { position: relative; @@ -988,81 +919,7 @@ li.menu-item { width: 18px; height: 18px; margin-right: 10px; -} -/* -* 'on/off' switch style -*/ -@color1: #f4f4f4; -@color2: #3197EE; -@switch-height: 20px; -/*@switch-width: 60px;*/ -@switch-width: 45px; -.switch-labeled { - .onoffswitch { - margin-right: 20px; - } -} -.onoffswitch { - /*display: none;*/ - position: relative; - width: @switch-width; - -webkit-user-select:none; -} - -.onoffswitch__checkbox { - display: none; - - &:disabled { - + label { - cursor: default; - pointer-events: none; - opacity: 0.7; - } - } - - &:checked + .onoffswitch__label { - background-color: @color2; - } - - &:checked + .onoffswitch__label { - border-color: @color2; - - &:before { - border-color: @color2; - right: 0px; - } - } -} - -.onoffswitch__label { - display: block; - overflow: hidden; - cursor: pointer; - height: @switch-height; - padding: 0; - line-height: @switch-height; - border: 2px solid darken(@color1, 25%); - border-radius: @switch-height; - background-color: darken(@color1, 25%); - transition: all 0.25s ease-in; - box-sizing: content-box; - - &:before { - content: ""; - display: block; - width: @switch-height; - margin: 0px; - background: #FFF; - position: absolute; - top: 0; - bottom: 0; - right: @switch-width - 24; - border: 2px solid darken(@color1, 25%); - border-radius: @switch-height; - transition: all 0.25s ease-in 0s; - } -} diff --git a/win-linux/src/clangater.cpp b/win-linux/src/clangater.cpp index b4f1976e2..ab9638ad0 100644 --- a/win-linux/src/clangater.cpp +++ b/win-linux/src/clangater.cpp @@ -122,7 +122,7 @@ void CLangater::init() QCoreApplication::installTranslator(tr); } -QString CLangater::getLanguageName() +QString CLangater::getCurrentLangCode() { return getInstance()->m_lang; } diff --git a/win-linux/src/clangater.h b/win-linux/src/clangater.h index 7fe6e025c..ca72d6f2c 100644 --- a/win-linux/src/clangater.h +++ b/win-linux/src/clangater.h @@ -10,7 +10,7 @@ public: static CLangater * getInstance(); static void init(); - static QString getLanguageName(); + static QString getCurrentLangCode(); static void addTranslation(const QString& dir, const QString& name); static void addTranslation(const QString& dir); diff --git a/win-linux/src/cmainpanel.cpp b/win-linux/src/cmainpanel.cpp index 004b90e29..c94333b84 100644 --- a/win-linux/src/cmainpanel.cpp +++ b/win-linux/src/cmainpanel.cpp @@ -225,7 +225,7 @@ CMainPanel::CMainPanel(QWidget *parent, bool isCustomWindow, uchar dpi_ratio) // m_pTabs->updateIcons(); QString params = QString("lang=%1&username=%3&location=%2") - .arg(CLangater::getLanguageName(), Utils::systemLocationCode()); + .arg(CLangater::getCurrentLangCode(), Utils::systemLocationCode()); wstring wparams = params.toStdWString(); wstring user_name = Utils::systemUserName(); @@ -1037,7 +1037,7 @@ void CMainPanel::loadStartPage() QString data_path = qApp->applicationDirPath() + "/index.html"; #endif - QString additional = "?waitingloader=yes&lang=" + CLangater::getLanguageName(); + QString additional = "?waitingloader=yes&lang=" + CLangater::getCurrentLangCode(); QString _portal = _reg_user.value("portal").value(); if (!_portal.isEmpty()) { diff --git a/win-linux/src/version.h b/win-linux/src/version.h index 2f2cf1b5e..6912b322d 100644 --- a/win-linux/src/version.h +++ b/win-linux/src/version.h @@ -39,8 +39,8 @@ #define VER_NUM_MAJOR 5 #define VER_NUM_MINOR 2 -#define VER_NUM_BUILD 47 -#define VER_NUM_REVISION 402 +#define VER_NUM_BUILD 48 +#define VER_NUM_REVISION 404 #define VER_NUMBER VER_NUM_MAJOR,VER_NUM_MINOR,VER_NUM_BUILD,VER_NUM_REVISION #define VER_STRING VER_STR_LONG(VER_NUM_MAJOR,VER_NUM_MINOR,VER_NUM_BUILD,VER_NUM_REVISION) #define VER_STRING_SHORT VER_STR_SHORT(VER_NUM_MAJOR,VER_NUM_MINOR) diff --git a/win-linux/src/win/mainwindow.cpp b/win-linux/src/win/mainwindow.cpp index 2268c02d6..8b4de3b71 100644 --- a/win-linux/src/win/mainwindow.cpp +++ b/win-linux/src/win/mainwindow.cpp @@ -721,7 +721,7 @@ void CMainWindow::slot_mainPageReady() QString(VER_FILEVERSION_STR).toStdWString().c_str()); win_sparkle_set_appcast_url(URL_APPCAST_UPDATES); win_sparkle_set_registry_path(QString("Software\\%1\\%2").arg(REG_GROUP_KEY).arg(REG_APP_NAME).toLatin1()); - win_sparkle_set_lang(CLangater::getLanguageName().toLatin1()); + win_sparkle_set_lang(CLangater::getCurrentLangCode().toLatin1()); win_sparkle_set_did_find_update_callback(&CMainWindow::updateFound); win_sparkle_set_did_not_find_update_callback(&CMainWindow::updateNotFound);