Work on web engine. It SUXX. I will abandon internal web browser completely. User would have to rely on external web browser setup.
This commit is contained in:
parent
b87efa1cf0
commit
3682c20611
10 changed files with 20 additions and 25 deletions
|
@ -70,13 +70,10 @@ QModelIndex MessagesProxyModel::getNextUnreadItemIndex(int default_row, int max_
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessagesProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const {
|
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(left)
|
||||||
Q_UNUSED(right)
|
Q_UNUSED(right)
|
||||||
|
|
||||||
|
// NOTE: Porovnání se provádí již při dotazu v databázi, netřeba řešit zde.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QWebEngineProfile>
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
@ -96,7 +97,7 @@ int main(int argc, char *argv[]) {
|
||||||
main_window.setWindowTitle(APP_LONG_NAME);
|
main_window.setWindowTitle(APP_LONG_NAME);
|
||||||
|
|
||||||
// Now is a good time to initialize dynamic keyboard shortcuts.
|
// Now is a good time to initialize dynamic keyboard shortcuts.
|
||||||
DynamicShortcuts::load(qApp->userActions());
|
DynamicShortcuts::load(qApp->userActions());
|
||||||
|
|
||||||
// Display main window.
|
// Display main window.
|
||||||
if (qApp->settings()->value(GROUP(GUI), SETTING(GUI::MainWindowStartsHidden)).toBool() && SystemTrayIcon::isSystemTrayActivated()) {
|
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()));
|
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.
|
// Enter global event loop.
|
||||||
return Application::exec();
|
return Application::exec();
|
||||||
|
|
|
@ -131,15 +131,15 @@ class Application : public QtSingleApplication {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString tempFolderPath() {
|
inline QString tempFolderPath() {
|
||||||
return IOFactory::getSystemFolder(SYSTEM_FOLDER_ENUM::TempLocation);
|
return IOFactory::getSystemFolder(QStandardPaths::TempLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString documentsFolderPath() {
|
inline QString documentsFolderPath() {
|
||||||
return IOFactory::getSystemFolder(SYSTEM_FOLDER_ENUM::DocumentsLocation);
|
return IOFactory::getSystemFolder(QStandardPaths::DocumentsLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString homeFolderPath() {
|
inline QString homeFolderPath() {
|
||||||
return IOFactory::getSystemFolder(SYSTEM_FOLDER_ENUM::HomeLocation);
|
return IOFactory::getSystemFolder(QStandardPaths::HomeLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void backupDatabaseSettings(bool backup_database, bool backup_settings,
|
void backupDatabaseSettings(bool backup_database, bool backup_settings,
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
IOFactory::IOFactory() {
|
IOFactory::IOFactory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IOFactory::getSystemFolder(SYSTEM_FOLDER_ENUM::StandardLocation location) {
|
QString IOFactory::getSystemFolder(QStandardPaths::StandardLocation location) {
|
||||||
return SYSTEM_FOLDER_ENUM::writableLocation(location);
|
return QStandardPaths::writableLocation(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IOFactory::ensureUniqueFilename(const QString &name, const QString &append_format) {
|
QString IOFactory::ensureUniqueFilename(const QString &name, const QString &append_format) {
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "definitions/definitions.h"
|
#include "definitions/definitions.h"
|
||||||
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#define SYSTEM_FOLDER_ENUM QStandardPaths
|
|
||||||
|
|
||||||
|
|
||||||
class IOFactory {
|
class IOFactory {
|
||||||
|
@ -34,7 +33,7 @@ class IOFactory {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Returns system-wide folder according to type.
|
// 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
|
// Checks given file if it exists and if it does, then generates non-existing new file
|
||||||
// according to format.
|
// according to format.
|
||||||
|
|
|
@ -181,13 +181,13 @@ DKEY Downloads::AlwaysPromptForFilename = "prompt_for_filename";
|
||||||
DVALUE(bool) Downloads::AlwaysPromptForFilenameDef = false;
|
DVALUE(bool) Downloads::AlwaysPromptForFilenameDef = false;
|
||||||
|
|
||||||
DKEY Downloads::TargetDirectory = "target_directory";
|
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";
|
DKEY Downloads::RemovePolicy = "remove_policy";
|
||||||
DVALUE(int) Downloads::RemovePolicyDef = DownloadManager::Never;
|
DVALUE(int) Downloads::RemovePolicyDef = DownloadManager::Never;
|
||||||
|
|
||||||
DKEY Downloads::TargetExplicitDirectory = "target_explicit_directory";
|
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";
|
DKEY Downloads::ShowDownloadsWhenNewDownloadStarts = "show_downloads_on_new_download_start";
|
||||||
DVALUE(bool) Downloads::ShowDownloadsWhenNewDownloadStartsDef = true;
|
DVALUE(bool) Downloads::ShowDownloadsWhenNewDownloadStartsDef = true;
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QWebEngineSettings>
|
#include <QWebEngineSettings>
|
||||||
|
#include <QWebEngineDownloadItem>
|
||||||
|
|
||||||
|
|
||||||
DownloadItem::DownloadItem(bool is_direct_download, QNetworkReply *reply, QWidget *parent) : QWidget(parent),
|
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);
|
download(QNetworkRequest(url), direct_download);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DownloadManager::download(QWebEngineDownloadItem *down) {
|
||||||
|
download(down->url(), true);
|
||||||
|
}
|
||||||
|
|
||||||
void DownloadManager::handleUnsupportedContent(QNetworkReply *reply, bool direct_download) {
|
void DownloadManager::handleUnsupportedContent(QNetworkReply *reply, bool direct_download) {
|
||||||
if (reply == NULL || reply->url().isEmpty()) {
|
if (reply == NULL || reply->url().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -32,6 +32,7 @@ class AutoSaver;
|
||||||
class DownloadModel;
|
class DownloadModel;
|
||||||
class QFileIconProvider;
|
class QFileIconProvider;
|
||||||
class QMimeData;
|
class QMimeData;
|
||||||
|
class QWebEngineDownloadItem;
|
||||||
|
|
||||||
class DownloadItem : public QWidget {
|
class DownloadItem : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -127,6 +128,7 @@ class DownloadManager : public TabContent {
|
||||||
public slots:
|
public slots:
|
||||||
void download(const QNetworkRequest &request, bool direct_download = false);
|
void download(const QNetworkRequest &request, bool direct_download = false);
|
||||||
void download(const QUrl &url, 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 handleUnsupportedContent(QNetworkReply *reply, bool direct_download = false);
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
|
|
|
@ -136,10 +136,6 @@ void WebView::saveCurrentPageToFile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::createConnections() {
|
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_actionSavePageAs, SIGNAL(triggered()), this, SLOT(saveCurrentPageToFile()));
|
||||||
connect(m_actionPrint, SIGNAL(triggered()), this, SLOT(printCurrentPage()));
|
connect(m_actionPrint, SIGNAL(triggered()), this, SLOT(printCurrentPage()));
|
||||||
connect(m_actionOpenLinkNewTab, SIGNAL(triggered()), this, SLOT(openLinkInNewTab()));
|
connect(m_actionOpenLinkNewTab, SIGNAL(triggered()), this, SLOT(openLinkInNewTab()));
|
||||||
|
@ -232,10 +228,6 @@ void WebView::printCurrentPage() {
|
||||||
print_preview.data()->exec();
|
print_preview.data()->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::downloadLink(const QNetworkRequest &request) {
|
|
||||||
qApp->downloadManager()->download(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebView::mousePressEvent(QMouseEvent *event) {
|
void WebView::mousePressEvent(QMouseEvent *event) {
|
||||||
if (event->button() & Qt::MiddleButton) {
|
if (event->button() & Qt::MiddleButton) {
|
||||||
m_gestureOrigin = event->pos();
|
m_gestureOrigin = event->pos();
|
||||||
|
|
|
@ -65,9 +65,6 @@ class WebView : public QWebEngineView {
|
||||||
void saveCurrentPageToFile();
|
void saveCurrentPageToFile();
|
||||||
void printCurrentPage();
|
void printCurrentPage();
|
||||||
|
|
||||||
private slots:
|
|
||||||
void downloadLink(const QNetworkRequest &request);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Initializes all actions.
|
// Initializes all actions.
|
||||||
void initializeActions();
|
void initializeActions();
|
||||||
|
|
Loading…
Add table
Reference in a new issue