Ticket #3746: 0001-Backgrounds-3746-Can-t-reset-default-background-colo.patch

File 0001-Backgrounds-3746-Can-t-reset-default-background-colo.patch, 3.2 KB (added by valzant, 4 years ago)
  • src/preferences/backgrounds/BackgroundsView.cpp

    From e2a88e671d5726c2525c108d50c2064ea4dd35c2 Mon Sep 17 00:00:00 2001
    From: Valzant <qisoster@gmail.com>
    Date: Thu, 5 Jan 2017 01:07:09 +0000
    Subject: [PATCH] Backgrounds: #3746 Can't reset default background colour in
     Screen Preferences
    
    * Added 'Defaults' button, before 'Revert' button, similar in layout to 'Appearance'.
    * When clicked, it sets the color picker to RGB = (51, 102, 152 ), the default color.
    ---
     src/preferences/backgrounds/BackgroundsView.cpp | 21 +++++++++++++++++++++
     src/preferences/backgrounds/BackgroundsView.h   |  1 +
     2 files changed, 22 insertions(+)
    
    diff --git a/src/preferences/backgrounds/BackgroundsView.cpp b/src/preferences/backgrounds/BackgroundsView.cpp
    index 71853c8..c5fc04a 100644
    a b  
    4242
    4343
    4444static const uint32 kMsgApplySettings = 'aply';
     45static const uint32 kMsgDefaultSettings = 'dflt';
    4546static const uint32 kMsgRevertSettings = 'rvrt';
    4647
    4748static const uint32 kMsgUpdateColor = 'upcl';
    BackgroundsView::BackgroundsView()  
    212213        .SetInsets(B_USE_DEFAULT_SPACING)
    213214        .View());
    214215
     216    fDefaults = new BButton(B_TRANSLATE("Defaults"),
     217        new BMessage(kMsgDefaultSettings));
    215218    fRevert = new BButton(B_TRANSLATE("Revert"),
    216219        new BMessage(kMsgRevertSettings));
    217220    fApply = new BButton(B_TRANSLATE("Apply"),
    218221        new BMessage(kMsgApplySettings));
    219222
     223    fDefaults->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
     224        B_ALIGN_NO_VERTICAL));
    220225    fRevert->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
    221226        B_ALIGN_NO_VERTICAL));
    222227    fApply->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT,
    BackgroundsView::BackgroundsView()  
    234239            .Add(rightbox)
    235240            .End()
    236241        .AddGroup(B_HORIZONTAL, 0)
     242            .Add(fDefaults)
    237243            .Add(fRevert)
     244            .AddGlue()
    238245            .Add(fApply)
    239246            .SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0)
    240247            .End();
    BackgroundsView::AllAttached()  
    262269    fIconLabelOutline->SetTarget(this);
    263270    fPicker->SetTarget(this);
    264271    fApply->SetTarget(this);
     272    fDefaults->SetTarget(this);
    265273    fRevert->SetTarget(this);
    266274
    267275    BPath path;
    BackgroundsView::AllAttached()  
    290298    }
    291299
    292300    fApply->SetEnabled(false);
     301    fDefaults->SetEnabled(false);
    293302    fRevert->SetEnabled(false);
    294303}
    295304
    BackgroundsView::MessageReceived(BMessage* message)  
    423432            _UpdateButtons();
    424433            break;
    425434        }
     435
     436        case kMsgDefaultSettings:
     437        {
     438            rgb_color color = {51, 102, 152, 255};
     439            fPicker->SetValue(color);
     440
     441            _UpdatePreview();
     442            _UpdateButtons();
     443            break;
     444        }
     445
    426446        case kMsgRevertSettings:
    427447            _UpdateWithCurrent();
    428448            break;
    BackgroundsView::_UpdateButtons()  
    964984    }
    965985
    966986    fApply->SetEnabled(hasChanged);
     987    fDefaults->SetEnabled(hasChanged);
    967988    fRevert->SetEnabled(hasChanged);
    968989}
    969990
  • src/preferences/backgrounds/BackgroundsView.h

    diff --git a/src/preferences/backgrounds/BackgroundsView.h b/src/preferences/backgrounds/BackgroundsView.h
    index eece562..b2120ef 100644
    a b protected:  
    141141
    142142            BColorControl*      fPicker;
    143143            BButton*            fApply;
     144            BButton*            fDefaults;
    144145            BButton*            fRevert;
    145146            BCheckBox*          fIconLabelOutline;
    146147            BMenu*              fPlacementMenu;