From 2abe26db203c75798775a42eae2d7dc7ab9bf354 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Wed, 20 Dec 2017 18:08:56 +0100 Subject: Bug fixes .config/smolbote will now be created if missing Connected profiles to download manager Added missing license from WebPage --- BUGS.md | 6 +++--- src/browser.cpp | 37 ++--------------------------------- src/lib/downloads/downloadswidget.cpp | 6 ++---- src/lib/downloads/downloadswidget.h | 2 +- src/main.cpp | 15 +++++++++++--- src/webengine/webpage.cpp | 8 ++++++++ src/webengine/webpage.h | 8 ++++++++ src/webengine/webview.cpp | 3 ++- tools/check_license.rb | 4 ++++ 9 files changed, 42 insertions(+), 47 deletions(-) diff --git a/BUGS.md b/BUGS.md index fefded5..40857ee 100644 --- a/BUGS.md +++ b/BUGS.md @@ -6,16 +6,16 @@ How to reproduce: enter an address into the address bar, load the page, crash on ### MainWindow doesn't save size on close -### User config doesn't generate on first run if .config/smolbote doesn't exist - ### Close tab shortcut doesn't work ### Search terms in address bar QUrl always seems to return true when checking if valid url +### databases-incognito in home +Folder is empty. + ## To do list ### Search function ### Instance check on startup - diff --git a/src/browser.cpp b/src/browser.cpp index f4cadb5..7a169e9 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -57,12 +57,14 @@ void Browser::loadProfiles() for(const QString &name : profileList) { std::shared_ptr profile = std::make_shared(name, profileDir.absoluteFilePath(name), nullptr); profile->setRequestInterceptor(m_urlRequestInterceptor.get()); + connect(profile.get(), &WebEngineProfile::downloadRequested, m_downloadManager.get(), &DownloadsWidget::addDownload); m_profiles.insert(name, profile); } // Also add the Off-the-record profile std::shared_ptr otr = std::make_shared(nullptr); otr->setRequestInterceptor(m_urlRequestInterceptor.get()); + connect(otr.get(), &WebEngineProfile::downloadRequested, m_downloadManager.get(), &DownloadsWidget::addDownload); m_profiles.insert("", otr); // set default profile @@ -73,41 +75,6 @@ void Browser::loadProfiles() #endif } -/* -std::shared_ptr &Browser::bookmarks() -{ - Q_ASSERT(m_bookmarksManager); - return m_bookmarksManager; -} - -std::shared_ptr &Browser::downloads() -{ - Q_ASSERT(m_downloadManager); - return m_downloadManager; -} - -BlockerManager *Browser::blocklists() -{ - if(!m_blocklistManager) { - m_blocklistManager = new BlockerManager(); - } - return m_blocklistManager; -} - -MainWindow *Browser::activeWindow() -{ - if(m_windows.empty()) { - return nullptr; - } - - for(auto it = m_windows.cbegin(); it != m_windows.cend(); it++) { - if(it->data()->isActiveWindow()) { - return it->data(); - } - } - return m_windows.first().data(); -}*/ - MainWindow *Browser::createWindow() { // the window will delete itself when it closes, so we don't need to delete it diff --git a/src/lib/downloads/downloadswidget.cpp b/src/lib/downloads/downloadswidget.cpp index 0022ff9..460014f 100644 --- a/src/lib/downloads/downloadswidget.cpp +++ b/src/lib/downloads/downloadswidget.cpp @@ -16,7 +16,7 @@ #include #include "widgets/downloaditemwidget.h" -DownloadsWidget::DownloadsWidget(const QString path, QWidget *parent) : +DownloadsWidget::DownloadsWidget(const QString &downloadPath, QWidget *parent) : QWidget(parent), ui(new Ui::DownloadDialog) { @@ -27,15 +27,13 @@ DownloadsWidget::DownloadsWidget(const QString path, QWidget *parent) : ui->setupUi(this); ui->filePath->setWordWrap(true); - m_downloadPath = path; + m_downloadPath = downloadPath; connect(ui->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(showItemDetails(int))); } DownloadsWidget::~DownloadsWidget() { - qDebug("Destroying DownloadsManager"); - delete ui; } diff --git a/src/lib/downloads/downloadswidget.h b/src/lib/downloads/downloadswidget.h index a6dcf71..a601147 100644 --- a/src/lib/downloads/downloadswidget.h +++ b/src/lib/downloads/downloadswidget.h @@ -21,7 +21,7 @@ class DownloadsWidget : public QWidget Q_OBJECT public: - explicit DownloadsWidget(const QString path, QWidget *parent = 0); + explicit DownloadsWidget(const QString &downloadPath, QWidget *parent = nullptr); ~DownloadsWidget(); public slots: diff --git a/src/main.cpp b/src/main.cpp index 8e5edb0..7433cc8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,8 @@ #include "browser.h" #include #include +#include +#include #include #include "mainwindow.h" @@ -109,6 +111,8 @@ int main(int argc, char *argv[]) return 0; } + // TODO: check for other instances + std::shared_ptr config = std::make_shared(); config->readDefaultConfiguration(readConfig(parser.value(defaultConfigOption))); config->readUserConfiguration(parser.value(configOption).toStdString()); @@ -122,6 +126,14 @@ int main(int argc, char *argv[]) path = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/smolbote.cfg"; } + QDir configDir = QFileInfo(path).absoluteDir(); + if(!configDir.exists()) { + bool mkpathSuccess = configDir.mkpath("."); +#ifdef QT_DEBUG + qDebug("mkpath %s: %s", qUtf8Printable(configDir.absolutePath()), mkpathSuccess ? "ok" : "failed"); +#endif + } + #ifdef QT_DEBUG qDebug("Generating user config on first run to %s", qUtf8Printable(path)); #endif @@ -134,9 +146,6 @@ int main(int argc, char *argv[]) } instance.setConfiguration(config); - - // TODO: instance check - instance.loadProfiles(); MainWindow* mainWindow = instance.createWindow(); diff --git a/src/webengine/webpage.cpp b/src/webengine/webpage.cpp index 79ba809..a39c942 100644 --- a/src/webengine/webpage.cpp +++ b/src/webengine/webpage.cpp @@ -1,3 +1,11 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: git://neueland.iserlohn-fortress.net/smolbote.git + * + * SPDX-License-Identifier: GPL-3.0 + */ + #include "webpage.h" WebPage::WebPage(QWebEngineProfile *profile, QObject *parent) : diff --git a/src/webengine/webpage.h b/src/webengine/webpage.h index 6ae0802..ffbe34d 100644 --- a/src/webengine/webpage.h +++ b/src/webengine/webpage.h @@ -1,3 +1,11 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: git://neueland.iserlohn-fortress.net/smolbote.git + * + * SPDX-License-Identifier: GPL-3.0 + */ + #ifndef WEBPAGE_H #define WEBPAGE_H diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp index 4f7b386..55efad7 100644 --- a/src/webengine/webview.cpp +++ b/src/webengine/webview.cpp @@ -130,7 +130,8 @@ QMenu *WebView::pageMenu() void WebView::setPage(WebPage *page) { Q_CHECK_PTR(page); - //this->page()->deleteLater(); + // make sure the page gets cleaned up if we replace it by taking ownership + page->setParent(this); connect(page, &WebPage::linkHovered, this, &WebView::handleLinkHovered); connect(page, &WebPage::certificateErrorMessage, this, &WebView::handleCertificateError); QWebEngineView::setPage(page); diff --git a/tools/check_license.rb b/tools/check_license.rb index c519513..66cb0f1 100755 --- a/tools/check_license.rb +++ b/tools/check_license.rb @@ -15,4 +15,8 @@ file_names.each do |file_name| } end +if exit_code == 0 then + puts "All licenses okay" +end + exit exit_code -- cgit v1.2.1