1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +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()) {
foreach (QString message, messages) {
sendMessage(message);
@ -355,31 +359,36 @@ void MainApplication::sendMessages(MainApplication::MessageType mes, bool state)
void MainApplication::receiveAppMessage(QString message)
{
QWidget* actWin = getWindow();
if (message.startsWith("URL:")) {
QString url(message.remove("URL:"));
addNewTab(WebView::guessUrlFromString(url));
actWin = getWindow();
}
else if (message.startsWith("ACTION:")) {
QString text = message.mid(7);
if (text == "NewTab") {
addNewTab();
actWin = getWindow();
}
else if (text == "NewWindow") {
makeNewWindow(false);
actWin = makeNewWindow(false);
}
else if (text == "ShowDownloadManager") {
downManager()->show();
actWin = downManager();
}
else if (text == "StartPrivateBrowsing") {
sendMessages(StartPrivateBrowsing, true);
actWin = getWindow();
}
}
QupZilla* actWin = getWindow();
if (!actWin && !isClosing()) { // It can only occur if download manager window was still open
makeNewWindow(true);
return;
}
actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized);
actWin->raise();
actWin->activateWindow();
@ -394,7 +403,7 @@ void MainApplication::addNewTab(const QUrl &url)
getWindow()->tabWidget()->addView(url);
}
void MainApplication::makeNewWindow(bool tryRestore, const QUrl &startUrl)
QupZilla* MainApplication::makeNewWindow(bool tryRestore, const QUrl &startUrl)
{
QupZilla::StartBehaviour behaviour;
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)));
m_mainWindows.append(newWindow);
newWindow->show();
return newWindow;
}
void MainApplication::connectDatabase()

View File

@ -66,7 +66,7 @@ public:
void loadSettings();
void reloadSettings() { loadSettings(); emit message(ReloadSettings, true); }
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 aboutToCloseWindow(QupZilla* window);
bool isStateChanged();