* 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:
|
case WINDOW_OPENED:
|
||||||
fWindowCount++;
|
fWindowCount++;
|
||||||
|
fDownloadWindow->SetMinimizeOnClose(false);
|
||||||
break;
|
break;
|
||||||
case WINDOW_CLOSED:
|
case WINDOW_CLOSED:
|
||||||
fWindowCount--;
|
fWindowCount--;
|
||||||
@@ -250,6 +251,28 @@ BrowserApp::RefsReceived(BMessage* message)
|
|||||||
bool
|
bool
|
||||||
BrowserApp::QuitRequested()
|
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++) {
|
for (int i = 0; BWindow* window = WindowAt(i); i++) {
|
||||||
BrowserWindow* webWindow = dynamic_cast<BrowserWindow*>(window);
|
BrowserWindow* webWindow = dynamic_cast<BrowserWindow*>(window);
|
||||||
if (!webWindow)
|
if (!webWindow)
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
|
|
||||||
#include "BrowserApp.h"
|
#include "BrowserApp.h"
|
||||||
|
#include "BrowserWindow.h"
|
||||||
#include "DownloadProgressView.h"
|
#include "DownloadProgressView.h"
|
||||||
#include "SettingsKeys.h"
|
#include "SettingsKeys.h"
|
||||||
#include "SettingsMessage.h"
|
#include "SettingsMessage.h"
|
||||||
@@ -135,7 +136,8 @@ DownloadWindow::DownloadWindow(BRect frame, bool visible,
|
|||||||
SettingsMessage* settings)
|
SettingsMessage* settings)
|
||||||
: BWindow(frame, "Downloads",
|
: BWindow(frame, "Downloads",
|
||||||
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
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);
|
SetPulseRate(1000000);
|
||||||
|
|
||||||
@@ -156,6 +158,13 @@ DownloadWindow::DownloadWindow(BRect frame, bool visible,
|
|||||||
BMenu* menu = new BMenu("Downloads");
|
BMenu* menu = new BMenu("Downloads");
|
||||||
menu->AddItem(new BMenuItem("Open downloads folder",
|
menu->AddItem(new BMenuItem("Open downloads folder",
|
||||||
new BMessage(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'));
|
menu->AddItem(new BMenuItem("Hide", new BMessage(B_QUIT_REQUESTED), 'J'));
|
||||||
menuBar->AddItem(menu);
|
menuBar->AddItem(menu);
|
||||||
|
|
||||||
@@ -305,12 +314,52 @@ DownloadWindow::MessageReceived(BMessage* message)
|
|||||||
bool
|
bool
|
||||||
DownloadWindow::QuitRequested()
|
DownloadWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
if (!IsHidden())
|
if (fMinimizeOnClose) {
|
||||||
Hide();
|
if (!IsMinimized())
|
||||||
|
Minimize(true);
|
||||||
|
} else {
|
||||||
|
if (!IsHidden())
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
return false;
|
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
|
// #pragma mark - private
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ public:
|
|||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
|
bool DownloadsInProgress();
|
||||||
|
void SetMinimizeOnClose(bool minimize);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _DownloadStarted(BWebDownload* download);
|
void _DownloadStarted(BWebDownload* download);
|
||||||
void _DownloadFinished(BWebDownload* download);
|
void _DownloadFinished(BWebDownload* download);
|
||||||
@@ -66,6 +69,7 @@ private:
|
|||||||
BButton* fRemoveFinishedButton;
|
BButton* fRemoveFinishedButton;
|
||||||
BButton* fRemoveMissingButton;
|
BButton* fRemoveMissingButton;
|
||||||
BString fDownloadPath;
|
BString fDownloadPath;
|
||||||
|
bool fMinimizeOnClose;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DOWNLOAD_WINDOW_H
|
#endif // DOWNLOAD_WINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user