From 8944545a3f86d4e2cb3e01b3758d18522fcf8372 Mon Sep 17 00:00:00 2001
From: Owen <owenca@users.noreply.github.com>
Date: Sat, 29 Apr 2017 19:45:53 +0000
Subject: [PATCH 4/4] BFilePanel: Add setter AlwaysEnableDefaultButton().
The default button (e.g., Save/Open) is enabled/disabled by Tracker
depending on whether or not any items are selected. With this new
setter, the default button can be kept enabled even if no items are
selected.
Fixes #13463.
---
headers/os/storage/FilePanel.h | 2 ++
src/kits/tracker/FilePanel.cpp | 11 +++++++++++
src/kits/tracker/FilePanelPriv.cpp | 16 ++++++++++++++--
src/kits/tracker/FilePanelPriv.h | 3 +++
4 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/headers/os/storage/FilePanel.h b/headers/os/storage/FilePanel.h
index ded44de..4e39186 100644
a
|
b
|
class BFilePanel {
|
82 | 82 | void Rewind(); |
83 | 83 | status_t GetNextSelectedRef(entry_ref* ref); |
84 | 84 | |
| 85 | void AlwaysEnableDefaultButton(); |
| 86 | |
85 | 87 | private: |
86 | 88 | virtual void _ReservedFilePanel1(); |
87 | 89 | virtual void _ReservedFilePanel2(); |
diff --git a/src/kits/tracker/FilePanel.cpp b/src/kits/tracker/FilePanel.cpp
index 539b7ea..466a3eb 100644
a
|
b
|
BFilePanel::SelectionChanged()
|
386 | 386 | { |
387 | 387 | // hook function |
388 | 388 | } |
| 389 | |
| 390 | |
| 391 | void |
| 392 | BFilePanel::AlwaysEnableDefaultButton() |
| 393 | { |
| 394 | AutoLock<BWindow> lock(fWindow); |
| 395 | if (!lock) |
| 396 | return; |
| 397 | |
| 398 | static_cast<TFilePanel*>(fWindow)->AlwaysEnableDefaultButton(); |
| 399 | } |
diff --git a/src/kits/tracker/FilePanelPriv.cpp b/src/kits/tracker/FilePanelPriv.cpp
index 7a367e3..9ac07c9 100644
a
|
b
|
TFilePanel::TFilePanel(file_panel_mode mode, BMessenger* target,
|
167 | 167 | fSelectionIterator(0), |
168 | 168 | fMessage(NULL), |
169 | 169 | fHideWhenDone(hideWhenDone), |
170 | | fIsTrackingMenu(false) |
| 170 | fIsTrackingMenu(false), |
| 171 | fAlwaysEnableDefaultButton(false) |
171 | 172 | { |
172 | 173 | InitIconPreloader(); |
173 | 174 | |
… |
… |
TFilePanel::SetClientObject(BFilePanel* panel)
|
553 | 554 | |
554 | 555 | |
555 | 556 | void |
| 557 | TFilePanel::AlwaysEnableDefaultButton() |
| 558 | { |
| 559 | fAlwaysEnableDefaultButton = true; |
| 560 | |
| 561 | BButton* button = dynamic_cast<BButton*>(FindView("default button")); |
| 562 | if (button != NULL) |
| 563 | button->SetEnabled(true); |
| 564 | } |
| 565 | |
| 566 | |
| 567 | void |
556 | 568 | TFilePanel::AdjustButton() |
557 | 569 | { |
558 | 570 | // adjust button state |
… |
… |
TFilePanel::AdjustButton()
|
613 | 625 | } |
614 | 626 | |
615 | 627 | button->SetLabel(buttonText.String()); |
616 | | button->SetEnabled(enabled); |
| 628 | button->SetEnabled(fAlwaysEnableDefaultButton || enabled); |
617 | 629 | } |
618 | 630 | |
619 | 631 | |
diff --git a/src/kits/tracker/FilePanelPriv.h b/src/kits/tracker/FilePanelPriv.h
index 22acfd7..99b9150 100644
a
|
b
|
public:
|
102 | 102 | |
103 | 103 | bool TrackingMenu() const; |
104 | 104 | |
| 105 | void AlwaysEnableDefaultButton(); |
| 106 | |
105 | 107 | protected: |
106 | 108 | BPoseView* NewPoseView(Model* model, uint32); |
107 | 109 | virtual void Init(const BMessage* message = NULL); |
… |
… |
private:
|
151 | 153 | BString fButtonText; |
152 | 154 | bool fHideWhenDone; |
153 | 155 | bool fIsTrackingMenu; |
| 156 | bool fAlwaysEnableDefaultButton; |
154 | 157 | |
155 | 158 | typedef BContainerWindow _inherited; |
156 | 159 | }; |