6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
36 #include "SettingsViews.h"
42 #include <ColorControl.h>
43 #include <ControlLook.h>
44 #include <LayoutBuilder.h>
46 #include <MenuField.h>
47 #include <NodeMonitor.h>
49 #include <RadioButton.h>
50 #include <StringView.h>
53 #include "DeskWindow.h"
56 #include "WidgetAttributeText.h"
59 static const uint32 kSpaceBarSwitchColor
= 'SBsc';
61 //TODO: defaults should be set in one place only (TrackerSettings.cpp) while
62 // being accessible from here.
63 // What about adding DefaultValue(), IsDefault() etc... methods to
65 static const uint8 kSpaceBarAlpha
= 192;
66 static const rgb_color kDefaultUsedSpaceColor
= { 0, 203, 0, kSpaceBarAlpha
};
67 static const rgb_color kDefaultFreeSpaceColor
68 = { 255, 255, 255, kSpaceBarAlpha
};
69 static const rgb_color kDefaultWarningSpaceColor
70 = { 203, 0, 0, kSpaceBarAlpha
};
74 send_bool_notices(uint32 what
, const char* name
, bool value
)
76 TTracker
* tracker
= dynamic_cast<TTracker
*>(be_app
);
81 message
.AddBool(name
, value
);
82 tracker
->SendNotices(what
, &message
);
86 #undef B_TRANSLATION_CONTEXT
87 #define B_TRANSLATION_CONTEXT "SettingsView"
90 // #pragma mark - SettingsView
93 SettingsView::SettingsView(const char* name
)
100 SettingsView::~SettingsView()
106 The inherited functions should set the default values
107 and update the UI gadgets. The latter can by done by
108 calling ShowCurrentSettings().
111 SettingsView::SetDefaults()
117 This function is used by the window to tell whether
118 it can ghost the defaults button or not. It doesn't
119 shows the default settings, this function should
123 SettingsView::IsDefaultable() const
130 The inherited functions should set the values that was
131 active when the settings window opened. It should also
132 update the UI widgets accordingly, preferrable by calling
133 ShowCurrentSettings().
136 SettingsView::Revert()
142 This function is called when the window is shown to let
143 the settings views record the state to revert to.
146 SettingsView::RecordRevertSettings()
152 This function is used by the window to tell the view
153 to display the current settings in the tracker.
156 SettingsView::ShowCurrentSettings()
162 This function is used by the window to tell whether
163 it can ghost the revert button or not. It it shows the
164 reverted settings, this function should return true.
167 SettingsView::IsRevertable() const
173 // #pragma mark - DesktopSettingsView
176 DesktopSettingsView::DesktopSettingsView()
178 SettingsView("DesktopSettingsView"),
179 fShowDisksIconRadioButton(NULL
),
180 fMountVolumesOntoDesktopRadioButton(NULL
),
181 fMountSharedVolumesOntoDesktopCheckBox(NULL
),
182 fShowDisksIcon(false),
183 fMountVolumesOntoDesktop(false),
184 fMountSharedVolumesOntoDesktop(false),
185 fIntegrateNonBootBeOSDesktops(false),
186 fEjectWhenUnmounting(false)
188 fShowDisksIconRadioButton
= new BRadioButton("",
189 B_TRANSLATE("Show Disks icon"),
190 new BMessage(kShowDisksIconChanged
));
192 fMountVolumesOntoDesktopRadioButton
= new BRadioButton("",
193 B_TRANSLATE("Show volumes on Desktop"),
194 new BMessage(kVolumesOnDesktopChanged
));
196 fMountSharedVolumesOntoDesktopCheckBox
= new BCheckBox("",
197 B_TRANSLATE("Show shared volumes on Desktop"),
198 new BMessage(kVolumesOnDesktopChanged
));
200 const float spacing
= be_control_look
->DefaultItemSpacing();
202 BLayoutBuilder::Group
<>(this, B_VERTICAL
, 0)
203 .Add(fShowDisksIconRadioButton
)
204 .Add(fMountVolumesOntoDesktopRadioButton
)
205 .AddGroup(B_VERTICAL
, 0)
206 .Add(fMountSharedVolumesOntoDesktopCheckBox
)
207 .SetInsets(spacing
* 2, 0, 0, 0)
215 DesktopSettingsView::AttachedToWindow()
217 fShowDisksIconRadioButton
->SetTarget(this);
218 fMountVolumesOntoDesktopRadioButton
->SetTarget(this);
219 fMountSharedVolumesOntoDesktopCheckBox
->SetTarget(this);
224 DesktopSettingsView::MessageReceived(BMessage
* message
)
226 TTracker
* tracker
= dynamic_cast<TTracker
*>(be_app
);
230 TrackerSettings settings
;
232 switch (message
->what
) {
233 case kShowDisksIconChanged
:
235 // Turn on and off related settings:
236 fMountVolumesOntoDesktopRadioButton
->SetValue(
237 !(fShowDisksIconRadioButton
->Value() == 1));
238 fMountSharedVolumesOntoDesktopCheckBox
->SetEnabled(
239 fMountVolumesOntoDesktopRadioButton
->Value() == 1);
241 // Set the new settings in the tracker:
242 settings
.SetShowDisksIcon(fShowDisksIconRadioButton
->Value() == 1);
243 settings
.SetMountVolumesOntoDesktop(
244 fMountVolumesOntoDesktopRadioButton
->Value() == 1);
245 settings
.SetMountSharedVolumesOntoDesktop(
246 fMountSharedVolumesOntoDesktopCheckBox
->Value() == 1);
248 // Construct the notification message:
249 BMessage notificationMessage
;
250 notificationMessage
.AddBool("ShowDisksIcon",
251 fShowDisksIconRadioButton
->Value() == 1);
252 notificationMessage
.AddBool("MountVolumesOntoDesktop",
253 fMountVolumesOntoDesktopRadioButton
->Value() == 1);
254 notificationMessage
.AddBool("MountSharedVolumesOntoDesktop",
255 fMountSharedVolumesOntoDesktopCheckBox
->Value() == 1);
257 // Send the notification message:
258 tracker
->SendNotices(kVolumesOnDesktopChanged
,
259 ¬ificationMessage
);
261 // Tell the settings window the contents have changed:
262 Window()->PostMessage(kSettingsContentsModified
);
266 case kVolumesOnDesktopChanged
:
268 // Turn on and off related settings:
269 fShowDisksIconRadioButton
->SetValue(
270 !(fMountVolumesOntoDesktopRadioButton
->Value() == 1));
271 fMountSharedVolumesOntoDesktopCheckBox
->SetEnabled(
272 fMountVolumesOntoDesktopRadioButton
->Value() == 1);
274 // Set the new settings in the tracker:
275 settings
.SetShowDisksIcon(fShowDisksIconRadioButton
->Value() == 1);
276 settings
.SetMountVolumesOntoDesktop(
277 fMountVolumesOntoDesktopRadioButton
->Value() == 1);
278 settings
.SetMountSharedVolumesOntoDesktop(
279 fMountSharedVolumesOntoDesktopCheckBox
->Value() == 1);
281 // Construct the notification message:
282 BMessage notificationMessage
;
283 notificationMessage
.AddBool("ShowDisksIcon",
284 fShowDisksIconRadioButton
->Value() == 1);
285 notificationMessage
.AddBool("MountVolumesOntoDesktop",
286 fMountVolumesOntoDesktopRadioButton
->Value() == 1);
287 notificationMessage
.AddBool("MountSharedVolumesOntoDesktop",
288 fMountSharedVolumesOntoDesktopCheckBox
->Value() == 1);
290 // Send the notification message:
291 tracker
->SendNotices(kVolumesOnDesktopChanged
,\
292 ¬ificationMessage
);
294 // Tell the settings window the contents have changed:
295 Window()->PostMessage(kSettingsContentsModified
);
300 _inherited::MessageReceived(message
);
307 DesktopSettingsView::SetDefaults()
309 // ToDo: Avoid the duplication of the default values.
310 TrackerSettings settings
;
312 settings
.SetShowDisksIcon(false);
313 settings
.SetMountVolumesOntoDesktop(true);
314 settings
.SetMountSharedVolumesOntoDesktop(true);
315 settings
.SetEjectWhenUnmounting(true);
317 ShowCurrentSettings();
323 DesktopSettingsView::IsDefaultable() const
325 TrackerSettings settings
;
327 return settings
.ShowDisksIcon() != false
328 || settings
.MountVolumesOntoDesktop() != true
329 || settings
.MountSharedVolumesOntoDesktop() != true
330 || settings
.EjectWhenUnmounting() != true;
335 DesktopSettingsView::Revert()
337 TrackerSettings settings
;
339 settings
.SetShowDisksIcon(fShowDisksIcon
);
340 settings
.SetMountVolumesOntoDesktop(fMountVolumesOntoDesktop
);
341 settings
.SetMountSharedVolumesOntoDesktop(fMountSharedVolumesOntoDesktop
);
342 settings
.SetEjectWhenUnmounting(fEjectWhenUnmounting
);
344 ShowCurrentSettings();
350 DesktopSettingsView::_SendNotices()
352 TTracker
* tracker
= dynamic_cast<TTracker
*>(be_app
);
356 // Construct the notification message:
357 BMessage notificationMessage
;
358 notificationMessage
.AddBool("ShowDisksIcon",
359 fShowDisksIconRadioButton
->Value() == 1);
360 notificationMessage
.AddBool("MountVolumesOntoDesktop",
361 fMountVolumesOntoDesktopRadioButton
->Value() == 1);
362 notificationMessage
.AddBool("MountSharedVolumesOntoDesktop",
363 fMountSharedVolumesOntoDesktopCheckBox
->Value() == 1);
365 // Send notices to the tracker about the change:
366 tracker
->SendNotices(kVolumesOnDesktopChanged
, ¬ificationMessage
);
367 tracker
->SendNotices(kDesktopIntegrationChanged
, ¬ificationMessage
);
372 DesktopSettingsView::ShowCurrentSettings()
374 TrackerSettings settings
;
376 fShowDisksIconRadioButton
->SetValue(settings
.ShowDisksIcon());
377 fMountVolumesOntoDesktopRadioButton
->SetValue(
378 settings
.MountVolumesOntoDesktop());
380 fMountSharedVolumesOntoDesktopCheckBox
->SetValue(
381 settings
.MountSharedVolumesOntoDesktop());
382 fMountSharedVolumesOntoDesktopCheckBox
->SetEnabled(
383 settings
.MountVolumesOntoDesktop());
388 DesktopSettingsView::RecordRevertSettings()
390 TrackerSettings settings
;
392 fShowDisksIcon
= settings
.ShowDisksIcon();
393 fMountVolumesOntoDesktop
= settings
.MountVolumesOntoDesktop();
394 fMountSharedVolumesOntoDesktop
= settings
.MountSharedVolumesOntoDesktop();
395 fEjectWhenUnmounting
= settings
.EjectWhenUnmounting();
400 DesktopSettingsView::IsRevertable() const
402 return fShowDisksIcon
!= (fShowDisksIconRadioButton
->Value() > 0)
403 || fMountVolumesOntoDesktop
!=
404 (fMountVolumesOntoDesktopRadioButton
->Value() > 0)
405 || fMountSharedVolumesOntoDesktop
!=
406 (fMountSharedVolumesOntoDesktopCheckBox
->Value() > 0);
410 // #pragma mark - WindowsSettingsView
413 WindowsSettingsView::WindowsSettingsView()
415 SettingsView("WindowsSettingsView"),
416 fShowFullPathInTitleBarCheckBox(NULL
),
417 fSingleWindowBrowseCheckBox(NULL
),
418 fShowNavigatorCheckBox(NULL
),
419 fOutlineSelectionCheckBox(NULL
),
420 fSortFolderNamesFirstCheckBox(NULL
),
421 fHideDotFilesCheckBox(NULL
),
422 fTypeAheadFilteringCheckBox(NULL
),
423 fShowFullPathInTitleBar(false),
424 fSingleWindowBrowse(false),
425 fShowNavigator(false),
426 fTransparentSelection(false),
427 fSortFolderNamesFirst(false),
428 fHideDotFiles(false),
429 fTypeAheadFiltering(false)
431 fShowFullPathInTitleBarCheckBox
= new BCheckBox("",
432 B_TRANSLATE("Show folder location in title tab"),
433 new BMessage(kWindowsShowFullPathChanged
));
435 fSingleWindowBrowseCheckBox
= new BCheckBox("",
436 B_TRANSLATE("Single window navigation"),
437 new BMessage(kSingleWindowBrowseChanged
));
439 fShowNavigatorCheckBox
= new BCheckBox("",
440 B_TRANSLATE("Show navigator"),
441 new BMessage(kShowNavigatorChanged
));
443 fOutlineSelectionCheckBox
= new BCheckBox("",
444 B_TRANSLATE("Outline selection rectangle only"),
445 new BMessage(kTransparentSelectionChanged
));
447 fSortFolderNamesFirstCheckBox
= new BCheckBox("",
448 B_TRANSLATE("List folders first"),
449 new BMessage(kSortFolderNamesFirstChanged
));
451 fHideDotFilesCheckBox
= new BCheckBox("",
452 B_TRANSLATE("Hide dotfiles"),
453 new BMessage(kHideDotFilesChanged
));
455 fTypeAheadFilteringCheckBox
= new BCheckBox("",
456 B_TRANSLATE("Enable type-ahead filtering"),
457 new BMessage(kTypeAheadFilteringChanged
));
459 const float spacing
= be_control_look
->DefaultItemSpacing();
461 BLayoutBuilder::Group
<>(this, B_VERTICAL
, 0)
462 .AddGroup(B_VERTICAL
, 0)
463 .Add(fShowFullPathInTitleBarCheckBox
)
464 .Add(fSingleWindowBrowseCheckBox
)
466 .AddGroup(B_VERTICAL
)
467 .Add(fShowNavigatorCheckBox
)
468 .SetInsets(spacing
* 2, 0, 0, 0)
470 .AddGroup(B_VERTICAL
, 0)
471 .Add(fOutlineSelectionCheckBox
)
472 .Add(fSortFolderNamesFirstCheckBox
)
473 .Add(fHideDotFilesCheckBox
)
474 .Add(fTypeAheadFilteringCheckBox
)
482 WindowsSettingsView::AttachedToWindow()
484 fSingleWindowBrowseCheckBox
->SetTarget(this);
485 fShowNavigatorCheckBox
->SetTarget(this);
486 fShowFullPathInTitleBarCheckBox
->SetTarget(this);
487 fOutlineSelectionCheckBox
->SetTarget(this);
488 fSortFolderNamesFirstCheckBox
->SetTarget(this);
489 fHideDotFilesCheckBox
->SetTarget(this);
490 fTypeAheadFilteringCheckBox
->SetTarget(this);
495 WindowsSettingsView::MessageReceived(BMessage
* message
)
497 TTracker
* tracker
= dynamic_cast<TTracker
*>(be_app
);
501 TrackerSettings settings
;
503 switch (message
->what
) {
504 case kWindowsShowFullPathChanged
:
505 settings
.SetShowFullPathInTitleBar(
506 fShowFullPathInTitleBarCheckBox
->Value() == 1);
507 tracker
->SendNotices(kWindowsShowFullPathChanged
);
508 Window()->PostMessage(kSettingsContentsModified
);
511 case kSingleWindowBrowseChanged
:
512 settings
.SetSingleWindowBrowse(
513 fSingleWindowBrowseCheckBox
->Value() == 1);
514 if (fSingleWindowBrowseCheckBox
->Value() == 0) {
515 fShowNavigatorCheckBox
->SetEnabled(false);
516 settings
.SetShowNavigator(0);
518 fShowNavigatorCheckBox
->SetEnabled(true);
519 settings
.SetShowNavigator(
520 fShowNavigatorCheckBox
->Value() != 0);
522 tracker
->SendNotices(kShowNavigatorChanged
);
523 tracker
->SendNotices(kSingleWindowBrowseChanged
);
524 Window()->PostMessage(kSettingsContentsModified
);
527 case kShowNavigatorChanged
:
528 settings
.SetShowNavigator(fShowNavigatorCheckBox
->Value() == 1);
529 tracker
->SendNotices(kShowNavigatorChanged
);
530 Window()->PostMessage(kSettingsContentsModified
);
533 case kTransparentSelectionChanged
:
535 settings
.SetTransparentSelection(
536 fOutlineSelectionCheckBox
->Value() == B_CONTROL_OFF
);
538 // Make the notification message and send it to the tracker:
539 send_bool_notices(kTransparentSelectionChanged
,
540 "TransparentSelection", settings
.TransparentSelection());
542 Window()->PostMessage(kSettingsContentsModified
);
546 case kSortFolderNamesFirstChanged
:
548 settings
.SetSortFolderNamesFirst(
549 fSortFolderNamesFirstCheckBox
->Value() == 1);
551 // Make the notification message and send it to the tracker:
552 send_bool_notices(kSortFolderNamesFirstChanged
,
553 "SortFolderNamesFirst",
554 fSortFolderNamesFirstCheckBox
->Value() == 1);
556 Window()->PostMessage(kSettingsContentsModified
);
560 case kHideDotFilesChanged
:
562 settings
.SetHideDotFiles(
563 fHideDotFilesCheckBox
->Value() == 1);
565 // Make the notification message and send it to the tracker:
566 send_bool_notices(kHideDotFilesChanged
,
568 fHideDotFilesCheckBox
->Value() == 1);
570 Window()->PostMessage(kSettingsContentsModified
);
574 case kTypeAheadFilteringChanged
:
576 settings
.SetTypeAheadFiltering(
577 fTypeAheadFilteringCheckBox
->Value() == 1);
578 send_bool_notices(kTypeAheadFilteringChanged
,
579 "TypeAheadFiltering",
580 fTypeAheadFilteringCheckBox
->Value() == 1);
581 Window()->PostMessage(kSettingsContentsModified
);
586 _inherited::MessageReceived(message
);
593 WindowsSettingsView::SetDefaults()
595 TTracker
* tracker
= dynamic_cast<TTracker
*>(be_app
);
599 TrackerSettings settings
;
601 if (settings
.ShowFullPathInTitleBar()) {
602 settings
.SetShowFullPathInTitleBar(false);
603 tracker
->SendNotices(kWindowsShowFullPathChanged
);
606 if (settings
.SingleWindowBrowse()) {
607 settings
.SetSingleWindowBrowse(false);
608 tracker
->SendNotices(kSingleWindowBrowseChanged
);
611 if (settings
.ShowNavigator()) {
612 settings
.SetShowNavigator(false);
613 tracker
->SendNotices(kShowNavigatorChanged
);
616 if (!settings
.TransparentSelection()) {
617 settings
.SetTransparentSelection(true);
618 send_bool_notices(kTransparentSelectionChanged
,
619 "TransparentSelection", true);
622 if (!settings
.SortFolderNamesFirst()) {
623 settings
.SetSortFolderNamesFirst(true);
624 send_bool_notices(kSortFolderNamesFirstChanged
,
625 "SortFolderNamesFirst", true);
628 if (!settings
.HideDotFiles()) {
629 settings
.SetHideDotFiles(true);
630 send_bool_notices(kHideDotFilesChanged
,
631 "HideDotFiles", true);
634 if (settings
.TypeAheadFiltering()) {
635 settings
.SetTypeAheadFiltering(false);
636 send_bool_notices(kTypeAheadFilteringChanged
,
637 "TypeAheadFiltering", true);
640 ShowCurrentSettings();
645 WindowsSettingsView::IsDefaultable() const
647 TrackerSettings settings
;
649 return settings
.ShowFullPathInTitleBar() != false
650 || settings
.SingleWindowBrowse() != false
651 || settings
.ShowNavigator() != false
652 || settings
.TransparentSelection() != true
653 || settings
.SortFolderNamesFirst() != true
654 || settings
.TypeAheadFiltering() != false;
659 WindowsSettingsView::Revert()
661 TTracker
* tracker
= dynamic_cast<TTracker
*>(be_app
);
665 TrackerSettings settings
;
667 if (settings
.ShowFullPathInTitleBar() != fShowFullPathInTitleBar
) {
668 settings
.SetShowFullPathInTitleBar(fShowFullPathInTitleBar
);
669 tracker
->SendNotices(kWindowsShowFullPathChanged
);
672 if (settings
.SingleWindowBrowse() != fSingleWindowBrowse
) {
673 settings
.SetSingleWindowBrowse(fSingleWindowBrowse
);
674 tracker
->SendNotices(kSingleWindowBrowseChanged
);
677 if (settings
.ShowNavigator() != fShowNavigator
) {
678 settings
.SetShowNavigator(fShowNavigator
);
679 tracker
->SendNotices(kShowNavigatorChanged
);
682 if (settings
.TransparentSelection() != fTransparentSelection
) {
683 settings
.SetTransparentSelection(fTransparentSelection
);
684 send_bool_notices(kTransparentSelectionChanged
,
685 "TransparentSelection", fTransparentSelection
);
688 if (settings
.SortFolderNamesFirst() != fSortFolderNamesFirst
) {
689 settings
.SetSortFolderNamesFirst(fSortFolderNamesFirst
);
690 send_bool_notices(kSortFolderNamesFirstChanged
,
691 "SortFolderNamesFirst", fSortFolderNamesFirst
);
694 if (settings
.HideDotFiles() != fHideDotFiles
) {
695 settings
.SetSortFolderNamesFirst(fHideDotFiles
);
696 send_bool_notices(kHideDotFilesChanged
,
697 "HideDotFiles", fHideDotFiles
);
700 if (settings
.TypeAheadFiltering() != fTypeAheadFiltering
) {
701 settings
.SetTypeAheadFiltering(fTypeAheadFiltering
);
702 send_bool_notices(kTypeAheadFilteringChanged
,
703 "TypeAheadFiltering", fTypeAheadFiltering
);
706 ShowCurrentSettings();
711 WindowsSettingsView::ShowCurrentSettings()
713 TrackerSettings settings
;
715 fShowFullPathInTitleBarCheckBox
->SetValue(
716 settings
.ShowFullPathInTitleBar());
717 fSingleWindowBrowseCheckBox
->SetValue(settings
.SingleWindowBrowse());
718 fShowNavigatorCheckBox
->SetEnabled(settings
.SingleWindowBrowse());
719 fShowNavigatorCheckBox
->SetValue(settings
.ShowNavigator());
720 fOutlineSelectionCheckBox
->SetValue(settings
.TransparentSelection()
721 ? B_CONTROL_OFF
: B_CONTROL_ON
);
722 fSortFolderNamesFirstCheckBox
->SetValue(settings
.SortFolderNamesFirst());
723 fHideDotFilesCheckBox
->SetValue(settings
.HideDotFiles());
724 fTypeAheadFilteringCheckBox
->SetValue(settings
.TypeAheadFiltering());
729 WindowsSettingsView::RecordRevertSettings()
731 TrackerSettings settings
;
733 fShowFullPathInTitleBar
= settings
.ShowFullPathInTitleBar();
734 fSingleWindowBrowse
= settings
.SingleWindowBrowse();
735 fShowNavigator
= settings
.ShowNavigator();
736 fTransparentSelection
= settings
.TransparentSelection();
737 fSortFolderNamesFirst
= settings
.SortFolderNamesFirst();
738 fHideDotFiles
= settings
.HideDotFiles();
739 fTypeAheadFiltering
= settings
.TypeAheadFiltering();
744 WindowsSettingsView::IsRevertable() const
746 TrackerSettings settings
;
748 return fShowFullPathInTitleBar
!= settings
.ShowFullPathInTitleBar()
749 || fSingleWindowBrowse
!= settings
.SingleWindowBrowse()
750 || fShowNavigator
!= settings
.ShowNavigator()
751 || fTransparentSelection
!= settings
.TransparentSelection()
752 || fSortFolderNamesFirst
!= settings
.SortFolderNamesFirst()
753 || fHideDotFiles
!= settings
.HideDotFiles()
754 || fTypeAheadFiltering
!= settings
.TypeAheadFiltering();
758 // #pragma mark - SpaceBarSettingsView
761 SpaceBarSettingsView::SpaceBarSettingsView()
763 SettingsView("SpaceBarSettingsView")
765 fSpaceBarShowCheckBox
= new BCheckBox("",
766 B_TRANSLATE("Show space bars on volumes"),
767 new BMessage(kUpdateVolumeSpaceBar
));
769 BPopUpMenu
* menu
= new BPopUpMenu(B_EMPTY_STRING
);
770 menu
->SetFont(be_plain_font
);
773 menu
->AddItem(item
= new BMenuItem(
774 B_TRANSLATE("Used space color"),
775 new BMessage(kSpaceBarSwitchColor
)));
776 item
->SetMarked(true);
778 menu
->AddItem(new BMenuItem(
779 B_TRANSLATE("Free space color"),
780 new BMessage(kSpaceBarSwitchColor
)));
781 menu
->AddItem(new BMenuItem(
782 B_TRANSLATE("Warning space color"),
783 new BMessage(kSpaceBarSwitchColor
)));
785 fColorPicker
= new BMenuField("menu", NULL
, menu
);
787 fColorControl
= new BColorControl(BPoint(0, 0),
788 B_CELLS_16x16
, 1, "SpaceColorControl",
789 new BMessage(kSpaceBarColorChanged
));
790 fColorControl
->SetValue(TrackerSettings().UsedSpaceColor());
792 BBox
* box
= new BBox("box");
793 box
->SetLabel(fColorPicker
);
794 box
->AddChild(BLayoutBuilder::Group
<>(B_HORIZONTAL
)
796 .SetInsets(B_USE_DEFAULT_SPACING
)
799 BLayoutBuilder::Group
<>(this, B_VERTICAL
)
800 .Add(fSpaceBarShowCheckBox
)
803 .SetInsets(B_USE_DEFAULT_SPACING
);
807 SpaceBarSettingsView::~SpaceBarSettingsView()
813 SpaceBarSettingsView::AttachedToWindow()
815 fSpaceBarShowCheckBox
->SetTarget(this);
816 fColorControl
->SetTarget(this);
817 fColorPicker
->Menu()->SetTargetForItems(this);
822 SpaceBarSettingsView::MessageReceived(BMessage
* message
)
824 TTracker
* tracker
= dynamic_cast<TTracker
*>(be_app
);
828 TrackerSettings settings
;
830 switch (message
->what
) {
831 case kUpdateVolumeSpaceBar
:
833 settings
.SetShowVolumeSpaceBar(
834 fSpaceBarShowCheckBox
->Value() == 1);
835 Window()->PostMessage(kSettingsContentsModified
);
836 tracker
->PostMessage(kShowVolumeSpaceBar
);
840 case kSpaceBarSwitchColor
:
842 fCurrentColor
= message
->FindInt32("index");
843 switch (fCurrentColor
) {
845 fColorControl
->SetValue(settings
.UsedSpaceColor());
849 fColorControl
->SetValue(settings
.FreeSpaceColor());
853 fColorControl
->SetValue(settings
.WarningSpaceColor());
859 case kSpaceBarColorChanged
:
861 rgb_color color
= fColorControl
->ValueAsColor();
862 color
.alpha
= kSpaceBarAlpha
;
863 // alpha is ignored by BColorControl but is checked
866 switch (fCurrentColor
) {
868 settings
.SetUsedSpaceColor(color
);
872 settings
.SetFreeSpaceColor(color
);
876 settings
.SetWarningSpaceColor(color
);
880 BWindow
* window
= Window();
882 window
->PostMessage(kSettingsContentsModified
);
884 tracker
->PostMessage(kSpaceBarColorChanged
);
889 _inherited::MessageReceived(message
);
896 SpaceBarSettingsView::SetDefaults()
898 TTracker
* tracker
= dynamic_cast<TTracker
*>(be_app
);
902 TrackerSettings settings
;
904 if (!settings
.ShowVolumeSpaceBar()) {
905 settings
.SetShowVolumeSpaceBar(true);
906 send_bool_notices(kShowVolumeSpaceBar
, "ShowVolumeSpaceBar", true);
909 if (settings
.UsedSpaceColor() != kDefaultUsedSpaceColor
910 || settings
.FreeSpaceColor() != kDefaultFreeSpaceColor
911 || settings
.WarningSpaceColor() != kDefaultWarningSpaceColor
) {
912 settings
.SetUsedSpaceColor(kDefaultUsedSpaceColor
);
913 settings
.SetFreeSpaceColor(kDefaultFreeSpaceColor
);
914 settings
.SetWarningSpaceColor(kDefaultWarningSpaceColor
);
915 tracker
->SendNotices(kSpaceBarColorChanged
);
918 ShowCurrentSettings();
923 SpaceBarSettingsView::IsDefaultable() const
925 TrackerSettings settings
;
927 return settings
.ShowVolumeSpaceBar() != true
928 || settings
.UsedSpaceColor() != kDefaultUsedSpaceColor
929 || settings
.FreeSpaceColor() != kDefaultFreeSpaceColor
930 || settings
.WarningSpaceColor() != kDefaultWarningSpaceColor
;
935 SpaceBarSettingsView::Revert()
937 TTracker
* tracker
= dynamic_cast<TTracker
*>(be_app
);
941 TrackerSettings settings
;
943 if (settings
.ShowVolumeSpaceBar() != fSpaceBarShow
) {
944 settings
.SetShowVolumeSpaceBar(fSpaceBarShow
);
945 send_bool_notices(kShowVolumeSpaceBar
, "ShowVolumeSpaceBar",
949 if (settings
.UsedSpaceColor() != fUsedSpaceColor
950 || settings
.FreeSpaceColor() != fFreeSpaceColor
951 || settings
.WarningSpaceColor() != fWarningSpaceColor
) {
952 settings
.SetUsedSpaceColor(fUsedSpaceColor
);
953 settings
.SetFreeSpaceColor(fFreeSpaceColor
);
954 settings
.SetWarningSpaceColor(fWarningSpaceColor
);
955 tracker
->SendNotices(kSpaceBarColorChanged
);
958 ShowCurrentSettings();
963 SpaceBarSettingsView::ShowCurrentSettings()
965 TrackerSettings settings
;
967 fSpaceBarShowCheckBox
->SetValue(settings
.ShowVolumeSpaceBar());
969 switch (fCurrentColor
) {
971 fColorControl
->SetValue(settings
.UsedSpaceColor());
974 fColorControl
->SetValue(settings
.FreeSpaceColor());
977 fColorControl
->SetValue(settings
.WarningSpaceColor());
984 SpaceBarSettingsView::RecordRevertSettings()
986 TrackerSettings settings
;
988 fSpaceBarShow
= settings
.ShowVolumeSpaceBar();
989 fUsedSpaceColor
= settings
.UsedSpaceColor();
990 fFreeSpaceColor
= settings
.FreeSpaceColor();
991 fWarningSpaceColor
= settings
.WarningSpaceColor();
996 SpaceBarSettingsView::IsRevertable() const
998 TrackerSettings settings
;
1000 return fSpaceBarShow
!= settings
.ShowVolumeSpaceBar()
1001 || fUsedSpaceColor
!= settings
.UsedSpaceColor()
1002 || fFreeSpaceColor
!= settings
.FreeSpaceColor()
1003 || fWarningSpaceColor
!= settings
.WarningSpaceColor();