Codebase list kcolorpicker / 04af708
New upstream version 0.1.4 Boyuan Yang 3 years ago
16 changed file(s) with 172 addition(s) and 347 deletion(s). Raw diff Collapse all Expand all
33 dist: trusty
44
55 before_install:
6 - sudo add-apt-repository ppa:beineri/opt-qt562-trusty -y
6 - sudo add-apt-repository ppa:beineri/opt-qt594-trusty -y
77 - sudo apt-get update -qq
88
99 install:
10 - sudo apt-get -y install qt56base
10 - sudo apt-get -y install qt59base
1111 - source /opt/qt*/bin/qt*-env.sh
1212
1313 jobs:
00 cmake_minimum_required(VERSION 3.5)
1 project(kColorPicker LANGUAGES CXX VERSION 0.1.1)
1 project(kColorPicker LANGUAGES CXX VERSION 0.1.4)
22
3 set(QT_MIN_VERSION "5.6.1")
3 set(QT_MIN_VERSION "5.9.4")
44
55 set(CMAKE_CXX_STANDARD 11)
66 set(CMAKE_CXX_STANDARD_REQUIRED ON)
1212 option(BUILD_TESTS "Build Unit Tests" OFF)
1313 option(BUILD_EXAMPLE "Build Example Application" ON)
1414
15 find_package(Qt5 ${QT_MIN_VERSION} REQUIRED Widgets Test)
15 find_package(Qt5 ${QT_MIN_VERSION} REQUIRED Widgets)
1616
1717 include(GNUInstallDirs)
1818 include(FeatureSummary)
2424 endif (BUILD_EXAMPLE)
2525
2626 if (BUILD_TESTS)
27 find_package(Qt5 ${QT_MIN_VERSION} REQUIRED Test)
2728 enable_testing()
2829 add_subdirectory(tests)
2930 endif (BUILD_TESTS)
+126
-300
LICENSE less more
0 GNU GENERAL PUBLIC LICENSE
1 Version 2, June 1991
0 GNU LESSER GENERAL PUBLIC LICENSE
1 Version 3, 29 June 2007
22
3 Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
4 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
54 Everyone is permitted to copy and distribute verbatim copies
65 of this license document, but changing it is not allowed.
76
8 Preamble
97
10 The licenses for most software are designed to take away your
11 freedom to share and change it. By contrast, the GNU General Public
12 License is intended to guarantee your freedom to share and change free
13 software--to make sure the software is free for all its users. This
14 General Public License applies to most of the Free Software
15 Foundation's software and to any other program whose authors commit to
16 using it. (Some other Free Software Foundation software is covered by
17 the GNU Lesser General Public License instead.) You can apply it to
18 your programs, too.
8 This version of the GNU Lesser General Public License incorporates
9 the terms and conditions of version 3 of the GNU General Public
10 License, supplemented by the additional permissions listed below.
1911
20 When we speak of free software, we are referring to freedom, not
21 price. Our General Public Licenses are designed to make sure that you
22 have the freedom to distribute copies of free software (and charge for
23 this service if you wish), that you receive source code or can get it
24 if you want it, that you can change the software or use pieces of it
25 in new free programs; and that you know you can do these things.
12 0. Additional Definitions.
2613
27 To protect your rights, we need to make restrictions that forbid
28 anyone to deny you these rights or to ask you to surrender the rights.
29 These restrictions translate to certain responsibilities for you if you
30 distribute copies of the software, or if you modify it.
14 As used herein, "this License" refers to version 3 of the GNU Lesser
15 General Public License, and the "GNU GPL" refers to version 3 of the GNU
16 General Public License.
3117
32 For example, if you distribute copies of such a program, whether
33 gratis or for a fee, you must give the recipients all the rights that
34 you have. You must make sure that they, too, receive or can get the
35 source code. And you must show them these terms so they know their
36 rights.
18 "The Library" refers to a covered work governed by this License,
19 other than an Application or a Combined Work as defined below.
3720
38 We protect your rights with two steps: (1) copyright the software, and
39 (2) offer you this license which gives you legal permission to copy,
40 distribute and/or modify the software.
21 An "Application" is any work that makes use of an interface provided
22 by the Library, but which is not otherwise based on the Library.
23 Defining a subclass of a class defined by the Library is deemed a mode
24 of using an interface provided by the Library.
4125
42 Also, for each author's protection and ours, we want to make certain
43 that everyone understands that there is no warranty for this free
44 software. If the software is modified by someone else and passed on, we
45 want its recipients to know that what they have is not the original, so
46 that any problems introduced by others will not reflect on the original
47 authors' reputations.
26 A "Combined Work" is a work produced by combining or linking an
27 Application with the Library. The particular version of the Library
28 with which the Combined Work was made is also called the "Linked
29 Version".
4830
49 Finally, any free program is threatened constantly by software
50 patents. We wish to avoid the danger that redistributors of a free
51 program will individually obtain patent licenses, in effect making the
52 program proprietary. To prevent this, we have made it clear that any
53 patent must be licensed for everyone's free use or not licensed at all.
31 The "Minimal Corresponding Source" for a Combined Work means the
32 Corresponding Source for the Combined Work, excluding any source code
33 for portions of the Combined Work that, considered in isolation, are
34 based on the Application, and not on the Linked Version.
5435
55 The precise terms and conditions for copying, distribution and
56 modification follow.
36 The "Corresponding Application Code" for a Combined Work means the
37 object code and/or source code for the Application, including any data
38 and utility programs needed for reproducing the Combined Work from the
39 Application, but excluding the System Libraries of the Combined Work.
5740
58 GNU GENERAL PUBLIC LICENSE
59 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
41 1. Exception to Section 3 of the GNU GPL.
6042
61 0. This License applies to any program or other work which contains
62 a notice placed by the copyright holder saying it may be distributed
63 under the terms of this General Public License. The "Program", below,
64 refers to any such program or work, and a "work based on the Program"
65 means either the Program or any derivative work under copyright law:
66 that is to say, a work containing the Program or a portion of it,
67 either verbatim or with modifications and/or translated into another
68 language. (Hereinafter, translation is included without limitation in
69 the term "modification".) Each licensee is addressed as "you".
43 You may convey a covered work under sections 3 and 4 of this License
44 without being bound by section 3 of the GNU GPL.
7045
71 Activities other than copying, distribution and modification are not
72 covered by this License; they are outside its scope. The act of
73 running the Program is not restricted, and the output from the Program
74 is covered only if its contents constitute a work based on the
75 Program (independent of having been made by running the Program).
76 Whether that is true depends on what the Program does.
46 2. Conveying Modified Versions.
7747
78 1. You may copy and distribute verbatim copies of the Program's
79 source code as you receive it, in any medium, provided that you
80 conspicuously and appropriately publish on each copy an appropriate
81 copyright notice and disclaimer of warranty; keep intact all the
82 notices that refer to this License and to the absence of any warranty;
83 and give any other recipients of the Program a copy of this License
84 along with the Program.
48 If you modify a copy of the Library, and, in your modifications, a
49 facility refers to a function or data to be supplied by an Application
50 that uses the facility (other than as an argument passed when the
51 facility is invoked), then you may convey a copy of the modified
52 version:
8553
86 You may charge a fee for the physical act of transferring a copy, and
87 you may at your option offer warranty protection in exchange for a fee.
54 a) under this License, provided that you make a good faith effort to
55 ensure that, in the event an Application does not supply the
56 function or data, the facility still operates, and performs
57 whatever part of its purpose remains meaningful, or
8858
89 2. You may modify your copy or copies of the Program or any portion
90 of it, thus forming a work based on the Program, and copy and
91 distribute such modifications or work under the terms of Section 1
92 above, provided that you also meet all of these conditions:
59 b) under the GNU GPL, with none of the additional permissions of
60 this License applicable to that copy.
9361
94 a) You must cause the modified files to carry prominent notices
95 stating that you changed the files and the date of any change.
62 3. Object Code Incorporating Material from Library Header Files.
9663
97 b) You must cause any work that you distribute or publish, that in
98 whole or in part contains or is derived from the Program or any
99 part thereof, to be licensed as a whole at no charge to all third
100 parties under the terms of this License.
64 The object code form of an Application may incorporate material from
65 a header file that is part of the Library. You may convey such object
66 code under terms of your choice, provided that, if the incorporated
67 material is not limited to numerical parameters, data structure
68 layouts and accessors, or small macros, inline functions and templates
69 (ten or fewer lines in length), you do both of the following:
10170
102 c) If the modified program normally reads commands interactively
103 when run, you must cause it, when started running for such
104 interactive use in the most ordinary way, to print or display an
105 announcement including an appropriate copyright notice and a
106 notice that there is no warranty (or else, saying that you provide
107 a warranty) and that users may redistribute the program under
108 these conditions, and telling the user how to view a copy of this
109 License. (Exception: if the Program itself is interactive but
110 does not normally print such an announcement, your work based on
111 the Program is not required to print an announcement.)
71 a) Give prominent notice with each copy of the object code that the
72 Library is used in it and that the Library and its use are
73 covered by this License.
11274
113 These requirements apply to the modified work as a whole. If
114 identifiable sections of that work are not derived from the Program,
115 and can be reasonably considered independent and separate works in
116 themselves, then this License, and its terms, do not apply to those
117 sections when you distribute them as separate works. But when you
118 distribute the same sections as part of a whole which is a work based
119 on the Program, the distribution of the whole must be on the terms of
120 this License, whose permissions for other licensees extend to the
121 entire whole, and thus to each and every part regardless of who wrote it.
75 b) Accompany the object code with a copy of the GNU GPL and this license
76 document.
12277
123 Thus, it is not the intent of this section to claim rights or contest
124 your rights to work written entirely by you; rather, the intent is to
125 exercise the right to control the distribution of derivative or
126 collective works based on the Program.
78 4. Combined Works.
12779
128 In addition, mere aggregation of another work not based on the Program
129 with the Program (or with a work based on the Program) on a volume of
130 a storage or distribution medium does not bring the other work under
131 the scope of this License.
80 You may convey a Combined Work under terms of your choice that,
81 taken together, effectively do not restrict modification of the
82 portions of the Library contained in the Combined Work and reverse
83 engineering for debugging such modifications, if you also do each of
84 the following:
13285
133 3. You may copy and distribute the Program (or a work based on it,
134 under Section 2) in object code or executable form under the terms of
135 Sections 1 and 2 above provided that you also do one of the following:
86 a) Give prominent notice with each copy of the Combined Work that
87 the Library is used in it and that the Library and its use are
88 covered by this License.
13689
137 a) Accompany it with the complete corresponding machine-readable
138 source code, which must be distributed under the terms of Sections
139 1 and 2 above on a medium customarily used for software interchange; or,
90 b) Accompany the Combined Work with a copy of the GNU GPL and this license
91 document.
14092
141 b) Accompany it with a written offer, valid for at least three
142 years, to give any third party, for a charge no more than your
143 cost of physically performing source distribution, a complete
144 machine-readable copy of the corresponding source code, to be
145 distributed under the terms of Sections 1 and 2 above on a medium
146 customarily used for software interchange; or,
93 c) For a Combined Work that displays copyright notices during
94 execution, include the copyright notice for the Library among
95 these notices, as well as a reference directing the user to the
96 copies of the GNU GPL and this license document.
14797
148 c) Accompany it with the information you received as to the offer
149 to distribute corresponding source code. (This alternative is
150 allowed only for noncommercial distribution and only if you
151 received the program in object code or executable form with such
152 an offer, in accord with Subsection b above.)
98 d) Do one of the following:
15399
154 The source code for a work means the preferred form of the work for
155 making modifications to it. For an executable work, complete source
156 code means all the source code for all modules it contains, plus any
157 associated interface definition files, plus the scripts used to
158 control compilation and installation of the executable. However, as a
159 special exception, the source code distributed need not include
160 anything that is normally distributed (in either source or binary
161 form) with the major components (compiler, kernel, and so on) of the
162 operating system on which the executable runs, unless that component
163 itself accompanies the executable.
100 0) Convey the Minimal Corresponding Source under the terms of this
101 License, and the Corresponding Application Code in a form
102 suitable for, and under terms that permit, the user to
103 recombine or relink the Application with a modified version of
104 the Linked Version to produce a modified Combined Work, in the
105 manner specified by section 6 of the GNU GPL for conveying
106 Corresponding Source.
164107
165 If distribution of executable or object code is made by offering
166 access to copy from a designated place, then offering equivalent
167 access to copy the source code from the same place counts as
168 distribution of the source code, even though third parties are not
169 compelled to copy the source along with the object code.
108 1) Use a suitable shared library mechanism for linking with the
109 Library. A suitable mechanism is one that (a) uses at run time
110 a copy of the Library already present on the user's computer
111 system, and (b) will operate properly with a modified version
112 of the Library that is interface-compatible with the Linked
113 Version.
170114
171 4. You may not copy, modify, sublicense, or distribute the Program
172 except as expressly provided under this License. Any attempt
173 otherwise to copy, modify, sublicense or distribute the Program is
174 void, and will automatically terminate your rights under this License.
175 However, parties who have received copies, or rights, from you under
176 this License will not have their licenses terminated so long as such
177 parties remain in full compliance.
115 e) Provide Installation Information, but only if you would otherwise
116 be required to provide such information under section 6 of the
117 GNU GPL, and only to the extent that such information is
118 necessary to install and execute a modified version of the
119 Combined Work produced by recombining or relinking the
120 Application with a modified version of the Linked Version. (If
121 you use option 4d0, the Installation Information must accompany
122 the Minimal Corresponding Source and Corresponding Application
123 Code. If you use option 4d1, you must provide the Installation
124 Information in the manner specified by section 6 of the GNU GPL
125 for conveying Corresponding Source.)
178126
179 5. You are not required to accept this License, since you have not
180 signed it. However, nothing else grants you permission to modify or
181 distribute the Program or its derivative works. These actions are
182 prohibited by law if you do not accept this License. Therefore, by
183 modifying or distributing the Program (or any work based on the
184 Program), you indicate your acceptance of this License to do so, and
185 all its terms and conditions for copying, distributing or modifying
186 the Program or works based on it.
127 5. Combined Libraries.
187128
188 6. Each time you redistribute the Program (or any work based on the
189 Program), the recipient automatically receives a license from the
190 original licensor to copy, distribute or modify the Program subject to
191 these terms and conditions. You may not impose any further
192 restrictions on the recipients' exercise of the rights granted herein.
193 You are not responsible for enforcing compliance by third parties to
194 this License.
129 You may place library facilities that are a work based on the
130 Library side by side in a single library together with other library
131 facilities that are not Applications and are not covered by this
132 License, and convey such a combined library under terms of your
133 choice, if you do both of the following:
195134
196 7. If, as a consequence of a court judgment or allegation of patent
197 infringement or for any other reason (not limited to patent issues),
198 conditions are imposed on you (whether by court order, agreement or
199 otherwise) that contradict the conditions of this License, they do not
200 excuse you from the conditions of this License. If you cannot
201 distribute so as to satisfy simultaneously your obligations under this
202 License and any other pertinent obligations, then as a consequence you
203 may not distribute the Program at all. For example, if a patent
204 license would not permit royalty-free redistribution of the Program by
205 all those who receive copies directly or indirectly through you, then
206 the only way you could satisfy both it and this License would be to
207 refrain entirely from distribution of the Program.
135 a) Accompany the combined library with a copy of the same work based
136 on the Library, uncombined with any other library facilities,
137 conveyed under the terms of this License.
208138
209 If any portion of this section is held invalid or unenforceable under
210 any particular circumstance, the balance of the section is intended to
211 apply and the section as a whole is intended to apply in other
212 circumstances.
139 b) Give prominent notice with the combined library that part of it
140 is a work based on the Library, and explaining where to find the
141 accompanying uncombined form of the same work.
213142
214 It is not the purpose of this section to induce you to infringe any
215 patents or other property right claims or to contest validity of any
216 such claims; this section has the sole purpose of protecting the
217 integrity of the free software distribution system, which is
218 implemented by public license practices. Many people have made
219 generous contributions to the wide range of software distributed
220 through that system in reliance on consistent application of that
221 system; it is up to the author/donor to decide if he or she is willing
222 to distribute software through any other system and a licensee cannot
223 impose that choice.
143 6. Revised Versions of the GNU Lesser General Public License.
224144
225 This section is intended to make thoroughly clear what is believed to
226 be a consequence of the rest of this License.
145 The Free Software Foundation may publish revised and/or new versions
146 of the GNU Lesser General Public License from time to time. Such new
147 versions will be similar in spirit to the present version, but may
148 differ in detail to address new problems or concerns.
227149
228 8. If the distribution and/or use of the Program is restricted in
229 certain countries either by patents or by copyrighted interfaces, the
230 original copyright holder who places the Program under this License
231 may add an explicit geographical distribution limitation excluding
232 those countries, so that distribution is permitted only in or among
233 countries not thus excluded. In such case, this License incorporates
234 the limitation as if written in the body of this License.
150 Each version is given a distinguishing version number. If the
151 Library as you received it specifies that a certain numbered version
152 of the GNU Lesser General Public License "or any later version"
153 applies to it, you have the option of following the terms and
154 conditions either of that published version or of any later version
155 published by the Free Software Foundation. If the Library as you
156 received it does not specify a version number of the GNU Lesser
157 General Public License, you may choose any version of the GNU Lesser
158 General Public License ever published by the Free Software Foundation.
235159
236 9. The Free Software Foundation may publish revised and/or new versions
237 of the General Public License from time to time. Such new versions will
238 be similar in spirit to the present version, but may differ in detail to
239 address new problems or concerns.
240
241 Each version is given a distinguishing version number. If the Program
242 specifies a version number of this License which applies to it and "any
243 later version", you have the option of following the terms and conditions
244 either of that version or of any later version published by the Free
245 Software Foundation. If the Program does not specify a version number of
246 this License, you may choose any version ever published by the Free Software
247 Foundation.
248
249 10. If you wish to incorporate parts of the Program into other free
250 programs whose distribution conditions are different, write to the author
251 to ask for permission. For software which is copyrighted by the Free
252 Software Foundation, write to the Free Software Foundation; we sometimes
253 make exceptions for this. Our decision will be guided by the two goals
254 of preserving the free status of all derivatives of our free software and
255 of promoting the sharing and reuse of software generally.
256
257 NO WARRANTY
258
259 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
260 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
261 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
262 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
263 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
264 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
265 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
266 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
267 REPAIR OR CORRECTION.
268
269 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
270 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
271 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
272 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
273 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
274 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
275 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
276 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
277 POSSIBILITY OF SUCH DAMAGES.
278
279 END OF TERMS AND CONDITIONS
280
281 How to Apply These Terms to Your New Programs
282
283 If you develop a new program, and you want it to be of the greatest
284 possible use to the public, the best way to achieve this is to make it
285 free software which everyone can redistribute and change under these terms.
286
287 To do so, attach the following notices to the program. It is safest
288 to attach them to the start of each source file to most effectively
289 convey the exclusion of warranty; and each file should have at least
290 the "copyright" line and a pointer to where the full notice is found.
291
292 {description}
293 Copyright (C) {year} {fullname}
294
295 This program is free software; you can redistribute it and/or modify
296 it under the terms of the GNU General Public License as published by
297 the Free Software Foundation; either version 2 of the License, or
298 (at your option) any later version.
299
300 This program is distributed in the hope that it will be useful,
301 but WITHOUT ANY WARRANTY; without even the implied warranty of
302 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
303 GNU General Public License for more details.
304
305 You should have received a copy of the GNU General Public License along
306 with this program; if not, write to the Free Software Foundation, Inc.,
307 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
308
309 Also add information on how to contact you by electronic and paper mail.
310
311 If the program is interactive, make it output a short notice like this
312 when it starts in an interactive mode:
313
314 Gnomovision version 69, Copyright (C) year name of author
315 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
316 This is free software, and you are welcome to redistribute it
317 under certain conditions; type `show c' for details.
318
319 The hypothetical commands `show w' and `show c' should show the appropriate
320 parts of the General Public License. Of course, the commands you use may
321 be called something other than `show w' and `show c'; they could even be
322 mouse-clicks or menu items--whatever suits your program.
323
324 You should also get your employer (if you work as a programmer) or your
325 school, if any, to sign a "copyright disclaimer" for the program, if
326 necessary. Here is a sample; alter the names:
327
328 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
329 `Gnomovision' (which makes passes at compilers) written by James Hacker.
330
331 {signature of Ty Coon}, 1 April 1989
332 Ty Coon, President of Vice
333
334 This General Public License does not permit incorporating your program into
335 proprietary programs. If your program is a subroutine library, you may
336 consider it more useful to permit linking proprietary applications with the
337 library. If this is what you want to do, use the GNU Lesser General
338 Public License instead of this License.
160 If the Library as you received it specifies that a proxy can decide
161 whether future versions of the GNU Lesser General Public License shall
162 apply, that proxy's public statement of acceptance of any version is
163 permanent authorization for you to choose that version for the
164 Library.
00 # kColorPicker [![Build Status](https://travis-ci.org/ksnip/kColorPicker.svg?branch=master)](https://travis-ci.org/ksnip/kColorPicker)
11 QToolButton with color popup menu with lets you select a color. The popup features a color dialog button which can be used to add custom colors to the popup menu.
22
3 Version 0.1.1
3 Version 0.1.4
44
55 ![kColorPicker](https://i.imgur.com/VkhUvFa.png "kColorPicker")
66
4242 void setFixedSize(int width, int height);
4343 QColor color() const;
4444
45 public slots:
45 public Q_SLOTS:
4646 void setColor(const QColor &color);
4747
48 signals:
48 Q_SIGNALS:
4949 void colorChanged(const QColor &color) const;
5050
5151 private:
5252 QScopedPointer<KColorPickerPrivate> const d_ptr;
5353
54 private slots:
54 private Q_SLOTS:
5555 void setColorIcon(const QColor &color);
5656 void setIconSize(const QSize &size);
5757 void colorSelected(const QColor &color);
5858 };
5959
6060 }
61
6162 #endif //KCOLORPICKER_KCOLORPICKER_H
22 *
33 * This program is free software; you can redistribute it and/or modify
44 * it under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
5 * the Free Software Foundation; either version 3 of the License, or
66 * (at your option) any later version.
77 *
88 * This program is distributed in the hope that it will be useful,
22 *
33 * This program is free software; you can redistribute it and/or modify
44 * it under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
5 * the Free Software Foundation; either version 3 of the License, or
66 * (at your option) any later version.
77 *
88 * This program is distributed in the hope that it will be useful,
22 *
33 * This program is free software; you can redistribute it and/or modify
44 * it under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
5 * the Free Software Foundation; either version 3 of the License, or
66 * (at your option) any later version.
77 *
88 * This program is distributed in the hope that it will be useful,
9999 Q_D(KColorPicker);
100100 auto icon = IconCreator::createIcon(color, d->mIconSize);
101101 setIcon(icon);
102 setToolTip(color.name());
102103 }
103104
104105 //
22 *
33 * This program is free software; you can redistribute it and/or modify
44 * it under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
5 * the Free Software Foundation; either version 3 of the License, or
66 * (at your option) any later version.
77 *
88 * This program is distributed in the hope that it will be useful,
7575
7676 ColorButton *PopupMenu::createButton(const QColor &color)
7777 {
78 auto iconSize = getIconSize();
79 auto icon = IconCreator::createIcon(color, iconSize);
78 auto icon = IconCreator::createIcon(color, QSize(25, 25));
8079 auto button = new ColorButton(icon, color);
8180 return button;
82 }
83 QSize PopupMenu::getIconSize() const
84 { auto xScaleFactor = logicalDpiX() / 96.0;
85 auto yScaleFactor = logicalDpiY() / 96.0;
86 return {static_cast<int>(25 * xScaleFactor), static_cast<int>(25 * yScaleFactor) };
8781 }
8882
8983 void PopupMenu::addColorButton(const QColor &color)
22 *
33 * This program is free software; you can redistribute it and/or modify
44 * it under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
5 * the Free Software Foundation; either version 3 of the License, or
66 * (at your option) any later version.
77 *
88 * This program is distributed in the hope that it will be useful,
5656
5757 private slots:
5858 void colorSelected(const QColor &color);
59 QSize getIconSize() const;
6059 };
6160
6261 } // namespace kColorPicker
22 *
33 * This program is free software; you can redistribute it and/or modify
44 * it under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
5 * the Free Software Foundation; either version 3 of the License, or
66 * (at your option) any later version.
77 *
88 * This program is distributed in the hope that it will be useful,
2020
2121 namespace kColorPicker {
2222
23 AbstractPopupMenuButton::AbstractPopupMenuButton(const QIcon &icon)
23 AbstractPopupMenuButton::AbstractPopupMenuButton(const QIcon &icon) :
24 mHoverColor(QColor(QStringLiteral("#add8e6")))
2425 {
2526 setIcon(icon);
26 setFixedSize(getSizeBasedOnIcon());
27 setFixedSize(iconSize() + QSize(8, 8));
2728 connect(this, &QToolButton::clicked, this, &AbstractPopupMenuButton::buttonClicked);
28 }
29 QSize AbstractPopupMenuButton::getSizeBasedOnIcon() const
30 {
31 auto xScaleFactor = logicalDpiX() / 96.0;
32 auto yScaleFactor = logicalDpiY() / 96.0;
33 return iconSize() + QSize(static_cast<int>(4 * xScaleFactor), static_cast<int>(4 * yScaleFactor));
3429 }
3530
3631 void AbstractPopupMenuButton::paintEvent(QPaintEvent *event)
3833 QPainter painter(this);
3934 QStyleOption styleOption;
4035 styleOption.initFrom(this);
41 auto buttonRect = event->rect();
42 auto selectionRect = QRect(buttonRect.topLeft().x(), buttonRect.topLeft().y(), iconSize().width() + 3, iconSize().height() + 3);
43 auto hoverRect = QRect(buttonRect.topLeft().x() + 1, buttonRect.topLeft().y() + 1, iconSize().width() + 1, iconSize().height() + 1);
36 auto rect = event->rect();
37 auto scaleRatio = devicePixelRatioF();
38 auto buttonRect = QRectF(rect.x() + (2 / scaleRatio), rect.y() + (2 / scaleRatio), rect.width() - 3, rect.height() - 3);
39
40 if(styleOption.state & QStyle::State_MouseOver)
41 {
42 auto defaultPen = painter.pen();
43 auto defaultBrush = painter.brush();
44 painter.setPen(mHoverColor);
45 painter.setBrush(mHoverColor);
46 painter.drawRect(buttonRect);
47 painter.setPen(defaultPen);
48 painter.setBrush(defaultBrush);
49 }
4450
4551 painter.drawPixmap(buttonRect.topLeft() + QPointF(2, 2), icon().pixmap(iconSize()));
4652
4753 if(isChecked()) {
48 painter.drawRect(selectionRect);
49 }
50
51 if(styleOption.state & QStyle::State_MouseOver)
52 {
53 painter.setPen(QColor(QStringLiteral("#add8e6")));
54 painter.drawRect(hoverRect);
54 painter.drawRect(buttonRect);
5555 }
5656 }
5757
22 *
33 * This program is free software; you can redistribute it and/or modify
44 * it under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
5 * the Free Software Foundation; either version 3 of the License, or
66 * (at your option) any later version.
77 *
88 * This program is distributed in the hope that it will be useful,
3838 protected slots:
3939 void paintEvent(QPaintEvent *event) override;
4040 virtual void buttonClicked() = 0;
41 QSize getSizeBasedOnIcon() const;
41
42 private:
43 QColor mHoverColor;
4244 };
4345
4446 } // namespace kColorPicker
22 *
33 * This program is free software; you can redistribute it and/or modify
44 * it under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
5 * the Free Software Foundation; either version 3 of the License, or
66 * (at your option) any later version.
77 *
88 * This program is distributed in the hope that it will be useful,
2323 ColorButton::ColorButton(const QIcon &icon, const QColor &color) : AbstractPopupMenuButton(icon)
2424 {
2525 setCheckable(true);
26 setToolTip(color.name());
2627 mColor = color;
2728 }
2829
22 *
33 * This program is free software; you can redistribute it and/or modify
44 * it under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
5 * the Free Software Foundation; either version 3 of the License, or
66 * (at your option) any later version.
77 *
88 * This program is distributed in the hope that it will be useful,
22 *
33 * This program is free software; you can redistribute it and/or modify
44 * it under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
5 * the Free Software Foundation; either version 3 of the License, or
66 * (at your option) any later version.
77 *
88 * This program is distributed in the hope that it will be useful,
22 *
33 * This program is free software; you can redistribute it and/or modify
44 * it under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
5 * the Free Software Foundation; either version 3 of the License, or
66 * (at your option) any later version.
77 *
88 * This program is distributed in the hope that it will be useful,