aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/subwindow/subwindow.cpp3
-rw-r--r--src/subwindow/tabwidget.cpp16
-rw-r--r--src/webengine/webprofile.cpp2
-rw-r--r--src/webengine/webprofilemanager.h13
-rw-r--r--src/webengine/webview.cpp14
5 files changed, 18 insertions, 30 deletions
diff --git a/src/subwindow/subwindow.cpp b/src/subwindow/subwindow.cpp
index 6e9a713..a2d6138 100644
--- a/src/subwindow/subwindow.cpp
+++ b/src/subwindow/subwindow.cpp
@@ -57,7 +57,6 @@ SubWindow::SubWindow(QWidget *parent, Qt::WindowFlags flags)
close();
} else {
auto *view = dynamic_cast<WebView *>(tabWidget->widget(index));
- Q_CHECK_PTR(view);
disconnect(titleConnection);
disconnect(linkHoveredConnection);
@@ -67,12 +66,10 @@ SubWindow::SubWindow(QWidget *parent, Qt::WindowFlags flags)
this->setWindowTitle(QString("%1 :%2").arg(title, v->profile()->name()));
});
setWindowTitle(QString("%1 :%2").arg(view->title(), view->profile()->name()));
-
linkHoveredConnection = connect(view->page(), &WebPage::linkHovered, this, [this](const QString &url) {
if(!url.isEmpty())
emit showStatusMessage(url, 3000);
});
-
emit currentViewChanged(view);
}
});
diff --git a/src/subwindow/tabwidget.cpp b/src/subwindow/tabwidget.cpp
index 6f1e348..69f3b8a 100644
--- a/src/subwindow/tabwidget.cpp
+++ b/src/subwindow/tabwidget.cpp
@@ -42,8 +42,11 @@ TabWidget::TabWidget(SubWindow *parent)
// when changing tabs, give focus to the widget
// otherwise when closing tabs, the tabwidget will retain focus
connect(this, &TabWidget::currentChanged, this, [this](int index) {
- if(widget(index))
+ previous = current;
+ current = index;
+ /*if(widget(index)) {
widget(index)->setFocus();
+ }*/
});
// context menu
@@ -68,12 +71,6 @@ TabWidget::TabWidget(SubWindow *parent)
removeTab(i);
}
});
-
- //
- connect(this, &TabWidget::currentChanged, this, [this](int index) {
- previous = current;
- current = index;
- });
}
TabWidget::~TabWidget()
@@ -85,7 +82,9 @@ TabWidget::~TabWidget()
int TabWidget::addTab(WebView *view)
{
- Q_ASSERT_X(view != nullptr, "TabWidget::addTab", "Tried to add null view");
+ if(view == nullptr) {
+ return -1;
+ }
const int idx = QTabWidget::addTab(view, view->title());
connect(view, &WebView::titleChanged, [this, view](const QString &title) {
@@ -100,7 +99,6 @@ int TabWidget::addTab(WebView *view)
setTabIcon(current_idx, icon);
}
});
-
tabBar()->setTabData(idx, QVariant::fromValue<SubWindow::TabData>(SubWindow::TabData{}));
return idx;
}
diff --git a/src/webengine/webprofile.cpp b/src/webengine/webprofile.cpp
index 719ab34..f1e71fb 100644
--- a/src/webengine/webprofile.cpp
+++ b/src/webengine/webprofile.cpp
@@ -18,12 +18,10 @@ static WebProfile *s_profile = nullptr;
void WebProfile::setDefaultProfile(WebProfile *profile)
{
- Q_CHECK_PTR(profile);
s_profile = profile;
}
WebProfile *WebProfile::defaultProfile()
{
- Q_CHECK_PTR(s_profile);
return s_profile;
}
diff --git a/src/webengine/webprofilemanager.h b/src/webengine/webprofilemanager.h
index 91dcaf8..a356506 100644
--- a/src/webengine/webprofilemanager.h
+++ b/src/webengine/webprofilemanager.h
@@ -41,10 +41,11 @@ public:
}
if(!profiles.contains(default_id)) {
- Profile profile;
- profile.settings = WebProfile::load(QString(), search, homepage, newtab);
- profile.ptr = WebProfile::load(default_id, profile.settings, true);
- profiles[default_id] = profile;
+ auto *settings = WebProfile::load(QString(), search, homepage, newtab);
+ profiles[default_id] = Profile{
+ .settings = settings,
+ .ptr = WebProfile::load(default_id, settings, true),
+ };
}
WebProfile::setDefaultProfile(profiles[default_id].ptr);
}
@@ -73,7 +74,7 @@ public:
}
if(profile != nullptr && settings != nullptr) {
- profiles[id] = Profile{ profile, settings, false };
+ profiles[id] = Profile{ settings, profile, false };
}
}
@@ -101,8 +102,8 @@ private:
set_typestate(consumed) void consume() {}
struct Profile {
- WebProfile *ptr = nullptr;
QSettings *settings = nullptr;
+ WebProfile *ptr = nullptr;
bool selfDestruct = false;
};
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp
index 38e564a..bc52102 100644
--- a/src/webengine/webview.cpp
+++ b/src/webengine/webview.cpp
@@ -37,9 +37,7 @@ WebView::WebView(WebProfile *profile, cb_createWindow_t cb, QWidget *parent)
: WebView(parent)
{
cb_createWindow = cb;
- Q_CHECK_PTR(profile);
- m_profile = profile;
- setPage(new WebPage(profile, this));
+ setProfile(profile);
}
WebView::WebView(const Session::WebView &webview_data, cb_createWindow_t cb, QWidget *parent)
@@ -47,11 +45,7 @@ WebView::WebView(const Session::WebView &webview_data, cb_createWindow_t cb, QWi
{
cb_createWindow = cb;
WebProfileManager profileManager;
-
- auto *profile = profileManager.profile(webview_data.profile);
- if(profile != nullptr) {
- setProfile(profile);
- }
+ setProfile(profileManager.profile(webview_data.profile));
if(!webview_data.url.isEmpty())
load(QUrl::fromUserInput(webview_data.url));
@@ -64,9 +58,9 @@ WebView::WebView(const Session::WebView &webview_data, cb_createWindow_t cb, QWi
void WebView::setProfile(WebProfile *profile)
{
- m_profile = profile;
+ m_profile = (profile == nullptr) ? WebProfile::defaultProfile() : profile;
const auto url = this->url();
- setPage(new WebPage(profile, this));
+ setPage(new WebPage(m_profile, this));
this->load(url);
}