Slight template window tweaks

This commit is contained in:
Jaidyn Ann 2021-06-18 14:18:45 -05:00
parent 4f8aaf7957
commit 84eb2d68ba
5 changed files with 21 additions and 17 deletions

View File

@ -61,13 +61,11 @@ ProtocolTemplate::Load(BView* parent, BMessage* settings)
{ {
if (!parent) if (!parent)
debugger("Couldn't build protocol's settings GUI on a NULL parent!"); debugger("Couldn't build protocol's settings GUI on a NULL parent!");
BMessage curr; BMessage curr;
float inset = ceilf(be_plain_font->Size() * 0.7f);
// Setup layout // Setup layout
parent->SetLayout(new BGroupLayout(B_VERTICAL)); parent->SetLayout(new BGroupLayout(B_VERTICAL));
BGroupLayoutBuilder layout(B_VERTICAL, inset); BGroupLayoutBuilder layout(B_VERTICAL);
for (int32 i = 0; fTemplate->FindMessage("setting", i, &curr) == B_OK; i++) { for (int32 i = 0; fTemplate->FindMessage("setting", i, &curr) == B_OK; i++) {
char temp[512]; char temp[512];

View File

@ -50,6 +50,8 @@ TemplateView::AttachedToWindow()
menu = menuField->Menu(); menu = menuField->Menu();
if (menu) { if (menu) {
if (i == 0)
menu->MakeFocus(true);
for (int32 j = 0; j < menu->CountItems(); j++) { for (int32 j = 0; j < menu->CountItems(); j++) {
BMenuItem* item = menu->ItemAt(j); BMenuItem* item = menu->ItemAt(j);
item->SetMessage(new BMessage(kChanged)); item->SetMessage(new BMessage(kChanged));
@ -60,16 +62,22 @@ TemplateView::AttachedToWindow()
} }
if (textControl) { if (textControl) {
if (i == 0)
textControl->MakeFocus(true);
textControl->SetMessage(new BMessage(kChanged)); textControl->SetMessage(new BMessage(kChanged));
textControl->SetTarget(Window()); textControl->SetTarget(Window());
} }
if (checkBox) { if (checkBox) {
if (i == 0)
checkBox->MakeFocus(true);
checkBox->SetMessage(new BMessage(kChanged)); checkBox->SetMessage(new BMessage(kChanged));
checkBox->SetTarget(Window()); checkBox->SetTarget(Window());
} }
if (textView) { if (textView) {
if (i == 0)
textView->MakeFocus(true);
textView->SetMessage(new BMessage(kChanged)); textView->SetMessage(new BMessage(kChanged));
textView->SetTarget(Window()); textView->SetTarget(Window());
} }

View File

@ -20,7 +20,6 @@
#include "TemplateView.h" #include "TemplateView.h"
const uint32 kCancel = 'canc';
const uint32 kOK = 'save'; const uint32 kOK = 'save';
const uint32 kAccSelected = 'JWas'; const uint32 kAccSelected = 'JWas';
@ -81,9 +80,6 @@ TemplateWindow::MessageReceived(BMessage* msg)
Close(); Close();
break; break;
} }
case kCancel:
Close();
break;
case kChanged: case kChanged:
break; break;
default: default:
@ -105,22 +101,23 @@ TemplateWindow::_InitInterface()
fTemplateView = new TemplateView("template"); fTemplateView = new TemplateView("template");
fMenuField = new BMenuField("accountMenuField", NULL, _CreateAccountMenu()); fMenuField = new BMenuField("accountMenuField", NULL, _CreateAccountMenu());
BButton* cancel = new BButton("Cancel", new BMessage(kCancel));
BButton* fOkButton = new BButton("OK", new BMessage(kOK)); BButton* fOkButton = new BButton("OK", new BMessage(kOK));
if (fAccounts.CountItems() <= 0) if (fAccounts.CountItems() <= 0)
fOkButton->SetEnabled(false); fOkButton->SetEnabled(false);
fOkButton->MakeDefault(true);
const float spacing = be_control_look->DefaultItemSpacing(); const float spacing = be_control_look->DefaultItemSpacing();
BLayoutBuilder::Group<>(this, B_VERTICAL) BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(fTemplateView) .Add(fTemplateView)
.AddGroup(B_HORIZONTAL) .AddGroup(B_HORIZONTAL)
.Add(fMenuField) .Add(fMenuField)
.AddGlue() .AddGlue()
.Add(cancel) .Add(new BButton("Cancel", new BMessage(B_QUIT_REQUESTED)))
.Add(fOkButton) .Add(fOkButton)
.End() .End()
.AddGlue() .End();
.SetInsets(spacing, spacing, spacing, 0);
} }
@ -129,7 +126,6 @@ TemplateWindow::_LoadTemplate()
{ {
if (fAccounts.CountItems() == 0) if (fAccounts.CountItems() == 0)
return; return;
// fOkButton->SetEnabled(true);
ProtocolLooper* looper ProtocolLooper* looper
= fServer->GetProtocolLooper(fAccounts.ValueAt(fSelectedAcc)); = fServer->GetProtocolLooper(fAccounts.ValueAt(fSelectedAcc));
@ -142,6 +138,8 @@ TemplateWindow::_LoadTemplate()
fTemplateView->RemoveChild(fTemplateView->ChildAt(i)); fTemplateView->RemoveChild(fTemplateView->ChildAt(i));
fTemplate->Load(fTemplateView); fTemplate->Load(fTemplateView);
fTemplateView->AttachedToWindow();
fTemplateView->MakeFocus(true);
} }

View File

@ -1149,7 +1149,7 @@ JabberHandler::_SettingsTemplate(const char* username, bool serverOption)
BMessage passwordText; BMessage passwordText;
passwordText.AddString("name", "password"); passwordText.AddString("name", "password");
passwordText.AddString("description", "Password"); passwordText.AddString("description", "Password:");
passwordText.AddString("error", "You can't log into an account without a " passwordText.AddString("error", "You can't log into an account without a "
"password.\nPlease fill in your password for the given account."); "password.\nPlease fill in your password for the given account.");
passwordText.AddInt32("type", 'CSTR'); passwordText.AddInt32("type", 'CSTR');
@ -1158,7 +1158,7 @@ JabberHandler::_SettingsTemplate(const char* username, bool serverOption)
BMessage serverText; BMessage serverText;
serverText.AddString("name", "server"); serverText.AddString("name", "server");
serverText.AddString("description", "Server"); serverText.AddString("description", "Server:");
serverText.AddString("error", "You can't add an account without a server.\n" serverText.AddString("error", "You can't add an account without a server.\n"
"Please add a valid XMPP server."); "Please add a valid XMPP server.");
serverText.AddInt32("type", 'CSTR'); serverText.AddInt32("type", 'CSTR');
@ -1167,7 +1167,7 @@ JabberHandler::_SettingsTemplate(const char* username, bool serverOption)
BMessage resourceText; BMessage resourceText;
resourceText.AddString("name", "resource"); resourceText.AddString("name", "resource");
resourceText.AddString("description", "Resource"); resourceText.AddString("description", "Resource:");
resourceText.AddInt32("type", 'CSTR'); resourceText.AddInt32("type", 'CSTR');
resourceText.AddString("default", "Caya"); resourceText.AddString("default", "Caya");
resourceText.AddString("error", "You can't add an account without a " resourceText.AddString("error", "You can't add an account without a "
@ -1184,7 +1184,7 @@ JabberHandler::_RoomTemplate()
BMessage stemplate('IMst'); BMessage stemplate('IMst');
BMessage roomIdentifier; BMessage roomIdentifier;
roomIdentifier.AddString("name", "chat_id"); roomIdentifier.AddString("name", "chat_id");
roomIdentifier.AddString("description", "Room identifier"); roomIdentifier.AddString("description", "Room identifier:");
roomIdentifier.AddString("error", "You can't create a room without a JID!\n" roomIdentifier.AddString("error", "You can't create a room without a JID!\n"
"Use the \"name@server\" format."); "Use the \"name@server\" format.");
roomIdentifier.AddInt32("type", 'CSTR'); roomIdentifier.AddInt32("type", 'CSTR');

View File

@ -49,7 +49,7 @@ BMessage
JabberProtocol::SettingsTemplate(const char* name) JabberProtocol::SettingsTemplate(const char* name)
{ {
if (name == BString("account")) if (name == BString("account"))
return JabberHandler::_SettingsTemplate("Jabber identifier", true); return JabberHandler::_SettingsTemplate("Jabber identifier:", true);
if (name == BString("room")) if (name == BString("room"))
return JabberHandler::_RoomTemplate(); return JabberHandler::_RoomTemplate();
else else