hrev48090 adds 2 changesets to branch 'master' old head: 9303787b1a749039a88318f3f74a5c84d82e3c8b new head: fdec4227f5fc60024af6f092e1ae14f6425938b9 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=fdec422+%5E9303787 ---------------------------------------------------------------------------- e0a26dc: HaikuDepot: Centralized user account features in the UI There is now a right-aligned second menu bar for the account management. The menu label is what was previously shown underneath the search terms field. The menu items have moved from the Tools menu into the new user menu. This means the login/logout functionality is directly available where the login info is shown in the UI when you click it. fdec422: HaikuDepot: Resurrect Options menu... And move the (new) checkmarks into the Options menu. This makes them less easy to discover, but cleans up the UI, especially since the options to show development and source code packages are not very important for most users. [ Stephan Aßmus <superstippi@xxxxxx> ] ---------------------------------------------------------------------------- 6 files changed, 131 insertions(+), 145 deletions(-) src/apps/haikudepot/ui/FilterView.cpp | 78 +------------ src/apps/haikudepot/ui/FilterView.h | 13 --- src/apps/haikudepot/ui/MainWindow.cpp | 155 ++++++++++++++++--------- src/apps/haikudepot/ui/MainWindow.h | 13 ++- src/apps/haikudepot/ui_generic/support.cpp | 15 +++ src/apps/haikudepot/ui_generic/support.h | 2 + ############################################################################ Commit: e0a26dce59fe1b3461b7c8d392992f39cd58dbaf URL: http://cgit.haiku-os.org/haiku/commit/?id=e0a26dc Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sat Oct 25 15:16:37 2014 UTC HaikuDepot: Centralized user account features in the UI There is now a right-aligned second menu bar for the account management. The menu label is what was previously shown underneath the search terms field. The menu items have moved from the Tools menu into the new user menu. This means the login/logout functionality is directly available where the login info is shown in the UI when you click it. ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/FilterView.cpp b/src/apps/haikudepot/ui/FilterView.cpp index ef52e08..11c2c1b 100644 --- a/src/apps/haikudepot/ui/FilterView.cpp +++ b/src/apps/haikudepot/ui/FilterView.cpp @@ -15,10 +15,10 @@ #include <MenuItem.h> #include <Messenger.h> #include <PopUpMenu.h> -#include <StringView.h> #include <TextControl.h> #include "Model.h" +#include "support.h" #undef B_TRANSLATION_CONTEXT @@ -38,16 +38,6 @@ add_categories_to_menu(const CategoryList& categories, BMenu* menu) } -static void -set_small_font(BView* view) -{ - BFont font; - view->GetFont(&font); - font.SetSize(ceilf(font.Size() * 0.8)); - view->SetFont(&font); -} - - static BCheckBox* create_check_box(const char* label, const char* name) { @@ -98,11 +88,6 @@ FilterView::FilterView() fSourceCodeCheckBox = create_check_box( B_TRANSLATE("Source code"), "source code"); - // Logged in user label - fUsername = new BStringView("logged in user", ""); - set_small_font(fUsername); - fUsername->SetHighColor(80, 80, 80); - // Build layout BLayoutBuilder::Group<>(this) .AddGroup(B_HORIZONTAL) @@ -119,8 +104,7 @@ FilterView::FilterView() .Add(fInstalledCheckBox) .Add(fDevelopmentCheckBox) .Add(fSourceCodeCheckBox) - .AddGlue(0.5f) - .Add(fUsername) + .AddGlue() .End() .SetInsets(B_USE_DEFAULT_SPACING) @@ -214,17 +198,3 @@ FilterView::AdoptCheckmarks(const Model& model) fSourceCodeCheckBox->SetValue(model.ShowSourcePackages()); } - -void -FilterView::SetUsername(const BString& username) -{ - BString label; - if (username.Length() == 0) { - label = B_TRANSLATE("Not logged in"); - } else { - label = B_TRANSLATE("Logged in as %User%"); - label.ReplaceAll("%User%", username); - } - fUsername->SetText(label); -} - diff --git a/src/apps/haikudepot/ui/FilterView.h b/src/apps/haikudepot/ui/FilterView.h index 81e6a6b..056d889 100644 --- a/src/apps/haikudepot/ui/FilterView.h +++ b/src/apps/haikudepot/ui/FilterView.h @@ -10,7 +10,6 @@ class BCheckBox; class BMenuField; -class BStringView; class BTextControl; class Model; @@ -34,8 +33,6 @@ public: void AdoptModel(const Model& model); void AdoptCheckmarks(const Model& model); - void SetUsername(const BString& username); - private: BMenuField* fShowField; BMenuField* fRepositoryField; @@ -45,8 +42,6 @@ private: BCheckBox* fInstalledCheckBox; BCheckBox* fDevelopmentCheckBox; BCheckBox* fSourceCodeCheckBox; - - BStringView* fUsername; }; #endif // FILTER_VIEW_H diff --git a/src/apps/haikudepot/ui/MainWindow.cpp b/src/apps/haikudepot/ui/MainWindow.cpp index a997992..e1dddea 100644 --- a/src/apps/haikudepot/ui/MainWindow.cpp +++ b/src/apps/haikudepot/ui/MainWindow.cpp @@ -45,6 +45,7 @@ #include "PackageListView.h" #include "PackageManager.h" #include "RatePackageWindow.h" +#include "support.h" #include "UserLoginWindow.h" @@ -109,6 +110,9 @@ MainWindow::MainWindow(BRect frame, const BMessage& settings) BWindow(frame, B_TRANSLATE_SYSTEM_NAME("HaikuDepot"), B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), + fUserMenu(NULL), + fLogInItem(NULL), + fLogOutItem(NULL), fModelListener(new MessageModelListener(BMessenger(this)), true), fTerminating(false), fSinglePackageMode(false), @@ -117,6 +121,12 @@ MainWindow::MainWindow(BRect frame, const BMessage& settings) BMenuBar* menuBar = new BMenuBar(B_TRANSLATE("Main Menu")); _BuildMenu(menuBar); + BMenuBar* userMenuBar = new BMenuBar(B_TRANSLATE("User Menu")); + _BuildUserMenu(userMenuBar); + set_small_font(userMenuBar); + userMenuBar->SetExplicitMaxSize(BSize(B_SIZE_UNSET, + menuBar->MaxSize().height)); + fFilterView = new FilterView(); fPackageListView = new PackageListView(fModel.Lock()); fPackageInfoView = new PackageInfoView(fModel.Lock(), this); @@ -124,7 +134,10 @@ MainWindow::MainWindow(BRect frame, const BMessage& settings) fSplitView = new BSplitView(B_VERTICAL, 5.0f); BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) - .Add(menuBar) + .AddGroup(B_HORIZONTAL, 0.0f) + .Add(menuBar, 1.0f) + .Add(userMenuBar, 0.0f) + .End() .Add(fFilterView) .AddSplit(fSplitView) .AddGroup(B_VERTICAL) @@ -175,6 +188,8 @@ MainWindow::MainWindow(BRect frame, const BMessage& settings, BWindow(frame, B_TRANSLATE_SYSTEM_NAME("HaikuDepot"), B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), + fUserMenu(NULL), + fLogInItem(NULL), fLogOutItem(NULL), fModelListener(new MessageModelListener(BMessenger(this)), true), fTerminating(false), @@ -463,11 +478,7 @@ MainWindow::_BuildMenu(BMenuBar* menuBar) menu->AddItem(new BMenuItem(B_TRANSLATE("Refresh depots"), new BMessage(MSG_REFRESH_DEPOTS))); menu->AddSeparatorItem(); - menu->AddItem(new BMenuItem(B_TRANSLATE("Log in" B_UTF8_ELLIPSIS), - new BMessage(MSG_LOG_IN))); - fLogOutItem = new BMenuItem(B_TRANSLATE("Log out"), - new BMessage(MSG_LOG_OUT)); - menu->AddItem(fLogOutItem); + menuBar->AddItem(menu); // menu = new BMenu(B_TRANSLATE("Options")); @@ -486,6 +497,23 @@ MainWindow::_BuildMenu(BMenuBar* menuBar) void +MainWindow::_BuildUserMenu(BMenuBar* menuBar) +{ + fUserMenu = new BMenu(B_TRANSLATE("Not logged in")); + + fLogInItem = new BMenuItem(B_TRANSLATE("Log in" B_UTF8_ELLIPSIS), + new BMessage(MSG_LOG_IN)); + fUserMenu->AddItem(fLogInItem); + + fLogOutItem = new BMenuItem(B_TRANSLATE("Log out"), + new BMessage(MSG_LOG_OUT)); + fUserMenu->AddItem(fLogOutItem); + + menuBar->AddItem(fUserMenu); +} + + +void MainWindow::_InitWorkerThreads() { fPendingActionsSem = create_sem(0, "PendingPackageActions"); @@ -939,9 +967,27 @@ void MainWindow::_UpdateAuthorization() { BString username(fModel.Username()); + bool hasUser = !username.IsEmpty(); + if (fLogOutItem != NULL) - fLogOutItem->SetEnabled(username.Length() > 0); - fFilterView->SetUsername(username); + fLogOutItem->SetEnabled(hasUser); + if (fLogInItem != NULL) { + if (hasUser) + fLogInItem->SetLabel(B_TRANSLATE("Switch account" B_UTF8_ELLIPSIS)); + else + fLogInItem->SetLabel(B_TRANSLATE("Log in" B_UTF8_ELLIPSIS)); + } + + if (fUserMenu != NULL) { + BString label; + if (username.Length() == 0) { + label = B_TRANSLATE("Not logged in"); + } else { + label = B_TRANSLATE("Logged in as %User%"); + label.ReplaceAll("%User%", username); + } + fUserMenu->Superitem()->SetLabel(label); + } } diff --git a/src/apps/haikudepot/ui/MainWindow.h b/src/apps/haikudepot/ui/MainWindow.h index 18a494d..9805fe6 100644 --- a/src/apps/haikudepot/ui/MainWindow.h +++ b/src/apps/haikudepot/ui/MainWindow.h @@ -14,6 +14,8 @@ #include "PackageInfoListener.h" +class BMenu; +class BMenuItem; class BSplitView; class FilterView; class PackageActionsView; @@ -55,6 +57,8 @@ private: private: void _BuildMenu(BMenuBar* menuBar); + void _BuildUserMenu(BMenuBar* menuBar); + void _InitWorkerThreads(); void _AdoptModel(); @@ -65,11 +69,8 @@ private: void _RefreshPackageList(); void _StartRefreshWorker(bool force = false); - static status_t _RefreshModelThreadWorker(void* arg); - static status_t _PackageActionWorker(void* arg); - static status_t _PopulatePackageWorker(void* arg); void _NotifyUser(const char* title, @@ -85,7 +86,13 @@ private: PackageListView* fPackageListView; PackageInfoView* fPackageInfoView; BSplitView* fSplitView; + + BMenu* fUserMenu; + BMenuItem* fLogInItem; BMenuItem* fLogOutItem; + + BMenuItem* fShowAvailablePackagesItem; + BMenuItem* fShowInstalledPackagesItem; BMenuItem* fShowDevelopPackagesItem; BMenuItem* fShowSourcePackagesItem; diff --git a/src/apps/haikudepot/ui_generic/support.cpp b/src/apps/haikudepot/ui_generic/support.cpp index 9287cd8..d508769 100644 --- a/src/apps/haikudepot/ui_generic/support.cpp +++ b/src/apps/haikudepot/ui_generic/support.cpp @@ -13,10 +13,12 @@ #include <Directory.h> #include <File.h> #include <FindDirectory.h> +#include <Font.h> #include <Path.h> #include <Resources.h> #include <Roster.h> #include <Screen.h> +#include <View.h> status_t @@ -145,3 +147,16 @@ get_app_resources(BResources& resources) return resources.SetTo(&info.ref); } + +void +set_small_font(BView* view) +{ + BFont font; + view->GetFont(&font); + font.SetSize(ceilf(font.Size() * 0.8)); + view->SetFont(&font); +} + + + + diff --git a/src/apps/haikudepot/ui_generic/support.h b/src/apps/haikudepot/ui_generic/support.h index 1f45eb3..31ec2c4 100644 --- a/src/apps/haikudepot/ui_generic/support.h +++ b/src/apps/haikudepot/ui_generic/support.h @@ -11,6 +11,7 @@ class BMessage; class BResources; +class BView; class BWindow; @@ -25,5 +26,6 @@ bool make_sure_frame_is_on_screen(BRect& frame, float borderWidth = 5.0f, status_t get_app_resources(BResources& resources); +void set_small_font(BView* view); #endif // SUPPORT_H ############################################################################ Revision: hrev48090 Commit: fdec4227f5fc60024af6f092e1ae14f6425938b9 URL: http://cgit.haiku-os.org/haiku/commit/?id=fdec422 Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sat Oct 25 15:30:54 2014 UTC HaikuDepot: Resurrect Options menu... And move the (new) checkmarks into the Options menu. This makes them less easy to discover, but cleans up the UI, especially since the options to show development and source code packages are not very important for most users. ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/FilterView.cpp b/src/apps/haikudepot/ui/FilterView.cpp index 11c2c1b..c4e9763 100644 --- a/src/apps/haikudepot/ui/FilterView.cpp +++ b/src/apps/haikudepot/ui/FilterView.cpp @@ -9,7 +9,6 @@ #include <stdio.h> #include <Catalog.h> -#include <CheckBox.h> #include <LayoutBuilder.h> #include <MenuField.h> #include <MenuItem.h> @@ -38,17 +37,6 @@ add_categories_to_menu(const CategoryList& categories, BMenu* menu) } -static BCheckBox* -create_check_box(const char* label, const char* name) -{ - BMessage* message = new BMessage(MSG_FILTER_SELECTED); - message->AddString("name", name); - BCheckBox* checkBox = new BCheckBox(label, message); - set_small_font(checkBox); - return checkBox; -} - - FilterView::FilterView() : BGroupView("filter view", B_VERTICAL) @@ -78,16 +66,6 @@ FilterView::FilterView() float maxSearchWidth = minSearchWidth * 2; fSearchTermsText->SetExplicitMaxSize(BSize(maxSearchWidth, B_SIZE_UNSET)); - // Construct check boxen - fAvailableCheckBox = create_check_box( - B_TRANSLATE("Available"), "available"); - fInstalledCheckBox = create_check_box( - B_TRANSLATE("Installed"), "installed"); - fDevelopmentCheckBox = create_check_box( - B_TRANSLATE("Development"), "development"); - fSourceCodeCheckBox = create_check_box( - B_TRANSLATE("Source code"), "source code"); - // Build layout BLayoutBuilder::Group<>(this) .AddGroup(B_HORIZONTAL) @@ -99,13 +77,6 @@ FilterView::FilterView() .AddGlue(0.5f) .Add(fSearchTermsText, 1.0f) .End() - .AddGroup(B_HORIZONTAL) - .Add(fAvailableCheckBox) - .Add(fInstalledCheckBox) - .Add(fDevelopmentCheckBox) - .Add(fSourceCodeCheckBox) - .AddGlue() - .End() .SetInsets(B_USE_DEFAULT_SPACING) ; @@ -125,11 +96,6 @@ FilterView::AttachedToWindow() fSearchTermsText->SetTarget(this); fSearchTermsText->MakeFocus(); - - fAvailableCheckBox->SetTarget(Window()); - fInstalledCheckBox->SetTarget(Window()); - fDevelopmentCheckBox->SetTarget(Window()); - fSourceCodeCheckBox->SetTarget(Window()); } @@ -184,17 +150,5 @@ FilterView::AdoptModel(const Model& model) add_categories_to_menu(model.Categories(), showMenu); showMenu->ItemAt(0)->SetMarked(true); - - AdoptCheckmarks(model); -} - - -void -FilterView::AdoptCheckmarks(const Model& model) -{ - fAvailableCheckBox->SetValue(model.ShowAvailablePackages()); - fInstalledCheckBox->SetValue(model.ShowInstalledPackages()); - fDevelopmentCheckBox->SetValue(model.ShowDevelopPackages()); - fSourceCodeCheckBox->SetValue(model.ShowSourcePackages()); } diff --git a/src/apps/haikudepot/ui/FilterView.h b/src/apps/haikudepot/ui/FilterView.h index 056d889..4e444d6 100644 --- a/src/apps/haikudepot/ui/FilterView.h +++ b/src/apps/haikudepot/ui/FilterView.h @@ -8,7 +8,6 @@ #include <GroupView.h> -class BCheckBox; class BMenuField; class BTextControl; class Model; @@ -16,7 +15,6 @@ class Model; enum { MSG_CATEGORY_SELECTED = 'ctsl', - MSG_FILTER_SELECTED = 'ftsl', MSG_DEPOT_SELECTED = 'dpsl', MSG_SEARCH_TERMS_MODIFIED = 'stmd', }; @@ -31,17 +29,11 @@ public: virtual void MessageReceived(BMessage* message); void AdoptModel(const Model& model); - void AdoptCheckmarks(const Model& model); private: BMenuField* fShowField; BMenuField* fRepositoryField; BTextControl* fSearchTermsText; - - BCheckBox* fAvailableCheckBox; - BCheckBox* fInstalledCheckBox; - BCheckBox* fDevelopmentCheckBox; - BCheckBox* fSourceCodeCheckBox; }; #endif // FILTER_VIEW_H diff --git a/src/apps/haikudepot/ui/MainWindow.cpp b/src/apps/haikudepot/ui/MainWindow.cpp index e1dddea..71a33f5 100644 --- a/src/apps/haikudepot/ui/MainWindow.cpp +++ b/src/apps/haikudepot/ui/MainWindow.cpp @@ -60,6 +60,9 @@ enum { MSG_LOG_OUT = 'lgot', MSG_AUTHORIZATION_CHANGED = 'athc', MSG_PACKAGE_STATE_CHANGED = 'mpsc', + + MSG_SHOW_AVAILABLE_PACKAGES = 'savl', + MSG_SHOW_INSTALLED_PACKAGES = 'sins', MSG_SHOW_SOURCE_PACKAGES = 'ssrc', MSG_SHOW_DEVELOP_PACKAGES = 'sdvl' }; @@ -289,6 +292,24 @@ MainWindow::MessageReceived(BMessage* message) _UpdateAuthorization(); break; + case MSG_SHOW_AVAILABLE_PACKAGES: + { + BAutolock locker(fModel.Lock()); + fModel.SetShowAvailablePackages( + !fModel.ShowAvailablePackages()); + } + _AdoptModel(); + break; + + case MSG_SHOW_INSTALLED_PACKAGES: + { + BAutolock locker(fModel.Lock()); + fModel.SetShowInstalledPackages( + !fModel.ShowInstalledPackages()); + } + _AdoptModel(); + break; + case MSG_SHOW_SOURCE_PACKAGES: { BAutolock locker(fModel.Lock()); @@ -337,36 +358,6 @@ MainWindow::MessageReceived(BMessage* message) break; } - case MSG_FILTER_SELECTED: - { - BString name; - int32 value; - if (message->FindString("name", &name) != B_OK - || message->FindInt32("be:value", &value) != B_OK) { - break; - } - { - BAutolock locker(fModel.Lock()); - if (name == "available") { - fModel.SetShowAvailablePackages( - value == B_CONTROL_ON); - } else if (name == "installed") { - fModel.SetShowInstalledPackages( - value == B_CONTROL_ON); - } else if (name == "development") { - fModel.SetShowDevelopPackages( - value == B_CONTROL_ON); - } else if (name == "source code") { - fModel.SetShowSourcePackages( - value == B_CONTROL_ON); - } else { - break; - } - } - _AdoptModel(); - break; - } - case MSG_DEPOT_SELECTED: { BString name; @@ -481,18 +472,31 @@ MainWindow::_BuildMenu(BMenuBar* menuBar) menuBar->AddItem(menu); -// menu = new BMenu(B_TRANSLATE("Options")); -// -// fShowDevelopPackagesItem = new BMenuItem( -// B_TRANSLATE("Show develop packages"), -// new BMessage(MSG_SHOW_DEVELOP_PACKAGES)); -// menu->AddItem(fShowDevelopPackagesItem); -// -// fShowSourcePackagesItem = new BMenuItem(B_TRANSLATE("Show source packages"), -// new BMessage(MSG_SHOW_SOURCE_PACKAGES)); -// menu->AddItem(fShowSourcePackagesItem); -// -// menuBar->AddItem(menu); + menu = new BMenu(B_TRANSLATE("Options")); + + fShowAvailablePackagesItem = new BMenuItem( + B_TRANSLATE("Show available packages"), + new BMessage(MSG_SHOW_AVAILABLE_PACKAGES)); + menu->AddItem(fShowAvailablePackagesItem); + + fShowInstalledPackagesItem = new BMenuItem( + B_TRANSLATE("Show installed packages"), + new BMessage(MSG_SHOW_INSTALLED_PACKAGES)); + menu->AddItem(fShowInstalledPackagesItem); + + menu->AddSeparatorItem(); + + fShowDevelopPackagesItem = new BMenuItem( + B_TRANSLATE("Show develop packages"), + new BMessage(MSG_SHOW_DEVELOP_PACKAGES)); + menu->AddItem(fShowDevelopPackagesItem); + + fShowSourcePackagesItem = new BMenuItem( + B_TRANSLATE("Show source packages"), + new BMessage(MSG_SHOW_SOURCE_PACKAGES)); + menu->AddItem(fShowSourcePackagesItem); + + menuBar->AddItem(menu); } @@ -546,9 +550,10 @@ MainWindow::_AdoptModel() } BAutolock locker(fModel.Lock()); -// fShowSourcePackagesItem->SetMarked(fModel.ShowSourcePackages()); -// fShowDevelopPackagesItem->SetMarked(fModel.ShowDevelopPackages()); - fFilterView->AdoptCheckmarks(fModel); + fShowAvailablePackagesItem->SetMarked(fModel.ShowAvailablePackages()); + fShowInstalledPackagesItem->SetMarked(fModel.ShowInstalledPackages()); + fShowSourcePackagesItem->SetMarked(fModel.ShowSourcePackages()); + fShowDevelopPackagesItem->SetMarked(fModel.ShowDevelopPackages()); }