1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

Fixed restoring of multiple windows

Restoring of multiple windows now won't add additional tab in second and
next windows
This commit is contained in:
nowrep 2011-11-03 18:51:46 +01:00
parent c3971c2672
commit 575b15db6c
3 changed files with 33 additions and 10 deletions

View File

@ -154,7 +154,7 @@ MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &cm
translateApp(); translateApp();
QWebHistoryInterface::setDefaultInterface(new WebHistoryInterface(this)); QWebHistoryInterface::setDefaultInterface(new WebHistoryInterface(this));
QupZilla* qupzilla = new QupZilla(true, startUrl); QupZilla* qupzilla = new QupZilla(QupZilla::FirstAppWindow, startUrl);
m_mainWindows.append(qupzilla); m_mainWindows.append(qupzilla);
connect(qupzilla, SIGNAL(message(MainApplication::MessageType,bool)), this, SLOT(sendMessages(MainApplication::MessageType,bool))); connect(qupzilla, SIGNAL(message(MainApplication::MessageType,bool)), this, SLOT(sendMessages(MainApplication::MessageType,bool)));
qupzilla->show(); qupzilla->show();
@ -350,7 +350,13 @@ void MainApplication::addNewTab(const QUrl &url)
void MainApplication::makeNewWindow(bool tryRestore, const QUrl &startUrl) void MainApplication::makeNewWindow(bool tryRestore, const QUrl &startUrl)
{ {
QupZilla* newWindow = new QupZilla(tryRestore, startUrl); QupZilla::StartBehaviour behaviour;
if (tryRestore)
behaviour = QupZilla::OtherRestoredWindow;
else
behaviour = QupZilla::NewWindow;
QupZilla* newWindow = new QupZilla(behaviour, startUrl);
connect(newWindow, SIGNAL(message(MainApplication::MessageType,bool)), this, SLOT(sendMessages(MainApplication::MessageType,bool))); connect(newWindow, SIGNAL(message(MainApplication::MessageType,bool)), this, SLOT(sendMessages(MainApplication::MessageType,bool)));
m_mainWindows.append(newWindow); m_mainWindows.append(newWindow);
newWindow->show(); newWindow->show();
@ -623,7 +629,7 @@ bool MainApplication::restoreStateSlot(QupZilla* window)
stream >> tabState; stream >> tabState;
stream >> qMainWindowState; stream >> qMainWindowState;
QupZilla* window = new QupZilla(false); QupZilla* window = new QupZilla(QupZilla::OtherRestoredWindow);
m_mainWindows.append(window); m_mainWindows.append(window);
connect(window, SIGNAL(message(MainApplication::MessageType,bool)), this, SLOT(sendMessages(MainApplication::MessageType,bool))); connect(window, SIGNAL(message(MainApplication::MessageType,bool)), this, SLOT(sendMessages(MainApplication::MessageType,bool)));
QEventLoop eLoop; QEventLoop eLoop;

View File

@ -81,13 +81,13 @@ const QIcon QupZilla::qupzillaIcon()
return i; return i;
} }
QupZilla::QupZilla(bool tryRestore, QUrl startUrl) QupZilla::QupZilla(StartBehaviour behaviour, QUrl startUrl)
: QMainWindow(0) : QMainWindow(0)
, m_tryRestore(tryRestore)
, m_historyMenuChanged(true) , m_historyMenuChanged(true)
, m_bookmarksMenuChanged(true) , m_bookmarksMenuChanged(true)
, m_isClosing(false) , m_isClosing(false)
, m_startingUrl(startUrl) , m_startingUrl(startUrl)
, m_startBehaviour(behaviour)
, m_actionPrivateBrowsing(0) , m_actionPrivateBrowsing(0)
, m_webInspectorDock(0) , m_webInspectorDock(0)
, m_sideBar(0) , m_sideBar(0)
@ -136,7 +136,8 @@ void QupZilla::postLaunch()
settings.endGroup(); settings.endGroup();
QUrl startUrl; QUrl startUrl;
if (m_tryRestore) { switch (m_startBehaviour) {
case FirstAppWindow:
if (afterLaunch == 0) if (afterLaunch == 0)
startUrl = QUrl(""); startUrl = QUrl("");
else if (afterLaunch == 1) else if (afterLaunch == 1)
@ -146,8 +147,23 @@ void QupZilla::postLaunch()
if ( startingAfterCrash || (addTab && afterLaunch == 2) ) if ( startingAfterCrash || (addTab && afterLaunch == 2) )
addTab = !mApp->restoreStateSlot(this); addTab = !mApp->restoreStateSlot(this);
} else break;
startUrl = m_homepage;
case NewWindow:
if (afterLaunch == 0)
startUrl = QUrl("");
else if (afterLaunch == 1)
startUrl = m_homepage;
else
startUrl = m_homepage;
addTab = true;
break;
case OtherRestoredWindow:
addTab = false;
break;
}
if (!m_startingUrl.isEmpty()) { if (!m_startingUrl.isEmpty()) {
startUrl = WebView::guessUrlFromString(m_startingUrl.toString()); startUrl = WebView::guessUrlFromString(m_startingUrl.toString());

View File

@ -79,7 +79,8 @@ public:
static const QIcon qupzillaIcon(); static const QIcon qupzillaIcon();
explicit QupZilla(bool m_tryRestore=true, QUrl startUrl=QUrl()); enum StartBehaviour { FirstAppWindow, OtherRestoredWindow, NewWindow };
explicit QupZilla(StartBehaviour behaviour = FirstAppWindow, QUrl startUrl = QUrl());
~QupZilla(); ~QupZilla();
void refreshAddressBar(); void refreshAddressBar();
@ -195,13 +196,13 @@ private:
void addSideBar(); void addSideBar();
bool m_tryRestore;
bool m_historyMenuChanged; bool m_historyMenuChanged;
bool m_bookmarksMenuChanged; bool m_bookmarksMenuChanged;
bool m_isClosing; bool m_isClosing;
QUrl m_startingUrl; QUrl m_startingUrl;
QUrl m_newtab; QUrl m_newtab;
QUrl m_homepage; QUrl m_homepage;
StartBehaviour m_startBehaviour;
QVBoxLayout* m_mainLayout; QVBoxLayout* m_mainLayout;
QSplitter* m_mainSplitter; QSplitter* m_mainSplitter;