When no settings file is found, resize the list view and the window such that

all columns are seen (taking care not to become bigger than the screen) and
center the window on screen.

+alphabranch


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32853 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-08-31 11:42:18 +00:00
parent e5f148ddec
commit f7a0f575a8
3 changed files with 30 additions and 2 deletions
+2 -1
View File
@@ -36,7 +36,8 @@ void
DriveSetup::ReadyToRun()
{
fWindow = new MainWindow(BRect(50, 50, 600, 450));
_RestoreSettings();
if (_RestoreSettings() != B_OK)
fWindow->ApplyDefaultSettings();
fWindow->Show();
}
+26
View File
@@ -372,6 +372,32 @@ MainWindow::RestoreSettings(BMessage* archive)
}
void
MainWindow::ApplyDefaultSettings()
{
if (!Lock())
return;
fListView->ResizeAllColumnsToPreferred();
// Adjust window size for convenience
float enlargeBy = fListView->PreferredSize().width
- fListView->Bounds().Width();
if (enlargeBy > 0.0f) {
BScreen screen(this);
float windowWidth = Frame().Width() + enlargeBy;
if (windowWidth > screen.Frame().Width() - 20.0f)
windowWidth = screen.Frame().Width() - 20.0f;
ResizeTo(windowWidth, Frame().Height());
}
CenterOnScreen();
Unlock();
}
// #pragma mark -
+2 -1
View File
@@ -41,6 +41,7 @@ public:
// MainWindow
status_t StoreSettings(BMessage* archive) const;
status_t RestoreSettings(BMessage* archive);
void ApplyDefaultSettings();
private:
void _ScanDrives();
@@ -68,7 +69,7 @@ private:
const BString& diskSystemName);
void _Create(BDiskDevice* disk,
partition_id selectedPartition);
void _Delete(BDiskDevice* disk,
void _Delete(BDiskDevice* disk,
partition_id selectedPartition);