Fixing #7984 and some code guidelines.
This commit is contained in:
@@ -65,7 +65,6 @@ ErrorAlert(const char* message, status_t err, BWindow *window = NULL)
|
|||||||
alert->Go();
|
alert->Go();
|
||||||
|
|
||||||
printf("%s\n%s [%lx]", message, strerror(err), err);
|
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
|
// functions for EnumeratedStringValueSettings
|
||||||
|
|
||||||
const char* CaptureRateAt(int32 i)
|
const char*
|
||||||
|
CaptureRateAt(int32 i)
|
||||||
{
|
{
|
||||||
return (i >= 0 && i < kCaptureRatesCount) ? kCaptureRates[i].name : NULL;
|
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;
|
return (i >= 0 && i < kUploadClientsCount) ? kUploadClients[i] : NULL;
|
||||||
}
|
}
|
||||||
@@ -200,7 +201,8 @@ CodyCam::ReadyToRun()
|
|||||||
(const char*) B_TRANSLATE_SYSTEM_NAME("CodyCam"), B_TITLED_WINDOW,
|
(const char*) B_TRANSLATE_SYSTEM_NAME("CodyCam"), B_TITLED_WINDOW,
|
||||||
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, &fPort);
|
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, &fPort);
|
||||||
|
|
||||||
_SetUpNodes();
|
if(_SetUpNodes() != B_OK)
|
||||||
|
fWindow->ToggleMenuOnOff();
|
||||||
|
|
||||||
((VideoWindow*)fWindow)->ApplyControls();
|
((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");
|
BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), "menu bar");
|
||||||
|
|
||||||
BMenuItem* menuItem;
|
BMenuItem* menuItem;
|
||||||
BMenu* menu = new BMenu(B_TRANSLATE("File"));
|
fMenu = new BMenu(B_TRANSLATE("File"));
|
||||||
|
|
||||||
menuItem = new BMenuItem(B_TRANSLATE("Video settings"),
|
menuItem = new BMenuItem(B_TRANSLATE("Video settings"),
|
||||||
new BMessage(msg_video), 'P');
|
new BMessage(msg_video), 'P');
|
||||||
menuItem->SetTarget(be_app);
|
menuItem->SetTarget(be_app);
|
||||||
menu->AddItem(menuItem);
|
fMenu->AddItem(menuItem);
|
||||||
|
|
||||||
menu->AddSeparatorItem();
|
fMenu->AddSeparatorItem();
|
||||||
|
|
||||||
menuItem = new BMenuItem(B_TRANSLATE("Start video"),
|
menuItem = new BMenuItem(B_TRANSLATE("Start video"),
|
||||||
new BMessage(msg_start), 'A');
|
new BMessage(msg_start), 'A');
|
||||||
menuItem->SetTarget(be_app);
|
menuItem->SetTarget(be_app);
|
||||||
menu->AddItem(menuItem);
|
fMenu->AddItem(menuItem);
|
||||||
|
|
||||||
menuItem = new BMenuItem(B_TRANSLATE("Stop video"),
|
menuItem = new BMenuItem(B_TRANSLATE("Stop video"),
|
||||||
new BMessage(msg_stop), 'O');
|
new BMessage(msg_stop), 'O');
|
||||||
menuItem->SetTarget(be_app);
|
menuItem->SetTarget(be_app);
|
||||||
menu->AddItem(menuItem);
|
fMenu->AddItem(menuItem);
|
||||||
|
|
||||||
menu->AddSeparatorItem();
|
fMenu->AddSeparatorItem();
|
||||||
|
|
||||||
menuItem = new BMenuItem(B_TRANSLATE("Quit"),
|
menuItem = new BMenuItem(B_TRANSLATE("Quit"),
|
||||||
new BMessage(B_QUIT_REQUESTED), 'Q');
|
new BMessage(B_QUIT_REQUESTED), 'Q');
|
||||||
menuItem->SetTarget(be_app);
|
menuItem->SetTarget(be_app);
|
||||||
menu->AddItem(menuItem);
|
fMenu->AddItem(menuItem);
|
||||||
|
|
||||||
menuBar->AddItem(menu);
|
menuBar->AddItem(fMenu);
|
||||||
|
|
||||||
/* add some controls */
|
/* add some controls */
|
||||||
_BuildCaptureControls();
|
_BuildCaptureControls();
|
||||||
@@ -717,6 +719,7 @@ VideoWindow::_BuildCaptureControls()
|
|||||||
|
|
||||||
// FTP setup box
|
// FTP setup box
|
||||||
fFtpSetupBox = new BBox("FTP Setup", B_WILL_DRAW);
|
fFtpSetupBox = new BBox("FTP Setup", B_WILL_DRAW);
|
||||||
|
fFtpSetupBox->SetLabel(B_TRANSLATE("Output"));
|
||||||
|
|
||||||
fUploadClientMenu = new BPopUpMenu(B_TRANSLATE("Send to" B_UTF8_ELLIPSIS));
|
fUploadClientMenu = new BPopUpMenu(B_TRANSLATE("Send to" B_UTF8_ELLIPSIS));
|
||||||
for (int i = 0; i < kUploadClientsCount; i++) {
|
for (int i = 0; i < kUploadClientsCount; i++) {
|
||||||
@@ -724,14 +727,12 @@ VideoWindow::_BuildCaptureControls()
|
|||||||
m->AddInt32("client", i);
|
m->AddInt32("client", i);
|
||||||
fUploadClientMenu->AddItem(new BMenuItem(kUploadClients[i], m));
|
fUploadClientMenu->AddItem(new BMenuItem(kUploadClients[i], m));
|
||||||
}
|
}
|
||||||
|
|
||||||
fUploadClientMenu->SetTargetForItems(this);
|
fUploadClientMenu->SetTargetForItems(this);
|
||||||
fUploadClientMenu->FindItem(fUploadClientSetting->Value())->SetMarked(true);
|
fUploadClientMenu->FindItem(fUploadClientSetting->Value())->SetMarked(true);
|
||||||
fUploadClientSelector = new BMenuField("UploadClient", NULL,
|
fUploadClientSelector = new BMenuField("UploadClient", NULL,
|
||||||
fUploadClientMenu);
|
fUploadClientMenu);
|
||||||
|
|
||||||
fFtpSetupBox->SetLabel(B_TRANSLATE("Output"));
|
|
||||||
// this doesn't work with the layout manager
|
|
||||||
// fFtpSetupBox->SetLabel(fUploadClientSelector);
|
|
||||||
fUploadClientSelector->SetLabel(B_TRANSLATE("Type:"));
|
fUploadClientSelector->SetLabel(B_TRANSLATE("Type:"));
|
||||||
|
|
||||||
BGridLayout *ftpLayout = new BGridLayout(kXBuffer, 0);
|
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 -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ const char* kUploadClients[] = {
|
|||||||
|
|
||||||
const int32 kUploadClientsCount = sizeof(kUploadClients) / sizeof(char*);
|
const int32 kUploadClientsCount = sizeof(kUploadClients) / sizeof(char*);
|
||||||
|
|
||||||
|
class VideoWindow;
|
||||||
|
class ControlWindow;
|
||||||
|
|
||||||
class CodyCam : public BApplication {
|
class CodyCam : public BApplication {
|
||||||
public:
|
public:
|
||||||
@@ -104,9 +106,9 @@ private:
|
|||||||
VideoConsumer* fVideoConsumer;
|
VideoConsumer* fVideoConsumer;
|
||||||
media_output fProducerOut;
|
media_output fProducerOut;
|
||||||
media_input fConsumerIn;
|
media_input fConsumerIn;
|
||||||
BWindow* fWindow;
|
VideoWindow* fWindow;
|
||||||
port_id fPort;
|
port_id fPort;
|
||||||
BWindow* fVideoControlWindow;
|
ControlWindow* fVideoControlWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -124,6 +126,7 @@ public:
|
|||||||
|
|
||||||
BView* VideoView();
|
BView* VideoView();
|
||||||
BStringView* StatusLine();
|
BStringView* StatusLine();
|
||||||
|
void ToggleMenuOnOff();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _BuildCaptureControls();
|
void _BuildCaptureControls();
|
||||||
@@ -159,6 +162,8 @@ private:
|
|||||||
ftp_msg_info fFtpInfo;
|
ftp_msg_info fFtpInfo;
|
||||||
|
|
||||||
Settings* fSettings;
|
Settings* fSettings;
|
||||||
|
|
||||||
|
BMenu* fMenu;
|
||||||
|
|
||||||
StringValueSetting* fServerSetting;
|
StringValueSetting* fServerSetting;
|
||||||
StringValueSetting* fLoginSetting;
|
StringValueSetting* fLoginSetting;
|
||||||
|
|||||||
Reference in New Issue
Block a user