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:
@@ -36,7 +36,8 @@ void
|
||||
DriveSetup::ReadyToRun()
|
||||
{
|
||||
fWindow = new MainWindow(BRect(50, 50, 600, 450));
|
||||
_RestoreSettings();
|
||||
if (_RestoreSettings() != B_OK)
|
||||
fWindow->ApplyDefaultSettings();
|
||||
fWindow->Show();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 -
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user