mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-04-07 14:09:22 +08:00
[win-nix] refactoring
This commit is contained in:
@ -64,7 +64,6 @@
|
||||
#ifdef _WIN32
|
||||
#include "win/cprintdialog.h"
|
||||
#include "shlobj.h"
|
||||
#include "lmcons.h"
|
||||
|
||||
#else
|
||||
#define VK_F4 0x73
|
||||
@ -228,7 +227,7 @@ CMainPanel::CMainPanel(QWidget *parent, bool isCustomWindow, uchar dpi_ratio)
|
||||
QString params = QString("lang=%1&username=%3&location=%2")
|
||||
.arg(CLangater::getLanguageName(), Utils::systemLocationCode());
|
||||
wstring wparams = params.toStdWString();
|
||||
wstring user_name = readSystemUserName();
|
||||
wstring user_name = Utils::systemUserName();
|
||||
|
||||
wparams.replace(wparams.find(L"%3"), 2, user_name);
|
||||
AscAppManager::getInstance().InitAdditionalEditorParams(wparams);
|
||||
@ -1326,27 +1325,6 @@ void CMainPanel::onOutsideAuth(QString json)
|
||||
}
|
||||
}
|
||||
|
||||
wstring CMainPanel::readSystemUserName()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
WCHAR _env_name[UNLEN + 1]{0};
|
||||
DWORD _size = UNLEN + 1;
|
||||
|
||||
return GetUserName(_env_name, &_size) ?
|
||||
wstring(_env_name) : L"Unknown.User";
|
||||
#else
|
||||
QString _env_name = qgetenv("USER");
|
||||
if ( _env_name.isEmpty() ) {
|
||||
_env_name = qgetenv("USERNAME");
|
||||
|
||||
if (_env_name.isEmpty())
|
||||
_env_name = "Unknown.User";
|
||||
}
|
||||
|
||||
return _env_name.toStdWString();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CMainPanel::setInputFiles(QStringList * list)
|
||||
{
|
||||
RELEASEOBJECT(m_inFiles)
|
||||
|
||||
@ -92,7 +92,6 @@ private:
|
||||
int trySaveDocument(int);
|
||||
void RecalculatePlaces();
|
||||
|
||||
wstring readSystemUserName();
|
||||
signals:
|
||||
// void downloadEvent(NSEditorApi::CAscDownloadFileInfo *);
|
||||
void mainWindowChangeState(Qt::WindowState);
|
||||
|
||||
@ -155,7 +155,7 @@ int main( int argc, char *argv[] )
|
||||
application_cef->Init_CEF(&AscAppManager::getInstance(), argc, argv);
|
||||
/* ********************** */
|
||||
|
||||
GET_REGISTRY_SYSTEM(reg_system)
|
||||
// GET_REGISTRY_SYSTEM(reg_system)
|
||||
GET_REGISTRY_USER(reg_user)
|
||||
reg_user.setFallbacksEnabled(false);
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "shlobj.h"
|
||||
#include "lmcons.h"
|
||||
typedef HRESULT (__stdcall *SetCurrentProcessExplicitAppUserModelIDProc)(PCWSTR AppID);
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
@ -428,3 +429,24 @@ bool Utils::setAppUserModelId(const QString& modelid)
|
||||
|
||||
return _result;
|
||||
}
|
||||
|
||||
wstring Utils::systemUserName()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
WCHAR _env_name[UNLEN + 1]{0};
|
||||
DWORD _size = UNLEN + 1;
|
||||
|
||||
return GetUserName(_env_name, &_size) ?
|
||||
wstring(_env_name) : L"Unknown.User";
|
||||
#else
|
||||
QString _env_name = qgetenv("USER");
|
||||
if ( _env_name.isEmpty() ) {
|
||||
_env_name = qgetenv("USERNAME");
|
||||
|
||||
if (_env_name.isEmpty())
|
||||
_env_name = "Unknown.User";
|
||||
}
|
||||
|
||||
return _env_name.toStdWString();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -44,6 +44,7 @@ public:
|
||||
static QString lastPath(int type);
|
||||
static void keepLastPath(int type, const QString&);
|
||||
static QString getUserPath();
|
||||
static wstring systemUserName();
|
||||
static QString getAppCommonPath();
|
||||
static QRect getScreenGeometry(const QPoint&);
|
||||
static void openUrl(const QString&);
|
||||
|
||||
Reference in New Issue
Block a user