Ticket #254: Anxiety - Ticket 254 - 20070816.diff
File Anxiety - Ticket 254 - 20070816.diff, 16.4 KB (added by , 17 years ago) |
---|
-
src/preferences/virtualmemory/Settings.cpp
205 205 206 206 207 207 bool 208 Settings::IsDefaultable() 209 { 210 return fSwapEnabled != fInitialSwapEnabled 211 || fSwapSize != fInitialSwapSize; 212 } 213 214 215 bool 208 216 Settings::SwapChanged() 209 217 { 210 218 return fSwapEnabled != fInitialSwapEnabled -
src/preferences/virtualmemory/Settings.h
27 27 28 28 void SetSwapDefaults(); 29 29 void RevertSwapChanges(); 30 bool IsDefaultable(); 30 31 bool SwapChanged(); 31 32 32 33 private: -
src/preferences/virtualmemory/SettingsWindow.cpp
196 196 // Add "Defaults" and "Revert" buttons 197 197 198 198 rect.top = box->Frame().bottom + 10; 199 BButton* button = new BButton(rect, "defaults", "Defaults", new BMessage(kMsgDefaults)); 200 button->ResizeToPreferred(); 201 view->AddChild(button); 199 fDefaultsButton = new BButton(rect, "defaults", "Defaults", new BMessage(kMsgDefaults)); 200 fDefaultsButton->ResizeToPreferred(); 201 fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); 202 view->AddChild(fDefaultsButton); 202 203 203 rect = button->Frame();204 rect = fDefaultsButton->Frame(); 204 205 rect.OffsetBy(rect.Width() + 10, 0); 205 206 fRevertButton = new BButton(rect, "revert", "Revert", new BMessage(kMsgRevert)); 206 button->ResizeToPreferred(); 207 fRevertButton->ResizeToPreferred(); 208 fRevertButton->SetEnabled(false); 207 209 view->AddChild(fRevertButton); 208 210 209 view->ResizeTo(view->Frame().Width(), button->Frame().bottom + 10);211 view->ResizeTo(view->Frame().Width(), fRevertButton->Frame().bottom + 10); 210 212 ResizeTo(view->Bounds().Width(), view->Bounds().Height()); 211 213 AddChild(view); 212 214 // add view after resizing the window, so that the view's resizing … … 266 268 267 269 // ToDo: set volume 268 270 271 fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); 272 269 273 bool changed = fSettings.SwapChanged(); 270 274 if (fRevertButton->IsEnabled() != changed) { 271 275 fRevertButton->SetEnabled(changed); -
src/preferences/virtualmemory/SettingsWindow.h
30 30 31 31 BCheckBox* fSwapEnabledCheckBox; 32 32 BSlider* fSizeSlider; 33 BButton* fDefaultsButton; 33 34 BButton* fRevertButton; 34 35 BStringView* fWarningStringView; 35 36 -
src/preferences/mouse/MouseSettings.h
30 30 31 31 void Revert(); 32 32 void Defaults(); 33 bool IsDefaultable(); 33 34 void Dump(); 34 35 35 36 BPoint WindowPosition() const { return fWindowPosition; } -
src/preferences/mouse/MouseWindow.cpp
48 48 // Add the "Default" button 49 49 BRect rect(kBorderSpace, fSettingsView->Frame().bottom + kItemSpace + 2, 50 50 kBorderSpace + 75, fSettingsView->Frame().bottom + 20); 51 BButton *button = new BButton(rect, "defaults", "Defaults", new BMessage(kMsgDefaults)); 52 button->ResizeToPreferred(); 53 view->AddChild(button); 51 fDefaultsButton = new BButton(rect, "defaults", "Defaults", new BMessage(kMsgDefaults)); 52 fDefaultsButton->ResizeToPreferred(); 53 fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); 54 view->AddChild(fDefaultsButton); 54 55 55 56 // Add the "Revert" button 56 rect.OffsetBy( button->Bounds().Width() + kItemSpace, 0);57 rect.OffsetBy(fDefaultsButton->Bounds().Width() + kItemSpace, 0); 57 58 fRevertButton = new BButton(rect, "revert", "Revert", new BMessage(kMsgRevert)); 58 59 fRevertButton->SetEnabled(false); 59 60 fRevertButton->ResizeToPreferred(); … … 64 65 // buttons and draw the selected imagery 65 66 66 67 ResizeTo(fSettingsView->Frame().right + kBorderSpace, 67 button->Frame().bottom + kBorderSpace - 1);68 fRevertButton->Frame().bottom + kBorderSpace - 1); 68 69 69 70 // check if the window is on screen 70 71 … … 105 106 fSettings.Defaults(); 106 107 fSettingsView->UpdateFromSettings(); 107 108 108 SetRevertable(true); 109 fDefaultsButton->SetEnabled(false); 110 fRevertButton->SetEnabled(true); 109 111 break; 110 112 } 111 113 … … 114 116 fSettings.Revert(); 115 117 fSettingsView->UpdateFromSettings(); 116 118 117 SetRevertable(false); 119 fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); 120 fRevertButton->SetEnabled(false); 118 121 break; 119 122 } 120 123 … … 124 127 if (message->FindInt32("index", &type) == B_OK) { 125 128 fSettings.SetMouseType(++type); 126 129 fSettingsView->SetMouseType(type); 127 SetRevertable(true); 130 fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); 131 fRevertButton->SetEnabled(true); 128 132 } 129 133 break; 130 134 } … … 134 138 int32 mode; 135 139 if (message->FindInt32("mode", &mode) == B_OK) { 136 140 fSettings.SetMouseMode((mode_mouse)mode); 137 SetRevertable(true); 141 fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); 142 fRevertButton->SetEnabled(true); 138 143 } 139 144 break; 140 145 } … … 145 150 if (message->FindInt32("be:value", &value) == B_OK) { 146 151 // slow = 1000000, fast = 0 147 152 fSettings.SetClickSpeed(value * 1000); 148 SetRevertable(true); 153 fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); 154 fRevertButton->SetEnabled(true); 149 155 } 150 156 break; 151 157 } … … 156 162 if (message->FindInt32("be:value", &value) == B_OK) { 157 163 // slow = 8192, fast = 524287 158 164 fSettings.SetMouseSpeed((int32)pow(2, value * 6 / 1000) * 8192); 159 SetRevertable(true); 165 fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); 166 fRevertButton->SetEnabled(true); 160 167 } 161 168 break; 162 169 } … … 167 174 if (message->FindInt32("be:value", &value) == B_OK) { 168 175 // slow = 0, fast = 262144 169 176 fSettings.SetAccelerationFactor((int32)pow(value * 4 / 1000, 2) * 16384); 170 SetRevertable(true); 177 fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); 178 fRevertButton->SetEnabled(true); 171 179 } 172 180 break; 173 181 } … … 189 197 } 190 198 191 199 fSettings.SetMapping(button, mapping); 192 SetRevertable(true); 200 fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); 201 fRevertButton->SetEnabled(true); 193 202 fSettingsView->MouseMapUpdated(); 194 203 } 195 204 break; … … 201 210 } 202 211 } 203 212 204 205 void206 MouseWindow::SetRevertable(bool revertable)207 {208 fRevertButton->SetEnabled(revertable);209 }210 -
src/preferences/mouse/MouseWindow.h
33 33 virtual bool QuitRequested(); 34 34 virtual void MessageReceived(BMessage *message); 35 35 36 void SetRevertable(bool revertable);37 38 36 private: 39 37 MouseSettings fSettings; 38 BButton *fDefaultsButton; 40 39 BButton *fRevertButton; 41 40 SettingsView *fSettingsView; 42 41 }; -
src/preferences/mouse/MouseSettings.cpp
191 191 } 192 192 193 193 194 /** Checks if the settings are different then the system defaults 195 */ 196 197 bool 198 MouseSettings::IsDefaultable() 199 { 200 return fSettings.click_speed != kDefaultClickSpeed 201 || fSettings.accel.speed != kDefaultMouseSpeed 202 || fSettings.type != kDefaultMouseType 203 || fSettings.accel.accel_factor != kDefaultAccelerationFactor 204 || fMode != B_NORMAL_MOUSE 205 || fSettings.map.button[0] != B_PRIMARY_MOUSE_BUTTON 206 || fSettings.map.button[1] != B_SECONDARY_MOUSE_BUTTON 207 || fSettings.map.button[2] != B_TERTIARY_MOUSE_BUTTON; 208 } 209 210 194 211 /** Reverts to the active settings at program startup 195 212 */ 196 213 -
src/preferences/fonts/FontView.cpp
93 93 fFixedView->RelayoutIfNeeded(); 94 94 } 95 95 96 bool 97 FontView::IsDefaultable() 98 { 99 return fPlainView->IsDefaultable() 100 || fBoldView->IsDefaultable() 101 || fFixedView->IsDefaultable(); 102 } 96 103 97 104 bool 98 105 FontView::IsRevertable() -
src/preferences/fonts/MainWindow.h
33 33 34 34 BMessageRunner* fRunner; 35 35 FontView* fFontsView; 36 BButton* fDefaultsButton; 36 37 BButton* fRevertButton; 37 38 38 39 FontsSettings fSettings; -
src/preferences/fonts/FontView.h
25 25 void UpdateFonts(); 26 26 void RelayoutIfNeeded(); 27 27 28 bool IsDefaultable(); 28 29 bool IsRevertable(); 29 30 30 31 private: -
src/preferences/fonts/FontSelectionView.cpp
392 392 393 393 394 394 bool 395 FontSelectionView::IsDefaultable() 396 { 397 font_family default_family; 398 font_style default_style; 399 float default_size; 400 401 if (_get_system_default_font_(Name(), default_family, default_style, &default_size) != B_OK) 402 return false; 403 404 font_family current_family; 405 font_style current_style; 406 float current_size; 407 408 fCurrentFont.GetFamilyAndStyle(¤t_family, ¤t_style); 409 current_size = fCurrentFont.Size(); 410 411 return strcmp(current_family, default_family) != 0 412 || strcmp(current_style, default_style) != 0 413 || current_size != default_size; 414 } 415 416 417 bool 395 418 FontSelectionView::IsRevertable() 396 419 { 397 420 return fCurrentFont != fSavedFont; -
src/preferences/fonts/FontSelectionView.h
34 34 35 35 void SetDefaults(); 36 36 void Revert(); 37 bool IsDefaultable(); 37 38 bool IsRevertable(); 38 39 39 40 void UpdateFontsMenu(); -
src/preferences/fonts/MainWindow.cpp
35 35 36 36 rect.left = 10; 37 37 rect.top = rect.bottom - 10; 38 BButton *button = new BButton(rect, "defaults", "Defaults",38 fDefaultsButton = new BButton(rect, "defaults", "Defaults", 39 39 new BMessage(kMsgSetDefaults), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW); 40 button->ResizeToPreferred(); 41 float buttonHeight = button->Bounds().Height(); 42 button->MoveBy(0, -buttonHeight); 43 view->AddChild(button); 40 fDefaultsButton->ResizeToPreferred(); 41 fDefaultsButton->SetEnabled(false); 42 float buttonHeight = fDefaultsButton->Bounds().Height(); 43 fDefaultsButton->MoveBy(0, -buttonHeight); 44 view->AddChild(fDefaultsButton); 44 45 45 rect = button->Frame();46 rect.OffsetBy( button->Bounds().Width() + 10, 0);46 rect = fDefaultsButton->Frame(); 47 rect.OffsetBy(fDefaultsButton->Bounds().Width() + 10, 0); 47 48 48 49 fRevertButton = new BButton(rect, "revert", "Revert", 49 50 new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW); … … 99 100 100 101 fRunner = new BMessageRunner(this, new BMessage(kMsgCheckFonts), 3000000); 101 102 // every 3 seconds 103 104 fDefaultsButton->SetEnabled(fFontsView->IsDefaultable()); 102 105 } 103 106 104 107 … … 123 126 { 124 127 switch (message->what) { 125 128 case kMsgUpdate: 129 fDefaultsButton->SetEnabled(fFontsView->IsDefaultable()); 126 130 fRevertButton->SetEnabled(fFontsView->IsRevertable()); 127 131 break; 128 132 129 133 case kMsgSetDefaults: 130 134 fFontsView->SetDefaults(); 135 fDefaultsButton->SetEnabled(false); 131 136 fRevertButton->SetEnabled(fFontsView->IsRevertable()); 132 137 break; 133 138 134 139 case kMsgRevert: 135 140 fFontsView->Revert(); 141 fDefaultsButton->SetEnabled(fFontsView->IsDefaultable()); 136 142 fRevertButton->SetEnabled(false); 137 143 break; 138 144 -
src/preferences/keyboard/KeyboardSettings.cpp
117 117 SetKeyboardRepeatDelay(kb_default_key_repeat_delay); 118 118 SetKeyboardRepeatRate(kb_default_key_repeat_rate); 119 119 } 120 121 122 bool 123 KeyboardSettings::IsDefaultable() 124 { 125 return fSettings.key_repeat_delay != kb_default_key_repeat_delay 126 || fSettings.key_repeat_rate != kb_default_key_repeat_rate; 127 } -
src/preferences/keyboard/KeyboardSettings.h
21 21 void Dump(); 22 22 void Revert(); 23 23 void Defaults(); 24 bool IsDefaultable(); 24 25 25 26 BPoint WindowCorner() const { return fCorner; } 26 27 void SetWindowCorner(BPoint corner); -
src/preferences/keyboard/KeyboardWindow.cpp
39 39 if (slider !=NULL) 40 40 slider->SetValue(fSettings.KeyboardRepeatDelay()); 41 41 42 BButton *button = (BButton *)FindView("keyboard_defaults"); 43 if (button !=NULL) 44 button->SetEnabled(fSettings.IsDefaultable()); 45 42 46 #ifdef DEBUG 43 47 fSettings.Dump(); 44 48 #endif … … 78 82 slider = (BSlider *)FindView("delay_until_key_repeat"); 79 83 if (slider !=NULL) 80 84 slider->SetValue(fSettings.KeyboardRepeatDelay()); 85 86 button = (BButton *)FindView("keyboard_defaults"); 87 if (button !=NULL) 88 button->SetEnabled(false); 81 89 82 90 button = (BButton *)FindView("keyboard_revert"); 83 91 if (button !=NULL) … … 95 103 if (slider !=NULL) 96 104 slider->SetValue(fSettings.KeyboardRepeatDelay()); 97 105 106 button = (BButton *)FindView("keyboard_defaults"); 107 if (button !=NULL) 108 button->SetEnabled(fSettings.IsDefaultable()); 109 98 110 button = (BButton *)FindView("keyboard_revert"); 99 111 if (button !=NULL) 100 112 button->SetEnabled(false); … … 106 118 break; 107 119 fSettings.SetKeyboardRepeatRate(rate); 108 120 121 button = (BButton *)FindView("keyboard_defaults"); 122 if (button !=NULL) 123 button->SetEnabled(fSettings.IsDefaultable()); 124 109 125 button = (BButton *)FindView("keyboard_revert"); 110 126 if (button !=NULL) 111 127 button->SetEnabled(true); … … 133 149 if (slider !=NULL) 134 150 slider->SetValue(delay); 135 151 152 button = (BButton *)FindView("keyboard_defaults"); 153 if (button !=NULL) 154 button->SetEnabled(fSettings.IsDefaultable()); 155 136 156 button = (BButton *)FindView("keyboard_revert"); 137 157 if (button !=NULL) 138 158 button->SetEnabled(true); -
src/preferences/sounds/HWindow.cpp
139 139 ,new BMessage(M_STOP_MESSAGE) 140 140 ,B_FOLLOW_RIGHT | B_FOLLOW_TOP); 141 141 button->ResizeToPreferred(); 142 button->SetEnabled(false); 142 143 button->MoveTo(box->Bounds().right - button->Bounds().Width() - 15, rect.top); 143 144 box->AddChild(button); 144 145 … … 153 154 ,new BMessage(M_PLAY_MESSAGE) 154 155 ,B_FOLLOW_RIGHT | B_FOLLOW_TOP); 155 156 button->ResizeToPreferred(); 157 button->SetEnabled(false); 156 158 button->MoveTo(rect.left - button->Bounds().Width() - 15, rect.top); 157 159 box->AddChild(button); 158 160 … … 408 410 409 411 if(!menufield) 410 412 return; 413 411 414 if(sel >=0) { 412 menufield->SetEnabled(true); 413 button->SetEnabled(true); 415 HEventItem *item = cast_as(fEventList->ItemAt(sel),HEventItem); 416 const char* path = item->Path(); 417 418 menufield->SetEnabled(path != NULL); 419 button->SetEnabled(path != NULL); 414 420 } else { 415 421 menufield->SetEnabled(false); 416 422 button->SetEnabled(false);