summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThanos Doukoudakis <thanos.doukoudakis@isode.com>2017-03-22 12:44:15 (GMT)
committerKevin Smith <kevin.smith@isode.com>2017-04-10 11:07:34 (GMT)
commitde89a73ff9c7575323cb61e358e8e3c8274214e4 (patch)
treeec2db27b99055823733258a09e1af9db5264c61d /Swift/QtUI/QtWebKitChatView.cpp
parentebd98c32281e2c2689480357f7e8ce6084e16384 (diff)
downloadswift-de89a73ff9c7575323cb61e358e8e3c8274214e4.zip
swift-de89a73ff9c7575323cb61e358e8e3c8274214e4.tar.bz2
Make the default chat view font to render thicker on Windows
Added a font-weight property on the body style to enhance the default font weight (400) only on Windows, in order to improve the look of the chat view. If the font-weight is being defined in any other styles rules with higher priority, this default value will be overwritten. Test-Information: Tested with with windows 10 (qt5.4.2), Windows 10 (qt5.7), Ubuntu 16.04.2 (qt5.5) Change-Id: Iafd969cff487a907d136b9d2d8b393a90681216f
Diffstat (limited to 'Swift/QtUI/QtWebKitChatView.cpp')
-rw-r--r--Swift/QtUI/QtWebKitChatView.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp
index 290bd59..16d31e3 100644
--- a/Swift/QtUI/QtWebKitChatView.cpp
+++ b/Swift/QtUI/QtWebKitChatView.cpp
@@ -327,60 +327,68 @@ void QtWebKitChatView::resetView() {
pageHTML.replace("==bodyBackground==", "background-color:#e3e3e3");
pageHTML.replace(pageHTML.indexOf("%@"), 2, theme_->getBase());
if (pageHTML.count("%@") > 3) {
pageHTML.replace(pageHTML.indexOf("%@"), 2, theme_->getMainCSS());
}
pageHTML.replace(pageHTML.indexOf("%@"), 2, "Variants/Blue on Green.css");
pageHTML.replace(pageHTML.indexOf("%@"), 2, ""/*headerSnippet.getContent()*/);
pageHTML.replace(pageHTML.indexOf("%@"), 2, ""/*footerSnippet.getContent()*/);
QEventLoop syncLoop;
connect(webView_, SIGNAL(loadFinished(bool)), &syncLoop, SLOT(quit()));
webPage_->mainFrame()->setHtml(pageHTML);
while (!viewReady_) {
syncLoop.processEvents(QEventLoop::AllEvents, 50);
}
document_ = webPage_->mainFrame()->documentElement();
scrollToBottom();
connect(webPage_->mainFrame(), SIGNAL(contentsSizeChanged(const QSize&)), this, SLOT(handleFrameSizeChanged()), Qt::UniqueConnection);
// Hooking up to scroll bar update, because Qt does not provide a way to retrieve accurate scroll bar updates from C++ directly.
QWebElement body = document_.findFirst("body");
assert(!body.isNull());
body.setAttribute("onscroll", "chatwindow.verticalScrollBarPositionChanged(document.body.scrollTop / (document.body.scrollHeight - window.innerHeight))");
// Adjust web view default 96 DPI setting to screen DPI.
// For more information see https://webkit.org/blog/57/css-units/
webView_->setZoomFactor(QApplication::desktop()->screen()->logicalDpiX() / 96.0);
body.setStyleProperty("font-size", QString("%1pt").arg(QApplication::font().pointSize()));
+
+#ifdef Q_OS_WIN
+ // Fix for Swift-162
+ // Changing the font weight for windows in order for the fonts to display better.
+ // In the future, when we enable dpiawareness on windows, this can be reverted.
+ body.setStyleProperty("font-weight", QString("500"));
+#endif // Q_OS_WIN
+
}
static QWebElement findElementWithID(QWebElement document, QString elementName, QString id) {
QWebElementCollection elements = document.findAll(elementName);
Q_FOREACH(QWebElement element, elements) {
if (element.attribute("id") == id) {
return element;
}
}
return QWebElement();
}
void QtWebKitChatView::setFileTransferProgress(QString id, const int percentageDone) {
rememberScrolledToBottom();
QWebElement ftElement = findElementWithID(document_, "div", id);
if (ftElement.isNull()) {
SWIFT_LOG(debug) << "Tried to access FT UI via invalid id!" << std::endl;
return;
}
QWebElement progressBar = ftElement.findFirst("div.progressbar");
progressBar.setStyleProperty("width", QString::number(percentageDone) + "%");
QWebElement progressBarValue = ftElement.findFirst("div.progressbar-value");
progressBarValue.setInnerXml(QString::number(percentageDone) + " %");
}
void QtWebKitChatView::setFileTransferStatus(QString id, const ChatWindow::FileTransferState state, const QString& /* msg */) {
rememberScrolledToBottom();
QWebElement ftElement = findElementWithID(document_, "div", id);
if (ftElement.isNull()) {