From 8b9880f2b104b091d05e56871e7814cc9cf7c070 Mon Sep 17 00:00:00 2001
From: Humdinger <humdingerb@gmail.com>
Date: Sat, 16 Dec 2017 20:56:09 +0100
Subject: [PATCH] Changes to HaikuDepot GUI
As discussed at #13860.
* Moved "Show only featured packages" from the "Show" menu to a
checkbox in the filter view.
* Moved "Repositories" popup menu into the menu bar.
* Removed the "Featured packages" title.
* Entering a search term doesn't override the "Only featured"
filter anymore (used to disable the "Only featured" filter).
---
src/apps/haikudepot/ui/FilterView.cpp | 41 +++++-----------------
src/apps/haikudepot/ui/FilterView.h | 4 ++-
src/apps/haikudepot/ui/MainWindow.cpp | 65 +++++++++++++++++++++--------------
src/apps/haikudepot/ui/MainWindow.h | 3 +-
4 files changed, 52 insertions(+), 61 deletions(-)
diff --git a/src/apps/haikudepot/ui/FilterView.cpp b/src/apps/haikudepot/ui/FilterView.cpp
index be2d0ca982..1e25f3b063 100644
a
|
b
|
|
9 | 9 | #include <stdio.h> |
10 | 10 | |
11 | 11 | #include <Catalog.h> |
| 12 | #include <CheckBox.h> |
12 | 13 | #include <LayoutBuilder.h> |
13 | 14 | #include <MenuField.h> |
14 | 15 | #include <MenuItem.h> |
… |
… |
FilterView::FilterView()
|
41 | 42 | : |
42 | 43 | BGroupView("filter view", B_VERTICAL) |
43 | 44 | { |
44 | | // Contruct category popup |
| 45 | // Construct category popup |
45 | 46 | BPopUpMenu* showMenu = new BPopUpMenu(B_TRANSLATE("Category")); |
46 | 47 | fShowField = new BMenuField("category", B_TRANSLATE("Category:"), showMenu); |
47 | 48 | |
48 | | // Construct repository popup |
49 | | BPopUpMenu* repositoryMenu = new BPopUpMenu(B_TRANSLATE("Repository")); |
50 | | fRepositoryField = new BMenuField("repository", B_TRANSLATE("Repository:"), |
51 | | repositoryMenu); |
| 49 | fShowFeaturedPackages = new BCheckBox("showonlyfeatured", |
| 50 | B_TRANSLATE("Show only featured packages"), |
| 51 | new BMessage(MSG_SHOW_FEATURED_PACKAGES)); |
52 | 52 | |
53 | 53 | // Construct search terms field |
54 | 54 | fSearchTermsText = new BTextControl("search terms", |
… |
… |
FilterView::FilterView()
|
71 | 71 | .AddGroup(B_HORIZONTAL) |
72 | 72 | .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1.2f) |
73 | 73 | .Add(fShowField, 0.0f) |
74 | | .Add(fRepositoryField, 0.0f) |
| 74 | .Add(fShowFeaturedPackages, 0.0f) |
75 | 75 | .SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)) |
76 | 76 | .End() |
77 | 77 | .AddGlue(0.5f) |
… |
… |
void
|
92 | 92 | FilterView::AttachedToWindow() |
93 | 93 | { |
94 | 94 | fShowField->Menu()->SetTargetForItems(Window()); |
95 | | fRepositoryField->Menu()->SetTargetForItems(Window()); |
| 95 | fShowFeaturedPackages->SetTarget(Window()); |
96 | 96 | fSearchTermsText->SetTarget(this); |
97 | 97 | |
98 | 98 | fSearchTermsText->MakeFocus(); |
… |
… |
FilterView::MessageReceived(BMessage* message)
|
121 | 121 | void |
122 | 122 | FilterView::AdoptModel(const Model& model) |
123 | 123 | { |
124 | | // Adopt depots |
125 | | BMenu* repositoryMenu = fRepositoryField->Menu(); |
126 | | repositoryMenu->RemoveItems(0, repositoryMenu->CountItems(), true); |
127 | | |
128 | | repositoryMenu->AddItem(new BMenuItem(B_TRANSLATE("All repositories"), |
129 | | new BMessage(MSG_DEPOT_SELECTED))); |
130 | | |
131 | | repositoryMenu->AddItem(new BSeparatorItem()); |
132 | | |
133 | | bool foundSelectedDepot = false; |
134 | | const DepotList& depots = model.Depots(); |
135 | | for (int i = 0; i < depots.CountItems(); i++) { |
136 | | const DepotInfo& depot = depots.ItemAtFast(i); |
137 | | BMessage* message = new BMessage(MSG_DEPOT_SELECTED); |
138 | | message->AddString("name", depot.Name()); |
139 | | BMenuItem* item = new BMenuItem(depot.Name(), message); |
140 | | repositoryMenu->AddItem(item); |
141 | | |
142 | | if (depot.Name() == model.Depot()) { |
143 | | item->SetMarked(true); |
144 | | foundSelectedDepot = true; |
145 | | } |
146 | | } |
147 | | |
148 | | if (!foundSelectedDepot) |
149 | | repositoryMenu->ItemAt(0)->SetMarked(true); |
| 124 | fShowFeaturedPackages->SetValue(model.ShowFeaturedPackages()); |
150 | 125 | |
151 | 126 | // Adopt categories |
152 | 127 | BMenu* showMenu = fShowField->Menu(); |
diff --git a/src/apps/haikudepot/ui/FilterView.h b/src/apps/haikudepot/ui/FilterView.h
index 4e444d6b4a..b290e8135c 100644
a
|
b
|
|
8 | 8 | #include <GroupView.h> |
9 | 9 | |
10 | 10 | |
| 11 | class BCheckBox; |
11 | 12 | class BMenuField; |
12 | 13 | class BTextControl; |
13 | 14 | class Model; |
… |
… |
enum {
|
17 | 18 | MSG_CATEGORY_SELECTED = 'ctsl', |
18 | 19 | MSG_DEPOT_SELECTED = 'dpsl', |
19 | 20 | MSG_SEARCH_TERMS_MODIFIED = 'stmd', |
| 21 | MSG_SHOW_FEATURED_PACKAGES = 'sofp', |
20 | 22 | }; |
21 | 23 | |
22 | 24 | |
… |
… |
public:
|
32 | 34 | |
33 | 35 | private: |
34 | 36 | BMenuField* fShowField; |
35 | | BMenuField* fRepositoryField; |
| 37 | BCheckBox* fShowFeaturedPackages; |
36 | 38 | BTextControl* fSearchTermsText; |
37 | 39 | }; |
38 | 40 | |
diff --git a/src/apps/haikudepot/ui/MainWindow.cpp b/src/apps/haikudepot/ui/MainWindow.cpp
index f094cb9a22..dfda12b481 100644
a
|
b
|
enum {
|
74 | 74 | MSG_AUTHORIZATION_CHANGED = 'athc', |
75 | 75 | MSG_PACKAGE_CHANGED = 'pchd', |
76 | 76 | |
77 | | MSG_SHOW_FEATURED_PACKAGES = 'sofp', |
78 | 77 | MSG_SHOW_AVAILABLE_PACKAGES = 'savl', |
79 | 78 | MSG_SHOW_INSTALLED_PACKAGES = 'sins', |
80 | 79 | MSG_SHOW_SOURCE_PACKAGES = 'ssrc', |
… |
… |
MainWindow::MainWindow(const BMessage& settings)
|
152 | 151 | |
153 | 152 | fSplitView = new BSplitView(B_VERTICAL, 5.0f); |
154 | 153 | |
155 | | BGroupView* featuredPackagesGroup = new BGroupView(B_VERTICAL); |
156 | | BStringView* featuredPackagesTitle = new BStringView( |
157 | | "featured packages title", B_TRANSLATE("Featured packages")); |
158 | | BFont font(be_bold_font); |
159 | | font.SetSize(font.Size() * 1.3f); |
160 | | featuredPackagesTitle->SetFont(&font); |
161 | | featuredPackagesGroup->SetExplicitMaxSize( |
162 | | BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); |
163 | | BLayoutBuilder::Group<>(featuredPackagesGroup) |
164 | | .Add(featuredPackagesTitle) |
165 | | .Add(fFeaturedPackagesView) |
166 | | ; |
167 | | |
168 | 154 | fWorkStatusView = new WorkStatusView("work status"); |
169 | 155 | fPackageListView->AttachWorkStatusView(fWorkStatusView); |
170 | 156 | |
171 | 157 | BView* listArea = new BView("list area", 0); |
172 | 158 | fListLayout = new BCardLayout(); |
173 | 159 | listArea->SetLayout(fListLayout); |
174 | | listArea->AddChild(featuredPackagesGroup); |
| 160 | listArea->AddChild(fFeaturedPackagesView); |
175 | 161 | listArea->AddChild(fPackageListView); |
176 | 162 | |
177 | 163 | BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) |
… |
… |
MainWindow::MessageReceived(BMessage* message)
|
319 | 305 | { |
320 | 306 | fModelWorker = B_BAD_THREAD_ID; |
321 | 307 | _AdoptModel(); |
322 | | fFilterView->AdoptModel(fModel); |
| 308 | _UpdateAvailableRepositories(); |
323 | 309 | fWorkStatusView->SetIdle(); |
324 | 310 | break; |
325 | 311 | } |
… |
… |
MainWindow::MessageReceived(BMessage* message)
|
445 | 431 | fModel.SetDepot(name); |
446 | 432 | } |
447 | 433 | _AdoptModel(); |
| 434 | _UpdateAvailableRepositories(); |
448 | 435 | break; |
449 | 436 | } |
450 | 437 | |
… |
… |
MainWindow::_BuildMenu(BMenuBar* menuBar)
|
678 | 665 | |
679 | 666 | menuBar->AddItem(menu); |
680 | 667 | |
681 | | menu = new BMenu(B_TRANSLATE("Show")); |
| 668 | fRepositoryMenu = new BMenu(B_TRANSLATE("Repositories")); |
| 669 | menuBar->AddItem(fRepositoryMenu); |
682 | 670 | |
683 | | fShowFeaturedPackagesItem = new BMenuItem( |
684 | | B_TRANSLATE("Only featured packages"), |
685 | | new BMessage(MSG_SHOW_FEATURED_PACKAGES)); |
686 | | menu->AddItem(fShowFeaturedPackagesItem); |
687 | | |
688 | | menu->AddSeparatorItem(); |
| 671 | menu = new BMenu(B_TRANSLATE("Show")); |
689 | 672 | |
690 | 673 | fShowAvailablePackagesItem = new BMenuItem( |
691 | 674 | B_TRANSLATE("Available packages"), |
… |
… |
MainWindow::_AdoptModel()
|
835 | 818 | release_sem(fNewPackagesToShowSem); |
836 | 819 | |
837 | 820 | BAutolock locker(fModel.Lock()); |
838 | | fShowFeaturedPackagesItem->SetMarked(fModel.ShowFeaturedPackages()); |
839 | | fShowFeaturedPackagesItem->SetEnabled(fModel.SearchTerms() == ""); |
840 | 821 | fShowAvailablePackagesItem->SetMarked(fModel.ShowAvailablePackages()); |
841 | 822 | fShowInstalledPackagesItem->SetMarked(fModel.ShowInstalledPackages()); |
842 | 823 | fShowSourcePackagesItem->SetMarked(fModel.ShowSourcePackages()); |
843 | 824 | fShowDevelopPackagesItem->SetMarked(fModel.ShowDevelopPackages()); |
844 | 825 | |
845 | | if (fModel.ShowFeaturedPackages() && fModel.SearchTerms() == "") |
| 826 | if (fModel.ShowFeaturedPackages()) |
846 | 827 | fListLayout->SetVisibleItem((int32)0); |
847 | 828 | else |
848 | 829 | fListLayout->SetVisibleItem((int32)1); |
| 830 | |
| 831 | fFilterView->AdoptModel(fModel); |
849 | 832 | } |
850 | 833 | |
851 | 834 | |
… |
… |
MainWindow::_UpdateAuthorization()
|
1406 | 1389 | } |
1407 | 1390 | |
1408 | 1391 | |
| 1392 | void |
| 1393 | MainWindow::_UpdateAvailableRepositories() |
| 1394 | { |
| 1395 | fRepositoryMenu->RemoveItems(0, fRepositoryMenu->CountItems(), true); |
| 1396 | |
| 1397 | fRepositoryMenu->AddItem(new BMenuItem(B_TRANSLATE("All repositories"), |
| 1398 | new BMessage(MSG_DEPOT_SELECTED))); |
| 1399 | |
| 1400 | fRepositoryMenu->AddItem(new BSeparatorItem()); |
| 1401 | |
| 1402 | bool foundSelectedDepot = false; |
| 1403 | const DepotList& depots = fModel.Depots(); |
| 1404 | for (int i = 0; i < depots.CountItems(); i++) { |
| 1405 | const DepotInfo& depot = depots.ItemAtFast(i); |
| 1406 | BMessage* message = new BMessage(MSG_DEPOT_SELECTED); |
| 1407 | message->AddString("name", depot.Name()); |
| 1408 | BMenuItem* item = new BMenuItem(depot.Name(), message); |
| 1409 | fRepositoryMenu->AddItem(item); |
| 1410 | |
| 1411 | if (depot.Name() == fModel.Depot()) { |
| 1412 | item->SetMarked(true); |
| 1413 | foundSelectedDepot = true; |
| 1414 | } |
| 1415 | } |
| 1416 | |
| 1417 | if (!foundSelectedDepot) |
| 1418 | fRepositoryMenu->ItemAt(0)->SetMarked(true); |
| 1419 | } |
| 1420 | |
| 1421 | |
1409 | 1422 | void |
1410 | 1423 | MainWindow::_RatePackage() |
1411 | 1424 | { |
diff --git a/src/apps/haikudepot/ui/MainWindow.h b/src/apps/haikudepot/ui/MainWindow.h
index 6f7d95c18a..5a13228d67 100644
a
|
b
|
private:
|
92 | 92 | void _OpenLoginWindow( |
93 | 93 | const BMessage& onSuccessMessage); |
94 | 94 | void _UpdateAuthorization(); |
| 95 | void _UpdateAvailableRepositories(); |
95 | 96 | void _RatePackage(); |
96 | 97 | void _ShowScreenshot(); |
97 | 98 | |
… |
… |
private:
|
107 | 108 | ScreenshotWindow* fScreenshotWindow; |
108 | 109 | |
109 | 110 | BMenu* fUserMenu; |
| 111 | BMenu* fRepositoryMenu; |
110 | 112 | BMenuItem* fLogInItem; |
111 | 113 | BMenuItem* fLogOutItem; |
112 | 114 | |
113 | | BMenuItem* fShowFeaturedPackagesItem; |
114 | 115 | BMenuItem* fShowAvailablePackagesItem; |
115 | 116 | BMenuItem* fShowInstalledPackagesItem; |
116 | 117 | BMenuItem* fShowDevelopPackagesItem; |