From 7a40c9757e509a9e04d288ca40872c0efdcc8538 Mon Sep 17 00:00:00 2001 From: stippi Date: Sat, 13 Feb 2010 00:29:06 +0000 Subject: [PATCH] Make the Download Window accessible from every window. Bring it to the workspace that the window is on that send the request to show it. Remember the size and if it was showing across sessions. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@56 94f232f2-1747-11df-bad5-a5bfde151594 --- src/apps/webpositive/DownloadWindow.cpp | 5 +++-- src/apps/webpositive/DownloadWindow.h | 2 +- src/apps/webpositive/LauncherApp.cpp | 27 +++++++++++++++++++++---- src/apps/webpositive/LauncherWindow.cpp | 7 +++++++ src/apps/webpositive/LauncherWindow.h | 3 ++- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/apps/webpositive/DownloadWindow.cpp b/src/apps/webpositive/DownloadWindow.cpp index d6b932d6a5..a90b919fd7 100644 --- a/src/apps/webpositive/DownloadWindow.cpp +++ b/src/apps/webpositive/DownloadWindow.cpp @@ -40,13 +40,14 @@ #include #include -DownloadWindow::DownloadWindow(BRect frame) +DownloadWindow::DownloadWindow(BRect frame, bool visible) : BWindow(frame, "Downloads", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) { SetLayout(new BGroupLayout(B_VERTICAL)); - Minimize(true); + if (!visible) + Minimize(true); Show(); } diff --git a/src/apps/webpositive/DownloadWindow.h b/src/apps/webpositive/DownloadWindow.h index dc652f7442..66e88b2940 100644 --- a/src/apps/webpositive/DownloadWindow.h +++ b/src/apps/webpositive/DownloadWindow.h @@ -34,7 +34,7 @@ class WebDownload; class DownloadWindow : public BWindow { public: - DownloadWindow(BRect frame); + DownloadWindow(BRect frame, bool visible); virtual ~DownloadWindow(); virtual void MessageReceived(BMessage*); diff --git a/src/apps/webpositive/LauncherApp.cpp b/src/apps/webpositive/LauncherApp.cpp index 403e750055..84a338ff07 100644 --- a/src/apps/webpositive/LauncherApp.cpp +++ b/src/apps/webpositive/LauncherApp.cpp @@ -36,14 +36,13 @@ #include "WebProcess.h" #include "WebView.h" #include "WebViewConstants.h" - #include +#include #include #include #include #include #include - #include extern const char* kApplicationSignature = "application/x-vnd.RJL-HaikuLauncher"; @@ -88,17 +87,21 @@ void LauncherApp::ReadyToRun() WebProcess::initializeOnce(); WebProcess::setCacheModel(WEBKIT_CACHE_MODEL_WEB_BROWSER); - m_downloadWindow = new DownloadWindow(BRect(100, 100, 300, 250)); - BFile settingsFile; BRect windowFrameFromSettings = m_lastWindowFrame; + BRect downloadWindowFrame(100, 100, 300, 250); + bool showDownloads = false; if (openSettingsFile(settingsFile, B_READ_ONLY)) { BMessage settingsArchive; settingsArchive.Unflatten(&settingsFile); settingsArchive.FindRect("window frame", &windowFrameFromSettings); + settingsArchive.FindRect("downloads window frame", &downloadWindowFrame); + settingsArchive.FindBool("show downloads", &showDownloads); } m_lastWindowFrame = windowFrameFromSettings; + m_downloadWindow = new DownloadWindow(downloadWindowFrame, showDownloads); + m_initialized = true; if (m_launchRefsMessage) { @@ -165,6 +168,17 @@ void LauncherApp::MessageReceived(BMessage* message) PostMessage(B_QUIT_REQUESTED); break; + case SHOW_DOWNLOAD_WINDOW: { + BAutolock _(m_downloadWindow); + uint32 workspaces; + if (message->FindUInt32("workspaces", &workspaces) == B_OK) + m_downloadWindow->SetWorkspaces(workspaces); + if (m_downloadWindow->IsMinimized()) + m_downloadWindow->Minimize(false); + else + m_downloadWindow->Activate(); + } + default: BApplication::MessageReceived(message); break; @@ -215,6 +229,11 @@ bool LauncherApp::QuitRequested() if (openSettingsFile(settingsFile, B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY)) { BMessage settingsArchive; settingsArchive.AddRect("window frame", m_lastWindowFrame); + if (m_downloadWindow->Lock()) { + settingsArchive.AddRect("downloads window frame", m_downloadWindow->Frame()); + settingsArchive.AddBool("show downloads", !m_downloadWindow->IsMinimized()); + m_downloadWindow->Unlock(); + } settingsArchive.Flatten(&settingsFile); } diff --git a/src/apps/webpositive/LauncherWindow.cpp b/src/apps/webpositive/LauncherWindow.cpp index 0a171db2bd..bc9c3970c4 100644 --- a/src/apps/webpositive/LauncherWindow.cpp +++ b/src/apps/webpositive/LauncherWindow.cpp @@ -93,6 +93,8 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener, newItem->SetTarget(be_app); menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 'W')); menu->AddSeparatorItem(); + menu->AddItem(new BMenuItem("Show Downloads", new BMessage(SHOW_DOWNLOAD_WINDOW), 'D')); + menu->AddSeparatorItem(); BMenuItem* quitItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'); menu->AddItem(quitItem); quitItem->SetTarget(be_app); @@ -252,6 +254,11 @@ void LauncherWindow::MessageReceived(BMessage* message) m_findGroup->SetVisible(false); break; + case SHOW_DOWNLOAD_WINDOW: + message->AddUInt32("workspaces", Workspaces()); + be_app->PostMessage(message); + break; + default: WebViewWindow::MessageReceived(message); break; diff --git a/src/apps/webpositive/LauncherWindow.h b/src/apps/webpositive/LauncherWindow.h index 46fde08bac..0760fc4280 100644 --- a/src/apps/webpositive/LauncherWindow.h +++ b/src/apps/webpositive/LauncherWindow.h @@ -50,7 +50,8 @@ enum ToolbarPolicy { enum { NEW_WINDOW = 'nwnd', WINDOW_OPENED = 'wndo', - WINDOW_CLOSED = 'wndc' + WINDOW_CLOSED = 'wndc', + SHOW_DOWNLOAD_WINDOW = 'sdwd' }; class LauncherWindow : public WebViewWindow {