Patch by Shisui: Automatic filename basename selection and "Save" as default

button for Screenshot. Fixes #5626. Thanks a lot!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36208 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2010-04-13 11:25:15 +00:00
parent 5dcec7802a
commit 0d84b31334
2 changed files with 30 additions and 2 deletions
+28 -2
View File
@@ -159,6 +159,9 @@ ScreenshotWindow::MessageReceived(BMessage* message)
BCardLayout* layout = dynamic_cast<BCardLayout*> (GetLayout());
if (layout)
layout->SetVisibleItem(1L);
fSaveScreenshot->MakeDefault(true);
SetTitle(TR("Save screenshot"));
break;
}
@@ -168,12 +171,14 @@ ScreenshotWindow::MessageReceived(BMessage* message)
_TakeScreenshot();
_UpdatePreviewPanel();
Show();
_UpdateFilenameSelection();
break;
case kImageOutputFormat:
message->FindInt32("be:type", &fImageFileType);
message->FindInt32("be:translator", &fTranslator);
fNameControl->SetText(_FindValidFileName(fNameControl->Text()).String());
_UpdateFilenameSelection();
break;
case kLocationChanged:
@@ -183,6 +188,7 @@ ScreenshotWindow::MessageReceived(BMessage* message)
fLastSelectedPath = static_cast<BMenuItem*> (source);
fNameControl->SetText(_FindValidFileName(fNameControl->Text()).String());
_UpdateFilenameSelection();
break;
}
@@ -235,6 +241,7 @@ ScreenshotWindow::MessageReceived(BMessage* message)
if (layout)
layout->SetVisibleItem(0L);
SetDefaultButton(NULL);
SetTitle(TR("Take Screenshot"));
fBackToSave->SetEnabled(true);
@@ -280,8 +287,11 @@ ScreenshotWindow::_InitWindow()
_TakeScreenshot();
_UpdatePreviewPanel();
layout->SetVisibleItem(1L);
} else
fSaveScreenshot->MakeDefault(true);
} else {
layout->SetVisibleItem(0L);
SetDefaultButton(NULL);
}
}
@@ -392,6 +402,9 @@ ScreenshotWindow::_SetupSecondLayoutItem(BCardLayout* layout)
BBox* divider = new BBox(B_FANCY_BORDER, NULL);
divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
fSaveScreenshot = new BButton("",
TR("Save"), new BMessage(kFinishScreenshot));
BGridLayout* gridLayout = BGridLayoutBuilder(0.0, 5.0)
.Add(fNameControl->CreateLabelLayoutItem(), 0, 0)
.Add(fNameControl->CreateTextViewLayoutItem(), 1, 0)
@@ -416,7 +429,7 @@ ScreenshotWindow::_SetupSecondLayoutItem(BCardLayout* layout)
.Add(new BButton("", TR("Options"), new BMessage(kShowOptions)))
.AddGlue()
.Add(new BButton("", TR("Cancel"), new BMessage(B_QUIT_REQUESTED)))
.Add(new BButton("", TR("Save"), new BMessage(kFinishScreenshot)))
.Add(fSaveScreenshot)
.End()
.SetInsets(10.0, 10.0, 10.0, 10.0)
);
@@ -561,10 +574,23 @@ ScreenshotWindow::_UpdatePreviewPanel()
if (layout)
layout->SetVisibleItem(1L);
_UpdateFilenameSelection();
SetTitle(TR("Save screenshot"));
}
void
ScreenshotWindow::_UpdateFilenameSelection()
{
fNameControl->MakeFocus(true);
fNameControl->TextView()->Select(0,
fNameControl->TextView()->TextLength() -
fExtension.Length());
fNameControl->TextView()->ScrollToSelection();
}
BString
ScreenshotWindow::_FindValidFileName(const char* name)
{
+2
View File
@@ -56,6 +56,7 @@ private:
BString& label, int32 index, bool markItem);
void _UpdatePreviewPanel();
void _UpdateFilenameSelection();
BString _FindValidFileName(const char* name);
int32 _PathIndexInMenu(const BString& path) const;
@@ -76,6 +77,7 @@ private:
BCheckBox* fShowMouse;
BButton* fBackToSave;
BButton* fTakeScreenshot;
BButton* fSaveScreenshot;
BTextControl* fNameControl;
BMenu* fTranslatorMenu;
BMenu* fOutputPathMenu;