HaikuDepot: Allow to set the rating comment's language.
This commit is contained in:
@@ -330,10 +330,11 @@ MainWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case MSG_RATE_PACKAGE:
|
case MSG_RATE_PACKAGE:
|
||||||
{
|
{
|
||||||
// TODO: Allow only one RatingWindow
|
// TODO: Allow only one RatePackageWindow
|
||||||
// TODO: Mechanism for remembering the window frame
|
// TODO: Mechanism for remembering the window frame
|
||||||
RatePackageWindow* window = new RatePackageWindow(this,
|
RatePackageWindow* window = new RatePackageWindow(this,
|
||||||
BRect(0, 0, 500, 400));
|
BRect(0, 0, 500, 400), fModel.PreferredLanguage(),
|
||||||
|
fModel.SupportedLanguages());
|
||||||
window->Show();
|
window->Show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,8 @@
|
|||||||
enum {
|
enum {
|
||||||
MSG_SEND = 'send',
|
MSG_SEND = 'send',
|
||||||
MSG_PACKAGE_RATED = 'rpkg',
|
MSG_PACKAGE_RATED = 'rpkg',
|
||||||
MSG_STABILITY_SELECTED = 'stbl'
|
MSG_STABILITY_SELECTED = 'stbl',
|
||||||
|
MSG_LANGUAGE_SELECTED = 'lngs'
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Layouts the scrollbar so it looks nice with no border and the document
|
//! Layouts the scrollbar so it looks nice with no border and the document
|
||||||
@@ -145,13 +146,28 @@ add_stabilities_to_menu(const StabilityRatingList& stabilities, BMenu* menu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame)
|
static void
|
||||||
|
add_languages_to_menu(const StringList& languages, BMenu* menu)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < languages.CountItems(); i++) {
|
||||||
|
const BString& language = languages.ItemAtFast(i);
|
||||||
|
BMessage* message = new BMessage(MSG_LANGUAGE_SELECTED);
|
||||||
|
message->AddString("code", language);
|
||||||
|
BMenuItem* item = new BMenuItem(language, message);
|
||||||
|
menu->AddItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame,
|
||||||
|
const BString& preferredLanguage, const StringList& supportedLanguages)
|
||||||
:
|
:
|
||||||
BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Your rating"),
|
BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Your rating"),
|
||||||
B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL,
|
B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL,
|
||||||
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
|
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
|
||||||
fRatingText(),
|
fRatingText(),
|
||||||
fRating(-1.0f)
|
fRating(-1.0f),
|
||||||
|
fCommentLanguage(preferredLanguage)
|
||||||
{
|
{
|
||||||
AddToSubset(parent);
|
AddToSubset(parent);
|
||||||
|
|
||||||
@@ -174,11 +190,10 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame)
|
|||||||
textView->SetTextEditor(TextEditorRef(new TextEditor(), true));
|
textView->SetTextEditor(TextEditorRef(new TextEditor(), true));
|
||||||
|
|
||||||
// Construct stability rating popup
|
// Construct stability rating popup
|
||||||
// Construct repository popup
|
|
||||||
BPopUpMenu* stabilityMenu = new BPopUpMenu(B_TRANSLATE("Stability"));
|
BPopUpMenu* stabilityMenu = new BPopUpMenu(B_TRANSLATE("Stability"));
|
||||||
BMenuField* stabilityRatingField = new BMenuField("stability",
|
BMenuField* stabilityRatingField = new BMenuField("stability",
|
||||||
B_TRANSLATE("Stability:"), stabilityMenu);
|
B_TRANSLATE("Stability:"), stabilityMenu);
|
||||||
|
|
||||||
StabilityRatingList stabilities;
|
StabilityRatingList stabilities;
|
||||||
stabilities.Add(StabilityRating(
|
stabilities.Add(StabilityRating(
|
||||||
B_TRANSLATE("Not specified"), "UNSPECIFIED"));
|
B_TRANSLATE("Not specified"), "UNSPECIFIED"));
|
||||||
@@ -199,6 +214,20 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame)
|
|||||||
fStability = stabilities.ItemAt(0).Name();
|
fStability = stabilities.ItemAt(0).Name();
|
||||||
stabilityMenu->ItemAt(0)->SetMarked(true);
|
stabilityMenu->ItemAt(0)->SetMarked(true);
|
||||||
|
|
||||||
|
// Construct languages popup
|
||||||
|
BPopUpMenu* languagesMenu = new BPopUpMenu(B_TRANSLATE("Language"));
|
||||||
|
BMenuField* languageField = new BMenuField("language",
|
||||||
|
B_TRANSLATE("Comment language:"), languagesMenu);
|
||||||
|
|
||||||
|
add_languages_to_menu(supportedLanguages, languagesMenu);
|
||||||
|
languagesMenu->SetTargetForItems(this);
|
||||||
|
|
||||||
|
BMenuItem* defaultItem = languagesMenu->ItemAt(
|
||||||
|
supportedLanguages.IndexOf(fCommentLanguage));
|
||||||
|
if (defaultItem != NULL)
|
||||||
|
defaultItem->SetMarked(true);
|
||||||
|
|
||||||
|
// Construct buttons
|
||||||
BButton* cancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
|
BButton* cancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
|
||||||
new BMessage(B_QUIT_REQUESTED));
|
new BMessage(B_QUIT_REQUESTED));
|
||||||
|
|
||||||
@@ -211,6 +240,7 @@ RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame)
|
|||||||
.Add(ratingLabel, 0, 0)
|
.Add(ratingLabel, 0, 0)
|
||||||
.Add(setRatingView, 1, 0)
|
.Add(setRatingView, 1, 0)
|
||||||
.AddMenuField(stabilityRatingField, 0, 1)
|
.AddMenuField(stabilityRatingField, 0, 1)
|
||||||
|
.AddMenuField(languageField, 0, 2)
|
||||||
.End()
|
.End()
|
||||||
.Add(textScrollView)
|
.Add(textScrollView)
|
||||||
.AddGroup(B_HORIZONTAL)
|
.AddGroup(B_HORIZONTAL)
|
||||||
|
|||||||
@@ -13,7 +13,9 @@
|
|||||||
|
|
||||||
class RatePackageWindow : public BWindow {
|
class RatePackageWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
RatePackageWindow(BWindow* parent, BRect frame);
|
RatePackageWindow(BWindow* parent, BRect frame,
|
||||||
|
const BString& preferredLanguage,
|
||||||
|
const StringList& supportedLanguages);
|
||||||
virtual ~RatePackageWindow();
|
virtual ~RatePackageWindow();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
@@ -27,6 +29,7 @@ private:
|
|||||||
TextDocumentRef fRatingText;
|
TextDocumentRef fRatingText;
|
||||||
float fRating;
|
float fRating;
|
||||||
BString fStability;
|
BString fStability;
|
||||||
|
BString fCommentLanguage;
|
||||||
PackageInfoRef fPackage;
|
PackageInfoRef fPackage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user