void TitleBar::onTokenAcquired(const QString& strToken) { WizService::Token::instance()->disconnect(this); #ifdef USEWEBENGINE QWebEngineView* comments = noteView()->commentView(); #else QWebView* comments = noteView()->commentView(); #endif if (strToken.isEmpty()) { comments->hide(); return; } QString strKbGUID = noteView()->note().strKbGUID; QString strGUID = noteView()->note().strGUID; m_commentsUrl = WizService::ApiEntry::commentUrl(strToken, strKbGUID, strGUID); if (comments->isVisible()) { // comments->load(QUrl()); comments->load(m_commentsUrl); } QUrl kUrl(WizService::ApiEntry::kUrlFromGuid(strToken, strKbGUID)); QString strCountUrl = WizService::ApiEntry::commentCountUrl(kUrl.host(), strToken, strKbGUID, strGUID); WizService::AsyncApi* api = new WizService::AsyncApi(this); connect(api, SIGNAL(getCommentsCountFinished(int)), SLOT(onGetCommentsCountFinished(int))); api->getCommentsCount(strCountUrl); }
void TitleBar::onCommentsButtonClicked() { #ifdef USEWEBENGINE QWebEngineView* comments = noteView()->commentView(); #else QWebView* comments = noteView()->commentView(); #endif if (comments->isVisible()) { comments->hide(); return; } if (isNetworkAccessible()) { if (!m_commentsUrl.isEmpty()) { comments->load(m_commentsUrl); QSplitter* splitter = qobject_cast<QSplitter*>(comments->parentWidget()); Q_ASSERT(splitter); QList<int> li = splitter->sizes(); Q_ASSERT(li.size() == 2); QList<int> lin; lin.push_back(li.value(0) - COMMENT_FRAME_WIDTH); lin.push_back(li.value(1) + COMMENT_FRAME_WIDTH); splitter->setSizes(lin); comments->show(); } else { loadErrorPage(); comments->show(); } } else { m_commentsBtn->setEnabled(false); } }