Merge branch 'develop' into feature/merge-pull-request

This commit is contained in:
Alexey Golubev
2017-06-21 19:54:29 +03:00
committed by GitHub
27 changed files with 515 additions and 177 deletions

View File

@ -7,9 +7,11 @@ INCLUDEPATH += $$PWD/src/prop \
$$PWD/src
HEADERS += \
src/clogger.h \
src/prop/defines_p.h
SOURCES += \
src/clogger.cpp \
src/prop/csplash.cpp \
src/prop/ccefeventsimpl.cpp \
src/prop/cmainpanelimpl.cpp \
@ -30,6 +32,9 @@ win32 {
DEFINES += _UPDMODULE
DEFINES += URL_APPCAST_UPDATES=$$join(LINK,,\\\",\\\")
LIBS += -L$$PWD/3dparty/WinSparkle/$$PLATFORM_BUILD -lWinSparkle
message(updates is turned on)
message(url: $$join(LINK,,\\\",\\\"))
}
CONFIG(debug, debug|release) {

View File

@ -107,6 +107,7 @@ linux-g++ {
win32 {
DEFINES += JAS_WIN_MSVC_BUILD WIN32
DEFINES += WIN32
DEFINES += Q_COMPILER_INITIALIZER_LISTS
RC_ICONS += ./res/icons/desktop_icons.ico

View File

@ -91,6 +91,11 @@ de.extODP =OpenDocument  Präsentation
fr.extODP =Présentation OpenDocument
es.extODP =Presentación de OpenDocument
en.defprogAppDescription=Free desktop office suite for document editing and collaboration
ru.defprogAppDescription=Бесплатный десктопный офисный пакет для редактирования документов и совместной работы
de.defprogAppDescription=Kostenlose Desktop-Office-Suite für Dokumentenbearbeitung und Zusammenarbeit
fr.defprogAppDescription=Suite bureautique d'applications de bureau gratuite pour l'édition de documents et la collaboration
es.defprogAppDescription=Paquete desktop de oficina gratuito para edición de documentos y colaboración
[Code]
@ -263,6 +268,23 @@ end;
//----------
procedure AddToDefaultPrograms;
var
i: integer;
argsArray: TArrayOfString;
begin
RegWriteStringValue(HKEY_LOCAL_MACHINE, '{#APP_REG_PATH}\Capabilities', 'ApplicationDescription', ExpandConstant('{cm:defprogAppDescription}'));
RegWriteStringValue(HKEY_LOCAL_MACHINE, '{#APP_REG_PATH}\Capabilities', 'ApplicationIcon', ExpandConstant('"{app}\{#NAME_EXE_OUT},0"'));
RegWriteStringValue(HKEY_LOCAL_MACHINE, '{#APP_REG_PATH}\Capabilities', 'ApplicationName', '{#sAppName}');
for i := 0 to GetArrayLength(AudioExts) - 1 do begin
Explode(argsArray, ExtensionRegistryInfo[i],':');
RegWriteStringValue(HKEY_LOCAL_MACHINE, '{#APP_REG_PATH}\Capabilities\FileAssociations', '.' + LowerCase(AudioExts[i]), argsArray[0]);
end;
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\RegisteredApplications', 'DesktopEditors', '{#APP_REG_PATH}\Capabilities');
end;
procedure DoPostInstall();
var
i: Integer;
@ -275,13 +297,14 @@ begin
begin
Explode(argsArray, ExtensionRegistryInfo[i],':');
if not RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Classes\' + argsArray[0]) then begin
// checking existance is temporary locked to rewrite new icons indexes
//if not RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Classes\' + argsArray[0]) then begin
if Length(argsArray[1]) <> 0 then
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Classes\' + argsArray[0], '', argsArray[1]);
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Classes\' + argsArray[0] + '\DefaultIcon', '', ExpandConstant('{app}\{#iconsExe},' + argsArray[2]));
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Classes\' + argsArray[0] + '\shell\open\command', '', ExpandConstant('"{app}\{#NAME_EXE_OUT}" "%1"'));
end;
//end;
ext := LowerCase(AudioExts[i]);
@ -312,6 +335,8 @@ begin
end;
end;
end;
AddToDefaultPrograms;
end;
{
@ -353,4 +378,6 @@ begin
RegDeleteKeyIncludingSubkeys(HKEY_LOCAL_MACHINE, ExpandConstant('Software\Classes\Applications\{#NAME_EXE_OUT})'));
RegDeleteKeyIncludingSubkeys(HKEY_LOCAL_MACHINE, ExpandConstant('Software\Classes\.' + ext + '\OpenWithList\{#NAME_EXE_OUT}'));
end;
RegDeleteValue(HKEY_LOCAL_MACHINE, 'Software\RegisteredApplications', 'DesktopEditors');
end;

View File

@ -5,6 +5,7 @@
#define NAME_EXE_OUT 'DesktopEditors.exe'
#define iconsExe 'projicons.exe'
#define licfile 'agpl-3.0'
#define APPWND_CLASS_NAME 'DocEditorsWindowClass'
#define sAppVersion GetFileVersion(AddBackslash(SourcePath) + '..\..\Build\Release\release\' + NAME_EXE_OUT)
#define sAppVerShort Copy(sAppVersion, 0, 3)
@ -41,11 +42,10 @@ UninstallDisplayIcon = {app}\{#NAME_EXE_OUT}
OutputDir =.\
Compression =lzma
PrivilegesRequired =admin
AppMutex =TEAMLAB
AppMutex ={code:getAppMutex}
ChangesEnvironment =yes
SetupMutex =ASC
[Languages]
Name: en; MessagesFile: compiler:Default.isl; LicenseFile: ..\..\..\common\package\license\{#licfile}.rtf;
Name: ru; MessagesFile: compiler:Languages\Russian.isl; LicenseFile: ..\..\..\common\package\license\{#licfile}.rtf;
@ -100,6 +100,12 @@ es.WarningWrongArchitecture =Usted está tratando de instalar la versión de la
;it.Uninstall =Disinstalla
;======================================================================================================
en.UpdateAppRunning=Setup has detected that %1 is currently running.%n%nIt'll be closed automatically. Click OK to continue, or Cancel to exit.
ru.UpdateAppRunning=Обнаружен запущенный экземпляр %1.%n%nДля обновления он будет автоматически закрыт. Нажмите «OK», чтобы продолжить, или «Отмена», чтобы выйти.
de.UpdateAppRunning=Setup hat festgestellt, dass es aktuell %1 läuft. %n%nEs wird automatisch geschlossen. Klicken Sie zum Fortfahren auf OK oder auf Abbrechen zum Beenden des Programms.
fr.UpdateAppRunning=L'installation a détecté que %1 est en cours d'exécution. %n%nIl sera fermé automatiquement. Cliquez sur OK pour continuer, ou Annuler pour quitter le programme.
es.UpdateAppRunning=Programa de instalación ha detectado que actualmente %1 está funcionando.%n%nSe cerrará  automáticamente. Haga clic en OK para continuar o Cerrar para salir.
;en.AssociateDescription =Associate office document file types with %1
;ru.AssociateDescription =Ассоциировать типы файлов офисных документов с %1
@ -109,21 +115,27 @@ const
SMTO_ABORTIFHUNG = 2;
WM_WININICHANGE = $001A;
WM_SETTINGCHANGE = WM_WININICHANGE;
WM_USER = $400;
type
WPARAM = UINT_PTR;
LPARAM = INT_PTR;
LRESULT = INT_PTR;
var
gHWND: Longint;
procedure GetSystemTimeAsFileTime(var lpFileTime: TFileTime); external 'GetSystemTimeAsFileTime@kernel32.dll';
function SendTextMessageTimeout(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: PAnsiChar; fuFlags: UINT; uTimeout: UINT; out lpdwResult: DWORD): LRESULT;
external 'SendMessageTimeoutA@user32.dll stdcall';
function GetCommandlineParam(inParamName: String):String; forward;
function CheckCommandlineParam(inpn: String) : Boolean; forward;
function StartsWith(SubStr, S: String) : Boolean; forward;
function StringReplace(S, oldSubString, newSubString: String) : String; forward;
procedure CleanDir(path: string); forward;
procedure DirectoryCopy(SourcePath, DestPath: string); forward;
//procedure checkArchitectureVersion; forward;
function GetHKLM: Integer; forward;
@ -144,7 +156,11 @@ var
OutResult: Boolean;
path, mess: string;
regkey: integer;
hWnd: Longint;
msg: string;
begin
gHWND := 0;
OutResult := True;
if IsWin64 then
@ -171,6 +187,32 @@ begin
end
end;
if OutResult then begin
if CheckCommandlineParam('/update') then
begin
gHWND := FindWindowByClassName('{#APPWND_CLASS_NAME}');
if gHWND <> 0 then begin
OutResult := (IDOK = MsgBox(ExpandConstant('{cm:UpdateAppRunning,{#sAppName}}'), mbInformation, MB_OKCANCEL));
if OutResult then begin
PostMessage(gHWND, WM_USER+254, 0, 0);
Sleep(1000);
while true do begin
hWnd := FindWindowByClassName('{#APPWND_CLASS_NAME}');
if hWnd <> 0 then begin
msg := FmtMessage(SetupMessage(msgSetupAppRunningError), ['{#sAppName}']);
if IDCANCEL = MsgBox(msg, mbError, MB_OKCANCEL) then begin
OutResult := false;
break;
end;
end else
break;
end;
end;
end;
end;
end;
Result := OutResult;
end;
@ -197,6 +239,56 @@ begin
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
commonCachePath, userCachePath: string;
paramStore: string;
ErrorCode: Integer;
begin
if CurStep = ssPostInstall then begin
DoPostInstall();
// migrate from the prev version when user's data saved to system common path
commonCachePath := ExpandConstant('{commonappdata}\{#APP_PATH}\data\cache');
userCachePath := ExpandConstant('{localappdata}\{#APP_PATH}\data\cache');
if DirExists(commonCachePath) then begin
ForceDirectories(userCachePath);
DirectoryCopy(commonCachePath, userCachePath);
end;
paramStore := GetCommandlineParam('/store');
if Length(paramStore) > 0 then begin
RegWriteStringValue(HKEY_LOCAL_MACHINE, ExpandConstant('{#APP_REG_PATH}'), 'Store', paramStore);
end;
paramStore := GetCommandlineParam('/uninst');
if (Length(paramStore) > 0) and (paramStore = 'full') then begin
RegWriteStringValue(HKEY_LOCAL_MACHINE, ExpandConstant('{#APP_REG_PATH}'), 'uninstall', paramStore);
end;
end else
if CurStep = ssDone then begin
if not (gHWND = 0) then begin
ShellExec('', ExpandConstant('{app}\{#NAME_EXE_OUT}'), '', '', SW_SHOW, ewNoWait, ErrorCode);
end
end;
end;
function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
CleanDir(ExpandConstant('{app}\editors\web-apps'));
CleanDir(ExpandConstant('{app}\editors\sdkjs'));
end;
function getAppMutex(P: String): String;
var
hWnd: Longint;
begin
if not CheckCommandlineParam('/update') then
Result := 'TEAMLAB'
else
Result := 'UPDATE';
end;
procedure installVCRedist(FileName, LabelCaption: String);
var
Params: String;
@ -273,6 +365,19 @@ begin
Result := IntToStr(fileTimeNano100/10000 - 11644473600000);
end;
function getAppPrevLang(param: string): string;
var
lang: string;
begin
if WizardSilent and
RegValueExists(GetHKLM(), '{#APP_REG_PATH}', 'locale') and
RegQueryStringValue(GetHKLM(), '{#APP_REG_PATH}', 'locale', lang) then
begin
result := lang
end else
result := ExpandConstant('{language}');
end;
function libExists(const dllname: String) : boolean;
begin
Result := not FileExists(ExpandConstant('{sys}\'+dllname));
@ -284,6 +389,7 @@ var
begin
if not RegQueryStringValue(GetHKLM(), 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', OrigPath)
then begin
Result := True;
Result := True;
exit;
end;
@ -338,38 +444,6 @@ begin
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
commonCachePath, userCachePath: string;
paramStore: string;
begin
if CurStep = ssPostInstall then
begin
DoPostInstall();
// migrate from prev version when user's data saved to system common path
commonCachePath := ExpandConstant('{commonappdata}\{#APP_PATH}\data\cache');
userCachePath := ExpandConstant('{localappdata}\{#APP_PATH}\data\cache');
if DirExists(commonCachePath) then
begin
ForceDirectories(userCachePath);
DirectoryCopy(commonCachePath, userCachePath);
end
end;
paramStore := GetCommandlineParam('/store');
if Length(paramStore) > 0 then
begin
RegWriteStringValue(HKEY_LOCAL_MACHINE, ExpandConstant('{#APP_REG_PATH}'), 'Store', paramStore);
end;
paramStore := GetCommandlineParam('/uninst');
if (Length(paramStore) > 0) and (paramStore = 'full') then
begin
RegWriteStringValue(HKEY_LOCAL_MACHINE, ExpandConstant('{#APP_REG_PATH}'), 'uninstall', paramStore);
end;
end;
function StartsWith(SubStr, S: String) : Boolean;
begin
Result := Pos(SubStr, S) = 1;
@ -402,9 +476,29 @@ begin
end;
end;
function CheckCommandlineParam(inpn: String) : Boolean;
var
i: Integer;
begin
Result := false;
for i:= 1 to ParamCount do begin
if inpn = Lowercase(ParamStr(i)) then begin
Result := true;
break;
end;
end;
end;
procedure CleanDir(path: string);
begin
if DirExists(path) then begin
DelTree(path, true, true, true)
end;
end;
[Dirs]
Name: {commonappdata}\{#APP_PATH}\webdata\cloud; Flags: uninsalwaysuninstall
Name: {commonappdata}\{#APP_PATH}\webdata\cloud; Flags: uninsalwaysuninstall;
[Files]
@ -422,8 +516,8 @@ Source: ..\..\..\common\package\license\3dparty\3DPARTYLICENSE; DestDir: {app};
;Source: ..\..\common\loginpage\deploy\*; DestDir: {commonappdata}\{#APP_PATH}\webdata\local;
Source: ..\..\..\common\package\dictionaries\*; DestDir: {app}\dictionaries; Flags: recursesubdirs;
Source: ..\..\..\..\core\build\jsdesktop\web-apps\*; DestDir: {app}\editors\web-apps; Flags: recursesubdirs;
Source: ..\..\..\..\core\build\jsdesktop\sdkjs\*; DestDir: {app}\editors\sdkjs; Flags: recursesubdirs;
Source: ..\..\..\..\core\build\jsdesktop\web-apps\*; DestDir: {app}\editors\web-apps; Flags: recursesubdirs;
Source: ..\..\..\..\core\build\jsdesktop\sdkjs\*; DestDir: {app}\editors\sdkjs; Flags: recursesubdirs;
Source: ..\..\..\..\core\build\empty\*; DestDir: {app}\converter\empty;
Source: ..\..\..\common\converter\DoctRenderer.config; DestDir: {app}\converter;
@ -470,8 +564,8 @@ Filename: {app}\launch.bat; Parameters: {#NAME_EXE_OUT}; Description: {cm:Launch
[Registry]
;Root: HKLM; Subkey: {#APP_REG_PATH}; Flags: uninsdeletekey;
Root: HKLM; Subkey: {#APP_REG_PATH}; ValueType: string; ValueName: AppPath; ValueData: {app}; Flags: uninsdeletevalue;
Root: HKLM; Subkey: {#APP_REG_PATH}; ValueType: string; ValueName: locale; ValueData: {language}; Flags: uninsdeletevalue;
Root: HKLM; Subkey: {#APP_REG_PATH}; ValueType: string; ValueName: AppPath; ValueData: {app}; Flags: uninsdeletevalue;
Root: HKLM; Subkey: {#APP_REG_PATH}; ValueType: string; ValueName: locale; ValueData: {code:getAppPrevLang}; Flags: uninsdeletevalue;
Root: HKLM; Subkey: {#APP_REG_PATH}; ValueType: qword; ValueName: timestamp; ValueData: {code:getPosixTime}; Flags: uninsdeletevalue;
Root: HKLM; Subkey: SYSTEM\CurrentControlSet\Control\Session Manager\Environment; ValueType: expandsz; ValueName: Path; ValueData: "{olddata};{app}\converter"; Check: NeedsAddPath(ExpandConstant('{app}\converter')); AfterInstall: RefreshEnvironment;

View File

@ -79,10 +79,6 @@ QTabBar::tab {
padding-left: 14px;
}
QTabBar::tab {
padding-left: 14px;
}
QTabBar::close-button {
image: url(:/res/icons/tab_close_normal_2x.png);
/*border-image: none;*/

View File

@ -53,8 +53,6 @@
</qresource>
<qresource prefix="/styles@2x">
<file alias="styles.qss">res/styles/styles@2x.qss</file>
<file alias="tabbar.qss">res/styles/tabbar@2x.qss</file>
<file alias="tabbar.nix.qss">res/styles/tabbar_nix@2x.qss</file>
</qresource>
<qresource prefix="/i18n">
<file>langs/en.qm</file>
@ -66,5 +64,7 @@
<qresource prefix="/sep-styles">
<file alias="tabbar.qss">res/styles/tabbar.qss</file>
<file alias="tabbar.nix.qss">res/styles/tabbar_nix.qss</file>
<file alias="tabbar@2x.qss">res/styles/tabbar@2x.qss</file>
<file alias="tabbar@2x.nix.qss">res/styles/tabbar_nix@2x.qss</file>
</qresource>
</RCC>

View File

@ -133,7 +133,7 @@ CAscTabWidget::CAscTabWidget(QWidget *parent)
QObject::connect(this, &QTabWidget::currentChanged, [=](){updateIcons(); setFocusedView();});
m_widthParams.apply_dpi(g_dpi_ratio);
m_widthParams.apply_scale(g_dpi_ratio);
}
int CAscTabWidget::addEditor(COpenOptions& opts)

View File

@ -101,7 +101,7 @@ class CAscTabWidget : public QTabWidget
int tools_width;
int custom_offset;
void apply_dpi(int dpi) {
void apply_scale(int dpi) {
tab.max *= dpi;
tab.min *= dpi;
tabs_span *= dpi;

View File

@ -210,6 +210,10 @@ void CCefEventsTransformer::OnEvent(NSEditorApi::CAscMenuEvent *pEvent)
if ( !(cmd.find(L"files:explore") == std::wstring::npos) ) {
QMetaObject::invokeMethod( pObjParent, "onLocalFileLocation", Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdWString(pData->get_Param())) );
} else
if ( !(cmd.find(L"update") == std::wstring::npos) ) {
if ( QString::fromStdWString(pData->get_Param()) == "check" )
QMetaObject::invokeMethod( pObjParent, "onCheckUpdates", Qt::QueuedConnection);
} else {
// std::wregex _re_appcmd(L"^app\\:(\\w+)", std::tr1::wregex::icase);
// auto _iter_cmd = std::wsregex_iterator(cmd.begin(), cmd.end(), _re_appcmd);

View File

@ -11,6 +11,8 @@
#include <QDebug>
extern QStringList g_cmdArgs;
class CLangater::CLangaterIntf
{
public:
@ -58,7 +60,7 @@ void CLangater::init()
QString _lang,
_lang_path = ":/i18n/langs/",
_cmd_args = QCoreApplication::arguments().join(',');
_cmd_args = g_cmdArgs.join(',');
QRegularExpression _re(reCmdLang);
QRegularExpressionMatch _re_match = _re.match(_cmd_args);

57
win-linux/src/clogger.cpp Normal file
View File

@ -0,0 +1,57 @@
#include "clogger.h"
#include "utils.h"
#include <memory>
#include <QDebug>
extern QStringList g_cmdArgs;
CLogger::CLogger(QObject *parent, QString fileName)
: QObject(parent)
, m_showDate(true)
, m_file(0)
{
if ( !fileName.isEmpty() ) {
m_file = new QFile(fileName);
m_file->open(QIODevice::Append | QIODevice::Text);
}
}
CLogger::~CLogger()
{
if ( m_file )
m_file->close();
}
void CLogger::write(const QString &value)
{
QString text(value);// + "";
if ( m_showDate )
text = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss ") + text;
QTextStream out(m_file);
out.setCodec("UTF-8");
if ( m_file ) {
out << text << endl;
}
}
//void CLogger::setShowDateTime(bool value)
//{
// m_showDate = value;
//}
void CLogger::log(const QString& str)
{
static char _enabled = 0;
if ( _enabled == 0 ) {
_enabled = g_cmdArgs.indexOf("--log");
}
if ( _enabled > 0 ) {
QString _file_name = Utils::getAppCommonPath() + "/app.log";
std::unique_ptr<CLogger> _logger(new CLogger(0, _file_name));
_logger->write(str);
}
}

30
win-linux/src/clogger.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef CLOGGER_H
#define CLOGGER_H
#include <QObject>
#include <QFile>
#include <QTextStream>
#include <QDateTime>
class CLogger : public QObject
{
Q_OBJECT
public:
explicit CLogger(QObject *parent, QString fileName);
~CLogger();
// void setShowDateTime(bool value);
static void log(const QString&);
private:
QFile * m_file;
bool m_showDate;
signals:
public slots:
void write(const QString &value);
};
#endif // CLOGGER_H

View File

@ -157,9 +157,9 @@ CMainPanel::CMainPanel(QWidget *parent, CAscApplicationManager *manager, bool is
m_pButtonMain->setGeometry(0, 0, BUTTON_MAIN_WIDTH * g_dpi_ratio, TITLE_HEIGHT * g_dpi_ratio);
QObject::connect(m_pButtonMain, SIGNAL(clicked()), this, SLOT(pushButtonMainClicked()));
QString _tabs_stylesheet_file = g_dpi_ratio > 1 ? ":/styles@2x/" : ":/sep-styles/";
QString _tabs_stylesheets = g_dpi_ratio > 1 ? ":/sep-styles/tabbar@2x" : ":/sep-styles/tabbar";
if (isCustomWindow) {
_tabs_stylesheet_file += "tabbar.qss";
_tabs_stylesheets += ".qss";
palette.setColor(QPalette::Background, QColor("#313437"));
auto _creatToolButton = [small_btn_size](const QString& name, QWidget * parent) {
@ -202,7 +202,7 @@ CMainPanel::CMainPanel(QWidget *parent, CAscApplicationManager *manager, bool is
m_boxTitleBtns->setFixedSize(282*g_dpi_ratio, TOOLBTN_HEIGHT*g_dpi_ratio);
} else {
#ifdef __linux__
_tabs_stylesheet_file += "tabbar.nix.qss";
_tabs_stylesheets += ".nix.qss";
#endif
m_pButtonMain->setProperty("theme", "light");
@ -216,7 +216,7 @@ CMainPanel::CMainPanel(QWidget *parent, CAscApplicationManager *manager, bool is
m_boxTitleBtns->setFixedSize(342*g_dpi_ratio, 16*g_dpi_ratio);
}
QFile styleFile(_tabs_stylesheet_file);
QFile styleFile(_tabs_stylesheets);
styleFile.open( QFile::ReadOnly );
m_pTabs->setStyleSheet(QString(styleFile.readAll()));
m_pTabs->setAutoFillBackground(true);
@ -1133,6 +1133,7 @@ void CMainPanel::onKeyDown(void * eventData)
RELEASEINTERFACE(pData)
switch (key) {
case 'W':
case VK_F4:
if (_is_ctrl && m_pTabs->isActive()) {
m_pTabs->closeEditorByIndex(m_pTabs->currentIndex());
@ -1302,9 +1303,9 @@ QString CMainPanel::getSaveMessage()
void CMainPanel::updateStylesheets()
{
QString _tabs_stylesheet_file = g_dpi_ratio > 1 ? ":/styles@2x/" : ":/sep-styles/";
QString _tabs_stylesheets = g_dpi_ratio > 1 ? ":/sep-styles/tabbar@2x" : ":/sep-styles/tabbar";
if ( m_isCustomWindow ) {
_tabs_stylesheet_file += "tabbar.qss";
_tabs_stylesheets += ".qss";
QSize small_btn_size(28*g_dpi_ratio, TOOLBTN_HEIGHT*g_dpi_ratio);
@ -1315,13 +1316,13 @@ void CMainPanel::updateStylesheets()
m_boxTitleBtns->setFixedSize(282*g_dpi_ratio, TOOLBTN_HEIGHT*g_dpi_ratio);
} else {
#ifdef __linux__
_tabs_stylesheet_file += "tabbar.nix.qss";
_tabs_stylesheets += ".nix.qss";
#endif
m_boxTitleBtns->setFixedSize(342*g_dpi_ratio, 16*g_dpi_ratio);
}
QFile styleFile(_tabs_stylesheet_file);
QFile styleFile(_tabs_stylesheets);
styleFile.open( QFile::ReadOnly );
m_pTabs->setStyleSheet(QString(styleFile.readAll()));
@ -1334,3 +1335,7 @@ void CMainPanel::updateStylesheets()
m_pButtonDownload->setAnimatedIcon(g_dpi_ratio > 1 ?
":/res/icons/downloading_2x.gif" : ":/res/icons/downloading.gif" );
}
void CMainPanel::onCheckUpdates()
{
emit checkUpdates();
}

View File

@ -65,6 +65,7 @@ public:
void doOpenLocalFiles();
void setInputFiles(QStringList *);
void updateStylesheets();
void cmdMainPage(const QString&, const QString&) const;
#ifdef __linux
QWidget * getTitleWidget();
@ -73,7 +74,6 @@ public:
protected:
void refreshAboutVersion();
void cmdMainPage(const QString&, const QString&) const;
void cmdAppManager(int, void *);
virtual QString getSaveMessage();
@ -97,6 +97,7 @@ signals:
void mainWindowChangeState(Qt::WindowState);
void mainWindowClose();
void mainPageReady();
void checkUpdates();
public slots:
void pushButtonMinimizeClicked();
@ -141,6 +142,7 @@ public slots:
void onMainPageReady();
void onFileChecked(const QString&, int, bool);
void onCheckUpdates();
private:
std::wstring m_sDownloadName;

View File

@ -42,6 +42,8 @@
#include <QMimeData>
#include "singleapplication.h"
extern QStringList g_cmdArgs;
CMainWindow::CMainWindow(QWidget *parent)
: QMainWindow(parent)
, CX11Decoration(this)
@ -53,7 +55,7 @@ CMainWindow::CMainWindow(QWidget *parent)
CMainWindow::CMainWindow(CAscApplicationManager * pAppManager)
: CMainWindow((QWidget *)0) /* doesn't compile via gcc 4.8 without parameter */
{
parseInputArgs(qApp->arguments());
parseInputArgs(g_cmdArgs);
setWindowIcon(Utils::appIcon());
setObjectName("MainWindow");
@ -89,7 +91,7 @@ CMainWindow::CMainWindow(CAscApplicationManager * pAppManager)
connect(pMainPanel, &CMainPanel::mainWindowClose, this, &CMainWindow::slot_windowClose);
SingleApplication * app = static_cast<SingleApplication *>(QCoreApplication::instance());
pMainPanel->setInputFiles(Utils::getInputFiles(app->arguments()));
pMainPanel->setInputFiles(Utils::getInputFiles(g_cmdArgs));
connect(app, &SingleApplication::showUp, [=](QString args){
QStringList * _list = Utils::getInputFiles(args.split(";"));

View File

@ -62,6 +62,7 @@
#include "common/File.h"
BYTE g_dpi_ratio = 1;
QStringList g_cmdArgs;
int main( int argc, char *argv[] )
{
@ -168,13 +169,14 @@ int main( int argc, char *argv[] )
#endif
reg_user.setFallbacksEnabled(false);
g_cmdArgs = QCoreApplication::arguments();
/* read lang fom different places
* cmd argument --lang:en apply the language one time
* cmd argument --keeplang:en also keep the language for next sessions
*/
int _arg_i;
if (!(_arg_i = app.arguments().indexOf("--help") < 0)) {
if (!(_arg_i = g_cmdArgs.indexOf("--help") < 0)) {
CHelp::out();
pApplicationManager->CloseApplication();

View File

@ -33,8 +33,8 @@
#ifndef VERSION_H
#define VERSION_H
#define VER_FILEVERSION 4,3,2,318
#define VER_FILEVERSION_STR "4.3.2.318\0"
#define VER_FILEVERSION 4,3,3,332
#define VER_FILEVERSION_STR "4.3.3.332\0"
#define VER_PRODUCTVERSION VER_FILEVERSION
#define VER_PRODUCTVERSION_STR "4.3\0"

View File

@ -56,6 +56,7 @@
#include "../utils.h"
#include "../csplash.h"
#include "../clangater.h"
#include "../clogger.h"
//#include <QScreen>
#include <QSettings>
@ -66,8 +67,7 @@
#include "../version.h"
#endif
extern byte g_dpi_ratio;
extern QStringList g_cmdArgs;
CWinPanel::CWinPanel( HWND hWnd, CAscApplicationManager* pManager )
: QWinWidget( hWnd )
@ -86,6 +86,12 @@ CWinPanel::CWinPanel( HWND hWnd, CAscApplicationManager* pManager )
connect(panel, &CMainPanelImpl::mainWindowClose, this, &CWinPanel::slot_windowClose);
connect(panel, &CMainPanelImpl::mainPageReady, this, &CWinPanel::slot_mainPageReady);
#ifdef _UPDMODULE
connect(panel, &CMainPanelImpl::checkUpdates, this, []{
win_sparkle_check_update_with_ui();
});
#endif
/*
CAscLocalOpenFiles * pData = (CAscLocalOpenFiles *)data;
vector<std::wstring>& vctFiles = pData->get_Files();
@ -100,7 +106,7 @@ CWinPanel::CWinPanel( HWND hWnd, CAscApplicationManager* pManager )
// m_pManager->SetEventListener(this);
panel->setInputFiles(Utils::getInputFiles(qApp->arguments()));
panel->setInputFiles(Utils::getInputFiles(g_cmdArgs));
// parseInputArgs(qApp->arguments());
}
@ -175,11 +181,23 @@ void CWinPanel::goStartPage()
m_pMainPanel->goStart();
}
void CWinPanel::doClose()
{
QTimer::singleShot(500, this, [=]{
m_pMainPanel->pushButtonCloseClicked();
});
}
void CWinPanel::focus()
{
m_pMainPanel->focus();
}
void CWinPanel::updatePanelStylesheets()
{
m_pMainPanel->updateStylesheets();
}
void CWinPanel::applyWindowState(Qt::WindowState state)
{
m_pMainPanel->applyMainWindowState(state);
@ -192,13 +210,6 @@ void CWinPanel::slot_windowClose()
// PostQuitMessage(0);
}
void CWinPanel::doClose()
{
QTimer::singleShot(500, this, [=]{
m_pMainPanel->pushButtonCloseClicked();
});
}
void CWinPanel::slot_windowChangeState(Qt::WindowState s)
{
int cmdShow = SW_RESTORE;
@ -226,7 +237,6 @@ void CWinPanel::slot_mainPageReady()
#ifdef _UPDMODULE
QString _prod_name = WINDOW_NAME;
qDebug() << "update's window title: " << _prod_name;
GET_REGISTRY_USER(_user)
if (!_user.contains("CheckForUpdates")) {
@ -239,11 +249,46 @@ void CWinPanel::slot_mainPageReady()
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_did_find_update_callback(&CWinPanel::updateFound);
win_sparkle_set_did_not_find_update_callback(&CWinPanel::updateNotFound);
win_sparkle_set_error_callback(&CWinPanel::updateError);
win_sparkle_init();
m_pMainPanel->cmdMainPage("updates", "on");
CLogger::log(QString("updates is on: ") + URL_APPCAST_UPDATES);
#endif
}
void CWinPanel::updatePanelStylesheets()
#if defined(_UPDMODULE)
#include "mainwindow.h"
extern HWND gTopWinId;
CWinPanel * getInstance()
{
m_pMainPanel->updateStylesheets();
if ( gTopWinId ) {
CMainWindow * window = reinterpret_cast<CMainWindow *>( GetWindowLongPtr( gTopWinId, GWLP_USERDATA ) );
if ( window )
return window->m_pWinPanel;
}
return NULL;
}
void CWinPanel::updateFound()
{
CLogger::log("found updates");
}
void CWinPanel::updateNotFound()
{
CLogger::log("updates isn't found");
}
void CWinPanel::updateError()
{
CLogger::log("updates error");
}
#endif

View File

@ -65,6 +65,13 @@ private:
CAscApplicationManager * m_pManager;
CMainPanelImpl * m_pMainPanel;
private:
#ifdef _UPDMODULE
static void updateFound();
static void updateNotFound();
static void updateError();
#endif
private slots:
void slot_windowClose();
void slot_windowChangeState(Qt::WindowState);

View File

@ -50,6 +50,8 @@
#include <QSettings>
#include <QDebug>
#define UM_INSTALL_UPDATE WM_USER+254
HWND gWinId = 0;
HWND gTopWinId;
extern byte g_dpi_ratio;
@ -72,11 +74,15 @@ CMainWindow::CMainWindow(CAscApplicationManager* pManager, HBRUSH windowBackgrou
// adjust window size
QRect _window_rect = reg_user.value("position", QRect(100, 100, 1324 * g_dpi_ratio, 800 * g_dpi_ratio)).toRect();
QRect _screen_size = Utils::getScreenGeometry(_window_rect.topLeft());
if (_screen_size.width() < _window_rect.width())
_window_rect.setLeft(_screen_size.left()), _window_rect.setWidth(_screen_size.width());
if ( _screen_size.width() < _window_rect.width() + 120 ||
_screen_size.height() < _window_rect.height() + 120 )
{
_window_rect.setLeft(_screen_size.left()),
_window_rect.setTop(_screen_size.top());
if (_screen_size.height() < _window_rect.height())
_window_rect.setTop(_screen_size.top()), _window_rect.setHeight(_screen_size.height());
if ( _screen_size.width() < _window_rect.width() ) _window_rect.setWidth(_screen_size.width());
if ( _screen_size.height() < _window_rect.height() ) _window_rect.setHeight(_screen_size.height());
}
m_pManager = pManager;
m_pManager->StartSpellChecker();
@ -469,6 +475,9 @@ LRESULT CALLBACK CMainWindow::WndProc( HWND hWnd, UINT message, WPARAM wParam, L
LocalFree(szArglist);
}
break;}
case UM_INSTALL_UPDATE:
window->m_pWinPanel->doClose();
break;
default: {
break;
}