├── .gitignore ├── CMakeLists.txt ├── COPYING ├── README.md ├── cmake ├── AsteroidCMakeSettings.cmake ├── AsteroidTranslations.cmake ├── FindLipstick.cmake ├── FindMapplauncherd_qt5.cmake ├── FindMce.cmake ├── FindMlite5.cmake ├── FindQtMpris.cmake ├── FindSystemSettings.cmake └── FindTimed.cmake ├── generate-desktop.sh └── src ├── CMakeLists.txt ├── app ├── AsteroidAppConfig.cmake.in ├── CMakeLists.txt ├── asteroidapp.cpp ├── asteroidapp.h └── asteroidapp.prf ├── controls ├── CMakeLists.txt ├── doc │ ├── asteroid_controls.qdocconf │ └── images │ │ ├── PageDotExample.jpg │ │ ├── SpinnerExample.jpg │ │ └── labelExample.jpg ├── qml │ ├── Application.qml │ ├── BorderGestureArea.qml │ ├── CircularSpinner.qml │ ├── Dims.qml │ ├── HandWritingKeyboard.qml │ ├── HighlightBar.qml │ ├── IconButton.qml │ ├── Indicator.qml │ ├── IntSelector.qml │ ├── Label.qml │ ├── LabeledActionButton.qml │ ├── LabeledSwitch.qml │ ├── LayerStack.qml │ ├── ListItem.qml │ ├── Marquee.qml │ ├── PageDot.qml │ ├── PageHeader.qml │ ├── SegmentedArc.qml │ ├── Spinner.qml │ ├── SpinnerDelegate.qml │ ├── StatusPage.qml │ ├── Switch.qml │ ├── TextArea.qml │ ├── TextBase.qml │ └── TextField.qml ├── qmldir ├── resources.qrc └── src │ ├── application_p.cpp │ ├── application_p.h │ ├── controls_plugin.cpp │ ├── controls_plugin.h │ ├── flatmesh.cpp │ ├── flatmesh.h │ ├── flatmeshnode.cpp │ ├── flatmeshnode.h │ ├── icon.cpp │ └── icon.h └── utils ├── CMakeLists.txt ├── doc └── asteroid_utils.qdocconf ├── qmldir └── src ├── bluetoothstatus.cpp ├── bluetoothstatus.h ├── devicespecs.cpp ├── devicespecs.h ├── fileinfo.cpp ├── fileinfo.h ├── utils_plugin.cpp └── utils_plugin.h /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *~ 3 | *.autosave 4 | *.a 5 | *.core 6 | *.moc 7 | *.o 8 | *.obj 9 | *.orig 10 | *.rej 11 | *.so 12 | *.so.* 13 | *_pch.h.cpp 14 | *_resource.rc 15 | *.qm 16 | .#* 17 | *.*# 18 | core 19 | !core/ 20 | tags 21 | .DS_Store 22 | *.debug 23 | Makefile* 24 | *.prl 25 | *.app 26 | moc_*.cpp 27 | ui_*.h 28 | qrc_*.cpp 29 | Thumbs.db 30 | *.res 31 | *.rc 32 | build 33 | 34 | # qtcreator generated files 35 | *.pro.user* 36 | *.qmlproject.user* 37 | 38 | # xemacs temporary files 39 | *.flc 40 | 41 | # Vim temporary files 42 | .*.swp 43 | 44 | # Visual Studio generated files 45 | *.ib_pdb_index 46 | *.idb 47 | *.ilk 48 | *.pdb 49 | *.sln 50 | *.suo 51 | *.vcproj 52 | *vcproj.*.*.user 53 | *.ncb 54 | *.sdf 55 | *.opensdf 56 | *.vcxproj 57 | *vcxproj.* 58 | 59 | # MinGW generated files 60 | *.Debug 61 | *.Release 62 | 63 | # Python byte code 64 | *.pyc 65 | 66 | # Binaries 67 | # -------- 68 | *.dll 69 | *.exe 70 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.6.0) 2 | 3 | project(qml-asteroid 4 | VERSION 2.0.0 5 | DESCRIPTION "QML components, styles and demos for AsteroidOS") 6 | 7 | find_package(ECM REQUIRED NO_MODULE) 8 | 9 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) 10 | 11 | option(WITH_ASTEROIDAPP "Build the AsteroidApp class" ON) 12 | option(WITH_CMAKE_MODULES "Install AsteroidOS CMake modules" ON) 13 | 14 | include(FeatureSummary) 15 | include(GNUInstallDirs) 16 | include(ECMFindQmlModule) 17 | include(ECMGeneratePkgConfigFile) 18 | include(AsteroidCMakeSettings) 19 | 20 | set(ASTEROID_MODULES_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/asteroidapp/cmake) 21 | 22 | find_package(Qt5 ${QT_MIN_VERSION} COMPONENTS DBus Qml Quick Svg REQUIRED) 23 | if (WITH_ASTEROIDAPP) 24 | find_package(Mlite5 MODULE REQUIRED) 25 | find_package(Mapplauncherd_qt5 MODULE REQUIRED) 26 | endif() 27 | 28 | ecm_find_qmlmodule(QtQuick.VirtualKeyboard 2.1) 29 | 30 | if (WITH_CMAKE_MODULES) 31 | # Install CMake modules 32 | file(GLOB installAsteroidModuleFiles LIST_DIRECTORIES FALSE ${CMAKE_SOURCE_DIR}/cmake/*[^~]) 33 | install(FILES ${installAsteroidModuleFiles} DESTINATION ${ASTEROID_MODULES_INSTALL_DIR}) 34 | else() 35 | get_target_property(REAL_QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION) 36 | 37 | if (NOT QT_INSTALL_QML) 38 | execute_process(COMMAND "${REAL_QMAKE_EXECUTABLE}" -query QT_INSTALL_QML 39 | OUTPUT_VARIABLE QT_INSTALL_QML 40 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) 41 | endif() 42 | set(INSTALL_QML_IMPORT_DIR ${QT_INSTALL_QML}) 43 | endif() 44 | 45 | add_subdirectory(src) 46 | 47 | if (WITH_ASTEROIDAPP) 48 | install(PROGRAMS generate-desktop.sh 49 | DESTINATION ${CMAKE_INSTALL_BINDIR} 50 | RENAME asteroid-generate-desktop) 51 | endif() 52 | 53 | feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) 54 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QML Components for Asteroid 2 | 3 | QML-Asteroid provides elements to develop applications for [AsteroidOS](http://asteroidos.org). 4 | 5 | ## Non-watch version 6 | It's often convenient to develop on a desktop computer rather than directly on the watch. For that reason, `qml-asteroid` also supports building a non-watch version. To build and install it on a desktop computer, one can turn off the generation of the AsteroidApp class and the installation of CMake modules. For example, in the project's main directory, we might execute this command: 7 | 8 | ``` 9 | cmake -DWITH_ASTEROIDAPP=OFF -DWITH_CMAKE_MODULES=OFF -S . -B desktop 10 | ``` 11 | 12 | This will create a directory `desktop` which will then contain all of the CMake-generated build scripts. To build the modules: 13 | 14 | ``` 15 | cmake --build desktop -j 16 | ``` 17 | 18 | This tells CMake to build in the `desktop` directory and the `-j` tells it to use as many cores as possible to speed up the build. Once this is done, one can install the modules on the computer: 19 | 20 | ``` 21 | sudo cmake --build desktop -j -t install 22 | ``` 23 | 24 | This uses `sudo` because root privileges are generally needed for installation. The `-t install` tells CMake that the build target (that is, the goal) is `install` so the `org.asteroid.controls` and `org.asteroid.utils` QML modules will be installed in the correct location for the computer and may then be used, for example, in testing and developing watchfaces. 25 | -------------------------------------------------------------------------------- /cmake/AsteroidCMakeSettings.cmake: -------------------------------------------------------------------------------- 1 | if (NOT ASTEROID_SKIP_BUILD_SETTINGS) 2 | # Always include srcdir and builddir in include path 3 | # This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} in about every subdir 4 | # since cmake 2.4.0 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | 7 | # put the include dirs which are in the source or build tree 8 | # before all other include dirs, so the headers in the sources 9 | # are preferred over the already installed ones 10 | # since cmake 2.4.1 11 | set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) 12 | 13 | # Add the src and build dir to the BUILD_INTERFACE include directories 14 | # of all targets. Similar to CMAKE_INCLUDE_CURRENT_DIR, but transitive. 15 | # Since CMake 2.8.11 16 | set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) 17 | 18 | # When a shared library changes, but its includes do not, don't relink 19 | # all dependencies. It is not needed. 20 | # Since CMake 2.8.11 21 | set(CMAKE_LINK_DEPENDS_NO_SHARED ON) 22 | 23 | # Default to shared libs, if no type is explicitly given to add_library(): 24 | set(BUILD_SHARED_LIBS TRUE CACHE BOOL "If enabled, shared libs will be built by default, otherwise static libs") 25 | 26 | # Enable automoc in cmake 27 | # Since CMake 2.8.6 28 | set(CMAKE_AUTOMOC ON) 29 | 30 | # Enable autorcc and in cmake so qrc files get generated 31 | # Since CMake 3.0 32 | set(CMAKE_AUTORCC ON) 33 | 34 | set(INSTALL_QML_IMPORT_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/qml" 35 | CACHE PATH "Custom QML import installation directory") 36 | 37 | set(QT_MIN_VERSION "5.12.0") 38 | endif() 39 | -------------------------------------------------------------------------------- /cmake/AsteroidTranslations.cmake: -------------------------------------------------------------------------------- 1 | function(BUILD_TRANSLATIONS directory) 2 | if(TARGET build-translations) 3 | message(WARNING "The build_translations function was already called") 4 | return() 5 | endif() 6 | 7 | find_package(Qt5LinguistTools REQUIRED) 8 | 9 | file(GLOB LANGUAGE_FILES_TS ${directory}/*.ts) 10 | #set_source_files_properties(${LANGUAGE_FILES_TS} PROPERTIES OUTPUT_LOCATION "i18n") 11 | qt5_add_translation(LANGUAGE_FILES_QM ${LANGUAGE_FILES_TS} OPTIONS "-idbased") 12 | add_custom_target(build-translations ALL 13 | COMMENT "Building translations in ${director}..." 14 | DEPENDS ${LANGUAGE_FILES_QM}) 15 | 16 | install(FILES ${LANGUAGE_FILES_QM} 17 | DESTINATION ${CMAKE_INSTALL_DATADIR}/translations) 18 | endfunction() 19 | 20 | function(GENERATE_DESKTOP src_directory application_name) 21 | find_program(generate_desktop_executable 22 | NAMES asteroid-generate-desktop) 23 | 24 | set(OUTPUT_DESKTOP_FILE ${CMAKE_BINARY_DIR}/${application_name}.desktop) 25 | execute_process( 26 | COMMAND ${generate_desktop_executable} ${src_directory} ${application_name} ${OUTPUT_DESKTOP_FILE}) 27 | 28 | install(FILES ${OUTPUT_DESKTOP_FILE} 29 | DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) 30 | endfunction() 31 | -------------------------------------------------------------------------------- /cmake/FindLipstick.cmake: -------------------------------------------------------------------------------- 1 | # Try to find lipstick-qt5 2 | # Once done this will define 3 | # LIPSTICK_FOUND - System has lipstick 4 | # LIPSTICK_INCLUDE_DIRS - The lipstick include directories 5 | # LIPSTICK_LIBRARIES - The libraries needed to use lipstick 6 | # LIPSTICK_DEFINITIONS - Compiler switches required for using lipstick 7 | 8 | find_package(PkgConfig REQUIRED) 9 | pkg_check_modules(PC_Lipstick QUIET lipstick-qt5) 10 | set(Lipstick_DEFINITIONS ${PC_Lipstick_CFLAGS_OTHER}) 11 | 12 | find_path(Lipstick_INCLUDE_DIRS 13 | NAMES lipstickcompositor.h 14 | PATH_SUFFIXES lipstick-qt5 15 | PATHS ${PC_Lipstick_INCLUDEDIR} ${PC_Lipstick_INCLUDE_DIRS}) 16 | 17 | find_library(Lipstick_LIBRARIES 18 | NAMES lipstick-qt5 19 | PATHS ${PC_Lipstick_LIBDIR} ${PC_Lipstick_LIBRARY_DIRS}) 20 | 21 | set(Lipstick_VERSION ${PC_Lipstick_VERSION}) 22 | 23 | include(FindPackageHandleStandardArgs) 24 | find_package_handle_standard_args(Lipstick 25 | FOUND_VAR 26 | Lipstick_FOUND 27 | REQUIRED_VARS 28 | Lipstick_LIBRARIES 29 | Lipstick_INCLUDE_DIRS 30 | VERSION_VAR 31 | Lipstick_VERSION) 32 | 33 | mark_as_advanced(Lipstick_INCLUDE_DIR Lipstick_LIBRARY Lipstick_VERSION) 34 | 35 | if(Lipstick_FOUND AND NOT TARGET Lipstick::Lipstick) 36 | add_library(Lipstick::Lipstick UNKNOWN IMPORTED) 37 | set_target_properties(Lipstick::Lipstick PROPERTIES 38 | IMPORTED_LOCATION "${Lipstick_LIBRARIES}" 39 | INTERFACE_INCLUDE_DIRECTORIES "${Lipstick_INCLUDE_DIRS}") 40 | endif() 41 | -------------------------------------------------------------------------------- /cmake/FindMapplauncherd_qt5.cmake: -------------------------------------------------------------------------------- 1 | # Try to find qdeclarative5-boostable 2 | # Once done this will define 3 | # MAPPLAUNCHERD_QT5_FOUND - System has qdeclarative 4 | # MAPPLAUNCHERD_QT5_INCLUDE_DIRS - The qdeclarative include directories 5 | # MAPPLAUNCHERD_QT5_LIBRARIES - The libraries needed to use qdeclarative 6 | # MAPPLAUNCHERD_QT5_DEFINITIONS - Compiler switches required for using qdeclarative 7 | 8 | find_package(PkgConfig REQUIRED) 9 | pkg_check_modules(PC_Mapplauncherd_qt5 QUIET qdeclarative5-boostable) 10 | set(Mapplauncherd_qt5_DEFINITIONS ${PC_Mapplauncherd_qt5_CFLAGS_OTHER}) 11 | 12 | find_path(Mapplauncherd_qt5_INCLUDE_DIRS 13 | NAMES mdeclarativecache.h 14 | PATH_SUFFIXES mdeclarativecache5 15 | PATHS ${PC_Mapplauncherd_qt5_INCLUDEDIR} ${PC_Mapplauncherd_qt5_INCLUDE_DIRS}) 16 | 17 | find_library(Mapplauncherd_qt5_LIBRARIES 18 | NAMES mdeclarativecache5 19 | PATHS ${PC_Mapplauncherd_qt5_LIBDIR} ${PC_Mapplauncherd_qt5_LIBRARY_DIRS}) 20 | 21 | set(Mapplauncherd_qt5_VERSION ${PC_Mapplauncherd_qt5_VERSION}) 22 | 23 | include(FindPackageHandleStandardArgs) 24 | find_package_handle_standard_args(Mapplauncherd_qt5 25 | FOUND_VAR 26 | Mapplauncherd_qt5_FOUND 27 | REQUIRED_VARS 28 | Mapplauncherd_qt5_LIBRARIES 29 | Mapplauncherd_qt5_INCLUDE_DIRS 30 | VERSION_VAR 31 | Mapplauncherd_qt5_VERSION) 32 | 33 | mark_as_advanced(Mapplauncherd_qt5_INCLUDE_DIR Mapplauncherd_qt5_LIBRARY Mapplauncherd_qt5_VERSION) 34 | 35 | if(Mapplauncherd_qt5_FOUND AND NOT TARGET Mapplauncherd_qt5::Mapplauncherd_qt5) 36 | add_library(Mapplauncherd_qt5::Mapplauncherd_qt5 UNKNOWN IMPORTED) 37 | set_target_properties(Mapplauncherd_qt5::Mapplauncherd_qt5 PROPERTIES 38 | IMPORTED_LOCATION "${Mapplauncherd_qt5_LIBRARIES}" 39 | INTERFACE_INCLUDE_DIRECTORIES "${Mapplauncherd_qt5_INCLUDE_DIRS}") 40 | endif() 41 | -------------------------------------------------------------------------------- /cmake/FindMce.cmake: -------------------------------------------------------------------------------- 1 | # Try to find mce 2 | # Once done this will define 3 | # MCE_FOUND - System has mce 4 | # MCE_INCLUDE_DIRS - The mce include directories 5 | # MCE_LIBRARIES - The libraries needed to use mce 6 | # MCE_DEFINITIONS - Compiler switches required for using mce 7 | 8 | find_package(PkgConfig REQUIRED) 9 | pkg_check_modules(PC_Mce QUIET mce) 10 | set(Mce_DEFINITIONS ${PC_Mce_CFLAGS_OTHER}) 11 | 12 | find_path(Mce_INCLUDE_DIRS 13 | NAMES mode-names.h 14 | PATH_SUFFIXES mce 15 | PATHS ${PC_Mce_INCLUDEDIR} ${PC_Mce_INCLUDE_DIRS}) 16 | 17 | set(Mce_VERSION ${PC_Mce_VERSION}) 18 | 19 | include(FindPackageHandleStandardArgs) 20 | find_package_handle_standard_args(Mce 21 | FOUND_VAR 22 | Mce_FOUND 23 | REQUIRED_VARS 24 | Mce_INCLUDE_DIRS 25 | VERSION_VAR 26 | Mce_VERSION) 27 | 28 | mark_as_advanced(Mce_LIBRARY Mce_VERSION) 29 | 30 | if(Mce_FOUND AND NOT TARGET Mce::Mce) 31 | add_library(Mce::Mce UNKNOWN IMPORTED) 32 | set_target_properties(Mce::Mce PROPERTIES 33 | INTERFACE_INCLUDE_DIRECTORIES "${Mce5_INCLUDE_DIRS}") 34 | endif() 35 | -------------------------------------------------------------------------------- /cmake/FindMlite5.cmake: -------------------------------------------------------------------------------- 1 | # Try to find mlite5 2 | # Once done this will define 3 | # MLITE5_FOUND - System has mlite5 4 | # MLITE5_INCLUDE_DIRS - The mlite5 include directories 5 | # MLITE5_LIBRARIES - The libraries needed to use mlite5 6 | # MLITE5_DEFINITIONS - Compiler switches required for using mlite5 7 | 8 | find_package(PkgConfig REQUIRED) 9 | pkg_check_modules(PC_Mlite5 QUIET mlite5) 10 | set(Mlite5_DEFINITIONS ${PC_Mlite5_CFLAGS_OTHER}) 11 | 12 | find_path(Mlite5_INCLUDE_DIRS 13 | NAMES mlite-global.h 14 | PATH_SUFFIXES mlite5 15 | PATHS ${PC_Mlite5_INCLUDEDIR} ${PC_Mlite5_INCLUDE_DIRS}) 16 | 17 | find_library(Mlite5_LIBRARIES 18 | NAMES mlite5 19 | PATHS ${PC_Mlite5_LIBDIR} ${PC_Mlite5_LIBRARY_DIRS}) 20 | 21 | set(Mlite5_VERSION ${PC_Mlite5_VERSION}) 22 | 23 | include(FindPackageHandleStandardArgs) 24 | find_package_handle_standard_args(Mlite5 25 | FOUND_VAR 26 | Mlite5_FOUND 27 | REQUIRED_VARS 28 | Mlite5_LIBRARIES 29 | Mlite5_INCLUDE_DIRS 30 | VERSION_VAR 31 | Mlite5_VERSION) 32 | 33 | mark_as_advanced(Mlite5_INCLUDE_DIR Mlite5_LIBRARY Mlite5_VERSION) 34 | 35 | if(Mlite5_FOUND AND NOT TARGET Mlite5::Mlite5) 36 | add_library(Mlite5::Mlite5 UNKNOWN IMPORTED) 37 | set_target_properties(Mlite5::Mlite5 PROPERTIES 38 | IMPORTED_LOCATION "${Mlite5_LIBRARIES}" 39 | INTERFACE_INCLUDE_DIRECTORIES "${Mlite5_INCLUDE_DIRS}") 40 | endif() 41 | -------------------------------------------------------------------------------- /cmake/FindQtMpris.cmake: -------------------------------------------------------------------------------- 1 | # Try to find mpris 2 | # Once done this will define 3 | # QTMPRIS_FOUND - System has mpris 4 | # QTMPRIS_INCLUDE_DIRS - The mpris include directories 5 | # QTMPRIS_LIBRARIES - The libraries needed to use mpris 6 | # QTMPRIS_DEFINITIONS - Compiler switches required for using mpris 7 | 8 | find_package(PkgConfig REQUIRED) 9 | pkg_check_modules(PC_QtMpris QUIET mpris-qt5) 10 | set(QtMpris_DEFINITIONS ${PC_QtMpris_CFLAGS_OTHER}) 11 | 12 | find_path(QtMpris_INCLUDE_DIRS 13 | NAMES mpris.h 14 | PATH_SUFFIXES mpris 15 | PATHS ${PC_QtMpris_INCLUDEDIR} ${PC_QtMpris_INCLUDE_DIRS}) 16 | 17 | find_library(QtMpris_LIBRARIES 18 | NAMES mpris-qt5 19 | PATHS ${PC_QtMpris_LIBDIR} ${PC_QtMpris_LIBRARY_DIRS}) 20 | 21 | set(QtMpris_VERSION ${PC_QtMpris_VERSION}) 22 | 23 | include(FindPackageHandleStandardArgs) 24 | find_package_handle_standard_args(QtMpris 25 | FOUND_VAR 26 | QtMpris_FOUND 27 | REQUIRED_VARS 28 | QtMpris_LIBRARIES 29 | QtMpris_INCLUDE_DIRS 30 | VERSION_VAR 31 | QtMpris_VERSION) 32 | 33 | mark_as_advanced(QtMpris_INCLUDE_DIR QtMpris_LIBRARY QtMpris_VERSION) 34 | 35 | if(QtMpris_FOUND AND NOT TARGET QtMpris::QtMpris) 36 | add_library(QtMpris::QtMpris UNKNOWN IMPORTED) 37 | set_target_properties(QtMpris::QtMpris PROPERTIES 38 | IMPORTED_LOCATION "${QtMpris_LIBRARIES}" 39 | INTERFACE_INCLUDE_DIRECTORIES "${QtMpris_INCLUDE_DIRS}") 40 | endif() 41 | -------------------------------------------------------------------------------- /cmake/FindSystemSettings.cmake: -------------------------------------------------------------------------------- 1 | # Try to find systemsettings 2 | # Once done this will define 3 | # SYSTEMSETTINGS_FOUND - System has systemsettings 4 | # SYSTEMSETTINGS_INCLUDE_DIRS - The systemsettings include directories 5 | # SYSTEMSETTINGS_LIBRARIES - The libraries needed to use systemsettings 6 | # SYSTEMSETTINGS_DEFINITIONS - Compiler switches required for using systemsettings 7 | 8 | find_package(PkgConfig REQUIRED) 9 | pkg_check_modules(PC_SystemSettings QUIET systemsettings) 10 | set(SystemSettings_DEFINITIONS ${PC_SystemSettings_CFLAGS_OTHER}) 11 | 12 | find_path(SystemSettings_INCLUDE_DIRS 13 | NAMES aboutsettings.h 14 | PATH_SUFFIXES systemsettings 15 | PATHS ${PC_SystemSettings_INCLUDEDIR} ${PC_SystemSettings_INCLUDE_DIRS}) 16 | 17 | find_library(SystemSettings_LIBRARIES 18 | NAMES systemsettings 19 | PATHS ${PC_SystemSettings_LIBDIR} ${PC_SystemSettings_LIBRARY_DIRS}) 20 | 21 | set(SystemSettings_VERSION ${PC_SystemSettings_VERSION}) 22 | 23 | include(FindPackageHandleStandardArgs) 24 | find_package_handle_standard_args(SystemSettings 25 | FOUND_VAR 26 | SystemSettings_FOUND 27 | REQUIRED_VARS 28 | SystemSettings_LIBRARIES 29 | SystemSettings_INCLUDE_DIRS 30 | VERSION_VAR 31 | SystemSettings_VERSION) 32 | 33 | mark_as_advanced(SystemSettings_INCLUDE_DIR SystemSettings_LIBRARY SystemSettings_VERSION) 34 | 35 | if(SystemSettings_FOUND AND NOT TARGET SystemSettings::SystemSettings) 36 | add_library(SystemSettings::SystemSettings UNKNOWN IMPORTED) 37 | set_target_properties(SystemSettings::SystemSettings PROPERTIES 38 | IMPORTED_LOCATION "${SystemSettings_LIBRARIES}" 39 | INTERFACE_INCLUDE_DIRECTORIES "${SystemSettings_INCLUDE_DIRS}") 40 | endif() 41 | -------------------------------------------------------------------------------- /cmake/FindTimed.cmake: -------------------------------------------------------------------------------- 1 | # Try to find timed-qt5 2 | # Once done this will define 3 | # TIMED_FOUND - System has timed 4 | # TIMED_INCLUDE_DIRS - The timed include directories 5 | # TIMED_LIBRARIES - The libraries needed to use timed 6 | 7 | find_package(PkgConfig REQUIRED) 8 | pkg_check_modules(PC_Timed QUIET timed-qt5) 9 | 10 | find_library(Timed_LIBRARIES 11 | NAMES timed-qt5 12 | PATHS ${PC_Timed_LIBDIR} ${PC_Timed_LIBRARY_DIRS}) 13 | 14 | set(Timed_VERSION ${PC_Timed_VERSION}) 15 | 16 | include(FindPackageHandleStandardArgs) 17 | find_package_handle_standard_args(Timed 18 | FOUND_VAR 19 | Timed_FOUND 20 | REQUIRED_VARS 21 | Timed_LIBRARIES 22 | VERSION_VAR 23 | Timed_VERSION) 24 | 25 | mark_as_advanced(Timed_LIBRARIES Timed_VERSION) 26 | 27 | if(Timed_FOUND AND NOT TARGET Timed::Timed) 28 | add_library(Timed::Timed UNKNOWN IMPORTED) 29 | set_target_properties(Timed::Timed PROPERTIES 30 | IMPORTED_LOCATION "${Timed_LIBRARIES}") 31 | endif() 32 | -------------------------------------------------------------------------------- /generate-desktop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (C) 2017 Florent Revest 4 | # All rights reserved. 5 | # 6 | # You may use this file under the terms of BSD license as follows: 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # * Neither the name of the author nor the 16 | # names of its contributors may be used to endorse or promote products 17 | # derived from this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 23 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | # This script is used to extract the translated app names found inevery .ts file 31 | # and gather those strings with the .desktop.template file in a single .desktop 32 | 33 | if [ "$#" -ne 3 ]; then 34 | echo "usage: $0 src_directory application_name output_file" 35 | exit 1 36 | fi 37 | 38 | SRC_DIR=$1 39 | APPLICATION_NAME=$2 40 | OUTPUT_FILE=$3 41 | if [ ! -f "${SRC_DIR}/${APPLICATION_NAME}.desktop.template" ]; then 42 | echo "${SRC_DIR}/${APPLICATION_NAME}.desktop.template not found" 43 | exit 2 44 | fi 45 | if [ ! -f "${SRC_DIR}/i18n/${APPLICATION_NAME}.desktop.h" ]; then 46 | echo "${SRC_DIR}/i18n/${APPLICATION_NAME}.desktop.h not found" 47 | exit 2 48 | fi 49 | 50 | DEFAULT_NAME=$(grep -oP '//% "\K[^"]+(?=")' "${SRC_DIR}/i18n/${APPLICATION_NAME}.desktop.h") 51 | if [ -z "$DEFAULT_NAME" ]; then 52 | echo "Default name can not be found in ${SRC_DIR}/i18n/${APPLICATION_NAME}.desktop.h" 53 | exit 3 54 | fi 55 | 56 | cat "${SRC_DIR}/${APPLICATION_NAME}.desktop.template" > "$OUTPUT_FILE" 57 | echo "Name=$DEFAULT_NAME" >> "$OUTPUT_FILE" 58 | 59 | for FILE in "${SRC_DIR}"/i18n/*.ts; do 60 | echo "Processing $FILE..." 61 | 62 | PROCESSED_LANG=$(grep -oP 'language="\K[^"]+(?=")' "$FILE") 63 | if [ -z "$PROCESSED_LANG" ]; then 64 | echo "> Couldn't find a corresponding language id, aborting" 65 | continue 66 | fi 67 | echo "> Language: $PROCESSED_LANG detected" 68 | 69 | TRANSLATION_LINE=$(grep -A 3 '' "$FILE" | grep ' Couldn't find a corresponding desktop.h translation, aborting" 72 | continue 73 | fi 74 | 75 | LINE_IS_UNFINISHED=$(echo "$TRANSLATION_LINE" | grep unfinished) 76 | if [ -n "$LINE_IS_UNFINISHED" ]; then 77 | echo "> Translation line has been found but is marked as unfinished, aborting" 78 | continue 79 | fi 80 | 81 | TRANSLATED_NAME=$(echo "$TRANSLATION_LINE" | grep -oP '>\K[^<]*(?=)') 82 | if [ -z "$TRANSLATED_NAME" ]; then 83 | echo "> Translation is empty, aborting" 84 | continue 85 | fi 86 | echo "> Translation '$TRANSLATED_NAME' found, filling $OUTPUT_FILE" 87 | 88 | echo "Name[$PROCESSED_LANG]=$TRANSLATED_NAME" >> "$OUTPUT_FILE" 89 | done 90 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (WITH_ASTEROIDAPP) 2 | add_subdirectory(app) 3 | endif() 4 | add_subdirectory(controls) 5 | add_subdirectory(utils) 6 | -------------------------------------------------------------------------------- /src/app/AsteroidAppConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include(CMakeFindDependencyMacro) 4 | find_dependency(Qt5Qml @QT_MIN_VERSION@) 5 | find_dependency(Qt5Quick @QT_MIN_VERSION@) 6 | 7 | set(ASTEROID_MODULE_PATH "@PACKAGE_ASTEROID_MODULES_INSTALL_DIR@") 8 | 9 | include("${CMAKE_CURRENT_LIST_DIR}/AsteroidAppTargets.cmake") 10 | @PACKAGE_INCLUDE_QCHTARGETS@ 11 | -------------------------------------------------------------------------------- /src/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRC asteroidapp.cpp) 2 | set(HEADERS asteroidapp.h) 3 | 4 | add_library(asteroidapp ${SRC} ${HEADERS}) 5 | 6 | target_link_libraries(asteroidapp 7 | PUBLIC 8 | Qt5::Qml 9 | Qt5::Quick 10 | PRIVATE 11 | Mlite5::Mlite5 12 | Mapplauncherd_qt5::Mapplauncherd_qt5) 13 | 14 | set_target_properties(asteroidapp PROPERTIES 15 | EXPORT_NAME AsteroidApp 16 | SOVERSION ${PROJECT_VERSION_MAJOR} 17 | VERSION ${PROJECT_VERSION}) 18 | 19 | target_include_directories(asteroidapp PUBLIC 20 | $ 21 | $) 22 | 23 | # Install the library 24 | install(TARGETS asteroidapp 25 | EXPORT AsteroidAppTargets 26 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) 27 | 28 | # Install headers 29 | install(FILES ${HEADERS} 30 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/asteroidapp 31 | COMPONENT Devel) 32 | 33 | install(FILES asteroidapp.prf 34 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/mkspecs/features 35 | COMPONENT Devel) 36 | 37 | ecm_generate_pkgconfig_file( 38 | BASE_NAME asteroidapp 39 | DEPS qdeclarative5-boostable 40 | FILENAME_VAR asteroidapp 41 | DESCRIPTION ${PROJECT_DESCRIPTION} 42 | INSTALL) 43 | 44 | # Configure and install the CMake Config file 45 | include(CMakePackageConfigHelpers) 46 | set(CMAKECONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/asteroidapp) 47 | 48 | configure_package_config_file( 49 | "AsteroidAppConfig.cmake.in" 50 | "${CMAKE_CURRENT_BINARY_DIR}/AsteroidAppConfig.cmake" 51 | INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} 52 | PATH_VARS 53 | CMAKE_INSTALL_PREFIX 54 | CMAKE_INSTALL_INCLUDEDIR 55 | CMAKE_INSTALL_LIBDIR 56 | ASTEROID_MODULES_INSTALL_DIR 57 | NO_CHECK_REQUIRED_COMPONENTS_MACRO) 58 | write_basic_package_version_File(${CMAKE_CURRENT_BINARY_DIR}/AsteroidAppConfigVersion.cmake 59 | VERSION ${asteroidapp_VERSION} 60 | COMPATIBILITY SameMajorVersion) 61 | 62 | install(EXPORT AsteroidAppTargets 63 | DESTINATION ${CMAKECONFIG_INSTALL_DIR} 64 | COMPONENT Devel) 65 | 66 | install(FILES 67 | "${CMAKE_CURRENT_BINARY_DIR}/AsteroidAppConfig.cmake" 68 | "${CMAKE_CURRENT_BINARY_DIR}/AsteroidAppConfigVersion.cmake" 69 | DESTINATION ${CMAKECONFIG_INSTALL_DIR} 70 | COMPONENT Devel) 71 | -------------------------------------------------------------------------------- /src/app/asteroidapp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 - Florent Revest 3 | * Copyright (C) 2013 - 2014 Jolla Ltd. 4 | * Contact: Thomas Perl 5 | * All rights reserved. 6 | * 7 | * This file is part of qml-asteroid 8 | * 9 | * You may use this file under the terms of the GNU Lesser General 10 | * Public License version 2.1 as published by the Free Software Foundation 11 | * and appearing in the file license.lgpl included in the packaging 12 | * of this file. 13 | * 14 | * This library is free software; you can redistribute it and/or 15 | * modify it under the terms of the GNU Lesser General Public 16 | * License version 2.1 as published by the Free Software Foundation 17 | * and appearing in the file license.lgpl included in the packaging 18 | * of this file. 19 | * 20 | * This library is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * Lesser General Public License for more details. 24 | * 25 | */ 26 | 27 | #include "asteroidapp.h" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | static QString applicationPath() 39 | { 40 | QString argv0 = QCoreApplication::arguments()[0]; 41 | 42 | if (argv0.startsWith("/")) { 43 | // First, try argv[0] if it's an absolute path (needed for booster) 44 | return argv0; 45 | } else { 46 | // If that doesn't give an absolute path, use /proc-based detection 47 | return QCoreApplication::applicationFilePath(); 48 | } 49 | } 50 | 51 | namespace AsteroidApp { 52 | QString appName() 53 | { 54 | QFileInfo exe = QFileInfo(applicationPath()); 55 | return exe.baseName(); 56 | } 57 | 58 | QGuiApplication *application(int &argc, char **argv) 59 | { 60 | static QGuiApplication *app = NULL; 61 | 62 | if (app == NULL) { 63 | app = MDeclarativeCache::qApplication(argc, argv); 64 | 65 | app->setOrganizationName(appName()); 66 | app->setOrganizationDomain(appName()); 67 | app->setApplicationName(appName()); 68 | 69 | QTranslator *translator = new QTranslator(); 70 | translator->load(QLocale(), appName(), ".", "/usr/share/translations", ".qm"); 71 | app->installTranslator(translator); 72 | } else { 73 | qWarning("AsteroidApp::application() called multiple times"); 74 | } 75 | 76 | return app; 77 | } 78 | 79 | QQuickView *createView() 80 | { 81 | QQuickView *view = MDeclarativeCache::qQuickView(); 82 | MDesktopEntry entry("/usr/share/applications/" + appName() + ".desktop"); 83 | if (entry.isValid()) { 84 | view->setTitle(entry.name()); 85 | } 86 | 87 | QObject::connect(view->engine(), &QQmlEngine::quit, 88 | qApp, &QGuiApplication::quit); 89 | 90 | return view; 91 | } 92 | 93 | int main(int &argc, char **argv) 94 | { 95 | QScopedPointer app(AsteroidApp::application(argc, argv)); 96 | QScopedPointer view(AsteroidApp::createView()); 97 | view->setSource(QUrl("qrc:/main.qml")); 98 | view->resize(app->primaryScreen()->size()); 99 | view->show(); 100 | return app->exec(); 101 | } 102 | }; 103 | -------------------------------------------------------------------------------- /src/app/asteroidapp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 - Florent Revest 3 | * Copyright (C) 2013 - 2014 Jolla Ltd. 4 | * Contact: Thomas Perl 5 | * All rights reserved. 6 | * 7 | * This file is part of qml-asteroid 8 | * 9 | * You may use this file under the terms of the GNU Lesser General 10 | * Public License version 2.1 as published by the Free Software Foundation 11 | * and appearing in the file license.lgpl included in the packaging 12 | * of this file. 13 | * 14 | * This library is free software; you can redistribute it and/or 15 | * modify it under the terms of the GNU Lesser General Public 16 | * License version 2.1 as published by the Free Software Foundation 17 | * and appearing in the file license.lgpl included in the packaging 18 | * of this file. 19 | * 20 | * This library is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * Lesser General Public License for more details. 24 | * 25 | */ 26 | 27 | #ifndef ASTEROIDAPP_H 28 | #define ASTEROIDAPP_H 29 | 30 | #include 31 | 32 | class QGuiApplication; 33 | class QQuickView; 34 | 35 | #if defined(ASTEROIDAPP_LIBRARY) 36 | # define ASTEROIDAPP_EXPORT Q_DECL_EXPORT 37 | #else 38 | # define ASTEROIDAPP_EXPORT Q_DECL_IMPORT 39 | #endif 40 | 41 | namespace AsteroidApp { 42 | // Simple interface: Get boosted application and view 43 | ASTEROIDAPP_EXPORT QGuiApplication *application(int &argc, char **argv); 44 | ASTEROIDAPP_EXPORT QQuickView *createView(); 45 | 46 | // Very simple interface: Uses "qrc:/main.qml" as QML entry point 47 | ASTEROIDAPP_EXPORT int main(int &argc, char **argv); 48 | }; 49 | 50 | Q_DECL_EXPORT int main(int argc, char *argv[]); 51 | 52 | #endif /* ASTEROIDAPP_H */ 53 | -------------------------------------------------------------------------------- /src/app/asteroidapp.prf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 Florent Revest 2 | # Copyright (c) 2013 - 2014 Jolla Ltd. 3 | # Contact: Thomas Perl 4 | # All rights reserved. 5 | # 6 | # This file is part of qml-asteroid 7 | # 8 | # You may use this file under the terms of BSD license as follows: 9 | # 10 | # Redistribution and use in source and binary forms, with or without 11 | # modification, are permitted provided that the following conditions are met: 12 | # * Redistributions of source code must retain the above copyright 13 | # notice, this list of conditions and the following disclaimer. 14 | # * Redistributions in binary form must reproduce the above copyright 15 | # notice, this list of conditions and the following disclaimer in the 16 | # documentation and/or other materials provided with the distribution. 17 | # * Neither the name of the Jolla Ltd nor the 18 | # names of its contributors may be used to endorse or promote products 19 | # derived from this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 25 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | QT += quick qml 34 | 35 | target.path = /usr/bin 36 | 37 | desktop.commands = bash $$_PRO_FILE_PWD_/i18n/generate-desktop.sh $$_PRO_FILE_PWD_ $${TARGET}.desktop 38 | desktop.files = $$OUT_PWD/$${TARGET}.desktop 39 | desktop.path = /usr/share/applications 40 | desktop.CONFIG = no_check_exist 41 | 42 | INSTALLS += target desktop 43 | 44 | CONFIG += link_pkgconfig qtquickcompiler 45 | PKGCONFIG += asteroidapp 46 | INCLUDEPATH += /usr/include/asteroidapp 47 | -------------------------------------------------------------------------------- /src/controls/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRC 2 | src/controls_plugin.cpp 3 | src/application_p.cpp 4 | src/flatmesh.cpp 5 | src/flatmeshnode.cpp 6 | src/icon.cpp) 7 | set(HEADERS 8 | src/controls_plugin.h 9 | src/application_p.h 10 | src/flatmesh.h 11 | src/flatmeshnode.h 12 | src/icon.h) 13 | 14 | add_library(asteroidcontrolsplugin ${SRC} ${HEADERS} resources.qrc) 15 | 16 | set(controls 17 | Application 18 | BorderGestureArea 19 | CircularSpinner 20 | Dims 21 | HandWritingKeyboard 22 | HighlightBar 23 | IconButton 24 | Indicator 25 | IntSelector 26 | Label 27 | LabeledActionButton 28 | LabeledSwitch 29 | LayerStack 30 | ListItem 31 | Marquee 32 | PageDot 33 | PageHeader 34 | SegmentedArc 35 | Spinner 36 | SpinnerDelegate 37 | StatusPage 38 | Switch 39 | TextArea 40 | TextBase 41 | TextField 42 | ) 43 | set(controls-docs "$,PREPEND,qml->,APPEND,.html>") 44 | set(doc-dir "${CMAKE_BINARY_DIR}/doc/html") 45 | set(full-controls-docs "$") 46 | 47 | add_custom_target( 48 | doc 49 | DEPENDS "${full-controls-docs}" 50 | ) 51 | 52 | add_custom_command( 53 | OUTPUT "${full-controls-docs}" 54 | COMMAND "qdoc" "-indexdir" "/usr/share/doc/qt5" "-outputdir" "${doc-dir}" "${CMAKE_CURRENT_SOURCE_DIR}/doc/asteroid_controls.qdocconf" 55 | COMMENT "Generating HTML format Reference documentation..." VERBATIM 56 | ) 57 | 58 | target_link_libraries(asteroidcontrolsplugin 59 | Qt5::Qml 60 | Qt5::Quick 61 | Qt5::Svg) 62 | 63 | install(TARGETS asteroidcontrolsplugin 64 | DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/controls) 65 | install(FILES qmldir 66 | DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/controls) 67 | -------------------------------------------------------------------------------- /src/controls/doc/asteroid_controls.qdocconf: -------------------------------------------------------------------------------- 1 | project = AsteroidControls 2 | description = Asteroid Controls Documentation 3 | 4 | outputformats = HTML 5 | 6 | depends = qtqml qtquick qtwidgets qtdoc qtquicklayouts 7 | 8 | sources.fileextensions = "*.cpp *.qdoc *.mm *.qml" 9 | headers.fileextensions = "*.h *.ch *.h++ *.hh *.hpp *.hxx" 10 | 11 | sourcedirs = \ 12 | ../src \ 13 | ../qml 14 | 15 | headerdirs = ../src 16 | imagedirs = ./images 17 | 18 | qhp.projects = AsteroidControls 19 | 20 | qhp.AsteroidControls.file = asteroidcontrols.qhp 21 | qhp.AsteroidControls.namespace = org.asteroid.controls.100 22 | qhp.AsteroidControls.indexTitle = Asteroid Controls 23 | -------------------------------------------------------------------------------- /src/controls/doc/images/PageDotExample.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsteroidOS/qml-asteroid/1cd5ada695ac64735091a458fb3cd55911426e92/src/controls/doc/images/PageDotExample.jpg -------------------------------------------------------------------------------- /src/controls/doc/images/SpinnerExample.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsteroidOS/qml-asteroid/1cd5ada695ac64735091a458fb3cd55911426e92/src/controls/doc/images/SpinnerExample.jpg -------------------------------------------------------------------------------- /src/controls/doc/images/labelExample.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsteroidOS/qml-asteroid/1cd5ada695ac64735091a458fb3cd55911426e92/src/controls/doc/images/labelExample.jpg -------------------------------------------------------------------------------- /src/controls/qml/Application.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Florent Revest 3 | * 2015 Tim Süberkrüb 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | import QtQuick 2.9 20 | import org.asteroid.controls 1.0 21 | import org.asteroid.utils 1.0 22 | 23 | /*! 24 | \qmltype Application 25 | \inqmlmodule AsteroidControls 26 | \brief Shows a flat mesh background with indicators. 27 | 28 | The Application type is intended to be used as the top level QML object 29 | for graphical applications on AsteroidOS. By default only the top and 30 | left indicators are visible and the bottom and right indicators are not. 31 | 32 | Here's a short example: 33 | 34 | \qml 35 | import QtQuick 2.9 36 | import org.asteroid.controls 1.0 37 | 38 | Application { 39 | // show a purple-ish flat mesh background 40 | id: myapp 41 | centerColor: "#00010B" 42 | outerColor: "#E044A6" 43 | // make all indicators visible 44 | rightIndicVisible: true 45 | bottomIndicVisible: true 46 | 47 | Rectangle { 48 | id: square 49 | anchors.centerIn: parent 50 | color: "yellow" 51 | width: parent.width * 0.4 52 | height: parent.height * 0.2 53 | } 54 | } 55 | \endqml 56 | */ 57 | 58 | Application_p { 59 | anchors.fill: parent 60 | 61 | /*! 62 | Outer color for the flat mesh. 63 | */ 64 | property alias outerColor: fm.outerColor 65 | /*! 66 | Inner color for the flat mesh. 67 | */ 68 | property alias centerColor: fm.centerColor 69 | 70 | function animIndicators() { 71 | rightIndicator.animate(); 72 | leftIndicator.animate(); 73 | topIndicator.animate(); 74 | bottomIndicator.animate(); 75 | } 76 | 77 | FlatMesh { 78 | id: fm 79 | anchors.fill: parent 80 | } 81 | 82 | /*! 83 | Is the right indicator visible? 84 | */ 85 | property alias rightIndicVisible: rightIndicator.visible 86 | /*! 87 | Is the left indicator visible? 88 | */ 89 | property alias leftIndicVisible: leftIndicator.visible 90 | /*! 91 | Is the top indicator visible? 92 | */ 93 | property alias topIndicVisible: topIndicator.visible 94 | /*! 95 | Is the bottom indicator visible? 96 | */ 97 | property alias bottomIndicVisible: bottomIndicator.visible 98 | 99 | Indicator { 100 | id: rightIndicator 101 | edge: Qt.RightEdge 102 | visible: false 103 | z: 10 104 | anchors.verticalCenterOffset: DeviceSpecs.flatTireHeight/2 105 | } 106 | 107 | Indicator { 108 | id: leftIndicator 109 | edge: Qt.LeftEdge 110 | visible: true 111 | z: 10 112 | anchors.verticalCenterOffset: DeviceSpecs.flatTireHeight/2 113 | } 114 | 115 | Indicator { 116 | id: topIndicator 117 | edge: Qt.TopEdge 118 | visible: true 119 | z: 10 120 | } 121 | 122 | Indicator { 123 | id: bottomIndicator 124 | edge: Qt.BottomEdge 125 | visible: false 126 | z: 10 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/controls/qml/BorderGestureArea.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Florent Revest 3 | * 2014 Aleksi Suomalainen 4 | * 2013 John Brooks 5 | * All rights reserved. 6 | * 7 | * You may use this file under the terms of BSD license as follows: 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions are met: 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * * Neither the name of the author nor the 17 | * names of its contributors may be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 24 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | import QtQuick 2.9 33 | import QtQuick.Window 2.0 34 | import org.asteroid.utils 1.0 35 | 36 | /*! 37 | \qmltype BorderGestureArea 38 | \inqmlmodule AsteroidControls 39 | 40 | \brief Provides simple gesture support for swiping up, down, left, right. 41 | 42 | A simple example, based on the example for \l Application is shown below. If 43 | the user swipes right, the rectangle turns red. If the user swipes left, 44 | the rectangle turns blue. If the user swipes down, the rectangle turns 45 | yellow. No action is assigned to swipes up. 46 | 47 | \qml 48 | import QtQuick 2.9 49 | import org.asteroid.controls 1.0 50 | 51 | Application { 52 | id: myapp 53 | centerColor: "#00010B" 54 | outerColor: "#E044A6" 55 | rightIndicVisible: true 56 | bottomIndicVisible: true 57 | 58 | BorderGestureArea { 59 | id: gestureArea 60 | anchors.fill: parent 61 | acceptsRight: true 62 | acceptsLeft: true 63 | acceptsDown: true 64 | onGestureFinished: { 65 | if (gesture == "right") { 66 | square.color = "red" 67 | } 68 | else if (gesture == "left") { 69 | square.color = "blue" 70 | } 71 | else { 72 | square.color = "yellow" 73 | } 74 | } 75 | } 76 | 77 | Rectangle { 78 | id: square 79 | anchors.centerIn: parent 80 | color: "yellow" 81 | width: parent.width * 0.4 82 | height: parent.height * 0.2 83 | } 84 | } 85 | \endqml 86 | 87 | Also note that it is possible to use a \l BorderGestureArea inside 88 | other containers. For example, one could add the following inside 89 | the \l Rectangle in the example above. Within the rectangle, swipes up 90 | turn the \l Rectangle green and swipes down turn it orange. 91 | 92 | \qml 93 | BorderGestureArea { 94 | id: innerGestureArea 95 | anchors.fill: parent 96 | acceptsUp: true 97 | acceptsDown: true 98 | onGestureFinished: { 99 | if (gesture == "up") { 100 | square.color = "green" 101 | } 102 | else { 103 | square.color = "orange" 104 | } 105 | } 106 | } 107 | \endqml 108 | 109 | */ 110 | MouseArea { 111 | id: root 112 | 113 | property int boundary: width*DeviceSpecs.borderGestureWidth 114 | property bool delayReset 115 | 116 | signal gestureStarted(string gesture) 117 | signal gestureFinished(string gesture) 118 | 119 | /*! 120 | True if the current gesture active. 121 | */ 122 | property bool active: gesture != "" 123 | /*! 124 | Describes the current gesture. 125 | 126 | The string is "down", "left", "up" or "right" if the 127 | user has gestured. Otherwise the string is empty. 128 | */ 129 | property string gesture 130 | property int value 131 | property int max 132 | property real progress: Math.abs(value) / max 133 | /*! 134 | True if gesture is left or right. 135 | */ 136 | property bool horizontal: gesture === "left" || gesture === "right" 137 | property bool inverted: gesture === "left" || gesture === "up" 138 | 139 | /*! 140 | Tells the BorderGestureArea to accept right gestures. 141 | */ 142 | property bool acceptsRight: false 143 | /*! 144 | Tells the BorderGestureArea to accept left gestures. 145 | */ 146 | property bool acceptsLeft: false 147 | /*! 148 | Tells the BorderGestureArea to accept down gestures. 149 | */ 150 | property bool acceptsDown: false 151 | /*! 152 | Tells the BorderGestureArea to accept up gestures. 153 | */ 154 | property bool acceptsUp: false 155 | 156 | // Internal 157 | property int _mouseStart 158 | property variant _gestures: ["down", "left", "up", "right"] 159 | 160 | onPressed: { 161 | if (mouse.x < boundary && acceptsRight) { 162 | gesture = "right" 163 | max = width - mouse.x 164 | } else if (width - mouse.x < boundary && acceptsLeft) { 165 | gesture = "left" 166 | max = mouse.x 167 | } else if (mouse.y < boundary && acceptsDown) { 168 | gesture = "down" 169 | max = height - mouse.y 170 | } else if (height - mouse.y < boundary && acceptsUp) { 171 | gesture = "up" 172 | max = mouse.y 173 | } else { 174 | mouse.accepted = false 175 | return 176 | } 177 | 178 | value = 0 179 | if (horizontal) 180 | _mouseStart = mouse.x 181 | else 182 | _mouseStart = mouse.y 183 | 184 | gestureStarted(gesture) 185 | } 186 | 187 | onPositionChanged: { 188 | var p = horizontal ? mouse.x : mouse.y 189 | value = Math.max(Math.min(p - _mouseStart, max), -max) 190 | } 191 | 192 | function reset() { 193 | gesture = "" 194 | value = max = 0 195 | _mouseStart = 0 196 | } 197 | 198 | onDelayResetChanged: { 199 | if (!delayReset) 200 | reset() 201 | } 202 | 203 | onReleased: { 204 | gestureFinished(gesture) 205 | if (!delayReset) 206 | reset() 207 | } 208 | } 209 | 210 | -------------------------------------------------------------------------------- /src/controls/qml/CircularSpinner.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import QtQuick 2.9 19 | import org.asteroid.controls 1.0 20 | 21 | /*! 22 | \qmltype CircularSpinner 23 | \inqmlmodule AsteroidControls 24 | 25 | \brief A simplified vertical circular spinner, handy for selecting values. 26 | 27 | Creating a vertical spinner to allow the user to select a value from a 28 | list is simple with \l CircularSpinner. A short example is shown below. 29 | By default, it uses the current index as the data value and pads the number 30 | to two digits. This is particularly convenient for setting times and dates 31 | 32 | \qml 33 | import QtQuick 2.9 34 | import org.asteroid.controls 1.0 35 | 36 | CircularSpinner { 37 | id: rating 38 | anchors.centerIn: parent 39 | width: parent.width * 0.5 40 | height: parent.height 41 | model: 10 42 | } 43 | \endqml 44 | 45 | A slightly more complex version uses a \l SpinnerDelegate to allow 46 | a user to select an animal. 47 | 48 | \qml 49 | import QtQuick 2.9 50 | import org.asteroid.controls 1.0 51 | 52 | CircularSpinner { 53 | id: animals 54 | anchors.centerIn: parent 55 | width: parent.width * 0.5 56 | height: parent.height 57 | model: 6 58 | delegate: SpinnerDelegate{ 59 | text: ["aardvark", "bear", "camel", "dog", "elephant", "fox"][index] 60 | } 61 | } 62 | \endqml 63 | */ 64 | PathView { 65 | /*! 66 | Show a visible separator to the right of this spinner. 67 | */ 68 | property alias showSeparator: separator.visible 69 | 70 | id: pv 71 | preferredHighlightBegin: 0.5 72 | preferredHighlightEnd: 0.5 73 | highlightRangeMode: PathView.StrictlyEnforceRange 74 | highlightMoveDuration: 0 75 | clip: true 76 | 77 | delegate: SpinnerDelegate { } 78 | 79 | path: Path { 80 | startX: pv.width/2; startY: pv.height/2-pv.model*Dims.h(6) 81 | PathLine { x: pv.width/2; y: pv.height/2+pv.model*Dims.h(6) } 82 | } 83 | 84 | Rectangle { 85 | id: separator 86 | width: 1 87 | height: parent.height*0.8 88 | color: "#88FFFFFF" 89 | anchors.verticalCenter: parent.verticalCenter 90 | anchors.right: parent.right 91 | visible: false 92 | } 93 | 94 | layer.enabled: true 95 | layer.effect: ShaderEffect { 96 | fragmentShader: " 97 | precision mediump float; 98 | varying highp vec2 qt_TexCoord0; 99 | uniform sampler2D source; 100 | void main(void) 101 | { 102 | vec4 sourceColor = texture2D(source, qt_TexCoord0); 103 | float alpha = 1.0; 104 | if(qt_TexCoord0.y < 0.2) 105 | alpha = qt_TexCoord0.y*5.0; 106 | if(qt_TexCoord0.y > 0.8) 107 | alpha = (1.0-qt_TexCoord0.y)*5.0; 108 | gl_FragColor = sourceColor * alpha; 109 | }" 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/controls/qml/Dims.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Part of this code is based on QML-Material (https://github.com/papyros/qml-material/) 3 | * Asteroid Modificatons 4 | * Copyright (C) 2017 Florent Revest 5 | * Copyright (C) 2015 Tim Süberkrüb (https://github.com/tim-sueberkrueb) 6 | * QML Material - An application framework implementing Material Design. 7 | * Copyright (C) 2014-2015 Michael Spencer 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 2.1 of the 12 | * License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with this program. If not, see . 21 | */ 22 | import QtQuick 2.9 23 | import QtQuick.Window 2.2 24 | import org.asteroid.utils 1.0 25 | 26 | pragma Singleton 27 | 28 | /*! 29 | \qmltype Dims 30 | \inqmlmodule AsteroidControls 31 | 32 | \brief Provides access to dimensions relative to a ratio of the screen width/height. 33 | 34 | This singleton provides methods for building a user interface that automatically scales based on 35 | screen proportions. Use the Dims::w function wherever you need to specify a size relative to 36 | the screen width, and Dims::h when you need a dimension relative to the height. Dims::l 37 | provides a ratio of the smallest dimension for smartwatches that could have a screen larger than 38 | high. 39 | 40 | Here is a short example: 41 | 42 | \qml 43 | import QtQuick 2.0 44 | import org.asteroid.controls 1.0 45 | 46 | Rectangle { 47 | width: Dims.w(80) // 80 % of screen width 48 | height: Dims.h(50) // 50 % of screen height 49 | 50 | Label { 51 | text:"A" 52 | font.pixelSize: Dims.l(20) // 20 % of screen's smallest dimension 53 | } 54 | } 55 | \endqml 56 | */ 57 | QtObject { 58 | id: units 59 | 60 | /*! 61 | \qmlmethod real w(real number) 62 | \brief Returns a dimension that is \a number percent of the screen width. 63 | */ 64 | function w(number) { 65 | return (number/100)*Screen.desktopAvailableWidth 66 | } 67 | 68 | /*! 69 | \qmlmethod real h(real number) 70 | \brief Returns a dimension that is \a number percent of the screen height. 71 | */ 72 | function h(number) { 73 | return (number/100)*(Screen.desktopAvailableHeight+DeviceSpecs.flatTireHeight) 74 | } 75 | 76 | /*! 77 | \qmlmethod real l(real number) 78 | \brief Returns a dimension that is \a number percent of the screen width or height; whichever is smaller. 79 | */ 80 | function l(number) { 81 | if(Screen.desktopAvailableWidth > (Screen.desktopAvailableHeight+DeviceSpecs.flatTireHeight)) 82 | return h(number) 83 | else 84 | return w(number) 85 | } 86 | 87 | /*! 88 | \brief The default icon button margin used. 89 | */ 90 | property real iconButtonMargin: l(3) 91 | /*! 92 | \brief The default font size used. 93 | */ 94 | property real defaultFontSize: l(7) 95 | } 96 | -------------------------------------------------------------------------------- /src/controls/qml/HandWritingKeyboard.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import QtQuick 2.9 19 | import QtQuick.VirtualKeyboard 2.1 20 | 21 | /*! 22 | \qmltype HandWritingKeyboard 23 | \inqmlmodule AsteroidControls 24 | 25 | \brief A hand writing keyboard for AsteroidOS. 26 | 27 | The HandWritingKeyboard is a virtual keyboard that allows 28 | a user to input text without a physical keyboard. 29 | The HandWritingKeyboard is the default virtual keyboard for 30 | AsteroidOS. 31 | 32 | In this example, a simple \l TextField is created in the center 33 | of the screen with preview text "sample text". 34 | 35 | \qml 36 | import QtQuick 2.9 37 | import org.asteroid.controls 1.0 38 | 39 | Item { 40 | HandWritingKeyboard { 41 | anchors.fill: parent 42 | } 43 | 44 | TextField { 45 | width: parent.width * 0.8 46 | textWidth: parent.width *0.75 47 | anchors { 48 | horizontalCenter: parent.horizontalCenter 49 | verticalCenter: parent.verticalCenter 50 | } 51 | previewText: "sample text" 52 | } 53 | } 54 | \endqml 55 | 56 | */ 57 | HandwritingInputPanel { 58 | z: 99 59 | anchors.fill: parent 60 | inputPanel: inputPanel 61 | Component.onCompleted: { 62 | active = true 63 | available = true 64 | } 65 | 66 | Rectangle { 67 | z: -1 68 | anchors.fill: parent 69 | color: "black" 70 | opacity: 0.7 71 | transitions: Transition { 72 | PropertyAnimation { properties: "opacity"; easing.type: Easing.InOutQuad } 73 | } 74 | } 75 | 76 | InputPanel { 77 | id: inputPanel 78 | visible: false 79 | } 80 | 81 | IconButton { 82 | anchors.horizontalCenter: parent.horizontalCenter 83 | anchors.bottom: parent.bottom 84 | anchors.bottomMargin: parent.height/28 85 | 86 | iconName: "ios-checkmark-circle-outline" 87 | 88 | onClicked: Qt.inputMethod.hide() 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/controls/qml/HighlightBar.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 - Timo Könnecke 3 | * Copyright (C) 2022 - Ed Beroset 4 | * Copyright (C) 2020 - Darrel Griët 5 | * Copyright (C) 2015 - Florent Revest 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import QtQuick 2.9 22 | import org.asteroid.controls 1.0 23 | 24 | /*! 25 | \qmltype HighlightBar 26 | \inqmlmodule AsteroidControls 27 | 28 | \brief A combined Rectangle and MouseArea. 29 | 30 | The \l HighlightBar can be used as part of a delegate for a \l ListView 31 | or other similar collection or by itself as a convenience. It 32 | combines a \l Rectangle and \l MouseArea and by default is 33 | transparent. When it is clicked it turns slightly translucent 34 | and also emits a \l MouseArea::clicked signal. 35 | 36 | Note that because HighlightBar fills 37 | the parent, creating a smaller HighlightBar requires defining a 38 | parent with a set width and height. 39 | 40 | The simplest example is this: 41 | \qml 42 | import QtQuick 2.9 43 | import org.asteroid.controls 1.0 44 | 45 | HighlightBar { } 46 | \endqml 47 | 48 | That example fills the screen and shows the background color 49 | (if any) and briefly turns on opacity when the screen is clicked. 50 | 51 | A slightly more complex example is shown below. It starts with 52 | a transparent background and then cycles between a centered green 53 | or blue \l Rectangle with each mouse click. 54 | 55 | \qml 56 | import QtQuick 2.9 57 | import org.asteroid.controls 1.0 58 | 59 | Item { 60 | Item { 61 | width: parent.width * 0.5 62 | height: parent.height * 0.5 63 | anchors.centerIn: parent 64 | HighlightBar { 65 | property int colorIndex: 0 66 | onClicked: { 67 | colorIndex = 1 - colorIndex 68 | color = ["blue", "green"][colorIndex] 69 | } 70 | } 71 | } 72 | } 73 | \endqml 74 | */ 75 | Rectangle { 76 | /*! forward the clicked() signal to parent */ 77 | signal clicked() 78 | /*! alias to receive boolean forceOn to act like a controlled radio button */ 79 | property bool forceOn: false 80 | 81 | anchors.fill: parent 82 | /*! the default color may be overridden */ 83 | color: rowClick.containsPress || forceOn ? "#33ffffff" : "#00ffffff" 84 | 85 | Behavior on color { 86 | ColorAnimation { 87 | duration: 150; 88 | easing.type: Easing.OutQuad 89 | } 90 | } 91 | 92 | MouseArea { 93 | id: rowClick 94 | 95 | anchors.fill: parent 96 | hoverEnabled: true 97 | onClicked: parent.clicked() 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/controls/qml/IconButton.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 - Florent Revest 3 | * 2015 - Tim Süberkrüb 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | import QtQuick 2.9 20 | import org.asteroid.controls 1.0 21 | 22 | /*! 23 | \qmltype IconButton 24 | \inqmlmodule org.asteroid.controls 1.0 25 | 26 | \brief Provides a virtual button with settable icon. 27 | 28 | This control provides a virtual button which can then be used to 29 | do things via the \l MouseArea::clicked signal 30 | 31 | Here is an example which displays a blue square filling the screen and a button at 32 | the bottom of the screen. When the button is pressed, the square turns green. 33 | 34 | \qml 35 | import QtQuick 2.9 36 | import org.asteroid.controls 1.0 37 | 38 | Rectangle { 39 | id: square 40 | color: "blue" 41 | IconButton { 42 | iconName: "ios-checkmark-circle-outline" 43 | anchors { 44 | bottom: parent.bottom 45 | horizontalCenter: parent.horizontalCenter 46 | bottomMargin: Dims.iconButtonMargin 47 | } 48 | 49 | onClicked: { 50 | square.color = "green" 51 | } 52 | } 53 | } 54 | \endqml 55 | */ 56 | MouseArea { 57 | id: iconButton 58 | 59 | /*! Color of the icon */ 60 | property color iconColor: "#FFFFFFFF" 61 | /*! Color of the icon once pressed*/ 62 | property color pressedIconColor: "#FFFFFFFF" 63 | /*! The name of the icon */ 64 | property alias iconName: icon.name 65 | 66 | width: Dims.l(20) 67 | height: width 68 | 69 | Icon { 70 | id: icon 71 | name: "ios-circle-outline" 72 | anchors.fill: parent 73 | color: pressed ? pressedIconColor : iconColor 74 | opacity: iconButton.containsPress ? 0.7 : 1.0 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/controls/qml/Indicator.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import QtQuick 2.9 19 | import org.asteroid.controls 1.0 20 | 21 | /*! 22 | \qmltype Indicator 23 | \inqmlmodule AsteroidControls 24 | 25 | \brief Edge indicator for AsteroidOS. 26 | 27 | The Indicator appears in one of four edges: top, right, 28 | bottom or left as a small diamond shape. On loading it is 29 | animated and, depending on the setting of \l keepExpanded, 30 | either expands and then recedes into the edge or stays 31 | expanded. 32 | 33 | In this simple example, one \l Indicator is at the top and 34 | stays expanded, while another at the right does not. 35 | 36 | \qml 37 | import QtQuick 2.9 38 | import org.asteroid.controls 1.0 39 | 40 | Item { 41 | Indicator { 42 | keepExpanded: true 43 | } 44 | Indicator { 45 | edge: Qt.RightEdge 46 | } 47 | } 48 | \endqml 49 | 50 | While the intent of the indicator is to show something 51 | to lead the user to additional content or screens of some kind, 52 | it is also technically possible to use an \l Indicator within 53 | other objects. Here, a centered orange \l Rectangle has 54 | \l Indicator objects embedded on two of its edges. This code 55 | fragment can be inserted into the above example just before the 56 | final closing brace for a complete example. 57 | 58 | \qml 59 | Rectangle { 60 | color: "orange" 61 | anchors.centerIn: parent 62 | width: parent.width * 0.5 63 | height: parent.height * 0.5 64 | Indicator { 65 | edge: Qt.BottomEdge 66 | } 67 | Indicator { 68 | edge: Qt.LeftEdge 69 | keepExpanded: true 70 | } 71 | } 72 | \endqml 73 | */ 74 | Item { 75 | /*! which edge the indicator attaches to */ 76 | property int edge: Qt.TopEdge 77 | /*! If true, keep the indicator expanded */ 78 | property bool keepExpanded: false 79 | 80 | function animate() { 81 | offsetHigh = 0.8*finWidth 82 | bodyWidthAnim.restart() 83 | fishOffsetAnim.restart() 84 | bodyOpacityAnim.restart() 85 | } 86 | 87 | function animateFar() { 88 | offsetHigh = 2*finWidth 89 | bodyWidthAnim.restart() 90 | fishOffsetAnim.restart() 91 | bodyOpacityAnim.restart() 92 | } 93 | 94 | id: fish 95 | width: body.width 96 | height: body.height 97 | anchors.verticalCenter: { 98 | if(edge === Qt.LeftEdge || edge === Qt.RightEdge) return parent.verticalCenter 99 | else if(edge === Qt.TopEdge) return parent.top 100 | else return parent.bottom 101 | } 102 | anchors.horizontalCenter: { 103 | if(edge === Qt.TopEdge || edge === Qt.BottomEdge) return parent.horizontalCenter 104 | else if(edge === Qt.RightEdge) return parent.right 105 | else return parent.left 106 | } 107 | rotation: { 108 | if(edge === Qt.RightEdge) return 45 109 | else if(edge === Qt.TopEdge) return -45 110 | else if(edge== Qt.LeftEdge) return -135 111 | else return 135 112 | } 113 | 114 | property real finWidth: Dims.l(1.5) 115 | property real bodyWidthLow: Dims.l(1.8) 116 | property real bodyWidthHigh: 2*finWidth 117 | property real bodyOpacityLow: 0.6 118 | property real bodyOpacityHigh: 0.8 119 | property real offsetLow: 0 120 | property real offsetHigh: 2*finWidth 121 | 122 | Component.onCompleted: animate() 123 | 124 | onKeepExpandedChanged: { 125 | if(keepExpanded) { 126 | bodyWidthLow = bodyWidthHigh 127 | bodyOpacityLow = bodyOpacityHigh 128 | offsetLow = offsetHigh 129 | } else { 130 | bodyWidthLow = Dims.l(1.8) 131 | bodyOpacityLow = 0.6 132 | offsetLow = 0 133 | } 134 | animate() 135 | } 136 | 137 | SequentialAnimation { 138 | id: fishOffsetAnim 139 | running: false 140 | NumberAnimation { 141 | target: fish 142 | property: { 143 | if(edge === Qt.TopEdge || edge === Qt.BottomEdge) return "anchors.verticalCenterOffset" 144 | else return "anchors.horizontalCenterOffset" 145 | } 146 | to: { 147 | if(edge === Qt.TopEdge || edge === Qt.LeftEdge) return offsetHigh 148 | else return -offsetHigh 149 | } 150 | duration: 300 151 | } 152 | NumberAnimation { 153 | target: fish 154 | property: { 155 | if(edge === Qt.TopEdge || edge === Qt.BottomEdge) return "anchors.verticalCenterOffset" 156 | else return "anchors.horizontalCenterOffset" 157 | } 158 | to: offsetLow 159 | duration: 400 160 | } 161 | } 162 | 163 | Rectangle { 164 | id: body 165 | width: bodyWidthLow 166 | height: width 167 | color: Qt.rgba(215, 215, 215) 168 | opacity: bodyOpacityLow 169 | 170 | SequentialAnimation { 171 | id: bodyWidthAnim 172 | running: false 173 | NumberAnimation { 174 | target: body 175 | property: "width" 176 | to: bodyWidthHigh 177 | duration: 300 178 | } 179 | NumberAnimation { 180 | target: body 181 | property: "width" 182 | to: bodyWidthLow 183 | duration: 400 184 | } 185 | } 186 | 187 | SequentialAnimation { 188 | id: bodyOpacityAnim 189 | running: false 190 | NumberAnimation { 191 | target: body 192 | property: "opacity" 193 | to: bodyOpacityHigh 194 | duration: 300 195 | } 196 | NumberAnimation { 197 | target: body 198 | property: "opacity" 199 | to: bodyOpacityLow 200 | duration: 400 201 | } 202 | } 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /src/controls/qml/IntSelector.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 - Timo Könnecke 3 | * Copyright (C) 2022 - Ed Beroset 4 | * Copyright (C) 2020 - Darrel Griët 5 | * Copyright (C) 2015 - Florent Revest 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import QtQuick 2.9 22 | import org.asteroid.controls 1.0 23 | 24 | /*! 25 | \qmltype IntSelector 26 | \inqmlmodule AsteroidControls 27 | 28 | \brief A control to select an integer value from a range. 29 | 30 | This control allows the user to select an integer value by 31 | clicking on an associated left icon or right icon. By default 32 | the range is from \l min to \l max with a given \l stepSize 33 | which is the increment added or subtracted for each icon press. 34 | 35 | Here is a short example that shows two \l IntSelector controls. 36 | The top one uses mostly defaults and sets the value to 50%, incrementing 37 | or decrementing 10% at each step. The lower one uses a range of -10 38 | to +10 mV and starts at a value of -3, incrementing or decrementing 39 | by 1 mV each step. 40 | 41 | \qml 42 | import QtQuick 2.0 43 | import org.asteroid.controls 1.0 44 | 45 | Item { 46 | IntSelector { 47 | id: first 48 | anchors.bottom: parent.verticalCenter 49 | height: parent.height * 0.2 50 | value: 50 51 | } 52 | IntSelector { 53 | anchors.top: first.bottom 54 | height: parent.height * 0.2 55 | min: -10 56 | max: +10 57 | stepSize: 1 58 | value: -3 59 | unitMarker: "mV" 60 | } 61 | } 62 | \endqml 63 | */ 64 | 65 | Item { 66 | /*! minimum allowed value. Default is 0 */ 67 | property int min: 0 68 | /*! maximum allowed value. Default is 100 */ 69 | property int max: 100 70 | /*! step size per button actuatio. Default is 10 */ 71 | property int stepSize: 10 72 | /*! unitMarker value appended to value display between button. Default is % */ 73 | property string unitMarker: "%" 74 | /*! initial value of the control. Default is 0 */ 75 | property int value: 0 76 | /*! left and right margin for the row content */ 77 | property int rowMargin: Dims.w(15) 78 | /*! size of the icon/s */ 79 | property int iconSize: Dims.l(20) 80 | /*! size of the label text */ 81 | property int labelFontSize: Dims.l(6) 82 | 83 | /*! width defaults to parent's width */ 84 | width: parent.width 85 | /*! height defaults to parent's height */ 86 | height: parent.height 87 | 88 | IconButton { 89 | id: buttonLeft 90 | 91 | iconName: "ios-remove-circle-outline" 92 | anchors { 93 | left: parent.left 94 | leftMargin: rowMargin 95 | verticalCenter: parent.verticalCenter 96 | } 97 | height: iconSize 98 | width: height 99 | onClicked: { 100 | var newVal = value - stepSize 101 | if(newVal < min) newVal = min 102 | value = newVal 103 | } 104 | } 105 | 106 | Label { 107 | text: value + unitMarker 108 | anchors { 109 | left: buttonLeft.right 110 | right: buttonRight.left 111 | } 112 | font.pixelSize: labelFontSize 113 | horizontalAlignment: Text.AlignHCenter 114 | verticalAlignment: Text.AlignVCenter 115 | wrapMode: Text.Wrap 116 | height: parent.height 117 | } 118 | 119 | IconButton { 120 | id: buttonRight 121 | 122 | iconName: "ios-add-circle-outline" 123 | anchors { 124 | right: parent.right 125 | rightMargin: rowMargin 126 | verticalCenter: parent.verticalCenter 127 | } 128 | height: iconSize 129 | width: height 130 | onClicked: { 131 | var newVal = value + stepSize 132 | if(newVal > max) newVal = max 133 | value = newVal 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/controls/qml/Label.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import QtQuick 2.9 19 | import org.asteroid.controls 1.0 20 | 21 | /*! 22 | \qmltype Label 23 | \inqmlmodule org.asteroid.controls 1.0 24 | 25 | \brief Provides a way to get a text label sized for AsteroidOS. 26 | 27 | This is a simple wrapper for \l Text that by default has white text with 28 | \l Text::font.pixelSize of \l Dims::defaultFontSize. 29 | 30 | Here is a short example that shows some text in a blue rectangle on a yellow background: 31 | 32 | \qml 33 | import QtQuick 2.9 34 | import org.asteroid.controls 1.0 35 | 36 | Rectangle { 37 | anchors.fill: parent 38 | color: "yellow" 39 | Rectangle { 40 | anchors.centerIn: parent 41 | width: Dims.w(50) 42 | height: Dims.h(10) 43 | color: "blue" 44 | 45 | Label { 46 | text:"This is a label." 47 | } 48 | } 49 | } 50 | \endqml 51 | 52 | The result looks like this on a round watch \image labelExample.jpg "label example screen" 53 | 54 | 55 | */ 56 | Text { 57 | color: "white" 58 | font.pixelSize: Dims.defaultFontSize 59 | elide: Text.ElideRight 60 | clip: true 61 | } 62 | 63 | -------------------------------------------------------------------------------- /src/controls/qml/LabeledActionButton.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 - Timo Könnecke 3 | * Copyright (C) 2022 - Ed Beroset 4 | * Copyright (C) 2020 - Darrel Griët 5 | * Copyright (C) 2015 - Florent Revest 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import QtQuick 2.9 22 | import org.asteroid.controls 1.0 23 | 24 | /*! 25 | \qmltype LabeledActionButton 26 | \inqmlmodule AsteroidControls 27 | 28 | \brief Clickable label plus icon. 29 | 30 | This control shows a label and an icon, horizontally aligned, 31 | and acts as as a button, passing the \l clicked signal to the 32 | caller. 33 | 34 | Here is a short example: 35 | 36 | \qml 37 | import QtQuick 2.0 38 | import org.asteroid.controls 1.0 39 | 40 | Item { 41 | LabeledActionButton { 42 | icon: "ios-power-outline" 43 | text: "Shut down" 44 | onClicked: visible = false 45 | } 46 | } 47 | \endqml 48 | */ 49 | Item { 50 | /*! alias to receive string icon.name */ 51 | property alias icon: icon.name 52 | /*! alias to receive string label.text */ 53 | property alias text: label.text 54 | /*! left and right margin for the row content */ 55 | property int rowMargin: Dims.w(15) 56 | /*! size of the icon/s */ 57 | property int iconSize: Dims.l(20) 58 | /*! size of the label text */ 59 | property int labelFontSize: Dims.l(6) 60 | /*! forward the clicked() signal to parent */ 61 | signal clicked() 62 | 63 | width: parent.width 64 | height: parent.height 65 | 66 | Behavior on opacity { 67 | NumberAnimation { 68 | duration: 200; 69 | easing.type: Easing.OutQuad 70 | } 71 | } 72 | 73 | HighlightBar { 74 | onClicked: parent.clicked() 75 | } 76 | 77 | Label { 78 | id: label 79 | 80 | anchors { 81 | left: parent.left 82 | leftMargin: rowMargin 83 | right: icon.left 84 | rightMargin: Dims.h(4) 85 | } 86 | text: value 87 | font.pixelSize: labelFontSize 88 | verticalAlignment: Text.AlignVCenter 89 | wrapMode: Text.Wrap 90 | height: parent.height 91 | } 92 | 93 | Icon { 94 | id: icon 95 | 96 | anchors { 97 | right: parent.right 98 | rightMargin: rowMargin 99 | verticalCenter: parent.verticalCenter 100 | } 101 | height: iconSize 102 | width: height 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/controls/qml/LabeledSwitch.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 - Timo Könnecke 3 | * Copyright (C) 2022 - Ed Beroset 4 | * Copyright (C) 2020 - Darrel Griët 5 | * Copyright (C) 2015 - Florent Revest 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import QtQuick 2.9 22 | import org.asteroid.controls 1.0 23 | 24 | /*! 25 | \qmltype LabeledSwitch 26 | \inqmlmodule org.asteroid.controls 1.0 27 | 28 | \brief This combines \l Label and \l Switch in a convenient package. 29 | 30 | This example shows a centered blue square and a \l LabeledSwitch centered below it. 31 | The square turns green when the toggle is checked, and red when it is unchecked. 32 | 33 | \qml 34 | import QtQuick 2.9 35 | import org.asteroid.controls 1.0 36 | 37 | Item { 38 | anchors.fill: parent 39 | Rectangle { 40 | id: square 41 | anchors.centerIn: parent 42 | width: 100 43 | height: 100 44 | color: "blue" 45 | } 46 | LabeledSwitch { 47 | anchors.top: square.bottom 48 | anchors.horizontalCenter: square.horizontalCenter 49 | width: Dims.l(80) 50 | height: Dims.l(20) 51 | text: "Enable" 52 | checked: false 53 | onCheckedChanged: { 54 | if (checked) { 55 | square.color = "green" 56 | } else { 57 | square.color = "red" 58 | } 59 | } 60 | } 61 | } 62 | 63 | \endqml 64 | */ 65 | Item { 66 | /*! alias to receive string toggle.checked */ 67 | property alias checked: toggle.checked 68 | /*! alias to receive string label.text */ 69 | property alias text: label.text 70 | /*! left and right margin for the row content */ 71 | property int rowMargin: Dims.w(15) 72 | /*! size of the icon/s */ 73 | property int iconSize: Dims.l(20) 74 | /*! size of the label text */ 75 | property int labelFontSize: Dims.l(6) 76 | 77 | /*! default width is parent width */ 78 | width: parent.width 79 | /*! default height is parent height */ 80 | height: parent.height 81 | 82 | Behavior on opacity { 83 | NumberAnimation { 84 | duration: 200; 85 | easing.type: Easing.OutQuad 86 | } 87 | } 88 | 89 | Label { 90 | id: label 91 | 92 | anchors { 93 | left: parent.left 94 | leftMargin: rowMargin 95 | right: toggle.left 96 | rightMargin: Dims.h(4) 97 | } 98 | text: value 99 | font.pixelSize: labelFontSize 100 | verticalAlignment: Text.AlignVCenter 101 | wrapMode: Text.Wrap 102 | height: parent.height 103 | } 104 | 105 | Switch { 106 | id: toggle 107 | 108 | anchors { 109 | right: parent.right 110 | rightMargin: rowMargin 111 | verticalCenter: parent.verticalCenter 112 | } 113 | height: iconSize 114 | width: height 115 | } 116 | 117 | HighlightBar { 118 | onClicked: toggle.checked = !toggle.checked 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/controls/qml/LayerStack.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Florent Revest 3 | * 2015 Tim Süberkrüb 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | import QtQuick 2.9 20 | 21 | 22 | /*! 23 | \qmltype LayerStack 24 | \inqmlmodule AsteroidControls 25 | 26 | \brief A simple stack of QML components. 27 | 28 | This provides a way to manage a virtual stack of QML compoments 29 | and to navigate between them. 30 | 31 | Because \l LayerStack is a more advanced and complex control, the 32 | example program is longer than usual, but not too complex. There 33 | are three different \l Component elements defined, named "top", "one", 34 | and "two". The \l firstPage of the \l LayerStack is set to the "top" 35 | component, and the other components provide a means to navigate either 36 | deeper into the stack or back up, depending on which stack component 37 | it is. The \l Component labeled "one" is the only one that can go 38 | either deeper (to "two") or up (to "top"). 39 | 40 | \qml 41 | import QtQuick 2.0 42 | import org.asteroid.controls 1.0 43 | 44 | Item { 45 | Component { 46 | id: one 47 | Item { 48 | LabeledActionButton { 49 | text: "Still deeper" 50 | anchors.bottom: parent.verticalCenter 51 | height: parent.height * 0.2 52 | onClicked: stack.push(two) 53 | } 54 | LabeledActionButton { 55 | text: "Back up" 56 | anchors.top: parent.verticalCenter 57 | height: parent.height * 0.2 58 | onClicked: stack.pop(stack.currentLayer) 59 | } 60 | } 61 | } 62 | Component { 63 | id: two 64 | LabeledActionButton { 65 | text: "Deep enough" 66 | onClicked: stack.pop(stack.currentLayer) 67 | } 68 | } 69 | Component { 70 | id: top 71 | LabeledActionButton { 72 | text: "Go deeper" 73 | onClicked: stack.push(one) 74 | } 75 | } 76 | anchors.fill: parent 77 | LayerStack { 78 | id: stack 79 | firstPage: top 80 | win: null 81 | } 82 | } 83 | \endqml 84 | */ 85 | Item { 86 | id: layersStack 87 | anchors.fill: parent 88 | objectName: "LayerStack" 89 | 90 | /*! The top level page of the stack */ 91 | property var firstPage 92 | /*! The collection of pages of the stack */ 93 | property var layers: [] 94 | /*! The current layer of the stack */ 95 | property var currentLayer: layers.length > 0 ? layers[layers.length-1] : null 96 | property var firstPageItem 97 | /*! Can be set to null if you don't want indicators animations and systemgestures override. If your LayerStack isn't directly a child element of your window, you can also specify the window via this parameter. */ 98 | property QtObject win: parent 99 | 100 | Flickable { 101 | id: contentArea 102 | anchors.fill: parent 103 | interactive: false 104 | Row { id: content } 105 | } 106 | 107 | SequentialAnimation { 108 | id: pushAnim 109 | 110 | NumberAnimation { 111 | id: pushAnimX 112 | target: contentArea 113 | property: "contentX" 114 | duration: 200 115 | easing.type: Easing.OutQuint 116 | } 117 | 118 | ScriptAction { script: if(win !== null) win.animIndicators() } 119 | } 120 | 121 | onFirstPageChanged: { 122 | if(typeof firstPage != 'undefined') { 123 | if (firstPageItem) { 124 | firstPageItem.destroy() 125 | } 126 | while (layers.length > 0) { 127 | pop(currentLayer) 128 | } 129 | var params = {} 130 | params["width"] = Qt.binding(function() { return width }) 131 | params["height"] = Qt.binding(function() { return height }) 132 | params["x"] = 0 133 | params["y"] = 0 134 | if(typeof firstPage != 'undefined' && firstPage.status === Component.Ready) { 135 | firstPageItem=firstPage.createObject(content, params) 136 | firstPageItem.clip = true 137 | layersChanged() 138 | } 139 | } else { 140 | console.log("LayerStack: firstpage has been updated with a null value") 141 | } 142 | } 143 | 144 | function push(component, params) { 145 | if (component.status === Component.Ready) { 146 | if (typeof params === 'undefined') params = {} 147 | params["width"] = Qt.binding(function() { return width }) 148 | params["height"] = Qt.binding(function() { return height }) 149 | params["depth"] = (layers.length+1) 150 | params["x"] = params["depth"]*width 151 | params["y"] = 0 152 | params["clip"] = true 153 | 154 | var layer; 155 | params["pop"] = function() { layersStack.popAnim(); } 156 | layer = component.createObject(content, params); 157 | layers.push(layer); 158 | pushAnimX.to = layers.length*width 159 | pushAnim.start(); 160 | if(win !== null) 161 | win.setOverridesSystemGestures(layers.length > 0) 162 | layersChanged(); 163 | return layer 164 | } 165 | } 166 | 167 | function popAnim() { 168 | swipeAnimation.valueTo = width 169 | swipeAnimation.start(); 170 | } 171 | 172 | function pop(layer) { 173 | layer.destroy(); 174 | layers.pop(layer); 175 | contentArea.contentX = layers.length*width 176 | if(win !== null) 177 | win.setOverridesSystemGestures(layers.length > 0) 178 | layersChanged(); 179 | if(win !== null) 180 | win.animIndicators() 181 | } 182 | 183 | BorderGestureArea { 184 | id: gestureArea 185 | anchors.fill: parent 186 | enabled: layers.length > 0 187 | acceptsRight: true 188 | 189 | property real swipeThreshold: 0.15 190 | 191 | onGestureStarted: { 192 | swipeAnimation.stop() 193 | cancelAnimation.stop() 194 | if(gesture == "right") 195 | state = "swipe" 196 | } 197 | 198 | onGestureFinished: { 199 | if(gesture == "right") { 200 | if (gestureArea.progress >= swipeThreshold) { 201 | swipeAnimation.valueTo = width 202 | swipeAnimation.start() 203 | } else 204 | cancelAnimation.start() 205 | } else 206 | cancelAnimation.start() 207 | } 208 | 209 | states: [ 210 | State { 211 | name: "swipe" 212 | 213 | PropertyChanges { 214 | target: gestureArea 215 | delayReset: true 216 | } 217 | 218 | PropertyChanges { 219 | target: contentArea 220 | contentX: layers.length*width - gestureArea.value 221 | } 222 | } 223 | ] 224 | 225 | SequentialAnimation { 226 | id: cancelAnimation 227 | 228 | NumberAnimation { 229 | target: gestureArea 230 | property: "value" 231 | to: 0 232 | duration: 200 233 | easing.type: Easing.OutQuint 234 | } 235 | 236 | PropertyAction { 237 | target: gestureArea 238 | property: "state" 239 | value: "" 240 | } 241 | 242 | ScriptAction { script: if(win !== null) win.animIndicators() } 243 | } 244 | 245 | SequentialAnimation { 246 | id: swipeAnimation 247 | 248 | property alias valueTo: valueAnimation.to 249 | 250 | PropertyAction { 251 | target: gestureArea 252 | property: "state" 253 | value: "swipe" 254 | } 255 | 256 | NumberAnimation { 257 | id: valueAnimation 258 | target: gestureArea 259 | property: "value" 260 | duration: 200 261 | easing.type: Easing.OutQuint 262 | } 263 | 264 | PropertyAction { 265 | target: gestureArea 266 | property: "state" 267 | value: "" 268 | } 269 | 270 | ScriptAction { script: pop(currentLayer) } 271 | } 272 | } 273 | } 274 | -------------------------------------------------------------------------------- /src/controls/qml/ListItem.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 - Timo Könnecke 3 | * 2015 - Florent Revest 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | import QtQuick 2.9 20 | import org.asteroid.controls 1.0 21 | import org.asteroid.utils 1.0 22 | 23 | /*! 24 | \qmltype ListItem 25 | \inqmlmodule AsteroidControls 26 | 27 | \brief A delegate to display a icon and text combo. 28 | 29 | An example is shown below which display three icons 30 | with their associated text and allows the user to select 31 | one. Note that both highlighting and processing of the 32 | \l ListItem::clicked signal should typically be explicitly 33 | set. 34 | 35 | \qml 36 | import QtQuick 2.9 37 | import org.asteroid.controls 1.0 38 | 39 | Item { 40 | 41 | ListModel { 42 | id: powerModel 43 | ListElement { text: "off"; icon: "ios-power-outline" } 44 | ListElement { text: "reboot"; icon: "ios-sync" } 45 | ListElement { text: "fire"; icon: "ios-bonfire-outline" } 46 | } 47 | 48 | ListView { 49 | id: powerItems 50 | model: powerModel 51 | anchors { 52 | top: parent.top 53 | topMargin: parent.height * 0.20 54 | } 55 | height: parent.height 56 | width: parent.width 57 | delegate: ListItem { 58 | title: text 59 | iconName: icon 60 | highlight: powerItems.currentIndex == index ? 0.2 : 0 61 | onClicked: powerItems.currentIndex = index 62 | } 63 | } 64 | } 65 | \endqml 66 | */ 67 | Item { 68 | /*! alias to recieve string label.text */ 69 | property alias title: label.text 70 | /*! alias to recieve string icon.name */ 71 | property alias iconName: icon.name 72 | /*! alias to recieve boolean highlight.forceOn */ 73 | property alias highlight: highlight.forceOn 74 | /*! size of the icon/s */ 75 | property int iconSize: height - Dims.h(6) 76 | /*! size of the label text */ 77 | property int labelFontSize: Dims.l(9) 78 | /*! forward the clicked() signal to parent */ 79 | signal clicked() 80 | 81 | width: parent.width 82 | height: Dims.h(21) 83 | 84 | HighlightBar { 85 | id: highlight 86 | 87 | onClicked: parent.clicked() 88 | } 89 | 90 | Icon { 91 | id: icon 92 | 93 | width: iconSize 94 | height: width 95 | 96 | anchors { 97 | verticalCenter: parent.verticalCenter 98 | left: parent.left 99 | leftMargin: DeviceSpecs.hasRoundScreen ? Dims.w(18) : Dims.w(12) 100 | } 101 | } 102 | 103 | Label { 104 | id: label 105 | 106 | anchors { 107 | leftMargin: DeviceSpecs.hasRoundScreen ? Dims.w(6) : Dims.w(10) 108 | left: icon.right 109 | verticalCenter: parent.verticalCenter 110 | } 111 | font { 112 | pixelSize: labelFontSize 113 | styleName: "SemiCondensed Light" 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/controls/qml/Marquee.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import QtQuick 2.9 19 | import org.asteroid.controls 1.0 20 | 21 | /*! 22 | \qmltype Marquee 23 | \inqmlmodule AsteroidControls 24 | 25 | \brief Display text that may be longer than the available space. 26 | 27 | The \l Marquee control shows as much as possible of the string 28 | initially, then animates it moving to the left until it gets to 29 | the end of the string. It then resets to the beginning of the 30 | string and repeats infinitely. 31 | 32 | Here is a short example: 33 | 34 | \qml 35 | import QtQuick 2.0 36 | import org.asteroid.controls 1.0 37 | 38 | Item { 39 | Marquee { 40 | text: "The quick brown fox jumps over the lazy dog." 41 | height: parent.height * 0.3 42 | width: parent.width * 0.8 43 | anchors.centerIn: parent 44 | } 45 | } 46 | \endqml 47 | */ 48 | Item { 49 | id: container 50 | clip: true 51 | 52 | /*! the text to display */ 53 | property alias text: animatedText.text 54 | /*! the text \l Font */ 55 | property alias font: animatedText.font 56 | /*! the text color */ 57 | property alias color: animatedText.color 58 | 59 | function originX() { 60 | var ret = container.width-animatedText.width 61 | if(ret > 0) return ret/2 62 | else return 0 63 | } 64 | 65 | function destinationX() { 66 | var ret = container.width-animatedText.width 67 | if(ret < 0) return ret 68 | else return originX() 69 | } 70 | 71 | function restartAnimation() { 72 | animation.stop() 73 | animation1.from = originX() 74 | animation1.to = originX() 75 | animation2.to = destinationX() 76 | animation.start() 77 | } 78 | 79 | onWidthChanged: restartAnimation() 80 | 81 | Label { 82 | id: animatedText 83 | width: contentWidth 84 | onWidthChanged: restartAnimation() 85 | elide: Text.ElideNone 86 | } 87 | 88 | SequentialAnimation { 89 | id: animation 90 | loops: Animation.Infinite 91 | 92 | NumberAnimation { 93 | id: animation1 94 | target: animatedText 95 | property: "x" 96 | duration: 2000 97 | } 98 | 99 | NumberAnimation { 100 | id: animation2 101 | target: animatedText 102 | property: "x" 103 | duration: (animatedText.width)/Dims.w(0.08) 104 | easing.type: Easing.InOutQuad 105 | } 106 | 107 | NumberAnimation { 108 | target: animatedText 109 | property: "x" 110 | duration: 2000 111 | } 112 | } 113 | } 114 | 115 | -------------------------------------------------------------------------------- /src/controls/qml/PageDot.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 - Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import QtQuick 2.9 19 | 20 | 21 | /*! 22 | \qmltype PageDot 23 | \inqmlmodule AsteroidControls 24 | 25 | \brief Display indicator dots indicating a fixed collection. 26 | 27 | The \l PageDot control shows a series of dots with one dot 28 | highlighted. This is typically used to show a series of pages 29 | or other items and to indicate where within the collection 30 | one currently is. The example below uses the \l IntSelector 31 | control to increment and decrement an indicator, with the 32 | \l PageDot control at the bottom of the screen indicating 33 | where in the collection the setting currently is. 34 | 35 | Here is a short example: 36 | 37 | \qml 38 | import QtQuick 2.0 39 | import org.asteroid.controls 1.0 40 | 41 | Item { 42 | IntSelector { 43 | id: page 44 | min: 1 45 | max: 5 46 | value: 1 47 | stepSize: 1 48 | unitMarker: " of " + page.max 49 | 50 | } 51 | PageDot { 52 | height: parent.height * 0.03 53 | anchors { 54 | horizontalCenter: parent.horizontalCenter 55 | bottom: parent.bottom 56 | bottomMargin: parent.height * 0.04 57 | } 58 | dotNumber: page.max - page.min + 1 59 | currentIndex: page.value - page.min 60 | } 61 | } 62 | \endqml 63 | 64 | The effect on a round watch is shown below. 65 | \image PageDotExample.jpg "PageDot example screenshot" 66 | */ 67 | Item { 68 | width: height*5/4*(dotNumber+(additionalDot ? 1 : 0)) 69 | visible: additionalDot ? dotNumber > 0 : dotNumber > 1 70 | 71 | property int currentIndex: 0 72 | property int dotNumber: 0 73 | 74 | property bool additionalDot: false 75 | property string additionalDotText: "+" 76 | 77 | Row { 78 | anchors.fill: parent 79 | spacing: height/4 80 | Repeater { 81 | model: dotNumber 82 | Rectangle { 83 | width: parent.height 84 | height: parent.height 85 | radius: parent.height 86 | color: "white" 87 | opacity: index == currentIndex ? 1 : 0.5 88 | } 89 | } 90 | 91 | Label { 92 | text: additionalDotText 93 | width: additionalDot ? parent.height : 0 94 | height: parent.height 95 | verticalAlignment: Text.AlignVCenter 96 | opacity: currentIndex == dotNumber ? 1 : 0.5 97 | visible: additionalDot 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/controls/qml/PageHeader.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 - Timo Könnecke 3 | * Copyright (C) 2017 - Florent Revest 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | import QtQuick 2.9 20 | import org.asteroid.controls 1.0 21 | import org.asteroid.utils 1.0 22 | 23 | /*! 24 | \qmltype PageHeader 25 | \inqmlmodule org.asteroid.controls 1.0 26 | 27 | \brief Provides a title on a page. 28 | 29 | This is intended to be used as a title for a settings page. Note that there should only 30 | be a single instance on a page; otherwise the titles will all be placed in the same location 31 | and make it impossible to read either title. 32 | 33 | Here is a short example that puts a purple \l Rectangle on the screen 34 | and a \l PageHeader at the top of the screen. 35 | 36 | \qml 37 | import QtQuick 2.9 38 | import org.asteroid.controls 1.0 39 | 40 | Item { 41 | PageHeader { text: "Example Page" } 42 | Rectangle { 43 | anchors.centerIn: parent 44 | width: parent.width * 0.5 45 | height: parent.height * 0.5 46 | color: "blue" 47 | } 48 | } 49 | \endqml 50 | */ 51 | 52 | Item { 53 | /*! The text to display. */ 54 | property alias text: title.text 55 | 56 | height: Dims.h(20) 57 | anchors { 58 | top: parent.top 59 | left: parent.left 60 | right: parent.right 61 | } 62 | 63 | Rectangle { 64 | anchors.fill: parent 65 | gradient: Gradient { 66 | GradientStop { position: 0.2; color: "#dd000000" } 67 | GradientStop { position: 0.8; color: "#55000000" } 68 | GradientStop { position: 1.0; color: "#00000000" } 69 | } 70 | } 71 | 72 | Label { 73 | id: title 74 | 75 | height: Dims.h(20) 76 | anchors.centerIn: parent 77 | font { 78 | styleName: "SemiCondensed Light" 79 | pixelSize: Dims.l(7) 80 | } 81 | verticalAlignment: Text.AlignVCenter 82 | horizontalAlignment: Text.AlignHCenter 83 | leftPadding: DeviceSpecs.hasRoundScreen ? Dims.w(25) : 0 84 | rightPadding: DeviceSpecs.hasRoundScreen ? Dims.w(25) : 0 85 | wrapMode: Text.WordWrap 86 | maximumLineCount: 2 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/controls/qml/SegmentedArc.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - Timo Könnecke 3 | * 2022 - Darrel Griët 4 | * 2022 - Ed Beroset 5 | * 2016 - Sylvia van Os 6 | * 2015 - Florent Revest 7 | * 2012 - Vasiliy Sorokin 8 | * Aleksey Mikhailichenko 9 | * Arto Jalkanen 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | import QtQuick 2.15 26 | import QtQuick.Shapes 1.1 27 | 28 | /*! 29 | \qmltype SegmentedArc 30 | \inqmlmodule AsteroidControls 31 | 32 | \brief A segmented arc that uses color to represent a value. 33 | 34 | This control allows the user to create an arc that is segmented 35 | int \l segmentAmount pieces from a start angle of \l start degrees 36 | through a swing of \l endFromStart degrees from there. An 37 | \l inputValue (as a number from 0 to 100) is represented by some 38 | number of those segments set to color \l fgColor while the others 39 | are set to the color \l bgColor. 40 | 41 | This example shows a "speedometer" style gauge that goes from 42 | the lower left (-135 degrees) to the lower right (+135 degrees) 43 | which is a full range of 270 degrees. The initial value is 25% 44 | but can be changed via the \l IntSelector control. 45 | 46 | \qml 47 | import QtQuick 2.15 48 | import org.asteroid.controls 1.0 49 | 50 | Item { 51 | IntSelector { 52 | id: number 53 | value: 25 54 | stepSize: 5 55 | } 56 | SegmentedArc { 57 | anchors.fill: parent 58 | segmentAmount: 10 59 | inputValue: number.value 60 | start: -135 61 | endFromStart: 270 62 | fgColor: "orange" 63 | bgColor: "darkblue" 64 | } 65 | } 66 | \endqml 67 | */ 68 | Repeater { 69 | id: segmentedArc 70 | 71 | /*! initial value of the control. Default is 0 */ 72 | property real inputValue: 0 73 | /*! Number of segments to use */ 74 | property int segmentAmount: 12 75 | /*! Starting angle in degrees for segmented arc. Default is 0 which is top */ 76 | property int start: 0 77 | /*! Gap angle in degrees for segmented arc. Default is 6 */ 78 | property int gap: 6 79 | /*! Angle span in degrees of the complete segmented arc. Default is 360 */ 80 | property int endFromStart: 360 81 | /*! Draw clockwise. Default is true */ 82 | property bool clockwise: true 83 | /*! Arc stroke width. Default is 0.011 */ 84 | property real arcStrokeWidth: .011 85 | /*! Draw clockwise. Default is 0.3685 */ 86 | property real scalefactor: .374 - (arcStrokeWidth / 2) 87 | /*! Color of segments that are on. Default is #26C485 (green) */ 88 | property color fgColor: "#26C485" 89 | /*! Color of segments that are off. Default is black */ 90 | property color bgColor: "black" 91 | 92 | model: segmentAmount 93 | 94 | Shape { 95 | id: segment 96 | 97 | ShapePath { 98 | fillColor: "transparent" 99 | strokeColor: index / segmentedArc.segmentAmount < segmentedArc.inputValue / 100 ? fgColor : bgColor 100 | strokeWidth: parent.height * segmentedArc.arcStrokeWidth 101 | capStyle: ShapePath.RoundCap 102 | joinStyle: ShapePath.MiterJoin 103 | startX: parent.width / 2 104 | startY: parent.height * ( .5 - segmentedArc.scalefactor) 105 | 106 | PathAngleArc { 107 | centerX: parent.width / 2 108 | centerY: parent.height / 2 109 | radiusX: segmentedArc.scalefactor * parent.width 110 | radiusY: segmentedArc.scalefactor * parent.height 111 | startAngle: -90 + index * (sweepAngle + (segmentedArc.clockwise ? +segmentedArc.gap : -segmentedArc.gap)) + segmentedArc.start 112 | sweepAngle: segmentedArc.clockwise ? (segmentedArc.endFromStart / segmentedArc.segmentAmount) - segmentedArc.gap : 113 | -(segmentedArc.endFromStart / segmentedArc.segmentAmount) + segmentedArc.gap 114 | moveToStart: true 115 | } 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/controls/qml/Spinner.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import QtQuick 2.9 19 | import org.asteroid.controls 1.0 20 | 21 | 22 | /*! 23 | \qmltype Spinner 24 | \inqmlmodule AsteroidControls 25 | 26 | \brief Simple spinner to select values from collection. 27 | 28 | Here is a short that shows a \l Spinner containing three items 29 | and using a \l SpinnerDelegate to display them. 30 | 31 | \qml 32 | import QtQuick 2.0 33 | import org.asteroid.controls 1.0 34 | 35 | Spinner { 36 | id: rating 37 | model: ["Larry", "Moe", "Curly"] 38 | delegate: SpinnerDelegate{ 39 | text: rating.model[index] 40 | MouseArea { 41 | anchors.fill: parent 42 | onClicked: rating.currentIndex = index 43 | } 44 | } 45 | highlight: Rectangle { color: "orange" } 46 | highlightFollowsCurrentItem: true 47 | focus: true 48 | } 49 | \endqml 50 | */ 51 | ListView { 52 | property alias showSeparator: separator.visible 53 | 54 | id: lv 55 | preferredHighlightBegin: height / 2 - Dims.h(5) 56 | preferredHighlightEnd: height / 2 + Dims.h(5) 57 | highlightRangeMode: ListView.StrictlyEnforceRange 58 | spacing: Dims.h(2) 59 | clip: true 60 | 61 | delegate: SpinnerDelegate { } 62 | 63 | Rectangle { 64 | id: separator 65 | width: 1 66 | height: parent.height*0.8 67 | color: "#88FFFFFF" 68 | anchors.verticalCenter: parent.verticalCenter 69 | anchors.right: parent.right 70 | visible: false 71 | } 72 | 73 | layer.enabled: true 74 | layer.effect: ShaderEffect { 75 | fragmentShader: " 76 | precision mediump float; 77 | varying highp vec2 qt_TexCoord0; 78 | uniform sampler2D source; 79 | void main(void) 80 | { 81 | vec4 sourceColor = texture2D(source, qt_TexCoord0); 82 | float alpha = 1.0; 83 | if(qt_TexCoord0.y < 0.2) 84 | alpha = qt_TexCoord0.y*5.0; 85 | if(qt_TexCoord0.y > 0.8) 86 | alpha = (1.0-qt_TexCoord0.y)*5.0; 87 | gl_FragColor = sourceColor * alpha; 88 | }" 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/controls/qml/SpinnerDelegate.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import QtQuick 2.9 19 | import org.asteroid.controls 1.0 20 | 21 | /*! 22 | \qmltype SpinnerDelegate 23 | \inqmlmodule AsteroidControls 24 | 25 | \brief Provides a delegate for use with CircularSpinner. 26 | 27 | The SpinnerDelegate is primarily intended to be used with a \l CircularSpinner 28 | but may also be used with a plain \l ListView or \l PathView. It is responsible 29 | for displaying each value in the list model. This example shows how a user can 30 | select from list of 20 integers. Here, a \l MouseArea is added to allow the user 31 | to select a value. 32 | 33 | \qml 34 | import QtQuick 2.9 35 | import org.asteroid.controls 1.0 36 | 37 | ListView { 38 | id: rating 39 | anchors.centerIn: parent 40 | model: 20 41 | delegate: SpinnerDelegate{ 42 | MouseArea { 43 | anchors.fill: parent 44 | onClicked: rating.currentIndex = index 45 | } 46 | } 47 | highlight: Rectangle { color: "green" } 48 | highlightFollowsCurrentItem: true 49 | focus: true 50 | } 51 | \endqml 52 | 53 | This somewhat more complex example shows a month and a year \l CircularSpinner 54 | each with a \l SpinnerDelegate that overrides the \l text attribute. 55 | 56 | \qml 57 | import QtQuick 2.12 58 | import org.asteroid.controls 1.0 59 | 60 | Item { 61 | id: combinationSelector 62 | anchors.fill: parent 63 | Row { 64 | anchors.fill: parent 65 | CircularSpinner { 66 | id: month 67 | height: parent.height 68 | width: parent.width/2 69 | model: 12 70 | showSeparator: true 71 | delegate: SpinnerDelegate{ text: Qt.locale().monthName(index, Locale.ShortFormat) } 72 | } 73 | CircularSpinner { 74 | id: year 75 | height: parent.height 76 | width: parent.width/2 77 | model: 100 78 | showSeparator: false 79 | delegate: SpinnerDelegate { text: index+2000 } 80 | } 81 | } 82 | } 83 | \endqml 84 | 85 | The effect on a round watch is shown below. 86 | \image SpinnerExample.jpg "Spinner example screenshot" 87 | */ 88 | Label { 89 | property bool isCircularSpinner: PathView.view !== null 90 | property bool isCurr: isCircularSpinner ? PathView.isCurrentItem : ListView.isCurrentItem 91 | 92 | width: isCircularSpinner ? PathView.view.width : ListView.view.width 93 | height: Dims.h(10) 94 | 95 | function zeroPadding(x) { 96 | if (x<10) return "0"+x; 97 | else return x; 98 | } 99 | 100 | /*! 101 | Defaults to a zero-padded two-digit value. 102 | */ 103 | text: zeroPadding(index) 104 | horizontalAlignment: Text.AlignHCenter 105 | verticalAlignment: Text.AlignVCenter 106 | 107 | opacity: isCurr ? 1.0 : 0.6 108 | scale: isCurr ? 1.4 : 0.8 109 | Behavior on scale { NumberAnimation { duration: 200 } } 110 | Behavior on opacity { NumberAnimation { duration: 200 } } 111 | } 112 | -------------------------------------------------------------------------------- /src/controls/qml/StatusPage.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 - Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | import QtQuick 2.9 19 | import org.asteroid.controls 1.0 20 | 21 | 22 | /*! 23 | \qmltype StatusPage 24 | \inqmlmodule AsteroidControls 25 | 26 | \brief Provides access to dimensions relative to a ratio of the screen width/height. 27 | 28 | This singleton provides methods for building a user interface that automatically scales based on 29 | screen proportions. Use the Dims::w function wherever you need to specify a size relative to 30 | the screen width, and Dims::h when you need a dimension relative to the height. Dims::l 31 | provides a ratio of the smallest dimension for smartwatches that could have a screen larger than 32 | high. 33 | 34 | Here is a short example: 35 | 36 | \qml 37 | import QtQuick 2.0 38 | import org.asteroid.controls 1.0 39 | 40 | StatusPage { 41 | text: "On fire" 42 | icon: "ios-bonfire-outline" 43 | clickable: true 44 | onClicked: icon = "ios-bonfire" 45 | } 46 | \endqml 47 | */ 48 | Item { 49 | /*! Text to display */ 50 | property alias text: statusLabel.text 51 | /*! Icon to display */ 52 | property alias icon: statusIcon.name 53 | /*! Page is clickable. Default to false */ 54 | property bool clickable: false 55 | /*! Active background */ 56 | property bool activeBackground: false 57 | /*! signal emitted when clicked */ 58 | signal clicked() 59 | 60 | anchors.fill: parent 61 | 62 | Rectangle { 63 | id: statusBackground 64 | anchors.centerIn: parent 65 | anchors.verticalCenterOffset: -Dims.h(13) 66 | color: "black" 67 | radius: width/2 68 | opacity: activeBackground ? 0.4 : 0.2 69 | width: parent.height*0.25 70 | height: width 71 | } 72 | Icon { 73 | id: statusIcon 74 | anchors.fill: statusBackground 75 | anchors.margins: Dims.l(3) 76 | } 77 | MouseArea { 78 | id: statusMA 79 | enabled: clickable 80 | anchors.fill: statusBackground 81 | onClicked: parent.clicked() 82 | } 83 | 84 | Label { 85 | id: statusLabel 86 | font.pixelSize: Dims.l(5) 87 | horizontalAlignment: Text.AlignHCenter 88 | verticalAlignment: Text.AlignVCenter 89 | wrapMode: Text.Wrap 90 | anchors.left: parent.left; anchors.right: parent.right 91 | anchors.leftMargin: Dims.w(4); anchors.rightMargin: anchors.leftMargin 92 | anchors.verticalCenter: parent.verticalCenter 93 | anchors.verticalCenterOffset: Dims.h(15) 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/controls/qml/Switch.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Darrel Griët 3 | * Copyright (C) 2016 Florent Revest 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as 7 | * published by the Free Software Foundation, either version 2.1 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | import QtQuick 2.5 20 | import org.asteroid.controls 1.0 21 | 22 | /*! 23 | \qmltype Switch 24 | \inqmlmodule org.asteroid.controls 1.0 25 | 26 | \brief Specializes \l IconButton to provide an on/off toggle. 27 | 28 | The IconButton is a specialization of the \l IconButton that provides 29 | an on/off toggle. 30 | 31 | This example shows a blue square centered in the screen with a Switch below it. When the 32 | Switch is checked, the square turns green. When it is unchecked, the square turns red. 33 | 34 | \qml 35 | import QtQuick 2.9 36 | import org.asteroid.controls 1.0 37 | 38 | Item { 39 | anchors.centerIn: parent 40 | anchors.fill: parent 41 | Rectangle { 42 | id: square 43 | anchors.centerIn: parent 44 | width: 100 45 | height: 100 46 | color: "blue" 47 | } 48 | Switch { 49 | anchors.top: square.bottom 50 | anchors.horizontalCenter: parent.horizontalCenter 51 | width: Dims.l(20) 52 | onCheckedChanged: { 53 | if (checked) 54 | square.color = "green" 55 | else 56 | square.color = "red" 57 | } 58 | } 59 | } 60 | \endqml 61 | */ 62 | Item { 63 | property bool checked 64 | 65 | width: Dims.l(30) 66 | height: width 67 | 68 | Icon { 69 | id: onIcon 70 | anchors.fill: parent 71 | name: "ios-checkmark-circle-outline" 72 | opacity: checked ? (!enabled ? 0.6 : 1.0) : 0.0 73 | Behavior on opacity { NumberAnimation { duration: 100 } } 74 | } 75 | Icon { 76 | id: offIcon 77 | anchors.fill: parent 78 | name: "ios-circle-outline" 79 | opacity: !checked ? (!enabled ? 0.6 : 1.0) : 0.0 80 | Behavior on opacity { NumberAnimation { duration: 100 } } 81 | } 82 | MouseArea { 83 | anchors.fill: parent 84 | onClicked: checked = !checked 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/controls/qml/TextArea.qml: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2016 The Qt Company Ltd. 4 | ** Contact: https://www.qt.io/licensing/ 5 | ** 6 | ** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:GPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and The Qt Company. For licensing terms 14 | ** and conditions see https://www.qt.io/terms-conditions. For further 15 | ** information use the contact form at https://www.qt.io/contact-us. 16 | ** 17 | ** GNU General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU 19 | ** General Public License version 3 or (at your option) any later version 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 22 | ** included in the packaging of this file. Please review the following 23 | ** information to ensure the GNU General Public License requirements will 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 25 | ** 26 | ** $QT_END_LICENSE$ 27 | ** 28 | ****************************************************************************/ 29 | 30 | import QtQuick 2.9 31 | import QtQuick.VirtualKeyboard 2.15 32 | 33 | /*! 34 | \qmltype TextArea 35 | \inqmlmodule AsteroidControls 36 | 37 | \brief Editable multi-line text field. 38 | 39 | The TextArea provides an editable multiline area which 40 | can use a virtual keyboard to accept text. The default 41 | virtual keyboard for AsteroidOS is the \l HandWritingKeyboard 42 | which is used in this example. In this example, a simple 43 | \l TextArea is created in the upper left corner of the screen. 44 | 45 | \qml 46 | import QtQuick 2.9 47 | import org.asteroid.controls 1.0 48 | 49 | Item { 50 | HandWritingKeyboard { 51 | anchors.fill: parent 52 | } 53 | TextArea { 54 | width: parent.width * 0.8 55 | height: parent.height * 0.8 56 | anchors.top: parent.top 57 | } 58 | } 59 | \endqml 60 | */ 61 | TextBase { 62 | id: textArea 63 | 64 | /*! Text color */ 65 | property alias color: textEdit.color 66 | /*! The input text */ 67 | property alias text: textEdit.text 68 | /*! The input text width */ 69 | property alias textWidth: textEdit.width 70 | /*! Whether to make the field read-only */ 71 | property alias readOnly: textEdit.readOnly 72 | /*! See TextInput::inputMethodHints */ 73 | property alias inputMethodHints: textEdit.inputMethodHints 74 | 75 | editor: textEdit 76 | 77 | Repeater { 78 | model: Math.floor((parent.height - 30) / editor.cursorRectangle.height) 79 | Rectangle { 80 | x: 8 81 | y: (index+1)*editor.cursorRectangle.height+6 82 | height: 1; width: textArea.width-24 83 | color: "#D6D6D6" 84 | } 85 | } 86 | MouseArea { 87 | anchors.fill: parent 88 | onClicked: textEdit.forceActiveFocus() 89 | } 90 | TextEdit { 91 | id: textEdit 92 | 93 | EnterKeyAction.actionId: textArea.enterKeyAction 94 | EnterKeyAction.label: textArea.enterKeyText 95 | EnterKeyAction.enabled: textArea.enterKeyEnabled 96 | 97 | y: 6 98 | focus: true 99 | color: "#2B2C2E" 100 | wrapMode: TextEdit.Wrap 101 | cursorVisible: activeFocus 102 | height: Math.max(implicitHeight, 60) 103 | font.pixelSize: textArea.fontPixelSize 104 | selectionColor: Qt.rgba(1.0, 1.0, 1.0, 0.5) 105 | selectedTextColor: Qt.rgba(0.0, 0.0, 0.0, 0.8) 106 | selectByMouse: true 107 | anchors { left: parent.left; right: parent.right; margins: 12 } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/controls/qml/TextBase.qml: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2016 The Qt Company Ltd. 4 | ** Contact: https://www.qt.io/licensing/ 5 | ** 6 | ** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:GPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and The Qt Company. For licensing terms 14 | ** and conditions see https://www.qt.io/terms-conditions. For further 15 | ** information use the contact form at https://www.qt.io/contact-us. 16 | ** 17 | ** GNU General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU 19 | ** General Public License version 3 or (at your option) any later version 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 22 | ** included in the packaging of this file. Please review the following 23 | ** information to ensure the GNU General Public License requirements will 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 25 | ** 26 | ** $QT_END_LICENSE$ 27 | ** 28 | ****************************************************************************/ 29 | 30 | import QtQuick 2.9 31 | import QtQuick.VirtualKeyboard 2.1 32 | 33 | FocusScope { 34 | id: textBase 35 | 36 | property var editor 37 | property bool previewTextActive: !editor.activeFocus && text.length === 0 38 | property int fontPixelSize: 32 39 | property string previewText 40 | property int enterKeyAction: EnterKeyAction.None 41 | property string enterKeyText 42 | property bool enterKeyEnabled: enterKeyAction === EnterKeyAction.None || editor.text.length > 0 || editor.inputMethodComposing 43 | 44 | implicitHeight: editor.height + 12 45 | 46 | signal enterKeyClicked 47 | 48 | Keys.onReleased: { 49 | if (event.key === Qt.Key_Return) 50 | enterKeyClicked() 51 | } 52 | 53 | Rectangle { 54 | // background 55 | radius: 5.0 56 | anchors.fill: parent 57 | color: "#FFFFFF" 58 | border { width: 1; color: editor.activeFocus ? "#606060" : "#BDBEBF" } 59 | } 60 | Text { 61 | id: previewText 62 | 63 | y: 8 64 | clip: true 65 | color: "#a0a1a2" 66 | visible: previewTextActive 67 | text: textBase.previewText 68 | font.pixelSize: 28 69 | anchors { left: parent.left; right: parent.right; margins: 12 } 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/controls/qml/TextField.qml: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2016 The Qt Company Ltd. 4 | ** Contact: https://www.qt.io/licensing/ 5 | ** 6 | ** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:GPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and The Qt Company. For licensing terms 14 | ** and conditions see https://www.qt.io/terms-conditions. For further 15 | ** information use the contact form at https://www.qt.io/contact-us. 16 | ** 17 | ** GNU General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU 19 | ** General Public License version 3 or (at your option) any later version 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 22 | ** included in the packaging of this file. Please review the following 23 | ** information to ensure the GNU General Public License requirements will 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 25 | ** 26 | ** $QT_END_LICENSE$ 27 | ** 28 | ****************************************************************************/ 29 | 30 | import QtQuick 2.9 31 | import QtQuick.VirtualKeyboard 2.1 32 | 33 | /*! 34 | \qmltype TextField 35 | \inqmlmodule AsteroidControls 36 | 37 | \brief Editable text field. 38 | 39 | The TextField type provides an editable text field which can 40 | use a virtual keyboard to accept text. The default 41 | virtual keyboard for AsteroidOS is the \l HandWritingKeyboard 42 | which is used in this example. In this example, a simple 43 | TextField is created in the center of the screen with 44 | preview text "sample text". The preview text is intended to 45 | convey what kind of input is being asked but the actual value 46 | of the field once filled in is \l text. 47 | 48 | \qml 49 | import QtQuick 2.9 50 | import org.asteroid.controls 1.0 51 | 52 | Item { 53 | HandWritingKeyboard { 54 | anchors.fill: parent 55 | } 56 | 57 | TextField { 58 | width: parent.width * 0.8 59 | textWidth: parent.width *0.75 60 | anchors { 61 | horizontalCenter: parent.horizontalCenter 62 | verticalCenter: parent.verticalCenter 63 | } 64 | previewText: "sample text" 65 | } 66 | } 67 | \endqml 68 | 69 | */ 70 | TextBase { 71 | id: textField 72 | 73 | /*! Text color */ 74 | property alias color: textInput.color 75 | /*! The input text */ 76 | property alias text: textInput.text 77 | /*! The input text width */ 78 | property alias textWidth: textInput.width 79 | /*! Whether to make the field read-only */ 80 | property alias readOnly: textInput.readOnly 81 | /*! See TextInput::inputMethodHints */ 82 | property alias inputMethodHints: textInput.inputMethodHints 83 | /*! See TextInput::validator */ 84 | property alias validator: textInput.validator 85 | /*! See TextInput::echoMode */ 86 | property alias echoMode: textInput.echoMode 87 | /*! Delay time from when a letter is input to when it is obscured */ 88 | property int passwordMaskDelay: 1000 89 | 90 | editor: textInput 91 | 92 | Flickable { 93 | id: flickable 94 | 95 | x: 12 96 | clip: true 97 | width: parent.width-24 98 | height: parent.height 99 | flickableDirection: Flickable.HorizontalFlick 100 | interactive: contentWidth - 4 > width 101 | 102 | contentWidth: textInput.width+2 103 | contentHeight: textInput.height 104 | TextInput { 105 | id: textInput 106 | 107 | EnterKeyAction.actionId: textField.enterKeyAction 108 | EnterKeyAction.label: textField.enterKeyText 109 | EnterKeyAction.enabled: textField.enterKeyEnabled 110 | 111 | y: 6 112 | focus: true 113 | color: "#2B2C2E" 114 | cursorVisible: activeFocus 115 | passwordCharacter: "\u2022" 116 | font.pixelSize: textField.fontPixelSize 117 | selectionColor: Qt.rgba(0.0, 0.0, 0.0, 0.15) 118 | selectedTextColor: color 119 | selectByMouse: true 120 | width: Math.max(flickable.width, implicitWidth)-2 121 | 122 | Binding { 123 | target: textInput 124 | property: "passwordMaskDelay" 125 | value: textField.passwordMaskDelay 126 | when: textInput.hasOwnProperty("passwordMaskDelay") 127 | } 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/controls/qmldir: -------------------------------------------------------------------------------- 1 | module org.asteroid.controls 2 | 3 | plugin asteroidcontrolsplugin 4 | 5 | Application 1.0 qrc:///org/asteroid/controls/qml/Application.qml 6 | BorderGestureArea 1.0 qrc:///org/asteroid/controls/qml/BorderGestureArea.qml 7 | CircularSpinner 1.0 qrc:///org/asteroid/controls/qml/CircularSpinner.qml 8 | singleton Dims 1.0 qrc:///org/asteroid/controls/qml/Dims.qml 9 | HandWritingKeyboard 1.0 qrc:///org/asteroid/controls/qml/HandWritingKeyboard.qml 10 | HighlightBar 1.0 qrc:///org/asteroid/controls/qml/HighlightBar.qml 11 | IconButton 1.0 qrc:///org/asteroid/controls/qml/IconButton.qml 12 | Indicator 1.0 qrc:///org/asteroid/controls/qml/Indicator.qml 13 | IntSelector 1.0 qrc:///org/asteroid/controls/qml/IntSelector.qml 14 | Label 1.0 qrc:///org/asteroid/controls/qml/Label.qml 15 | LabeledActionButton 1.0 qrc:///org/asteroid/controls/qml/LabeledActionButton.qml 16 | LabeledSwitch 1.0 qrc:///org/asteroid/controls/qml/LabeledSwitch.qml 17 | LayerStack 1.0 qrc:///org/asteroid/controls/qml/LayerStack.qml 18 | ListItem 1.0 qrc:///org/asteroid/controls/qml/ListItem.qml 19 | Marquee 1.0 qrc:///org/asteroid/controls/qml/Marquee.qml 20 | PageDot 1.0 qrc:///org/asteroid/controls/qml/PageDot.qml 21 | PageHeader 1.0 qrc:///org/asteroid/controls/qml/PageHeader.qml 22 | SegmentedArc 1.0 qrc:///org/asteroid/controls/qml/SegmentedArc.qml 23 | Spinner 1.0 qrc:///org/asteroid/controls/qml/Spinner.qml 24 | SpinnerDelegate 1.0 qrc:///org/asteroid/controls/qml/SpinnerDelegate.qml 25 | StatusPage 1.0 qrc:///org/asteroid/controls/qml/StatusPage.qml 26 | Switch 1.0 qrc:///org/asteroid/controls/qml/Switch.qml 27 | TextArea 1.0 qrc:///org/asteroid/controls/qml/TextArea.qml 28 | TextBase 1.0 qrc:///org/asteroid/controls/qml/TextBase.qml 29 | TextField 1.0 qrc:///org/asteroid/controls/qml/TextField.qml 30 | -------------------------------------------------------------------------------- /src/controls/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | qml/Application.qml 4 | qml/BorderGestureArea.qml 5 | qml/CircularSpinner.qml 6 | qml/Dims.qml 7 | qml/ListItem.qml 8 | qml/HandWritingKeyboard.qml 9 | qml/HighlightBar.qml 10 | qml/IconButton.qml 11 | qml/Indicator.qml 12 | qml/Label.qml 13 | qml/LayerStack.qml 14 | qml/Marquee.qml 15 | qml/LabeledSwitch.qml 16 | qml/LabeledActionButton.qml 17 | qml/PageDot.qml 18 | qml/PageHeader.qml 19 | qml/IntSelector.qml 20 | qml/SegmentedArc.qml 21 | qml/SpinnerDelegate.qml 22 | qml/Spinner.qml 23 | qml/StatusPage.qml 24 | qml/Switch.qml 25 | qml/TextArea.qml 26 | qml/TextBase.qml 27 | qml/TextField.qml 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/controls/src/application_p.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Florent Revest 3 | * All rights reserved. 4 | * 5 | * You may use this file under the terms of BSD license as follows: 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of the author nor the 15 | * names of its contributors may be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #include "application_p.h" 31 | 32 | Application_p::Application_p() : QQuickItem() 33 | { 34 | m_overridesSystemGestures = false; 35 | } 36 | 37 | void Application_p::setOverridesSystemGestures(bool enable) 38 | { 39 | if(m_overridesSystemGestures != enable) 40 | { 41 | m_overridesSystemGestures = enable; 42 | if(enable) 43 | window()->setFlags(window()->flags() | Qt::WindowOverridesSystemGestures); 44 | else 45 | window()->setFlags(window()->flags() & ~Qt::WindowOverridesSystemGestures); 46 | emit overridesSystemGesturesChanged(); 47 | } 48 | } 49 | 50 | bool Application_p::overridesSystemGestures() 51 | { 52 | return m_overridesSystemGestures; 53 | } 54 | -------------------------------------------------------------------------------- /src/controls/src/application_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Florent Revest 3 | * All rights reserved. 4 | * 5 | * You may use this file under the terms of BSD license as follows: 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of the author nor the 15 | * names of its contributors may be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef APPLICATION_P_H 31 | #define APPLICATION_P_H 32 | 33 | #include 34 | #include 35 | 36 | class Application_p : public QQuickItem 37 | { 38 | Q_OBJECT 39 | Q_PROPERTY(QQuickWindow* window READ window CONSTANT) 40 | Q_PROPERTY(bool overridesSystemGestures READ overridesSystemGestures WRITE setOverridesSystemGestures NOTIFY overridesSystemGesturesChanged) 41 | 42 | public: 43 | explicit Application_p(); 44 | Q_INVOKABLE void setOverridesSystemGestures(bool enable); 45 | bool overridesSystemGestures(); 46 | 47 | private: 48 | bool m_overridesSystemGestures; 49 | 50 | signals: 51 | void overridesSystemGesturesChanged(); 52 | }; 53 | 54 | #endif // APPLICATION_P_H 55 | -------------------------------------------------------------------------------- /src/controls/src/controls_plugin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 - Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "controls_plugin.h" 19 | #include 20 | #include 21 | #include 22 | #include "application_p.h" 23 | #include "flatmesh.h" 24 | #include "icon.h" 25 | 26 | ControlsPlugin::ControlsPlugin(QObject *parent) : QQmlExtensionPlugin(parent) 27 | { 28 | } 29 | 30 | void ControlsPlugin::registerTypes(const char *uri) 31 | { 32 | Q_ASSERT(uri == QLatin1String("org.asteroid.controls")); 33 | 34 | QGuiApplication::setFont(QFont("Noto Sans")); 35 | 36 | qmlRegisterType(uri, 1, 0, "Application_p"); 37 | qmlRegisterType(uri, 1, 0, "FlatMesh"); 38 | qmlRegisterType(uri, 1, 0, "Icon"); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/controls/src/controls_plugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 - Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef CONTROLSPLUGIN_H 19 | #define CONTROLSPLUGIN_H 20 | 21 | #include 22 | 23 | class ControlsPlugin : public QQmlExtensionPlugin 24 | { 25 | Q_OBJECT 26 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") 27 | 28 | public: 29 | explicit ControlsPlugin(QObject *parent = 0); 30 | void registerTypes(const char *uri); 31 | }; 32 | 33 | #endif // CONTROLSPLUGIN_H 34 | 35 | -------------------------------------------------------------------------------- /src/controls/src/flatmesh.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Florent Revest 3 | * All rights reserved. 4 | * 5 | * You may use this file under the terms of BSD license as follows: 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of the author nor the 15 | * names of its contributors may be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #include "flatmesh.h" 31 | #include "flatmeshnode.h" 32 | 33 | FlatMesh::FlatMesh(QQuickItem *parent) : QQuickItem(parent) 34 | { 35 | m_timer.setInterval(90); 36 | m_timer.setSingleShot(false); 37 | connect(&m_timer, SIGNAL(timeout()), this, SLOT(update())); 38 | m_timer.start(); 39 | 40 | m_centerColor = QColor("#ffaa39"); 41 | m_outerColor = QColor("#df4829"); 42 | 43 | connect(this, SIGNAL(visibleChanged()), this, SLOT(maybeEnableAnimation())); 44 | 45 | setFlag(ItemHasContents); 46 | setAnimated(true); 47 | } 48 | 49 | void FlatMesh::setCenterColor(QColor c) 50 | { 51 | if (c == m_centerColor) 52 | return; 53 | m_centerColor = c; 54 | update(); 55 | } 56 | 57 | void FlatMesh::setOuterColor(QColor c) 58 | { 59 | if (c == m_outerColor) 60 | return; 61 | m_outerColor = c; 62 | update(); 63 | } 64 | 65 | void FlatMesh::maybeEnableAnimation() 66 | { 67 | if (isVisible() && m_animated) { 68 | m_timer.start(); 69 | } else { 70 | m_timer.stop(); 71 | } 72 | update(); 73 | } 74 | 75 | void FlatMesh::setAnimated(bool animated) 76 | { 77 | if (animated == m_animated) 78 | return; 79 | m_animated = animated; 80 | emit animatedChanged(); 81 | maybeEnableAnimation(); 82 | } 83 | 84 | QSGNode *FlatMesh::updatePaintNode(QSGNode *old, UpdatePaintNodeData *) 85 | { 86 | FlatMeshNode *n = static_cast(old); 87 | if (!n) 88 | n = new FlatMeshNode(window(), boundingRect()); 89 | 90 | n->setAnimated(m_animated); 91 | n->setRect(boundingRect()); 92 | n->setCenterColor(m_centerColor); 93 | n->setOuterColor(m_outerColor); 94 | 95 | return n; 96 | } 97 | -------------------------------------------------------------------------------- /src/controls/src/flatmesh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Florent Revest 3 | * All rights reserved. 4 | * 5 | * You may use this file under the terms of BSD license as follows: 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of the author nor the 15 | * names of its contributors may be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef FLATMESH_H 31 | #define FLATMESH_H 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | class FlatMesh : public QQuickItem 39 | { 40 | Q_OBJECT 41 | Q_PROPERTY(QColor centerColor WRITE setCenterColor READ getCenterColor) 42 | Q_PROPERTY(QColor outerColor WRITE setOuterColor READ getOuterColor) 43 | Q_PROPERTY(bool animated WRITE setAnimated READ getAnimated NOTIFY animatedChanged) 44 | 45 | public: 46 | FlatMesh(QQuickItem *parent = 0); 47 | 48 | bool getAnimated() const { return m_animated; } 49 | void setAnimated(bool animated); 50 | 51 | QColor getCenterColor() const { return m_centerColor; } 52 | void setCenterColor(QColor c); 53 | 54 | QColor getOuterColor() const { return m_outerColor; } 55 | void setOuterColor(QColor c); 56 | 57 | signals: 58 | void animatedChanged(); 59 | 60 | protected: 61 | QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *data); 62 | 63 | private slots: 64 | void maybeEnableAnimation(); 65 | 66 | private: 67 | QColor m_centerColor, m_outerColor; 68 | bool m_animated; 69 | QTimer m_timer; 70 | }; 71 | 72 | #endif // FLATMESH_H 73 | -------------------------------------------------------------------------------- /src/controls/src/flatmeshnode.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Florent Revest 3 | * All rights reserved. 4 | * 5 | * You may use this file under the terms of BSD license as follows: 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of the author nor the 15 | * names of its contributors may be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #include "flatmeshnode.h" 31 | 32 | #include 33 | 34 | #include 35 | #include 36 | 37 | /* Used to compute a triangle color from its distance to the center */ 38 | static inline QColor interpolateColors(const QColor& color1, const QColor& color2, qreal ratio) 39 | { 40 | /* Linear scale is too harsh, this looks better. This is not supposed to be called very often */ 41 | ratio = pow(ratio, 1.7); 42 | if (ratio>1) ratio=1; 43 | 44 | int r = color1.red()*(1-ratio) + color2.red()*ratio; 45 | int g = color1.green()*(1-ratio) + color2.green()*ratio; 46 | int b = color1.blue()*(1-ratio) + color2.blue()*ratio; 47 | 48 | return QColor(r, g, b); 49 | } 50 | 51 | FlatMeshNode::FlatMeshNode(QQuickWindow *window, QRectF boundingRect) 52 | : QSGSimpleRectNode(boundingRect, Qt::transparent), 53 | m_animationState(0), m_animated(true), m_window(window) 54 | { 55 | connect(window, SIGNAL(afterRendering()), this, SLOT(maybeAnimate())); 56 | 57 | connect(window, SIGNAL(widthChanged(int)), this, SLOT(generateGrid())); 58 | connect(window, SIGNAL(heightChanged(int)), this, SLOT(generateGrid())); 59 | 60 | srand(time(NULL)); 61 | generateGrid(); 62 | 63 | for(int y = 0; y < NUM_POINTS_Y-1; y++) { 64 | for(int x = 0; x < NUM_POINTS_X-1; x++) { 65 | for(int n = 0; n < 2; n++) { 66 | QSGGeometryNode *triangle = new QSGGeometryNode(); 67 | 68 | QSGFlatColorMaterial *color = new QSGFlatColorMaterial; 69 | triangle->setOpaqueMaterial(color); 70 | triangle->setFlag(QSGNode::OwnsMaterial); 71 | 72 | QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 3); 73 | triangle->setGeometry(geometry); 74 | triangle->setFlag(QSGNode::OwnsGeometry); 75 | 76 | appendChildNode(triangle); 77 | } 78 | } 79 | } 80 | 81 | maybeAnimate(); 82 | } 83 | 84 | void FlatMeshNode::updateColors() 85 | { 86 | int centerX = m_unitWidth*((NUM_POINTS_X-2)/2); 87 | int centerY = m_unitHeight*((NUM_POINTS_Y-2)/2); 88 | int radius = rect().width()*0.6; 89 | 90 | QSGGeometryNode *triangle = static_cast(firstChild()); 91 | for(int y = 0; y < NUM_POINTS_Y-1; y++) { 92 | for(int x = 0; x < NUM_POINTS_X-1; x++) { 93 | for(int n = 0; n < 2; n++) { 94 | QSGFlatColorMaterial *color = static_cast(triangle->opaqueMaterial()); 95 | color->setColor(interpolateColors(m_centerColor, m_outerColor, 96 | sqrt(pow(m_points[y*NUM_POINTS_Y+x].centerX-centerX, 2) + pow(m_points[y*NUM_POINTS_Y+x].centerY-centerY, 2))/radius)); 97 | triangle->setOpaqueMaterial(color); 98 | 99 | triangle->markDirty(QSGNode::DirtyMaterial); 100 | triangle = static_cast(triangle->nextSibling()); 101 | } 102 | } 103 | } 104 | } 105 | 106 | void FlatMeshNode::setCenterColor(QColor c) 107 | { 108 | if (c == m_centerColor) 109 | return; 110 | m_centerColor = c; 111 | updateColors(); 112 | } 113 | 114 | void FlatMeshNode::setOuterColor(QColor c) 115 | { 116 | if (c == m_outerColor) 117 | return; 118 | m_outerColor = c; 119 | updateColors(); 120 | } 121 | 122 | /* When the size changes, regenerate a grid of points that serves as a base for further operations */ 123 | void FlatMeshNode::generateGrid() 124 | { 125 | m_unitWidth = rect().width()/(NUM_POINTS_X-2); 126 | m_unitHeight = rect().height()/(NUM_POINTS_Y-2); 127 | 128 | for(int y = 0; y < NUM_POINTS_Y; y++) { 129 | for(int x = 0; x < NUM_POINTS_X; x++) { 130 | Point *point = &m_points[y*NUM_POINTS_Y+x]; 131 | point->centerX = m_unitWidth*x; 132 | point->centerY = m_unitHeight*y; 133 | 134 | if(x != 0 && x != (NUM_POINTS_X-1) && y != 0 && y != (NUM_POINTS_Y-1)) { 135 | int offsetX = rand()%m_unitWidth - m_unitWidth/3; 136 | int offsetY = rand()%m_unitHeight - m_unitHeight/3; 137 | float normalization = ((float)m_unitWidth)/(2*(abs(offsetX)+abs(offsetY))); 138 | offsetX*=normalization; 139 | offsetY*=normalization; 140 | point->animOriginX = point->centerX + offsetX; 141 | point->animOriginY = point->centerY + offsetY; 142 | 143 | offsetX = rand()%m_unitWidth - m_unitWidth/3; 144 | offsetY = rand()%m_unitHeight - m_unitHeight/3; 145 | normalization = ((float)m_unitWidth)/(2*(abs(offsetX)+abs(offsetY))); 146 | offsetX*=normalization; 147 | offsetY*=normalization; 148 | point->animEndX = point->centerX + offsetX; 149 | point->animEndY = point->centerY + offsetY; 150 | } 151 | else { 152 | point->animEndX = point->animOriginX = point->centerX; 153 | point->animEndY = point->animOriginY = point->centerY; 154 | } 155 | } 156 | } 157 | } 158 | 159 | void FlatMeshNode::setAnimated(bool animated) 160 | { 161 | m_animated = animated; 162 | } 163 | 164 | void FlatMeshNode::maybeAnimate() 165 | { 166 | static QElapsedTimer t; 167 | bool firstFrame = false; 168 | if(!t.isValid()) { 169 | t.start(); 170 | firstFrame = true; 171 | } 172 | if (firstFrame || (m_animated && t.elapsed() >= 80)) { 173 | t.restart(); 174 | m_animationState += 0.03; 175 | 176 | /* Interpolate all points positions according to the animationState */ 177 | for(int i = 0; i < NUM_POINTS_X*NUM_POINTS_Y; i++) { 178 | Point *p = &m_points[i]; 179 | 180 | p->currentPos.x = p->animOriginX + (p->animEndX-p->animOriginX)*m_animationState; 181 | p->currentPos.y = p->animOriginY + (p->animEndY-p->animOriginY)*m_animationState; 182 | } 183 | 184 | /* Update all triangles' geometries according to the new points position */ 185 | qreal lastCenterX = m_unitWidth*(NUM_POINTS_X-1); 186 | qreal lastcenterY = m_unitHeight*(NUM_POINTS_Y-1); 187 | QSGGeometryNode *triangle = static_cast(firstChild()); 188 | for(int i = 0; i < NUM_POINTS_X*NUM_POINTS_Y; i++) { 189 | if(m_points[i].centerX != lastCenterX && m_points[i].centerY != lastcenterY) { 190 | QSGGeometry::Point2D *lowerV = triangle->geometry()->vertexDataAsPoint2D(); 191 | lowerV[0] = m_points[i].currentPos; 192 | lowerV[1] = m_points[i+NUM_POINTS_X].currentPos; 193 | lowerV[2] = m_points[i+NUM_POINTS_X+1].currentPos; 194 | triangle->markDirty(QSGNode::DirtyGeometry); 195 | triangle = static_cast(triangle->nextSibling()); 196 | 197 | QSGGeometry::Point2D *upperV = triangle->geometry()->vertexDataAsPoint2D(); 198 | upperV[0] = m_points[i].currentPos; 199 | upperV[1] = m_points[i+1].currentPos; 200 | upperV[2] = m_points[i+NUM_POINTS_X+1].currentPos; 201 | triangle = static_cast(triangle->nextSibling()); 202 | } 203 | } 204 | 205 | /* Regenerate a set of animation end points when the animation is finished */ 206 | if(m_animationState >= 1.0) { 207 | m_animationState = 0.0; 208 | 209 | for(int y = 0; y < NUM_POINTS_Y; y++) { 210 | for(int x = 0; x < NUM_POINTS_X; x++) { 211 | Point *point = &m_points[y*NUM_POINTS_Y+x]; 212 | 213 | if(x != 0 && x != (NUM_POINTS_X-1) && y != 0 && y != (NUM_POINTS_Y-1)) { 214 | int offsetX = rand()%m_unitWidth - m_unitWidth/3; 215 | int offsetY = rand()%m_unitHeight - m_unitHeight/3; 216 | float normalization = ((float)m_unitWidth)/(2*(abs(offsetX)+abs(offsetY))); 217 | offsetX*=normalization; 218 | offsetY*=normalization; 219 | 220 | point->animOriginX = point->animEndX; 221 | point->animEndX = point->centerX + offsetX; 222 | 223 | point->animOriginY = point->animEndY; 224 | point->animEndY = point->centerY + offsetY; 225 | } 226 | } 227 | } 228 | } 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /src/controls/src/flatmeshnode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Florent Revest 3 | * All rights reserved. 4 | * 5 | * You may use this file under the terms of BSD license as follows: 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of the author nor the 15 | * names of its contributors may be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef FLATMESHNODE_H 31 | #define FLATMESHNODE_H 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #define NUM_POINTS_X 13 38 | #define NUM_POINTS_Y 13 39 | 40 | struct Point { 41 | qreal centerX; 42 | qreal centerY; 43 | 44 | qreal animOriginX; 45 | qreal animOriginY; 46 | 47 | qreal animEndX; 48 | qreal animEndY; 49 | 50 | QSGGeometry::Point2D currentPos; 51 | }; 52 | 53 | class FlatMeshNode : public QObject, public QSGSimpleRectNode 54 | { 55 | Q_OBJECT 56 | public: 57 | FlatMeshNode(QQuickWindow *window, QRectF rect); 58 | void setAnimated(bool animated); 59 | 60 | void setCenterColor(QColor c); 61 | void setOuterColor(QColor c); 62 | 63 | public slots: 64 | void maybeAnimate(); 65 | void generateGrid(); 66 | 67 | private: 68 | void updateColors(); 69 | 70 | qreal m_animationState; 71 | bool m_animated; 72 | int m_unitWidth, m_unitHeight; 73 | QColor m_centerColor, m_outerColor; 74 | QQuickWindow *m_window; 75 | Point m_points[NUM_POINTS_X*NUM_POINTS_Y]; 76 | }; 77 | 78 | 79 | #endif // FLATMESHNODE_H 80 | -------------------------------------------------------------------------------- /src/controls/src/icon.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Florent Revest 3 | * All rights reserved. 4 | * 5 | * You may use this file under the terms of BSD license as follows: 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of the author nor the 15 | * names of its contributors may be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #include "icon.h" 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #define ICONS_DIRECTORY "/usr/share/icons/asteroid/" 37 | 38 | Icon::Icon() 39 | { 40 | setFlag(ItemHasContents, true); 41 | setRenderTarget(QQuickPaintedItem::FramebufferObject); 42 | m_color = Qt::white; 43 | } 44 | 45 | void Icon::updateBasePixmap() 46 | { 47 | m_pixmap = QPixmap(QSize(width(), height())); 48 | } 49 | 50 | void Icon::updatePixmapContent() 51 | { 52 | if(m_pixmap.isNull()) 53 | return; 54 | 55 | m_pixmap.fill(Qt::transparent); 56 | 57 | if(!QFile::exists(ICONS_DIRECTORY + m_name + ".svg")) 58 | return; 59 | 60 | QPainter painter(&m_pixmap); 61 | QSvgRenderer svgRenderer(ICONS_DIRECTORY + m_name + ".svg"); 62 | svgRenderer.render(&painter); 63 | } 64 | 65 | void Icon::updatePixmapColor() 66 | { 67 | if(m_pixmap.isNull()) 68 | return; 69 | 70 | QPainter painter(&m_pixmap); 71 | painter.setCompositionMode(QPainter::CompositionMode_SourceIn); 72 | painter.fillRect(QRect(0, 0, width(), height()), m_color); 73 | } 74 | 75 | void Icon::paint(QPainter *painter) 76 | { 77 | if(m_pixmap.isNull()) 78 | return; 79 | painter->drawPixmap(0, 0, width(), height(), m_pixmap); 80 | } 81 | 82 | void Icon::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) 83 | { 84 | QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry); 85 | if(newGeometry.size() == oldGeometry.size() || newGeometry.width() == 0 || newGeometry.height() == 0) 86 | return; 87 | updateBasePixmap(); 88 | updatePixmapContent(); 89 | updatePixmapColor(); 90 | update(); 91 | } 92 | 93 | QString Icon::name() 94 | { 95 | return m_name; 96 | } 97 | 98 | void Icon::setName(QString name) 99 | { 100 | if(m_name == name) 101 | return; 102 | 103 | m_name = name; 104 | 105 | updatePixmapContent(); 106 | updatePixmapColor(); 107 | update(); 108 | emit nameChanged(); 109 | } 110 | 111 | QColor Icon::color() 112 | { 113 | return m_color; 114 | } 115 | 116 | void Icon::setColor(QColor color) 117 | { 118 | if(m_color == color) 119 | return; 120 | 121 | m_color = color; 122 | 123 | updatePixmapColor(); 124 | update(); 125 | emit colorChanged(); 126 | } 127 | -------------------------------------------------------------------------------- /src/controls/src/icon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Florent Revest 3 | * All rights reserved. 4 | * 5 | * You may use this file under the terms of BSD license as follows: 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * * Neither the name of the author nor the 15 | * names of its contributors may be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef ICON_H 31 | #define ICON_H 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | class Icon : public QQuickPaintedItem 38 | { 39 | Q_OBJECT 40 | 41 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) 42 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) 43 | 44 | public: 45 | Icon(); 46 | 47 | QString name(); 48 | void setName(QString); 49 | 50 | QColor color(); 51 | void setColor(QColor); 52 | 53 | void paint(QPainter *painter) override; 54 | 55 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; 56 | 57 | signals: 58 | void nameChanged(); 59 | void colorChanged(); 60 | 61 | private: 62 | void updateBasePixmap(); 63 | void updatePixmapContent(); 64 | void updatePixmapColor(); 65 | 66 | float m_size; 67 | QString m_name; 68 | QColor m_color; 69 | QPixmap m_pixmap; 70 | }; 71 | 72 | #endif // ICON_H 73 | -------------------------------------------------------------------------------- /src/utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRC 2 | src/utils_plugin.cpp 3 | src/devicespecs.cpp 4 | src/fileinfo.cpp 5 | src/bluetoothstatus.cpp) 6 | set(HEADERS 7 | src/utils_plugin.h 8 | src/devicespecs.h 9 | src/fileinfo.h 10 | src/bluetoothstatus.h) 11 | 12 | add_library(asteroidutilsplugin ${SRC} ${HEADERS}) 13 | 14 | target_link_libraries(asteroidutilsplugin 15 | Qt5::DBus 16 | Qt5::Qml 17 | Qt5::Quick) 18 | 19 | install(TARGETS asteroidutilsplugin 20 | DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/utils) 21 | install(FILES qmldir 22 | DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/utils) 23 | -------------------------------------------------------------------------------- /src/utils/doc/asteroid_utils.qdocconf: -------------------------------------------------------------------------------- 1 | project = AsteroidUtils 2 | description = Asteroid Utils Documentation 3 | 4 | outputformats = HTML 5 | outputdir = html 6 | 7 | depends = qtqml qtquick qtwidgets qtdoc qtquicklayouts 8 | 9 | sources.fileextensions = "*.cpp *.qdoc *.mm *.qml" 10 | headers.fileextensions = "*.h *.ch *.h++ *.hh *.hpp *.hxx" 11 | 12 | sourcedirs = \ 13 | ../src \ 14 | ../qml 15 | 16 | headerdirs = ../src 17 | 18 | qhp.projects = AsteroidUtils 19 | 20 | qhp.AsteroidUtils.file = asteroidutils.qhp 21 | qhp.AsteroidUtils.namespace = org.asteroid.Utils.100 22 | qhp.AsteroidUtils.indexTitle = Asteroid Utils 23 | -------------------------------------------------------------------------------- /src/utils/qmldir: -------------------------------------------------------------------------------- 1 | module org.asteroid.utils 2 | 3 | plugin asteroidutilsplugin 4 | -------------------------------------------------------------------------------- /src/utils/src/bluetoothstatus.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 - Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "bluetoothstatus.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | BluetoothStatus::BluetoothStatus(QObject *parent) : QObject(parent), mBus(QDBusConnection::systemBus()) 29 | { 30 | mPowered = false; 31 | mConnected = false; 32 | 33 | qDBusRegisterMetaType(); 34 | 35 | mWatcher = new QDBusServiceWatcher("org.bluez", QDBusConnection::systemBus()); 36 | connect(mWatcher, SIGNAL(serviceRegistered(const QString&)), this, SLOT(serviceRegistered(const QString&))); 37 | connect(mWatcher, SIGNAL(serviceUnregistered(const QString&)), this, SLOT(serviceUnregistered(const QString&))); 38 | 39 | QDBusInterface remoteOm("org.bluez", "/", "org.freedesktop.DBus.ObjectManager", mBus); 40 | if(remoteOm.isValid()) 41 | serviceRegistered("org.bluez"); 42 | else 43 | serviceUnregistered("org.bluez"); 44 | } 45 | 46 | void BluetoothStatus::serviceRegistered(const QString& name) 47 | { 48 | mBus.connect("org.bluez", "/", "org.freedesktop.DBus.ObjectManager", "InterfacesAdded", this, SLOT(InterfacesAdded(QDBusObjectPath, InterfaceList))); 49 | mBus.connect("org.bluez", "/", "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved", this, SLOT(InterfacesRemoved(QDBusObjectPath, QStringList))); 50 | 51 | updatePowered(); 52 | updateConnected(); 53 | } 54 | 55 | void BluetoothStatus::serviceUnregistered(const QString& name) 56 | { 57 | if(mPowered) { 58 | mPowered = false; 59 | emit poweredChanged(); 60 | } 61 | 62 | if(mConnected) { 63 | mConnected = false; 64 | emit connectedChanged(); 65 | } 66 | } 67 | 68 | void BluetoothStatus::updatePowered() 69 | { 70 | bool powered = false; 71 | QDBusInterface remoteOm("org.bluez", "/", "org.freedesktop.DBus.ObjectManager", mBus); 72 | 73 | QDBusMessage result = remoteOm.call("GetManagedObjects"); 74 | 75 | const QDBusArgument argument = result.arguments().at(0).value(); 76 | if (argument.currentType() == QDBusArgument::MapType) { 77 | argument.beginMap(); 78 | while (!argument.atEnd()) { 79 | QString key; 80 | InterfaceList value; 81 | 82 | argument.beginMapEntry(); 83 | argument >> key >> value; 84 | argument.endMapEntry(); 85 | 86 | if (value.contains("org.bluez.Adapter1")) { 87 | mBus.connect("org.bluez", key, "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(PropertiesChanged(QString, QMap, QStringList))); 88 | QMap properties = value.value("org.bluez.Adapter1"); 89 | if(properties.contains("Powered")) 90 | powered |= properties.value("Powered").toBool(); 91 | } 92 | } 93 | argument.endMap(); 94 | } 95 | 96 | if(powered != mPowered) { 97 | mPowered = powered; 98 | emit poweredChanged(); 99 | } 100 | } 101 | 102 | void BluetoothStatus::updateConnected() 103 | { 104 | bool connected = false; 105 | QDBusInterface remoteOm("org.bluez", "/", "org.freedesktop.DBus.ObjectManager", mBus); 106 | 107 | QDBusMessage result = remoteOm.call("GetManagedObjects"); 108 | 109 | const QDBusArgument argument = result.arguments().at(0).value(); 110 | if (argument.currentType() == QDBusArgument::MapType) { 111 | argument.beginMap(); 112 | while (!argument.atEnd()) { 113 | QString key; 114 | InterfaceList value; 115 | 116 | argument.beginMapEntry(); 117 | argument >> key >> value; 118 | argument.endMapEntry(); 119 | 120 | if (value.contains("org.bluez.Device1")) { 121 | mBus.connect("org.bluez", key, "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(PropertiesChanged(QString, QMap, QStringList))); 122 | QMap properties = value.value("org.bluez.Device1"); 123 | if(properties.contains("Connected")) 124 | connected |= properties.value("Connected").toBool(); 125 | } 126 | } 127 | argument.endMap(); 128 | } 129 | 130 | if(connected != mConnected) { 131 | mConnected = connected; 132 | emit connectedChanged(); 133 | } 134 | } 135 | 136 | void BluetoothStatus::InterfacesAdded(QDBusObjectPath, InterfaceList) 137 | { 138 | updatePowered(); 139 | updateConnected(); 140 | } 141 | 142 | void BluetoothStatus::InterfacesRemoved(QDBusObjectPath, QStringList) 143 | { 144 | updatePowered(); 145 | updateConnected(); 146 | } 147 | 148 | void BluetoothStatus::PropertiesChanged(QString, QMap, QStringList) 149 | { 150 | updatePowered(); 151 | updateConnected(); 152 | } 153 | 154 | bool BluetoothStatus::getPowered() 155 | { 156 | return mPowered; 157 | } 158 | 159 | bool BluetoothStatus::getConnected() 160 | { 161 | return mConnected; 162 | } 163 | 164 | void BluetoothStatus::setPowered(bool powered) 165 | { 166 | QDBusInterface serviceManager("org.bluez", "/org/bluez/hci0", "org.bluez.Adapter1", mBus); 167 | serviceManager.setProperty("Powered", powered); 168 | } 169 | -------------------------------------------------------------------------------- /src/utils/src/bluetoothstatus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 - Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | typedef QMap> InterfaceList; 28 | Q_DECLARE_METATYPE(InterfaceList) 29 | 30 | class BluetoothStatus : public QObject 31 | { 32 | Q_OBJECT 33 | Q_PROPERTY(bool powered READ getPowered WRITE setPowered NOTIFY poweredChanged) 34 | Q_PROPERTY(bool connected READ getConnected NOTIFY connectedChanged) 35 | 36 | public: 37 | BluetoothStatus(QObject *parent = 0); 38 | void setPowered(bool); 39 | bool getPowered(); 40 | bool getConnected(); 41 | void updatePowered(); 42 | void updateConnected(); 43 | 44 | public slots: 45 | void serviceRegistered(const QString& name); 46 | void serviceUnregistered(const QString& name); 47 | void InterfacesAdded(QDBusObjectPath, InterfaceList); 48 | void InterfacesRemoved(QDBusObjectPath, QStringList); 49 | void PropertiesChanged(QString, QMap, QStringList); 50 | 51 | signals: 52 | void connectedChanged(); 53 | void poweredChanged(); 54 | 55 | private: 56 | bool mConnected, mPowered; 57 | QDBusConnection mBus; 58 | QDBusServiceWatcher *mWatcher; 59 | }; 60 | 61 | -------------------------------------------------------------------------------- /src/utils/src/devicespecs.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 - Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "devicespecs.h" 19 | #include 20 | 21 | const char* CONFIG_FILE = "/etc/asteroid/machine.conf"; 22 | const char* HOST_FILE = "/etc/hostname"; 23 | const char* OS_RELEASE_FILE = "/etc/os-release"; 24 | 25 | DeviceSpecs::DeviceSpecs() 26 | : m_settings(CONFIG_FILE, QSettings::IniFormat) 27 | { 28 | QSettings::Status status(m_settings.status()); 29 | if (status == QSettings::FormatError ) { 30 | qWarning("Configuration file \"%s\" is in wrong format", CONFIG_FILE); 31 | } else if (status != QSettings::NoError) { 32 | qWarning("Unable to open \"%s\" configuration file", CONFIG_FILE); 33 | } 34 | 35 | QFile host(HOST_FILE); 36 | if (host.open(QIODevice::ReadOnly | QIODevice::Text)) { 37 | QTextStream in(&host); 38 | in.setCodec("UTF-8"); 39 | m_hostname = in.readLine(); 40 | host.close(); 41 | } 42 | 43 | QFile release(OS_RELEASE_FILE); 44 | if (release.open(QIODevice::ReadOnly | QIODevice::Text)) { 45 | QTextStream in(&release); 46 | in.setCodec("UTF-8"); 47 | QString line = in.readLine(); 48 | for (bool searching{true}; searching && !in.atEnd(); line = in.readLine()) { 49 | if (line.startsWith("BUILD_ID")) { 50 | auto parts = line.split(QLatin1Char('=')); 51 | m_buildid = parts[1]; 52 | m_buildid.remove(QChar('"')); 53 | searching = false; 54 | } 55 | } 56 | release.close(); 57 | } 58 | } 59 | 60 | bool DeviceSpecs::hasRoundScreen() 61 | { 62 | return m_settings.value("Display/ROUND", false).toBool(); 63 | } 64 | 65 | double DeviceSpecs::borderGestureWidth() 66 | { 67 | return m_settings.value("Display/BORDER_GESTURE_WIDTH", 0.1).toFloat(); 68 | } 69 | 70 | int DeviceSpecs::flatTireHeight() 71 | { 72 | return m_settings.value("Display/FLAT_TIRE", 0).toInt(); 73 | } 74 | 75 | bool DeviceSpecs::needsBurnInProtection() 76 | { 77 | return m_settings.value("Display/NEEDS_BURN_IN_PROTECTION", true).toBool(); 78 | } 79 | 80 | bool DeviceSpecs::hasWlan() 81 | { 82 | return m_settings.value("Capabilities/HAS_WLAN", false).toBool(); 83 | } 84 | 85 | bool DeviceSpecs::hasSpeaker() 86 | { 87 | return m_settings.value("Capabilities/HAS_SPEAKER", false).toBool(); 88 | } 89 | 90 | QString DeviceSpecs::hostname() const 91 | { 92 | return m_hostname; 93 | } 94 | 95 | QString DeviceSpecs::machineName() const 96 | { 97 | return m_settings.value("Identity/MACHINE", "unknown").toString(); 98 | } 99 | 100 | QString DeviceSpecs::buildID() const 101 | { 102 | return m_buildid; 103 | } 104 | -------------------------------------------------------------------------------- /src/utils/src/devicespecs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 - Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef DEVICESPECS_H 19 | #define DEVICESPECS_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | class DeviceSpecs : public QObject 27 | { 28 | Q_OBJECT 29 | Q_DISABLE_COPY(DeviceSpecs) 30 | Q_PROPERTY(bool hasRoundScreen READ hasRoundScreen CONSTANT) 31 | Q_PROPERTY(double borderGestureWidth READ borderGestureWidth CONSTANT) 32 | Q_PROPERTY(int flatTireHeight READ flatTireHeight CONSTANT) 33 | Q_PROPERTY(bool needsBurnInProtection READ needsBurnInProtection CONSTANT) 34 | Q_PROPERTY(bool hasWlan READ hasWlan CONSTANT) 35 | Q_PROPERTY(bool hasSpeaker READ hasSpeaker CONSTANT) 36 | Q_PROPERTY(QString hostname READ hostname CONSTANT) 37 | Q_PROPERTY(QString machineName READ machineName CONSTANT) 38 | Q_PROPERTY(QString buildID READ buildID CONSTANT) 39 | DeviceSpecs(); 40 | public: 41 | static QObject *qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine) 42 | { 43 | Q_UNUSED(engine); 44 | Q_UNUSED(scriptEngine); 45 | 46 | return new DeviceSpecs; 47 | } 48 | bool hasRoundScreen(); 49 | double borderGestureWidth(); 50 | int flatTireHeight(); 51 | bool needsBurnInProtection(); 52 | bool hasWlan(); 53 | bool hasSpeaker(); 54 | QString hostname() const; 55 | QString machineName() const; 56 | QString buildID() const; 57 | private: 58 | QSettings m_settings; 59 | QString m_hostname; 60 | QString m_buildid; 61 | }; 62 | 63 | #endif // DEVICESPECS_H 64 | -------------------------------------------------------------------------------- /src/utils/src/fileinfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - Darrel Griët 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "fileinfo.h" 19 | #include 20 | #include 21 | 22 | bool FileInfo::exists(const QString fileName) 23 | { 24 | QString file = QString(fileName); 25 | file.replace(QRegularExpression("^file:\\/\\/"), ""); 26 | file.replace(QRegularExpression("^qrc:\\/"), ":/"); 27 | return QFile::exists(file); 28 | } 29 | -------------------------------------------------------------------------------- /src/utils/src/fileinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 - Darrel Griët 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef FILEINFO_H 19 | #define FILEINFO_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | class FileInfo : public QObject 26 | { 27 | Q_OBJECT 28 | Q_DISABLE_COPY(FileInfo) 29 | FileInfo() {} 30 | public: 31 | static QObject *qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine) 32 | { 33 | Q_UNUSED(engine); 34 | Q_UNUSED(scriptEngine); 35 | 36 | return new FileInfo; 37 | } 38 | Q_INVOKABLE bool exists(const QString fileName); 39 | }; 40 | 41 | #endif // FILEINFO_H 42 | -------------------------------------------------------------------------------- /src/utils/src/utils_plugin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 - Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "utils_plugin.h" 19 | #include 20 | #include "bluetoothstatus.h" 21 | #include "devicespecs.h" 22 | #include "fileinfo.h" 23 | 24 | UtilsPlugin::UtilsPlugin(QObject *parent) : QQmlExtensionPlugin(parent) 25 | { 26 | } 27 | 28 | void UtilsPlugin::registerTypes(const char *uri) 29 | { 30 | Q_ASSERT(uri == QLatin1String("org.asteroid.utils")); 31 | 32 | qmlRegisterSingletonType(uri, 1,0, "DeviceSpecs", &DeviceSpecs::qmlInstance); 33 | qmlRegisterSingletonType(uri, 1, 0, "FileInfo", &FileInfo::qmlInstance); 34 | qmlRegisterType(uri, 1, 0, "BluetoothStatus"); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/utils/src/utils_plugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 - Florent Revest 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as 6 | * published by the Free Software Foundation, either version 2.1 of the 7 | * License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef UTILSPLUGIN_H 19 | #define UTILSPLUGIN_H 20 | 21 | #include 22 | 23 | class UtilsPlugin : public QQmlExtensionPlugin 24 | { 25 | Q_OBJECT 26 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") 27 | 28 | public: 29 | explicit UtilsPlugin(QObject *parent = 0); 30 | void registerTypes(const char *uri); 31 | }; 32 | 33 | #endif // UTILSPLUGIN_H 34 | 35 | --------------------------------------------------------------------------------