diff --git a/src/core/messagesproxymodel.cpp b/src/core/messagesproxymodel.cpp index 26e4dd6a6..4954a75f7 100755 --- a/src/core/messagesproxymodel.cpp +++ b/src/core/messagesproxymodel.cpp @@ -70,13 +70,10 @@ QModelIndex MessagesProxyModel::getNextUnreadItemIndex(int default_row, int max_ } bool MessagesProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { - // FIXME: V případě hodně položke je to pomalé. - // V případě, že do messagelistu budu zobrazovat řekněme - // více než 4 000 zpráv, tak tady vracet automaticky false, - // neprovádět skutečně porovnávání. Q_UNUSED(left) Q_UNUSED(right) + // NOTE: Porovnání se provádí již při dotazu v databázi, netřeba řešit zde. return false; } diff --git a/src/main.cpp b/src/main.cpp index 6ce6dadfe..fa8510d30 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,6 +36,7 @@ #include #include #include +#include int main(int argc, char *argv[]) { @@ -96,7 +97,7 @@ int main(int argc, char *argv[]) { main_window.setWindowTitle(APP_LONG_NAME); // Now is a good time to initialize dynamic keyboard shortcuts. - DynamicShortcuts::load(qApp->userActions()); + DynamicShortcuts::load(qApp->userActions()); // Display main window. if (qApp->settings()->value(GROUP(GUI), SETTING(GUI::MainWindowStartsHidden)).toBool() && SystemTrayIcon::isSystemTrayActivated()) { @@ -133,6 +134,8 @@ int main(int argc, char *argv[]) { QTimer::singleShot(STARTUP_UPDATE_DELAY, application.system(), SLOT(checkForUpdatesOnStartup())); } + QObject::connect(QWebEngineProfile::defaultProfile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)), + qApp->downloadManager(), SLOT(download(QWebEngineDownloadItem*))); // Enter global event loop. return Application::exec(); diff --git a/src/miscellaneous/application.h b/src/miscellaneous/application.h index fe03129f9..7e28be5fe 100755 --- a/src/miscellaneous/application.h +++ b/src/miscellaneous/application.h @@ -131,15 +131,15 @@ class Application : public QtSingleApplication { } inline QString tempFolderPath() { - return IOFactory::getSystemFolder(SYSTEM_FOLDER_ENUM::TempLocation); + return IOFactory::getSystemFolder(QStandardPaths::TempLocation); } inline QString documentsFolderPath() { - return IOFactory::getSystemFolder(SYSTEM_FOLDER_ENUM::DocumentsLocation); + return IOFactory::getSystemFolder(QStandardPaths::DocumentsLocation); } inline QString homeFolderPath() { - return IOFactory::getSystemFolder(SYSTEM_FOLDER_ENUM::HomeLocation); + return IOFactory::getSystemFolder(QStandardPaths::HomeLocation); } void backupDatabaseSettings(bool backup_database, bool backup_settings, diff --git a/src/miscellaneous/iofactory.cpp b/src/miscellaneous/iofactory.cpp index ee623378c..398cc0ce4 100755 --- a/src/miscellaneous/iofactory.cpp +++ b/src/miscellaneous/iofactory.cpp @@ -30,8 +30,8 @@ IOFactory::IOFactory() { } -QString IOFactory::getSystemFolder(SYSTEM_FOLDER_ENUM::StandardLocation location) { - return SYSTEM_FOLDER_ENUM::writableLocation(location); +QString IOFactory::getSystemFolder(QStandardPaths::StandardLocation location) { + return QStandardPaths::writableLocation(location); } QString IOFactory::ensureUniqueFilename(const QString &name, const QString &append_format) { diff --git a/src/miscellaneous/iofactory.h b/src/miscellaneous/iofactory.h index f99337b61..59b5f1f79 100755 --- a/src/miscellaneous/iofactory.h +++ b/src/miscellaneous/iofactory.h @@ -23,7 +23,6 @@ #include "definitions/definitions.h" #include -#define SYSTEM_FOLDER_ENUM QStandardPaths class IOFactory { @@ -34,7 +33,7 @@ class IOFactory { public: // Returns system-wide folder according to type. - static QString getSystemFolder(SYSTEM_FOLDER_ENUM::StandardLocation location); + static QString getSystemFolder(QStandardPaths::StandardLocation location); // Checks given file if it exists and if it does, then generates non-existing new file // according to format. diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp index 9022f3a78..4ab375556 100755 --- a/src/miscellaneous/settings.cpp +++ b/src/miscellaneous/settings.cpp @@ -181,13 +181,13 @@ DKEY Downloads::AlwaysPromptForFilename = "prompt_for_filename"; DVALUE(bool) Downloads::AlwaysPromptForFilenameDef = false; DKEY Downloads::TargetDirectory = "target_directory"; -DVALUE(QString) Downloads::TargetDirectoryDef = IOFactory::getSystemFolder(SYSTEM_FOLDER_ENUM::DesktopLocation); +DVALUE(QString) Downloads::TargetDirectoryDef = IOFactory::getSystemFolder(QStandardPaths::DesktopLocation); DKEY Downloads::RemovePolicy = "remove_policy"; DVALUE(int) Downloads::RemovePolicyDef = DownloadManager::Never; DKEY Downloads::TargetExplicitDirectory = "target_explicit_directory"; -DVALUE(QString) Downloads::TargetExplicitDirectoryDef = IOFactory::getSystemFolder(SYSTEM_FOLDER_ENUM::DesktopLocation); +DVALUE(QString) Downloads::TargetExplicitDirectoryDef = IOFactory::getSystemFolder(QStandardPaths::DesktopLocation); DKEY Downloads::ShowDownloadsWhenNewDownloadStarts = "show_downloads_on_new_download_start"; DVALUE(bool) Downloads::ShowDownloadsWhenNewDownloadStartsDef = true; diff --git a/src/network-web/downloadmanager.cpp b/src/network-web/downloadmanager.cpp index 8f35a3047..4d57b606b 100755 --- a/src/network-web/downloadmanager.cpp +++ b/src/network-web/downloadmanager.cpp @@ -39,6 +39,7 @@ #include #include #include +#include DownloadItem::DownloadItem(bool is_direct_download, QNetworkReply *reply, QWidget *parent) : QWidget(parent), @@ -512,6 +513,10 @@ void DownloadManager::download(const QUrl &url, bool direct_download) { download(QNetworkRequest(url), direct_download); } +void DownloadManager::download(QWebEngineDownloadItem *down) { + download(down->url(), true); +} + void DownloadManager::handleUnsupportedContent(QNetworkReply *reply, bool direct_download) { if (reply == NULL || reply->url().isEmpty()) { return; diff --git a/src/network-web/downloadmanager.h b/src/network-web/downloadmanager.h index 737bff142..75a1af274 100755 --- a/src/network-web/downloadmanager.h +++ b/src/network-web/downloadmanager.h @@ -32,6 +32,7 @@ class AutoSaver; class DownloadModel; class QFileIconProvider; class QMimeData; +class QWebEngineDownloadItem; class DownloadItem : public QWidget { Q_OBJECT @@ -127,6 +128,7 @@ class DownloadManager : public TabContent { public slots: void download(const QNetworkRequest &request, bool direct_download = false); void download(const QUrl &url, bool direct_download = false); + void download(QWebEngineDownloadItem *down); void handleUnsupportedContent(QNetworkReply *reply, bool direct_download = false); void cleanup(); diff --git a/src/network-web/webview.cpp b/src/network-web/webview.cpp index 4da6d6412..b967c79a3 100755 --- a/src/network-web/webview.cpp +++ b/src/network-web/webview.cpp @@ -136,10 +136,6 @@ void WebView::saveCurrentPageToFile() { } void WebView::createConnections() { - connect(this, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); - connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(popupContextMenu(QPoint))); - connect(page(), SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadLink(QNetworkRequest))); - connect(m_actionSavePageAs, SIGNAL(triggered()), this, SLOT(saveCurrentPageToFile())); connect(m_actionPrint, SIGNAL(triggered()), this, SLOT(printCurrentPage())); connect(m_actionOpenLinkNewTab, SIGNAL(triggered()), this, SLOT(openLinkInNewTab())); @@ -232,10 +228,6 @@ void WebView::printCurrentPage() { print_preview.data()->exec(); } -void WebView::downloadLink(const QNetworkRequest &request) { - qApp->downloadManager()->download(request); -} - void WebView::mousePressEvent(QMouseEvent *event) { if (event->button() & Qt::MiddleButton) { m_gestureOrigin = event->pos(); diff --git a/src/network-web/webview.h b/src/network-web/webview.h index 394528bec..ae5a06b9f 100755 --- a/src/network-web/webview.h +++ b/src/network-web/webview.h @@ -65,9 +65,6 @@ class WebView : public QWebEngineView { void saveCurrentPageToFile(); void printCurrentPage(); - private slots: - void downloadLink(const QNetworkRequest &request); - protected: // Initializes all actions. void initializeActions();