Verified Commit 9a1addb6 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳
Browse files

Make it impossible to save tabs until old ones are loaded

parent 67c001cc
...@@ -36,7 +36,6 @@ TabsModel::TabsModel(QObject *parent) : QAbstractListModel(parent) { ...@@ -36,7 +36,6 @@ TabsModel::TabsModel(QObject *parent) : QAbstractListModel(parent) {
m_tabsReadOnly = true; m_tabsReadOnly = true;
// Make sure model always contains at least one tab // Make sure model always contains at least one tab
createEmptyTab(); createEmptyTab();
m_tabsReadOnly = false;
} }
QHash<int, QByteArray> TabsModel::roleNames() const QHash<int, QByteArray> TabsModel::roleNames() const
...@@ -105,17 +104,28 @@ TabState TabsModel::tab(int index) { ...@@ -105,17 +104,28 @@ TabState TabsModel::tab(int index) {
* @brief TabsModel::loadInitialTabs sets up the tabs that should already be open when starting the browser * @brief TabsModel::loadInitialTabs sets up the tabs that should already be open when starting the browser
* This includes the configured homepage, an url passed on the command line (usually by another app) and tabs * This includes the configured homepage, an url passed on the command line (usually by another app) and tabs
* which were still open when the browser was last closed. * which were still open when the browser was last closed.
*
* @warning It is impossible to save any new tabs until this function was called.
*/ */
void TabsModel::loadInitialTabs() void TabsModel::loadInitialTabs()
{ {
if (m_privateMode) return; if (!m_privateMode) {
if (AngelFish::BrowserManager::instance()->initialUrl().isEmpty()) { loadTabs();
if (!loadTabs() && m_tabs.first().url() == QStringLiteral("about:blank")) {
load(AngelFish::BrowserManager::instance()->homepage());
}
} else {
load(AngelFish::BrowserManager::instance()->initialUrl());
} }
m_tabsReadOnly = false;
if (!m_privateMode) {
if (AngelFish::BrowserManager::instance()->initialUrl().isEmpty()) {
if (m_tabs.first().url() == QStringLiteral("about:blank"))
load(AngelFish::BrowserManager::instance()->homepage());
} else {
if (m_tabs.first().url() == QStringLiteral("about:blank"))
load(AngelFish::BrowserManager::instance()->initialUrl());
else
newTab(AngelFish::BrowserManager::instance()->initialUrl());
}
}
} }
/** /**
...@@ -199,7 +209,7 @@ bool TabsModel::loadTabs() ...@@ -199,7 +209,7 @@ bool TabsModel::loadTabs()
bool TabsModel::saveTabs() const bool TabsModel::saveTabs() const
{ {
// only save if not in private mode // only save if not in private mode
if (!m_privateMode && !m_tabsReadOnly) { if (!m_privateMode) {
QString outputDir = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) QString outputDir = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)
+ QStringLiteral("/angelfish/"); + QStringLiteral("/angelfish/");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment