aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-09-22 17:26:40 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2017-09-22 17:26:40 +0200
commitabc6beaf783fad2dacf9e4ed75208854e0760f5e (patch)
tree336430e898f57b21e9be46d27767ae24e440e5af /src
parentUpdated documentation (diff)
downloadsmolbote-abc6beaf783fad2dacf9e4ed75208854e0760f5e.tar.xz
Some fixes based on clazy
Diffstat (limited to 'src')
-rw-r--r--src/browser.cpp18
-rw-r--r--src/lib/navigation/urllineedit.cpp8
-rw-r--r--src/mainwindow.cpp13
3 files changed, 24 insertions, 15 deletions
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);
}