Adding a settings button to change translator settings, refer to ticket #3813
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37335 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
|
#include <TranslatorRoster.h>
|
||||||
|
|
||||||
#include "PreviewView.h"
|
#include "PreviewView.h"
|
||||||
#include "Utility.h"
|
#include "Utility.h"
|
||||||
@@ -50,7 +51,8 @@ enum {
|
|||||||
kImageFormat,
|
kImageFormat,
|
||||||
kLocationChanged,
|
kLocationChanged,
|
||||||
kChooseLocation,
|
kChooseLocation,
|
||||||
kSaveScreenshot
|
kSaveScreenshot,
|
||||||
|
kSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -158,6 +160,8 @@ ScreenshotWindow::ScreenshotWindow(const Utility& utility, bool silent,
|
|||||||
.Add(fNameControl->CreateTextViewLayoutItem(), 1, 0)
|
.Add(fNameControl->CreateTextViewLayoutItem(), 1, 0)
|
||||||
.Add(menuField->CreateLabelLayoutItem(), 0, 1)
|
.Add(menuField->CreateLabelLayoutItem(), 0, 1)
|
||||||
.Add(menuField->CreateMenuBarLayoutItem(), 1, 1)
|
.Add(menuField->CreateMenuBarLayoutItem(), 1, 1)
|
||||||
|
.Add(new BButton("", B_TRANSLATE("Settings"B_UTF8_ELLIPSIS),
|
||||||
|
new BMessage(kSettings)), 2, 1)
|
||||||
.Add(menuField2->CreateLabelLayoutItem(), 0, 2)
|
.Add(menuField2->CreateLabelLayoutItem(), 0, 2)
|
||||||
.Add(menuField2->CreateMenuBarLayoutItem(), 1, 2);
|
.Add(menuField2->CreateMenuBarLayoutItem(), 1, 2);
|
||||||
gridLayout->SetMinColumnWidth(1,
|
gridLayout->SetMinColumnWidth(1,
|
||||||
@@ -303,6 +307,10 @@ ScreenshotWindow::MessageReceived(BMessage* message)
|
|||||||
fUtility.CopyToClipboard(fScreenshot);
|
fUtility.CopyToClipboard(fScreenshot);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kSettings:
|
||||||
|
_ShowSettings();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
@@ -319,6 +327,9 @@ ScreenshotWindow::Quit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma - private
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScreenshotWindow::_NewScreenshot(bool silent, bool clipboard)
|
ScreenshotWindow::_NewScreenshot(bool silent, bool clipboard)
|
||||||
{
|
{
|
||||||
@@ -543,6 +554,56 @@ ScreenshotWindow::_SaveScreenshot()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScreenshotWindow::_ShowSettings()
|
||||||
|
{
|
||||||
|
// Find a translator
|
||||||
|
translator_id translator = 0;
|
||||||
|
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
||||||
|
translator_id* translators = NULL;
|
||||||
|
int32 numTranslators = 0;
|
||||||
|
if (roster->GetAllTranslators(&translators, &numTranslators) != B_OK)
|
||||||
|
return;
|
||||||
|
bool foundTranslator = false;
|
||||||
|
for (int32 x = 0; x < numTranslators; x++) {
|
||||||
|
const translation_format* formats = NULL;
|
||||||
|
int32 numFormats;
|
||||||
|
if (roster->GetOutputFormats(translators[x], &formats, &numFormats) == B_OK) {
|
||||||
|
for (int32 i = 0; i < numFormats; ++i) {
|
||||||
|
if (formats[i].type == static_cast<uint32>(fImageFileType)) {
|
||||||
|
translator = translators[x];
|
||||||
|
foundTranslator = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (foundTranslator)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
delete [] translators;
|
||||||
|
if (!foundTranslator)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Create a window with a configuration view
|
||||||
|
BView *view;
|
||||||
|
BRect rect(0, 0, 239, 239);
|
||||||
|
|
||||||
|
status_t err = roster->MakeConfigurationView(translator, NULL, &view,
|
||||||
|
&rect);
|
||||||
|
if (err < B_OK || view == NULL) {
|
||||||
|
BAlert *alert = new BAlert(NULL, strerror(err), "OK");
|
||||||
|
alert->Go();
|
||||||
|
} else {
|
||||||
|
BWindow* window = new BWindow(rect, "Translator Settings",
|
||||||
|
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||||
|
B_NOT_ZOOMABLE | B_NOT_RESIZABLE);
|
||||||
|
window->AddChild(view);
|
||||||
|
window->CenterOnScreen();
|
||||||
|
window->Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BString
|
BString
|
||||||
ScreenshotWindow::_FindValidFileName(const char* name)
|
ScreenshotWindow::_FindValidFileName(const char* name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ private:
|
|||||||
void _UpdateFilenameSelection();
|
void _UpdateFilenameSelection();
|
||||||
void _SetupTranslatorMenu();
|
void _SetupTranslatorMenu();
|
||||||
status_t _SaveScreenshot();
|
status_t _SaveScreenshot();
|
||||||
|
void _ShowSettings();
|
||||||
BString _FindValidFileName(const char* name);
|
BString _FindValidFileName(const char* name);
|
||||||
BPath _GetDirectory();
|
BPath _GetDirectory();
|
||||||
void _ReadSettings();
|
void _ReadSettings();
|
||||||
|
|||||||
Reference in New Issue
Block a user