* Scroll the downloads which just started into view.
* Delete the progress view when init fails. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@356 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
committed by
Alexandre Deckner
parent
2232d801e0
commit
98b056e146
@@ -157,8 +157,7 @@ DownloadWindow::DownloadWindow(BRect frame, bool visible,
|
|||||||
menu->AddItem(new BMenuItem("Hide", new BMessage(B_QUIT_REQUESTED), 'H'));
|
menu->AddItem(new BMenuItem("Hide", new BMessage(B_QUIT_REQUESTED), 'H'));
|
||||||
menuBar->AddItem(menu);
|
menuBar->AddItem(menu);
|
||||||
|
|
||||||
BScrollView* scrollView = new DownloadContainerScrollView(
|
fDownloadsScrollView = new DownloadContainerScrollView(downloadsGroupView);
|
||||||
downloadsGroupView);
|
|
||||||
|
|
||||||
fRemoveFinishedButton = new BButton("Remove finished",
|
fRemoveFinishedButton = new BButton("Remove finished",
|
||||||
new BMessage(REMOVE_FINISHED_DOWNLOADS));
|
new BMessage(REMOVE_FINISHED_DOWNLOADS));
|
||||||
@@ -172,7 +171,7 @@ DownloadWindow::DownloadWindow(BRect frame, bool visible,
|
|||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
||||||
.Add(menuBar)
|
.Add(menuBar)
|
||||||
.Add(scrollView)
|
.Add(fDownloadsScrollView)
|
||||||
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
@@ -280,6 +279,9 @@ DownloadWindow::QuitRequested()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - private
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DownloadWindow::_DownloadStarted(BWebDownload* download)
|
DownloadWindow::_DownloadStarted(BWebDownload* download)
|
||||||
{
|
{
|
||||||
@@ -308,9 +310,26 @@ DownloadWindow::_DownloadStarted(BWebDownload* download)
|
|||||||
fRemoveFinishedButton->SetEnabled(finishedCount > 0);
|
fRemoveFinishedButton->SetEnabled(finishedCount > 0);
|
||||||
fRemoveMissingButton->SetEnabled(missingCount > 0);
|
fRemoveMissingButton->SetEnabled(missingCount > 0);
|
||||||
DownloadProgressView* view = new DownloadProgressView(download);
|
DownloadProgressView* view = new DownloadProgressView(download);
|
||||||
if (!view->Init())
|
if (!view->Init()) {
|
||||||
|
delete view;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
fDownloadViewsLayout->AddView(index, view);
|
fDownloadViewsLayout->AddView(index, view);
|
||||||
|
float viewHeight = view->MinSize().height + 1;
|
||||||
|
if (BScrollBar* scrollBar = fDownloadsScrollView->ScrollBar(B_VERTICAL)) {
|
||||||
|
float min;
|
||||||
|
float max;
|
||||||
|
scrollBar->GetRange(&min, &max);
|
||||||
|
float scrollOffset = min + index * viewHeight;
|
||||||
|
float scrollBarHeight = scrollBar->Bounds().Height() - 1;
|
||||||
|
float value = scrollBar->Value();
|
||||||
|
if (scrollOffset < value)
|
||||||
|
scrollBar->SetValue(scrollOffset);
|
||||||
|
else if (scrollOffset + viewHeight > value + scrollBarHeight) {
|
||||||
|
float diff = scrollOffset + viewHeight - (value + scrollBarHeight);
|
||||||
|
scrollBar->SetValue(value + diff);
|
||||||
|
}
|
||||||
|
}
|
||||||
_SaveSettings();
|
_SaveSettings();
|
||||||
|
|
||||||
SetWorkspaces(B_CURRENT_WORKSPACE);
|
SetWorkspaces(B_CURRENT_WORKSPACE);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
class BButton;
|
class BButton;
|
||||||
class BFile;
|
class BFile;
|
||||||
class BGroupLayout;
|
class BGroupLayout;
|
||||||
|
class BScrollView;
|
||||||
class BWebDownload;
|
class BWebDownload;
|
||||||
class SettingsMessage;
|
class SettingsMessage;
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ private:
|
|||||||
bool _OpenSettingsFile(BFile& file, uint32 mode);
|
bool _OpenSettingsFile(BFile& file, uint32 mode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
BScrollView* fDownloadsScrollView;
|
||||||
BGroupLayout* fDownloadViewsLayout;
|
BGroupLayout* fDownloadViewsLayout;
|
||||||
BButton* fRemoveFinishedButton;
|
BButton* fRemoveFinishedButton;
|
||||||
BButton* fRemoveMissingButton;
|
BButton* fRemoveMissingButton;
|
||||||
|
|||||||
Reference in New Issue
Block a user