From 9c4dd932c6d692178bb8d5265c634126cb415767 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 26 May 2020 22:23:25 +0300 Subject: Turn on more warnings by default - fix clazy warnings - fix various other compiler warnings - bugfix: connect profiles' downloadRequested signal --- src/subwindow/subwindow.cpp | 16 ++++++++-------- src/subwindow/subwindow.h | 6 +++--- src/subwindow/tabwidget.cpp | 22 ++++++++++------------ 3 files changed, 21 insertions(+), 23 deletions(-) (limited to 'src/subwindow') diff --git a/src/subwindow/subwindow.cpp b/src/subwindow/subwindow.cpp index 588a070..6e9a713 100644 --- a/src/subwindow/subwindow.cpp +++ b/src/subwindow/subwindow.cpp @@ -78,18 +78,18 @@ SubWindow::SubWindow(QWidget *parent, Qt::WindowFlags flags) }); } -SubWindow::SubWindow(const Session::SubWindow &data, QWidget *parent, Qt::WindowFlags flags) +SubWindow::SubWindow(const Session::SubWindow &tab_data, QWidget *parent, Qt::WindowFlags flags) : SubWindow(parent, flags) { WebProfileManager profileManager; - auto *profile = profileManager.profile(data.profile); + auto *profile = profileManager.profile(tab_data.profile); if(profile != nullptr) { setProfile(profile); } - for(const auto &data : data.tabs) { - addTab(data); + for(const auto &tab : tab_data.tabs) { + addTab(tab); } } @@ -117,9 +117,9 @@ void SubWindow::setProfile(WebProfile *profile) } } -void SubWindow::setTabData(TabData &data, int index) +void SubWindow::setTabData(TabData &tab_data, int index) { - tabWidget->tabBar()->setTabData(index, QVariant::fromValue(data)); + tabWidget->tabBar()->setTabData(index, QVariant::fromValue(tab_data)); } SubWindow::TabData SubWindow::tabData(int index) const @@ -149,9 +149,9 @@ int SubWindow::addTab(const QUrl &url, WebProfile *profile) return tabWidget->addTab(view); } -int SubWindow::addTab(const Session::WebView &data) +int SubWindow::addTab(const Session::WebView &tab_data) { - auto *view = new WebView(data, std::bind(&SubWindow::createView, this, std::placeholders::_1), this); + auto *view = new WebView(tab_data, std::bind(&SubWindow::createView, this, std::placeholders::_1), this); return tabWidget->addTab(view); } diff --git a/src/subwindow/subwindow.h b/src/subwindow/subwindow.h index 88f3985..68f7cf9 100644 --- a/src/subwindow/subwindow.h +++ b/src/subwindow/subwindow.h @@ -28,7 +28,7 @@ public: }; explicit SubWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); - explicit SubWindow(const Session::SubWindow &data, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); + explicit SubWindow(const Session::SubWindow &tab_data, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); ~SubWindow() = default; [[nodiscard]] Session::SubWindow serialize() const; @@ -58,7 +58,7 @@ public: return m_profile; } - void setTabData(TabData &data, int index); + void setTabData(TabData &tab_data, int index); [[nodiscard]] TabData tabData(int index) const; signals: @@ -71,7 +71,7 @@ public slots: WebView *createView(QWebEnginePage::WebWindowType type); int addTab(const QUrl &url = QUrl(), WebProfile *profile = nullptr); - int addTab(const Session::WebView &data); + int addTab(const Session::WebView &tab_data); void closeTab(int index) { tabWidget->removeTab(index); diff --git a/src/subwindow/tabwidget.cpp b/src/subwindow/tabwidget.cpp index efa2b6a..6f1e348 100644 --- a/src/subwindow/tabwidget.cpp +++ b/src/subwindow/tabwidget.cpp @@ -87,23 +87,21 @@ int TabWidget::addTab(WebView *view) { Q_ASSERT_X(view != nullptr, "TabWidget::addTab", "Tried to add null view"); - int idx = QTabWidget::addTab(view, view->title()); + const int idx = QTabWidget::addTab(view, view->title()); connect(view, &WebView::titleChanged, [this, view](const QString &title) { - int idx = this->indexOf(view); - Q_ASSERT(idx != -1); - - this->setTabText(idx, title); + const int current_idx = indexOf(view); + if(current_idx != -1) { + setTabText(current_idx, title); + } }); connect(view, &WebView::iconChanged, [this, view](const QIcon &icon) { - int idx = this->indexOf(view); - Q_ASSERT(idx != -1); - - this->setTabIcon(idx, icon); + const int current_idx = indexOf(view); + if(current_idx != -1) { + setTabIcon(current_idx, icon); + } }); - SubWindow::TabData data; - tabBar()->setTabData(idx, QVariant::fromValue(data)); - + tabBar()->setTabData(idx, QVariant::fromValue(SubWindow::TabData{})); return idx; } -- cgit v1.2.1