Commit 9356a5c3 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov
parent 2e415011
......@@ -2,6 +2,7 @@
#define QASCAPPLICATIONMANAGER
#include "QAscMainPanel.h"
#include <QApplication>
class QAscApplicationManager : public CAscApplicationManager
{
......@@ -29,6 +30,14 @@ public:
{
m_pPanel->CheckKeyboard();
}
virtual int GetPlatformKeyboardLayout()
{
if (this->IsPlatformKeyboardSupport())
return CAscApplicationManager::GetPlatformKeyboardLayout();
return -1;
}
};
#endif // QASCAPPLICATIONMANAGER
......
......@@ -141,7 +141,8 @@ static int AscEditor_Main( int argc, char *argv[] )
a.setStyleSheet("#mainPanel { margin: 0; padding: 0; }\
#systemPanel { margin: 0; padding: 0; } \
#centralWidget { background: #313437; } \
QPushButton:focus{border:none;outline:none;}");
QPushButton:focus{border:none;outline:none;}\
QWidget {border:none;outline:none;}");
// Font
QFont mainFont = a.font();
......
......@@ -81,6 +81,8 @@ public:
width:135px; height: 27px; \
margin-left: 0px; margin-right: 1px; margin-top: 0px; margin-bottom: 0px; }";
strStyleQSS += "QTabBar::tab:focus { border:none;outline:none; }";
strStyleQSS += "QTabBar::tab:hover { \
background-color: #DDDDDD; border: 1px solid #DDDDDD; border-radius: 1px; }";
......@@ -192,6 +194,8 @@ protected:
width:%1px; height: 27px; \
margin-right: 1px; margin-left: 0px; margin-top: 0px; margin-bottom: 0px; }").arg(nTabWidth);
strStyleQSS += "QTabBar::tab:focus { border:none;outline:none; }";
strStyleQSS += "QTabBar::tab:hover { \
background-color: #DDDDDD; border: 1px solid #DDDDDD; border-radius: 1px; }";
......
......@@ -156,6 +156,7 @@ public:
virtual void StartSaveDialog(const std::wstring& sName);
virtual void EndSaveDialog(const std::wstring& sPath);
virtual bool IsPlatformKeyboardSupport();
virtual int GetPlatformKeyboardLayout();
protected:
......
......@@ -95,4 +95,25 @@ public:
AscEditorType GetEditorType();
};
class IFileDownloaderEvents
{
public:
virtual void OnProgress(int nProgress) = 0;
virtual void OnDownload(bool bIsSuccess) = 0;
};
class CCefFileDownloader_Private;
class Q_DECL_EXPORT CCefFileDownloader
{
protected:
CCefFileDownloader_Private* m_pInternal;
public:
CCefFileDownloader(IFileDownloaderEvents* pEvents);
~CCefFileDownloader();
void DownloadFile(CAscApplicationManager* pManager, const std::wstring& sUrl, const std::wstring& sDstFile);
};
#endif // CEFCLIENT_CEFWEBVIEW_H
......@@ -644,6 +644,69 @@ namespace NSCommon
///////////////////////////////////////////////////////
class CCefFileDownloaderThread : public NSThreads::CBaseThread, public IFileDownloaderEvents
{
public :
CCefFileDownloaderThread(CAscApplicationManager* pManager, std::wstring sFileUrl, std::wstring sFileDst) : NSThreads::CBaseThread()
{
m_sFilePath = sFileDst;
m_sFileUrl = sFileUrl;
m_bComplete = false;
m_bWork = false;
m_pManager = pManager;
m_pDownloader = NULL;
}
~CCefFileDownloaderThread()
{
RELEASEOBJECT(m_pDownloader);
}
bool IsFileDownloaded()
{
return m_bComplete;
}
void OnProgress(int nProgress)
{
}
void OnDownload(bool bIsSuccess)
{
m_bComplete = bIsSuccess;
m_bWork = false;
}
protected :
virtual DWORD ThreadProc ()
{
m_bComplete = false;
m_bWork = true;
m_pDownloader = new CCefFileDownloader(this);
m_pDownloader->DownloadFile(m_pManager, m_sFileUrl, m_sFilePath);
while (m_bWork)
{
NSThreads::Sleep(100);
}
m_bRunThread = FALSE;
return 0;
}
protected :
std::wstring m_sFilePath; // Путь к сохраненному файлу на диске
std::wstring m_sFileUrl; // Ссылка на скачивание файла
bool m_bComplete; // Закачался файл или нет
bool m_bWork;
CCefFileDownloader* m_pDownloader;
CAscApplicationManager* m_pManager;
};
class CCefScriptLoader : public NSThreads::CBaseThread
{
public:
......@@ -686,8 +749,12 @@ protected:
}
else
{
#ifdef WIN32
CFileDownloader oDownloader(m_sUrl, false);
oDownloader.SetFilePath(m_sDestination);
#else
CCefFileDownloaderThread oDownloader(m_pManager, m_sUrl, m_sDestination);
#endif
oDownloader.Start( 0 );
while ( oDownloader.IsRunned() )
{
......@@ -1350,6 +1417,14 @@ void CAscApplicationManager::EndSaveDialog(const std::wstring& sPath)
}
}
bool CAscApplicationManager::IsPlatformKeyboardSupport()
{
#ifdef WIN32
return true;
#endif
return false;
}
int CAscApplicationManager::GetPlatformKeyboardLayout()
{
#ifdef WIN32
......
......@@ -426,6 +426,213 @@ public:
void CloseBrowser(bool _force_close);
};
class CCefFileDownloader_Private : public client::ClientHandler, public client::ClientHandler::Delegate
{
public:
IFileDownloaderEvents* m_pEvents;
std::wstring m_sFileSrc;
std::wstring m_sFileDst;
CefRefPtr<CefBrowser> browser_;
int browser_id_;
CCefFileDownloader_Private() : client::ClientHandler(this, false, "https://onlyoffice.com/")
{
m_pEvents = NULL;
}
virtual ~CCefFileDownloader_Private()
{
}
public:
CefRefPtr<CefBrowser> GetBrowser() const
{
return browser_;
}
int GetBrowserId() const
{
return browser_id_;
}
virtual bool OnBeforePopup(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& target_url,
const CefString& target_frame_name,
CefLifeSpanHandler::WindowOpenDisposition target_disposition,
bool user_gesture,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings,
bool* no_javascript_access) OVERRIDE
{
CEF_REQUIRE_IO_THREAD();
return true;
}
virtual bool OnConsoleMessage(CefRefPtr<CefBrowser> browser,
const CefString& message,
const CefString& source,
int line) OVERRIDE
{
return false;
}
virtual bool OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event,
bool* is_keyboard_shortcut) OVERRIDE
{
return false;
}
virtual void OnBeforeDownload(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
CefRefPtr<CefBeforeDownloadCallback> callback)
{
CEF_REQUIRE_UI_THREAD();
callback->Continue(m_sFileDst, false);
}
void OnDownloadUpdated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
CefRefPtr<CefDownloadItemCallback> callback) OVERRIDE
{
CEF_REQUIRE_UI_THREAD();
if (NULL == m_pEvents)
return;
m_pEvents->OnProgress(download_item->GetPercentComplete());
if (download_item->IsComplete())
{
m_pEvents->OnDownload(true);
CloseBrowser(true);
}
if (download_item->IsCanceled())
{
m_pEvents->OnDownload(false);
CloseBrowser(true);
}
}
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE
{
client::ClientHandler::OnAfterCreated(browser);
if (!GetBrowser())
{
// We need to keep the main child window, but not popup windows
browser->GetHost()->StartDownload(m_sFileSrc);
browser_ = browser;
browser_id_ = browser->GetIdentifier();
}
}
void CloseBrowser(bool _force_close)
{
if (!CefCurrentlyOn(TID_UI))
{
CefPostTask(TID_UI,
base::Bind(&CCefFileDownloader_Private::CloseBrowser, this, _force_close));
return;
}
if (GetBrowser() && GetBrowser()->GetHost())
GetBrowser()->GetHost()->CloseBrowser(_force_close);
}
// ClientHandlerDelegate
virtual void OnBrowserCreated(CefRefPtr<CefBrowser> browser) OVERRIDE {}
// Called when the browser is closing.
virtual void OnBrowserClosing(CefRefPtr<CefBrowser> browser) OVERRIDE {}
// Called when the browser has been closed.
virtual void OnBrowserClosed(CefRefPtr<CefBrowser> browser) OVERRIDE {}
// Set the window URL address.
virtual void OnSetAddress(const std::string& url) OVERRIDE {}
// Set the window title.
virtual void OnSetTitle(const std::string& title) OVERRIDE {}
// Set fullscreen mode.
virtual void OnSetFullscreen(bool fullscreen) OVERRIDE {}
// Set the loading state.
virtual void OnSetLoadingState(bool isLoading,
bool canGoBack,
bool canGoForward) OVERRIDE {}
// Set the draggable regions.
virtual void OnSetDraggableRegions(const std::vector<CefDraggableRegion>& regions) OVERRIDE {}
public:
IMPLEMENT_REFCOUNTING(CCefFileDownloader_Private);
};
CCefFileDownloader::CCefFileDownloader(IFileDownloaderEvents* pEvents)
{
m_pInternal = new CCefFileDownloader_Private();
m_pInternal->m_pEvents = pEvents;
}
CCefFileDownloader::~CCefFileDownloader()
{
m_pInternal->Release();
m_pInternal = NULL;
}
void CCefFileDownloader::DownloadFile(CAscApplicationManager* pManager, const std::wstring& sUrl, const std::wstring& sDstFile)
{
m_pInternal->m_sFileSrc = sUrl;
m_pInternal->m_sFileDst = sDstFile;
CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager(NULL);
manager->SetStoragePath(pManager->m_oSettings.cookie_path, true, NULL);
CefWindowHandle hWnd = (CefWindowHandle)0;
CefWindowInfo info;
CefBrowserSettings _settings;
_settings.file_access_from_file_urls = STATE_ENABLED;
_settings.universal_access_from_file_urls = STATE_ENABLED;
_settings.javascript_access_clipboard = STATE_ENABLED;
_settings.plugins = STATE_DISABLED;
_settings.java = STATE_DISABLED;
// Initialize window info to the defaults for a child window.
#ifdef WIN32
RECT rect;
rect.left = 0;
rect.top = 0;
rect.right = 10;
rect.bottom = 10;
#else
CefRect rect;
rect.x = 0;
rect.y = 0;
rect.width = 10;
rect.height = 10;
#endif
info.SetAsChild(hWnd, rect);
// Creat the new child browser window
CefBrowserHost::CreateBrowser(info, m_pInternal, "ascdesktop://emptydownload.html", _settings, NULL);
}
class CAscClientHandler : public client::ClientHandler, public CCookieFoundCallback, public client::ClientHandler::Delegate
{
public:
......
......@@ -53,6 +53,17 @@ public:
mime_type_ = "text/html";
}
if (url.find("ascdesktop://emptydownload.html") != std::string::npos)
{
std::string sPageCrash = "<html><head><meta charset=\"utf-8\"><title>download</title></head><body></body></html>";
data_ = sPageCrash;
handled = true;
// Set the resulting mime type
mime_type_ = "text/html";
}
#if 0
if (strstr(url.c_str(), "handler.html") != NULL) {
// Build the response html
......
......@@ -471,7 +471,15 @@ protected :
m_bComplete = (CURLE_OK == res);
if (m_bComplete)
m_sFilePath = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sOut.c_str(), (LONG)sOut.length());
{
if (m_sFilePath.empty())
m_sFilePath = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sOut.c_str(), (LONG)sOut.length());
else
{
std::wstring sSrc = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sOut.c_str(), (LONG)sOut.length());
NSFile::CFileBinary::Move(sSrc, m_sFilePath);
}
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment