[win-nix] set provider on open portal page

This commit is contained in:
Maxim Kadushkin
2018-10-10 15:54:52 +03:00
parent 141510d28e
commit ccf13abaef
5 changed files with 21 additions and 196 deletions

File diff suppressed because one or more lines are too long

View File

@ -280,21 +280,21 @@ int CAscTabWidget::count(int type) const
}
}
int CAscTabWidget::addPortal(QString url, QString name)
int CAscTabWidget::addPortal(const QString& url, const QString& name, const QString& provider)
{
if ( url.isEmpty() ) return -1;
setProperty("empty", false);
QString args;
if ( !url.contains(QRegularExpression("desktop=true")) )
QString args, _url = url;
if ( !_url.contains(QRegularExpression("desktop=true")) )
args.append("/products/files/?desktop=true");
else {
QRegularExpression _re("^((?:https?:\\/{2})?[^\\s\\/]+)([^\\s]+)", QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch _re_match = _re.match(url);
if ( _re_match.hasMatch() ) {
url = _re_match.captured(1);
_url = _re_match.captured(1);
args = _re_match.captured(2);
}
}
@ -303,19 +303,20 @@ int CAscTabWidget::addPortal(QString url, QString name)
pView->view()->SetBackgroundCefColor(244, 244, 244);
pView->setGeometry(0,0, size().width(), size().height() - tabBar()->height());
pView->initAsSimple();
pView->cef()->load((url + args).toStdWString());
pView->cef()->SetExternalCloud(provider.toStdWString());
pView->cef()->load((_url + args).toStdWString());
QString portal = name.isEmpty() ? Utils::getPortalName(url) : name;
CAscTabData * data = new CAscTabData(portal, etPortal);
data->setViewId(pView->cef()->GetId());
data->setUrl(url);
data->setUrl(_url);
pView->setData(data);
int tab_index = -1;
tab_index = insertTab(tab_index, pView, portal);
tabBar()->setTabToolTip(tab_index, url);
tabBar()->setTabToolTip(tab_index, _url);
((CTabBar *)tabBar())->setTabTheme(tab_index, CTabBar::Light);
((CTabBar *)tabBar())->tabStartLoading(tab_index);
@ -668,13 +669,13 @@ int CAscTabWidget::openLocalDocument(COpenOptions& opts, bool select, bool force
return tabIndex;
}
int CAscTabWidget::openPortal(const QString& url)
int CAscTabWidget::openPortal(const QString& url, const QString& provider)
{
QString portal_name = Utils::getPortalName(url);
int tabIndex = tabIndexByTitle(portal_name, etPortal);
if (tabIndex < 0) {
tabIndex = addPortal(url, "");
tabIndex = addPortal(url, "", provider);
}
return tabIndex;
@ -699,7 +700,7 @@ int CAscTabWidget::newPortal(const QString& url, const QString& name)
{
int tabIndex = tabIndexByEditorType(etNewPortal);
if ( tabIndex < 0 ) {
if ( !((tabIndex = addPortal(url, name)) < 0) ) {
if ( !((tabIndex = addPortal(url, name, "asc")) < 0) ) {
panel(tabIndex)->data()->setContentType(etNewPortal);
}
}

View File

@ -142,7 +142,7 @@ public:
// int addEditor(QString strName, AscEditorType etType = etDocument, std::wstring strUrl = L"");
int addEditor(COpenOptions&);
int addPortal(QString url, QString name);
int addPortal(const QString& url, const QString& name, const QString& provider);
int addOAuthPortal(const QString& portal, const QString& type, const QString& service);
int insertPanel(QWidget *, int);
void closeEditorByIndex(int index, bool checkmodified = false);
@ -202,7 +202,7 @@ public:
void applyDocumentSave(int, bool);
void setDocumentWebOption(int, const QString&);
int openPortal(const QString& url);
int openPortal(const QString& url, const QString& provider);
bool updatePortal(int index,const QString& url);
int newPortal(const QString& url, const QString& name);

View File

@ -814,7 +814,7 @@ void CMainPanel::onLocalFileLocation(int uid, QString param)
if ( !(_tab_index < 0)) {
((CAscTabWidget *)m_pTabs)->updatePortal(_tab_index, _folder);
} else {
_tab_index = m_pTabs->addPortal(_folder, "");
_tab_index = m_pTabs->addPortal(_folder, "", "");
}
if ( !(_tab_index < 0) ) {
@ -1319,7 +1319,9 @@ void CMainPanel::onKeyDown(void * eventData)
void CMainPanel::onPortalOpen(QString url)
{
int res = m_pTabs->openPortal(url);
QStringList _opts = url.split("#");
int res = _opts.size() > 1 ? m_pTabs->openPortal(_opts.at(1), _opts.at(0)) :
m_pTabs->openPortal(_opts.at(0), "asc");
if ( !(res < 0) ) {
toggleButtonMain(false, true);
m_pTabs->setCurrentIndex(res);

View File

@ -39,8 +39,8 @@
#define VER_NUM_MAJOR 5
#define VER_NUM_MINOR 2
#define VER_NUM_BUILD 52
#define VER_NUM_REVISION 412
#define VER_NUM_BUILD 53
#define VER_NUM_REVISION 414
#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)