Ticket #254: 20070819 - Ticket 254c.diff
File 20070819 - Ticket 254c.diff, 16.0 KB (added by , 17 years ago) |
---|
-
src/preferences/appearance/ColorSet.h
32 32 bool ConvertFromMessage(const BMessage *msg); 33 33 34 34 void SetToDefaults(void); 35 bool IsDefaultable(void); 35 36 36 37 rgb_color StringToColor(const char *string); 37 38 rgb_color AttributeToColor(int32 which); -
src/preferences/appearance/APRView.cpp
146 146 fDefaults = new BButton(BRect(0,0,1,1),"DefaultsButton","Defaults", 147 147 new BMessage(DEFAULT_SETTINGS), 148 148 B_FOLLOW_LEFT |B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); 149 fDefaults->ResizeToPreferred(); 149 fDefaults->ResizeToPreferred(); 150 fDefaults->SetEnabled(false); 150 151 fDefaults->MoveTo((fPicker->Frame().right-(fDefaults->Frame().Width()*2)-20)/2,fPicker->Frame().bottom+20); 151 152 AddChild(fDefaults); 152 153 … … 157 158 fRevert = new BButton(cvrect,"RevertButton","Revert", 158 159 new BMessage(REVERT_SETTINGS), 159 160 B_FOLLOW_LEFT |B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); 161 fRevert->SetEnabled(false); 160 162 AddChild(fRevert); 161 fRevert->SetEnabled(false);162 163 163 164 } 164 165 165 166 APRView::~APRView(void) 166 167 { 168 //BPrivate::set_system_colors(&fCurrentSet); 167 169 ColorSet::SaveColorSet("/boot/home/config/settings/app_server/system_colors",fCurrentSet); 168 170 } 169 171 … … 185 187 fDefaults->Frame().bottom + 10); 186 188 LoadSettings(); 187 189 fAttrList->Select(0); 190 191 fDefaults->SetEnabled(fCurrentSet.IsDefaultable()); 188 192 } 189 193 190 194 void … … 221 225 // Update current fAttribute in the settings 222 226 fCurrentSet.SetColor(fAttrString.String(),col); 223 227 228 fDefaults->SetEnabled(fCurrentSet.IsDefaultable()); 224 229 fRevert->SetEnabled(true); 225 230 226 231 break; … … 236 241 237 242 fAttrString=whichitem->Text(); 238 243 UpdateControlsFromAttr(whichitem->Text()); 244 245 fDefaults->SetEnabled(fCurrentSet.IsDefaultable()); 239 246 break; 240 247 } 241 248 case REVERT_SETTINGS: { … … 248 255 } 249 256 case DEFAULT_SETTINGS: { 250 257 fCurrentSet.SetToDefaults(); 258 fDefaults->SetEnabled(false); 251 259 252 260 UpdateControlsFromAttr(fAttrString.String()); 253 261 BMenuItem *item = fDecorMenu->FindItem("Default"); … … 272 280 // getting them from the server at this point for testing purposes. 273 281 274 282 // Query the server for the current settings 275 // BPrivate::get_system_colors(&fCurrentSet);283 // BPrivate::get_system_colors(&fCurrentSet); 276 284 277 285 // TODO: remove this and enable the get_system_colors() call 278 286 if (ColorSet::LoadColorSet("/boot/home/config/settings/app_server/system_colors",&fCurrentSet) != B_OK) { -
src/preferences/appearance/ColorSet.cpp
25 25 color.alpha = 255; 26 26 } 27 27 28 static bool 29 match_rgb_color(rgb_color& color, uint8 red, uint8 green, uint8 blue) 30 { 31 return color.red == red 32 && color.green == green 33 && color.blue == blue; 34 } 28 35 36 29 37 // #pragma mark - 30 38 31 39 … … 173 181 } 174 182 175 183 /*! 184 \brief Checks if the ColorSet can be set to defaults. 185 */ 186 bool 187 ColorSet::IsDefaultable() 188 { 189 return !match_rgb_color(panel_background, 216, 216, 216) 190 || !match_rgb_color(panel_text, 0, 0, 0) 191 || !match_rgb_color(document_background, 255, 255, 255) 192 || !match_rgb_color(document_text, 0, 0, 0) 193 || !match_rgb_color(control_background, 245, 245, 245) 194 || !match_rgb_color(control_text, 0, 0, 0) 195 || !match_rgb_color(control_border, 0, 0, 0) 196 || !match_rgb_color(control_highlight, 102, 152, 203) 197 || !match_rgb_color(keyboard_navigation_base, 0, 0, 229) 198 || !match_rgb_color(keyboard_navigation_pulse, 0, 0, 0) 199 || !match_rgb_color(shine, 255, 255, 255) 200 || !match_rgb_color(shadow, 0, 0, 0) 201 || !match_rgb_color(menu_background, 216, 216, 216) 202 || !match_rgb_color(menu_selected_background, 115, 120, 184) 203 || !match_rgb_color(menu_text, 0, 0, 0) 204 || !match_rgb_color(menu_selected_text, 255, 255, 255) 205 || !match_rgb_color(menu_selected_border, 0, 0, 0) 206 || !match_rgb_color(tooltip_background, 255, 255, 0) 207 || !match_rgb_color(tooltip_text, 0, 0, 0) 208 || !match_rgb_color(success, 0, 255, 0) 209 || !match_rgb_color(failure, 255, 0, 0) 210 || !match_rgb_color(window_tab, 255, 203, 0) 211 || !match_rgb_color(window_tab_text, 0, 0, 0) 212 || !match_rgb_color(inactive_window_tab, 232, 232, 232) 213 || !match_rgb_color(inactive_window_tab_text, 80, 80, 80); 214 } 215 216 /*! 176 217 \brief Attaches the color set's members as data to the given BMessage 177 218 \param msg The message to receive the attributes 178 219 */ -
src/preferences/menu/MenuWindow.h
25 25 virtual void MessageReceived(BMessage *message); 26 26 virtual bool QuitRequested(); 27 27 28 void Update();29 void Defaults();30 31 28 private: 32 bool fRevert;33 ColorWindow* fColorWindow;34 MenuBar* fMenuBar;35 BButton* fRevertButton;29 ColorWindow* fColorWindow; 30 MenuBar* fMenuBar; 31 BButton* fDefaultsButton; 32 BButton* fRevertButton; 36 33 }; 37 34 38 35 #endif // MENU_WINDOW_H -
src/preferences/menu/MenuSettings.cpp
74 74 set_menu_info(&fDefaultSettings); 75 75 } 76 76 77 78 bool 79 MenuSettings::IsDefaultable() 80 { 81 menu_info info; 82 get_menu_info(&info); 83 84 return info.font_size != fDefaultSettings.font_size 85 || info.background_color != fDefaultSettings.background_color 86 || info.separator != fDefaultSettings.separator 87 || info.click_to_open != fDefaultSettings.click_to_open 88 || info.triggers_always_shown != fDefaultSettings.triggers_always_shown; 89 } 90 -
src/preferences/menu/MenuSettings.h
21 21 22 22 void Revert(); 23 23 void ResetToDefaults(); 24 bool IsDefaultable(); 24 25 25 26 private: 26 27 MenuSettings(); -
src/preferences/menu/MenuWindow.cpp
31 31 B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE) 32 32 { 33 33 fColorWindow = NULL; 34 fRevert = false;35 34 36 35 BView* topView = new BView(Bounds(), "menuView", B_FOLLOW_ALL_SIDES, 37 36 B_WILL_DRAW); … … 48 47 BRect buttonFrame(menuBarFrame.left, menuBarFrame.bottom + 10, 49 48 menuBarFrame.left + 75, menuBarFrame.bottom + 30); 50 49 51 BButton* defaultButton = new BButton(buttonFrame, "Default", "Defaults",50 fDefaultsButton = new BButton(buttonFrame, "Default", "Defaults", 52 51 new BMessage(MENU_DEFAULT), B_FOLLOW_H_CENTER | B_FOLLOW_BOTTOM, 53 52 B_WILL_DRAW | B_NAVIGABLE); 54 topView->AddChild(defaultButton); 53 fDefaultsButton->SetEnabled(false); 54 topView->AddChild(fDefaultsButton); 55 55 56 56 buttonFrame.OffsetBy(buttonFrame.Width() + 20, 0); 57 57 fRevertButton = new BButton(buttonFrame, "Revert", "Revert", new BMessage(MENU_REVERT), … … 60 60 topView->AddChild(fRevertButton); 61 61 62 62 topView->MakeFocus(); 63 64 Update(); 63 fMenuBar->Update(); 65 64 } 66 65 67 66 … … 73 72 74 73 switch (msg->what) { 75 74 case MENU_REVERT: 76 fRevert = false;77 75 settings->Revert(); 78 Update(); 76 77 fRevertButton->SetEnabled(false); 78 fDefaultsButton->SetEnabled(settings->IsDefaultable()); 79 fMenuBar->Update(); 79 80 break; 80 81 81 82 case MENU_DEFAULT: 82 fRevert = true;83 83 settings->ResetToDefaults(); 84 Update(); 84 85 fDefaultsButton->SetEnabled(false); 86 fMenuBar->Update(); 85 87 break; 86 88 87 89 case UPDATE_WINDOW: 88 Update();90 fMenuBar->Update(); 89 91 break; 90 92 91 93 case MENU_FONT_FAMILY: 92 94 case MENU_FONT_STYLE: 93 95 { 94 fRevert = true;95 96 const font_family *family; 96 97 msg->FindString("family", (const char **)&family); 97 98 const font_style *style; … … 101 102 strlcpy(info.f_family, (const char *)family, B_FONT_FAMILY_LENGTH); 102 103 strlcpy(info.f_style, (const char *)style, B_FONT_STYLE_LENGTH); 103 104 settings->Set(info); 104 Update(); 105 106 fRevertButton->SetEnabled(true); 107 fDefaultsButton->SetEnabled(settings->IsDefaultable()); 108 fMenuBar->Update(); 105 109 break; 106 110 } 107 111 108 112 case MENU_FONT_SIZE: 109 fRevert = true;110 113 settings->Get(info); 111 114 msg->FindFloat("size", &info.font_size); 112 115 settings->Set(info); 113 Update(); 116 117 fRevertButton->SetEnabled(true); 118 fDefaultsButton->SetEnabled(settings->IsDefaultable()); 119 fMenuBar->Update(); 114 120 break; 115 121 116 122 case ALLWAYS_TRIGGERS_MSG: 117 fRevert = true;118 123 settings->Get(info); 119 124 info.triggers_always_shown = !info.triggers_always_shown; 120 125 settings->Set(info); 126 127 fRevertButton->SetEnabled(true); 128 fDefaultsButton->SetEnabled(settings->IsDefaultable()); 121 129 fMenuBar->UpdateMenu(); 122 Update();130 fMenuBar->Update(); 123 131 break; 124 132 125 133 case CTL_MARKED_MSG: 126 fRevert = true;127 134 // This might not be the same for all keyboards 128 135 set_modifier_key(B_LEFT_COMMAND_KEY, 0x5c); 129 136 set_modifier_key(B_RIGHT_COMMAND_KEY, 0x60); 130 137 set_modifier_key(B_LEFT_CONTROL_KEY, 0x5d); 131 138 set_modifier_key(B_RIGHT_OPTION_KEY, 0x5f); 132 139 be_roster->Broadcast(new BMessage(B_MODIFIERS_CHANGED)); 133 Update(); 140 141 fRevertButton->SetEnabled(true); 142 fDefaultsButton->SetEnabled(settings->IsDefaultable()); 143 fMenuBar->Update(); 134 144 break; 135 145 136 146 case ALT_MARKED_MSG: 137 fRevert = true; 147 138 148 // This might not be the same for all keyboards 139 149 set_modifier_key(B_LEFT_COMMAND_KEY, 0x5d); 140 150 set_modifier_key(B_RIGHT_COMMAND_KEY, 0x5f); … … 142 152 set_modifier_key(B_RIGHT_OPTION_KEY, 0x60); 143 153 144 154 be_roster->Broadcast(new BMessage(B_MODIFIERS_CHANGED)); 145 Update(); 155 156 fRevertButton->SetEnabled(true); 157 fDefaultsButton->SetEnabled(settings->IsDefaultable()); 158 fMenuBar->Update(); 146 159 break; 147 160 148 161 case COLOR_SCHEME_OPEN_MSG: … … 158 171 break; 159 172 160 173 case MENU_COLOR: 161 fRevert = true; 162 Update(); 174 fRevertButton->SetEnabled(true); 175 fDefaultsButton->SetEnabled(settings->IsDefaultable()); 176 fMenuBar->Update(); 163 177 break; 164 178 165 179 default: … … 180 194 return true; 181 195 } 182 196 183 184 void185 MenuWindow::Update()186 {187 fRevertButton->SetEnabled(fRevert);188 189 // alert the rest of the application to update190 fMenuBar->Update();191 }192 -
src/kits/tracker/SettingsViews.cpp
93 93 94 94 95 95 /*! 96 This function is used by the window to tell whether 97 it can ghost the defaults button or not. It doesn't 98 shows the default settings, this function should 99 return true. 100 */ 101 bool 102 SettingsView::IsDefaultable() const 103 { 104 return true; 105 } 106 107 108 /*! 96 109 The inherited functions should set the values that was 97 110 active when the settings window opened. It should also 98 111 update the UI widgets accordingly, preferrable by calling … … 317 330 } 318 331 319 332 333 bool 334 DesktopSettingsView::IsDefaultable() const 335 { 336 TrackerSettings settings; 337 338 return settings.ShowDisksIcon() != false 339 || settings.MountVolumesOntoDesktop() != true 340 || settings.MountSharedVolumesOntoDesktop() != true 341 || settings.IntegrateNonBootBeOSDesktops() != false 342 || settings.EjectWhenUnmounting() != true; 343 } 344 345 320 346 void 321 347 DesktopSettingsView::Revert() 322 348 { … … 570 596 } 571 597 572 598 599 bool 600 WindowsSettingsView::IsDefaultable() const 601 { 602 TrackerSettings settings; 603 604 return settings.ShowFullPathInTitleBar() != false 605 || settings.SingleWindowBrowse() != false 606 || settings.ShowNavigator() != false 607 || settings.TransparentSelection() != true 608 || settings.SortFolderNamesFirst() != true; 609 } 610 611 573 612 void 574 613 WindowsSettingsView::Revert() 575 614 { … … 843 882 } 844 883 845 884 885 bool 886 TimeFormatSettingsView::IsDefaultable() const 887 { 888 TrackerSettings settings; 889 890 return settings.TimeFormatSeparator() != kSlashSeparator 891 || settings.DateOrderFormat() != kMDYFormat 892 || settings.ClockIs24Hr() != false; 893 } 894 895 846 896 void 847 897 TimeFormatSettingsView::Revert() 848 898 { … … 1146 1196 } 1147 1197 1148 1198 1199 bool 1200 SpaceBarSettingsView::IsDefaultable() const 1201 { 1202 TrackerSettings settings; 1203 1204 return settings.ShowVolumeSpaceBar() != false 1205 || settings.UsedSpaceColor() != Color(0, 203, 0, 192) 1206 || settings.FreeSpaceColor() != Color(255, 255, 255, 192) 1207 || settings.WarningSpaceColor() != Color(203, 0, 0, 192); 1208 } 1209 1210 1149 1211 void 1150 1212 SpaceBarSettingsView::Revert() 1151 1213 { … … 1307 1369 } 1308 1370 1309 1371 1372 bool 1373 TrashSettingsView::IsDefaultable() const 1374 { 1375 TrackerSettings settings; 1376 1377 return settings.DontMoveFilesToTrash() != false 1378 || settings.AskBeforeDeleteFile() != true; 1379 } 1380 1381 1310 1382 void 1311 1383 TrashSettingsView::Revert() 1312 1384 { -
src/kits/tracker/TrackerSettingsWindow.cpp
88 88 fDefaultsButton = new BButton(rect, "Defaults", "Defaults", 89 89 new BMessage(kDefaultsButtonPressed), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); 90 90 fDefaultsButton->ResizeToPreferred(); 91 fDefaultsButton->SetEnabled(false); 91 92 fDefaultsButton->MoveBy(0, -fDefaultsButton->Bounds().Height()); 92 93 topView->AddChild(fDefaultsButton); 93 94 … … 240 241 { 241 242 int32 itemCount = fSettingsTypeListView->CountItems(); 242 243 244 bool defaultable = false; 243 245 bool revertable = false; 244 246 245 247 for (int32 i = 0; i < itemCount; i++) { 248 defaultable |= _ViewAt(i)->IsDefaultable(); 246 249 revertable |= _ViewAt(i)->IsRevertable(); 247 250 } 248 251 249 fSettingsTypeListView->Invalidate(); 252 fSettingsTypeListView->Invalidate(); 253 fDefaultsButton->SetEnabled(defaultable); 250 254 fRevertButton->SetEnabled(revertable); 251 255 252 256 TrackerSettings().SaveSettings(false); … … 258 262 { 259 263 int32 itemCount = fSettingsTypeListView->CountItems(); 260 264 261 for (int32 i = 0; i < itemCount; i++) 262 _ViewAt(i)->SetDefaults(); 265 for (int32 i = 0; i < itemCount; i++) { 266 if (_ViewAt(i)->IsDefaultable()) 267 _ViewAt(i)->SetDefaults(); 268 } 263 269 264 270 _HandleChangedContents(); 265 271 } -
src/kits/tracker/SettingsViews.h
57 57 virtual ~SettingsView(); 58 58 59 59 virtual void SetDefaults(); 60 virtual bool IsDefaultable() const; 60 61 virtual void Revert(); 61 62 virtual void ShowCurrentSettings(); 62 63 virtual void RecordRevertSettings(); … … 75 76 virtual void GetPreferredSize(float *_width, float *_height); 76 77 77 78 virtual void SetDefaults(); 79 virtual bool IsDefaultable() const; 78 80 virtual void Revert(); 79 81 virtual void ShowCurrentSettings(); 80 82 virtual void RecordRevertSettings(); … … 108 110 virtual void GetPreferredSize(float *_width, float *_height); 109 111 110 112 virtual void SetDefaults(); 113 virtual bool IsDefaultable() const; 111 114 virtual void Revert(); 112 115 virtual void ShowCurrentSettings(); 113 116 virtual void RecordRevertSettings(); … … 139 142 virtual void GetPreferredSize(float *_width, float *_height); 140 143 141 144 virtual void SetDefaults(); 145 virtual bool IsDefaultable() const; 142 146 virtual void Revert(); 143 147 virtual void ShowCurrentSettings(); 144 148 virtual void RecordRevertSettings(); … … 178 182 virtual void GetPreferredSize(float *_width, float *_height); 179 183 180 184 virtual void SetDefaults(); 185 virtual bool IsDefaultable() const; 181 186 virtual void Revert(); 182 187 virtual void ShowCurrentSettings(); 183 188 virtual void RecordRevertSettings(); … … 206 211 virtual void GetPreferredSize(float *_width, float *_height); 207 212 208 213 virtual void SetDefaults(); 214 virtual bool IsDefaultable() const; 209 215 virtual void Revert(); 210 216 virtual void ShowCurrentSettings(); 211 217 virtual void RecordRevertSettings();