├── .gitignore
├── LICENSE
├── QRibbon.pro
├── QRibbon.pro.user
├── QRibbon.pro.user.18
├── QRibbon.pro.user.5cf5531
├── QRibbonDetails.svg
├── README.md
├── RibbonPoint.svg
├── RibbonUp.svg
├── main.cpp
├── memorycheck.bat
├── qribbon.cpp
├── qribbon.h
├── qribbon.qrc
├── qribbon_global.h
├── qribbonbutton.cpp
├── qribbonbutton.h
├── qribbonsection.cpp
├── qribbonsection.h
├── qribbontest.cpp
├── qribbontest.h
└── test.svg
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 | *.obj
6 |
7 | # Precompiled Headers
8 | *.gch
9 | *.pch
10 |
11 | # Compiled Dynamic libraries
12 | *.so
13 | *.dylib
14 | *.dll
15 |
16 | # Fortran module files
17 | *.mod
18 |
19 | # Compiled Static libraries
20 | *.lai
21 | *.la
22 | *.a
23 | *.lib
24 |
25 | # Executables
26 | *.exe
27 | *.out
28 | *.app
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
167 |
--------------------------------------------------------------------------------
/QRibbon.pro:
--------------------------------------------------------------------------------
1 | QT += widgets
2 |
3 | CONFIG(app) {
4 | warning(App config)
5 |
6 | QT += core gui
7 |
8 | TEMPLATE = app
9 | DEFINES += QRIBBON_TEST
10 |
11 | HEADERS = qribbon.h \
12 | qribbon_global.h \
13 | qribbontest.h \
14 | qribbonsection.h \
15 | qribbonbutton.h
16 |
17 | SOURCES = main.cpp \
18 | qribbon.cpp \
19 | qribbonsection.cpp \
20 | qribbonbutton.cpp \
21 | qribbontest.cpp
22 |
23 | INCLUDEPATH += "C:\Program Files (x86)\Visual Leak Detector\include"
24 | LIBS += -L"C:\Program Files (x86)\Visual Leak Detector\lib\win32" -lvld
25 |
26 | TARGET = qribbontest
27 |
28 | } else {
29 | warning(Lib config)
30 |
31 | CONFIG(installd) {
32 | TARGET = QRibbond
33 | } else {
34 | TARGET = QRibbon
35 | }
36 |
37 | TEMPLATE = lib
38 | DEFINES += QRIBBON_LIBRARY
39 |
40 | HEADERS = \
41 | qribbon.h \
42 | qribbon_global.h \
43 | qribbonsection.h \
44 | qribbonbutton.h \
45 |
46 | SOURCES = \
47 | qribbon.cpp \
48 | qribbonsection.cpp \
49 | qribbonbutton.cpp
50 |
51 | target.path = ../lib
52 | INSTALLS += target
53 |
54 | mylib.CONFIG = no_check_exists
55 | mylib.files = release/QRibbonPlugin.lib release/QRibbonPlugin.dll
56 | mylib.path =../lib
57 | INSTALLS += mylib
58 |
59 | warning($$INSTALLS)
60 |
61 | mylibd.CONFIG = no_check_exists
62 | mylibd.files = debug/QRibbonPlugind.lib debug/QRibbonPlugind.dll
63 | mylibd.path =../lib
64 | INSTALLS += mylibd
65 |
66 |
67 | DISTFILES +=
68 | OTHER_FILES +=
69 |
70 | header_files.files = $$HEADERS
71 | header_files.path = ../include
72 | INSTALLS += header_files
73 |
74 | warning($$INSTALLS)
75 | }
76 |
77 | RESOURCES += \
78 | qribbon.qrc
79 |
80 | DISTFILES += \
81 | memorycheck.bat \
82 | LICENSE \
83 | README.md
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/QRibbon.pro.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ProjectExplorer.Project.ActiveTarget
7 | 0
8 |
9 |
10 | ProjectExplorer.Project.EditorSettings
11 |
12 | true
13 | false
14 | true
15 |
16 | Cpp
17 |
18 | CppGlobal
19 |
20 |
21 |
22 | QmlJS
23 |
24 | QmlJSGlobal
25 |
26 |
27 | 2
28 | UTF-8
29 | false
30 | 4
31 | false
32 | true
33 | 1
34 | true
35 | 0
36 | true
37 | 0
38 | 8
39 | true
40 | 1
41 | true
42 | true
43 | true
44 | false
45 |
46 |
47 |
48 | ProjectExplorer.Project.PluginSettings
49 |
50 |
51 |
52 | ProjectExplorer.Project.Target.0
53 |
54 | Desktop Qt 5.2.1 MSVC2010 32bit
55 | Desktop Qt 5.2.1 MSVC2010 32bit
56 | qt.521.win32_msvc2010.essentials_kit
57 | 2
58 | 0
59 | 0
60 |
61 | C:/Users/hans-lokaal/workspace/Qt/build-QRibbon-Desktop_Qt_5_2_1_MSVC2010_32bit-Debug
62 |
63 |
64 | true
65 | qmake
66 |
67 | QtProjectManager.QMakeBuildStep
68 | false
69 | true
70 |
71 | false
72 |
73 |
74 | true
75 | Make
76 |
77 | Qt4ProjectManager.MakeStep
78 |
79 | false
80 |
81 |
82 |
83 | 2
84 | Build
85 |
86 | ProjectExplorer.BuildSteps.Build
87 |
88 |
89 |
90 | true
91 | Make
92 |
93 | Qt4ProjectManager.MakeStep
94 |
95 | true
96 | clean
97 |
98 |
99 | 1
100 | Clean
101 |
102 | ProjectExplorer.BuildSteps.Clean
103 |
104 | 2
105 | false
106 |
107 | Debug
108 |
109 | Qt4ProjectManager.Qt4BuildConfiguration
110 | 2
111 | true
112 |
113 |
114 | C:/Users/hans-lokaal/workspace/Qt/build-QRibbon-Desktop_Qt_5_2_1_MSVC2010_32bit-Release
115 |
116 |
117 | true
118 | qmake
119 |
120 | QtProjectManager.QMakeBuildStep
121 | false
122 | true
123 |
124 | false
125 |
126 |
127 | true
128 | Make
129 |
130 | Qt4ProjectManager.MakeStep
131 |
132 | false
133 |
134 |
135 |
136 | 2
137 | Build
138 |
139 | ProjectExplorer.BuildSteps.Build
140 |
141 |
142 |
143 | true
144 | Make
145 |
146 | Qt4ProjectManager.MakeStep
147 |
148 | true
149 | clean
150 |
151 |
152 | 1
153 | Clean
154 |
155 | ProjectExplorer.BuildSteps.Clean
156 |
157 | 2
158 | false
159 |
160 | Release
161 |
162 | Qt4ProjectManager.Qt4BuildConfiguration
163 | 0
164 | true
165 |
166 |
167 | C:/Users/hans-lokaal/workspace/Qt/build-QRibbon-Desktop_Qt_5_2_1_MSVC2010_32bit-Debug
168 |
169 |
170 | true
171 | qmake
172 |
173 | QtProjectManager.QMakeBuildStep
174 | false
175 | true
176 | "CONFIG+=app"
177 | false
178 |
179 |
180 | true
181 | Make
182 |
183 | Qt4ProjectManager.MakeStep
184 |
185 | false
186 |
187 |
188 |
189 | 2
190 | Build
191 |
192 | ProjectExplorer.BuildSteps.Build
193 |
194 |
195 |
196 | true
197 | Make
198 |
199 | Qt4ProjectManager.MakeStep
200 |
201 | true
202 | clean
203 |
204 |
205 | 1
206 | Clean
207 |
208 | ProjectExplorer.BuildSteps.Clean
209 |
210 | 2
211 | false
212 |
213 | Debug
214 | App
215 | Qt4ProjectManager.Qt4BuildConfiguration
216 | 2
217 | true
218 |
219 |
220 | C:/Users/hans-lokaal/workspace/Qt/build-QRibbon-Desktop_Qt_5_2_1_MSVC2010_32bit-Debug
221 |
222 |
223 | true
224 | qmake
225 |
226 | QtProjectManager.QMakeBuildStep
227 | false
228 | true
229 | "CONFIG+=installd"
230 | false
231 |
232 |
233 | true
234 | Make
235 |
236 | Qt4ProjectManager.MakeStep
237 |
238 | false
239 |
240 |
241 |
242 | 2
243 | Build
244 |
245 | ProjectExplorer.BuildSteps.Build
246 |
247 |
248 |
249 | true
250 | Make
251 |
252 | Qt4ProjectManager.MakeStep
253 |
254 | true
255 | clean
256 |
257 |
258 | 1
259 | Clean
260 |
261 | ProjectExplorer.BuildSteps.Clean
262 |
263 | 2
264 | false
265 |
266 | Debug
267 | installd
268 | Qt4ProjectManager.Qt4BuildConfiguration
269 | 2
270 | true
271 |
272 | 4
273 |
274 |
275 | 0
276 | Deploy
277 |
278 | ProjectExplorer.BuildSteps.Deploy
279 |
280 | 1
281 | Deploy locally
282 |
283 | ProjectExplorer.DefaultDeployConfiguration
284 |
285 | 1
286 |
287 |
288 |
289 | false
290 | false
291 | false
292 | false
293 | true
294 | 0.01
295 | 10
296 | true
297 | 1
298 | 25
299 |
300 | 1
301 | true
302 | false
303 | true
304 | valgrind
305 |
306 | 0
307 | 1
308 | 2
309 | 3
310 | 4
311 | 5
312 | 6
313 | 7
314 | 8
315 | 9
316 | 10
317 | 11
318 | 12
319 | 13
320 | 14
321 |
322 | 2
323 |
324 | QRibbon
325 |
326 | Qt4ProjectManager.Qt4RunConfiguration:C:/Users/hans-lokaal/workspace/Qt/QRibbon/QRibbon.pro
327 |
328 | QRibbon.pro
329 | false
330 | false
331 |
332 | 3768
333 | true
334 | false
335 | false
336 | false
337 | true
338 |
339 | 1
340 |
341 |
342 |
343 | ProjectExplorer.Project.TargetCount
344 | 1
345 |
346 |
347 | ProjectExplorer.Project.Updater.EnvironmentId
348 | {dc7d42c1-cc3e-4936-96b2-722dea22f78b}
349 |
350 |
351 | ProjectExplorer.Project.Updater.FileVersion
352 | 15
353 |
354 |
355 |
--------------------------------------------------------------------------------
/QRibbon.pro.user.18:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | EnvironmentId
7 | {dc7d42c1-cc3e-4936-96b2-722dea22f78b}
8 |
9 |
10 | ProjectExplorer.Project.ActiveTarget
11 | 0
12 |
13 |
14 | ProjectExplorer.Project.EditorSettings
15 |
16 | true
17 | false
18 | true
19 |
20 | Cpp
21 |
22 | CppGlobal
23 |
24 |
25 |
26 | QmlJS
27 |
28 | QmlJSGlobal
29 |
30 |
31 | 2
32 | UTF-8
33 | false
34 | 4
35 | false
36 | 80
37 | true
38 | true
39 | 1
40 | true
41 | false
42 | 0
43 | true
44 | 0
45 | 8
46 | true
47 | 1
48 | true
49 | true
50 | true
51 | false
52 |
53 |
54 |
55 | ProjectExplorer.Project.PluginSettings
56 |
57 |
58 |
59 | ProjectExplorer.Project.Target.0
60 |
61 | Desktop Qt 5.4.2 MSVC2013 32bit
62 | Desktop Qt 5.4.2 MSVC2013 32bit
63 | qt.54.win32_msvc2013_kit
64 | 2
65 | 0
66 | 0
67 |
68 | C:/Users/hans-lokaal/workspace/Qt/build-QRibbon-Desktop_Qt_5_4_2_MSVC2013_32bit-Debug
69 |
70 |
71 | true
72 | qmake
73 |
74 | QtProjectManager.QMakeBuildStep
75 | false
76 | true
77 |
78 | false
79 | false
80 | false
81 |
82 |
83 | true
84 | Make
85 |
86 | Qt4ProjectManager.MakeStep
87 |
88 | false
89 |
90 |
91 |
92 | 2
93 | Build
94 |
95 | ProjectExplorer.BuildSteps.Build
96 |
97 |
98 |
99 | true
100 | Make
101 |
102 | Qt4ProjectManager.MakeStep
103 |
104 | true
105 | clean
106 |
107 |
108 | 1
109 | Clean
110 |
111 | ProjectExplorer.BuildSteps.Clean
112 |
113 | 2
114 | false
115 |
116 | Debug
117 |
118 | Qt4ProjectManager.Qt4BuildConfiguration
119 | 2
120 | true
121 |
122 |
123 | C:/Users/hans-lokaal/workspace/Qt/build-QRibbon-Desktop_Qt_5_4_2_MSVC2013_32bit-Release
124 |
125 |
126 | true
127 | qmake
128 |
129 | QtProjectManager.QMakeBuildStep
130 | false
131 | true
132 |
133 | false
134 | false
135 | false
136 |
137 |
138 | true
139 | Make
140 |
141 | Qt4ProjectManager.MakeStep
142 |
143 | false
144 |
145 |
146 |
147 | 2
148 | Build
149 |
150 | ProjectExplorer.BuildSteps.Build
151 |
152 |
153 |
154 | true
155 | Make
156 |
157 | Qt4ProjectManager.MakeStep
158 |
159 | true
160 | clean
161 |
162 |
163 | 1
164 | Clean
165 |
166 | ProjectExplorer.BuildSteps.Clean
167 |
168 | 2
169 | false
170 |
171 | Release
172 |
173 | Qt4ProjectManager.Qt4BuildConfiguration
174 | 0
175 | true
176 |
177 |
178 | C:/Users/hans-lokaal/workspace/Qt/build-QRibbon-Desktop_Qt_5_4_2_MSVC2013_32bit-App
179 |
180 |
181 | true
182 | qmake
183 |
184 | QtProjectManager.QMakeBuildStep
185 | false
186 | true
187 | "CONFIG+=app"
188 | false
189 | false
190 | false
191 |
192 |
193 | true
194 | Make
195 |
196 | Qt4ProjectManager.MakeStep
197 |
198 | false
199 |
200 |
201 |
202 | 2
203 | Build
204 |
205 | ProjectExplorer.BuildSteps.Build
206 |
207 |
208 |
209 | true
210 | Make
211 |
212 | Qt4ProjectManager.MakeStep
213 |
214 | true
215 | clean
216 |
217 |
218 | 1
219 | Clean
220 |
221 | ProjectExplorer.BuildSteps.Clean
222 |
223 | 2
224 | false
225 |
226 | Debug
227 | App
228 | Qt4ProjectManager.Qt4BuildConfiguration
229 | 2
230 | true
231 |
232 | 3
233 |
234 |
235 | 0
236 | Deploy
237 |
238 | ProjectExplorer.BuildSteps.Deploy
239 |
240 | 1
241 | Deploy locally
242 |
243 | ProjectExplorer.DefaultDeployConfiguration
244 |
245 | 1
246 |
247 |
248 |
249 | false
250 | false
251 | false
252 | false
253 | true
254 | 0.01
255 | 10
256 | true
257 | 1
258 | 25
259 |
260 | 1
261 | true
262 | false
263 | true
264 | valgrind
265 |
266 | 0
267 | 1
268 | 2
269 | 3
270 | 4
271 | 5
272 | 6
273 | 7
274 | 8
275 | 9
276 | 10
277 | 11
278 | 12
279 | 13
280 | 14
281 |
282 | 2
283 |
284 | QRibbon
285 |
286 | Qt4ProjectManager.Qt4RunConfiguration:C:/Users/hans-lokaal/workspace/Qt/QRibbon/QRibbon.pro
287 |
288 | QRibbon.pro
289 | false
290 | false
291 |
292 | 3768
293 | false
294 | true
295 | false
296 | false
297 | true
298 |
299 | 1
300 |
301 |
302 |
303 | ProjectExplorer.Project.TargetCount
304 | 1
305 |
306 |
307 | ProjectExplorer.Project.Updater.FileVersion
308 | 18
309 |
310 |
311 | Version
312 | 18
313 |
314 |
315 |
--------------------------------------------------------------------------------
/QRibbon.pro.user.5cf5531:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | EnvironmentId
7 | {5cf5531b-2336-46e3-945c-a10ed55f9d89}
8 |
9 |
10 | ProjectExplorer.Project.ActiveTarget
11 | 0
12 |
13 |
14 | ProjectExplorer.Project.EditorSettings
15 |
16 | true
17 | false
18 | true
19 |
20 | Cpp
21 |
22 | CppGlobal
23 |
24 |
25 |
26 | QmlJS
27 |
28 | QmlJSGlobal
29 |
30 |
31 | 2
32 | UTF-8
33 | false
34 | 4
35 | false
36 | 80
37 | true
38 | true
39 | 1
40 | true
41 | false
42 | 0
43 | true
44 | 0
45 | 8
46 | true
47 | 1
48 | true
49 | true
50 | true
51 | false
52 |
53 |
54 |
55 | ProjectExplorer.Project.PluginSettings
56 |
57 |
58 |
59 | ProjectExplorer.Project.Target.0
60 |
61 | Desktop Qt 5.4.1 MSVC2013 32bit
62 | Desktop Qt 5.4.1 MSVC2013 32bit
63 | qt.54.win32_msvc2013_kit
64 | 4
65 | 0
66 | 0
67 |
68 | C:/Users/hans/workspace/Qt/build-QRibbon-Desktop_Qt_5_4_1_MSVC2013_32bit-Debug
69 |
70 |
71 | true
72 | qmake
73 |
74 | QtProjectManager.QMakeBuildStep
75 | false
76 | true
77 |
78 | false
79 | false
80 |
81 |
82 | true
83 | Make
84 |
85 | Qt4ProjectManager.MakeStep
86 |
87 | false
88 |
89 |
90 |
91 | 2
92 | Build
93 |
94 | ProjectExplorer.BuildSteps.Build
95 |
96 |
97 |
98 | true
99 | Make
100 |
101 | Qt4ProjectManager.MakeStep
102 |
103 | true
104 | clean
105 |
106 |
107 | 1
108 | Clean
109 |
110 | ProjectExplorer.BuildSteps.Clean
111 |
112 | 2
113 | false
114 |
115 | Debug
116 |
117 | Qt4ProjectManager.Qt4BuildConfiguration
118 | 2
119 | true
120 |
121 |
122 | C:/Users/hans/workspace/Qt/build-QRibbon-Desktop_Qt_5_4_1_MSVC2013_32bit-Release
123 |
124 |
125 | true
126 | qmake
127 |
128 | QtProjectManager.QMakeBuildStep
129 | false
130 | true
131 |
132 | false
133 | false
134 |
135 |
136 | true
137 | Make
138 |
139 | Qt4ProjectManager.MakeStep
140 |
141 | false
142 |
143 |
144 |
145 | 2
146 | Build
147 |
148 | ProjectExplorer.BuildSteps.Build
149 |
150 |
151 |
152 | true
153 | Make
154 |
155 | Qt4ProjectManager.MakeStep
156 |
157 | true
158 | clean
159 |
160 |
161 | 1
162 | Clean
163 |
164 | ProjectExplorer.BuildSteps.Clean
165 |
166 | 2
167 | false
168 |
169 | Release
170 |
171 | Qt4ProjectManager.Qt4BuildConfiguration
172 | 0
173 | true
174 |
175 |
176 | C:/Users/hans/workspace/Qt/build-QRibbon-Desktop_Qt_5_4_1_MSVC2013_32bit-Debug
177 |
178 |
179 | true
180 | qmake
181 |
182 | QtProjectManager.QMakeBuildStep
183 | false
184 | true
185 | "CONFIG+=installd"
186 | false
187 | false
188 |
189 |
190 | true
191 | Make
192 |
193 | Qt4ProjectManager.MakeStep
194 |
195 | false
196 |
197 |
198 |
199 |
200 | true
201 | Make
202 |
203 | Qt4ProjectManager.MakeStep
204 |
205 | false
206 | install
207 |
208 |
209 | 3
210 | Build
211 |
212 | ProjectExplorer.BuildSteps.Build
213 |
214 |
215 |
216 | true
217 | Make
218 |
219 | Qt4ProjectManager.MakeStep
220 |
221 | true
222 | clean
223 |
224 |
225 | 1
226 | Clean
227 |
228 | ProjectExplorer.BuildSteps.Clean
229 |
230 | 2
231 | false
232 |
233 | Debug
234 | Installd
235 | Qt4ProjectManager.Qt4BuildConfiguration
236 | 2
237 | true
238 |
239 |
240 | C:/Users/hans/workspace/Qt/build-QRibbon-Desktop_Qt_5_4_1_MSVC2013_32bit-Release
241 |
242 |
243 | true
244 | qmake
245 |
246 | QtProjectManager.QMakeBuildStep
247 | false
248 | true
249 |
250 | false
251 | false
252 |
253 |
254 | true
255 | Make
256 |
257 | Qt4ProjectManager.MakeStep
258 |
259 | false
260 |
261 |
262 |
263 |
264 | true
265 | Make
266 |
267 | Qt4ProjectManager.MakeStep
268 |
269 | false
270 | install
271 |
272 |
273 | 3
274 | Build
275 |
276 | ProjectExplorer.BuildSteps.Build
277 |
278 |
279 |
280 | true
281 | Make
282 |
283 | Qt4ProjectManager.MakeStep
284 |
285 | true
286 | clean
287 |
288 |
289 | 1
290 | Clean
291 |
292 | ProjectExplorer.BuildSteps.Clean
293 |
294 | 2
295 | false
296 |
297 | Release
298 | Install
299 | Qt4ProjectManager.Qt4BuildConfiguration
300 | 0
301 | true
302 |
303 |
304 | C:/Users/hans/workspace/Qt/build-QRibbon-Desktop_Qt_5_4_1_MSVC2013_32bit-App
305 |
306 |
307 | true
308 | qmake
309 |
310 | QtProjectManager.QMakeBuildStep
311 | false
312 | true
313 | "CONFIG+=app"
314 | false
315 | false
316 |
317 |
318 | true
319 | Make
320 |
321 | Qt4ProjectManager.MakeStep
322 |
323 | false
324 |
325 |
326 |
327 | 2
328 | Build
329 |
330 | ProjectExplorer.BuildSteps.Build
331 |
332 |
333 |
334 | true
335 | Make
336 |
337 | Qt4ProjectManager.MakeStep
338 |
339 | true
340 | clean
341 |
342 |
343 | 1
344 | Clean
345 |
346 | ProjectExplorer.BuildSteps.Clean
347 |
348 | 2
349 | false
350 |
351 | Debug
352 | App
353 | Qt4ProjectManager.Qt4BuildConfiguration
354 | 2
355 | true
356 |
357 | 5
358 |
359 |
360 | 0
361 | Deploy
362 |
363 | ProjectExplorer.BuildSteps.Deploy
364 |
365 | 1
366 | Deploy locally
367 |
368 | ProjectExplorer.DefaultDeployConfiguration
369 |
370 | 1
371 |
372 |
373 |
374 | false
375 | false
376 | false
377 | false
378 | false
379 | 0.01
380 | 10
381 | true
382 | 1
383 | 25
384 |
385 | 0
386 | true
387 | false
388 | false
389 | drmemory
390 |
391 | 0
392 | 1
393 | 2
394 | 3
395 | 4
396 | 5
397 | 6
398 | 7
399 | 8
400 | 9
401 | 10
402 | 11
403 | 12
404 | 13
405 | 14
406 |
407 | 2
408 |
409 | QRibbon
410 |
411 | Qt4ProjectManager.Qt4RunConfiguration:C:/Users/hans/workspace/Qt/QRibbon/QRibbon.pro
412 |
413 | QRibbon.pro
414 | false
415 | false
416 |
417 | 3768
418 | false
419 | true
420 | false
421 | false
422 | true
423 |
424 | 1
425 |
426 |
427 |
428 | ProjectExplorer.Project.TargetCount
429 | 1
430 |
431 |
432 | ProjectExplorer.Project.Updater.FileVersion
433 | 18
434 |
435 |
436 | Version
437 | 18
438 |
439 |
440 |
--------------------------------------------------------------------------------
/QRibbonDetails.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
94 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # QRibbon
2 | A Ribbon Toolbar / Menu for Qt
3 |
--------------------------------------------------------------------------------
/RibbonPoint.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
132 |
--------------------------------------------------------------------------------
/RibbonUp.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
81 |
--------------------------------------------------------------------------------
/main.cpp:
--------------------------------------------------------------------------------
1 | //#include
2 | #include
3 |
4 | #include "qribbontest.h"
5 |
6 | int main(int argc, char *argv[])
7 | {
8 | QApplication app(argc, argv);
9 | app.setOrganizationName("QtProject");
10 | app.setApplicationName("Application Example");
11 | QRibbonTest mainWin;
12 | mainWin.show();
13 | return app.exec();
14 | }
15 |
--------------------------------------------------------------------------------
/memorycheck.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | set PATH=%PATH%;..\lib;C:\Qt\5.4\msvc2013\bin
3 | cd ..\build-QRibbon-Desktop_Qt_5_4_1_MSVC2013_32bit-App\debug
4 | drmemory.exe qribbontest.exe
--------------------------------------------------------------------------------
/qribbon.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4 | ** Contact: http://www.qt-project.org/legal
5 | **
6 | ** This file is part of the examples of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:BSD$
9 | ** You may use this file under the terms of the BSD license as follows:
10 | **
11 | ** "Redistribution and use in source and binary forms, with or without
12 | ** modification, are permitted provided that the following conditions are
13 | ** met:
14 | ** * Redistributions of source code must retain the above copyright
15 | ** notice, this list of conditions and the following disclaimer.
16 | ** * Redistributions in binary form must reproduce the above copyright
17 | ** notice, this list of conditions and the following disclaimer in
18 | ** the documentation and/or other materials provided with the
19 | ** distribution.
20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21 | ** of its contributors may be used to endorse or promote products derived
22 | ** from this software without specific prior written permission.
23 | **
24 | **
25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 | **
37 | ** $QT_END_LICENSE$
38 | **
39 | ****************************************************************************/
40 |
41 | #include
42 |
43 | #include "qribbon.h"
44 | #include "qribbonbutton.h"
45 | #include "qribbonsection.h"
46 |
47 | #include
48 | #include
49 | #include
50 | #include
51 | #include
52 | #include
53 | #include
54 | #include
55 | #include
56 |
57 | QRibbon::QRibbon(QWidget *parent) : QTabWidget(parent)
58 | {
59 | hidden = false;
60 | popup = false;
61 | connect(this, SIGNAL(tabBarClicked(int)), this, SLOT(showRibbon(int)));
62 |
63 | QSizePolicy p = this->sizePolicy();
64 | p.setVerticalPolicy(QSizePolicy::Minimum);
65 | super::setSizePolicy(p);
66 |
67 | up = new QIcon(":/icons/RibbonUp.svg");
68 | point = new QIcon(":/icons/RibbonPoint.svg");
69 |
70 | {
71 | QString sheet = this->styleSheet();
72 | QWidget w;
73 | QColor c = w.palette().color(QPalette::Window);
74 |
75 | sheet.append("QTabWidget::pane { border: 1px solid #c0c0c0;top: -1px;background: "+c.name()+"; }");
76 | sheet.append("QTabBar::tab:!selected { border: 0px;margin: 0px;padding: 8px;background: none; }");
77 | sheet.append("QTabBar::tab:selected { background: " + c.name() + ";padding: 8px; }");
78 | sheet.append("QTabBar::tab { background: "+c.name()+"; border: 1px solid #c0c0c0; margin: 0px; padding: 8px; margin-bottom: -2px; border-bottom: 0px; }");
79 | sheet.append("QTabWidget::tab-bar { left: 3pt; }");
80 | //QMessageBox box;
81 | //box.setText(sheet);
82 | //box.exec();
83 | this->setStyleSheet(sheet);
84 | }
85 | }
86 |
87 | QRibbon::~QRibbon()
88 | {
89 | delete up;
90 | delete point;
91 | }
92 |
93 | QWidget *QRibbon::makeTab(QWidget *widget, int index)
94 | {
95 | QWidget *tab = new QWidget();
96 | QPalette pal(tab->palette());
97 | pal.setColor(QPalette::Background, tab->palette().color(QPalette::Window));
98 | tab->setPalette(pal);
99 | tab->setAutoFillBackground(true);
100 | //tab->setStyleSheet("border: 1px solid black");
101 |
102 | // Our widget is layed out as a grid
103 | QGridLayout *layout = new QGridLayout();
104 | layout->setContentsMargins(0,0,0,0);
105 | layout->setSpacing(0);
106 | tab->setLayout(layout);
107 |
108 | // It will contain a hide button
109 | QPushButton *hide = new QRibbonButton(*up, "", widget);
110 | hide->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
111 | QFont f;
112 | QFontMetrics metrics(f);
113 | QSize is = QSize(metrics.boundingRect("^").width()*2, metrics.boundingRect("^").height()*2);
114 | hide->setIconSize(is);
115 | is = QSize(is.width()*2, is.height());
116 | hide->setMaximumSize(is);
117 | //hide->setFlat(true);
118 |
119 | //QGridLayout *layout = (QGridLayout *) widget->layout();
120 | layout->addWidget(widget,0,0,1,1);
121 | layout->setAlignment(widget, Qt::AlignVertical_Mask | Qt::AlignLeft); //Qt::AlignHorizontal_Mask);
122 | layout->addWidget(hide,0,1,1,1);
123 | layout->setAlignment(hide, Qt::AlignRight | Qt::AlignBottom);
124 |
125 | if (index < 0) {
126 | pins.append(hide);
127 | widgets.append(widget);
128 | } else {
129 | pins.insert(index, hide);
130 | widgets.insert(index, widget);
131 | }
132 |
133 | QObject::connect(hide, SIGNAL(clicked()), this, SLOT(hideShow()));
134 |
135 | return tab;
136 | }
137 |
138 | int QRibbon::addTab(QWidget *widget, const QIcon &icon, const QString &label, const QString &name)
139 | {
140 | if (&name != 0) { widget->setObjectName(name); }
141 | return super::addTab(makeTab(widget), icon, label);
142 | }
143 |
144 | int QRibbon::addTab(QWidget *widget, const QString &label, const QString &name)
145 | {
146 | if (&name != 0) { widget->setObjectName(name); }
147 | return super::addTab(makeTab(widget), label);
148 | }
149 |
150 | int QRibbon::addTab(QWidget *widget, const QString &name)
151 | {
152 | if (&name != 0) { widget->setObjectName(name); }
153 | return super::addTab(makeTab(widget), widget->objectName());
154 | }
155 |
156 | int QRibbon::addDesignerTab(QWidget *widget)
157 | {
158 | return super::addTab(widget,widget->objectName());
159 | }
160 |
161 |
162 | int QRibbon::insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label, const QString &name)
163 | {
164 | if (&name != 0) { widget->setObjectName(name); }
165 | return super::insertTab(index, makeTab(widget), icon, label);
166 | }
167 |
168 | int QRibbon::insertTab(int index, QWidget *widget, const QString &label, const QString &name)
169 | {
170 | if (&name != 0) { widget->setObjectName(name); }
171 | return super::insertTab(index, makeTab(widget), label);
172 | }
173 |
174 | int QRibbon::insertTab(int index, QWidget *widget, const QString &name)
175 | {
176 | if (&name != 0) { widget->setObjectName(name); }
177 | return super::insertTab(index, makeTab(widget), widget->objectName());
178 | }
179 |
180 | int QRibbon::insertDesignerTab(int index, QWidget *widget)
181 | {
182 | return super::insertTab(index, widget, widget->objectName());
183 | }
184 |
185 |
186 | QWidget *QRibbon::addRibbonTab(const QString & label, const QString & name)
187 | {
188 | QWidget * widget = new QWidget();
189 | QHBoxLayout *hbox = new QHBoxLayout();
190 | hbox->setContentsMargins(0,0,0,0);
191 | hbox->setSpacing(2);
192 | widget->setLayout(hbox);
193 | if (&name != 0) { widget->setObjectName(name); }
194 | this->addTab(widget, label, widget->objectName());
195 | return widget;
196 | }
197 |
198 | void QRibbon::setCurrentIndex(int index)
199 | {
200 | super::setCurrentIndex(index);
201 | emit currentIndexChanged(index);
202 | }
203 |
204 | void QRibbon::setRibbonVisible(bool visible) {
205 | hidden = !visible;
206 | emit ribbonVisibilityChanged(visible);
207 | }
208 |
209 | QSize QRibbon::minimumSizeHint() const
210 | {
211 | return (hidden) ? currentSize : super::minimumSizeHint();
212 | }
213 |
214 | QSize QRibbon::sizeHint() const
215 | {
216 | return (hidden) ? currentSize : super::sizeHint();
217 | }
218 |
219 | void QRibbon::hideShow()
220 | {
221 | if (!hidden) {
222 | prevSize = this->size();
223 | int i;
224 | for(i = 0; i < this->count(); i++) {
225 | QWidget *page = this->widget(i);
226 | page->setVisible(false);
227 | pins[i]->setIcon(*point);
228 | }
229 | QSize newSize(prevSize.width(), this->tabBar()->size().height());
230 | currentSize = newSize;
231 | this->updateGeometry();
232 | setRibbonVisible(false);
233 | popup = true;
234 | } else {
235 | int i;
236 | for(i = 0; i < this->count(); i++) {
237 | QWidget *page = this->widget(i);
238 | page->setVisible(true);
239 | pins[i]->setIcon(*up);
240 | }
241 | currentSize = prevSize;
242 | this->updateGeometry();
243 | setRibbonVisible(true);
244 | popup = false;
245 | }
246 |
247 | }
248 |
249 | void QRibbon::showRibbon(int page)
250 | {
251 | if (hidden) {
252 | if (page == this->currentIndex() && popup) {
253 | popup = false;
254 | currentSize = prevSize;
255 | this->updateGeometry();
256 | int i;
257 | for(i = 0; i < this->count(); i++) {
258 | QWidget *page = this->widget(i);
259 | page->setVisible(true);
260 | }
261 | } else {
262 | int i;
263 | for(i = 0; i < this->count(); i++) {
264 | QWidget *page = this->widget(i);
265 | page->setVisible(false);
266 | }
267 | QSize newSize(prevSize.width(), this->tabBar()->size().height());
268 | currentSize = newSize;
269 | this->updateGeometry();
270 | popup = true;
271 | }
272 | }
273 | if (page != this->currentIndex()) {
274 | emit currentIndexChanged(page);
275 | }
276 | }
277 |
278 | QWidget *QRibbon::tab(int index) const
279 | {
280 | return super::widget(index);
281 | //return widgets[index];
282 | }
283 |
284 | QRibbonSection *QRibbon::section(const QString & name) const
285 | {
286 | int i;
287 | for(i = 0; i < widgets.size(); i++) {
288 | QWidget *widget = widgets[i];
289 | QObjectList list = widget->children();
290 | int j;
291 | for(j = 0; j < list.size(); j++) {
292 | QObject *w = list[j];
293 | if (_stricmp(w->metaObject()->className(),"QRibbonSection") == 0) {
294 | if (w->objectName() == name) {
295 | return (QRibbonSection *) w;
296 | }
297 | }
298 | }
299 | }
300 | return NULL;
301 | }
302 |
303 | void QRibbon::addSection(const QString &tabName, QRibbonSection *section)
304 | {
305 | int i;
306 | for(i = 0; i < widgets.size(); i++) {
307 | QWidget *w = widgets[i];
308 | if (w->objectName() == tabName) {
309 | QLayout *l = w->layout();
310 | if (!l) {
311 | QHBoxLayout *hb = new QHBoxLayout();
312 | hb->setContentsMargins(0,0,0,0);
313 | hb->setSpacing(2);
314 | w->setLayout(hb);
315 | l = w->layout();
316 | }
317 | l->addWidget(section);
318 | i = widgets.size() - 1;
319 | }
320 | }
321 | }
322 |
323 | QRibbonSection *QRibbon::section(int tabIndex, int sectionIndex) const
324 | {
325 | QWidget *widget = (tabIndex >= 0 && tabIndex children();
328 | QObject *w = (sectionIndex >= 0 && sectionIndex < list.size()) ? list[sectionIndex] : NULL;
329 | if (_stricmp(w->metaObject()->className(),"QRibbonSection") == 0) {
330 | return (QRibbonSection *) w;
331 | }
332 | }
333 |
334 | return NULL;
335 | }
336 |
337 | void QRibbon::setTabText(int index, const QString & txt) {
338 | super::setTabText(index, txt);
339 | emit tabTextChanged(index, txt);
340 | }
341 |
342 |
343 |
--------------------------------------------------------------------------------
/qribbon.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4 | ** Contact: http://www.qt-project.org/legal
5 | **
6 | ** This file is part of the examples of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:BSD$
9 | ** You may use this file under the terms of the BSD license as follows:
10 | **
11 | ** "Redistribution and use in source and binary forms, with or without
12 | ** modification, are permitted provided that the following conditions are
13 | ** met:
14 | ** * Redistributions of source code must retain the above copyright
15 | ** notice, this list of conditions and the following disclaimer.
16 | ** * Redistributions in binary form must reproduce the above copyright
17 | ** notice, this list of conditions and the following disclaimer in
18 | ** the documentation and/or other materials provided with the
19 | ** distribution.
20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21 | ** of its contributors may be used to endorse or promote products derived
22 | ** from this software without specific prior written permission.
23 | **
24 | **
25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 | **
37 | ** $QT_END_LICENSE$
38 | **
39 | ****************************************************************************/
40 |
41 | #ifndef QRIBBON_H
42 | #define QRIBBON_H
43 |
44 | #include "qribbon_global.h"
45 | #include
46 | #include
47 | #include
48 |
49 | class QRibbonSection;
50 |
51 | class QRIBBON_EXPORT QRibbon : public QTabWidget
52 | {
53 | Q_OBJECT
54 |
55 | private:
56 | bool hidden, popup;
57 | QSize prevSize, currentSize;
58 | QIcon *up, *point;
59 | QVector pins;
60 | QVector widgets;
61 |
62 | private:
63 | QWidget *makeTab(QWidget *widget, int index = -1);
64 |
65 | protected:
66 | typedef QTabWidget super;
67 | virtual QSize minimumSizeHint() const;
68 | virtual QSize sizeHint() const;
69 |
70 | public:
71 | QRibbon(QWidget *parent = 0);
72 | ~QRibbon();
73 |
74 | public:
75 | int addTab(QWidget *widget, const QIcon &icon, const QString &label, const QString &name = 0);
76 | int addTab(QWidget *widget, const QString &label, const QString &name = 0);
77 | int addTab(QWidget *widget, const QString &name = 0);
78 | int insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label, const QString &name = 0);
79 | int insertTab(int index, QWidget *widget, const QString &label, const QString &name = 0);
80 | int insertTab(int index, QWidget *widget, const QString &name = 0);
81 |
82 | public:
83 | int addDesignerTab(QWidget *widget);
84 | int insertDesignerTab(int index, QWidget *widget);
85 |
86 | public:
87 | QWidget *tab(int index) const;
88 |
89 | public:
90 | QWidget *addRibbonTab(const QString & label, const QString & name = 0);
91 |
92 | void setCurrentIndex(int index);
93 | void setTabText(int index, const QString &txt);
94 |
95 | QRibbonSection *section(int tabIndex, int sectionIndex) const;
96 | QRibbonSection *section(const QString &name) const;
97 |
98 | void addSection(const QString & tabName, QRibbonSection *section);
99 |
100 | signals:
101 | void ribbonVisibilityChanged(bool visible);
102 | void currentIndexChanged(int index);
103 | void tabTextChanged(int index, const QString & txt);
104 |
105 | protected slots:
106 | void setRibbonVisible(bool visible);
107 | void hideShow();
108 | void showRibbon(int page);
109 |
110 | };
111 |
112 | #endif // QRIBBON_H
113 |
--------------------------------------------------------------------------------
/qribbon.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | RibbonUp.svg
4 | RibbonPoint.svg
5 | QRibbonDetails.svg
6 | test.svg
7 |
8 |
9 |
--------------------------------------------------------------------------------
/qribbon_global.h:
--------------------------------------------------------------------------------
1 | #ifndef QRIBBON_GLOBAL_H
2 | #define QRIBBON_GLOBAL_H
3 |
4 | #include
5 |
6 | #if defined(QRIBBON_LIBRARY)
7 | # define QRIBBON_EXPORT Q_DECL_EXPORT
8 | #else
9 | # if defined(QRIBBON_TEST)
10 | # define QRIBBON_EXPORT
11 | # else
12 | # define QRIBBON_EXPORT Q_DECL_IMPORT
13 | # endif
14 | #endif
15 |
16 | #endif // QRIBBON_GLOBAL_H
17 |
18 |
--------------------------------------------------------------------------------
/qribbonbutton.cpp:
--------------------------------------------------------------------------------
1 | #include "qribbonbutton.h"
2 |
3 | #include
4 | #include
5 |
6 | QRibbonButton::QRibbonButton(QWidget *parent) : QPushButton(parent)
7 | {
8 | init(NULL);
9 | }
10 |
11 | QRibbonButton::QRibbonButton(const QString &text, QWidget *parent) : QPushButton(text, parent)
12 | {
13 | init(NULL);
14 | }
15 |
16 | QRibbonButton::QRibbonButton(const QIcon &icon, const QString &text, QWidget *parent)
17 | : QPushButton(icon, text, parent)
18 | {
19 | init(NULL);
20 | }
21 |
22 | QRibbonButton::QRibbonButton(const QIcon &icon, const QString &text, const QString & name, QWidget *parent)
23 | : QPushButton(icon, text, parent)
24 | {
25 | init(&name);
26 | }
27 |
28 |
29 |
30 | static int button_number = 0;
31 |
32 | void QRibbonButton::init(const QString *_name)
33 | {
34 | setFlat(true);
35 | _action = NULL;
36 |
37 | button_number += 1;
38 | QString name;
39 | if (_name == NULL) { // small error here
40 | name = name.sprintf("%s_%04d", "qribbonbut", button_number);
41 | this->setObjectName(name);
42 | } else {
43 | name = *_name;
44 | }
45 | this->setStyleSheet("#" + name + ":hover { background: #d5e1f2;border: none; }");
46 | }
47 |
48 | void QRibbonButton::setAction(QAction *a) {
49 | _action = a;
50 | }
51 |
52 | QAction *QRibbonButton::getAction() {
53 | return _action;
54 | }
55 |
56 | bool QRibbonButton::event(QEvent *e)
57 | {
58 | /*if(e->type() == QEvent::HoverEnter) {
59 | // setFlat(false);
60 | }
61 |
62 | if(e->type() == QEvent::HoverLeave) {
63 | // setFlat(true);
64 | }*/
65 |
66 | return QPushButton::event(e);
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/qribbonbutton.h:
--------------------------------------------------------------------------------
1 | #ifndef QRIBBONBUTTON_H
2 | #define QRIBBONBUTTON_H
3 |
4 | #include "qribbon_global.h"
5 |
6 | #include
7 |
8 |
9 | class QRIBBON_EXPORT QRibbonButton : public QPushButton
10 | {
11 | private:
12 | void init(const QString *_name);
13 |
14 | public:
15 | QRibbonButton(QWidget *parent);
16 | QRibbonButton(const QString & text, QWidget * parent = 0);
17 | QRibbonButton(const QIcon & icon, const QString & text, QWidget * parent = 0);
18 | QRibbonButton(const QIcon & icon, const QString & text, const QString & name, QWidget * parent = 0);
19 |
20 | public:
21 | void setAction(QAction *a);
22 | QAction *getAction();
23 |
24 | protected:
25 | bool event(QEvent *e);
26 |
27 | private:
28 | QAction *_action;
29 | };
30 |
31 | #endif // QRIBBONBUTTON_H
32 |
--------------------------------------------------------------------------------
/qribbonsection.cpp:
--------------------------------------------------------------------------------
1 | #include "qribbonbutton.h"
2 | #include "qribbonsection.h"
3 |
4 | #include
5 | #include
6 |
7 | QRibbonSection::QRibbonSection(QWidget *parent, const QString &_title, const QString &_name) : QWidget(parent)
8 | {
9 | action = NULL;
10 | col = 0;
11 | row = 0;
12 | colBase = 0;
13 | _index = -1;
14 |
15 | if (&_name) { this->setObjectName(_name); }
16 |
17 | QHBoxLayout *slayout = new QHBoxLayout();
18 | slayout->setContentsMargins(2,0,2,0);
19 | slayout->setSpacing(2);
20 | this->setLayout(slayout);
21 |
22 | //QLabel *lab_line = new QLabel("X", this);
23 | QFrame *line = new QFrame(this);
24 | line->setFrameStyle(QFrame::VLine | QFrame::Plain);
25 | line->setFixedWidth(3);
26 | line->setContentsMargins(0,3,0,5);
27 | line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
28 | QString sheet = line->styleSheet();
29 | sheet.append("QFrame { color: #c0c0c0; }");
30 | line->setStyleSheet(sheet);
31 |
32 | QWidget *wvbox = new QWidget(this);
33 | QVBoxLayout *layout = new QVBoxLayout();
34 | layout->setContentsMargins(0,0,0,0);
35 | layout->setSpacing(0);
36 | wvbox->setLayout(layout);
37 |
38 | buttons = new QWidget(wvbox);
39 | QGridLayout *blayout = new QGridLayout();
40 | blayout->setContentsMargins(0,0,0,0);
41 | blayout->setSpacing(2);
42 | buttons->setLayout(blayout);
43 |
44 | QHBoxLayout *lfooter = new QHBoxLayout();
45 | lfooter->setContentsMargins(0,0,0,0);
46 | QWidget *footer = new QWidget(wvbox);
47 | footer->setLayout(lfooter);
48 |
49 | if (&title == 0) {
50 | title = new QLabel("", footer);
51 | } else {
52 | title = new QLabel(_title, footer);
53 | }
54 | title->setAlignment(Qt::AlignCenter);
55 | QFont titleFont = title->font();
56 | titleFont.setPointSize(titleFont.pointSize()*0.98f);
57 | title->setFont(titleFont);
58 |
59 | {
60 | QIcon *dtl = new QIcon(":/icons/QRibbonDetails.svg");
61 | details = new QRibbonButton(*dtl, "", footer);
62 | delete dtl;
63 | }
64 | details->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
65 | QFont f;
66 | QFontMetrics metrics(f);
67 | QSize is = QSize(metrics.boundingRect("^").width(), metrics.boundingRect("X").height());
68 | is = QSize(is.width()*2, is.height());
69 | details->setIconSize(is);
70 | details->setMaximumSize(is);
71 | details->setVisible(false);
72 | QObject::connect(details, SIGNAL(clicked()), this, SLOT(activateDetails()));
73 |
74 |
75 | lfooter->addWidget(title, 1);
76 | lfooter->addWidget(details);
77 |
78 | layout->addWidget(buttons, 1);
79 | layout->addWidget(footer);
80 |
81 | slayout->addWidget(wvbox, 1);
82 | slayout->addWidget(line, 1);
83 | }
84 |
85 | QRibbonSection::~QRibbonSection()
86 | {
87 | }
88 |
89 | void QRibbonSection::setDetailsAction(QAction *_action)
90 | {
91 | action = _action;
92 | details->setVisible(action != NULL);
93 | }
94 |
95 | void QRibbonSection::activateDetails()
96 | {
97 | if (action) {
98 | action->trigger();
99 | }
100 | }
101 |
102 | void QRibbonSection::activateAction()
103 | {
104 | QAction *a;
105 | QRibbonButton *b = (QRibbonButton *) sender();
106 | if (b) {
107 | a = b->getAction();
108 | if (a) {
109 | a->trigger();
110 | }
111 | }
112 | }
113 |
114 | QWidget *QRibbonSection::widget(int index) {
115 | return _widgets[index];
116 | }
117 |
118 | int QRibbonSection::count() {
119 | return _widgets.size();
120 | }
121 |
122 | int QRibbonSection::currentIndex() {
123 | return _index;
124 | }
125 |
126 | void QRibbonSection::setCurrentIndex(int i) {
127 | _index = i;
128 | }
129 |
130 | void QRibbonSection::addAction(QAction * a, const QString &name)
131 | {
132 | QGridLayout *l = (QGridLayout *) buttons->layout();
133 | QRibbonButton *btn = new QRibbonButton(a->icon(), a->text(), name, buttons);
134 | btn->setAction(a);
135 | connect(btn, SIGNAL(clicked()), this, SLOT(activateAction()));
136 | if (&name != 0) { btn->setObjectName(name); } else { btn->setObjectName(a->objectName()); }
137 | l->addWidget(btn, row, col, 1, 1);
138 | col += 1;
139 | _widgets.append(btn);
140 | }
141 |
142 | void QRibbonSection::addLargeAction(QAction * a, const QString &name)
143 | {
144 | QGridLayout *l = (QGridLayout *) buttons->layout();
145 | QRibbonButton *btn = new QRibbonButton(a->icon(), a->text(), name, buttons);
146 | btn->setAction(a);
147 | connect(btn, SIGNAL(clicked()), this, SLOT(activateAction()));
148 | if (&name != 0) { btn->setObjectName(name); } else { btn->setObjectName(a->objectName()); }
149 | nextColumn();
150 | btn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
151 | btn->setIconSize(QSize(btn->iconSize().width() * 2, btn->iconSize().height() * 2));
152 | l->addWidget(btn, row, col, 2, 2);
153 | col += 2;
154 | _widgets.append(btn);
155 | }
156 |
157 | void QRibbonSection::addWidget(QWidget *w, const QString &name, int colspan)
158 | {
159 | QGridLayout *l = (QGridLayout *) buttons->layout();
160 | if (&name != 0) { w->setObjectName(name); }
161 | l->addWidget(w, row, col, 1, colspan);
162 | col += colspan;
163 | _widgets.append(w);
164 | }
165 |
166 | void QRibbonSection::addLargeWidget(QWidget *w, const QString &name)
167 | {
168 | QGridLayout *l = (QGridLayout *) buttons->layout();
169 | if (&name != 0) { w->setObjectName(name); }
170 | nextColumn();
171 | l->addWidget(w, row, col, 2, 2);
172 | col += 2;
173 | _widgets.append(w);
174 | }
175 |
176 | void QRibbonSection::nextColumn() {
177 | QGridLayout *l = (QGridLayout *) buttons->layout();
178 | colBase = l->columnCount();
179 | col = colBase;
180 | row = 0;
181 | }
182 |
183 | void QRibbonSection::nextRow() {
184 | row += 1;
185 | col = colBase;
186 | }
187 |
188 | void QRibbonSection::setTitle(const QString &_title)
189 | {
190 | title->setText(_title);
191 | }
192 |
193 |
--------------------------------------------------------------------------------
/qribbonsection.h:
--------------------------------------------------------------------------------
1 | #ifndef QRIBBONSECTION_H
2 | #define QRIBBONSECTION_H
3 |
4 | #include "qribbon_global.h"
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | class QRIBBON_EXPORT QRibbonSection : public QWidget
12 | {
13 | Q_OBJECT
14 |
15 | public:
16 | QRibbonSection(QWidget *parent = 0, const QString &title = 0, const QString &name = 0);
17 | ~QRibbonSection();
18 |
19 | private:
20 | QWidget *buttons;
21 | QLabel *title;
22 | QPushButton *details;
23 | QAction *action;
24 |
25 | int row;
26 | int col;
27 | int colBase;
28 |
29 | QVector _widgets;
30 | int _index;
31 |
32 | public:
33 | void setDetailsAction(QAction * action);
34 |
35 | public slots:
36 | void activateDetails();
37 | void activateAction();
38 |
39 | public:
40 | void addAction(QAction * btn, const QString & name = 0);
41 | void addLargeAction(QAction * btn, const QString & name = 0);
42 |
43 | void addLargeWidget(QWidget *w, const QString &name);
44 | void addWidget(QWidget *w, const QString & name = 0, int colspan = 1);
45 |
46 | void nextRow();
47 | void nextColumn();
48 |
49 | public:
50 | QWidget *widget(int index);
51 | int count();
52 | void setCurrentIndex(int index);
53 | int currentIndex();
54 |
55 | public:
56 | void setTitle(const QString & title);
57 | };
58 |
59 | #endif // QRIBBONSECTION_H
60 |
--------------------------------------------------------------------------------
/qribbontest.cpp:
--------------------------------------------------------------------------------
1 | #include "qribbonsection.h"
2 | #include "qribbontest.h"
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include "qribbon.h"
10 | #include
11 |
12 | QRibbonTest::QRibbonTest()
13 | {
14 | QPlainTextEdit *textEdit = new QPlainTextEdit;
15 | textEdit->insertPlainText("Hallo allemaal!\n\nDit is een tekst!");
16 | textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
17 | QWidget *widget = new QWidget(this);
18 | QVBoxLayout *layout = new QVBoxLayout();
19 | widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
20 | layout->setContentsMargins(0,0,0,0);
21 | layout->setSpacing(0);
22 |
23 | QPushButton *b1 = new QPushButton("Hi!", this);
24 | b1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
25 | QPushButton *b2 = new QPushButton("Hallo", this);
26 | connect(b1, SIGNAL(clicked()), this, SLOT(action()));
27 | connect(b2, SIGNAL(clicked()), this, SLOT(action()));
28 |
29 | QRibbon *ribbon = new QRibbon(this);
30 | QWidget* tab = ribbon->addRibbonTab("Start", "start");
31 |
32 | QRibbonSection *one = new QRibbonSection(tab, "Section One", "one");
33 | one->addWidget(b1, "b1");
34 | one->addWidget(b2, "b2");
35 |
36 | one->nextRow();
37 | QAction *a1 = new QAction(QIcon(":/icons/test.svg"), "&Test", one);
38 | one->addAction(a1, "a1");
39 | connect(a1, SIGNAL(triggered()), this, SLOT(action()));
40 |
41 | QAction *a2 = new QAction(QIcon(":/icons/test.svg"), "", one);
42 | one->addLargeAction(a2, "a2");
43 | connect(a2, SIGNAL(triggered()), this, SLOT(action()));
44 |
45 | QRibbonSection *two = new QRibbonSection(tab, "Section two", "two");
46 | QAction *aa = new QAction(QIcon(":/icons/test.svg"), "", two);
47 | aa->setObjectName("aa");
48 | connect(aa, SIGNAL(triggered()), this, SLOT(action()));
49 | two->addLargeAction(aa, "aa");
50 | QAction *bb = new QAction(QIcon(":/icons/RibbonPoint.svg"), "", two);
51 | bb->setObjectName("bb");
52 | connect(bb, SIGNAL(triggered()), this, SLOT(action()));
53 | two->addLargeAction(bb, "bb");
54 | QAction *det = new QAction(two);
55 | two->setDetailsAction(det);
56 |
57 | ribbon->addSection("start", one);
58 | ribbon->addSection("start", two);
59 |
60 | QWidget *tab2 = new QWidget();
61 | ribbon->addTab(tab2, "Tab 2", "tab2");
62 | QRibbonSection *three = new QRibbonSection(tab2, "Section 3", "three");
63 | QAction *a3 = new QAction(QIcon(":/icons/QRibbonDetails.svg"), "", three);
64 | connect(a3, SIGNAL(triggered()), this, SLOT(action()));
65 | QComboBox *cbox = new QComboBox();
66 | cbox->addItem("hi");
67 | cbox->addItem("hoi");
68 | cbox->addItem("jae");
69 | three->addWidget(cbox, "cbox", 2);
70 | QAction *a4 = new QAction(QIcon(":/icons/test.svg"), "", three);
71 | connect(a4, SIGNAL(triggered()), this, SLOT(action()));
72 | three->nextRow();
73 | three->addAction(a4, "a4");
74 | three->addWidget(new QLabel("HI"), "");
75 | three->addLargeAction(a3, "a3");
76 |
77 |
78 | ribbon->addSection("tab2", three);
79 | connect(ribbon,SIGNAL(currentIndexChanged(int)),this,SLOT(indexChanged(int)));
80 |
81 |
82 | layout->addWidget(ribbon);
83 |
84 | layout->addWidget(textEdit);
85 | widget->setLayout(layout);
86 | setCentralWidget(widget);
87 |
88 | //this->setWindowFlags(Qt::FramelessWindowHint);
89 | }
90 |
91 | QRibbonTest::~QRibbonTest()
92 | {
93 |
94 | }
95 |
96 | void QRibbonTest::indexChanged(int tab) {
97 | printf("current tab = %d\n", tab);
98 | fflush(stdout);
99 | }
100 |
101 | void QRibbonTest::action() {
102 | QAction *a = (QAction *) sender();
103 | printf("action = %p\n",a);
104 | if (a->objectName() == "bb") {
105 | printf("JE!\n");
106 | QApplication::quit();
107 | }
108 | fflush(stdout);
109 | }
110 |
--------------------------------------------------------------------------------
/qribbontest.h:
--------------------------------------------------------------------------------
1 | #ifndef QRIBBONTEST_H
2 | #define QRIBBONTEST_H
3 |
4 | #include
5 |
6 | class QRibbonTest : public QMainWindow
7 | {
8 | Q_OBJECT
9 |
10 | public slots:
11 | void action();
12 | void indexChanged(int tab);
13 |
14 | public:
15 | QRibbonTest();
16 | ~QRibbonTest();
17 | };
18 |
19 | #endif // QRIBBONTEST_H
20 |
--------------------------------------------------------------------------------
/test.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
143 |
--------------------------------------------------------------------------------