* When downloads are still in progress, warn the user when the app quits and
allow to continue downloading. * If the Downloads window is the only window, minimize on close instead of hiding without any way to get the window back. * Added menu item "New browser window" to Downloads window. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@512 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
committed by
Alexandre Deckner
parent
02a2ef1969
commit
fb03e2c573
@@ -212,6 +212,7 @@ BrowserApp::MessageReceived(BMessage* message)
|
||||
}
|
||||
case WINDOW_OPENED:
|
||||
fWindowCount++;
|
||||
fDownloadWindow->SetMinimizeOnClose(false);
|
||||
break;
|
||||
case WINDOW_CLOSED:
|
||||
fWindowCount--;
|
||||
@@ -250,6 +251,28 @@ BrowserApp::RefsReceived(BMessage* message)
|
||||
bool
|
||||
BrowserApp::QuitRequested()
|
||||
{
|
||||
if (fDownloadWindow->DownloadsInProgress()) {
|
||||
BAlert* alert = new BAlert("Downloads in progress",
|
||||
"There are still downloads in progress, do you really want to "
|
||||
"quit WebPositive now?", "Quit", "Continue downloads");
|
||||
int32 choice = alert->Go();
|
||||
if (choice == 1) {
|
||||
if (fWindowCount == 0) {
|
||||
if (fDownloadWindow->Lock()) {
|
||||
fDownloadWindow->SetWorkspaces(1 << current_workspace());
|
||||
if (fDownloadWindow->IsHidden())
|
||||
fDownloadWindow->Show();
|
||||
else
|
||||
fDownloadWindow->Activate();
|
||||
fDownloadWindow->SetMinimizeOnClose(true);
|
||||
fDownloadWindow->Unlock();
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; BWindow* window = WindowAt(i); i++) {
|
||||
BrowserWindow* webWindow = dynamic_cast<BrowserWindow*>(window);
|
||||
if (!webWindow)
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <SpaceLayoutItem.h>
|
||||
|
||||
#include "BrowserApp.h"
|
||||
#include "BrowserWindow.h"
|
||||
#include "DownloadProgressView.h"
|
||||
#include "SettingsKeys.h"
|
||||
#include "SettingsMessage.h"
|
||||
@@ -135,7 +136,8 @@ DownloadWindow::DownloadWindow(BRect frame, bool visible,
|
||||
SettingsMessage* settings)
|
||||
: BWindow(frame, "Downloads",
|
||||
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
|
||||
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
|
||||
fMinimizeOnClose(false)
|
||||
{
|
||||
SetPulseRate(1000000);
|
||||
|
||||
@@ -156,6 +158,13 @@ DownloadWindow::DownloadWindow(BRect frame, bool visible,
|
||||
BMenu* menu = new BMenu("Downloads");
|
||||
menu->AddItem(new BMenuItem("Open downloads folder",
|
||||
new BMessage(OPEN_DOWNLOADS_FOLDER)));
|
||||
BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
|
||||
newWindowMessage->AddString("url", "");
|
||||
BMenuItem* newWindowItem = new BMenuItem("New browser window",
|
||||
newWindowMessage, 'N');
|
||||
menu->AddItem(newWindowItem);
|
||||
newWindowItem->SetTarget(be_app);
|
||||
menu->AddSeparatorItem();
|
||||
menu->AddItem(new BMenuItem("Hide", new BMessage(B_QUIT_REQUESTED), 'J'));
|
||||
menuBar->AddItem(menu);
|
||||
|
||||
@@ -305,12 +314,52 @@ DownloadWindow::MessageReceived(BMessage* message)
|
||||
bool
|
||||
DownloadWindow::QuitRequested()
|
||||
{
|
||||
if (!IsHidden())
|
||||
Hide();
|
||||
if (fMinimizeOnClose) {
|
||||
if (!IsMinimized())
|
||||
Minimize(true);
|
||||
} else {
|
||||
if (!IsHidden())
|
||||
Hide();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
DownloadWindow::DownloadsInProgress()
|
||||
{
|
||||
bool downloadsInProgress = false;
|
||||
if (!Lock())
|
||||
return downloadsInProgress;
|
||||
|
||||
for (int32 i = fDownloadViewsLayout->CountItems() - 1;
|
||||
BLayoutItem* item = fDownloadViewsLayout->ItemAt(i); i--) {
|
||||
DownloadProgressView* view = dynamic_cast<DownloadProgressView*>(
|
||||
item->View());
|
||||
if (!view)
|
||||
continue;
|
||||
if (view->Download() != NULL) {
|
||||
downloadsInProgress = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Unlock();
|
||||
|
||||
return downloadsInProgress;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DownloadWindow::SetMinimizeOnClose(bool minimize)
|
||||
{
|
||||
if (Lock()) {
|
||||
fMinimizeOnClose = minimize;
|
||||
Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - private
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +50,9 @@ public:
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual bool QuitRequested();
|
||||
|
||||
bool DownloadsInProgress();
|
||||
void SetMinimizeOnClose(bool minimize);
|
||||
|
||||
private:
|
||||
void _DownloadStarted(BWebDownload* download);
|
||||
void _DownloadFinished(BWebDownload* download);
|
||||
@@ -66,6 +69,7 @@ private:
|
||||
BButton* fRemoveFinishedButton;
|
||||
BButton* fRemoveMissingButton;
|
||||
BString fDownloadPath;
|
||||
bool fMinimizeOnClose;
|
||||
};
|
||||
|
||||
#endif // DOWNLOAD_WINDOW_H
|
||||
|
||||
Reference in New Issue
Block a user