Fixing #7984 and some code guidelines.

This commit is contained in:
Fredrik Modéen
2012-07-24 00:07:19 +00:00
parent 48b4d20480
commit 1615cec9cc
2 changed files with 37 additions and 17 deletions
+30 -15
View File
@@ -65,7 +65,6 @@ ErrorAlert(const char* message, status_t err, BWindow *window = NULL)
alert->Go();
printf("%s\n%s [%lx]", message, strerror(err), err);
// be_app->PostMessage(B_QUIT_REQUESTED);
}
@@ -122,13 +121,15 @@ AddTranslationItems(BMenu* intoMenu, uint32 fromType)
// functions for EnumeratedStringValueSettings
const char* CaptureRateAt(int32 i)
const char*
CaptureRateAt(int32 i)
{
return (i >= 0 && i < kCaptureRatesCount) ? kCaptureRates[i].name : NULL;
}
const char* UploadClientAt(int32 i)
const char*
UploadClientAt(int32 i)
{
return (i >= 0 && i < kUploadClientsCount) ? kUploadClients[i] : NULL;
}
@@ -200,7 +201,8 @@ CodyCam::ReadyToRun()
(const char*) B_TRANSLATE_SYSTEM_NAME("CodyCam"), B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, &fPort);
_SetUpNodes();
if(_SetUpNodes() != B_OK)
fWindow->ToggleMenuOnOff();
((VideoWindow*)fWindow)->ApplyControls();
}
@@ -490,33 +492,33 @@ VideoWindow::VideoWindow(BRect frame, const char* title, window_type type,
BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), "menu bar");
BMenuItem* menuItem;
BMenu* menu = new BMenu(B_TRANSLATE("File"));
fMenu = new BMenu(B_TRANSLATE("File"));
menuItem = new BMenuItem(B_TRANSLATE("Video settings"),
new BMessage(msg_video), 'P');
menuItem->SetTarget(be_app);
menu->AddItem(menuItem);
fMenu->AddItem(menuItem);
menu->AddSeparatorItem();
fMenu->AddSeparatorItem();
menuItem = new BMenuItem(B_TRANSLATE("Start video"),
new BMessage(msg_start), 'A');
menuItem->SetTarget(be_app);
menu->AddItem(menuItem);
fMenu->AddItem(menuItem);
menuItem = new BMenuItem(B_TRANSLATE("Stop video"),
new BMessage(msg_stop), 'O');
menuItem->SetTarget(be_app);
menu->AddItem(menuItem);
fMenu->AddItem(menuItem);
menu->AddSeparatorItem();
fMenu->AddSeparatorItem();
menuItem = new BMenuItem(B_TRANSLATE("Quit"),
new BMessage(B_QUIT_REQUESTED), 'Q');
menuItem->SetTarget(be_app);
menu->AddItem(menuItem);
fMenu->AddItem(menuItem);
menuBar->AddItem(menu);
menuBar->AddItem(fMenu);
/* add some controls */
_BuildCaptureControls();
@@ -717,6 +719,7 @@ VideoWindow::_BuildCaptureControls()
// FTP setup box
fFtpSetupBox = new BBox("FTP Setup", B_WILL_DRAW);
fFtpSetupBox->SetLabel(B_TRANSLATE("Output"));
fUploadClientMenu = new BPopUpMenu(B_TRANSLATE("Send to" B_UTF8_ELLIPSIS));
for (int i = 0; i < kUploadClientsCount; i++) {
@@ -724,14 +727,12 @@ VideoWindow::_BuildCaptureControls()
m->AddInt32("client", i);
fUploadClientMenu->AddItem(new BMenuItem(kUploadClients[i], m));
}
fUploadClientMenu->SetTargetForItems(this);
fUploadClientMenu->FindItem(fUploadClientSetting->Value())->SetMarked(true);
fUploadClientSelector = new BMenuField("UploadClient", NULL,
fUploadClientMenu);
fFtpSetupBox->SetLabel(B_TRANSLATE("Output"));
// this doesn't work with the layout manager
// fFtpSetupBox->SetLabel(fUploadClientSelector);
fUploadClientSelector->SetLabel(B_TRANSLATE("Type:"));
BGridLayout *ftpLayout = new BGridLayout(kXBuffer, 0);
@@ -875,6 +876,20 @@ VideoWindow::_QuitSettings()
}
void
VideoWindow::ToggleMenuOnOff()
{
BMenuItem* item = fMenu->FindItem(msg_video);
item->SetEnabled(!item->IsEnabled());
item = fMenu->FindItem(msg_start);
item->SetEnabled(!item->IsEnabled());
item = fMenu->FindItem(msg_stop);
item->SetEnabled(!item->IsEnabled());
}
// #pragma mark -
+7 -2
View File
@@ -84,6 +84,8 @@ const char* kUploadClients[] = {
const int32 kUploadClientsCount = sizeof(kUploadClients) / sizeof(char*);
class VideoWindow;
class ControlWindow;
class CodyCam : public BApplication {
public:
@@ -104,9 +106,9 @@ private:
VideoConsumer* fVideoConsumer;
media_output fProducerOut;
media_input fConsumerIn;
BWindow* fWindow;
VideoWindow* fWindow;
port_id fPort;
BWindow* fVideoControlWindow;
ControlWindow* fVideoControlWindow;
};
@@ -124,6 +126,7 @@ public:
BView* VideoView();
BStringView* StatusLine();
void ToggleMenuOnOff();
private:
void _BuildCaptureControls();
@@ -159,6 +162,8 @@ private:
ftp_msg_info fFtpInfo;
Settings* fSettings;
BMenu* fMenu;
StringValueSetting* fServerSetting;
StringValueSetting* fLoginSetting;