aboutsummaryrefslogtreecommitdiff
path: root/src/subwindow
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-05-26 22:23:25 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-05-28 19:43:45 +0300
commit9c4dd932c6d692178bb8d5265c634126cb415767 (patch)
tree527300f8e710859965c142aed4e779a16b9d4ab6 /src/subwindow
parentUpdate ProfileEditor plugin (diff)
downloadsmolbote-9c4dd932c6d692178bb8d5265c634126cb415767.tar.xz
Turn on more warnings by default
- fix clazy warnings - fix various other compiler warnings - bugfix: connect profiles' downloadRequested signal
Diffstat (limited to 'src/subwindow')
-rw-r--r--src/subwindow/subwindow.cpp16
-rw-r--r--src/subwindow/subwindow.h6
-rw-r--r--src/subwindow/tabwidget.cpp22
3 files changed, 21 insertions, 23 deletions
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<TabData>(data));
+ tabWidget->tabBar()->setTabData(index, QVariant::fromValue<TabData>(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<SubWindow::TabData>(data));
-
+ tabBar()->setTabData(idx, QVariant::fromValue<SubWindow::TabData>(SubWindow::TabData{}));
return idx;
}