[haiku-commits] haiku: hrev48724 - src/preferences/screen

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 26 Jan 2015 11:04:30 +0100 (CET)

hrev48724 adds 1 changeset to branch 'master'
old head: e9b82428687037c1998e7140661a249710dd93c8
new head: 95ef50445f4c79fdbc2aad175287975ec214d6f1
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=95ef50445f4c+%5Ee9b824286870

----------------------------------------------------------------------------

95ef50445f4c: Screen: disable Apply button when no changes would be made.
  
  * Previously this would work only in "current workspace" mode.
  * Also avoid calling count_workspaces in a loop since its result is not
  cached and it needs to ask app_server each time.
  * Fixes #4231.
  
  Signed-off-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

                                                [ Janus <janus2@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev48724
Commit:      95ef50445f4c79fdbc2aad175287975ec214d6f1
URL:         http://cgit.haiku-os.org/haiku/commit/?id=95ef50445f4c
Author:      Janus <janus2@xxxxxxxxx>
Date:        Mon Jan 19 10:07:46 2015 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Mon Jan 26 10:05:31 2015 UTC

Ticket:      https://dev.haiku-os.org/ticket/4231

----------------------------------------------------------------------------

1 file changed, 20 insertions(+), 3 deletions(-)
src/preferences/screen/ScreenWindow.cpp | 23 ++++++++++++++++++++---

----------------------------------------------------------------------------

diff --git a/src/preferences/screen/ScreenWindow.cpp 
b/src/preferences/screen/ScreenWindow.cpp
index 511ed9a..c3bfb28 100644
--- a/src/preferences/screen/ScreenWindow.cpp
+++ b/src/preferences/screen/ScreenWindow.cpp
@@ -1215,8 +1215,24 @@ ScreenWindow::_BuildSupportedColorSpaces()
 void
 ScreenWindow::_CheckApplyEnabled()
 {
-       fApplyButton->SetEnabled(fSelected != fActive
-               || fAllWorkspacesItem->IsMarked());
+       bool applyEnabled = true;
+       
+       if (fSelected == fActive) {
+               applyEnabled = false;
+               if (fAllWorkspacesItem->IsMarked()) {
+                       screen_mode screenMode;
+                       const int32 workspaceCount = count_workspaces();
+                       for (int32 i = 0; i < workspaceCount; i++) {
+                               fScreenMode.Get(screenMode, i);
+                               if (screenMode != fSelected) {
+                                       applyEnabled = true;
+                                       break;
+                               }
+                       }
+               }
+       }
+       
+       fApplyButton->SetEnabled(applyEnabled);
 
        uint32 columns;
        uint32 rows;
@@ -1337,7 +1353,8 @@ ScreenWindow::_Apply()
 
                if (fAllWorkspacesItem->IsMarked()) {
                        int32 originatingWorkspace = current_workspace();
-                       for (int32 i = 0; i < count_workspaces(); i++) {
+                       const int32 workspaceCount = count_workspaces();
+                       for (int32 i = 0; i < workspaceCount; i++) {
                                if (i != originatingWorkspace)
                                        screen.SetMode(i, &newMode, true);
                        }


Other related posts:

  • » [haiku-commits] haiku: hrev48724 - src/preferences/screen - pulkomandy