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
This commit is contained in:
stippi 2010-02-13 00:29:06 +00:00
parent 4b059d47cd
commit 7a40c9757e
5 changed files with 36 additions and 8 deletions

View File

@ -40,13 +40,14 @@
#include <StatusBar.h>
#include <stdio.h>
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();
}

View File

@ -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*);

View File

@ -36,14 +36,13 @@
#include "WebProcess.h"
#include "WebView.h"
#include "WebViewConstants.h"
#include <Alert.h>
#include <Autolock.h>
#include <Entry.h>
#include <File.h>
#include <FindDirectory.h>
#include <Path.h>
#include <Screen.h>
#include <stdio.h>
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);
}

View File

@ -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;

View File

@ -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 {