DNSSettingsView: Disable list buttons when nothing selected
Change-Id: I2ff2ab1b3e29b1a8b217506ae620926f0f51787f Reviewed-on: https://review.haiku-os.org/c/haiku/+/3742 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
91b9cbbbb0
commit
e248c98eb8
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
static const int32 kMsgAddServer = 'adds';
|
static const int32 kMsgAddServer = 'adds';
|
||||||
static const int32 kMsgDeleteServer = 'dels';
|
static const int32 kMsgDeleteServer = 'dels';
|
||||||
|
static const int32 kMsgSelectServer = 'sels';
|
||||||
static const int32 kMsgMoveUp = 'mvup';
|
static const int32 kMsgMoveUp = 'mvup';
|
||||||
static const int32 kMsgMoveDown = 'mvdn';
|
static const int32 kMsgMoveDown = 'mvdn';
|
||||||
static const int32 kMsgApply = 'aply';
|
static const int32 kMsgApply = 'aply';
|
||||||
@@ -54,6 +55,7 @@ DNSSettingsView::DNSSettingsView(BNetworkSettingsItem* item)
|
|||||||
titleView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
titleView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
|
|
||||||
fServerListView = new BListView("nameservers");
|
fServerListView = new BListView("nameservers");
|
||||||
|
fServerListView->SetSelectionMessage(new BMessage(kMsgSelectServer));
|
||||||
const char* serverLabel = B_TRANSLATE("Server:");
|
const char* serverLabel = B_TRANSLATE("Server:");
|
||||||
fTextControl = new IPAddressControl(AF_UNSPEC, serverLabel, "server");
|
fTextControl = new IPAddressControl(AF_UNSPEC, serverLabel, "server");
|
||||||
fTextControl->SetExplicitMinSize(BSize(fTextControl->StringWidth("5") * 16
|
fTextControl->SetExplicitMinSize(BSize(fTextControl->StringWidth("5") * 16
|
||||||
@@ -63,12 +65,15 @@ DNSSettingsView::DNSSettingsView(BNetworkSettingsItem* item)
|
|||||||
fAddButton->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
fAddButton->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
fUpButton = new BButton(B_TRANSLATE("Move up"), new BMessage(kMsgMoveUp));
|
fUpButton = new BButton(B_TRANSLATE("Move up"), new BMessage(kMsgMoveUp));
|
||||||
fUpButton->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
fUpButton->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
|
fUpButton->SetEnabled(false);
|
||||||
fDownButton = new BButton(B_TRANSLATE("Move down"),
|
fDownButton = new BButton(B_TRANSLATE("Move down"),
|
||||||
new BMessage(kMsgMoveDown));
|
new BMessage(kMsgMoveDown));
|
||||||
fDownButton->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
fDownButton->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
|
fDownButton->SetEnabled(false);
|
||||||
fRemoveButton = new BButton(B_TRANSLATE("Remove"),
|
fRemoveButton = new BButton(B_TRANSLATE("Remove"),
|
||||||
new BMessage(kMsgDeleteServer));
|
new BMessage(kMsgDeleteServer));
|
||||||
fRemoveButton->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
fRemoveButton->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
|
fRemoveButton->SetEnabled(false);
|
||||||
fDomain = new BTextControl(B_TRANSLATE("Domain:"), "", NULL);
|
fDomain = new BTextControl(B_TRANSLATE("Domain:"), "", NULL);
|
||||||
fApplyButton = new BButton(B_TRANSLATE("Apply"), new BMessage(kMsgApply));
|
fApplyButton = new BButton(B_TRANSLATE("Apply"), new BMessage(kMsgApply));
|
||||||
|
|
||||||
@@ -143,6 +148,8 @@ DNSSettingsView::AttachedToWindow()
|
|||||||
fUpButton->SetTarget(this);
|
fUpButton->SetTarget(this);
|
||||||
fDownButton->SetTarget(this);
|
fDownButton->SetTarget(this);
|
||||||
|
|
||||||
|
fServerListView->SetTarget(this);
|
||||||
|
|
||||||
fTextControl->SetTarget(this);
|
fTextControl->SetTarget(this);
|
||||||
|
|
||||||
fApplyButton->SetTarget(this);
|
fApplyButton->SetTarget(this);
|
||||||
@@ -178,6 +185,17 @@ DNSSettingsView::MessageReceived(BMessage* message)
|
|||||||
fServerListView->SwapItems(index, index + 1);
|
fServerListView->SwapItems(index, index + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case kMsgSelectServer:
|
||||||
|
{
|
||||||
|
bool enabled = false;
|
||||||
|
if (fServerListView->CurrentSelection() > -1)
|
||||||
|
enabled = true;
|
||||||
|
|
||||||
|
fUpButton->SetEnabled(enabled);
|
||||||
|
fDownButton->SetEnabled(enabled);
|
||||||
|
fRemoveButton->SetEnabled(enabled);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case kMsgApply:
|
case kMsgApply:
|
||||||
if (_SaveDNSConfiguration() == B_OK)
|
if (_SaveDNSConfiguration() == B_OK)
|
||||||
fItem->NotifySettingsUpdated();
|
fItem->NotifySettingsUpdated();
|
||||||
|
|||||||
Reference in New Issue
Block a user