* make sure we close the app on ESCAPE

* do not launch a second window in case of RefsReceived



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27799 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Karsten Heimrich 2008-09-30 21:43:36 +00:00
parent 4c39bafa21
commit ef52eb17ea
4 changed files with 16 additions and 8 deletions

View File

@ -14,7 +14,8 @@
Screenshot::Screenshot() Screenshot::Screenshot()
: BApplication("application/x-vnd.haiku-screenshot"), : BApplication("application/x-vnd.haiku-screenshot"),
fArgvReceived(false) fArgvReceived(false),
fRefsReceived(false)
{ {
} }
@ -27,10 +28,11 @@ Screenshot::~Screenshot()
void void
Screenshot::ReadyToRun() Screenshot::ReadyToRun()
{ {
if(!fArgvReceived) if(!fArgvReceived && !fRefsReceived)
new ScreenshotWindow(); new ScreenshotWindow();
fArgvReceived = false; fArgvReceived = false;
fRefsReceived = false;
} }
@ -57,6 +59,8 @@ Screenshot::RefsReceived(BMessage* message)
new ScreenshotWindow(delay * 1000000, includeBorder, includeCursor, new ScreenshotWindow(delay * 1000000, includeBorder, includeCursor,
grabActiveWindow, showConfigureWindow, saveScreenshotSilent); grabActiveWindow, showConfigureWindow, saveScreenshotSilent);
fRefsReceived = true;
} }

View File

@ -19,4 +19,5 @@ private:
private: private:
bool fArgvReceived; bool fArgvReceived;
bool fRefsReceived;
}; };

View File

@ -190,11 +190,14 @@ ScreenshotWindow::MessageReceived(BMessage* message)
} }
} break; } break;
case kFinishScreenshot: { case kFinishScreenshot:
_WriteSettings(); _WriteSettings();
_SaveScreenshot(); _SaveScreenshot();
// fall through
case B_QUIT_REQUESTED:
be_app_messenger.SendMessage(B_QUIT_REQUESTED); be_app_messenger.SendMessage(B_QUIT_REQUESTED);
} break; break;
case kShowOptions: { case kShowOptions: {
BCardLayout* layout = dynamic_cast<BCardLayout*> (GetLayout()); BCardLayout* layout = dynamic_cast<BCardLayout*> (GetLayout());
@ -323,7 +326,7 @@ ScreenshotWindow::_SetupSecondLayoutItem(BCardLayout* layout)
fPreviewBox->SetExplicitMinSize(BSize(200.0, B_SIZE_UNSET)); fPreviewBox->SetExplicitMinSize(BSize(200.0, B_SIZE_UNSET));
fPreviewBox->SetFlags(fPreviewBox->Flags() | B_FULL_UPDATE_ON_RESIZE); fPreviewBox->SetFlags(fPreviewBox->Flags() | B_FULL_UPDATE_ON_RESIZE);
fNameControl = new BTextControl("", "Name:", "screenshot", NULL); fNameControl = new BTextControl("", "Name:", "screenshot1", NULL);
BMessage settings(_ReadSettings()); BMessage settings(_ReadSettings());
@ -333,7 +336,7 @@ ScreenshotWindow::_SetupSecondLayoutItem(BCardLayout* layout)
_SetupOutputPathMenu(new BMenu("Please select"), settings); _SetupOutputPathMenu(new BMenu("Please select"), settings);
BMenuField* menuField2 = new BMenuField("Save in:", fOutputPathMenu); BMenuField* menuField2 = new BMenuField("Save in:", fOutputPathMenu);
fNameControl->SetText(_FindValidFileName("screenshot").String()); fNameControl->SetText(_FindValidFileName("screenshot1").String());
BBox* divider = new BBox(B_FANCY_BORDER, NULL); BBox* divider = new BBox(B_FANCY_BORDER, NULL);
divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
@ -739,7 +742,7 @@ ScreenshotWindow::_SaveScreenshotSilent() const
int32 index = 1; int32 index = 1;
do { do {
char filename[32]; char filename[32];
sprintf(filename, "screenshot%ld.png", index++); sprintf(filename, "screenshot%ld", index++);
path = homePath; path = homePath;
path.Append(filename); path.Append(filename);
entry.SetTo(path.Path()); entry.SetTo(path.Path());

View File

@ -28,7 +28,7 @@ public:
bool saveScreenshotSilent = false); bool saveScreenshotSilent = false);
virtual ~ScreenshotWindow(); virtual ~ScreenshotWindow();
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
private: private:
void _InitWindow(); void _InitWindow();