1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Port away from many deprecated things

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2023-08-21 22:18:27 +02:00
parent 131dad641e
commit 80bd47ef46
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B
19 changed files with 74 additions and 70 deletions

View File

@ -38,7 +38,7 @@ void SqueezeLabelV1::paintEvent(QPaintEvent* event)
if (m_SqueezedTextCache != text()) {
m_SqueezedTextCache = text();
QFontMetrics fm = fontMetrics();
if (fm.width(m_SqueezedTextCache) > contentsRect().width()) {
if (fm.horizontalAdvance(m_SqueezedTextCache) > contentsRect().width()) {
QString elided = fm.elidedText(text(), Qt::ElideMiddle, width());
setText(elided);
}

View File

@ -155,9 +155,9 @@ void StyleHelper::verticalGradient(QPainter* painter, const QRect &spanRect, con
if (StyleHelper::usePixmapCache()) {
QString key;
QColor keyColor = baseColor(lightColored);
key.sprintf("mh_vertical %d %d %d %d %d",
spanRect.width(), spanRect.height(), clipRect.width(),
clipRect.height(), keyColor.rgb());
key.asprintf("mh_vertical %d %d %d %d %d",
spanRect.width(), spanRect.height(), clipRect.width(),
clipRect.height(), keyColor.rgb());
QPixmap pixmap;
if (!QPixmapCache::find(key, pixmap)) {

View File

@ -309,10 +309,10 @@ void AdBlockCustomList::loadSubscription(const QStringList &disabledRules)
stream.setCodec("UTF-8");
if (!rules.contains(ddg1 + QL1S("\n")))
stream << ddg1 << endl;
stream << ddg1 << Qt::endl;
if (!rules.contains(QL1S("\n") + ddg2))
stream << ddg2 << endl;
stream << ddg2 << Qt::endl;
}
file.close();
@ -330,12 +330,12 @@ void AdBlockCustomList::saveSubscription()
QTextStream textStream(&file);
textStream.setCodec("UTF-8");
textStream << "Title: " << title() << endl;
textStream << "Url: " << url().toString() << endl;
textStream << "[Adblock Plus 1.1.1]" << endl;
textStream << "Title: " << title() << Qt::endl;
textStream << "Url: " << url().toString() << Qt::endl;
textStream << "[Adblock Plus 1.1.1]" << Qt::endl;
for (const AdBlockRule* rule : qAsConst(m_rules)) {
textStream << rule->filter() << endl;
textStream << rule->filter() << Qt::endl;
}
file.close();

View File

@ -77,7 +77,7 @@ QIcon BookmarkItem::icon()
switch (m_type) {
case Url:
if (m_iconTime.isNull() || m_iconTime.elapsed() > iconCacheTime) {
if ((!m_iconTime.isValid()) || (m_iconTime.elapsed() > iconCacheTime)) {
m_icon = IconProvider::iconForUrl(m_url);
m_iconTime.restart();
}

View File

@ -21,7 +21,7 @@
#include <QString>
#include <QList>
#include <QIcon>
#include <QTime>
#include <QElapsedTimer>
#include <QUrl>
#include "qzcommon.h"
@ -97,7 +97,7 @@ private:
QString m_description;
QString m_keyword;
QIcon m_icon;
QTime m_iconTime;
QElapsedTimer m_iconTime;
int m_visitCount;
bool m_expanded;
bool m_sidebarExpanded;

View File

@ -51,13 +51,13 @@ bool HtmlExporter::exportBookmarks(BookmarkItem* root)
QTextStream stream(&file);
stream.setCodec("UTF-8");
stream << "<!DOCTYPE NETSCAPE-Bookmark-file-1>" << endl;
stream << "<!-- This is an automatically generated file." << endl;
stream << " It will be read and overwritten." << endl;
stream << " DO NOT EDIT! -->" << endl;
stream << R"(<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">)" << endl;
stream << "<TITLE>Bookmarks</TITLE>" << endl;
stream << "<H1>Bookmarks</H1>" << endl;
stream << "<!DOCTYPE NETSCAPE-Bookmark-file-1>" << Qt::endl;
stream << "<!-- This is an automatically generated file." << Qt::endl;
stream << " It will be read and overwritten." << Qt::endl;
stream << " DO NOT EDIT! -->" << Qt::endl;
stream << R"(<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">)" << Qt::endl;
stream << "<TITLE>Bookmarks</TITLE>" << Qt::endl;
stream << "<H1>Bookmarks</H1>" << Qt::endl;
writeBookmark(root, stream, 0);
return true;
@ -72,35 +72,35 @@ void HtmlExporter::writeBookmark(BookmarkItem* item, QTextStream &stream, int le
switch (item->type()) {
case BookmarkItem::Url:
stream << indent << "<DT><A HREF=\"" << item->urlString() << "\">" << item->title() << "</A>" << endl;
stream << indent << "<DT><A HREF=\"" << item->urlString() << "\">" << item->title() << "</A>" << Qt::endl;
break;
case BookmarkItem::Separator:
stream << indent << "<HR>" << endl;
stream << indent << "<HR>" << Qt::endl;
break;
case BookmarkItem::Folder: {
stream << indent << "<DT><H3>" << item->title() << "</H3>" << endl;
stream << indent << "<DL><p>" << endl;
stream << indent << "<DT><H3>" << item->title() << "</H3>" << Qt::endl;
stream << indent << "<DL><p>" << Qt::endl;
const auto children = item->children();
for (BookmarkItem* child : children) {
writeBookmark(child, stream, level + 1);
}
stream << indent << "</DL><p>" << endl;
stream << indent << "</DL><p>" << Qt::endl;
break;
}
case BookmarkItem::Root: {
stream << indent << "<DL><p>" << endl;
stream << indent << "<DL><p>" << Qt::endl;
const auto children = item->children();
for (BookmarkItem* child : children) {
writeBookmark(child, stream, level + 1);
}
stream << indent << "</DL><p>" << endl;
stream << indent << "</DL><p>" << Qt::endl;
break;
}

View File

@ -23,6 +23,7 @@
#include <QBasicTimer>
#include <QUrl>
#include <QNetworkReply>
#include <QElapsedTimer>
#include <QTime>
#include "qzcommon.h"
@ -52,7 +53,7 @@ public:
QString path() const;
QString fileName() const;
~DownloadItem() override;
void setDownTimer(const QTime &timer) { m_downTimer = timer; }
void setDownTimer(const QElapsedTimer &timer) { m_downTimer = timer; }
void startDownloading();
@ -87,7 +88,7 @@ private:
QWebEngineDownloadItem* m_download;
QString m_path;
QString m_fileName;
QTime m_downTimer;
QElapsedTimer m_downTimer;
QTime m_remTime;
QUrl m_downUrl;
bool m_openFile;

View File

@ -260,7 +260,7 @@ void DownloadManager::clearList()
void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
{
QTime downloadTimer;
QElapsedTimer downloadTimer;
downloadTimer.start();
closeDownloadTab(downloadItem);

View File

@ -22,6 +22,7 @@
#include <QApplication>
#include <QDateTime>
#include <QTimeZone>
#include <QTimer>
static QString dateTimeToString(const QDateTime &dateTime)
@ -336,7 +337,7 @@ void HistoryModel::historyEntryAdded(const HistoryEntry &entry)
m_todayItem = new HistoryItem(0);
m_todayItem->setStartTimestamp(-1);
m_todayItem->setEndTimestamp(QDateTime(QDate::currentDate()).toMSecsSinceEpoch());
m_todayItem->setEndTimestamp(QDateTime(QDate::currentDate(), QTime(), QTimeZone::systemTimeZone()).toMSecsSinceEpoch());
m_todayItem->title = tr("Today");
m_rootItem->prependChild(m_todayItem);
@ -466,17 +467,17 @@ void HistoryModel::init()
QString itemName;
if (timestampDate == today) {
endTimestamp = QDateTime(today).toMSecsSinceEpoch();
endTimestamp = QDateTime(today, QTime(), QTimeZone::systemTimeZone()).toMSecsSinceEpoch();
itemName = tr("Today");
}
else if (timestampDate >= week) {
endTimestamp = QDateTime(week).toMSecsSinceEpoch();
endTimestamp = QDateTime(week, QTime(), QTimeZone::systemTimeZone()).toMSecsSinceEpoch();
itemName = tr("This Week");
}
else if (timestampDate.month() == month.month() && timestampDate.year() == month.year()) {
endTimestamp = QDateTime(month).toMSecsSinceEpoch();
endTimestamp = QDateTime(month, QTime(), QTimeZone::systemTimeZone()).toMSecsSinceEpoch();
itemName = tr("This Month");
}
@ -484,8 +485,8 @@ void HistoryModel::init()
QDate startDate(timestampDate.year(), timestampDate.month(), timestampDate.daysInMonth());
QDate endDate(startDate.year(), startDate.month(), 1);
timestamp = QDateTime(startDate, QTime(23, 59, 59)).toMSecsSinceEpoch();
endTimestamp = QDateTime(endDate).toMSecsSinceEpoch();
timestamp = QDateTime(startDate, QTime(23, 59, 59), QTimeZone::systemTimeZone()).toMSecsSinceEpoch();
endTimestamp = QDateTime(endDate, QTime(), QTimeZone::systemTimeZone()).toMSecsSinceEpoch();
itemName = QString("%1 %2").arg(History::titleCaseLocalizedMonth(timestampDate.month()), QString::number(timestampDate.year()));
}

View File

@ -35,6 +35,7 @@
#include <QWebEngineSettings>
#include <QNetworkDiskCache>
#include <QDateTime>
#include <QTimeZone>
#include <QCloseEvent>
#include <QFileInfo>
#include <QWebEngineProfile>
@ -111,13 +112,13 @@ void ClearPrivateData::dialogAccepted()
switch (ui->historyLength->currentIndex()) {
case 0: //Later Today
end = QDateTime(today).toMSecsSinceEpoch();
end = QDateTime(today, QTime(), QTimeZone::systemTimeZone()).toMSecsSinceEpoch();
break;
case 1: //Week
end = QDateTime(week).toMSecsSinceEpoch();
end = QDateTime(week, QTime(), QTimeZone::systemTimeZone()).toMSecsSinceEpoch();
break;
case 2: //Month
end = QDateTime(month).toMSecsSinceEpoch();
end = QDateTime(month, QTime(), QTimeZone::systemTimeZone()).toMSecsSinceEpoch();
break;
case 3: //All
break;

View File

@ -45,7 +45,7 @@ QPoint QmlWheelEvent::globalPos() const
if (!m_wheelEvent) {
return QPoint(-1, -1);
}
return m_wheelEvent->globalPos();
return m_wheelEvent->globalPosition().toPoint();
}
QPointF QmlWheelEvent::globalPosF() const
@ -53,7 +53,7 @@ QPointF QmlWheelEvent::globalPosF() const
if (!m_wheelEvent) {
return QPointF(-1, -1);
}
return m_wheelEvent->globalPosF();
return m_wheelEvent->globalPosition();
}
int QmlWheelEvent::globalX() const
@ -61,7 +61,7 @@ int QmlWheelEvent::globalX() const
if (!m_wheelEvent) {
return -1;
}
return m_wheelEvent->globalX();
return m_wheelEvent->globalPosition().toPoint().x();
}
int QmlWheelEvent::globalY() const
@ -69,7 +69,7 @@ int QmlWheelEvent::globalY() const
if (!m_wheelEvent) {
return -1;
}
return m_wheelEvent->globalY();
return m_wheelEvent->globalPosition().toPoint().x();
}
bool QmlWheelEvent::inverted() const
@ -101,7 +101,7 @@ QPoint QmlWheelEvent::pos() const
if (!m_wheelEvent) {
return QPoint(-1, -1);
}
return m_wheelEvent->pos();
return m_wheelEvent->position().toPoint();
}
QPointF QmlWheelEvent::posF() const
@ -109,7 +109,7 @@ QPointF QmlWheelEvent::posF() const
if (!m_wheelEvent) {
return QPointF(-1, -1);
}
return m_wheelEvent->posF();
return m_wheelEvent->position();
}
int QmlWheelEvent::source() const
@ -125,7 +125,7 @@ int QmlWheelEvent::x() const
if (!m_wheelEvent) {
return -1;
}
return m_wheelEvent->x();
return m_wheelEvent->position().toPoint().x();
}
int QmlWheelEvent::y() const
@ -133,7 +133,7 @@ int QmlWheelEvent::y() const
if (!m_wheelEvent) {
return -1;
}
return m_wheelEvent->y();
return m_wheelEvent->position().toPoint().y();
}
void QmlWheelEvent::clear()

