* Prevent the user from chosing the same disk for source and destination.

* Keep the info text and the Begin button in consistent state at all times
  according to the selection of the disks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30379 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-04-24 15:32:40 +00:00
parent 4e65d35a57
commit b4eca493bb
2 changed files with 39 additions and 28 deletions
+39 -25
View File
@@ -196,10 +196,7 @@ InstallerWindow::InstallerWindow()
fInstallStatus(kReadyForInstall), fInstallStatus(kReadyForInstall),
fPackagesLayoutItem(NULL), fPackagesLayoutItem(NULL),
fSizeViewLayoutItem(NULL), fSizeViewLayoutItem(NULL)
fLastSrcItem(NULL),
fLastTargetItem(NULL)
{ {
fCopyEngine = new CopyEngine(this); fCopyEngine = new CopyEngine(this);
@@ -382,16 +379,10 @@ InstallerWindow::MessageReceived(BMessage *msg)
_ShowOptionalPackages(); _ShowOptionalPackages();
break; break;
case SRC_PARTITION: case SRC_PARTITION:
if (fLastSrcItem == fSrcMenu->FindMarked())
break;
fLastSrcItem = fSrcMenu->FindMarked();
_PublishPackages(); _PublishPackages();
_UpdateMenus(); _UpdateMenus();
break; break;
case TARGET_PARTITION: case TARGET_PARTITION:
if (fLastTargetItem == fDestMenu->FindMarked())
break;
fLastTargetItem = fDestMenu->FindMarked();
_UpdateMenus(); _UpdateMenus();
break; break;
case SETUP_MESSAGE: case SETUP_MESSAGE:
@@ -525,29 +516,41 @@ InstallerWindow::_ScanPartitions()
_PublishPackages(); _PublishPackages();
} }
_UpdateMenus(); _UpdateMenus();
_SetStatusMessage("Choose the disk you want to install onto from the "
"pop-up menu. Then click \"Begin\".");
} }
void void
InstallerWindow::_UpdateMenus() InstallerWindow::_UpdateMenus()
{ {
PartitionMenuItem *item1 = (PartitionMenuItem *)fSrcMenu->FindMarked(); PartitionMenuItem* srcItem = (PartitionMenuItem*)fSrcMenu->FindMarked();
BString label; BString label;
if (item1) { if (srcItem) {
label = item1->MenuLabel(); label = srcItem->MenuLabel();
} else { } else {
if (fSrcMenu->CountItems() == 0) if (fSrcMenu->CountItems() == 0)
label = "<none>"; label = "<none>";
else else
label = ((PartitionMenuItem *)fSrcMenu->ItemAt(0))->MenuLabel(); label = ((PartitionMenuItem*)fSrcMenu->ItemAt(0))->MenuLabel();
} }
fSrcMenuField->MenuItem()->SetLabel(label.String()); fSrcMenuField->MenuItem()->SetLabel(label.String());
PartitionMenuItem *item2 = (PartitionMenuItem *)fDestMenu->FindMarked(); if (srcItem) {
if (item2) { // Prevent the user from having picked the same partition as source
label = item2->MenuLabel(); // and destination.
for (int32 i = fDestMenu->CountItems() - 1; i >= 0; i--) {
PartitionMenuItem* dstItem
= (PartitionMenuItem*)fDestMenu->ItemAt(i);
if (dstItem->ID() == srcItem->ID()) {
dstItem->SetEnabled(false);
dstItem->SetMarked(false);
} else
dstItem->SetEnabled(true);
}
}
PartitionMenuItem* dstItem = (PartitionMenuItem*)fDestMenu->FindMarked();
if (dstItem) {
label = dstItem->MenuLabel();
} else { } else {
if (fDestMenu->CountItems() == 0) if (fDestMenu->CountItems() == 0)
label = "<none>"; label = "<none>";
@@ -555,12 +558,23 @@ InstallerWindow::_UpdateMenus()
label = "Please Choose Target"; label = "Please Choose Target";
} }
fDestMenuField->MenuItem()->SetLabel(label.String()); fDestMenuField->MenuItem()->SetLabel(label.String());
char message[255]; if (srcItem && dstItem) {
sprintf(message, "Press the Begin button to install from '%s' onto '%s'", char message[255];
item1 ? item1->Name() : "null", item2 ? item2->Name() : "null"); sprintf(message, "Press the Begin button to install from '%s' onto "
_SetStatusMessage(message); "'%s'.", srcItem->Name(), dstItem->Name());
if (item1 && item2) _SetStatusMessage(message);
fBeginButton->SetEnabled(true); } else if (srcItem) {
_SetStatusMessage("Choose the disk you want to install onto from the "
"pop-up menu. Then click \"Begin\".");
} else if (dstItem) {
_SetStatusMessage("Choose the source disk from the "
"pop-up menu. Then click \"Begin\".");
} else {
_SetStatusMessage("Choose the source and destination disk from the "
"pop-up menus. Then click \"Begin\".");
}
fBeginButton->SetEnabled(srcItem && dstItem);
} }
-3
View File
@@ -81,9 +81,6 @@ private:
CopyEngine* fCopyEngine; CopyEngine* fCopyEngine;
BString fLastStatus; BString fLastStatus;
BMenuItem* fLastSrcItem;
BMenuItem* fLastTargetItem;
}; };
#endif // INSTALLER_WINDOW_H #endif // INSTALLER_WINDOW_H