Ticket #13860: 0001-Changes-to-HaikuDepot-GUI.patch

File 0001-Changes-to-HaikuDepot-GUI.patch, 9.2 KB (added by humdinger, 7 years ago)

Patch for the changes (comment:6)

  • src/apps/haikudepot/ui/FilterView.cpp

    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  
    99#include <stdio.h>
    1010
    1111#include <Catalog.h>
     12#include <CheckBox.h>
    1213#include <LayoutBuilder.h>
    1314#include <MenuField.h>
    1415#include <MenuItem.h>
    FilterView::FilterView()  
    4142    :
    4243    BGroupView("filter view", B_VERTICAL)
    4344{
    44     // Contruct category popup
     45    // Construct category popup
    4546    BPopUpMenu* showMenu = new BPopUpMenu(B_TRANSLATE("Category"));
    4647    fShowField = new BMenuField("category", B_TRANSLATE("Category:"), showMenu);
    4748
    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));
    5252
    5353    // Construct search terms field
    5454    fSearchTermsText = new BTextControl("search terms",
    FilterView::FilterView()  
    7171        .AddGroup(B_HORIZONTAL)
    7272            .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1.2f)
    7373                .Add(fShowField, 0.0f)
    74                 .Add(fRepositoryField, 0.0f)
     74                .Add(fShowFeaturedPackages, 0.0f)
    7575                .SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET))
    7676            .End()
    7777            .AddGlue(0.5f)
    void  
    9292FilterView::AttachedToWindow()
    9393{
    9494    fShowField->Menu()->SetTargetForItems(Window());
    95     fRepositoryField->Menu()->SetTargetForItems(Window());
     95    fShowFeaturedPackages->SetTarget(Window());
    9696    fSearchTermsText->SetTarget(this);
    9797
    9898    fSearchTermsText->MakeFocus();
    FilterView::MessageReceived(BMessage* message)  
    121121void
    122122FilterView::AdoptModel(const Model& model)
    123123{
    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());
    150125
    151126    // Adopt categories
    152127    BMenu* showMenu = fShowField->Menu();
  • src/apps/haikudepot/ui/FilterView.h

    diff --git a/src/apps/haikudepot/ui/FilterView.h b/src/apps/haikudepot/ui/FilterView.h
    index 4e444d6b4a..b290e8135c 100644
    a b  
    88#include <GroupView.h>
    99
    1010
     11class BCheckBox;
    1112class BMenuField;
    1213class BTextControl;
    1314class Model;
    enum {  
    1718    MSG_CATEGORY_SELECTED       = 'ctsl',
    1819    MSG_DEPOT_SELECTED          = 'dpsl',
    1920    MSG_SEARCH_TERMS_MODIFIED   = 'stmd',
     21    MSG_SHOW_FEATURED_PACKAGES  = 'sofp',
    2022};
    2123
    2224
    public:  
    3234
    3335private:
    3436            BMenuField*         fShowField;
    35             BMenuField*         fRepositoryField;
     37            BCheckBox*          fShowFeaturedPackages;
    3638            BTextControl*       fSearchTermsText;
    3739};
    3840
  • src/apps/haikudepot/ui/MainWindow.cpp

    diff --git a/src/apps/haikudepot/ui/MainWindow.cpp b/src/apps/haikudepot/ui/MainWindow.cpp
    index f094cb9a22..dfda12b481 100644
    a b enum {  
    7474    MSG_AUTHORIZATION_CHANGED   = 'athc',
    7575    MSG_PACKAGE_CHANGED         = 'pchd',
    7676
    77     MSG_SHOW_FEATURED_PACKAGES  = 'sofp',
    7877    MSG_SHOW_AVAILABLE_PACKAGES = 'savl',
    7978    MSG_SHOW_INSTALLED_PACKAGES = 'sins',
    8079    MSG_SHOW_SOURCE_PACKAGES    = 'ssrc',
    MainWindow::MainWindow(const BMessage& settings)  
    152151
    153152    fSplitView = new BSplitView(B_VERTICAL, 5.0f);
    154153
    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 
    168154    fWorkStatusView = new WorkStatusView("work status");
    169155    fPackageListView->AttachWorkStatusView(fWorkStatusView);
    170156
    171157    BView* listArea = new BView("list area", 0);
    172158    fListLayout = new BCardLayout();
    173159    listArea->SetLayout(fListLayout);
    174     listArea->AddChild(featuredPackagesGroup);
     160    listArea->AddChild(fFeaturedPackagesView);
    175161    listArea->AddChild(fPackageListView);
    176162
    177163    BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f)
    MainWindow::MessageReceived(BMessage* message)  
    319305        {
    320306            fModelWorker = B_BAD_THREAD_ID;
    321307            _AdoptModel();
    322             fFilterView->AdoptModel(fModel);
     308            _UpdateAvailableRepositories();
    323309            fWorkStatusView->SetIdle();
    324310            break;
    325311        }
    MainWindow::MessageReceived(BMessage* message)  
    445431                fModel.SetDepot(name);
    446432            }
    447433            _AdoptModel();
     434            _UpdateAvailableRepositories();
    448435            break;
    449436        }
    450437
    MainWindow::_BuildMenu(BMenuBar* menuBar)  
    678665
    679666    menuBar->AddItem(menu);
    680667
    681     menu = new BMenu(B_TRANSLATE("Show"));
     668    fRepositoryMenu = new BMenu(B_TRANSLATE("Repositories"));
     669    menuBar->AddItem(fRepositoryMenu);
    682670
    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"));
    689672
    690673    fShowAvailablePackagesItem = new BMenuItem(
    691674        B_TRANSLATE("Available packages"),
    MainWindow::_AdoptModel()  
    835818    release_sem(fNewPackagesToShowSem);
    836819
    837820    BAutolock locker(fModel.Lock());
    838     fShowFeaturedPackagesItem->SetMarked(fModel.ShowFeaturedPackages());
    839     fShowFeaturedPackagesItem->SetEnabled(fModel.SearchTerms() == "");
    840821    fShowAvailablePackagesItem->SetMarked(fModel.ShowAvailablePackages());
    841822    fShowInstalledPackagesItem->SetMarked(fModel.ShowInstalledPackages());
    842823    fShowSourcePackagesItem->SetMarked(fModel.ShowSourcePackages());
    843824    fShowDevelopPackagesItem->SetMarked(fModel.ShowDevelopPackages());
    844825
    845     if (fModel.ShowFeaturedPackages() && fModel.SearchTerms() == "")
     826    if (fModel.ShowFeaturedPackages())
    846827        fListLayout->SetVisibleItem((int32)0);
    847828    else
    848829        fListLayout->SetVisibleItem((int32)1);
     830
     831    fFilterView->AdoptModel(fModel);
    849832}
    850833
    851834
    MainWindow::_UpdateAuthorization()  
    14061389}
    14071390
    14081391
     1392void
     1393MainWindow::_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
    14091422void
    14101423MainWindow::_RatePackage()
    14111424{
  • src/apps/haikudepot/ui/MainWindow.h

    diff --git a/src/apps/haikudepot/ui/MainWindow.h b/src/apps/haikudepot/ui/MainWindow.h
    index 6f7d95c18a..5a13228d67 100644
    a b private:  
    9292            void                _OpenLoginWindow(
    9393                                    const BMessage& onSuccessMessage);
    9494            void                _UpdateAuthorization();
     95            void                _UpdateAvailableRepositories();
    9596            void                _RatePackage();
    9697            void                _ShowScreenshot();
    9798
    private:  
    107108            ScreenshotWindow*   fScreenshotWindow;
    108109
    109110            BMenu*              fUserMenu;
     111            BMenu*              fRepositoryMenu;
    110112            BMenuItem*          fLogInItem;
    111113            BMenuItem*          fLogOutItem;
    112114
    113             BMenuItem*          fShowFeaturedPackagesItem;
    114115            BMenuItem*          fShowAvailablePackagesItem;
    115116            BMenuItem*          fShowInstalledPackagesItem;
    116117            BMenuItem*          fShowDevelopPackagesItem;