From 075d3e60f4e6fd3882b113f8fa19cd6f5c88e40d Mon Sep 17 00:00:00 2001 From: John Scipione Date: Mon, 14 Jan 2013 14:24:42 -0500 Subject: [PATCH] Update Deskbar preferences to use tabs instead of listview --- src/apps/deskbar/PreferencesWindow.cpp | 106 +++---------------------- src/apps/deskbar/PreferencesWindow.h | 5 -- 2 files changed, 12 insertions(+), 99 deletions(-) diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp index eb4fcf6ff9..ac00768d74 100644 --- a/src/apps/deskbar/PreferencesWindow.cpp +++ b/src/apps/deskbar/PreferencesWindow.cpp @@ -12,7 +12,6 @@ #include -#include #include #include #include @@ -25,10 +24,9 @@ #include #include #include -#include #include #include -#include +#include #include #include @@ -36,29 +34,6 @@ #include "StatusView.h" -namespace BPrivate { - -class SettingsItem : public BStringItem { - public: - SettingsItem(const char* label, BView* view) - : - BStringItem(label), - fSettingsView(view) - { - } - - BView* View() - { - return fSettingsView; - } - - private: - BView* fSettingsView; -}; - -} // namespace BPrivate - - static const float kIndentSpacing = be_control_look->DefaultItemSpacing() * 2.3; static const uint32 kSettingsViewChanged = 'Svch'; @@ -73,15 +48,6 @@ PreferencesWindow::PreferencesWindow(BRect frame) BWindow(frame, B_TRANSLATE("Deskbar preferences"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE) { - // Main view controls - fSettingsTypeListView = new BListView("List View", - B_SINGLE_SELECTION_LIST); - - BScrollView* scrollView = new BScrollView("scrollview", - fSettingsTypeListView, 0, false, true); - - fSettingsContainerBox = new BBox("SettingsContainerBox"); - // Menu controls fMenuRecentDocuments = new BCheckBox(B_TRANSLATE("Recent documents:"), new BMessage(kUpdateRecentCounts)); @@ -223,6 +189,7 @@ PreferencesWindow::PreferencesWindow(BRect frame) B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) .End() .View(); + menuSettingsView->SetName(B_TRANSLATE("Menu")); BView* applicationsSettingsView = BLayoutBuilder::Group<>() .AddGroup(B_VERTICAL, 0) @@ -243,6 +210,7 @@ PreferencesWindow::PreferencesWindow(BRect frame) B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) .End() .View(); + applicationsSettingsView->SetName(B_TRANSLATE("Applications")); BView* windowSettingsView = BLayoutBuilder::Group<>() .AddGroup(B_VERTICAL, 0) @@ -254,33 +222,19 @@ PreferencesWindow::PreferencesWindow(BRect frame) B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) .End() .View(); + windowSettingsView->SetName(B_TRANSLATE("Window")); + + BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL); + tabView->AddTab(menuSettingsView); + tabView->AddTab(applicationsSettingsView); + tabView->AddTab(windowSettingsView); BLayoutBuilder::Group<>(this) - .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) - .Add(scrollView) - .Add(fSettingsContainerBox) - .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, - B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) + .Add(tabView) + .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) .End(); - fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Menu"), - menuSettingsView)); - fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Applications"), - applicationsSettingsView)); - fSettingsTypeListView->AddItem(new SettingsItem(B_TRANSLATE("Window"), - windowSettingsView)); - - // constraint the listview width so that the longest item fits - float width = 0; - fSettingsTypeListView->GetPreferredSize(&width, NULL); - width += B_V_SCROLL_BAR_WIDTH; - fSettingsTypeListView->SetExplicitMinSize(BSize(width, 0)); - fSettingsTypeListView->SetExplicitMaxSize(BSize(width, B_SIZE_UNLIMITED)); - - fSettingsTypeListView->SetSelectionMessage( - new BMessage(kSettingsViewChanged)); - fSettingsTypeListView->Select(0); - CenterOnScreen(); } @@ -312,10 +266,6 @@ PreferencesWindow::MessageReceived(BMessage* message) EnableDisableDependentItems(); break; - case kSettingsViewChanged: - _HandleChangedSettingsView(); - break; - default: BWindow::MessageReceived(message); break; @@ -388,35 +338,3 @@ PreferencesWindow::EnableDisableDependentItems() fWindowAutoRaise->SetEnabled( fWindowAlwaysOnTop->Value() == B_CONTROL_OFF); } - - -// #pragma mark - - - -void -PreferencesWindow::_HandleChangedSettingsView() -{ - int32 currentSelection = fSettingsTypeListView->CurrentSelection(); - if (currentSelection < 0) - return; - - BView* oldView = fSettingsContainerBox->ChildAt(0); - - if (oldView != NULL) - oldView->RemoveSelf(); - - SettingsItem* selectedItem = - dynamic_cast - (fSettingsTypeListView->ItemAt(currentSelection)); - - if (selectedItem != NULL) { - fSettingsContainerBox->SetLabel(selectedItem->Text()); - - BView* view = selectedItem->View(); - view->SetViewColor(fSettingsContainerBox->ViewColor()); - view->Hide(); - fSettingsContainerBox->AddChild(view); - - view->Show(); - } -} diff --git a/src/apps/deskbar/PreferencesWindow.h b/src/apps/deskbar/PreferencesWindow.h index 6d07e58eb5..026bc73c4e 100644 --- a/src/apps/deskbar/PreferencesWindow.h +++ b/src/apps/deskbar/PreferencesWindow.h @@ -45,11 +45,6 @@ public: void EnableDisableDependentItems(); private: - void _HandleChangedSettingsView(); - - BListView* fSettingsTypeListView; - BBox* fSettingsContainerBox; - BCheckBox* fMenuRecentDocuments; BCheckBox* fMenuRecentApplications; BCheckBox* fMenuRecentFolders;