Package: musescore2 / 2.3.2+dfsg4-16

upstream/prefs-radio.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
Origin: upstream, commit:406b7b6bf23de8248f77015b8c38ec6d876c04cd
Author: J. Edward Sanchez <Spire42@users.noreply.github.com>
Description: Fix #304466: The “I/O” tab of the “Preferences” dialog should use radio buttons instead of checkboxes
 Fixed a UI problem with the “I/O” tab of the “Preferences” dialog that
 caused mutually exclusive options to be presented to the user as
 checkboxes instead of radio buttons.
 .
 The underlying technical reason for this was that the Qt framework does
 not allow group boxes to have radio buttons. This has been worked
 around by subclassing the QGroupBox class and rendering the checkboxes
 to look like radio buttons. This is sufficient for our purposes because
 the application already overrides the checkboxes' behavior to work like
 radio buttons.

--- a/mscore/CMakeLists.txt
+++ b/mscore/CMakeLists.txt
@@ -221,6 +221,7 @@ add_executable ( ${ExecutableName}
       ${resource_file}
       ${INCS}
 
+      radiobuttongroupbox.h
       recordbutton.h greendotbutton prefsdialog.h
       stringutils.h stringutils.cpp
       scoreview.cpp editinstrument.cpp editstyle.cpp
@@ -233,6 +234,7 @@ add_executable ( ${ExecutableName}
       mixer.cpp playpanel.cpp selectionwindow.cpp preferences.cpp measureproperties.cpp
       seq.cpp textpalette.cpp
       timedialog.cpp symboldialog.cpp shortcutcapturedialog.cpp
+      radiobuttongroupbox.cpp
       simplebutton.cpp musedata.cpp
       editdrumset.cpp editstaff.cpp voltaproperties.cpp
       timesigproperties.cpp newwizard.cpp transposedialog.cpp
--- a/mscore/prefsdialog.ui
+++ b/mscore/prefsdialog.ui
@@ -2711,7 +2711,7 @@
       </attribute>
       <layout class="QVBoxLayout" name="verticalLayout_8">
        <item>
-        <widget class="QGroupBox" name="pulseaudioDriver">
+        <widget class="Ms::RadioButtonGroupBox" name="pulseaudioDriver">
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
@@ -2736,7 +2736,7 @@
         </widget>
        </item>
        <item>
-        <widget class="QGroupBox" name="portaudioDriver">
+        <widget class="Ms::RadioButtonGroupBox" name="portaudioDriver">
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
@@ -2922,7 +2922,7 @@ Adjusting latency can help synchronize y
         </widget>
        </item>
        <item>
-        <widget class="QGroupBox" name="alsaDriver">
+        <widget class="Ms::RadioButtonGroupBox" name="alsaDriver">
          <property name="sizePolicy">
           <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
            <horstretch>0</horstretch>
@@ -3144,7 +3144,7 @@ Adjusting latency can help synchronize y
         </widget>
        </item>
        <item>
-        <widget class="QGroupBox" name="jackDriver">
+        <widget class="Ms::RadioButtonGroupBox" name="jackDriver">
          <property name="sizePolicy">
           <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
            <horstretch>0</horstretch>
@@ -4232,6 +4232,11 @@ Adjusting latency can help synchronize y
    <extends>QToolButton</extends>
    <header>recordbutton.h</header>
   </customwidget>
+  <customwidget>
+   <class>Ms::RadioButtonGroupBox</class>
+   <extends>QGroupBox</extends>
+   <header>radiobuttongroupbox.h</header>
+  </customwidget>
  </customwidgets>
  <tabstops>
   <tabstop>General</tabstop>
--- /dev/null
+++ b/mscore/radiobuttongroupbox.cpp
@@ -0,0 +1,49 @@
+//=============================================================================
+//  MuseScore
+//  Music Composition & Notation
+//
+//  Copyright (C) 2020 MuseScore BVBA and others
+//
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License version 2.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#include "radiobuttongroupbox.h"
+
+namespace Ms {
+
+void RadioButtonGroupBox::paintEvent(QPaintEvent*)
+      {
+      QStylePainter painter(this);
+      QStyleOptionGroupBox styleOption;
+      initStyleOption(&styleOption);
+
+      // Paint the default QGroupBox-style control, which includes an unwanted checkbox that we'll cover up afterwards.
+      painter.drawComplexControl(QStyle::CC_GroupBox, styleOption);
+
+      // Calculate the background color the same way Qt does in QFusionStylePrivate::tabFrameColor().
+      const QColor& buttonColor = styleOption.palette.button().color();
+      QColor bgColor = buttonColor.lighter(100 + std::max(1, (180 - qGray(buttonColor.rgb())) / 6));
+      bgColor.setHsv(bgColor.hue(), 3 * bgColor.saturation() / 4, bgColor.value());
+      bgColor = bgColor.lighter(104);
+
+      // Adjust the style options to use the checkbox's rectangle.
+      styleOption.rect = style()->subControlRect(QStyle::CC_GroupBox, &styleOption, QStyle::SC_GroupBoxCheckBox, this);
+
+      // Cover up the checkbox, making sure to enlarge the rectangle a bit to cover up any anti-aliasing around the edges.
+      painter.fillRect(styleOption.rect.adjusted(-2, -2, 2, 2), bgColor);
+
+      // Paint the radio button.
+      painter.drawPrimitive(QStyle::PE_IndicatorRadioButton, styleOption);
+      }
+
+}
--- /dev/null
+++ b/mscore/radiobuttongroupbox.h
@@ -0,0 +1,37 @@
+//=============================================================================
+//  MuseScore
+//  Music Composition & Notation
+//
+//  Copyright (C) 2020 MuseScore BVBA and others
+//
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License version 2.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#ifndef RADIOBUTTONGROUPBOX_H
+#define RADIOBUTTONGROUPBOX_H
+
+namespace Ms {
+
+class RadioButtonGroupBox : public QGroupBox {
+      Q_OBJECT
+
+      void paintEvent(QPaintEvent* event) override;
+
+   public:
+      explicit RadioButtonGroupBox(QWidget* parent = nullptr) : QGroupBox(parent) { }
+      explicit RadioButtonGroupBox(const QString& title, QWidget* parent = nullptr) : QGroupBox(title, parent) { }
+      };
+
+}
+
+#endif