Commit d6c4035f authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

We depend against qt5.15

parent c6ad2708
Pipeline #192432 passed with stage
in 2 minutes and 15 seconds
......@@ -69,9 +69,7 @@
#include <QtWebEngineWidgetsVersion>
#include <QtWebEngineCoreVersion>
#if QTWEBENGINECORE_VERSION >= QT_VERSION_CHECK(5, 13, 0)
#include <QWebEngineNotification>
#endif
#ifdef Q_OS_WIN
#include <QtWin>
......@@ -296,14 +294,12 @@ MainApplication::MainApplication(int &argc, char** argv)
m_webProfile = isPrivate() ? new QWebEngineProfile() : QWebEngineProfile::defaultProfile();
connect(m_webProfile, &QWebEngineProfile::downloadRequested, this, &MainApplication::downloadRequested);
#if QTWEBENGINECORE_VERSION >= QT_VERSION_CHECK(5, 13, 0)
m_webProfile->setNotificationPresenter([&] (std::unique_ptr<QWebEngineNotification> notification) {
auto notifications = desktopNotifications();
notifications->showNotification(
QPixmap::fromImage(notification->icon()), notification->title(), notification->message()
);
});
#endif
m_networkManager = new NetworkManager(this);
......@@ -963,25 +959,15 @@ void MainApplication::loadSettings()
webSettings->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
webSettings->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false);
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 10, 0)
webSettings->setAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript, settings.value(QSL("allowJavaScriptActivateWindow"), false).toBool());
#endif
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
webSettings->setAttribute(QWebEngineSettings::JavascriptCanPaste, settings.value(QSL("allowJavaScriptPaste"), true).toBool());
webSettings->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, settings.value(QSL("DisableVideoAutoPlay"), false).toBool());
webSettings->setAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly, settings.value(QSL("WebRTCPublicIpOnly"), true).toBool());
webSettings->setUnknownUrlSchemePolicy(QWebEngineSettings::AllowAllUnknownUrlSchemes);
#endif
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0)
webSettings->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, settings.value(QSL("DNSPrefetch"), true).toBool());
#endif
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 13, 0)
webSettings->setAttribute(QWebEngineSettings::PdfViewerEnabled, settings.value(QSL("intPDFViewer"), false).toBool());
webSettings->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, settings.value(QSL("screenCaptureEnabled"), false).toBool());
#endif
webSettings->setDefaultTextEncoding(settings.value(QSL("DefaultEncoding"), webSettings->defaultTextEncoding()).toString());
......
......@@ -93,11 +93,7 @@ QSize BookmarksToolbarButton::sizeHint() const
width = SEPARATOR_WIDTH;
}
else if (!m_showOnlyIcon) {
#if QTGUI_VERSION >= QT_VERSION_CHECK(5, 11, 0)
width += PADDING * 2 + fontMetrics().horizontalAdvance(m_bookmark->title());
#else
width += PADDING * 2 + fontMetrics().width(m_bookmark->title());
#endif
if (menu()) {
width += PADDING + 8;
......
......@@ -36,9 +36,7 @@ CookieJar::CookieJar(QObject* parent)
loadSettings();
m_client->loadAllCookies();
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
m_client->setCookieFilter(std::bind(&CookieJar::cookieFilter, this, std::placeholders::_1));
#endif
connect(m_client, &QWebEngineCookieStore::cookieAdded, this, &CookieJar::slotCookieAdded);
connect(m_client, &QWebEngineCookieStore::cookieRemoved, this, &CookieJar::slotCookieRemoved);
......@@ -46,9 +44,7 @@ CookieJar::CookieJar(QObject* parent)
CookieJar::~CookieJar()
{
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
m_client->setCookieFilter(nullptr);
#endif
}
void CookieJar::loadSettings()
......@@ -136,7 +132,6 @@ void CookieJar::slotCookieRemoved(const QNetworkCookie &cookie)
emit cookieRemoved(cookie);
}
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
bool CookieJar::cookieFilter(const QWebEngineCookieStore::FilterRequest &request) const
{
if (!m_allowCookies) {
......@@ -168,7 +163,6 @@ bool CookieJar::cookieFilter(const QWebEngineCookieStore::FilterRequest &request
return true;
}
#endif
bool CookieJar::rejectCookie(const QString &domain, const QNetworkCookie &cookie, const QString &cookieDomain) const
{
......
......@@ -56,9 +56,7 @@ private:
void slotCookieAdded(const QNetworkCookie &cookie);
void slotCookieRemoved(const QNetworkCookie &cookie);
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
bool cookieFilter(const QWebEngineCookieStore::FilterRequest &request) const;
#endif
bool acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource) const;
bool rejectCookie(const QString &domain, const QNetworkCookie &cookie, const QString &cookieDomain) const;
......
......@@ -75,10 +75,6 @@ CookieManager::CookieManager(QWidget *parent)
ui->blackList->addItems(settings.value("blacklist", QStringList()).toStringList());
settings.endGroup();
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 11, 0)
ui->filter3rdParty->hide();
#endif
ui->search->setPlaceholderText(tr("Search"));
ui->cookieTree->setDefaultItemShowMode(TreeWidget::ItemsCollapsed);
ui->cookieTree->sortItems(0, Qt::AscendingOrder);
......
......@@ -235,11 +235,9 @@ void DownloadItem::updateDownloadInfo(double currSpeed, qint64 received, qint64
// | m_remTime | |m_currSize| |m_fileSize| |m_speed|
// Remaining 26 minutes - 339MB of 693 MB (350kB/s)
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 10, 0)
if (m_download->isPaused()) {
return;
}
#endif
int estimatedTime = ((total - received) / 1024) / (currSpeed / 1024);
QString speed = currentSpeedToString(currSpeed);
......@@ -283,7 +281,6 @@ void DownloadItem::stop()
void DownloadItem::pauseResume()
{
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 10, 0)
if (m_download->isPaused()) {
m_download->resume();
ui->pauseResumeButton->setPixmap(QIcon::fromTheme(QSL("media-playback-pause")).pixmap(20, 20));
......@@ -292,7 +289,6 @@ void DownloadItem::pauseResume()
ui->pauseResumeButton->setPixmap(QIcon::fromTheme(QSL("media-playback-start")).pixmap(20, 20));
ui->downloadInfo->setText(tr("Paused - %1").arg(m_download->url().host()));
}
#endif
}
void DownloadItem::mouseDoubleClickEvent(QMouseEvent* e)
......@@ -312,13 +308,11 @@ void DownloadItem::customContextMenuRequested(const QPoint &pos)
menu.addSeparator();
menu.addAction(QIcon::fromTheme("process-stop"), tr("Cancel downloading"), this, &DownloadItem::stop)->setEnabled(m_downloading);
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 10, 0)
if (m_download->isPaused()) {
menu.addAction(QIcon::fromTheme("media-playback-start"), tr("Resume downloading"), this, &DownloadItem::pauseResume)->setEnabled(m_downloading);
} else {
menu.addAction(QIcon::fromTheme("media-playback-pause"), tr("Pause downloading"), this, &DownloadItem::pauseResume)->setEnabled(m_downloading);
}
#endif
menu.addAction(QIcon::fromTheme("list-remove"), tr("Remove From List"), this, &DownloadItem::clear)->setEnabled(!m_downloading);
......
......@@ -133,22 +133,10 @@ void DownloadManager::closeDownloadTab(QWebEngineDownloadItem *item) const
if (page->history()->count() != 0) {
return false;
}
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_UNUSED(url)
return true;
#else
if (page->url() != QUrl()) {
return false;
}
QUrl tabUrl = page->requestedUrl();
if (tabUrl.isEmpty()) {
tabUrl = QUrl(view->webTab()->locationBar()->text());
}
return tabUrl.host() == url.host();
#endif
};
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0)
if (!item->page()) {
return;
}
......@@ -163,30 +151,6 @@ void DownloadManager::closeDownloadTab(QWebEngineDownloadItem *item) const
if (testWebView(view, QUrl())) {
view->closeView();
}
#else
BrowserWindow* mainWindow = mApp->getWindow();
// If the main window was closed, there is no need to go further
if (mainWindow == nullptr) {
return;
}
if (testWebView(mainWindow->weView(), item->url())) {
mainWindow->weView()->closeView();
return;
}
const auto windows = mApp->windows();
for (auto *window : windows) {
const auto tabs = window->tabWidget()->allTabs();
for (auto *tab : tabs) {
auto *view = tab->webView();
if (testWebView(view, item->url())) {
view->closeView();
return;
}
}
}
#endif
}
QWinTaskbarButton *DownloadManager::taskbarButton()
......
......@@ -142,11 +142,7 @@ void LocationCompleterDelegate::paint(QPainter* painter, const QStyleOptionViewI
leftPosition += m_padding * 2;
// Trim link to maximum number of characters that can be visible, otherwise there may be perf issue with huge URLs
#if QTGUI_VERSION >= QT_VERSION_CHECK(5, 11, 0)
const int maxChars = (opt.rect.width() - leftPosition) / opt.fontMetrics.horizontalAdvance(QL1C('i'));
#else
const int maxChars = (opt.rect.width() - leftPosition) / opt.fontMetrics.width(QL1C('i'));
#endif
QString link;
const QByteArray linkArray = index.data(Qt::DisplayRole).toByteArray();
if (!linkArray.startsWith("data") && !linkArray.startsWith("javascript")) {
......@@ -176,11 +172,7 @@ void LocationCompleterDelegate::paint(QPainter* painter, const QStyleOptionViewI
// Draw separator
if (!link.isEmpty()) {
QChar separator = QL1C('-');
#if QTGUI_VERSION >= QT_VERSION_CHECK(5, 11, 0)
QRect separatorRect(leftPosition, center - linkMetrics.height() / 2, linkMetrics.horizontalAdvance(separator), linkMetrics.height());
#else
QRect separatorRect(leftPosition, center - linkMetrics.height() / 2, linkMetrics.width(separator), linkMetrics.height());
#endif
style->drawItemText(painter, separatorRect, Qt::AlignCenter, textPalette, true, separator, colorRole);
leftPosition += separatorRect.width() + m_padding * 2;
}
......
......@@ -42,9 +42,7 @@
#include <QWebEngineCertificateError>
#include <QtWebEngineWidgetsVersion>
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0)
#include <QWebEngineUrlScheme>
#endif
NetworkManager::NetworkManager(QObject *parent)
: QNetworkAccessManager(parent)
......@@ -59,11 +57,7 @@ NetworkManager::NetworkManager(QObject *parent)
// Create url interceptor
m_urlInterceptor = new NetworkUrlInterceptor(this);
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 13, 0)
mApp->webProfile()->setUrlRequestInterceptor(m_urlInterceptor);
#else
mApp->webProfile()->setRequestInterceptor(m_urlInterceptor);
#endif
// Create cookie jar
mApp->cookieJar();
......@@ -299,17 +293,12 @@ void NetworkManager::loadSettings()
void NetworkManager::shutdown()
{
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 13, 0)
mApp->webProfile()->setUrlRequestInterceptor(nullptr);
#else
mApp->webProfile()->setRequestInterceptor(nullptr);
#endif
}
// static
void NetworkManager::registerSchemes()
{
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0)
QWebEngineUrlScheme falkonScheme("falkon");
falkonScheme.setFlags(QWebEngineUrlScheme::SecureScheme | QWebEngineUrlScheme::ContentSecurityPolicyIgnored);
falkonScheme.setSyntax(QWebEngineUrlScheme::Syntax::Path);
......@@ -318,7 +307,6 @@ void NetworkManager::registerSchemes()
extensionScheme.setFlags(QWebEngineUrlScheme::SecureScheme | QWebEngineUrlScheme::ContentSecurityPolicyIgnored);
extensionScheme.setSyntax(QWebEngineUrlScheme::Syntax::Path);
QWebEngineUrlScheme::registerScheme(extensionScheme);
#endif
}
QNetworkReply *NetworkManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
......
......@@ -21,9 +21,7 @@
#include <QWebEnginePage>
#include <QtWebEngineWidgetsVersion>
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
#include <QWebEngineRegisterProtocolHandlerRequest>
#endif
ProtocolHandlerManager::ProtocolHandlerManager(QObject *parent)
: QObject(parent)
......@@ -83,10 +81,8 @@ void ProtocolHandlerManager::registerHandler(const QString &scheme, const QUrl &
QWebEnginePage *page = new QWebEnginePage(this);
connect(page, &QWebEnginePage::loadFinished, page, &QObject::deleteLater);
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
connect(page, &QWebEnginePage::registerProtocolHandlerRequested, this, [](QWebEngineRegisterProtocolHandlerRequest request) {
request.accept();
});
#endif
page->setHtml(QSL("<script>navigator.registerProtocolHandler('%1', '%2', '')</script>").arg(scheme, urlString), url);
}
......@@ -67,9 +67,7 @@ QString QmlWebEngineUrlRequestJob::initiator() const
return QString();
}
QString initiatorString;
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
initiatorString = QString::fromUtf8(m_job->initiator().toEncoded());
#endif
return initiatorString;
}
......
......@@ -30,14 +30,6 @@ JsOptions::JsOptions(QWidget* parent)
ui->setupUi(this);
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 10, 0)
ui->jscanActivateWindow->setVisible(false);
#endif
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 11, 0)
ui->jscanPaste->setVisible(false);
#endif
Settings settings;
settings.beginGroup("Web-Browser-Settings");
ui->jscanOpenWindow->setChecked(settings.value("allowJavaScriptOpenWindow", false).toBool());
......
......@@ -112,23 +112,6 @@ Preferences::Preferences(BrowserWindow* window)
ui->checkUpdates->setVisible(false);
#endif
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 11, 0)
ui->disableVideoAutoPlay->setVisible(false);
ui->webRTCPublicIpOnly->setVisible(false);
#endif
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 12, 0)
ui->dnsPrefetch->setVisible(false);
#endif
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 13, 0)
ui->intPDFViewer->setVisible(false);
#endif
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 13, 2)
ui->screenCaptureEnabled->setVisible(false);
#endif
auto setCategoryIcon = [this](int index, const QIcon &icon) {
ui->listWidget->item(index)->setIcon(QIcon(icon.pixmap(32)));
......
......@@ -138,12 +138,7 @@ ThemeManager::Theme ThemeManager::parseTheme(const QString &path, const QString
info.name = metadata.name();
info.description = metadata.comment();
info.author = metadata.value(QSL("X-Falkon-Author")).toString();
#if QTCORE_VERSION >= QT_VERSION_CHECK(5, 10, 0)
info.themePath = path.chopped(1);
#else
info.themePath = path;
info.themePath.chop(1);
#endif
const QString iconName = metadata.icon();
if (!iconName.isEmpty()) {
......
......@@ -1086,11 +1086,7 @@ QPixmap TabBarHelper::tabPixmap(int index) const
}
if (closeButton) {
#if QTGUI_VERSION >= QT_VERSION_CHECK(5, 11, 0)
const int width = tab.fontMetrics.horizontalAdvance(tab.text) + closeButton->width();
#else
const int width = tab.fontMetrics.width(tab.text) + closeButton->width();
#endif
tab.text = tab.fontMetrics.elidedText(tabText(index), Qt::ElideRight, width);
}
......
......@@ -40,12 +40,6 @@ HTML5PermissionsDialog::HTML5PermissionsDialog(QWidget* parent)
connect(ui->feature, SIGNAL(currentIndexChanged(int)), this, SLOT(featureIndexChanged()));
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &HTML5PermissionsDialog::saveSettings);
/* Hide unsupported HTML5 permissions */
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 10, 0)
ui->feature->removeItem(7);
ui->feature->removeItem(6);
#endif
showFeaturePermissions(currentFeature());
}
......@@ -119,12 +113,10 @@ QWebEnginePage::Feature HTML5PermissionsDialog::currentFeature() const
return QWebEnginePage::MediaAudioVideoCapture;
case 5:
return QWebEnginePage::MouseLock;
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 10, 0)
case 6:
return QWebEnginePage::DesktopVideoCapture;
case 7:
return QWebEnginePage::DesktopAudioVideoCapture;
#endif
default:
Q_UNREACHABLE();
return QWebEnginePage::Notifications;
......@@ -154,13 +146,11 @@ void HTML5PermissionsDialog::loadSettings()
m_granted[QWebEnginePage::MouseLock] = settings.value("MouseLockGranted", QStringList()).toStringList();
m_denied[QWebEnginePage::MouseLock] = settings.value("MouseLockDenied", QStringList()).toStringList();
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 10, 0)
m_granted[QWebEnginePage::DesktopVideoCapture] = settings.value("DesktopVideoCaptureGranted", QStringList()).toStringList();
m_denied[QWebEnginePage::DesktopVideoCapture] = settings.value("DesktopVideoCaptureDenied", QStringList()).toStringList();
m_granted[QWebEnginePage::DesktopAudioVideoCapture] = settings.value("DesktopAudioVideoCaptureGranted", QStringList()).toStringList();
m_denied[QWebEnginePage::DesktopAudioVideoCapture] = settings.value("DesktopAudioVideoCaptureDenied", QStringList()).toStringList();
#endif
settings.endGroup();
}
......@@ -188,13 +178,11 @@ void HTML5PermissionsDialog::saveSettings()
settings.setValue("MouseLockGranted", m_granted[QWebEnginePage::MouseLock]);
settings.setValue("MouseLockDenied", m_denied[QWebEnginePage::MouseLock]);
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 10, 0)
settings.setValue("DesktopVideoCaptureGranted", m_granted[QWebEnginePage::DesktopVideoCapture]);
settings.setValue("DesktopVideoCaptureDenied", m_denied[QWebEnginePage::DesktopVideoCapture]);
settings.setValue("DesktopAudioVideoCaptureGranted", m_granted[QWebEnginePage::DesktopAudioVideoCapture]);
settings.setValue("DesktopAudioVideoCaptureDenied", m_denied[QWebEnginePage::DesktopAudioVideoCapture]);
#endif
settings.endGroup();
......
......@@ -97,13 +97,11 @@ void HTML5PermissionsManager::loadSettings()
m_granted[QWebEnginePage::MouseLock] = settings.value("MouseLockGranted", QStringList()).toStringList();
m_denied[QWebEnginePage::MouseLock] = settings.value("MouseLockDenied", QStringList()).toStringList();
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 10, 0)
m_granted[QWebEnginePage::DesktopVideoCapture] = settings.value("DesktopVideoCaptureGranted", QStringList()).toStringList();
m_denied[QWebEnginePage::DesktopVideoCapture] = settings.value("DesktopVideoCaptureDenied", QStringList()).toStringList();
m_granted[QWebEnginePage::DesktopAudioVideoCapture] = settings.value("DesktopAudioVideoCaptureGranted", QStringList()).toStringList();
m_denied[QWebEnginePage::DesktopAudioVideoCapture] = settings.value("DesktopAudioVideoCaptureDenied", QStringList()).toStringList();
#endif
settings.endGroup();
}
......@@ -131,13 +129,11 @@ void HTML5PermissionsManager::saveSettings()
settings.setValue("MouseLockGranted", m_granted[QWebEnginePage::MouseLock]);
settings.setValue("MouseLockDenied", m_denied[QWebEnginePage::MouseLock]);
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 10, 0)
settings.setValue("DesktopVideoCaptureGranted", m_granted[QWebEnginePage::DesktopVideoCapture]);
settings.setValue("DesktopVideoCaptureDenied", m_denied[QWebEnginePage::DesktopVideoCapture]);
settings.setValue("DesktopAudioVideoCaptureGranted", m_granted[QWebEnginePage::DesktopAudioVideoCapture]);
settings.setValue("DesktopAudioVideoCaptureDenied", m_denied[QWebEnginePage::DesktopAudioVideoCapture]);
#endif
settings.endGroup();
}
......@@ -65,7 +65,6 @@ HTML5PermissionsNotification::HTML5PermissionsNotification(const QUrl &origin, Q
ui->textLabel->setText(tr("Allow %1 to hide your pointer?").arg(site));
break;
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 10, 0)
case QWebEnginePage::DesktopVideoCapture:
ui->textLabel->setText(tr("Allow %1 to capture your screen?").arg(site));
break;
......@@ -73,7 +72,6 @@ HTML5PermissionsNotification::HTML5PermissionsNotification(const QUrl &origin, Q
case QWebEnginePage::DesktopAudioVideoCapture:
ui->textLabel->setText(tr("Allow %1 to capture your screen and audio?").arg(site));
break;
#endif
default:
qWarning() << "Unknown feature" << feature;
break;
......
......@@ -115,11 +115,7 @@ QSize ListItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QMode
p->setFixedHeight(m_itemHeight + 2 * frameWidth);
}
}
#if QTGUI_VERSION >= QT_VERSION_CHECK(5, 11, 0)
int width = 2 * m_padding + option.fontMetrics.horizontalAdvance(index.data(Qt::DisplayRole).toString());
#else
int width = 2 * m_padding + option.fontMetrics.width(index.data(Qt::DisplayRole).toString());
#endif
width = width > (m_iconSize + 2 * m_padding) ? width : m_iconSize + 2 * m_padding;
if (m_uniformItemSizes) {
......
......@@ -397,11 +397,7 @@ QPixmap QzTools::createPixmapForSite(const QIcon &icon, const QString &title, co
{
const QFontMetrics fontMetrics = QApplication::fontMetrics();
const int padding = 4;
#if QTGUI_VERSION >= QT_VERSION_CHECK(5, 11, 0)
const int maxWidth = fontMetrics.horizontalAdvance(title.length() > url.length() ? title : url) + 3 * padding + 16;
#else
const int maxWidth = fontMetrics.width(title.length() > url.length() ? title : url) + 3 * padding + 16;
#endif
const int width = qMin(maxWidth, 150);
const int height = fontMetrics.height() * 2 + fontMetrics.leading() + 2 * padding;
......
Supports Markdown
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