diff options
-rw-r--r-- | smolbote.qbs | 2 | ||||
-rw-r--r-- | src/browser.cpp | 18 | ||||
-rw-r--r-- | src/lib/navigation/urllineedit.cpp | 8 | ||||
-rw-r--r-- | src/mainwindow.cpp | 13 | ||||
-rw-r--r-- | tools/updater/updater.go | 2 |
5 files changed, 26 insertions, 17 deletions
diff --git a/smolbote.qbs b/smolbote.qbs index 4bc1a7d..585210e 100644 --- a/smolbote.qbs +++ b/smolbote.qbs @@ -60,7 +60,7 @@ Project { defines.push("QT_DEPRECATED_WARNINGS", "QT_DISABLE_DEPRECATED_BEFORE="+project.deprecatedBefore); return defines; } - cpp.cxxLanguageVersion: "c++14" + cpp.cxxLanguageVersion: "c++11" Group { name: "main" diff --git a/src/browser.cpp b/src/browser.cpp index c01c165..15a7029 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -75,7 +75,8 @@ void Browser::loadPlugins() dir.cd("../lib/smolbote/plugins"); // Load all plugins - for(QString filename : dir.entryList(QDir::Files | QDir::Readable)) { + const QStringList files = dir.entryList(QDir::Files | QDir::Readable); + for(const QString &filename : files) { qDebug("Loading %s", qUtf8Printable(filename)); QPluginLoader loader(dir.absoluteFilePath(filename)); @@ -99,14 +100,15 @@ void Browser::loadProfiles() qDebug(">> Looking for profiles..."); profile(""); QDir dir(settings()->value("browser.profile.path").toString()); - for(const QString name : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { + const QStringList profileList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + for(const QString &name : profileList) { qDebug("- Adding profile %s", qUtf8Printable(name)); profile(name); } qDebug("<< Profiles end..."); //connect(this, SIGNAL(messageAvailable(QStringList)), this, SLOT(addWindow(QStringList))); - connect(this, &Browser::messageAvailable, [this](const QHash<QString, QVariant> params) { + connect(this, &Browser::messageAvailable, this, [&](const QHash<QString, QVariant> params) { //qDebug("Creating new window for [%s]", qUtf8Printable(params["urls"].toString())); @@ -224,7 +226,7 @@ void Browser::addWindow(MainWindow *window) Q_ASSERT(window != nullptr); m_windows.append(QPointer<MainWindow>(window)); - connect(window, &QObject::destroyed, [this]() { + connect(window, &QObject::destroyed, this, [&]() { this->clean(); }); @@ -240,9 +242,12 @@ MainWindow *Browser::addWindow(const QStringList params) void Browser::clean() { - for(int i = m_windows.size(); i >= 0; i--) { + for(int i = m_windows.count() - 1; i >= 0; i--) { if(m_windows[i].isNull()) { m_windows.removeAt(i); +#ifdef QT_DEBUG + qDebug("Removed deleted window from window list"); +#endif } } } @@ -274,7 +279,8 @@ WebEngineProfile* Browser::profile(const QString name) QStringList Browser::profiles() { QStringList l; - for(QString key : m_profiles.keys()) { + const QStringList keys = m_profiles.keys(); + for(const QString &key : keys) { l.append(key); } return l; diff --git a/src/lib/navigation/urllineedit.cpp b/src/lib/navigation/urllineedit.cpp index 5ba0701..5e47223 100644 --- a/src/lib/navigation/urllineedit.cpp +++ b/src/lib/navigation/urllineedit.cpp @@ -56,12 +56,12 @@ UrlLineEdit::UrlLineEdit(QWidget *parent) : listWidget->addItem("start.duckduckgo.com"); listWidget->addItem("neueland.iserlohn-fortress.net"); - connect(listWidget, &QListWidget::itemSelectionChanged, [this]() { + connect(listWidget, &QListWidget::itemSelectionChanged, this, [&]() { setText(listWidget->currentItem()->text()); }); - connect(listWidget, &QListWidget::itemActivated, [this](QListWidgetItem *item) { - setText(listWidget->currentItem()->text());; - this->m_menu->hide(); + connect(listWidget, &QListWidget::itemActivated, this, [&](QListWidgetItem *item) { + setText(item->text());; + m_menu->hide(); }); QWidgetAction *listAction = new QWidgetAction(m_menu); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 75f1da3..29a5c8f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -43,6 +43,9 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : m_addressBar(new AddressBar(navigationToolBar)), m_progressBar(new LoadingBar(this)) { + // delete this window when it closes + setAttribute(Qt::WA_DeleteOnClose, true); + // set up UI ui->setupUi(this); QAction *fullscreenAction = new QAction(this); @@ -59,8 +62,8 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : MainWindowMenuBar *menuBar = new MainWindowMenuBar(this); menuBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); - connect(menuBar->printAction(), &QAction::triggered, [this]() { - QString path = QFileDialog::getSaveFileName(this, tr("Print to PDF"), QDir::homePath(), tr("PDF files (*.pdf)")); + connect(menuBar->printAction(), &QAction::triggered, this, [&]() { + const QString path = QFileDialog::getSaveFileName(this, tr("Print to PDF"), QDir::homePath(), tr("PDF files (*.pdf)")); m_currentView->page()->printToPdf(path); }); @@ -94,17 +97,17 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : this->addToolBar(Qt::TopToolBarArea, navigationToolBar); // connect signals - connect(m_addressBar, &AddressBar::addressEntered, [&](const QUrl &url) { + connect(m_addressBar, &AddressBar::addressEntered, this, [&](const QUrl &url) { tabBar->currentView()->load(url); }); - connect(m_addressBar, &AddressBar::searchTermEntered, [&](const QString &string) { + connect(m_addressBar, &AddressBar::searchTermEntered, this, [&](const QString &string) { QString term = string.mid(1); term.replace(' ', '+'); tabBar->currentView()->load(QUrl::fromUserInput(qApp->settings()->value("general.search").toString().replace("$term", term))); }); connect(tabBar, SIGNAL(currentTabChanged(WebView*)), this, SLOT(handleTabChanged(WebView*))); - connect(qApp->bookmarks(), &BookmarksWidget::openUrl, [this](const QUrl &url) { + connect(qApp->bookmarks(), &BookmarksWidget::openUrl, this, [&](const QUrl &url) { if(this->isActiveWindow()) { this->newTab(url); } diff --git a/tools/updater/updater.go b/tools/updater/updater.go index ec778a3..07be93a 100644 --- a/tools/updater/updater.go +++ b/tools/updater/updater.go @@ -118,7 +118,7 @@ func main() { if *remoteFlag { fmt.Println("+ Reading remote version.json") - remote, err = parseJson("https://neueland.iserlohn-fortress.net/version.json") + remote, err = parseJson("https://neueland.iserlohn-fortress.net/smolbote/version") if err == nil { fmt.Println(fmt.Sprintf("| Got poi [%s-%d-%s]", remote.Poi.Version, remote.Poi.Patch, remote.Poi.Commit)) } |