├── LICENSE ├── README.md ├── images ├── buttons.png ├── display.png ├── knobs.png ├── lcd.png ├── osc.png ├── pedals.png ├── pluginmode.jpg ├── sliders.png └── zones.png └── source ├── 79-udev-komplete.rules ├── background.png ├── dropgraphicsscene.cpp ├── dropgraphicsscene.h ├── dropgraphicsview.cpp ├── dropgraphicsview.h ├── main.cpp ├── oscdialog.cpp ├── oscdialog.h ├── oscdialog.ui ├── qkontrol.cpp ├── qkontrol.h ├── qkontrol.ico ├── qkontrol.png ├── qkontrol.pro ├── qkontrol.qrc ├── qkontrol.ui └── widgets ├── LICENSE ├── QxtSpanSlider ├── QxtStringSpinBox ├── cpl1.0.txt ├── lgpl-2.1.txt ├── qxtglobal.cpp ├── qxtglobal.h ├── qxtnamespace.h ├── qxtpimpl.h ├── qxtspanslider.cpp ├── qxtspanslider.h ├── qxtspanslider_p.h ├── qxtstringspinbox.cpp └── qxtstringspinbox.h /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 489 | USA 490 | 491 | Also add information on how to contact you by electronic and paper mail. 492 | 493 | You should also get your employer (if you work as a programmer) or your 494 | school, if any, to sign a "copyright disclaimer" for the library, if 495 | necessary. Here is a sample; alter the names: 496 | 497 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 498 | library `Frob' (a library for tweaking knobs) written by James Random 499 | Hacker. 500 | 501 | , 1 April 1990 502 | Ty Coon, President of Vice 503 | 504 | That's all there is to it! 505 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | qKontrol is a Linux / macOS application to configure Native Instruments Komplete Kontrol MK2 keyboards. 2 | 3 | With this software it is possible to configure MIDI CCs assigned to all knobs, buttons, sliders, wheels and pedals, to split the keyboard into zones and to display assignments, CC values and custom images on the two displays. Furthermore, it offers a possibility to communicate with Bitwig Studio (incl. the Linux version) and maybe other DAWs the start and stop playback and recording, to turn on and of looping and the metronome and to fetch and display information about the currently selected track and plugin names as well as the song position. 4 | 5 | ![Device LCDs](https://raw.githubusercontent.com/GoaSkin/qKontrol/master/images/lcd.png) 6 | 7 | qKontrol is an open 3rd party application. It does not depend on any drivers or software provided by Native Instruments 8 | and comes with it's completely own codebase. 9 | 10 | Native Instruments is not responsible for this software in any way. If you need to get support, please ask the community! 11 | 12 | 13 | SYSTEM REQUIREMENTS: 14 | ==================== 15 | 16 | To run this program on Linux, the following dependencies need to be installed: 17 | 18 | - the QT toolkit 19 | - parts of libQXT (included) 20 | - libusb 21 | - libhidapi 22 | 23 | On Ubuntu, Debian and Raspbian, run 'apt-get install libqt5gui5 libqt5test5 libhidapi-libusb0 libusb-1.0' to install all the dependencies! 24 | 25 | The Mac version comes as application bundle which includes all dependencies. There is no additional software required. 26 | 27 | 28 | BUILD INSTRUCTIONS: 29 | =================== 30 | 31 | Ubuntu Linux: 32 | 33 | 1.) install the following packages from the repositories: 34 | 35 | - sudo apt-get install qtbase5-dev-tools qtbase5-dev build-essential libhidapi-dev:amd64 libhidapi-libusb0 libusb-1.0-0-dev 36 | 37 | 2.) dive into the source directory of the program and execute the following commands: 38 | 39 | - /usr/lib/x86_64-linux-gnu/qt5/bin/qmake 40 | - make 41 | - strip qkontrol 42 | 43 | 44 | Mac OS X: 45 | 46 | 1.) install the developer tools from apple using the app store 47 | 48 | 2.) download the QT open source edition from https://www.qt.io/ and install it 49 | 50 | 3.) open a terminal to install libhidapi and libusb using brew: 51 | 52 | - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null 53 | - brew install libusb 54 | - brew install libhidapi 55 | 56 | 4.) start the program "QT creator" from your recently installed QT distribution, open the .pro file from the qkontrol source 57 | and build the program using the menus 58 | 59 | 5.) (optionally) if you want to give your build to others which don't have QT installed theirselves, then locate the tool 60 | 'macdeployqt' from your QT installation. When found, then open a terminal and go into the folder where QT creator placedi 61 | the executable app bundle. Execute /the/folder/where/you/can/find/macdeployqt qkontrol.app. 62 | 63 | Windows: 64 | 65 | 1.) De-install the Komplete Kontrol Software and the NI Host Agent if installed. This software cannot coexist on Windows. 66 | 67 | 2.) Visit https://www.native-instruments.com/de/support/downloads/drivers-other-files/ , download and install the Komplete 68 | Kontrol MK2 drivers. 69 | 70 | 3.) Download ZADIG from https://zadig.akeo.ie/ and start this tool. Research for USB devices and select 71 | "Komplete Kontrol MK2 BD". When selected, replace the driver! This is necessary because we cannot interact with the 72 | original Native Instruments driver. The prior installation is only necessary for MIDI. 73 | 74 | 4.) Visit https://www.msys2.org/ . There, download and install MSYS2. After the installation, 75 | a shell opens and we need to install the dependencies by typing in these commands: 76 | 77 | - pacman -S mingw-w64-x86_64-hidapi 78 | - pacman -S mingw-w64-x86_64-libusb 79 | 80 | 5.) download the QT open source edition from https://www.qt.io/ and install it 81 | 82 | 6.) start the program "QT creator" from your recently installed QT distribution, open the .pro file from the qkontrol source 83 | and build the program using the menus. Use minGW 64 bit as toolchain because others won't work. After the program has been 84 | compiled, it doesn't start through the QT creator. That is normal at this point. Ignore this! 85 | 86 | 7.) Locate the place of your freshly compiled qkontrol.exe and run the program! 87 | It does just list a lot of missing DLLs. Notice the names, locate them on your harddisk and copy them all into this directory. 88 | 89 | 8.) run the program again to check if it works now. 90 | 91 | 9.) if you want to redistribute the compiled windows vesion, it is a good idea to pack all the DLLs into the archive and maybe also the driver you created with ZADIG. 92 | 93 | 94 | KNOWN ISSUES: 95 | ============= 96 | 97 | - On Linux, this program only runs with root permissions because the Linux kernel does not grant any device permissions 98 | to normal users. If you want to use the program as normal user, move the file '79-udev-komplete.rules' into the directory 99 | /etc/udev/rules.d/ and reboot! 100 | 101 | - On macOS, three system services need to be terminated before this program can access the device properly. 102 | The software asks on startup, if it should do it for you. 103 | 104 | - The current CC values are only displayed while a MIDI application is opened which receives MIDI data from the 105 | Komplete Kontrol. This is because the keyboard does only send the HID messages containing the CC values while 106 | MIDI data is beeing requested 107 | 108 | - At last, this software is usable with the Komplete Kontrol MK2 only. This includes all Komplete Kontrol keyboards 109 | with two displays on it. Like the first edition of the Komplete Kontrol keyboards, the models M32, A25, A49 and A61 110 | are also different hardware and not compatible. 111 | 112 | - Sometimes, the left and right key send their key codes continously instead of one time per touch. 113 | 114 | LICENSE: 115 | ======== 116 | 117 | You are permitted to use, modify and distribute this software under the terms and conditions of the LGPL license. 118 | Please read the LICENSE file for more details! LGPL was chosen because some dependencies of this software are 119 | also released under the terms and conditions of the LGPL license. I would really prefer to waive the copyright 120 | protection but that is not possible. 121 | 122 | This software comes with the source code of two 3rd party widgets from the libQXT project. The source files you 123 | will find in the widget/ subdirectory. These widgets, you may also use under the terms and conditions of the 124 | CPL license. For more details, read the LICENSE file in the widgets/ subdirectory! 125 | -------------------------------------------------------------------------------- /images/buttons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoaSkin/qKontrol/b478fd9818c1b01c695722762e6d55a9b2e0228e/images/buttons.png -------------------------------------------------------------------------------- /images/display.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoaSkin/qKontrol/b478fd9818c1b01c695722762e6d55a9b2e0228e/images/display.png -------------------------------------------------------------------------------- /images/knobs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoaSkin/qKontrol/b478fd9818c1b01c695722762e6d55a9b2e0228e/images/knobs.png -------------------------------------------------------------------------------- /images/lcd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoaSkin/qKontrol/b478fd9818c1b01c695722762e6d55a9b2e0228e/images/lcd.png -------------------------------------------------------------------------------- /images/osc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoaSkin/qKontrol/b478fd9818c1b01c695722762e6d55a9b2e0228e/images/osc.png -------------------------------------------------------------------------------- /images/pedals.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoaSkin/qKontrol/b478fd9818c1b01c695722762e6d55a9b2e0228e/images/pedals.png -------------------------------------------------------------------------------- /images/pluginmode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoaSkin/qKontrol/b478fd9818c1b01c695722762e6d55a9b2e0228e/images/pluginmode.jpg -------------------------------------------------------------------------------- /images/sliders.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoaSkin/qKontrol/b478fd9818c1b01c695722762e6d55a9b2e0228e/images/sliders.png -------------------------------------------------------------------------------- /images/zones.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoaSkin/qKontrol/b478fd9818c1b01c695722762e6d55a9b2e0228e/images/zones.png -------------------------------------------------------------------------------- /source/79-udev-komplete.rules: -------------------------------------------------------------------------------- 1 | ATTRS{idVendor}=="17cc", ATTRS{idProduct}=="1610", ACTION=="add", MODE="0777", RUN="/bin/sh -c 'echo -n $id:1.2 > /sys/bus/usb/drivers/usbhid/unbind'" 2 | ATTRS{idVendor}=="17cc", ATTRS{idProduct}=="1620", ACTION=="add", MODE="0777", RUN="/bin/sh -c 'echo -n $id:1.2 > /sys/bus/usb/drivers/usbhid/unbind'" 3 | ATTRS{idVendor}=="17cc", ATTRS{idProduct}=="1630", ACTION=="add", MODE="0777", RUN="/bin/sh -c 'echo -n $id:1.2 > /sys/bus/usb/drivers/usbhid/unbind'" 4 | -------------------------------------------------------------------------------- /source/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoaSkin/qKontrol/b478fd9818c1b01c695722762e6d55a9b2e0228e/source/background.png -------------------------------------------------------------------------------- /source/dropgraphicsscene.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "dropgraphicsscene.h" 4 | 5 | dropGraphicsScene::dropGraphicsScene(QObject* parent) : QGraphicsScene(parent) 6 | {} 7 | 8 | void dropGraphicsScene::dragEnterEvent(QDragEnterEvent *event) 9 | { 10 | event->acceptProposedAction(); 11 | } 12 | 13 | void dropGraphicsScene::dragMoveEvent(QDragMoveEvent *event) 14 | { 15 | // event->acceptProposedAction(); 16 | } 17 | 18 | void dropGraphicsScene::dropEvent(QDropEvent *event) 19 | { 20 | 21 | const QMimeData* mimeData = event->mimeData(); 22 | 23 | // check if it is an image file 24 | if (mimeData->hasUrls()) 25 | { 26 | clear(); 27 | addPixmap(QPixmap(QUrl(mimeData->text()).toLocalFile()).scaled(this->width(), this->height(), Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 28 | event->acceptProposedAction(); 29 | } 30 | } 31 | 32 | dropGraphicsScene::~dropGraphicsScene() 33 | {} 34 | 35 | -------------------------------------------------------------------------------- /source/dropgraphicsscene.h: -------------------------------------------------------------------------------- 1 | #ifndef _DROPGRAPHICSSCENE_H_ 2 | #define _DROPGRAPHICSSCENE_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class dropGraphicsScene : public QGraphicsScene 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit dropGraphicsScene(QObject *parent = 0); 16 | ~dropGraphicsScene(); 17 | 18 | private: 19 | QGraphicsScene scene; 20 | 21 | protected: 22 | void dragEnterEvent(QDragEnterEvent *event); 23 | void dragMoveEvent(QDragMoveEvent *event); 24 | void dropEvent(QDropEvent *event); 25 | 26 | protected slots: 27 | 28 | public slots: 29 | }; 30 | 31 | #endif /*_DROPGRAPHICSSCENE_H_*/ 32 | -------------------------------------------------------------------------------- /source/dropgraphicsview.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "dropgraphicsview.h" 4 | 5 | dropGraphicsView::dropGraphicsView(QWidget* parent) : QGraphicsView(parent) 6 | { 7 | this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 8 | this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 9 | this->setFrameShape(QFrame::Box); 10 | this->setFrameShadow(QFrame::Plain); 11 | this->setScene(&scene); 12 | scene.clear(); 13 | scene.addRect(QRect(0, 0, this->width(), this->height()), QPen(Qt::black), QBrush(Qt::SolidPattern)); 14 | } 15 | 16 | void dropGraphicsView::dragEnterEvent(QDragEnterEvent *event) 17 | { 18 | event->acceptProposedAction(); 19 | } 20 | 21 | void dropGraphicsView::dragMoveEvent(QDragMoveEvent *event) 22 | { 23 | event->acceptProposedAction(); 24 | } 25 | 26 | void dropGraphicsView::dropEvent(QDropEvent *event) 27 | { 28 | const QMimeData* mimeData = event->mimeData(); 29 | scene.clear(); 30 | currentFile = QUrl(mimeData->text()).toLocalFile().trimmed(); 31 | scene.addPixmap(QPixmap(currentFile).scaled(this->width()-4, this->height()-4, Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 32 | event->acceptProposedAction(); 33 | } 34 | 35 | void dropGraphicsView::setImage(QString file) 36 | { 37 | scene.clear(); 38 | currentFile = file; 39 | scene.addPixmap(QPixmap(currentFile).scaled(this->width()-4, this->height()-4, Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 40 | } 41 | 42 | dropGraphicsView::~dropGraphicsView() 43 | {} 44 | 45 | -------------------------------------------------------------------------------- /source/dropgraphicsview.h: -------------------------------------------------------------------------------- 1 | #ifndef _DROPGRAPHICSVIEW_H_ 2 | #define _DROPGRAPHICSVIEW_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "dropgraphicsscene.h" 10 | 11 | class dropGraphicsView : public QGraphicsView 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit dropGraphicsView(QWidget *parent = 0); 17 | void setImage(QString file); 18 | QString currentFile; 19 | ~dropGraphicsView(); 20 | 21 | private: 22 | dropGraphicsScene scene; 23 | 24 | protected: 25 | void dragEnterEvent(QDragEnterEvent *event); 26 | void dragMoveEvent(QDragMoveEvent *event); 27 | void dropEvent(QDropEvent *event); 28 | 29 | protected slots: 30 | 31 | public slots: 32 | }; 33 | 34 | #endif /*_DROPGRAPHICSVIEW_H_*/ 35 | -------------------------------------------------------------------------------- /source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "qkontrol.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication app(argc, argv); 7 | app.setApplicationName("qKontrol"); 8 | app.setWindowIcon(QIcon(":/images/qkontrol.ico")); 9 | qkontrolWindow win; 10 | win.show(); 11 | app.setQuitOnLastWindowClosed(true); 12 | 13 | return app.exec(); 14 | } 15 | -------------------------------------------------------------------------------- /source/oscdialog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "oscdialog.h" 5 | 6 | oscDialog::oscDialog(QWidget* parent /* = 0 */, Qt::WindowFlags flags /* = 0 */) : QDialog(parent, flags) 7 | { 8 | setupUi(this); 9 | 10 | // restore settings from INI file if it exists and update values 11 | if(QFile(QDir::homePath() + "/.qkontrol/osc.ini").exists()) 12 | { 13 | QSettings* settings = new QSettings(QDir::homePath() + "/.qkontrol/osc.ini", QSettings::IniFormat); 14 | checkBoxOSC->setChecked(settings->value("enabled").toBool()); 15 | hostname->setText(settings->value("hostname").toString()); 16 | spinBoxLocalport->setValue(settings->value("local").toInt()); 17 | spinBoxRemoteport->setValue(settings->value("remote").toInt()); 18 | } 19 | 20 | connect(applyButton, SIGNAL(clicked()), this, SLOT(saveAndClose())); 21 | } 22 | 23 | // write dialog settings into INI file and close the dialog 24 | void oscDialog::saveAndClose() 25 | { 26 | QSettings* settings = new QSettings(QDir::homePath() + "/.qkontrol/osc.ini", QSettings::IniFormat); 27 | settings->setValue("enabled", checkBoxOSC->isChecked()); 28 | settings->setValue("hostname", hostname->text()); 29 | settings->setValue("local", spinBoxLocalport->value()); 30 | settings->setValue("remote", spinBoxRemoteport->value()); 31 | accept(); 32 | } 33 | 34 | oscDialog::~oscDialog() 35 | { 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /source/oscdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef _OSCDIALOG_H_ 2 | #define _OSCDIALOG_H_ 3 | 4 | #include "ui_oscdialog.h" 5 | 6 | class oscDialog : public QDialog, public Ui_oscDialog 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | oscDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); 12 | ~oscDialog(); 13 | 14 | private: 15 | 16 | private slots: 17 | void saveAndClose(); 18 | 19 | protected slots: 20 | 21 | public slots: 22 | }; 23 | 24 | #endif /*_OSCDIALOG_H_*/ 25 | -------------------------------------------------------------------------------- /source/oscdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | oscDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 534 10 | 342 11 | 12 | 13 | 14 | OSC configuration 15 | 16 | 17 | 18 | 19 | 20 20 | 20 21 | 491 22 | 111 23 | 24 | 25 | 26 | Enable OSC to control Bitwig Audio or Reaper. To interact with your DAW, you need to install the DrivenByMoss OSC extension in your DAW first and to configure it properly. Please note that the incoming UDP port here must match the outgoing port configured in your DAW and vice versa. 27 | 28 | 29 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 30 | 31 | 32 | true 33 | 34 | 35 | 36 | 37 | 38 | 20 39 | 150 40 | 141 41 | 23 42 | 43 | 44 | 45 | font-weight: bold; 46 | 47 | 48 | enable OSC 49 | 50 | 51 | 52 | 53 | 54 | 20 55 | 220 56 | 491 57 | 28 58 | 59 | 60 | 61 | localhost 62 | 63 | 64 | 65 | 66 | 67 | 20 68 | 190 69 | 491 70 | 18 71 | 72 | 73 | 74 | font-weight: bold; 75 | 76 | 77 | Destination Host ('localhost' if same system) 78 | 79 | 80 | 81 | 82 | 83 | 20 84 | 260 85 | 111 86 | 18 87 | 88 | 89 | 90 | font-weight: bold; 91 | 92 | 93 | Local Port 94 | 95 | 96 | 97 | 98 | 99 | 20 100 | 290 101 | 91 102 | 28 103 | 104 | 105 | 106 | 1 107 | 108 | 109 | 65535 110 | 111 | 112 | 9000 113 | 114 | 115 | 116 | 117 | 118 | 180 119 | 260 120 | 111 121 | 18 122 | 123 | 124 | 125 | font-weight: bold; 126 | 127 | 128 | Remote Port 129 | 130 | 131 | 132 | 133 | 134 | 180 135 | 290 136 | 91 137 | 28 138 | 139 | 140 | 141 | 1 142 | 143 | 144 | 65535 145 | 146 | 147 | 8000 148 | 149 | 150 | 151 | 152 | 153 | 430 154 | 260 155 | 80 156 | 23 157 | 158 | 159 | 160 | &apply 161 | 162 | 163 | 164 | 165 | 166 | 430 167 | 295 168 | 80 169 | 23 170 | 171 | 172 | 173 | &cancel 174 | 175 | 176 | 177 | 178 | 179 | 180 | cancelButton 181 | clicked() 182 | oscDialog 183 | reject() 184 | 185 | 186 | 499 187 | 297 188 | 189 | 190 | 519 191 | 149 192 | 193 | 194 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /source/qkontrol.h: -------------------------------------------------------------------------------- 1 | #ifndef _QKONTROLWINDOW_H_ 2 | #define _QKONTROLWINDOW_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #ifdef Q_OS_MACOS 9 | #include "/usr/local/Cellar/hidapi/0.9.0/include/hidapi/hidapi.h" 10 | #else 11 | #include 12 | #endif 13 | #include "dropgraphicsview.h" 14 | #include "ui_qkontrol.h" 15 | 16 | class qkontrolWindow : public QMainWindow , protected Ui_mainwindow 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | qkontrolWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); 22 | ~qkontrolWindow(); 23 | 24 | private: 25 | bool pluginMode; // false = MIDI mode; true = plugin mode 26 | bool oscEnabled; // true if OSC is in use 27 | bool changeTrackinfo; // true if displays should update the track info 28 | int res; 29 | int pid; 30 | unsigned int bPage, kPage, kontrolPage, dirCount, dirPosition; 31 | hid_device *handle; // USB HID socket 32 | QByteArray lightArray, knobsButtons; 33 | QByteArray oldButtonArray; 34 | QMap allColors; // array containing all color settings 35 | QTemporaryFile leftScreen, rightScreen; // image files to be displayed on the screens 36 | QTimer *hid_data; 37 | QString getControlName(uint8_t CC); 38 | QStringList paramName; 39 | QDir dirName; 40 | bool load(QString filename); // function to load a preset 41 | QUdpSocket *udpSocket; // UDP socket to be used on OSC 42 | QString trackname; // trackname to be displayed if OSC is active 43 | QString devicename; // devicename to be displayed if OSC is active 44 | QString beatstring; // beat position to be displayed if OSC is active 45 | QString timestring; // song position to be displayed if OSC is active 46 | QString hostname; // hostname or IP to connect to the DAW via OSC 47 | unsigned int localPort, remotePort; // UDP ports to be used on OSC 48 | 49 | private slots: 50 | bool save(); // function to save a preset 51 | void getFileName(); 52 | 53 | protected slots: 54 | void drawImage(uint8_t screen, QPixmap *pixmap, ushort x = 0, ushort y = 0); 55 | void b_goLeft(); 56 | void b_goRight(); 57 | void b_setPage(int page); 58 | void k_goLeft(); 59 | void k_goRight(); 60 | void k_setPage(int page); 61 | void oscConfig(); 62 | void setKontrolpage(unsigned int page); 63 | void selectColor(QString target); 64 | void setSlidertextcolor(); 65 | void setDividercolor(); 66 | void setCCtextcolor(); 67 | void setParametertextcolor(); 68 | void setValuetextcolor(); 69 | void setButtons(); 70 | void setKeyzones(); 71 | void showOSCDialog(); 72 | void updateValues(); 73 | void updateBacklights(); 74 | void updateColors(); 75 | void updateOSCInfo(); 76 | void updatePedalview(); 77 | void updateWidgets(); 78 | void zapPreset(bool direction); 79 | 80 | public slots: 81 | }; 82 | 83 | #endif /*_QKONTROLWINDOW_H_*/ 84 | -------------------------------------------------------------------------------- /source/qkontrol.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoaSkin/qKontrol/b478fd9818c1b01c695722762e6d55a9b2e0228e/source/qkontrol.ico -------------------------------------------------------------------------------- /source/qkontrol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoaSkin/qKontrol/b478fd9818c1b01c695722762e6d55a9b2e0228e/source/qkontrol.png -------------------------------------------------------------------------------- /source/qkontrol.pro: -------------------------------------------------------------------------------- 1 | CONFIG += release 2 | TEMPLATE += app 3 | TARGET = qkontrol 4 | DEPENDPATH += . widgets 5 | INCLUDEPATH += . widgets 6 | 7 | QT += network widgets gui testlib xml 8 | 9 | FORMS += qkontrol.ui oscdialog.ui 10 | HEADERS += qkontrol.h widgets/qxtstringspinbox.h widgets/qxtspanslider.h widgets/qxtspanslider_p.h dropgraphicsscene.h dropgraphicsview.h oscdialog.h 11 | SOURCES += main.cpp qkontrol.cpp widgets/qxtstringspinbox.cpp widgets/qxtspanslider.cpp dropgraphicsscene.cpp dropgraphicsview.cpp oscdialog.cpp 12 | RESOURCES += qkontrol.qrc 13 | 14 | RC_ICONS = qkontrol.ico 15 | 16 | unix:!macx: LIBS += -lhidapi-libusb -lusb-1.0 17 | 18 | macx: LIBS += -L/usr/local/Cellar/hidapi/0.9.0/lib/ -lhidapi -L/usr/local/Cellar/libusb/1.0.22/lib/ -lusb-1.0 19 | macx: INCLUDEPATH += /usr/local/Cellar/hidapi/0.9.0/include/hidapi /usr/local/Cellar/libusb/1.0.22/include/libusb-1.0/ 20 | macx: DEPENDPATH += /usr/local/Cellar/hidapi/0.9.0/include/hidapi /usr/local/Cellar/libusb/1.0.22/include/libusb-1.0/ 21 | macx: PRE_TARGETDEPS += /usr/local/Cellar/hidapi/0.9.0/lib/libhidapi.a /usr/local/Cellar/libusb/1.0.22/lib/libusb-1.0.a 22 | 23 | win32: DEFINES += QXT_STATIC 24 | win32: LIBS += -LC:/msys64/mingw64/lib/ -lhidapi -llibusb-1.0 25 | win32: INCLUDEPATH += C:/msys64/mingw64/include 26 | win32: DEPENDPATH += C:/msys64/mingw64/include 27 | win32: PRE_TARGETDEPS += C:/msys64/mingw64/lib/libhidapi.a C:/msys64/mingw64/lib/libusb-1.0.a 28 | -------------------------------------------------------------------------------- /source/qkontrol.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | qkontrol.png 4 | background.png 5 | qkontrol.ico 6 | 7 | 8 | -------------------------------------------------------------------------------- /source/widgets/LICENSE: -------------------------------------------------------------------------------- 1 | Qt Extension Library 2 | Copyright (C) 2007 Qxt Foundation 3 | 4 | ------------------- Disclaimer ------------------------------------------------ 5 | 6 | Until the Qxt Foundation is legally established, copyright for the 7 | source code falls back to the original contributor. For information about the 8 | status of the Qxt Foundation, or about the copyright status of any part of Qxt, 9 | contact the Qxt project maintainers at 10 | 11 | Once the Qxt Foundation has been legally established, all contributors must 12 | transfer all copyright interest to the Qxt Foundation before their submissions 13 | will be added to the project. 14 | 15 | ------------------- License --------------------------------------------------- 16 | 17 | This library is free software; you can redistribute it and/or modify it 18 | under the terms of the Common Public License, version 1.0, as published by IBM 19 | or under the terms of the GNU Lesser General Public License, version 2.1, 20 | as published by the Free Software Foundation 21 | 22 | This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 23 | KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 24 | WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 25 | FITNESS FOR A PARTICULAR PURPOSE. 26 | 27 | You should have received a copy of the CPL along with this file. 28 | See the LICENSE file and the cpl1.0.txt file included with the source 29 | distribution for more information. If you did not receive a copy of the 30 | license, contact the Qxt Foundation. 31 | 32 | You should have received a copy of the LGPL along with this file. 33 | See the LICENSE file and the lgpl-2.1.txt file included with the source 34 | distribution for more information. If you did not receive a copy of the 35 | license, contact the Qxt Foundation. 36 | 37 | Parts of Qxt depend on Qt 4 and/or other libraries that have their own 38 | licenses. Qxt is independent of these licenses; however, use of these other 39 | libraries is subject to their respective license agreements. 40 | 41 | ------------------- Intent ---------------------------------------------------- 42 | 43 | The following section describes the opinions and intent of the Qxt Foundation 44 | with regards to the licensing and use of the Qxt source code and library. In 45 | the event that the CPL is found to be illegal or invalid, or if any application 46 | or clause of the license is subjected to question or abuse, this section is a 47 | general statement of the desired interpretation. 48 | 49 | This section has no legal standing and the statements made here are strictly 50 | subject to the text of the CPL; that is, if this section and the CPL are in 51 | disagreement, the text of the CPL takes precedence. In no way does this 52 | intent grant you any additional rights or impose any additional restrictions. 53 | 54 | If you have questions about licensing, contact the maintainers. 55 | 56 | Qxt is built and supported by open-source enthusiasts. 57 | - Please respect the open-source background of the contributors. The code is 58 | provided for everyone's use; you may not restrict the rights of anyone to 59 | use it. 60 | - No individual may claim ownership of any part of the code. It belongs 61 | to the community. 62 | - You may modify the source code to suit your needs, but these changes 63 | must be made free. If you distribute a modified form of Qxt, you must 64 | also distribute the entire source code of the modified form. 65 | - Digital Rights Management (DRM) puts unfair, unfree restrictions on 66 | users and developers. It is the opposite of Free Software. We can't 67 | stop you from using it, but please don't use the Qxt name for software 68 | restricted by DRM. 69 | - Please respect the time and effort put into the project by the developers. 70 | - If you find Qxt useful, it would be appreciated if you would include 71 | text in your application (for instance, in the About dialog) giving 72 | acknowledgement to Qxt. 73 | - If you make modifications to the source code, you must not call the 74 | modified version "Qxt." It's okay to include "Qxt" in the name, but 75 | anyone who receives the modified version needs to know that it's not 76 | the same as the version distributed by the Qxt Foundation. 77 | - We want everyone to be able to use Qxt without restrictions. 78 | - If you distribute Qxt in compiled binary form, please ensure that 79 | everyone who receives it can get the source code used to create it. 80 | - You are free to use Qxt in closed-source applications as long as you 81 | distribute Qxt in an open-source fashion. This does not require you 82 | to make your entire application open-source. 83 | - The Qxt Foundation is a non-profit, non-political organization. 84 | - Please don't use the Qxt name in any political or semi-political 85 | propaganda or publication. We don't like it. 86 | - Qxt is distributed "as-is," with no warranty. 87 | - If it makes your program crash, your computer blow up, or tiny demons 88 | fly out of your nose, please don't sue us. 89 | 90 | -------------------------------------------------------------------------------- /source/widgets/QxtSpanSlider: -------------------------------------------------------------------------------- 1 | #include "qxtspanslider.h" 2 | 3 | -------------------------------------------------------------------------------- /source/widgets/QxtStringSpinBox: -------------------------------------------------------------------------------- 1 | #include "qxtstringspinbox.h" 2 | 3 | -------------------------------------------------------------------------------- /source/widgets/cpl1.0.txt: -------------------------------------------------------------------------------- 1 | Common Public License Version 1.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC 4 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 5 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | 9 | "Contribution" means: 10 | 11 | a) in the case of the initial Contributor, the initial code and 12 | documentation distributed under this Agreement, and 13 | 14 | b) in the case of each subsequent Contributor: 15 | 16 | i) changes to the Program, and 17 | 18 | ii) additions to the Program; 19 | 20 | where such changes and/or additions to the Program originate from and are 21 | distributed by that particular Contributor. A Contribution 'originates' from a 22 | Contributor if it was added to the Program by such Contributor itself or anyone 23 | acting on such Contributor's behalf. Contributions do not include additions to 24 | the Program which: (i) are separate modules of software distributed in 25 | conjunction with the Program under their own license agreement, and (ii) are not 26 | derivative works of the Program. 27 | 28 | "Contributor" means any person or entity that distributes the Program. 29 | 30 | "Licensed Patents " mean patent claims licensable by a Contributor which are 31 | necessarily infringed by the use or sale of its Contribution alone or when 32 | combined with the Program. 33 | 34 | "Program" means the Contributions distributed in accordance with this Agreement. 35 | 36 | "Recipient" means anyone who receives the Program under this Agreement, 37 | including all Contributors. 38 | 39 | 2. GRANT OF RIGHTS 40 | 41 | a) Subject to the terms of this Agreement, each Contributor hereby grants 42 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 43 | reproduce, prepare derivative works of, publicly display, publicly perform, 44 | distribute and sublicense the Contribution of such Contributor, if any, and such 45 | derivative works, in source code and object code form. 46 | 47 | b) Subject to the terms of this Agreement, each Contributor hereby grants 48 | Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed 49 | Patents to make, use, sell, offer to sell, import and otherwise transfer the 50 | Contribution of such Contributor, if any, in source code and object code form. 51 | This patent license shall apply to the combination of the Contribution and the 52 | Program if, at the time the Contribution is added by the Contributor, such 53 | addition of the Contribution causes such combination to be covered by the 54 | Licensed Patents. The patent license shall not apply to any other combinations 55 | which include the Contribution. No hardware per se is licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other intellectual 60 | property rights of any other entity. Each Contributor disclaims any liability to 61 | Recipient for claims brought by any other entity based on infringement of 62 | intellectual property rights or otherwise. As a condition to exercising the 63 | rights and licenses granted hereunder, each Recipient hereby assumes sole 64 | responsibility to secure any other intellectual property rights needed, if any. 65 | For example, if a third party patent license is required to allow Recipient to 66 | distribute the Program, it is Recipient's responsibility to acquire that license 67 | before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license set 71 | forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under its 76 | own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title and 84 | non-infringement, and implied warranties or conditions of merchantability and 85 | fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on or 96 | through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within the 105 | Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, if 108 | any, in a manner that reasonably allows subsequent Recipients to identify the 109 | originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a manner 117 | which does not create potential liability for other Contributors. Therefore, if 118 | a Contributor includes the Program in a commercial product offering, such 119 | Contributor ("Commercial Contributor") hereby agrees to defend and indemnify 120 | every other Contributor ("Indemnified Contributor") against any losses, damages 121 | and costs (collectively "Losses") arising from claims, lawsuits and other legal 122 | actions brought by a third party against the Indemnified Contributor to the 123 | extent caused by the acts or omissions of such Commercial Contributor in 124 | connection with its distribution of the Program in a commercial product 125 | offering. The obligations in this section do not apply to any claims or Losses 126 | relating to any actual or alleged intellectual property infringement. In order 127 | to qualify, an Indemnified Contributor must: a) promptly notify the Commercial 128 | Contributor in writing of such claim, and b) allow the Commercial Contributor to 129 | control, and cooperate with the Commercial Contributor in, the defense and any 130 | related settlement negotiations. The Indemnified Contributor may participate in 131 | any such claim at its own expense. 132 | 133 | For example, a Contributor might include the Program in a commercial product 134 | offering, Product X. That Contributor is then a Commercial Contributor. If that 135 | Commercial Contributor then makes performance claims, or offers warranties 136 | related to Product X, those performance claims and warranties are such 137 | Commercial Contributor's responsibility alone. Under this section, the 138 | Commercial Contributor would have to defend claims against the other 139 | Contributors related to those performance claims and warranties, and if a court 140 | requires any other Contributor to pay any damages as a result, the Commercial 141 | Contributor must pay those damages. 142 | 143 | 5. NO WARRANTY 144 | 145 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN 146 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 147 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, 148 | NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each 149 | Recipient is solely responsible for determining the appropriateness of using and 150 | distributing the Program and assumes all risks associated with its exercise of 151 | rights under this Agreement, including but not limited to the risks and costs of 152 | program errors, compliance with applicable laws, damage to or loss of data, 153 | programs or equipment, and unavailability or interruption of operations. 154 | 155 | 6. DISCLAIMER OF LIABILITY 156 | 157 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 158 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 159 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST 160 | PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 161 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 162 | OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS 163 | GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 164 | 165 | 7. GENERAL 166 | 167 | If any provision of this Agreement is invalid or unenforceable under applicable 168 | law, it shall not affect the validity or enforceability of the remainder of the 169 | terms of this Agreement, and without further action by the parties hereto, such 170 | provision shall be reformed to the minimum extent necessary to make such 171 | provision valid and enforceable. 172 | 173 | If Recipient institutes patent litigation against a Contributor with respect to 174 | a patent applicable to software (including a cross-claim or counterclaim in a 175 | lawsuit), then any patent licenses granted by that Contributor to such Recipient 176 | under this Agreement shall terminate as of the date such litigation is filed. In 177 | addition, if Recipient institutes patent litigation against any entity 178 | (including a cross-claim or counterclaim in a lawsuit) alleging that the Program 179 | itself (excluding combinations of the Program with other software or hardware) 180 | infringes such Recipient's patent(s), then such Recipient's rights granted under 181 | Section 2(b) shall terminate as of the date such litigation is filed. 182 | 183 | All Recipient's rights under this Agreement shall terminate if it fails to 184 | comply with any of the material terms or conditions of this Agreement and does 185 | not cure such failure in a reasonable period of time after becoming aware of 186 | such noncompliance. If all Recipient's rights under this Agreement terminate, 187 | Recipient agrees to cease use and distribution of the Program as soon as 188 | reasonably practicable. However, Recipient's obligations under this Agreement 189 | and any licenses granted by Recipient relating to the Program shall continue and 190 | survive. 191 | 192 | Everyone is permitted to copy and distribute copies of this Agreement, but in 193 | order to avoid inconsistency the Agreement is copyrighted and may only be 194 | modified in the following manner. The Agreement Steward reserves the right to 195 | publish new versions (including revisions) of this Agreement from time to time. 196 | No one other than the Agreement Steward has the right to modify this Agreement. 197 | IBM is the initial Agreement Steward. IBM may assign the responsibility to serve 198 | as the Agreement Steward to a suitable separate entity. Each new version of the 199 | Agreement will be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the Agreement 201 | under which it was received. In addition, after a new version of the Agreement 202 | is published, Contributor may elect to distribute the Program (including its 203 | Contributions) under the new version. Except as expressly stated in Sections 204 | 2(a) and 2(b) above, Recipient receives no rights or licenses to the 205 | intellectual property of any Contributor under this Agreement, whether 206 | expressly, by implication, estoppel or otherwise. All rights in the Program not 207 | expressly granted under this Agreement are reserved. 208 | 209 | This Agreement is governed by the laws of the State of New York and the 210 | intellectual property laws of the United States of America. No party to this 211 | Agreement will bring a legal action under this Agreement more than one year 212 | after the cause of action arose. Each party waives its rights to a jury trial in 213 | any resulting litigation. 214 | -------------------------------------------------------------------------------- /source/widgets/lgpl-2.1.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | 504 | 505 | -------------------------------------------------------------------------------- /source/widgets/qxtglobal.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtCore module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | 26 | #include "qxtglobal.h" 27 | 28 | /*! 29 | \headerfile 30 | \title Global Qxt Declarations 31 | \inmodule QxtCore 32 | 33 | \brief The header provides basic declarations and 34 | is included by all other Qxt headers. 35 | */ 36 | 37 | /*! 38 | \macro QXT_VERSION 39 | \relates 40 | 41 | This macro expands a numeric value of the form 0xMMNNPP (MM = 42 | major, NN = minor, PP = patch) that specifies Qxt's version 43 | number. For example, if you compile your application against Qxt 44 | 0.4.0, the QXT_VERSION macro will expand to 0x000400. 45 | 46 | You can use QXT_VERSION to use the latest Qt features where 47 | available. For example: 48 | \code 49 | #if QXT_VERSION >= 0x000400 50 | qxtTabWidget->setTabMovementMode(QxtTabWidget::InPlaceMovement); 51 | #endif 52 | \endcode 53 | 54 | \sa QXT_VERSION_STR, qxtVersion() 55 | */ 56 | 57 | /*! 58 | \macro QXT_VERSION_STR 59 | \relates 60 | 61 | This macro expands to a string that specifies Qxt's version number 62 | (for example, "0.4.0"). This is the version against which the 63 | application is compiled. 64 | 65 | \sa qxtVersion(), QXT_VERSION 66 | */ 67 | 68 | /*! 69 | \relates 70 | 71 | Returns the version number of Qxt at run-time as a string (for 72 | example, "0.4.0"). This may be a different version than the 73 | version the application was compiled against. 74 | 75 | \sa QXT_VERSION_STR 76 | */ 77 | const char* qxtVersion() 78 | { 79 | return QXT_VERSION_STR; 80 | } 81 | 82 | /*! 83 | \headerfile 84 | \title The Qxt private implementation 85 | \inmodule QxtCore 86 | 87 | \brief The header provides tools for hiding 88 | details of a class. 89 | 90 | Application code generally doesn't have to be concerned about hiding its 91 | implementation details, but when writing library code it is important to 92 | maintain a constant interface, both source and binary. Maintaining a constant 93 | source interface is easy enough, but keeping the binary interface constant 94 | means moving implementation details into a private class. The PIMPL, or 95 | d-pointer, idiom is a common method of implementing this separation. QxtPimpl 96 | offers a convenient way to connect the public and private sides of your class. 97 | 98 | \section1 Getting Started 99 | Before you declare the public class, you need to make a forward declaration 100 | of the private class. The private class must have the same name as the public 101 | class, followed by the word Private. For example, a class named MyTest would 102 | declare the private class with: 103 | \code 104 | class MyTestPrivate; 105 | \endcode 106 | 107 | \section1 The Public Class 108 | Generally, you shouldn't keep any data members in the public class without a 109 | good reason. Functions that are part of the public interface should be declared 110 | in the public class, and functions that need to be available to subclasses (for 111 | calling or overriding) should be in the protected section of the public class. 112 | To connect the private class to the public class, include the 113 | QXT_DECLARE_PRIVATE macro in the private section of the public class. In the 114 | example above, the private class is connected as follows: 115 | \code 116 | private: 117 | QXT_DECLARE_PRIVATE(MyTest) 118 | \endcode 119 | 120 | Additionally, you must include the QXT_INIT_PRIVATE macro in the public class's 121 | constructor. Continuing with the MyTest example, your constructor might look 122 | like this: 123 | \code 124 | MyTest::MyTest() { 125 | // initialization 126 | QXT_INIT_PRIVATE(MyTest); 127 | } 128 | \endcode 129 | 130 | \section1 The Private Class 131 | As mentioned above, data members should usually be kept in the private class. 132 | This allows the memory layout of the private class to change without breaking 133 | binary compatibility for the public class. Functions that exist only as 134 | implementation details, or functions that need access to private data members, 135 | should be implemented here. 136 | 137 | To define the private class, inherit from the template QxtPrivate class, and 138 | include the QXT_DECLARE_PUBLIC macro in its public section. The template 139 | parameter should be the name of the public class. For example: 140 | \code 141 | class MyTestPrivate : public QxtPrivate { 142 | public: 143 | MyTestPrivate(); 144 | QXT_DECLARE_PUBLIC(MyTest) 145 | }; 146 | \endcode 147 | 148 | \section1 Accessing Private Members 149 | Use the qxt_d() function (actually a function-like object) from functions in 150 | the public class to access the private class. Similarly, functions in the 151 | private class can invoke functions in the public class by using the qxt_p() 152 | function (this one's actually a function). 153 | 154 | For example, assume that MyTest has methods named getFoobar and doBaz(), 155 | and MyTestPrivate has a member named foobar and a method named doQuux(). 156 | The code might resemble this example: 157 | \code 158 | int MyTest::getFoobar() { 159 | return qxt_d().foobar; 160 | } 161 | 162 | void MyTestPrivate::doQuux() { 163 | qxt_p().doBaz(foobar); 164 | } 165 | \endcode 166 | */ 167 | 168 | /*! 169 | * \macro QXT_DECLARE_PRIVATE(PUB) 170 | * \relates 171 | * Declares that a public class has a related private class. 172 | * 173 | * This shuold be put in the private section of the public class. The parameter is the name of the public class. 174 | */ 175 | 176 | /*! 177 | * \macro QXT_DECLARE_PUBLIC(PUB) 178 | * \relates 179 | * Declares that a private class has a related public class. 180 | * 181 | * This may be put anywhere in the declaration of the private class. The parameter is the name of the public class. 182 | */ 183 | 184 | /*! 185 | * \macro QXT_INIT_PRIVATE(PUB) 186 | * \relates 187 | * Initializes resources owned by the private class. 188 | * 189 | * This should be called from the public class's constructor, 190 | * before qxt_d() is used for the first time. The parameter is the name of the public class. 191 | */ 192 | 193 | /*! 194 | * \macro QXT_D(PUB) 195 | * \relates 196 | * Returns a reference in the current scope named "d" to the private class. 197 | * 198 | * This function is only available in a class using \a QXT_DECLARE_PRIVATE. 199 | */ 200 | 201 | /*! 202 | * \macro QXT_P(PUB) 203 | * \relates 204 | * Creates a reference in the current scope named "q" to the public class. 205 | * 206 | * This macro only works in a class using \a QXT_DECLARE_PUBLIC. 207 | */ 208 | 209 | /*! 210 | * \fn QxtPrivate& PUB::qxt_d() 211 | * \relates 212 | * Returns a reference to the private class. 213 | * 214 | * This function is only available in a class using \a QXT_DECLARE_PRIVATE. 215 | */ 216 | 217 | /*! 218 | * \fn const QxtPrivate& PUB::qxt_d() const 219 | * \relates 220 | * Returns a const reference to the private class. 221 | * 222 | * This function is only available in a class using \a QXT_DECLARE_PRIVATE. 223 | * This overload will be automatically used in const functions. 224 | */ 225 | 226 | /*! 227 | * \fn PUB& QxtPrivate::qxt_p() 228 | * \relates 229 | * Returns a reference to the public class. 230 | * 231 | * This function is only available in a class using \a QXT_DECLARE_PUBLIC. 232 | */ 233 | 234 | /*! 235 | * \fn const PUB& QxtPrivate::qxt_p() const 236 | * \relates 237 | * Returns a const reference to the public class. 238 | * 239 | * This function is only available in a class using \a QXT_DECLARE_PUBLIC. 240 | * This overload will be automatically used in const functions. 241 | */ 242 | -------------------------------------------------------------------------------- /source/widgets/qxtglobal.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtCore module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXTGLOBAL_H 27 | #define QXTGLOBAL_H 28 | 29 | #include 30 | 31 | #define QXT_VERSION 0x000602 32 | #define QXT_VERSION_STR "0.6.2" 33 | 34 | //--------------------------global macros------------------------------ 35 | 36 | #ifndef QXT_NO_MACROS 37 | 38 | #endif // QXT_NO_MACROS 39 | 40 | //--------------------------export macros------------------------------ 41 | 42 | #define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE 43 | 44 | #if !defined(QXT_STATIC) 45 | # if defined(BUILD_QXT_CORE) 46 | # define QXT_CORE_EXPORT Q_DECL_EXPORT 47 | # else 48 | # define QXT_CORE_EXPORT Q_DECL_IMPORT 49 | # endif 50 | #else 51 | # define QXT_CORE_EXPORT 52 | #endif // BUILD_QXT_CORE 53 | 54 | #if !defined(QXT_STATIC) 55 | # if defined(BUILD_QXT_GUI) 56 | # define QXT_GUI_EXPORT Q_DECL_EXPORT 57 | # else 58 | # define QXT_GUI_EXPORT Q_DECL_IMPORT 59 | # endif 60 | #else 61 | # define QXT_GUI_EXPORT 62 | #endif // BUILD_QXT_GUI 63 | 64 | #if !defined(QXT_STATIC) 65 | # if defined(BUILD_QXT_NETWORK) 66 | # define QXT_NETWORK_EXPORT Q_DECL_EXPORT 67 | # else 68 | # define QXT_NETWORK_EXPORT Q_DECL_IMPORT 69 | # endif 70 | #else 71 | # define QXT_NETWORK_EXPORT 72 | #endif // BUILD_QXT_NETWORK 73 | 74 | #if !defined(QXT_STATIC) 75 | # if defined(BUILD_QXT_SQL) 76 | # define QXT_SQL_EXPORT Q_DECL_EXPORT 77 | # else 78 | # define QXT_SQL_EXPORT Q_DECL_IMPORT 79 | # endif 80 | #else 81 | # define QXT_SQL_EXPORT 82 | #endif // BUILD_QXT_SQL 83 | 84 | #if !defined(QXT_STATIC) 85 | # if defined(BUILD_QXT_WEB) 86 | # define QXT_WEB_EXPORT Q_DECL_EXPORT 87 | # else 88 | # define QXT_WEB_EXPORT Q_DECL_IMPORT 89 | # endif 90 | #else 91 | # define QXT_WEB_EXPORT 92 | #endif // BUILD_QXT_WEB 93 | 94 | #if !defined(QXT_STATIC) 95 | # if defined(BUILD_QXT_BERKELEY) 96 | # define QXT_BERKELEY_EXPORT Q_DECL_EXPORT 97 | # else 98 | # define QXT_BERKELEY_EXPORT Q_DECL_IMPORT 99 | # endif 100 | #else 101 | # define QXT_BERKELEY_EXPORT 102 | #endif // BUILD_QXT_BERKELEY 103 | 104 | #if !defined(QXT_STATIC) 105 | # if defined(BUILD_QXT_ZEROCONF) 106 | # define QXT_ZEROCONF_EXPORT Q_DECL_EXPORT 107 | # else 108 | # define QXT_ZEROCONF_EXPORT Q_DECL_IMPORT 109 | # endif 110 | #else 111 | # define QXT_ZEROCONF_EXPORT 112 | #endif // QXT_ZEROCONF_EXPORT 113 | 114 | #if defined BUILD_QXT_CORE || defined BUILD_QXT_GUI || defined BUILD_QXT_SQL || defined BUILD_QXT_NETWORK || defined BUILD_QXT_WEB || defined BUILD_QXT_BERKELEY || defined BUILD_QXT_ZEROCONF 115 | # define BUILD_QXT 116 | #endif 117 | 118 | QXT_CORE_EXPORT const char* qxtVersion(); 119 | 120 | #ifndef QT_BEGIN_NAMESPACE 121 | #define QT_BEGIN_NAMESPACE 122 | #endif 123 | 124 | #ifndef QT_END_NAMESPACE 125 | #define QT_END_NAMESPACE 126 | #endif 127 | 128 | #ifndef QT_FORWARD_DECLARE_CLASS 129 | #define QT_FORWARD_DECLARE_CLASS(Class) class Class; 130 | #endif 131 | 132 | /**************************************************************************** 133 | ** This file is derived from code bearing the following notice: 134 | ** The sole author of this file, Adam Higerd, has explicitly disclaimed all 135 | ** copyright interest and protection for the content within. This file has 136 | ** been placed in the public domain according to United States copyright 137 | ** statute and case law. In jurisdictions where this public domain dedication 138 | ** is not legally recognized, anyone who receives a copy of this file is 139 | ** permitted to use, modify, duplicate, and redistribute this file, in whole 140 | ** or in part, with no restrictions or conditions. In these jurisdictions, 141 | ** this file shall be copyright (C) 2006-2008 by Adam Higerd. 142 | ****************************************************************************/ 143 | 144 | #define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface qxt_d; 145 | #define QXT_DECLARE_PUBLIC(PUB) friend class PUB; 146 | #define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this); 147 | #define QXT_D(PUB) PUB##Private& d = qxt_d() 148 | #define QXT_P(PUB) PUB& p = qxt_p() 149 | 150 | template 151 | class QxtPrivate 152 | { 153 | public: 154 | virtual ~QxtPrivate() 155 | {} 156 | inline void QXT_setPublic(PUB* pub) 157 | { 158 | qxt_p_ptr = pub; 159 | } 160 | 161 | protected: 162 | inline PUB& qxt_p() 163 | { 164 | return *qxt_p_ptr; 165 | } 166 | inline const PUB& qxt_p() const 167 | { 168 | return *qxt_p_ptr; 169 | } 170 | 171 | private: 172 | PUB* qxt_p_ptr; 173 | }; 174 | 175 | template 176 | class QxtPrivateInterface 177 | { 178 | friend class QxtPrivate; 179 | public: 180 | QxtPrivateInterface() 181 | { 182 | pvt = new PVT; 183 | } 184 | ~QxtPrivateInterface() 185 | { 186 | delete pvt; 187 | } 188 | 189 | inline void setPublic(PUB* pub) 190 | { 191 | pvt->QXT_setPublic(pub); 192 | } 193 | inline PVT& operator()() 194 | { 195 | return *static_cast(pvt); 196 | } 197 | inline const PVT& operator()() const 198 | { 199 | return *static_cast(pvt); 200 | } 201 | private: 202 | QxtPrivateInterface(const QxtPrivateInterface&) { } 203 | QxtPrivateInterface& operator=(const QxtPrivateInterface&) { } 204 | QxtPrivate* pvt; 205 | }; 206 | 207 | #endif // QXT_GLOBAL 208 | -------------------------------------------------------------------------------- /source/widgets/qxtnamespace.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtCore module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXTNAMESPACE_H 27 | #define QXTNAMESPACE_H 28 | 29 | #include 30 | 31 | #if (defined BUILD_QXT | defined Q_MOC_RUN) && !defined(QXT_DOXYGEN_RUN) 32 | #include 33 | 34 | class QXT_CORE_EXPORT Qxt : public QObject 35 | { 36 | Q_OBJECT 37 | Q_ENUMS(Rotation) 38 | Q_ENUMS(DecorationStyle) 39 | Q_ENUMS(ErrorCode) 40 | 41 | public: 42 | #else 43 | namespace Qxt 44 | { 45 | #endif 46 | enum Rotation 47 | { 48 | NoRotation = 0, 49 | UpsideDown = 180, 50 | Clockwise = 90, 51 | CounterClockwise = 270 52 | }; 53 | 54 | enum DecorationStyle 55 | { 56 | NoDecoration, 57 | Buttonlike, 58 | Menulike 59 | }; 60 | 61 | enum ErrorCode 62 | { 63 | NoError, 64 | UnknownError, 65 | LogicalError, 66 | Bug, 67 | UnexpectedEndOfFunction, 68 | NotImplemented, 69 | CodecError, 70 | NotInitialised, 71 | EndOfFile, 72 | FileIOError, 73 | FormatError, 74 | DeviceError, 75 | SDLError, 76 | InsufficientMemory, 77 | SeeErrorString, 78 | UnexpectedNullParameter, 79 | ClientTimeout, 80 | SocketIOError, 81 | ParserError, 82 | HeaderTooLong, 83 | Auth, 84 | Overflow 85 | }; 86 | 87 | enum QxtItemDataRole 88 | { 89 | ItemStartTimeRole = Qt::UserRole + 1, 90 | ItemDurationRole = ItemStartTimeRole + 1, 91 | UserRole = ItemDurationRole + 23 92 | }; 93 | 94 | enum Timeunit 95 | { 96 | Second, 97 | Minute, 98 | Hour, 99 | Day, 100 | Week, 101 | Month, 102 | Year 103 | }; 104 | }; 105 | 106 | #endif // QXTNAMESPACE_H 107 | -------------------------------------------------------------------------------- /source/widgets/qxtpimpl.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtCore module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | 26 | #include 27 | -------------------------------------------------------------------------------- /source/widgets/qxtspanslider.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtGui module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | #include "qxtspanslider.h" 26 | #include "qxtspanslider_p.h" 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | QxtSpanSliderPrivate::QxtSpanSliderPrivate() : 34 | lower(0), 35 | upper(0), 36 | lowerPos(0), 37 | upperPos(0), 38 | offset(0), 39 | position(0), 40 | lastPressed(NoHandle), 41 | mainControl(LowerHandle), 42 | lowerPressed(QStyle::SC_None), 43 | upperPressed(QStyle::SC_None), 44 | movement(QxtSpanSlider::FreeMovement), 45 | firstMovement(false), 46 | blockTracking(false) 47 | { 48 | } 49 | 50 | // TODO: get rid of this in Qt 4.3 51 | void QxtSpanSliderPrivate::initStyleOption(QStyleOptionSlider* option, SpanHandle handle) const 52 | { 53 | if (!option) 54 | return; 55 | 56 | const QSlider* p = &qxt_p(); 57 | option->initFrom(p); 58 | option->subControls = QStyle::SC_None; 59 | option->activeSubControls = QStyle::SC_None; 60 | option->orientation = p->orientation(); 61 | option->maximum = p->maximum(); 62 | option->minimum = p->minimum(); 63 | option->tickPosition = p->tickPosition(); 64 | option->tickInterval = p->tickInterval(); 65 | option->upsideDown = (p->orientation() == Qt::Horizontal) ? 66 | (p->invertedAppearance() != (option->direction == Qt::RightToLeft)) : (!p->invertedAppearance()); 67 | option->direction = Qt::LeftToRight; // we use the upsideDown option instead 68 | option->sliderPosition = (handle == LowerHandle ? lowerPos : upperPos); 69 | option->sliderValue = (handle == LowerHandle ? lower : upper); 70 | option->singleStep = p->singleStep(); 71 | option->pageStep = p->pageStep(); 72 | if (p->orientation() == Qt::Horizontal) 73 | option->state |= QStyle::State_Horizontal; 74 | } 75 | 76 | int QxtSpanSliderPrivate::pixelPosToRangeValue(int pos) const 77 | { 78 | QStyleOptionSlider opt; 79 | initStyleOption(&opt); 80 | 81 | int sliderMin = 0; 82 | int sliderMax = 0; 83 | int sliderLength = 0; 84 | const QSlider* p = &qxt_p(); 85 | const QRect gr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, p); 86 | const QRect sr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, p); 87 | if (p->orientation() == Qt::Horizontal) 88 | { 89 | sliderLength = sr.width(); 90 | sliderMin = gr.x(); 91 | sliderMax = gr.right() - sliderLength + 1; 92 | } 93 | else 94 | { 95 | sliderLength = sr.height(); 96 | sliderMin = gr.y(); 97 | sliderMax = gr.bottom() - sliderLength + 1; 98 | } 99 | return QStyle::sliderValueFromPosition(p->minimum(), p->maximum(), pos - sliderMin, 100 | sliderMax - sliderMin, opt.upsideDown); 101 | } 102 | 103 | void QxtSpanSliderPrivate::handleMousePress(const QPoint& pos, QStyle::SubControl& control, int value, SpanHandle handle) 104 | { 105 | QStyleOptionSlider opt; 106 | initStyleOption(&opt, handle); 107 | QSlider* p = &qxt_p(); 108 | const QStyle::SubControl oldControl = control; 109 | control = p->style()->hitTestComplexControl(QStyle::CC_Slider, &opt, pos, p); 110 | const QRect sr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, p); 111 | if (control == QStyle::SC_SliderHandle) 112 | { 113 | position = value; 114 | offset = pick(pos - sr.topLeft()); 115 | lastPressed = handle; 116 | p->setSliderDown(true); 117 | } 118 | if (control != oldControl) 119 | p->update(sr); 120 | } 121 | 122 | void QxtSpanSliderPrivate::setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2) const 123 | { 124 | QColor highlight = qxt_p().palette().color(QPalette::Highlight); 125 | QLinearGradient gradient(x1, y1, x2, y2); 126 | gradient.setColorAt(0, highlight.dark(120)); 127 | gradient.setColorAt(1, highlight.light(108)); 128 | painter->setBrush(gradient); 129 | 130 | if (orientation == Qt::Horizontal) 131 | painter->setPen(QPen(highlight.dark(130), 0)); 132 | else 133 | painter->setPen(QPen(highlight.dark(150), 0)); 134 | } 135 | 136 | void QxtSpanSliderPrivate::drawSpan(QStylePainter* painter, const QRect& rect) const 137 | { 138 | QStyleOptionSlider opt; 139 | initStyleOption(&opt); 140 | const QSlider* p = &qxt_p(); 141 | 142 | // area 143 | QRect groove = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, p); 144 | if (opt.orientation == Qt::Horizontal) 145 | groove.adjust(0, 0, -1, 0); 146 | else 147 | groove.adjust(0, 0, 0, -1); 148 | 149 | // pen & brush 150 | painter->setPen(QPen(p->palette().color(QPalette::Dark).light(110), 0)); 151 | if (opt.orientation == Qt::Horizontal) 152 | setupPainter(painter, opt.orientation, groove.center().x(), groove.top(), groove.center().x(), groove.bottom()); 153 | else 154 | setupPainter(painter, opt.orientation, groove.left(), groove.center().y(), groove.right(), groove.center().y()); 155 | 156 | // draw groove 157 | painter->drawRect(rect.intersected(groove)); 158 | } 159 | 160 | void QxtSpanSliderPrivate::drawHandle(QStylePainter* painter, SpanHandle handle) const 161 | { 162 | QStyleOptionSlider opt; 163 | initStyleOption(&opt, handle); 164 | opt.subControls = QStyle::SC_SliderHandle; 165 | QStyle::SubControl pressed = (handle == LowerHandle ? lowerPressed : upperPressed); 166 | if (pressed == QStyle::SC_SliderHandle) 167 | { 168 | opt.activeSubControls = pressed; 169 | opt.state |= QStyle::State_Sunken; 170 | } 171 | painter->drawComplexControl(QStyle::CC_Slider, opt); 172 | } 173 | 174 | void QxtSpanSliderPrivate::triggerAction(QAbstractSlider::SliderAction action, bool main) 175 | { 176 | int value = 0; 177 | bool no = false; 178 | bool up = false; 179 | const int min = qxt_p().minimum(); 180 | const int max = qxt_p().maximum(); 181 | const SpanHandle altControl = (mainControl == LowerHandle ? UpperHandle : LowerHandle); 182 | 183 | blockTracking = true; 184 | 185 | switch (action) 186 | { 187 | case QAbstractSlider::SliderSingleStepAdd: 188 | if ((main && mainControl == UpperHandle) || (!main && altControl == UpperHandle)) 189 | { 190 | value = qBound(min, upper + qxt_p().singleStep(), max); 191 | up = true; 192 | break; 193 | } 194 | value = qBound(min, lower + qxt_p().singleStep(), max); 195 | break; 196 | case QAbstractSlider::SliderSingleStepSub: 197 | if ((main && mainControl == UpperHandle) || (!main && altControl == UpperHandle)) 198 | { 199 | value = qBound(min, upper - qxt_p().singleStep(), max); 200 | up = true; 201 | break; 202 | } 203 | value = qBound(min, lower - qxt_p().singleStep(), max); 204 | break; 205 | case QAbstractSlider::SliderToMinimum: 206 | value = min; 207 | if ((main && mainControl == UpperHandle) || (!main && altControl == UpperHandle)) 208 | up = true; 209 | break; 210 | case QAbstractSlider::SliderToMaximum: 211 | value = max; 212 | if ((main && mainControl == UpperHandle) || (!main && altControl == UpperHandle)) 213 | up = true; 214 | break; 215 | case QAbstractSlider::SliderMove: 216 | if ((main && mainControl == UpperHandle) || (!main && altControl == UpperHandle)) 217 | up = true; 218 | case QAbstractSlider::SliderNoAction: 219 | no = true; 220 | break; 221 | default: 222 | qWarning("QxtSpanSliderPrivate::triggerAction: Unknown action"); 223 | break; 224 | } 225 | 226 | if (!no && !up) 227 | { 228 | if (movement == QxtSpanSlider::NoCrossing) 229 | value = qMin(value, upper); 230 | else if (movement == QxtSpanSlider::NoOverlapping) 231 | value = qMin(value, upper - 1); 232 | 233 | if (movement == QxtSpanSlider::FreeMovement && value > upper) 234 | { 235 | swapControls(); 236 | qxt_p().setUpperPosition(value); 237 | } 238 | else 239 | { 240 | qxt_p().setLowerPosition(value); 241 | } 242 | } 243 | else if (!no) 244 | { 245 | if (movement == QxtSpanSlider::NoCrossing) 246 | value = qMax(value, lower); 247 | else if (movement == QxtSpanSlider::NoOverlapping) 248 | value = qMax(value, lower + 1); 249 | 250 | if (movement == QxtSpanSlider::FreeMovement && value < lower) 251 | { 252 | swapControls(); 253 | qxt_p().setLowerPosition(value); 254 | } 255 | else 256 | { 257 | qxt_p().setUpperPosition(value); 258 | } 259 | } 260 | 261 | blockTracking = false; 262 | qxt_p().setLowerValue(lowerPos); 263 | qxt_p().setUpperValue(upperPos); 264 | } 265 | 266 | void QxtSpanSliderPrivate::swapControls() 267 | { 268 | qSwap(lower, upper); 269 | qSwap(lowerPressed, upperPressed); 270 | lastPressed = (lastPressed == LowerHandle ? UpperHandle : LowerHandle); 271 | mainControl = (mainControl == LowerHandle ? UpperHandle : LowerHandle); 272 | } 273 | 274 | void QxtSpanSliderPrivate::updateRange(int min, int max) 275 | { 276 | Q_UNUSED(min); 277 | Q_UNUSED(max); 278 | // setSpan() takes care of keeping span in range 279 | qxt_p().setSpan(lower, upper); 280 | } 281 | 282 | void QxtSpanSliderPrivate::movePressedHandle() 283 | { 284 | switch (lastPressed) 285 | { 286 | case QxtSpanSliderPrivate::LowerHandle: 287 | if (lowerPos != lower) 288 | { 289 | bool main = (mainControl == QxtSpanSliderPrivate::LowerHandle); 290 | triggerAction(QAbstractSlider::SliderMove, main); 291 | } 292 | break; 293 | case QxtSpanSliderPrivate::UpperHandle: 294 | if (upperPos != upper) 295 | { 296 | bool main = (mainControl == QxtSpanSliderPrivate::UpperHandle); 297 | triggerAction(QAbstractSlider::SliderMove, main); 298 | } 299 | break; 300 | default: 301 | break; 302 | } 303 | } 304 | 305 | /*! 306 | \class QxtSpanSlider 307 | \inmodule QxtGui 308 | \brief The QxtSpanSlider widget is a QSlider with two handles. 309 | 310 | QxtSpanSlider is a slider with two handles. QxtSpanSlider is 311 | handy for letting user to choose an span between min/max. 312 | 313 | The span color is calculated based on QPalette::Highlight. 314 | 315 | The keys are bound according to the following table: 316 | \table 317 | \header \o Orientation \o Key \o Handle 318 | \row \o Qt::Horizontal \o Qt::Key_Left \o lower 319 | \row \o Qt::Horizontal \o Qt::Key_Right \o lower 320 | \row \o Qt::Horizontal \o Qt::Key_Up \o upper 321 | \row \o Qt::Horizontal \o Qt::Key_Down \o upper 322 | \row \o Qt::Vertical \o Qt::Key_Up \o lower 323 | \row \o Qt::Vertical \o Qt::Key_Down \o lower 324 | \row \o Qt::Vertical \o Qt::Key_Left \o upper 325 | \row \o Qt::Vertical \o Qt::Key_Right \o upper 326 | \endtable 327 | 328 | Keys are bound by the time the slider is created. A key is bound 329 | to same handle for the lifetime of the slider. So even if the handle 330 | representation might change from lower to upper, the same key binding 331 | remains. 332 | 333 | \image qxtspanslider.png "QxtSpanSlider in Plastique style." 334 | 335 | \bold {Note:} QxtSpanSlider inherits QSlider for implementation specific 336 | reasons. Adjusting any single handle specific properties like 337 | \list 338 | \o QAbstractSlider::sliderPosition 339 | \o QAbstractSlider::value 340 | \endlist 341 | has no effect. However, all slider specific properties like 342 | \list 343 | \o QAbstractSlider::invertedAppearance 344 | \o QAbstractSlider::invertedControls 345 | \o QAbstractSlider::minimum 346 | \o QAbstractSlider::maximum 347 | \o QAbstractSlider::orientation 348 | \o QAbstractSlider::pageStep 349 | \o QAbstractSlider::singleStep 350 | \o QSlider::tickInterval 351 | \o QSlider::tickPosition 352 | \endlist 353 | are taken into consideration. 354 | */ 355 | 356 | /*! 357 | \enum QxtSpanSlider::HandleMovementMode 358 | 359 | This enum describes the available handle movement modes. 360 | 361 | \value FreeMovement The handles can be moved freely. 362 | \value NoCrossing The handles cannot cross, but they can still overlap each other. The lower and upper values can be the same. 363 | \value NoOverlapping The handles cannot overlap each other. The lower and upper values cannot be the same. 364 | */ 365 | 366 | /*! 367 | \fn QxtSpanSlider::lowerValueChanged(int lower) 368 | 369 | This signal is emitted whenever the \a lower value has changed. 370 | */ 371 | 372 | /*! 373 | \fn QxtSpanSlider::upperValueChanged(int upper) 374 | 375 | This signal is emitted whenever the \a upper value has changed. 376 | */ 377 | 378 | /*! 379 | \fn QxtSpanSlider::spanChanged(int lower, int upper) 380 | 381 | This signal is emitted whenever both the \a lower and the \a upper 382 | values have changed ie. the span has changed. 383 | */ 384 | 385 | /*! 386 | \fn QxtSpanSlider::lowerPositionChanged(int lower) 387 | 388 | This signal is emitted whenever the \a lower position has changed. 389 | */ 390 | 391 | /*! 392 | \fn QxtSpanSlider::upperPositionChanged(int upper) 393 | 394 | This signal is emitted whenever the \a upper position has changed. 395 | */ 396 | 397 | /*! 398 | Constructs a new QxtSpanSlider with \a parent. 399 | */ 400 | QxtSpanSlider::QxtSpanSlider(QWidget* parent) : QSlider(parent) 401 | { 402 | QXT_INIT_PRIVATE(QxtSpanSlider); 403 | connect(this, SIGNAL(rangeChanged(int, int)), &qxt_d(), SLOT(updateRange(int, int))); 404 | connect(this, SIGNAL(sliderReleased()), &qxt_d(), SLOT(movePressedHandle())); 405 | } 406 | 407 | /*! 408 | Constructs a new QxtSpanSlider with \a orientation and \a parent. 409 | */ 410 | QxtSpanSlider::QxtSpanSlider(Qt::Orientation orientation, QWidget* parent) : QSlider(orientation, parent) 411 | { 412 | QXT_INIT_PRIVATE(QxtSpanSlider); 413 | connect(this, SIGNAL(rangeChanged(int, int)), &qxt_d(), SLOT(updateRange(int, int))); 414 | connect(this, SIGNAL(sliderReleased()), &qxt_d(), SLOT(movePressedHandle())); 415 | } 416 | 417 | /*! 418 | Destructs the span slider. 419 | */ 420 | QxtSpanSlider::~QxtSpanSlider() 421 | { 422 | } 423 | 424 | /*! 425 | \property QxtSpanSlider::handleMovementMode 426 | \brief the handle movement mode 427 | */ 428 | QxtSpanSlider::HandleMovementMode QxtSpanSlider::handleMovementMode() const 429 | { 430 | return qxt_d().movement; 431 | } 432 | 433 | void QxtSpanSlider::setHandleMovementMode(QxtSpanSlider::HandleMovementMode mode) 434 | { 435 | qxt_d().movement = mode; 436 | } 437 | 438 | /*! 439 | \property QxtSpanSlider::lowerValue 440 | \brief the lower value of the span 441 | */ 442 | int QxtSpanSlider::lowerValue() const 443 | { 444 | return qMin(qxt_d().lower, qxt_d().upper); 445 | } 446 | 447 | void QxtSpanSlider::setLowerValue(int lower) 448 | { 449 | setSpan(lower, qxt_d().upper); 450 | } 451 | 452 | /*! 453 | \property QxtSpanSlider::upperValue 454 | \brief the upper value of the span 455 | */ 456 | int QxtSpanSlider::upperValue() const 457 | { 458 | return qMax(qxt_d().lower, qxt_d().upper); 459 | } 460 | 461 | void QxtSpanSlider::setUpperValue(int upper) 462 | { 463 | setSpan(qxt_d().lower, upper); 464 | } 465 | 466 | /*! 467 | Sets the span from \a lower to \a upper. 468 | */ 469 | void QxtSpanSlider::setSpan(int lower, int upper) 470 | { 471 | const int low = qBound(minimum(), qMin(lower, upper), maximum()); 472 | const int upp = qBound(minimum(), qMax(lower, upper), maximum()); 473 | if (low != qxt_d().lower || upp != qxt_d().upper) 474 | { 475 | if (low != qxt_d().lower) 476 | { 477 | qxt_d().lower = low; 478 | qxt_d().lowerPos = low; 479 | emit lowerValueChanged(low); 480 | } 481 | if (upp != qxt_d().upper) 482 | { 483 | qxt_d().upper = upp; 484 | qxt_d().upperPos = upp; 485 | emit upperValueChanged(upp); 486 | } 487 | emit spanChanged(qxt_d().lower, qxt_d().upper); 488 | update(); 489 | } 490 | } 491 | 492 | /*! 493 | \property QxtSpanSlider::lowerPosition 494 | \brief the lower position of the span 495 | */ 496 | int QxtSpanSlider::lowerPosition() const 497 | { 498 | return qxt_d().lowerPos; 499 | } 500 | 501 | void QxtSpanSlider::setLowerPosition(int lower) 502 | { 503 | if (qxt_d().lowerPos != lower) 504 | { 505 | qxt_d().lowerPos = lower; 506 | if (!hasTracking()) 507 | update(); 508 | if (isSliderDown()) 509 | emit lowerPositionChanged(lower); 510 | if (hasTracking() && !qxt_d().blockTracking) 511 | { 512 | bool main = (qxt_d().mainControl == QxtSpanSliderPrivate::LowerHandle); 513 | qxt_d().triggerAction(SliderMove, main); 514 | } 515 | } 516 | } 517 | 518 | /*! 519 | \property QxtSpanSlider::upperPosition 520 | \brief the upper position of the span 521 | */ 522 | int QxtSpanSlider::upperPosition() const 523 | { 524 | return qxt_d().upperPos; 525 | } 526 | 527 | void QxtSpanSlider::setUpperPosition(int upper) 528 | { 529 | if (qxt_d().upperPos != upper) 530 | { 531 | qxt_d().upperPos = upper; 532 | if (!hasTracking()) 533 | update(); 534 | if (isSliderDown()) 535 | emit upperPositionChanged(upper); 536 | if (hasTracking() && !qxt_d().blockTracking) 537 | { 538 | bool main = (qxt_d().mainControl == QxtSpanSliderPrivate::UpperHandle); 539 | qxt_d().triggerAction(SliderMove, main); 540 | } 541 | } 542 | } 543 | 544 | /*! 545 | \reimp 546 | */ 547 | void QxtSpanSlider::keyPressEvent(QKeyEvent* event) 548 | { 549 | QSlider::keyPressEvent(event); 550 | 551 | bool main = true; 552 | SliderAction action = SliderNoAction; 553 | switch (event->key()) 554 | { 555 | case Qt::Key_Left: 556 | main = (orientation() == Qt::Horizontal); 557 | action = !invertedAppearance() ? SliderSingleStepSub : SliderSingleStepAdd; 558 | break; 559 | case Qt::Key_Right: 560 | main = (orientation() == Qt::Horizontal); 561 | action = !invertedAppearance() ? SliderSingleStepAdd : SliderSingleStepSub; 562 | break; 563 | case Qt::Key_Up: 564 | main = (orientation() == Qt::Vertical); 565 | action = invertedControls() ? SliderSingleStepSub : SliderSingleStepAdd; 566 | break; 567 | case Qt::Key_Down: 568 | main = (orientation() == Qt::Vertical); 569 | action = invertedControls() ? SliderSingleStepAdd : SliderSingleStepSub; 570 | break; 571 | case Qt::Key_Home: 572 | main = (qxt_d().mainControl == QxtSpanSliderPrivate::LowerHandle); 573 | action = SliderToMinimum; 574 | break; 575 | case Qt::Key_End: 576 | main = (qxt_d().mainControl == QxtSpanSliderPrivate::UpperHandle); 577 | action = SliderToMaximum; 578 | break; 579 | default: 580 | event->ignore(); 581 | break; 582 | } 583 | 584 | if (action) 585 | qxt_d().triggerAction(action, main); 586 | } 587 | 588 | /*! 589 | \reimp 590 | */ 591 | void QxtSpanSlider::mousePressEvent(QMouseEvent* event) 592 | { 593 | if (minimum() == maximum() || (event->buttons() ^ event->button())) 594 | { 595 | event->ignore(); 596 | return; 597 | } 598 | 599 | qxt_d().handleMousePress(event->pos(), qxt_d().upperPressed, qxt_d().upper, QxtSpanSliderPrivate::UpperHandle); 600 | if (qxt_d().upperPressed != QStyle::SC_SliderHandle) 601 | qxt_d().handleMousePress(event->pos(), qxt_d().lowerPressed, qxt_d().lower, QxtSpanSliderPrivate::LowerHandle); 602 | 603 | qxt_d().firstMovement = true; 604 | event->accept(); 605 | } 606 | 607 | /*! 608 | \reimp 609 | */ 610 | void QxtSpanSlider::mouseMoveEvent(QMouseEvent* event) 611 | { 612 | if (qxt_d().lowerPressed != QStyle::SC_SliderHandle && qxt_d().upperPressed != QStyle::SC_SliderHandle) 613 | { 614 | event->ignore(); 615 | return; 616 | } 617 | 618 | QStyleOptionSlider opt; 619 | qxt_d().initStyleOption(&opt); 620 | const int m = style()->pixelMetric(QStyle::PM_MaximumDragDistance, &opt, this); 621 | int newPosition = qxt_d().pixelPosToRangeValue(qxt_d().pick(event->pos()) - qxt_d().offset); 622 | if (m >= 0) 623 | { 624 | const QRect r = rect().adjusted(-m, -m, m, m); 625 | if (!r.contains(event->pos())) 626 | { 627 | newPosition = qxt_d().position; 628 | } 629 | } 630 | 631 | // pick the preferred handle on the first movement 632 | if (qxt_d().firstMovement) 633 | { 634 | if (qxt_d().lower == qxt_d().upper) 635 | { 636 | if (newPosition < lowerValue()) 637 | { 638 | qxt_d().swapControls(); 639 | qxt_d().firstMovement = false; 640 | } 641 | } 642 | else 643 | { 644 | qxt_d().firstMovement = false; 645 | } 646 | } 647 | 648 | if (qxt_d().lowerPressed == QStyle::SC_SliderHandle) 649 | { 650 | if (qxt_d().movement == NoCrossing) 651 | newPosition = qMin(newPosition, upperValue()); 652 | else if (qxt_d().movement == NoOverlapping) 653 | newPosition = qMin(newPosition, upperValue() - 1); 654 | 655 | if (qxt_d().movement == FreeMovement && newPosition > qxt_d().upper) 656 | { 657 | qxt_d().swapControls(); 658 | setUpperPosition(newPosition); 659 | } 660 | else 661 | { 662 | setLowerPosition(newPosition); 663 | } 664 | } 665 | else if (qxt_d().upperPressed == QStyle::SC_SliderHandle) 666 | { 667 | if (qxt_d().movement == NoCrossing) 668 | newPosition = qMax(newPosition, lowerValue()); 669 | else if (qxt_d().movement == NoOverlapping) 670 | newPosition = qMax(newPosition, lowerValue() + 1); 671 | 672 | if (qxt_d().movement == FreeMovement && newPosition < qxt_d().lower) 673 | { 674 | qxt_d().swapControls(); 675 | setLowerPosition(newPosition); 676 | } 677 | else 678 | { 679 | setUpperPosition(newPosition); 680 | } 681 | } 682 | event->accept(); 683 | } 684 | 685 | /*! 686 | \reimp 687 | */ 688 | void QxtSpanSlider::mouseReleaseEvent(QMouseEvent* event) 689 | { 690 | QSlider::mouseReleaseEvent(event); 691 | setSliderDown(false); 692 | qxt_d().lowerPressed = QStyle::SC_None; 693 | qxt_d().upperPressed = QStyle::SC_None; 694 | update(); 695 | } 696 | 697 | /*! 698 | \reimp 699 | */ 700 | void QxtSpanSlider::paintEvent(QPaintEvent* event) 701 | { 702 | Q_UNUSED(event); 703 | QStylePainter painter(this); 704 | 705 | // groove & ticks 706 | QStyleOptionSlider opt; 707 | qxt_d().initStyleOption(&opt); 708 | opt.sliderValue = 0; 709 | opt.sliderPosition = 0; 710 | opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderTickmarks; 711 | painter.drawComplexControl(QStyle::CC_Slider, opt); 712 | 713 | // handle rects 714 | opt.sliderPosition = qxt_d().lowerPos; 715 | const QRect lr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); 716 | const int lrv = qxt_d().pick(lr.center()); 717 | opt.sliderPosition = qxt_d().upperPos; 718 | const QRect ur = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); 719 | const int urv = qxt_d().pick(ur.center()); 720 | 721 | // span 722 | const int minv = qMin(lrv, urv); 723 | const int maxv = qMax(lrv, urv); 724 | const QPoint c = QRect(lr.center(), ur.center()).center(); 725 | QRect spanRect; 726 | if (orientation() == Qt::Horizontal) 727 | spanRect = QRect(QPoint(minv, c.y() - 2), QPoint(maxv, c.y() + 1)); 728 | else 729 | spanRect = QRect(QPoint(c.x() - 2, minv), QPoint(c.x() + 1, maxv)); 730 | qxt_d().drawSpan(&painter, spanRect); 731 | 732 | // handles 733 | switch (qxt_d().lastPressed) 734 | { 735 | case QxtSpanSliderPrivate::LowerHandle: 736 | qxt_d().drawHandle(&painter, QxtSpanSliderPrivate::UpperHandle); 737 | qxt_d().drawHandle(&painter, QxtSpanSliderPrivate::LowerHandle); 738 | break; 739 | case QxtSpanSliderPrivate::UpperHandle: 740 | default: 741 | qxt_d().drawHandle(&painter, QxtSpanSliderPrivate::LowerHandle); 742 | qxt_d().drawHandle(&painter, QxtSpanSliderPrivate::UpperHandle); 743 | break; 744 | } 745 | } 746 | -------------------------------------------------------------------------------- /source/widgets/qxtspanslider.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtGui module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXTSPANSLIDER_H 26 | #define QXTSPANSLIDER_H 27 | 28 | #include 29 | #include "qxtnamespace.h" 30 | #include "qxtglobal.h" 31 | 32 | class QxtSpanSliderPrivate; 33 | 34 | class QXT_GUI_EXPORT QxtSpanSlider : public QSlider 35 | { 36 | Q_OBJECT 37 | QXT_DECLARE_PRIVATE(QxtSpanSlider) 38 | Q_PROPERTY(int lowerValue READ lowerValue WRITE setLowerValue) 39 | Q_PROPERTY(int upperValue READ upperValue WRITE setUpperValue) 40 | Q_PROPERTY(int lowerPosition READ lowerPosition WRITE setLowerPosition) 41 | Q_PROPERTY(int upperPosition READ upperPosition WRITE setUpperPosition) 42 | Q_PROPERTY(HandleMovementMode handleMovementMode READ handleMovementMode WRITE setHandleMovementMode) 43 | Q_ENUMS(HandleMovementMode) 44 | 45 | public: 46 | explicit QxtSpanSlider(QWidget* parent = 0); 47 | explicit QxtSpanSlider(Qt::Orientation orientation, QWidget* parent = 0); 48 | virtual ~QxtSpanSlider(); 49 | 50 | enum HandleMovementMode 51 | { 52 | FreeMovement, 53 | NoCrossing, 54 | NoOverlapping 55 | }; 56 | 57 | HandleMovementMode handleMovementMode() const; 58 | void setHandleMovementMode(HandleMovementMode mode); 59 | 60 | int lowerValue() const; 61 | int upperValue() const; 62 | 63 | int lowerPosition() const; 64 | int upperPosition() const; 65 | 66 | public Q_SLOTS: 67 | void setLowerValue(int lower); 68 | void setUpperValue(int upper); 69 | void setSpan(int lower, int upper); 70 | 71 | void setLowerPosition(int lower); 72 | void setUpperPosition(int upper); 73 | 74 | Q_SIGNALS: 75 | void spanChanged(int lower, int upper); 76 | void lowerValueChanged(int lower); 77 | void upperValueChanged(int upper); 78 | 79 | void lowerPositionChanged(int lower); 80 | void upperPositionChanged(int upper); 81 | 82 | protected: 83 | virtual void keyPressEvent(QKeyEvent* event); 84 | virtual void mousePressEvent(QMouseEvent* event); 85 | virtual void mouseMoveEvent(QMouseEvent* event); 86 | virtual void mouseReleaseEvent(QMouseEvent* event); 87 | virtual void paintEvent(QPaintEvent* event); 88 | }; 89 | 90 | #endif // QXTSPANSLIDER_H 91 | -------------------------------------------------------------------------------- /source/widgets/qxtspanslider_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtGui module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXTSPANSLIDER_P_H 26 | #define QXTSPANSLIDER_P_H 27 | 28 | #include 29 | #include 30 | #include "qxtspanslider.h" 31 | 32 | QT_FORWARD_DECLARE_CLASS(QStylePainter) 33 | QT_FORWARD_DECLARE_CLASS(QStyleOptionSlider) 34 | 35 | class QxtSpanSliderPrivate : public QObject, public QxtPrivate 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | QXT_DECLARE_PUBLIC(QxtSpanSlider) 41 | 42 | enum SpanHandle 43 | { 44 | NoHandle, 45 | LowerHandle, 46 | UpperHandle 47 | }; 48 | 49 | QxtSpanSliderPrivate(); 50 | void initStyleOption(QStyleOptionSlider* option, SpanHandle handle = UpperHandle) const; 51 | int pick(const QPoint& pt) const 52 | { 53 | return qxt_p().orientation() == Qt::Horizontal ? pt.x() : pt.y(); 54 | } 55 | int pixelPosToRangeValue(int pos) const; 56 | void handleMousePress(const QPoint& pos, QStyle::SubControl& control, int value, SpanHandle handle); 57 | void drawHandle(QStylePainter* painter, SpanHandle handle) const; 58 | void setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2) const; 59 | void drawSpan(QStylePainter* painter, const QRect& rect) const; 60 | void triggerAction(QAbstractSlider::SliderAction action, bool main); 61 | void swapControls(); 62 | 63 | int lower; 64 | int upper; 65 | int lowerPos; 66 | int upperPos; 67 | int offset; 68 | int position; 69 | SpanHandle lastPressed; 70 | SpanHandle mainControl; 71 | QStyle::SubControl lowerPressed; 72 | QStyle::SubControl upperPressed; 73 | QxtSpanSlider::HandleMovementMode movement; 74 | bool firstMovement; 75 | bool blockTracking; 76 | 77 | public Q_SLOTS: 78 | void updateRange(int min, int max); 79 | void movePressedHandle(); 80 | }; 81 | 82 | #endif // QXTSPANSLIDER_P_H 83 | -------------------------------------------------------------------------------- /source/widgets/qxtstringspinbox.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtGui module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | #include "qxtstringspinbox.h" 26 | 27 | class QxtStringSpinBoxPrivate : public QxtPrivate 28 | { 29 | public: 30 | QXT_DECLARE_PUBLIC(QxtStringSpinBox) 31 | int startsWith(const QString& start, QString& string) const; 32 | QStringList strings; 33 | }; 34 | 35 | int QxtStringSpinBoxPrivate::startsWith(const QString& start, QString& string) const 36 | { 37 | const int size = strings.size(); 38 | for (int i = 0; i < size; ++i) 39 | { 40 | if (strings.at(i).startsWith(start, Qt::CaseInsensitive)) 41 | { 42 | // found 43 | string = strings.at(i); 44 | return i; 45 | } 46 | } 47 | // not found 48 | return -1; 49 | } 50 | 51 | /*! 52 | \class QxtStringSpinBox 53 | \inmodule QxtGui 54 | \brief The QxtStringSpinBox widget is a spin box with string items. 55 | 56 | QxtStringSpinBox is spin box that takes strings. QxtStringSpinBox allows 57 | the user to choose a value by clicking the up and down buttons or by 58 | pressing Up or Down on the keyboard to increase or decrease the value 59 | currently displayed. The user can also type the value in manually. 60 | 61 | \image qxtstringspinbox.png "QxtStringSpinBox in Cleanlooks style." 62 | */ 63 | 64 | /*! 65 | Constructs a new QxtStringSpinBox with \a pParent. 66 | */ 67 | QxtStringSpinBox::QxtStringSpinBox(QWidget* pParent) : QSpinBox(pParent) 68 | { 69 | setRange(0, 0); 70 | } 71 | 72 | /*! 73 | Destructs the spin box. 74 | */ 75 | QxtStringSpinBox::~QxtStringSpinBox() 76 | {} 77 | 78 | /*! 79 | \property QxtStringSpinBox::strings 80 | \brief the string items of the spin box. 81 | */ 82 | const QStringList& QxtStringSpinBox::strings() const 83 | { 84 | return qxt_d().strings; 85 | } 86 | 87 | void QxtStringSpinBox::setStrings(const QStringList& strings) 88 | { 89 | qxt_d().strings = strings; 90 | setRange(0, strings.size() - 1); 91 | if (!strings.isEmpty()) 92 | setValue(0); 93 | } 94 | 95 | /*! 96 | \reimp 97 | */ 98 | void QxtStringSpinBox::fixup(QString& input) const 99 | { 100 | // just attempt to change the input string to be valid according to the string list 101 | // no need to result in a valid string, callers of this function are responsible to 102 | // re-test the validity afterwards 103 | 104 | // try finding a string from the list which starts with input 105 | input = input.simplified(); 106 | if (!input.isEmpty()) 107 | { 108 | qxt_d().startsWith(input, input); 109 | } 110 | } 111 | 112 | /*! 113 | \reimp 114 | */ 115 | QValidator::State QxtStringSpinBox::validate(QString& input, int& pos) const 116 | { 117 | // Invalid: input is invalid according to the string list 118 | // Intermediate: it is likely that a little more editing will make the input acceptable 119 | // (e.g. the user types "A" and stringlist contains "ABC") 120 | // Acceptable: the input is valid. 121 | Q_UNUSED(pos); 122 | QString temp; 123 | QValidator::State state = QValidator::Invalid; 124 | if (qxt_d().strings.contains(input)) 125 | { 126 | // exact match 127 | state = QValidator::Acceptable; 128 | } 129 | else if (input.isEmpty() || qxt_d().startsWith(input, temp) != -1) 130 | { 131 | // still empty or some string in the list starts with input 132 | state = QValidator::Intermediate; 133 | } 134 | // else invalid 135 | return state; 136 | } 137 | 138 | /*! 139 | \reimp 140 | */ 141 | QString QxtStringSpinBox::textFromValue(int value) const 142 | { 143 | Q_ASSERT(qxt_d().strings.isEmpty() || (value >= 0 && value < qxt_d().strings.size())); 144 | return qxt_d().strings.isEmpty() ? QLatin1String("") : qxt_d().strings.at(value); 145 | } 146 | 147 | /*! 148 | \reimp 149 | */ 150 | int QxtStringSpinBox::valueFromText(const QString& text) const 151 | { 152 | return qxt_d().strings.indexOf(text); 153 | } 154 | -------------------------------------------------------------------------------- /source/widgets/qxtstringspinbox.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtGui module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXTSTRINGSPINBOX_H 26 | #define QXTSTRINGSPINBOX_H 27 | 28 | #include 29 | #include "qxtglobal.h" 30 | 31 | class QxtStringSpinBoxPrivate; 32 | 33 | class QXT_GUI_EXPORT QxtStringSpinBox : public QSpinBox 34 | { 35 | Q_OBJECT 36 | QXT_DECLARE_PRIVATE(QxtStringSpinBox) 37 | Q_PROPERTY(QStringList strings READ strings WRITE setStrings) 38 | 39 | public: 40 | explicit QxtStringSpinBox(QWidget* pParent = 0); 41 | virtual ~QxtStringSpinBox(); 42 | 43 | const QStringList& strings() const; 44 | void setStrings(const QStringList& strings); 45 | 46 | virtual void fixup(QString& input) const; 47 | virtual QValidator::State validate(QString& input, int& pos) const; 48 | 49 | protected: 50 | virtual QString textFromValue(int value) const; 51 | virtual int valueFromText(const QString& text) const; 52 | }; 53 | 54 | #endif // QXTSTRINGSPINBOX_H 55 | --------------------------------------------------------------------------------