View File

@ -386,5 +386,5 @@ void QmlPluginInterface::setAcceptNavigationRequest(const QJSValue &acceptNaviga
QQmlListProperty<QObject> QmlPluginInterface::childItems()
{
return QQmlListProperty<QObject>(this, m_childItems);
return QQmlListProperty<QObject>(this, &m_childItems);
}

View File

@ -64,7 +64,7 @@
QString WebPage::s_lastUploadLocation = QDir::homePath();
QUrl WebPage::s_lastUnsupportedUrl;
QTime WebPage::s_lastUnsupportedUrlTime;
QElapsedTimer WebPage::s_lastUnsupportedUrlTime;
QStringList s_supportedSchemes;
static const bool kEnableJsOutput = qEnvironmentVariableIsSet("FALKON_ENABLE_JS_OUTPUT");
@ -365,7 +365,7 @@ void WebPage::desktopServicesOpen(const QUrl &url)
// Open same url only once in 2 secs
const int sameUrlTimeout = 2 * 1000;
if (s_lastUnsupportedUrl != url || s_lastUnsupportedUrlTime.isNull() || s_lastUnsupportedUrlTime.elapsed() > sameUrlTimeout) {
if ((s_lastUnsupportedUrl != url) || (!s_lastUnsupportedUrlTime.isValid()) || (s_lastUnsupportedUrlTime.elapsed() > sameUrlTimeout)) {
s_lastUnsupportedUrl = url;
s_lastUnsupportedUrlTime.restart();
QDesktopServices::openUrl(url);

View File

@ -22,6 +22,7 @@
#include <QWebEngineScript>
#include <QWebEngineFullScreenRequest>
#include <QVector>
#include <QElapsedTimer>
#include "qzcommon.h"
@ -104,7 +105,7 @@ private:
static QString s_lastUploadLocation;
static QUrl s_lastUnsupportedUrl;
static QTime s_lastUnsupportedUrlTime;
static QElapsedTimer s_lastUnsupportedUrlTime;
DelayedFileWatcher* m_fileWatcher;
QEventLoop* m_runningLoop;

View File

@ -1055,9 +1055,9 @@ void WebView::_wheelEvent(QWheelEvent *event)
if (event->spontaneous()) {
const qreal multiplier = QApplication::wheelScrollLines() / 3.0;
if (multiplier != 1.0) {
QWheelEvent e(event->pos(), event->globalPos(), event->pixelDelta(),
event->angleDelta() * multiplier, 0, Qt::Horizontal, event->buttons(),
event->modifiers(), event->phase(), event->source(), event->inverted());
QWheelEvent e(event->position(), event->globalPosition(), event->pixelDelta(),
event->angleDelta() * multiplier, event->buttons(),
event->modifiers(), event->phase(), event->inverted(), event->source());
QApplication::sendEvent(m_rwhvqt, &e);
event->accept();
}

View File

@ -72,7 +72,7 @@ QVector<PasswordEntry> KWalletPasswordBackend::getEntries(const QUrl &url)
}
// Sort to prefer last updated entries
qSort(list.begin(), list.end());
std::sort(list.begin(), list.end());
return list;
}

View File

@ -452,7 +452,7 @@ void TabManagerWidget::processActions()
m_refreshBlocked = true;
QHash<BrowserWindow*, WebTab*> selectedTabs;
QMultiHash<BrowserWindow*, WebTab*> selectedTabs;
const QString &command = sender()->objectName();
@ -477,7 +477,7 @@ void TabManagerWidget::processActions()
continue;
}
selectedTabs.insertMulti(mainWindow, webTab);
selectedTabs.insert(mainWindow, webTab);
}
winItem->setCheckState(0, Qt::Unchecked);
}
@ -518,7 +518,7 @@ void TabManagerWidget::changeGroupType()
}
}
void TabManagerWidget::closeSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash)
void TabManagerWidget::closeSelectedTabs(const QMultiHash<BrowserWindow*, WebTab*> &tabsHash)
{
if (tabsHash.isEmpty()) {
return;
@ -534,7 +534,7 @@ void TabManagerWidget::closeSelectedTabs(const QHash<BrowserWindow*, WebTab*> &t
}
}
static void detachTabsTo(BrowserWindow* targetWindow, const QHash<BrowserWindow*, WebTab*> &tabsHash)
static void detachTabsTo(BrowserWindow* targetWindow, const QMultiHash<BrowserWindow*, WebTab*> &tabsHash)
{
const QList<BrowserWindow*> &windows = tabsHash.uniqueKeys();
for (BrowserWindow* mainWindow : windows) {
@ -552,7 +552,7 @@ static void detachTabsTo(BrowserWindow* targetWindow, const QHash<BrowserWindow*
}
}
void TabManagerWidget::detachSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash)
void TabManagerWidget::detachSelectedTabs(const QMultiHash<BrowserWindow*, WebTab*> &tabsHash)
{
if (tabsHash.isEmpty() ||
(tabsHash.uniqueKeys().size() == 1 &&
@ -566,7 +566,7 @@ void TabManagerWidget::detachSelectedTabs(const QHash<BrowserWindow*, WebTab*> &
detachTabsTo(newWindow, tabsHash);
}
bool TabManagerWidget::bookmarkSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash)
bool TabManagerWidget::bookmarkSelectedTabs(const QMultiHash<BrowserWindow*, WebTab*> &tabsHash)
{
auto* dialog = new QDialog(getWindow(), Qt::WindowStaysOnTopHint | Qt::MSWindowsFixedSizeDialogHint);
auto* layout = new QBoxLayout(QBoxLayout::TopToBottom, dialog);
@ -608,7 +608,7 @@ bool TabManagerWidget::bookmarkSelectedTabs(const QHash<BrowserWindow*, WebTab*>
return true;
}
void TabManagerWidget::unloadSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash)
void TabManagerWidget::unloadSelectedTabs(const QMultiHash<BrowserWindow*, WebTab*> &tabsHash)
{
if (tabsHash.isEmpty()) {
return;
@ -951,7 +951,7 @@ bool TabTreeWidget::dropMimeData(QTreeWidgetItem *parent, int index, const QMime
}
}
else if (!webTab->isPinned()) {
QHash<BrowserWindow*, WebTab*> tabsHash;
QMultiHash<BrowserWindow*, WebTab*> tabsHash;
tabsHash.insert(window, webTab);
detachTabsTo(targetWindow, tabsHash);

View File

@ -20,7 +20,7 @@
#include <QWidget>
#include <QPointer>
#include <QHash>
#include <QMultiHash>
#include <QTreeWidgetItem>
namespace Ui
@ -68,10 +68,10 @@ public:
explicit TabManagerWidget(BrowserWindow* mainClass, QWidget* parent = 0, bool defaultWidget = false);
~TabManagerWidget() override;
void closeSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash);
void detachSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash);
bool bookmarkSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash);
void unloadSelectedTabs(const QHash<BrowserWindow*, WebTab*> &tabsHash);
void closeSelectedTabs(const QMultiHash<BrowserWindow*, WebTab*> &tabsHash);
void detachSelectedTabs(const QMultiHash<BrowserWindow*, WebTab*> &tabsHash);
bool bookmarkSelectedTabs(const QMultiHash<BrowserWindow*, WebTab*> &tabsHash);
void unloadSelectedTabs(const QMultiHash<BrowserWindow*, WebTab*> &tabsHash);
void setGroupType(GroupType type);

View File

@ -321,12 +321,12 @@ bool TLDExtractor::parseData(const QString &dataFile, bool loadPrivateDomains)
line = line.left(line.indexOf(QLatin1Char(' ')));
if (!line.contains(QLatin1Char('.'))) {
m_tldHash.insertMulti(line, line);
m_tldHash.insert(line, line);
}
else {
QString key = line.mid(line.lastIndexOf(QLatin1Char('.')) + 1);
m_tldHash.insertMulti(key, line);
m_tldHash.insert(key, line);
}
}