本文整理汇总了C++中BAlert::SetShortcut方法的典型用法代码示例。如果您正苦于以下问题:C++ BAlert::SetShortcut方法的具体用法?C++ BAlert::SetShortcut怎么用?C++ BAlert::SetShortcut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BAlert
的用法示例。
在下文中一共展示了BAlert::SetShortcut方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BAlert
bool
PrefWindow::QuitRequested()
{
if (!fDirty)
return true;
BAlert *alert = new BAlert("",
B_TRANSLATE("Save changes to this settings panel?"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Don't save"), B_TRANSLATE("Save"),
B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->SetShortcut(1, 'd');
alert->SetShortcut(2, 's');
int32 index = alert->Go();
if (index == 0)
return false;
if (index == 2)
_Save();
else
_Revert();
return true;
}
示例2: BAlert
bool
ApplicationTypeWindow::QuitRequested()
{
if (_NeedsSaving(CHECK_ALL) != 0) {
BAlert* alert = new BAlert(B_TRANSLATE("Save request"),
B_TRANSLATE("Save changes before closing?"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Don't save"),
B_TRANSLATE("Save"), B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->SetShortcut(1, 'd');
alert->SetShortcut(2, 's');
int32 choice = alert->Go();
switch (choice) {
case 0:
return false;
case 1:
break;
case 2:
_Save();
break;
}
}
be_app->PostMessage(kMsgTypeWindowClosed);
return true;
}
示例3: entry
bool
ShortcutsWindow::QuitRequested()
{
bool ret = true;
if (fKeySetModified) {
BAlert* alert = new BAlert(WARNING,
B_TRANSLATE("Save changes before closing?"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Don't save"),
B_TRANSLATE("Save"));
alert->SetShortcut(0, B_ESCAPE);
alert->SetShortcut(1, 'd');
alert->SetShortcut(2, 's');
switch(alert->Go()) {
case 0:
ret = false;
break;
case 1:
ret = true;
break;
case 2:
// Save: automatically if possible, otherwise go back and open
// up the file requester
if (fLastSaved.InitCheck() == B_OK) {
if (_SaveKeySet(fLastSaved) == false) {
BAlert* alert = new BAlert(ERROR,
B_TRANSLATE("Shortcuts was unable to save your "
"KeySet file!"),
B_TRANSLATE("Oh no"));
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
ret = true; //quit anyway
}
} else {
PostMessage(SAVE_KEYSET);
ret = false;
}
break;
}
}
if (ret) {
fColumnListView->DeselectAll();
// Save the window position.
entry_ref ref;
if (_GetWindowSettingsFile(&ref)) {
BEntry entry(&ref);
_SaveWindowSettings(entry);
}
}
return ret;
}
示例4: RemoveSelected
void PProjectWindow::RemoveSelected()
{
int s = 0;
do
{
if (fList->IsItemSelected(s)) {
PProjectItem* projectItem
= dynamic_cast<PProjectItem*>(fList->RemoveItem(s));
if (projectItem) {
CProjectGroupItem* projectGroupItem
= dynamic_cast<CProjectGroupItem*>(projectItem->ModelItem());
if (projectGroupItem) {
BAlert* alert
= new BAlert( "Pe message",
"You can't remove a group-item",
"Ah, Ok", NULL, NULL,
B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
B_WARNING_ALERT);
alert->SetShortcut( 0, B_ESCAPE);
alert->Go();
return;
} else {
fPrjFile->RemoveItem(projectItem->ModelItem());
delete projectItem;
SetDirty(true);
}
}
}
}
while (fList->IsItemSelected(s) ||
((s = fList->CurrentSelection(s)) > 0 && s < fList->CountItems()));
}
示例5: QuitRequested
bool MainWindow::QuitRequested()
{
bool downloading = !static_cast<TorrentorApp*>(be_app)->TorrentList().IsEmpty();
//
//
//
//for (int32 i = fTorrentList.CountItems(); i > 0; i--) {
// const TorrentObject* torrent = fTorrentList.ItemAt(i);
//
// active |= torrent->IsActive();
//}
//
if (downloading) {
BAlert* confirmAlert = new BAlert("", B_TRANSLATE("Quit Torrentor!?"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Quit"), NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
confirmAlert->SetShortcut(0, B_ESCAPE);
if (confirmAlert->Go() == 0)
return false;
}
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
示例6: BAlert
void
ReplicantView::AboutRequested()
{
BAlert* alert = new BAlert("QueryWatcher", "QueryWatcher 1.0\nBy Michael Armida\[email protected]", "Gee...Thanks");
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
}
示例7: AboutRequested
void AboutRequested()
{
// FIXME use BAboutBox
BString text("FRiSS Version ");
text << version();
text << "\n";
text << "\xC2\xA9""2010-2013 Adrien Destugues (PulkoMandy)\n";
text << "\[email protected]\n\n";
text << "\xC2\xA9""2004 Andreas Herzig (N3S)\n";
text << "\[email protected]\n\n";
text << "Original idea:\n\t0033\n\n";
// FIXME translation credits
#if 0
if (config!= NULL && config->Lang.Compare("enDE") != 0) {
text << _T("Language") << ": " << _T("FL:Language") << "\n";
text << "\t" << _T("FL:Translator") << "\n";
}
#endif
BAlert* alert = new BAlert("About fRiSS", text.String(), _T("Ok"));
alert->SetShortcut( 0, B_ESCAPE );
alert->Go();
}
示例8: path
status_t
ScreenshotWindow::_SaveScreenshot()
{
if (!fScreenshot || !fLastSelectedPath)
return B_ERROR;
BPath path(_GetDirectory());
if (path == NULL)
return B_ERROR;
path.Append(fNameControl->Text());
BEntry entry;
entry.SetTo(path.Path());
if (entry.Exists()) {
BAlert* overwriteAlert = new BAlert(
B_TRANSLATE("overwrite"),
B_TRANSLATE("This file already exists.\n Are you sure you would "
"like to overwrite it?"),
B_TRANSLATE("Cancel"),
B_TRANSLATE("Overwrite"),
NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
overwriteAlert->SetShortcut(0, B_ESCAPE);
if (overwriteAlert->Go() == 0)
return B_CANCELED;
}
return fUtility.Save(fScreenshot, path.Path(), fImageFileType);
}
示例9: msg
void
TouchpadView::MouseUp(BPoint point)
{
if (!fXTracking && !fYTracking)
return;
fXTracking = false;
fYTracking = false;
const float kSoftScrollLimit = 0.7;
int32 result = 0;
if (GetRightScrollRatio() > kSoftScrollLimit
|| GetBottomScrollRatio() > kSoftScrollLimit) {
BAlert* alert = new BAlert(B_TRANSLATE("Please confirm"),
B_TRANSLATE("The new scroll area is very large and may impede "
"normal mouse operation. Do you really want to change it?"),
B_TRANSLATE("OK"), B_TRANSLATE("Cancel"),
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(1, B_ESCAPE);
result = alert->Go();
}
if (result == 0) {
BMessage msg(SCROLL_AREA_CHANGED);
Invoke(&msg);
} else {
if (GetRightScrollRatio() > kSoftScrollLimit)
fXScrollRange = fOldXScrollRange;
if (GetBottomScrollRatio() > kSoftScrollLimit)
fYScrollRange = fOldYScrollRange;
DrawSliders();
}
}
示例10: msg
bool
FaberWindow::QuitRequested()
{
if (ProjectManager::HasChanged()) {
BString alertText = "Save changes to ";
alertText << ProjectManager::Name();
alertText << "?";
BAlert* alert = new BAlert("Warning!", alertText.String(),
"Cancel", "Don't save", "Save",
B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
int32 button_index = alert->Go();
if (button_index == 2) {
BMessenger msg(this);
// TODO add Builder-like methods to build commands.
BMessage* command = CommandBuilder(FABER_SAVE_PROJECT);
command->AddBool("faber:quit", true);
msg.SendMessage(command);
return false;
} else if (button_index == 0)
return false;
}
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
示例11: QuitRequested
bool PDocument::QuitRequested(void)
{
TRACE();
//check modified if there are changes wich we need to save
bool returnValue = true;
bool readLock = false;
if (modified)
{
readLock = Lock();
BAlert *myAlert = new BAlert("title", "Save changes to ...", _T("Cancel"), _T("Don't save"), _T("Save"), B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
myAlert->SetShortcut(0, B_ESCAPE);
int32 button_index = myAlert->Go();
if (button_index == 0)
returnValue = false;
else if (button_index == 1)
returnValue = true;
else
{
Save();
returnValue = true;
}
if (readLock)
Unlock();
}
if (returnValue)
{
window->Lock();
window->Quit();
}
return returnValue;
}
示例12: BAlert
bool
ShowImageWindow::_ClosePrompt()
{
if (!fModified)
return true;
int32 count = fNavigator.PageCount();
int32 page = fNavigator.CurrentPage();
BString prompt;
if (count > 1) {
bs_printf(&prompt,
B_TRANSLATE("The document '%s' (page %d) has been changed. Do you "
"want to close the document?"),
fImageView->Image()->name, page);
} else {
bs_printf(&prompt,
B_TRANSLATE("The document '%s' has been changed. Do you want to "
"close the document?"),
fImageView->Image()->name);
}
BAlert* alert = new BAlert(B_TRANSLATE("Close document"), prompt.String(),
B_TRANSLATE("Cancel"), B_TRANSLATE("Close"));
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() == 0) {
// Cancel
return false;
}
// Close
fModified = false;
return true;
}
示例13: BAlert
static int
ShowMessage(char* string)
{
BAlert *alert = new BAlert("Message", string, "OK");
alert->SetShortcut(1, B_ESCAPE);
return alert->Go();
}
示例14: entry
bool
RealNameAttributeText::CommitEditedTextFlavor(BTextView* textView)
{
const char* text = textView->Text();
BEntry entry(fModel->EntryRef());
if (entry.InitCheck() != B_OK)
return false;
BDirectory parent;
if (entry.GetParent(&parent) != B_OK)
return false;
bool removeExisting = false;
if (parent.Contains(text)) {
BAlert* alert = new BAlert("",
B_TRANSLATE("That name is already taken. "
"Please type another one."),
B_TRANSLATE("Replace other file"),
B_TRANSLATE("OK"),
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, 'r');
if (alert->Go())
return false;
removeExisting = true;
}
// TODO:
// use model-flavor specific virtuals for all of these special
// renamings
status_t result;
if (fModel->IsVolume()) {
BVolume volume(fModel->NodeRef()->device);
result = volume.InitCheck();
if (result == B_OK) {
RenameVolumeUndo undo(volume, text);
result = volume.SetName(text);
if (result != B_OK)
undo.Remove();
}
} else {
if (fModel->IsQuery()) {
BModelWriteOpener opener(fModel);
ASSERT(fModel->Node());
MoreOptionsStruct::SetQueryTemporary(fModel->Node(), false);
}
RenameUndo undo(entry, text);
result = entry.Rename(text, removeExisting);
if (result != B_OK)
undo.Remove();
}
return result == B_OK;
}
示例15: BAlert
bool
NetworkWindow::QuitRequested(void)
{
if (fSave->IsEnabled() == true) {
BAlert *alert = new BAlert("Save Info Alert", "Save changes before "
quitting?", "Don't Save", "Cancel", "Save");
alert->SetShortcut(1, B_ESCAPE);
int32 result = alert->Go();
switch (result) {
case 0: {
// Don't Save
break;
}
case 1:{
// Cancel
return false;
break;
}
case 2:{
// Save
SaveBackup(NULL,fData);
break;
}
default:
break;
}
}