* 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:
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'));
|
||||
menuBar->AddItem(menu);
|
||||
|
||||
BScrollView* scrollView = new DownloadContainerScrollView(
|
||||
downloadsGroupView);
|
||||
fDownloadsScrollView = new DownloadContainerScrollView(downloadsGroupView);
|
||||
|
||||
fRemoveFinishedButton = new BButton("Remove finished",
|
||||
new BMessage(REMOVE_FINISHED_DOWNLOADS));
|
||||
@ -172,7 +171,7 @@ DownloadWindow::DownloadWindow(BRect frame, bool visible,
|
||||
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
||||
.Add(menuBar)
|
||||
.Add(scrollView)
|
||||
.Add(fDownloadsScrollView)
|
||||
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
|
||||
.AddGlue()
|
||||
@ -280,6 +279,9 @@ DownloadWindow::QuitRequested()
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - private
|
||||
|
||||
|
||||
void
|
||||
DownloadWindow::_DownloadStarted(BWebDownload* download)
|
||||
{
|
||||
@ -308,9 +310,26 @@ DownloadWindow::_DownloadStarted(BWebDownload* download)
|
||||
fRemoveFinishedButton->SetEnabled(finishedCount > 0);
|
||||
fRemoveMissingButton->SetEnabled(missingCount > 0);
|
||||
DownloadProgressView* view = new DownloadProgressView(download);
|
||||
if (!view->Init())
|
||||
if (!view->Init()) {
|
||||
delete view;
|
||||
return;
|
||||
}
|
||||
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();
|
||||
|
||||
SetWorkspaces(B_CURRENT_WORKSPACE);
|
||||
|
@ -34,6 +34,7 @@
|
||||
class BButton;
|
||||
class BFile;
|
||||
class BGroupLayout;
|
||||
class BScrollView;
|
||||
class BWebDownload;
|
||||
class SettingsMessage;
|
||||
|
||||
@ -58,6 +59,7 @@ private:
|
||||
bool _OpenSettingsFile(BFile& file, uint32 mode);
|
||||
|
||||
private:
|
||||
BScrollView* fDownloadsScrollView;
|
||||
BGroupLayout* fDownloadViewsLayout;
|
||||
BButton* fRemoveFinishedButton;
|
||||
BButton* fRemoveMissingButton;
|
||||
|
Loading…
Reference in New Issue
Block a user