1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Fixed focusing new window when opened from cmd argument.

- also now correctly focusing download manager window
  when running qupzilla --download-manager
This commit is contained in:
nowrep 2011-12-27 12:27:39 +01:00
parent c4ee306b5c
commit ef28d2b00e
2 changed files with 15 additions and 4 deletions

View File

@ -116,6 +116,10 @@ MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &cm
} }
} }
if (messages.isEmpty()) {
messages.append(" ");
}
if (isRunning()) { if (isRunning()) {
foreach (QString message, messages) { foreach (QString message, messages) {
sendMessage(message); sendMessage(message);
@ -355,31 +359,36 @@ void MainApplication::sendMessages(MainApplication::MessageType mes, bool state)
void MainApplication::receiveAppMessage(QString message) void MainApplication::receiveAppMessage(QString message)
{ {
QWidget* actWin = getWindow();
if (message.startsWith("URL:")) { if (message.startsWith("URL:")) {
QString url(message.remove("URL:")); QString url(message.remove("URL:"));
addNewTab(WebView::guessUrlFromString(url)); addNewTab(WebView::guessUrlFromString(url));
actWin = getWindow();
} }
else if (message.startsWith("ACTION:")) { else if (message.startsWith("ACTION:")) {
QString text = message.mid(7); QString text = message.mid(7);
if (text == "NewTab") { if (text == "NewTab") {
addNewTab(); addNewTab();
actWin = getWindow();
} }
else if (text == "NewWindow") { else if (text == "NewWindow") {
makeNewWindow(false); actWin = makeNewWindow(false);
} }
else if (text == "ShowDownloadManager") { else if (text == "ShowDownloadManager") {
downManager()->show(); downManager()->show();
actWin = downManager();
} }
else if (text == "StartPrivateBrowsing") { else if (text == "StartPrivateBrowsing") {
sendMessages(StartPrivateBrowsing, true); sendMessages(StartPrivateBrowsing, true);
actWin = getWindow();
} }
} }
QupZilla* actWin = getWindow();
if (!actWin && !isClosing()) { // It can only occur if download manager window was still open if (!actWin && !isClosing()) { // It can only occur if download manager window was still open
makeNewWindow(true); makeNewWindow(true);
return; return;
} }
actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
actWin->raise(); actWin->raise();
actWin->activateWindow(); actWin->activateWindow();
@ -394,7 +403,7 @@ void MainApplication::addNewTab(const QUrl &url)
getWindow()->tabWidget()->addView(url); getWindow()->tabWidget()->addView(url);
} }
void MainApplication::makeNewWindow(bool tryRestore, const QUrl &startUrl) QupZilla* MainApplication::makeNewWindow(bool tryRestore, const QUrl &startUrl)
{ {
QupZilla::StartBehaviour behaviour; QupZilla::StartBehaviour behaviour;
if (tryRestore) { if (tryRestore) {
@ -408,6 +417,8 @@ void MainApplication::makeNewWindow(bool tryRestore, const QUrl &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();
return newWindow;
} }
void MainApplication::connectDatabase() void MainApplication::connectDatabase()

View File

@ -66,7 +66,7 @@ public:
void loadSettings(); void loadSettings();
void reloadSettings() { loadSettings(); emit message(ReloadSettings, true); } void reloadSettings() { loadSettings(); emit message(ReloadSettings, true); }
bool restoreStateSlot(QupZilla* window); bool restoreStateSlot(QupZilla* window);
void makeNewWindow(bool tryRestore, const QUrl &startUrl = QUrl()); QupZilla* makeNewWindow(bool tryRestore, const QUrl &startUrl = QUrl());
void addNewTab(const QUrl &url = QUrl()); void addNewTab(const QUrl &url = QUrl());
void aboutToCloseWindow(QupZilla* window); void aboutToCloseWindow(QupZilla* window);
bool isStateChanged(); bool isStateChanged();