├── .gitignore ├── Browthon_app.py ├── LICENSE ├── README.md └── files ├── Browthon_addons.py ├── Browthon_download.py ├── Browthon_elements.py ├── Browthon_main.py ├── Browthon_utils.py ├── Browthon_windows.py ├── addons ├── Test │ ├── info.json │ ├── logo.png │ └── test.py └── Youtubedl │ ├── info.json │ ├── logo.png │ └── youtubedl.py ├── logo.png ├── pyqt_logo.png ├── qt_logo.png └── style ├── Blue.bss ├── Dark.bss └── Red.bss /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.zip 3 | *.deb 4 | Autres/launch.sh 5 | Autres/Présentation 6 | Autres/pyweb.html 7 | Autres/release_modèle.txt 8 | .vscode 9 | *.pyc 10 | *.txt 11 | launch.sh 12 | 13 | *.log 14 | 15 | *.nja 16 | 17 | files/logs/ 18 | -------------------------------------------------------------------------------- /Browthon_app.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | # coding: utf-8 3 | 4 | import sys 5 | import os 6 | 7 | from PyQt5.QtWebEngineWidgets import * 8 | from PyQt5.QtGui import * 9 | from PyQt5.QtCore import * 10 | from PyQt5.QtWidgets import * 11 | from PyQt5.Qt import * 12 | 13 | from files.Browthon_main import * 14 | 15 | 16 | def launch(sys): 17 | if not os.path.isdir('logs'): 18 | os.mkdir("logs") 19 | try: 20 | with open('logs/browthon.log'): 21 | pass 22 | except IOError: 23 | with open('logs/browthon.log', 'w') as fichier: 24 | fichier.write("--- Fichier de log : Browthon ---\n") 25 | app = QApplication(sys.argv) 26 | icon = QIcon('logo.png') 27 | app.setWindowIcon(icon) 28 | url = "" 29 | try: 30 | with open('config.txt', 'r') as fichier: 31 | url = fichier.read().split("\n")[1].split(" ")[1] 32 | except IOError: 33 | with open('config.txt', 'w') as fichier: 34 | fichier.write("UrlMoteur https://www.google.fr/?gws_rd=ssl#q=\nUrlAccueil http://pastagames.fr.nf/browthon/\nJavaScript True\nNavigationPrivée False\nDéplacementOnglet True\nStyle Default\nSession False\nNiveauLog INFO\nLancer False") 35 | url = "http://pastagames.fr.nf/browthon/" 36 | 37 | urltemp = url 38 | if len(sys.argv) >= 2: 39 | if "." in sys.argv[1]: 40 | if "http://" in sys.argv[1] or "https://" in sys.argv[1]: 41 | urltemp = sys.argv[1] 42 | else: 43 | urltemp = "http://" + sys.argv[1] 44 | MainWindow(url, urltemp) 45 | 46 | app.exec_() 47 | 48 | 49 | if __name__ == '__main__': 50 | os.chdir("files") 51 | launch(sys) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Browthon-Python 2 | First version of Browthon made with Python and PyQt5 3 | 4 | ## Dépendances : 5 | - Python 3.5+ 6 | - PyQt5 (pip install pyqt5) 7 | - Requests (pip install requests) 8 | 9 | ## Autres informations : 10 | - Développeur principal : LavaPower 11 | - Contributeur : x 12 | - Développé sous : 13 | - Système : 14 | - Linux Manjaro / Windows 7 (V 2.2.0 --> Latest) 15 | - Windows 10 (V 2.1.0 --> V 2.2.0) 16 | - Linux Ubuntu 17.10 (V 0.5.0 --> V 2.1.0) 17 | - Linux Debian 9 (V 0.2.0 --> V 0.5.0) 18 | - Windows 7 (V 0.1.0 --> V 0.2.0) 19 | - Version Python : 20 | - 3.6.5 (V 2.2.0 --> Latest) 21 | - 3.6.4 (V 2.1.0 --> V 2.2.0) 22 | - 3.6.3 (V 0.5.0 --> V 2.1.0) 23 | - 3.5.3 (V 0.2.0 --> V 0.5.0) 24 | - 3.6.1 (V 0.1.0 --> V 0.2.0) 25 | - Libs : 26 | - PyQt5 (V 2.0.0 --> Latest) 27 | - Requests (V 0.6.0 --> Latest) 28 | - PySide (V 0.2.0 --> V 2.0.0) 29 | - PyQt4 (V 0.1.0 --> V 0.2.0) 30 | 31 | ## Remerciements : 32 | - Feldrise : https://github.com/Feldrise - Pour l'aide dans le développement 33 | - LechatGris : https://github.com/LechatGris - Pour l'idée du logo 34 | 35 | ## Bugs connus de la version en développement : 36 | - / 37 | 38 | ## Changelog : 39 | 40 | ### V 2.6.0 : Addon Update - 14 Juil 2018 : 41 | - Ajout d'addons créé en Python 42 | - Ajout d'une galerie d'addons sur le site 43 | - Ajout d'une page de remerciement au premiier lancement 44 | - Nouvelle version du Launcher 45 | - Nombreux bug fixes 46 | 47 | ### V 2.5.0 : Basic Update - 3 Juil 2018 : 48 | - Système de téléchargements avec menu 49 | - Nouveau menu pour l'historique et les favoris (avec raccourci H et F) 50 | - Nouveau système de logs 51 | - Système de fenêtre pour tous les anciens menus 52 | - Création de fenêtre pour les informations sur Browthon, PyQt et Qt 53 | 54 | ### V 2.4.0 : Browthon Update - 16 Juin 2018 : 55 | - Changement du nom (de PyWeb à Browthon) 56 | - Réécriture du launcher 57 | - Ajout du système de session (nom, enregistrement, lancement...) 58 | - Ajout du système de raccourci URL 59 | - Ajout d'un menu de clique droit complètement personnalisé 60 | - Enregistrement de la session avant de quitter (+ paramètre pour la charger automatiquement au lancement) 61 | - Mise à jour du thème Dark 62 | - Ajout des thèmes Red et Blue 63 | - Ajout du clic molette pour ouvrir un lien dans un nouvel onglet 64 | - Suppression du système de langues 65 | - Plusieurs bugs fixes et optimisation 66 | 67 | ### V 2.3.0 : Appearance Update - 30 Mai 2018 : 68 | - Création d'un package pour ArchLinux (et Manjaro) 69 | - Création d'un launcher pour télécharger les nouvelles versions automatiquement 70 | - Création de thèmes (juste le sombre pour l'instant) 71 | - Gestion basique des thèmes 72 | - Changement de traduction (modification et nouveaux ajouts) 73 | - Nouvelle apparence de PyWeb avec moins de boutons 74 | - Modification du logo de PyWeb 75 | - Bug Fix : L'icone de l'onglet ne changeait que si c'était le premier onglet 76 | - Bug Fix : Le texte de la fênetre de fermeture de PyWeb n'avaient pas de retour à la ligne 77 | 78 | ### V 2.2.1 : Fail Update - 23 Mai 2018 : 79 | - Update des versions dans le code et l'updater 80 | 81 | ### V 2.2.0 : Rebirth Update - 23 Mai 2018 : 82 | - Possibilité de voir le code source de la page actuel via F2 puis de repasser en mode "normal" toujours avec F2 83 | - Modification de l'icone du logiciel (merci LechatGris) 84 | - Ajout de l'icone du site dans les onglets 85 | - Bug Fix : Changement du site PyWeb 86 | - Bug Fix : Sur Linux, les fichiers de langues n'était pas en UTF8 valide. 87 | - Bug Fix : Le texte des fenêtres "Nouvelle MAJ" et "Informations" n'avaient pas de retour à la ligne 88 | 89 | ### V 2.1.0 : Language Update - 19 Jav 2018 : 90 | - Système de langue pour PyWeb (Francais et Anglais dispo par défaut) 91 | - Suppression de print() de debug qui avait été laissé par erreur 92 | - Paramètre : Url d'accueil modifiable depuis PyWeb 93 | - Paramètre : Langue utilisé par PyWeb 94 | - Bug Fix : Le choix d'un moteur réinitialise les autres paramètres. 95 | - Bug Fix : Le choix d'une url d'accueil réinitialise les autres paramètres. 96 | - Bug Fix : Quand on sélectionne un moteur, PyWeb ne fonctionne plus 97 | 98 | ### V 2.0.1 : Bug Fix Update - 5 Jan 2018 : 99 | - Enregistrement des paramètres 100 | - Fichier config plus user-friendly 101 | - Bug Fix : Les boutons reculer, reload et avancer n'avaient d'effet que sur le première page 102 | - Bug Fix : La recherche via la barre d'url retournait toujours une page blanche 103 | - Bug Fix : La touche 'Echap' ne fonctionnait qu'une fois pour quitter le mode plein écran 104 | - Bug Fix : Les favoris et l'historique n'avait pas d'interactions 105 | 106 | ### V 2.0.0 : PyQt5 Update - 4 Jan 2018 : 107 | - Reprogrammation en utilisant PyQt5 108 | - Le FullScreen est maintenant disponible ! (Merci à Feldrise) 109 | 110 | ### V 1.1.0 : Tab Update V3 - 2 Jan 2018 : 111 | - Reprogrammation du système d'onglet 112 | - Réorganisation de la fenêtre principale 113 | - Ajout d'un bouton home correspondant à la page d'accueil 114 | - Ajout de '[Privé]' dans le titre de la fenêtre quand on est en navigation privé 115 | - Paramètre : Déplacement à l'ouverture d'un onglet 116 | 117 | ### V 1.0.0 : First Update - 30 Dec 2017 : 118 | - Respect de la PEP8 (sauf de la limite de caractères par ligne) 119 | - Paramètre : Navigation privée 120 | - Raccourci : Q --> Fermeture de l'onglet actuel 121 | - Raccourci : P --> Ouverture du menu des paramètres 122 | - Raccourci : R --> Reload la page 123 | - Raccourci : H --> Ouverture du menu de l'historique 124 | - Raccourci : F --> Ouverture du menu des favoris 125 | - Raccourci : N --> Création d'un nouvel onglet 126 | 127 | ### V 0.6.0 : Favorite Update - 28 Dec 2017 : 128 | - Vérification de mise à jour 129 | - Recherche sur le moteur choisi des mots écrits dans l'url si il n'y a pas de point. 130 | - Début des Favoris (Ajout et suppression mais pas d'interaction) 131 | - Amélioration Favori et Historique avec des messages pour chaque action (ex : Suppression de l'historique) 132 | - Paramètre : Moteur de recherche préféré 133 | - Paramètre : JavaScript Activé/Désactivé 134 | - Raccourci : F10 --> Ouverture du menu des paramètres 135 | - Bug Fix : L'historique ne se supprimait pas 136 | 137 | ### V 0.5.0 : History Update - 20 Dec 2017 : 138 | - Création d'une page perso à PyWeb (https://lavapower.github.io/pyweb.html) 139 | - Page perso comme page d'accueil par défaut. 140 | - Confirmation avant extinction lors de la fermeture du dernier onglet. 141 | - Début de l'historique (Affichage + Suppression mais pas d'interaction) 142 | - Séparation de MainWindow dans le fichier "PyWeb_main" 143 | - Déplacement des fichiers .py utilisé par "PyWeb.py" dans files 144 | - Début des raccourcis claviers (F5 --> Reload la page) 145 | - Bug Fix : Toutes les lettres identiques à la première sont en majuscules. 146 | 147 | ### V 0.4.0 : Tab Update V2 - 10 Dec 2017 : 148 | - Changement du nom de l'onglet suivant le titre de la page (limité à 12 caractères) 149 | - Création d'option pour l'url d'accueil (modifiable que via le config.txt) 150 | - Fermeture du logiciel lors de la fermeture du dernier onglet 151 | - Nom du button de l'onglet ouvert set sans avoir besoin de cliquer dessus 152 | 153 | ### V 0.3.0 : Tab Update - 8 Dec 2017 : 154 | - Changement du titre de la fenêtre suivant le titre de la page avec écrit "- PyWeb" à la fin 155 | - Gestion d'url sans "http://" ni "https://" 156 | - Début de la gestion d'onglet (Limité à 10, fermer les onglets via le menu "⁞") 157 | - Division du code avec un fichier "PyWeb-utils.py" 158 | 159 | ### V 0.2.1 : Fix Reload Update - 4 Dec 2017 : 160 | - Ajout d'information dans le README 161 | - Le Bouton Reload fonctionne 162 | 163 | ### V 0.2.0 : PySide Update - 3 Dec 2017 : 164 | - Passage à PySide 165 | - Liaison du bouton "Entrer" à la barre URL 166 | - Les vidéos YouTube fonctionnent 167 | 168 | ### V 0.1.0 : URL Update - 28 Nov 2017 : 169 | - Ajout d'une barre d'url (qui se met à jour automatiquement) 170 | - Ajout d'un bouton pour entrer l'url 171 | - Ajout d'un bouton pour revenir en arrière 172 | - Ajout d'un bouton pour aller en avant 173 | - Ajout d'un bouton reload pour reload la page 174 | 175 | ### V 0.0.1 : Initial Update - 27 Nov 2017 : 176 | - Première version 177 | -------------------------------------------------------------------------------- /files/Browthon_addons.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | # coding: utf-8 3 | 4 | from PyQt5.QtWebEngineWidgets import * 5 | from PyQt5.QtGui import * 6 | from PyQt5.QtCore import * 7 | from PyQt5.QtWidgets import * 8 | from PyQt5.Qt import * 9 | 10 | import os, glob, json 11 | 12 | 13 | class AddonsManagerWidget(QWidget): 14 | def __init__(self, main): 15 | super(AddonsManagerWidget, self).__init__() 16 | self.setMinimumSize(700, 500) 17 | self.main = main 18 | self.addonsManager = AddonsManager(self.main) 19 | self.addonsManager.loadAddons() 20 | self.widgets = [] 21 | self.setupui() 22 | for i in self.addonsManager.imported: 23 | self.addonW = AddonWidget(self.main, self, "/".join(i.replace(".", "/").split("/")[1:-1])) 24 | self.widgets.append(self.addonW) 25 | self.layout.addWidget(self.addonW) 26 | self.layout.setAlignment(self.addonW, Qt.AlignTop) 27 | self.label.hide() 28 | 29 | def setupui(self): 30 | self.layoutMain = QVBoxLayout(self) 31 | self.scroll = QScrollArea(self) 32 | self.scroll.setWidgetResizable(True) 33 | self.title = QLabel("Addons") 34 | self.title.setFont(self.main.fonts["titre"]) 35 | self.title.setAlignment(Qt.AlignHCenter) 36 | self.layoutMain.addWidget(self.title) 37 | self.layoutMain.addWidget(self.scroll) 38 | 39 | self.container = QWidget() 40 | self.scroll.setWidget(self.container) 41 | self.layout = QVBoxLayout(self.container) 42 | self.label = QLabel("Pas de addons") 43 | self.label.setAlignment(Qt.AlignHCenter) 44 | self.layout.addWidget(self.label) 45 | if self.main.mainWindow.styleSheetParam != "Default": 46 | with open('style/' + self.main.mainWindow.styleSheetParam + ".bss", 'r') as fichier: 47 | bss = parseTheme(fichier.read()) 48 | self.setStyleSheet(bss) 49 | 50 | def launchAddons(self, function, args = None): 51 | self.addonsManager.launchAddons(self.widgets, function, args) 52 | 53 | 54 | class AddonWidget(QWidget): 55 | def __init__(self, main, manager, dossier): 56 | super(AddonWidget, self).__init__() 57 | self.main = main 58 | self.manager = manager 59 | self.datas = {} 60 | self.dossier = dossier 61 | try: 62 | with open(dossier+"/info.json", 'r') as f: 63 | self.datas = json.load(f) 64 | except: 65 | self.main.mainWindow.logger.warning("Le fichier info.json ("+dossier+"/info.json"+") n'a pas été trouvé") 66 | self.datas["Activation"] = "False" 67 | else: 68 | self.setupui() 69 | 70 | def setupui(self): 71 | self.grid = QGridLayout() 72 | 73 | self.logo = QPixmap(self.dossier + "/" + self.datas["Logo"]) 74 | self.imageLabel = QLabel() 75 | self.imageLabel.setPixmap(self.logo) 76 | self.title = QLabel(self.datas["Name"]) 77 | self.title.setFont(self.main.fonts["titre"]) 78 | self.author = QLabel("By : "+self.datas["Author"]) 79 | self.description = QLabel(self.datas["Description"]) 80 | self.description.setFont(self.main.fonts["description"]) 81 | self.bUrl = QPushButton("Site") 82 | self.bUrl.clicked.connect(self.openUrl) 83 | if self.datas["Activation"] == "True": 84 | self.bAct = QPushButton("Désactiver") 85 | self.bAct.clicked.connect(self.desactivate) 86 | else: 87 | self.bAct = QPushButton("Activer") 88 | self.bAct.clicked.connect(self.activate) 89 | 90 | self.grid.addWidget(self.imageLabel, 1, 1, 3, 1) 91 | self.grid.addWidget(self.title, 1, 2, 1, 1) 92 | self.grid.addWidget(self.author, 1, 3, 1, 1) 93 | self.grid.addWidget(self.description, 2, 2, 1, 2) 94 | self.grid.addWidget(self.bUrl, 3, 2, 1, 1) 95 | self.grid.addWidget(self.bAct, 3, 3, 1, 1) 96 | 97 | self.setLayout(self.grid) 98 | 99 | def openUrl(self): 100 | self.main.addOngletWithUrl(self.datas["Url"]) 101 | 102 | def desactivate(self): 103 | self.datas["Activation"] = "False" 104 | with open(self.dossier+"/info.json", 'w') as f: 105 | f.write(json.dumps(self.datas, indent=4)) 106 | QMessageBox.warning(self, "Addon désactivé", "L'addon "+self.datas["NameCode"]+ " a été désactivé") 107 | self.bAct.setText("Activer") 108 | self.bAct.clicked.disconnect() 109 | self.bAct.clicked.connect(self.activate) 110 | self.manager.addonsManager.LML[self.datas["NameCode"]].unload(self.manager.addonsManager.LML[self.datas["NameCode"]], self.main) 111 | 112 | def activate(self): 113 | self.datas["Activation"] = "True" 114 | with open(self.dossier+"/info.json", 'w') as f: 115 | f.write(json.dumps(self.datas, indent=4)) 116 | QMessageBox.warning(self, "Addon activé", "L'addon "+self.datas["NameCode"]+ " a été activé") 117 | self.bAct.setText("Désactiver") 118 | self.bAct.clicked.disconnect() 119 | self.bAct.clicked.connect(self.desactivate) 120 | self.manager.addonsManager.LML[self.datas["NameCode"]].load(self.manager.addonsManager.LML[self.datas["NameCode"]], self.main) 121 | 122 | 123 | class AddonsManager(): 124 | def __init__(self, main): 125 | self.main = main 126 | self.LML = {} 127 | self.imported = [] 128 | 129 | def include_all_modules(self): 130 | if os.path.exists("addons/"): 131 | filess = glob.glob("addons/*/*.py") 132 | else: 133 | filess = [] 134 | self.main.mainWindow.logger.info("Aucun addon trouvé") 135 | ext_libs = ["files.addons.{}.{}".format(f.split("/")[1], os.path.basename(f).split('.')[0]) for f in filess] 136 | self.imported = [] 137 | for module in ext_libs: 138 | try: 139 | exec("import {}".format(module)) 140 | self.imported.append(module) 141 | exec("self.LML[{}.name] = {}.instance".format(module, module)) 142 | 143 | except ImportError: 144 | pass 145 | return ext_libs, self.imported 146 | 147 | def loadAddons(self): 148 | self.libs, self.imported = self.include_all_modules() 149 | self.unimported = set(self.imported) ^ set(self.libs) 150 | if self.unimported: 151 | self.main.mainWindow.logger.error("Des modules ont été mal importés : {}".format(", ".join(list(self.unimported)))) 152 | if self.imported: 153 | self.main.mainWindow.logger.info("Des modules ont été importés : {}".format(", ".join(list(self.imported)))) 154 | 155 | def launchAddons(self, widgets, function, args): 156 | for i in self.LML: 157 | for j in widgets: 158 | if j.datas["NameCode"] == i and j.datas["Activation"] == "True": 159 | try: 160 | if function == "load": 161 | self.LML[i].load(self.LML[i], self.main) 162 | elif function == "unload": 163 | self.LML[i].unload(self.LML[i], self.main) 164 | elif function == "keyPress": 165 | self.LML[i].keyPress(self.LML[i], self.main, args) 166 | elif function == "enterUrl": 167 | self.LML[i].enterUrl(self.LML[i], self.main, args) 168 | elif function == "openOnglet": 169 | self.LML[i].openOnglet(self.LML[i], self.main, args) 170 | except: 171 | pass 172 | break 173 | -------------------------------------------------------------------------------- /files/Browthon_download.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | # coding: utf-8 3 | 4 | from PyQt5.QtWebEngineWidgets import * 5 | from PyQt5.QtGui import * 6 | from PyQt5.QtCore import * 7 | from PyQt5.QtWidgets import * 8 | from PyQt5.Qt import * 9 | 10 | from files.Browthon_utils import parseTheme, dezip 11 | 12 | import os, shutil 13 | 14 | 15 | class DownloadSignal(QObject): 16 | removeClicked = pyqtSignal() 17 | 18 | def __init__(self, parent): 19 | super(DownloadSignal, self).__init__() 20 | self.parent = parent 21 | 22 | 23 | class DownloadWidget(QWidget): 24 | def __init__(self, download, url, main): 25 | super(DownloadWidget, self).__init__() 26 | self.setupui() 27 | self.download = download 28 | self.url = url 29 | self.main = main 30 | self.downloadSignal = DownloadSignal(self) 31 | self.title.setText(QFileInfo(self.download.path()).fileName()) 32 | 33 | self.cancel.clicked.connect(self.cancelDownload) 34 | self.download.downloadProgress.connect(self.updateWidget) 35 | self.download.stateChanged.connect(self.updateWidget) 36 | 37 | self.updateWidget() 38 | 39 | def updateWidget(self): 40 | totalBytes = self.download.totalBytes() 41 | receivedBytes = self.download.receivedBytes() 42 | 43 | state = self.download.state() 44 | if state == QWebEngineDownloadItem.DownloadRequested: 45 | pass 46 | elif state == QWebEngineDownloadItem.DownloadInProgress: 47 | if totalBytes > 0: 48 | self.progressBar.setValue(int(100 * receivedBytes / totalBytes)) 49 | self.progressBar.setDisabled(False) 50 | self.progressBar.setFormat("%p% - {} téléchargés sur {}".format(self.withUnit(receivedBytes), self.withUnit(totalBytes))) 51 | else: 52 | self.progressBar.setValue(0) 53 | self.progressBar.setDisabled(False) 54 | self.progressBar.setFormat("Taille inconnue - {} téléchargés".format(self.withUnit(receivedBytes))) 55 | elif state == QWebEngineDownloadItem.DownloadCompleted: 56 | self.progressBar.setValue(100) 57 | self.progressBar.setDisabled(True) 58 | self.progressBar.setFormat("Complété - {} téléchargés".format(self.withUnit(receivedBytes))) 59 | if self.url == "http://pastagames.fr.nf/browthon/addons.php": 60 | rep = QMessageBox().question(self, "Addon "+QFileInfo(self.download.path()).fileName()+" téléchargé", 'Voulez-vous installer cet addon ?', QMessageBox.Yes, QMessageBox.No) 61 | if rep == 16384: 62 | print(self.download.path()) 63 | error = None 64 | try: 65 | shutil.copy(self.download.path(), "addons") 66 | os.remove(self.download.path()) 67 | except: 68 | error = "Déplacement impossible" 69 | else: 70 | try: 71 | dezip("addons/"+self.download.path().split('/')[-1], "addons") 72 | os.remove("addons/"+self.download.path().split('/')[-1]) 73 | except: 74 | error = "Dézippage impossible" 75 | if error != None: 76 | QMessageBox().warning(self, "Addon "+QFileInfo(self.download.path()).fileName(), "Installation impossible.\nErreur : "+error) 77 | self.main.mainWindow.logger.warning("Installation de l'addon "+QFileInfo(self.download.path()).fileName()+" impossible.\nErreur : "+error) 78 | else: 79 | QMessageBox().information(self, "Addon "+QFileInfo(self.download.path()).fileName(), "Installation réussie !") 80 | self.main.mainWindow.logger.info("Installation de l'addon "+QFileInfo(self.download.path()).fileName()+" réussie !") 81 | elif state == QWebEngineDownloadItem.DownloadCancelled: 82 | self.progressBar.setValue(0) 83 | self.progressBar.setDisabled(True) 84 | self.progressBar.setFormat("Annulé - {} téléchargés".format(self.withUnit(receivedBytes))) 85 | elif state == QWebEngineDownloadItem.DownloadInterrupted: 86 | self.progressBar.setValue(0) 87 | self.progressBar.setDisabled(True) 88 | self.progressBar.setFormat("Interrompu - {}".format(self.download.interruptReasonString())) 89 | 90 | if state == QWebEngineDownloadItem.DownloadInProgress: 91 | self.cancel.setText("Arrêter") 92 | self.cancel.setToolTip("Stopper le téléchargement") 93 | else: 94 | self.cancel.setText("Supprimer") 95 | self.cancel.setToolTip("Enlever le téléchargement") 96 | 97 | def cancelDownload(self): 98 | if self.download.state() == QWebEngineDownloadItem.DownloadInProgress: 99 | self.download.cancel() 100 | else: 101 | self.downloadSignal.removeClicked.emit() 102 | 103 | def withUnit(self, bytesNb): 104 | if bytesNb < 1 << 10: 105 | return str(round(bytesNb, 2)) + " B" 106 | elif bytesNb < 1 << 20: 107 | return str(round(bytesNb / (1 << 10), 2)) + " KiB" 108 | elif bytesNb < 1 << 30: 109 | return str(round(bytesNb / (1 << 20), 2)) + " MiB" 110 | else: 111 | return str(round(bytesNb / (1 << 30), 2)) + " GiB" 112 | 113 | def setupui(self): 114 | self.layout = QGridLayout() 115 | self.title = QLabel("NAME") 116 | self.cancel = QPushButton("Cancel") 117 | self.progressBar = QProgressBar() 118 | self.layout.addWidget(self.title, 1, 1) 119 | self.layout.addWidget(self.progressBar, 2, 1) 120 | self.layout.addWidget(self.cancel, 3, 1) 121 | self.setLayout(self.layout) 122 | 123 | 124 | class DownloadManagerWidget(QWidget): 125 | def __init__(self, main): 126 | super(DownloadManagerWidget, self).__init__() 127 | self.setMinimumSize(500, 300) 128 | self.main = main 129 | self.nbDownload = 0 130 | self.setupui() 131 | 132 | def downloadRequested(self, download): 133 | if download: 134 | if download.state() == QWebEngineDownloadItem.DownloadRequested: 135 | path = QFileDialog.getSaveFileName(self, "Sauver comme", 136 | download.path()) 137 | if path == "": 138 | return 139 | else: 140 | download.setPath(path[0]) 141 | download.accept() 142 | self.add(DownloadWidget(download, self.main.browser.url().toString(), self.main)) 143 | 144 | self.show() 145 | else: 146 | self.main.mainWindow.logger.critical("Le téléchargement n'a pas été demandé.") 147 | else: 148 | self.main.mainWindow.logger.critical("Le téléchargement est nul.") 149 | 150 | def add(self, downloadWidget): 151 | downloadWidget.downloadSignal.removeClicked.connect(self.remove) 152 | self.layout.addWidget(downloadWidget) 153 | self.layout.setAlignment(downloadWidget, Qt.AlignTop) 154 | self.nbDownload += 1 155 | if self.nbDownload >= 0: 156 | self.label.hide() 157 | 158 | def remove(self): 159 | downloadWidget = self.sender().parent 160 | self.layout.removeWidget(downloadWidget) 161 | downloadWidget.deleteLater() 162 | self.nbDownload -= 1 163 | if self.nbDownload <= 0: 164 | self.label.show() 165 | 166 | def setupui(self): 167 | self.layoutMain = QVBoxLayout(self) 168 | self.scroll = QScrollArea(self) 169 | self.scroll.setWidgetResizable(True) 170 | self.title = QLabel("Téléchargements") 171 | self.title.setFont(self.main.fonts["titre"]) 172 | self.title.setAlignment(Qt.AlignHCenter) 173 | self.layoutMain.addWidget(self.title) 174 | self.layoutMain.addWidget(self.scroll) 175 | 176 | self.container = QWidget() 177 | self.scroll.setWidget(self.container) 178 | self.layout = QVBoxLayout(self.container) 179 | self.label = QLabel("Pas de téléchargement") 180 | self.label.setAlignment(Qt.AlignHCenter) 181 | self.layout.addWidget(self.label) 182 | if self.main.mainWindow.styleSheetParam != "Default": 183 | with open('style/' + self.main.mainWindow.styleSheetParam + ".bss", 'r') as fichier: 184 | bss = parseTheme(fichier.read()) 185 | self.setStyleSheet(bss) -------------------------------------------------------------------------------- /files/Browthon_elements.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | # coding: utf-8 3 | 4 | from PyQt5.QtWebEngineWidgets import * 5 | from PyQt5.QtGui import * 6 | from PyQt5.QtCore import * 7 | from PyQt5.QtWidgets import * 8 | from PyQt5.Qt import * 9 | 10 | from files.Browthon_utils import * 11 | 12 | 13 | class UrlInput(QLineEdit): 14 | def __init__(self, main): 15 | super(UrlInput, self).__init__(main.url) 16 | self.main = main 17 | 18 | def enterUrl(self): 19 | urlT = self.text() 20 | for i in self.main.raccourciArray: 21 | if urlT == i.title: 22 | urlT = i.url 23 | if "http://" not in urlT and "https://" not in urlT: 24 | if "." in urlT: 25 | urlT = "http://" + urlT 26 | else: 27 | moteur = "" 28 | try: 29 | with open('config.txt', 'r') as fichier: 30 | moteur = fichier.read().split("\n")[0].split(" ")[1] 31 | except IOError: 32 | moteur = "https://www.google.fr/?gws_rd=ssl#q=" 33 | urlT = moteur + urlT 34 | self.url = QUrl(urlT) 35 | self.main.addonsManager.launchAddons("enterUrl", urlT) 36 | self.main.browser.load(self.url) 37 | 38 | def enterUrlGiven(self, url): 39 | urlT = url 40 | if "http://" not in urlT and "https://" not in urlT: 41 | urlT = "http://" + urlT 42 | self.url = QUrl(urlT) 43 | self.main.addonsManager.launchAddons("enterUrl", urlT) 44 | self.main.browser.load(self.url) 45 | 46 | def setUrl(self): 47 | self.setText(self.main.browser.url().toString()) 48 | 49 | 50 | class TabOnglet(QTabWidget): 51 | def __init__(self, main): 52 | super(TabOnglet, self).__init__() 53 | self.setTabPosition(QTabWidget.North) 54 | self.setMovable(True) 55 | self.addTab(main.onglet1, QIcon('logo.png'), "Browthon") 56 | self.main = main 57 | self.main.browser.show() 58 | 59 | def changeOnglet(self): 60 | self.main.browser = self.currentWidget() 61 | self.main.urlInput.setUrl() 62 | self.main.setTitle() 63 | self.main.addHistory() 64 | self.main.forward.disconnect() 65 | self.main.back.disconnect() 66 | self.main.reload.disconnect() 67 | self.main.back.clicked.connect(self.main.browser.back) 68 | self.main.forward.clicked.connect(self.main.browser.forward) 69 | self.main.reload.clicked.connect(self.main.browser.reload) 70 | 71 | 72 | class Onglet(QWebEngineView): 73 | def __init__(self, nb, main): 74 | super(Onglet, self).__init__() 75 | self.nb = nb 76 | self.main = main 77 | self.page = Page(self) 78 | self.setPage(self.page) 79 | if self.main.launched: 80 | self.load(QUrl(main.urltemp)) 81 | else: 82 | self.load(QUrl("http://pastagames.fr.nf/browthon/merci.html")) 83 | self.main.urltemp = self.main.url 84 | self.urlChanged.connect(main.urlInput.setUrl) 85 | self.titleChanged.connect(main.setTitle) 86 | self.iconChanged.connect(main.changeIcon) 87 | self.loadFinished.connect(main.addHistory) 88 | self.page.fullScreenRequested.connect(self.page.makeFullScreen) 89 | self.viewSource = QAction(self) 90 | self.viewSource.setShortcut(Qt.Key_F2) 91 | self.viewSource.triggered.connect(self.page.vSource) 92 | self.addAction(self.viewSource) 93 | 94 | def event(self, event): 95 | if event.type() == QEvent.ChildAdded: 96 | child_ev = event 97 | widget = child_ev.child() 98 | 99 | if widget: 100 | widget.installEventFilter(self) 101 | return True 102 | 103 | return super(Onglet, self).event(event) 104 | 105 | def contextMenuEvent(self, event): 106 | hit = self.page.hitTestContent(event.pos()) 107 | menu = ContextMenu(self, hit) 108 | if self.main.mainWindow.styleSheetParam != "Default": 109 | with open('style/' + self.main.mainWindow.styleSheetParam + ".bss", 'r') as fichier: 110 | bss = parseTheme(fichier.read()) 111 | bss = fichier.read() 112 | else: 113 | bss = "" 114 | menu.setStyleSheet(bss) 115 | pos = event.globalPos() 116 | p = QPoint(pos.x(), pos.y() + 1) 117 | menu.exec_(p) 118 | 119 | def eventFilter(self, obj, event): 120 | if event.type() == QEvent.MouseButtonRelease: 121 | if event.button() == Qt.MiddleButton: 122 | hit = self.page.hitTestContent(event.pos()) 123 | clickedUrl = hit.linkUrl() 124 | baseUrl = hit.baseUrl() 125 | if clickedUrl != baseUrl and clickedUrl != '': 126 | if 'http://' in clickedUrl or 'https://' in clickedUrl: 127 | result = clickedUrl 128 | elif clickedUrl == "#": 129 | result = baseUrl + clickedUrl 130 | else: 131 | result = "http://" + baseUrl.split("/")[2] + clickedUrl 132 | self.main.addOngletWithUrl(result) 133 | event.accept() 134 | return True 135 | return super(Onglet, self).eventFilter(obj, event) 136 | 137 | 138 | class Page(QWebEnginePage): 139 | def __init__(self, view): 140 | super(Page, self).__init__() 141 | self.main = view.main 142 | self.view = view 143 | self.loop = None 144 | 145 | def javaScriptConsoleMessage(self, level, msg, line, sourceID): 146 | """Override javaScriptConsoleMessage to use debug log.""" 147 | if level == QWebEnginePage.InfoMessageLevel: 148 | self.main.mainWindow.logger.info("JS - Ligne {} : {}".format(line, msg)) 149 | elif level == QWebEnginePage.WarningMessageLevel: 150 | self.main.mainWindow.logger.warning("JS - Ligne {} : {}".format(line, msg)) 151 | else: 152 | self.main.mainWindow.logger.error("JS - Ligne {} : {}".format(line, msg)) 153 | 154 | def hitTestContent(self, pos): 155 | return WebHitTestResult(self, pos) 156 | 157 | def mapToViewport(self, pos): 158 | return QPointF(pos.x(), pos.y()) 159 | 160 | def executeJavaScript(self, scriptSrc): 161 | self.loop = QEventLoop() 162 | self.result = QVariant() 163 | QTimer.singleShot(250, self.loop.quit) 164 | 165 | self.runJavaScript(scriptSrc, self.callbackJS) 166 | self.loop.exec_() 167 | self.loop = None 168 | return self.result 169 | 170 | def callbackJS(self, res): 171 | if self.loop is not None and self.loop.isRunning(): 172 | self.result = res 173 | self.loop.quit() 174 | 175 | def vSource(self): 176 | if "view-source:http" in self.url().toString(): 177 | self.load(QUrl(self.url().toString().split("view-source:")[1])) 178 | else: 179 | self.triggerAction(self.ViewSource) 180 | 181 | def cutAction(self): 182 | self.triggerAction(self.Cut) 183 | 184 | def copyAction(self): 185 | self.triggerAction(self.Copy) 186 | 187 | def pasteAction(self): 188 | self.triggerAction(self.Paste) 189 | 190 | def ExitFS(self): 191 | self.triggerAction(self.ExitFullScreen) 192 | 193 | def makeFullScreen(self, request): 194 | if request.toggleOn(): 195 | self.fullView = QWebEngineView() 196 | self.exitFSAction = QAction(self.fullView) 197 | self.exitFSAction.setShortcut(Qt.Key_Escape) 198 | self.exitFSAction.triggered.connect(self.ExitFS) 199 | 200 | self.fullView.addAction(self.exitFSAction) 201 | self.setView(self.fullView) 202 | self.fullView.showFullScreen() 203 | self.fullView.raise_() 204 | else: 205 | del self.fullView 206 | self.setView(self.view) 207 | request.accept() -------------------------------------------------------------------------------- /files/Browthon_main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | # coding: utf-8 3 | 4 | from PyQt5.QtWebEngineWidgets import * 5 | from PyQt5.QtGui import * 6 | from PyQt5.QtCore import * 7 | from PyQt5.QtWidgets import * 8 | from PyQt5.Qt import * 9 | 10 | from files.Browthon_utils import * 11 | from files.Browthon_windows import * 12 | from files.Browthon_elements import * 13 | from files.Browthon_download import DownloadManagerWidget 14 | from files.Browthon_addons import AddonsManagerWidget 15 | 16 | import logging 17 | import logging.handlers 18 | 19 | 20 | class MainWindow(QMainWindow): 21 | def __init__(self, url, urltemp): 22 | super(MainWindow, self).__init__() 23 | self.layout = self.layout() 24 | try: 25 | with open('config.txt', 'r') as fichier: 26 | defall = fichier.read().split('\n') 27 | self.styleSheetParam = defall[5].split(" ")[1] 28 | self.niveauLog = defall[7].split(" ")[1] 29 | except IOError: 30 | self.styleSheetParam = "Default" 31 | self.niveauLog = "INFO" 32 | self.logger = logging.getLogger("logger") 33 | if self.niveauLog == "DEBUG": 34 | self.logger.setLevel(logging.DEBUG) 35 | elif self.niveauLog == "WARNING": 36 | self.logger.setLevel(logging.WARNING) 37 | elif self.niveauLog == "ERROR": 38 | self.logger.setLevel(logging.ERROR) 39 | elif self.niveauLog == "CRITICAL": 40 | self.logger.setLevel(logging.CRITICAL) 41 | else: 42 | self.logger.setLevel(logging.INFO) 43 | handler = logging.handlers.RotatingFileHandler( 44 | "logs/browthon.log", maxBytes=10000, backupCount=3) 45 | formatter = logging.Formatter('[%(levelname)s] %(filename)s:%(lineno)d - %(message)s (%(asctime)s)') 46 | handler.setFormatter(formatter) 47 | self.logger.addHandler(handler) 48 | self.logger.info("=====================") 49 | self.logger.info("Lancement de Browthon") 50 | if self.styleSheetParam != "Default": 51 | try: 52 | with open('style/' + self.styleSheetParam + ".bss", 'r') as fichier: 53 | bss = parseTheme(fichier.read()) 54 | self.setStyleSheet(bss) 55 | self.logger.debug("Le thème %s a été chargé", defall[5].split(" ")[1]) 56 | except Exception as e: 57 | self.styleSheetParam = "Default" 58 | QMessageBox().warning(self, "Style inconnu", "Le style " + defall[5].split(" ")[1] + " n'est pas reconnu par Browthon.") 59 | self.logger.warning("Le thème %s est inconnu. Erreur : %s", defall[5].split(" ")[1], e) 60 | self.mainWidget = MainWidget(url, urltemp, self) 61 | self.setCentralWidget(self.mainWidget) 62 | self.show() 63 | 64 | def closeEvent(self, event): 65 | self.mainWidget.closeEvent(event) 66 | 67 | 68 | class MainWidget(QWidget): 69 | def __init__(self, url, urltemp, mainWindow): 70 | super(MainWidget, self).__init__() 71 | self.mainWindow = mainWindow 72 | self.url = url 73 | self.urltemp = urltemp 74 | self.versionMinimal = "2.6.0" 75 | self.versionAll = "V 2.6.0 : Addon Update" 76 | self.fonts = {"titre": QFont("Arial", 23, QFont.Bold), 77 | "description": QFont("Arial", 18)} 78 | self.grid = QGridLayout() 79 | try: 80 | with open('config.txt', 'r') as fichier: 81 | defall = fichier.read().split('\n') 82 | if defall[2].split(" ")[1] == "True": 83 | self.js = True 84 | else: 85 | self.js = False 86 | if defall[3].split(" ")[1] == "True": 87 | self.private = True 88 | else: 89 | self.private = False 90 | if defall[4].split(" ")[1] == "True": 91 | self.deplacement_onglet = True 92 | else: 93 | self.deplacement_onglet = False 94 | if defall[6].split(" ")[1] == "True": 95 | self.sessionRecovery = True 96 | else: 97 | self.sessionRecovery = False 98 | if defall[8].split(" ")[1] == "True": 99 | self.launched = True 100 | else: 101 | self.launched = False 102 | self.mainWindow.logger.debug("Config chargé") 103 | except IOError: 104 | self.js = True 105 | self.private = False 106 | self.sessionRecovery = False 107 | self.deplacement_onglet = True 108 | self.launched = False 109 | self.mainWindow.logger.warning("Le fichier de config n'a pas été trouvé") 110 | self.onglets = [] 111 | self.ongletP = QPushButton("+") 112 | self.ongletM = QPushButton("-") 113 | self.urlInput = UrlInput(self) 114 | self.back = QPushButton("<") 115 | self.forward = QPushButton(">") 116 | self.reload = QPushButton("↺") 117 | self.accueil = QPushButton("⌂") 118 | self.menu = self.mainWindow.menuBar() 119 | self.menu.addAction("Historique", self.openHistory) 120 | self.menu.addAction("Favoris", self.openFav) 121 | self.menu.addAction("Téléchargements", self.openDownload) 122 | self.menu.addAction("Sessions", self.openSession) 123 | self.menu.addAction("Raccourcis URL", self.openRaccourci) 124 | self.menu.addAction("Addons", self.openAddons) 125 | self.menu.addAction("Paramètres", self.openParametres) 126 | self.about = self.menu.addMenu("Informations") 127 | self.onglet1 = Onglet(1, self) 128 | self.browser = self.onglet1 129 | self.onglets.append(self.onglet1) 130 | self.tabOnglet = TabOnglet(self) 131 | self.downloadManager = DownloadManagerWidget(self) 132 | self.browthonInfo = InformationBox(self, "Browthon") 133 | self.pyqtInfo = InformationBox(self, "PyQt") 134 | self.qtInfo = InformationBox(self, "Qt") 135 | self.favArray = [] 136 | try: 137 | with open("fav.txt", 'r') as fichier: 138 | for i in fichier.read().split('\n'): 139 | item = i.split(" | ") 140 | self.favArray.append(Item(self, item[0], item[1])) 141 | except IOError: 142 | pass 143 | self.sessionArray = [] 144 | try: 145 | with open("session.txt", 'r') as fichier: 146 | for i in fichier.read().split('\n'): 147 | item = i.split(" | ") 148 | self.sessionArray.append(ItemSession(self, item[0], item[1].split(" - "))) 149 | except IOError: 150 | pass 151 | self.raccourciArray = [] 152 | try: 153 | with open("raccourci.txt", "r") as fichier: 154 | for i in fichier.read().split("\n"): 155 | item = i.split(" | ") 156 | self.raccourciArray.append(Item(self, item[0], item[1])) 157 | except IOError: 158 | pass 159 | self.historyArray = [] 160 | try: 161 | with open('history.txt', 'r') as fichier: 162 | for i in fichier.read().split("\n"): 163 | item = i.split(" | ") 164 | self.historyArray.append(Item(self, item[0], item[1])) 165 | except IOError: 166 | pass 167 | self.about.addAction("Sur Browthon", lambda: self.openInfo("Browthon")) 168 | self.about.addAction("Sur PyQt", lambda: self.openInfo("PyQt")) 169 | self.about.addAction("Sur Qt", lambda: self.openInfo("Qt")) 170 | self.tabOnglet.currentChanged.connect(self.tabOnglet.changeOnglet) 171 | self.reload.clicked.connect(self.onglet1.reload) 172 | self.back.clicked.connect(self.onglet1.back) 173 | self.forward.clicked.connect(self.onglet1.forward) 174 | self.urlInput.returnPressed.connect(self.urlInput.enterUrl) 175 | self.ongletP.clicked.connect(self.addOnglet) 176 | self.ongletM.clicked.connect(self.closeOnglet) 177 | self.accueil.clicked.connect(self.urlAccueil) 178 | QWebEngineProfile.defaultProfile().downloadRequested.connect(self.downloadManager.downloadRequested) 179 | self.grid.addWidget(self.back, 1, 0) 180 | self.grid.addWidget(self.reload, 1, 1) 181 | self.grid.addWidget(self.forward, 1, 2) 182 | self.grid.addWidget(self.urlInput, 1, 3, 1, 6) 183 | self.grid.addWidget(self.accueil, 1, 11) 184 | self.grid.addWidget(self.tabOnglet, 2, 0, 1, 12) 185 | self.grid.addWidget(self.ongletP, 1, 9) 186 | self.grid.addWidget(self.ongletM, 1, 10) 187 | self.setLayout(self.grid) 188 | QWebEngineSettings.globalSettings().setAttribute(QWebEngineSettings.FullScreenSupportEnabled, True) 189 | self.addSessionBox = AddSessionBox(self, "Nom Session", "Entrez le nom de la session ou ANNULER") 190 | self.removeSessionBox = RemoveSessionBox(self, "Nom Session", "Entrez le nom de la session ou ANNULER") 191 | self.addRaccourciBox = AddRaccourciBox(self, "Nom Raccourci", "Entrez le nom et l'url du raccourci ou ANNULER") 192 | self.removeRaccourciBox = RemoveRaccourciBox(self, "Nom Raccourci", "Entrez le nom du raccourci ou ANNULER") 193 | self.historyBox = ListeBox(self, self.historyArray, "Historique") 194 | self.favBox = ListeBox(self, self.favArray, "Favoris") 195 | self.raccourciBox = ListeBox(self, self.raccourciArray, "Raccourcis URL") 196 | self.sessionBox = ListeBox(self, self.sessionArray, "Sessions") 197 | self.parametresBox = ParametreBox(self) 198 | if self.sessionRecovery: 199 | try: 200 | with open("last.txt", "r") as fichier: 201 | contenu = fichier.read().split("\n") 202 | for i in range(len(contenu)): 203 | if i == 0: 204 | self.urlInput.enterUrlGiven(contenu[i]) 205 | else: 206 | self.addOngletWithUrl(contenu[i]) 207 | except: 208 | QMessageBox().warning(self, "Pas d'ancienne session", "Aucune ancienne session n'a été trouvée") 209 | self.mainWindow.logger.warning("Tentativement de chargement d'ancienne session alors qu'il n'y en a pas") 210 | self.addonsManager = AddonsManagerWidget(self) 211 | self.addonsManager.launchAddons("load") 212 | self.mainWindow.logger.info("Browthon chargé") 213 | 214 | def setTitle(self): 215 | if self.private: 216 | self.mainWindow.setWindowTitle("[Privé]" + " " + self.browser.title() + " - Browthon") 217 | else: 218 | self.mainWindow.setWindowTitle(self.browser.title() + " - Browthon") 219 | if len(self.browser.title()) >= 13: 220 | titre = self.browser.title()[:9] + "..." 221 | else: 222 | titre = self.browser.title() 223 | self.tabOnglet.setTabText(self.tabOnglet.currentIndex(), titre) 224 | 225 | def openInfo(self, about): 226 | if about == "Browthon": 227 | self.browthonInfo.setWindowModality(Qt.ApplicationModal) 228 | self.browthonInfo.show() 229 | elif about == "PyQt": 230 | self.pyqtInfo.setWindowModality(Qt.ApplicationModal) 231 | self.pyqtInfo.show() 232 | elif about == "Qt": 233 | self.qtInfo.setWindowModality(Qt.ApplicationModal) 234 | self.qtInfo.show() 235 | 236 | def changeIcon(self): 237 | self.tabOnglet.setTabIcon(self.tabOnglet.currentIndex(), self.browser.icon()) 238 | 239 | def urlAccueil(self): 240 | self.browser.load(QUrl(self.url)) 241 | 242 | def openParametres(self): 243 | self.parametresBox.setWindowModality(Qt.ApplicationModal) 244 | self.parametresBox.show() 245 | 246 | def openAddons(self): 247 | self.addonsManager.setWindowModality(Qt.ApplicationModal) 248 | self.addonsManager.show() 249 | 250 | def addOnglet(self): 251 | onglet = Onglet(len(self.onglets) + 1, self) 252 | self.onglets.append(onglet) 253 | self.tabOnglet.addTab(onglet, QIcon('logo.png'), "Browthon") 254 | onglet.show() 255 | if self.deplacement_onglet: 256 | self.tabOnglet.setCurrentWidget(onglet) 257 | self.addonsManager.launchAddons("openOnglet", self.urltemp) 258 | 259 | def addOngletWithUrl(self, url): 260 | onglet = Onglet(len(self.onglets) + 1, self) 261 | self.onglets.append(onglet) 262 | self.tabOnglet.addTab(onglet, QIcon('logo.png'), "Browthon") 263 | onglet.show() 264 | self.tabOnglet.setCurrentWidget(onglet) 265 | self.urlInput.enterUrlGiven(url) 266 | self.addonsManager.launchAddons("openOnglet", url) 267 | 268 | def closeOnglet(self): 269 | if self.tabOnglet.count() == 1: 270 | question = QMessageBox().question(self, "Quitter ?", "Vous avez fermé le dernier onglet... \n Voulez vous quitter Browthon ?".replace(" \\n ", "\n"), QMessageBox.Yes, QMessageBox.No) 271 | if question == 16384: 272 | self.mainWindow.close() 273 | else: 274 | self.tabOnglet.removeTab(self.tabOnglet.currentIndex()) 275 | 276 | def openDownload(self): 277 | self.downloadManager.setWindowModality(Qt.ApplicationModal) 278 | self.downloadManager.show() 279 | 280 | def openHistory(self): 281 | self.historyBox.setWindowModality(Qt.ApplicationModal) 282 | self.historyBox.showUpdate(self.historyArray) 283 | 284 | def addHistory(self): 285 | if not self.private and self.browser.title() != "": 286 | self.historyArray.append(Item(self, self.browser.title(), self.browser.url().toString())) 287 | 288 | def removeAllHistory(self): 289 | self.historyArray = [] 290 | QMessageBox().about(self, "Historique", "Historique supprimé") 291 | self.mainWindow.logger.debug("Totalité de l'historique supprimé") 292 | 293 | def removeHistory(self, urlToFind): 294 | found = False 295 | for i in range(len(self.historyArray) - 1, -1, -1): 296 | if urlToFind == self.historyArray[i].url: 297 | del self.historyArray[i] 298 | found = True 299 | if found: 300 | QMessageBox().about(self, "Supprimer", "Cette page n'est plus dans l'historique") 301 | self.mainWindow.logger.debug("Page %s de l'historique supprimé", urlToFind) 302 | else: 303 | QMessageBox().about(self, "Annulation", "Cette page n'est pas dans l'historique") 304 | self.mainWindow.logger.warning("Page %s n'est pas dans l'historique", urlToFind) 305 | 306 | def openSession(self): 307 | self.sessionBox.setWindowModality(Qt.ApplicationModal) 308 | self.sessionBox.showUpdate(self.sessionArray) 309 | 310 | def addSession(self): 311 | self.addSessionBox.setWindowModality(Qt.ApplicationModal) 312 | self.addSessionBox.show() 313 | 314 | def removeSession(self): 315 | self.removeSessionBox.setWindowModality(Qt.ApplicationModal) 316 | self.removeSessionBox.show() 317 | 318 | def removeAllSession(self): 319 | self.raccourciArray = [] 320 | QMessageBox().about(self, "Sessions", "Sessions supprimées") 321 | self.mainWindow.logger.debug("Totalité des sesssions supprimées") 322 | 323 | def openRaccourci(self): 324 | self.raccourciBox.setWindowModality(Qt.ApplicationModal) 325 | self.raccourciBox.showUpdate(self.raccourciArray) 326 | 327 | def removeAllRaccourci(self): 328 | self.raccourciArray = [] 329 | QMessageBox().about(self, "Raccourcis URL", "Raccourcis supprimés") 330 | self.mainWindow.logger.debug("Totalité de les raccourcis URL supprimés") 331 | 332 | def addRaccourci(self): 333 | self.addRaccourciBox.setWindowModality(Qt.ApplicationModal) 334 | self.addRaccourciBox.show() 335 | 336 | def removeRaccourci(self): 337 | self.removeRaccourciBox.setWindowModality(Qt.ApplicationModal) 338 | self.removeRaccourciBox.show() 339 | 340 | def openFav(self): 341 | self.favBox.setWindowModality(Qt.ApplicationModal) 342 | self.favBox.showUpdate(self.favArray) 343 | 344 | def addFav(self): 345 | found = False 346 | for i in self.favArray: 347 | if self.browser.url().toString() == i.url: 348 | found = True 349 | if found: 350 | QMessageBox().about(self, "Annulation", "Cette page est déjà dans les favoris") 351 | self.mainWindow.logger.warning("Page %s déja dans les favoris", self.browser.url().toString()) 352 | else: 353 | self.favArray.append(Item(self, self.browser.title(), self.browser.url().toString())) 354 | QMessageBox().about(self, "Ajouter", "Cette page est maintenant dans les favoris") 355 | self.mainWindow.logger.debug("Page %s n'est plus dans les favoris", self.browser.url().toString()) 356 | 357 | def removeAllFav(self): 358 | self.favArray = [] 359 | QMessageBox().about(self, "Favoris", "Favoris supprimé") 360 | self.mainWindow.logger.debug("Totalité de l'historique supprimé") 361 | 362 | def removeFav(self, url): 363 | found = False 364 | for i in range(len(self.favArray) - 1, -1, -1): 365 | if url == self.favArray[i].url: 366 | del self.favArray[i] 367 | found = True 368 | if found: 369 | QMessageBox().about(self, "Supprimer", "Cette page n'est plus dans les favoris") 370 | else: 371 | QMessageBox().about(self, "Annulation", "Cette page n'est pas dans les favoris") 372 | 373 | def keyPressEvent(self, event): 374 | self.addonsManager.launchAddons("keyPress", event) 375 | if event.key() == Qt.Key_R or event.key() == Qt.Key_F5: 376 | self.browser.reload() 377 | elif event.key() == Qt.Key_N: 378 | self.addOnglet() 379 | elif event.key() == Qt.Key_A: 380 | self.addonsManager.setWindowModality(Qt.ApplicationModal) 381 | self.addonsManager.show() 382 | elif event.key() == Qt.Key_Q: 383 | self.closeOnglet() 384 | elif event.key() == Qt.Key_T: 385 | self.refreshTheme() 386 | elif event.key() == Qt.Key_H: 387 | self.historyBox.setWindowModality(Qt.ApplicationModal) 388 | self.historyBox.showUpdate(self.historyArray) 389 | elif event.key() == Qt.Key_P: 390 | self.parametresBox.setWindowModality(Qt.ApplicationModal) 391 | self.parametresBox.show() 392 | elif event.key() == Qt.Key_S: 393 | self.sessionBox.setWindowModality(Qt.ApplicationModal) 394 | self.sessionBox.showUpdate(self.sessionArray) 395 | elif event.key() == Qt.Key_U: 396 | self.raccourciBox.setWindowModality(Qt.ApplicationModal) 397 | self.raccourciBox.showUpdate(self.raccourciArray) 398 | elif event.key() == Qt.Key_D: 399 | self.downloadManager.show() 400 | elif event.key() == Qt.Key_F: 401 | self.favBox.setWindowModality(Qt.ApplicationModal) 402 | self.favBox.showUpdate(self.favArray) 403 | elif event.key() == Qt.Key_L: 404 | try: 405 | with open("last.txt", "r") as fichier: 406 | contenu = fichier.read().split("\n") 407 | for i in range(len(contenu)): 408 | if i == 0: 409 | self.urlInput.enterUrlGiven(contenu[i]) 410 | else: 411 | self.addOngletWithUrl(contenu[i]) 412 | except: 413 | QMessageBox().warning(self, "Pas d'ancienne session", "Aucune ancienne session n'a été trouvée") 414 | self.mainWindow.logger.warning("Tentativement de chargement d'ancienne session alors qu'il n'y en a pas") 415 | 416 | def refreshTheme(self): 417 | if self.mainWindow.styleSheetParam != "Default": 418 | with open('style/' + self.mainWindow.styleSheetParam + ".bss", 'r') as fichier: 419 | bss = parseTheme(fichier.read()) 420 | else: 421 | bss = "" 422 | self.mainWindow.setStyleSheet(bss) 423 | self.addSessionBox.setStyleSheet(bss) 424 | self.removeSessionBox.setStyleSheet(bss) 425 | self.addRaccourciBox.setStyleSheet(bss) 426 | self.removeRaccourciBox.setStyleSheet(bss) 427 | self.historyBox.setStyleSheet(bss) 428 | self.favBox.setStyleSheet(bss) 429 | self.downloadManager.setStyleSheet(bss) 430 | self.parametresBox.setStyleSheet(bss) 431 | self.browthonInfo.setStyleSheet(bss) 432 | self.pyqtInfo.setStyleSheet(bss) 433 | self.qtInfo.setStyleSheet(bss) 434 | self.mainWindow.logger.debug("Thème %s rechargé", self.mainWindow.styleSheetParam) 435 | 436 | def closeEvent(self, event): 437 | if self.historyArray == []: 438 | try: 439 | with open('history.txt'): 440 | pass 441 | except IOError: 442 | pass 443 | else: 444 | os.remove('history.txt') 445 | else: 446 | with open('history.txt', 'w') as fichier: 447 | message = "" 448 | for i in range(len(self.historyArray)): 449 | if i == len(self.historyArray) - 1: 450 | message += self.historyArray[i].title + " | " + self.historyArray[i].url 451 | else: 452 | message += self.historyArray[i].title + " | " + self.historyArray[i].url + "\n" 453 | fichier.write(message) 454 | if self.raccourciArray == []: 455 | try: 456 | with open('raccourci.txt'): 457 | pass 458 | except IOError: 459 | pass 460 | else: 461 | os.remove('raccourci.txt') 462 | else: 463 | with open('raccourci.txt', 'w') as fichier: 464 | message = "" 465 | for i in range(len(self.raccourciArray)): 466 | if i == len(self.raccourciArray) - 1: 467 | message += self.raccourciArray[i].title + " | " + self.raccourciArray[i].url 468 | else: 469 | message += self.raccourciArray[i].title + " | " + self.raccourciArray[i].url + '\n' 470 | fichier.write(message) 471 | if self.sessionArray == []: 472 | try: 473 | with open('session.txt'): 474 | pass 475 | except IOError: 476 | pass 477 | else: 478 | os.remove('session.txt') 479 | else: 480 | with open('session.txt', 'w') as fichier: 481 | message = "" 482 | for i in range(len(self.sessionArray)): 483 | urls = "" 484 | for y in self.sessionArray[i].urls: 485 | if y == self.sessionArray[i].urls[len(self.sessionArray[i].urls) - 1]: 486 | urls += y 487 | else: 488 | urls += y + " - " 489 | if i == len(self.sessionArray) - 1: 490 | message += self.sessionArray[i].title + " | " + urls 491 | else: 492 | message += self.sessionArray[i].title + " | " + urls + "\n" 493 | fichier.write(message) 494 | if self.favArray == []: 495 | try: 496 | with open('fav.txt'): 497 | pass 498 | except IOError: 499 | pass 500 | else: 501 | os.remove('fav.txt') 502 | else: 503 | with open('fav.txt', 'w') as fichier: 504 | message = "" 505 | for i in range(len(self.favArray)): 506 | if i == len(self.favArray) - 1: 507 | message += self.favArray[i].title + " | " + self.favArray[i].url 508 | else: 509 | message += self.favArray[i].title + " | " + self.favArray[i].url + '\n' 510 | fichier.write(message) 511 | with open('last.txt', 'w') as fichier: 512 | contenu = "" 513 | for i in range(self.tabOnglet.count()): 514 | if i == self.tabOnglet.count() - 1: 515 | contenu += self.tabOnglet.widget(i).url().toString() 516 | else: 517 | contenu += self.tabOnglet.widget(i).url().toString() + "\n" 518 | fichier.write(contenu) 519 | try: 520 | with open('config.txt', 'r') as fichier: 521 | defall = fichier.read().split('\n') 522 | defall[8] = "Launch True" 523 | with open("config.txt", "w") as f: 524 | f.write("\n".join(defall)) 525 | except: 526 | pass 527 | self.addonsManager.launchAddons("unload") 528 | self.mainWindow.logger.info("Fermeture de Browthon complète") 529 | -------------------------------------------------------------------------------- /files/Browthon_utils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | # coding: utf-8 3 | 4 | from PyQt5.QtWebEngineWidgets import * 5 | from PyQt5.QtGui import * 6 | from PyQt5.QtCore import * 7 | from PyQt5.QtWidgets import * 8 | from PyQt5.Qt import * 9 | 10 | import os, zipfile 11 | 12 | 13 | def parseTheme(bssString): 14 | bssList = bssString.split("\n") 15 | i = 0 16 | while i < len(bssList): 17 | if bssList[i] != "": 18 | if bssList[i][0] == "#": 19 | del bssList[i] 20 | i += 1 21 | bssString = "\n".join(bssList) 22 | bssString.replace("bproperty", "qproperty") 23 | bssString.replace("blineargradient", "qlineargradient") 24 | 25 | bssString.replace("\\4", "") 26 | 27 | return bssString 28 | 29 | def dezip(filezip, pathdst = ''): 30 | if pathdst == '': pathdst = os.getcwd() 31 | zfile = zipfile.ZipFile(filezip, 'r') 32 | for i in zfile.namelist(): 33 | if os.path.isdir(i): 34 | try: 35 | os.makedirs(pathdst + os.sep + i) 36 | except: 37 | pass 38 | else: 39 | try: 40 | os.makedirs(pathdst + os.sep + os.path.dirname(i)) 41 | except: 42 | pass 43 | data = zfile.read(i) 44 | try: 45 | fp = open(pathdst + os.sep + i, "wb") 46 | fp.write(data) 47 | fp.close() 48 | except IsADirectoryError: 49 | pass 50 | zfile.close() 51 | 52 | 53 | class ListWidget(QListWidget): 54 | def __init__(self, liste): 55 | super(ListWidget, self).__init__() 56 | self.liste = liste 57 | for i in self.liste: 58 | self.addItem(i.title) 59 | 60 | def deleteAllItems(self): 61 | for i in range(self.count() - 1, -1, -1): 62 | self.takeItem(i) 63 | 64 | def updateList(self, liste): 65 | self.liste = liste 66 | self.deleteAllItems() 67 | for i in self.liste: 68 | self.addItem(i.title) 69 | 70 | 71 | class ContextMenu(QMenu): 72 | def __init__(self, onglet, hitTest): 73 | super(ContextMenu, self).__init__() 74 | self.onglet = onglet 75 | contextMenuData = self.onglet.page.contextMenuData() 76 | hitTest.updateWithContextMenuData(contextMenuData) 77 | self.addAction("Retour", self.onglet.back) 78 | self.addAction("Avancer", self.onglet.forward) 79 | self.addAction("Recharger", self.onglet.reload) 80 | self.addSeparator() 81 | self.addAction("Source", self.onglet.page.vSource) 82 | temp = False 83 | for i in self.onglet.main.favArray: 84 | if self.onglet.main.browser.url().toString() == i.url: 85 | temp = True 86 | if temp: 87 | self.addAction("Supprimer Favori", self.onglet.main.suppFav) 88 | else: 89 | self.addAction("Ajouter Favori", self.onglet.main.addFav) 90 | if hitTest.isContentEditable(): 91 | self.addSeparator() 92 | self.addAction("Couper", self.onglet.page.cutAction) 93 | self.addAction("Copier", self.onglet.page.copyAction) 94 | self.addAction("Coller", self.onglet.page.pasteAction) 95 | if hitTest.imageUrl() != "": 96 | self.addSeparator() 97 | self.addAction("Voir Image", lambda: self.onglet.main.addOngletWithUrl(hitTest.imageUrl())) 98 | self.addSeparator() 99 | clickedUrl = hitTest.linkUrl() 100 | baseUrl = hitTest.baseUrl() 101 | if clickedUrl != baseUrl and clickedUrl != '': 102 | if 'http://' in clickedUrl or 'https://' in clickedUrl: 103 | url = clickedUrl 104 | elif clickedUrl == "#": 105 | url = baseUrl + clickedUrl 106 | else: 107 | url = "http://" + baseUrl.split("/")[2] + clickedUrl 108 | self.addAction("Ouvrir Nouvel Onglet", lambda: self.onglet.main.addOngletWithUrl(url)) 109 | 110 | 111 | class WebHitTestResult(): 112 | def __init__(self, page, pos): 113 | self.page = page 114 | self.pos = pos 115 | self.m_linkUrl = self.page.url().toString() 116 | self.m_baseUrl = self.page.url().toString() 117 | self.viewportPos = self.page.mapToViewport(self.pos) 118 | self.source = """(function() { 119 | let e = document.elementFromPoint(%1, %2); 120 | if (!e) 121 | return; 122 | function isMediaElement(e) { 123 | return e.tagName == 'AUDIO' || e.tagName == 'VIDEO'; 124 | }; 125 | function isEditableElement(e) { 126 | if (e.isContentEditable) 127 | return true; 128 | if (e.tagName === 'INPUT' || e.tagName === 'TEXTAREA') 129 | return e.getAttribute('readonly') != 'readonly'; 130 | return false; 131 | }; 132 | function isSelected(e) { 133 | let selection = window.getSelection(); 134 | if (selection.type !== 'Range') 135 | return false; 136 | return window.getSelection().containsNode(e, true); 137 | }; 138 | let res = { 139 | baseUrl: document.baseURI, 140 | alternateText: e.getAttribute('alt'), 141 | boundingRect: '', 142 | imageUrl: '', 143 | contentEditable: isEditableElement(e), 144 | contentSelected: isSelected(e), 145 | linkTitle: '', 146 | linkUrl: '', 147 | mediaUrl: '', 148 | tagName: e.tagName.toLowerCase() 149 | }; 150 | let r = e.getBoundingClientRect(); 151 | res.boundingRect = [r.top, r.left, r.width, r.height]; 152 | if (e.tagName == 'IMG') 153 | res.imageUrl = e.getAttribute('src'); 154 | if (e.tagName == 'A') { 155 | res.linkTitle = e.text; 156 | res.linkUrl = e.getAttribute('href'); 157 | } 158 | while (e) { 159 | if (res.linkTitle === '' && e.tagName === 'A') { 160 | res.linkTitle = e.text; 161 | if(res.linkUrl === '') { 162 | res.linkUrl = e.getAttribute('href'); 163 | } 164 | } 165 | if (res.mediaUrl === '' && isMediaElement(e)) { 166 | res.mediaUrl = e.currentSrc; 167 | res.mediaPaused = e.paused; 168 | res.mediaMuted = e.muted; 169 | } 170 | e = e.parentElement; 171 | } 172 | return res; 173 | })()""" 174 | 175 | self.js = self.source.replace("%1", str(self.viewportPos.x())).replace("%2", str(self.viewportPos.y())) 176 | self.dic = self.page.executeJavaScript(self.js) 177 | if self.dic is None: 178 | return 179 | 180 | self.m_isNull = False 181 | self.m_baseUrl = self.dic["baseUrl"] 182 | self.m_alternateText = self.dic["alternateText"] 183 | self.m_imageUrl = self.dic["imageUrl"] 184 | self.m_isContentEditable = self.dic["contentEditable"] 185 | self.m_isContentSelected = self.dic["contentSelected"] 186 | self.m_linkTitle = self.dic["linkTitle"] 187 | self.m_linkUrl = self.dic["linkUrl"] 188 | self.m_mediaUrl = self.dic["mediaUrl"] 189 | try: 190 | self.m_mediaPaused = self.dic["mediaPaused"] 191 | self.m_mediaMuted = self.dic["mediaMuted"] 192 | except: 193 | pass 194 | self.m_tagName = self.dic["tagName"] 195 | 196 | def linkUrl(self): 197 | return self.m_linkUrl 198 | 199 | def isContentEditable(self): 200 | return self.m_isContentEditable 201 | 202 | def isContentSelected(self): 203 | return self.m_isContentSelected 204 | 205 | def imageUrl(self): 206 | try: 207 | return self.m_imageUrl 208 | except: 209 | return "" 210 | 211 | def mediaUrl(self): 212 | return self.m_mediaUrl 213 | 214 | def baseUrl(self): 215 | return self.m_baseUrl 216 | 217 | def updateWithContextMenuData(self, data): 218 | if data.isValid(): 219 | pass 220 | else: 221 | return 222 | 223 | self.m_linkTitle = data.linkText() 224 | self.m_linkUrl = data.linkUrl().toString() 225 | self.m_isContentEditable = data.isContentEditable() 226 | if data.selectedText() == "": 227 | self.m_isContentSelected = False 228 | else: 229 | self.m_isContentSelected = True 230 | 231 | if data.mediaType() == QWebEngineContextMenuData.MediaTypeImage: 232 | self.m_imageUrl = data.mediaUrl().toString() 233 | elif data.mediaType() == QWebEngineContextMenuData.MediaTypeAudio or data.mediaType() == QWebEngineContextMenuData.MediaTypeVideo: 234 | self.m_mediaUrl = data.mediaUrl().toString() 235 | 236 | class Item: 237 | def __init__(self, main, title, url): 238 | self.main = main 239 | self.url = url 240 | self.title = title 241 | 242 | def setInteraction(self, menu): 243 | menu.addAction(self.title, self.load) 244 | 245 | def load(self): 246 | self.main.addOngletWithUrl(self.url) 247 | 248 | class ItemSession: 249 | def __init__(self, main, title, urls): 250 | self.main = main 251 | self.urls = urls 252 | self.title = title 253 | 254 | def setInteraction(self, menu): 255 | menu.addAction(self.title, self.load) 256 | 257 | def load(self): 258 | for i in self.urls: 259 | self.main.addOngletWithUrl(i) 260 | -------------------------------------------------------------------------------- /files/Browthon_windows.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | # coding: utf-8 3 | 4 | from PyQt5.QtWebEngineWidgets import * 5 | from PyQt5.QtGui import * 6 | from PyQt5.QtCore import * 7 | from PyQt5.QtWidgets import * 8 | from PyQt5.Qt import * 9 | 10 | from files.Browthon_utils import * 11 | 12 | 13 | class ParametreBox(QWidget): 14 | def __init__(self, main): 15 | super(ParametreBox, self).__init__() 16 | self.main = main 17 | self.setWindowTitle("Paramètres") 18 | self.setMinimumSize(600, 400) 19 | self.layoutMain = QVBoxLayout(self) 20 | self.scroll = QScrollArea(self) 21 | self.scroll.setWidgetResizable(True) 22 | self.title = QLabel("Paramètres") 23 | self.title.setFont(self.main.fonts["titre"]) 24 | self.title.setAlignment(Qt.AlignHCenter) 25 | self.layoutMain.addWidget(self.title) 26 | self.layoutMain.addWidget(self.scroll) 27 | self.container = QWidget() 28 | self.scroll.setWidget(self.container) 29 | self.layout = QVBoxLayout(self.container) 30 | 31 | self.moteurListe = ["Google", "DuckDuckGo", "Ecosia", "Yahoo", "Bing"] 32 | self.url = "http://pastagames.fr.nf/browthon" 33 | self.jsListe = ["Activé", "Désactivé"] 34 | self.privateListe = ["Désactivé", "Activé"] 35 | self.deplacementListe = ["Activé", "Désactivé"] 36 | self.themeListe = ["Blanc", "Sombre", "Bleu", "Rouge"] 37 | self.sessionListe = ["Désactivé", "Activé"] 38 | self.logListe = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] 39 | try: 40 | with open('config.txt', 'r') as fichier: 41 | defall = fichier.read().split('\n') 42 | if defall[0].split(" ")[1] == "https://www.google.fr/?gws_rd=ssl#q=": 43 | temp = "Google" 44 | elif defall[0].split(" ")[1] == "https://duckduckgo.com/?q=": 45 | temp = "DuckDuckGo" 46 | elif defall[0].split(" ")[1] == "https://www.ecosia.org/search?q=": 47 | temp = "Ecosia" 48 | elif defall[0].split(" ")[1] == "https://fr.search.yahoo.com/search?p=": 49 | temp = "Yahoo" 50 | elif defall[0].split(" ")[1] == "https://www.bing.com/search?q=": 51 | temp = "Bing" 52 | for i in range(len(self.moteurListe)): 53 | if self.moteurListe[i] == temp: 54 | self.moteurListe[0], self.moteurListe[i] = self.moteurListe[i], self.moteurListe[0] 55 | break 56 | 57 | self.url = defall[1].split(" ")[1] 58 | 59 | if defall[2].split(" ")[1] == "True": 60 | self.jsListe = ["Activé", "Désactivé"] 61 | else: 62 | self.jsListe = ["Désactivé", "Activé"] 63 | 64 | if defall[3].split(" ")[1] == "True": 65 | self.privateListe = ["Activé", "Désactivé"] 66 | else: 67 | self.privateListe = ["Désactivé", "Activé"] 68 | 69 | if defall[4].split(" ")[1] == "True": 70 | self.deplacementListe = ["Activé", "Désactivé"] 71 | else: 72 | self.deplacementListe = ["Désactivé", "Activé"] 73 | 74 | if defall[5].split(" ")[1] == "Default": 75 | temp = "Blanc" 76 | elif defall[5].split(" ")[1] == "Dark": 77 | temp = "Sombre" 78 | elif defall[5].split(" ")[1] == "Blue": 79 | temp = "Bleu" 80 | elif defall[5].split(" ")[1] == "Red": 81 | temp = "Rouge" 82 | for i in range(len(self.themeListe)): 83 | if self.themeListe[i] == temp: 84 | self.themeListe[0], self.themeListe[i] = self.themeListe[i], self.themeListe[0] 85 | break 86 | 87 | if defall[6].split(" ")[1] == "True": 88 | self.sessionListe = ["Activé", "Désactivé"] 89 | else: 90 | self.sessionListe = ["Désactivé", "Activé"] 91 | 92 | for i in range(len(self.logListe)): 93 | if self.logListe[i] == defall[7].split(" ")[1]: 94 | self.logListe[0], self.logListe[i] = self.logListe[i], self.logListe[0] 95 | break 96 | except: 97 | pass 98 | 99 | self.moteur = QLabel("Moteur de recherche") 100 | self.moteur.setFont(self.main.fonts["description"]) 101 | self.moteur.setAlignment(Qt.AlignHCenter) 102 | self.layout.addWidget(self.moteur) 103 | self.moteurBox = QComboBox() 104 | self.moteurBox.addItems(self.moteurListe) 105 | self.layout.addWidget(self.moteurBox) 106 | 107 | self.accueil = QLabel("Url d'accueil") 108 | self.accueil.setFont(self.main.fonts["description"]) 109 | self.accueil.setAlignment(Qt.AlignHCenter) 110 | self.layout.addWidget(self.accueil) 111 | self.accueilBox = QLineEdit() 112 | self.accueilBox.setText(self.url) 113 | self.layout.addWidget(self.accueilBox) 114 | 115 | self.js = QLabel("JavaScript") 116 | self.js.setFont(self.main.fonts["description"]) 117 | self.js.setAlignment(Qt.AlignHCenter) 118 | self.layout.addWidget(self.js) 119 | self.jsBox = QComboBox() 120 | self.jsBox.addItems(self.jsListe) 121 | self.layout.addWidget(self.jsBox) 122 | 123 | self.private = QLabel("Navigation privée") 124 | self.private.setFont(self.main.fonts["description"]) 125 | self.private.setAlignment(Qt.AlignHCenter) 126 | self.layout.addWidget(self.private) 127 | self.privateBox = QComboBox() 128 | self.privateBox.addItems(self.privateListe) 129 | self.layout.addWidget(self.privateBox) 130 | 131 | self.deplacement = QLabel("Déplacement à l'ouverture d'un onglet") 132 | self.deplacement.setFont(self.main.fonts["description"]) 133 | self.deplacement.setAlignment(Qt.AlignHCenter) 134 | self.layout.addWidget(self.deplacement) 135 | self.deplacementBox = QComboBox() 136 | self.deplacementBox.addItems(self.deplacementListe) 137 | self.layout.addWidget(self.deplacementBox) 138 | 139 | self.style = QLabel("Thème") 140 | self.style.setFont(self.main.fonts["description"]) 141 | self.style.setAlignment(Qt.AlignHCenter) 142 | self.layout.addWidget(self.style) 143 | self.styleBox = QComboBox() 144 | self.styleBox.addItems(self.themeListe) 145 | self.layout.addWidget(self.styleBox) 146 | 147 | self.session = QLabel("Chargement de la dernière session") 148 | self.session.setFont(self.main.fonts["description"]) 149 | self.session.setAlignment(Qt.AlignHCenter) 150 | self.layout.addWidget(self.session) 151 | self.sessionBox = QComboBox() 152 | self.sessionBox.addItems(self.sessionListe) 153 | self.layout.addWidget(self.sessionBox) 154 | 155 | self.log = QLabel("Niveau minimum des logs") 156 | self.log.setFont(self.main.fonts["description"]) 157 | self.log.setAlignment(Qt.AlignHCenter) 158 | self.layout.addWidget(self.log) 159 | self.logBox = QComboBox() 160 | self.logBox.addItems(self.logListe) 161 | self.layout.addWidget(self.logBox) 162 | 163 | self.valider = QPushButton("Valider") 164 | self.valider.clicked.connect(self.validateChoice) 165 | self.layout.addWidget(self.valider) 166 | 167 | if self.main.mainWindow.styleSheetParam != "Default": 168 | with open('style/' + self.main.mainWindow.styleSheetParam + ".bss", 'r') as fichier: 169 | bss = parseTheme(fichier.read()) 170 | self.setStyleSheet(bss) 171 | 172 | def validateChoice(self): 173 | self.texteFile = "UrlMoteur " 174 | temp = self.moteurListe[self.moteurBox.currentIndex()] 175 | if temp == "Google": 176 | self.texteFile += "https://www.google.fr/?gws_rd=ssl#q=\n" 177 | elif temp == "DuckDuckGo": 178 | self.texteFile += "https://duckduckgo.com/?q=\n" 179 | elif temp == "Ecosia": 180 | self.texteFile += "https://www.ecosia.org/search?q=\n" 181 | elif temp == "Yahoo": 182 | self.texteFile += "https://fr.search.yahoo.com/search?p=\n" 183 | else: 184 | self.texteFile += "https://www.bing.com/search?q=\n" 185 | 186 | self.texteFile += "UrlAccueil " + self.accueilBox.text() + "\n" 187 | 188 | self.texteFile += "JavaScript " 189 | if self.jsListe[self.jsBox.currentIndex()] == "Activé": 190 | self.texteFile += "True\n" 191 | else: 192 | self.texteFile += "False\n" 193 | 194 | self.texteFile += "NavigationPrivée " 195 | if self.privateListe[self.privateBox.currentIndex()] == "Activé": 196 | self.texteFile += "True\n" 197 | else: 198 | self.texteFile += "False\n" 199 | 200 | self.texteFile += "DéplacementOnglet " 201 | if self.deplacementListe[self.deplacementBox.currentIndex()] == "Activé": 202 | self.texteFile += "True\n" 203 | else: 204 | self.texteFile += "False\n" 205 | 206 | self.texteFile += "Style " 207 | temp = self.themeListe[self.styleBox.currentIndex()] 208 | if temp == "Blanc": 209 | self.texteFile += "Default\n" 210 | elif temp == "Sombre": 211 | self.texteFile += "Dark\n" 212 | elif temp == "Bleu": 213 | self.texteFile += "Blue\n" 214 | else: 215 | self.texteFile += "Red\n" 216 | 217 | self.texteFile += "Session " 218 | if self.sessionListe[self.sessionBox.currentIndex()] == "Activé": 219 | self.texteFile += "True\n" 220 | else: 221 | self.texteFile += "False\n" 222 | 223 | self.texteFile += "NiveauLog " + self.logListe[self.logBox.currentIndex()] 224 | 225 | self.texteFile += "Launch True" 226 | 227 | with open('config.txt', 'w') as fichier: 228 | fichier.write(self.texteFile) 229 | QMessageBox().about(self, "Configuration enregistrée !", "Merci de relancer Browthon.") 230 | self.close() 231 | 232 | 233 | class ListeBox(QWidget): 234 | def __init__(self, main, liste, texte): 235 | super(ListeBox, self).__init__() 236 | self.main = main 237 | self.liste = liste 238 | self.texte = texte 239 | self.on = True 240 | self.setWindowTitle(texte) 241 | self.grid = QGridLayout() 242 | 243 | self.title = QLabel(texte) 244 | self.title.setAlignment(Qt.AlignHCenter) 245 | self.title.setFont(self.main.fonts["titre"]) 246 | self.listeW = ListWidget(liste) 247 | self.supprimer = QPushButton("Supprimer") 248 | self.supprimerT = QPushButton("Tout Supprimer") 249 | 250 | self.listeW.itemDoubleClicked.connect(self.launch) 251 | self.supprimerT.clicked.connect(self.deleteAll) 252 | self.supprimer.clicked.connect(self.delete) 253 | 254 | self.grid.addWidget(self.title, 1, 1, 1, 2) 255 | self.grid.addWidget(self.listeW, 2, 1, 1, 2) 256 | self.grid.addWidget(self.supprimer, 3, 1) 257 | self.grid.addWidget(self.supprimerT, 3, 2) 258 | 259 | if self.texte == "Favoris": 260 | self.addFav = QPushButton("Ajouter Favori") 261 | self.addFav.clicked.connect(self.addFavF) 262 | self.grid.addWidget(self.addFav, 4, 1, 1, 2) 263 | elif self.texte == "Raccourcis URL": 264 | self.addRaccourci = QPushButton("Ajouter Raccourci") 265 | self.addRaccourci.clicked.connect(self.addRaccourciF) 266 | self.grid.addWidget(self.addRaccourci, 4, 1, 1, 2) 267 | elif self.texte == "Sessions": 268 | self.addSession = QPushButton("Ajouter Session") 269 | self.addSession.clicked.connect(self.addSessionF) 270 | self.grid.addWidget(self.addSession, 4, 1, 1, 2) 271 | 272 | self.setLayout(self.grid) 273 | if self.main.mainWindow.styleSheetParam != "Default": 274 | with open('style/' + self.main.mainWindow.styleSheetParam + ".bss", 'r') as fichier: 275 | bss = parseTheme(fichier.read()) 276 | self.setStyleSheet(bss) 277 | 278 | def addFavF(self): 279 | self.close() 280 | self.main.addFav() 281 | 282 | def addRaccourciF(self): 283 | self.close() 284 | self.main.addRaccourci() 285 | 286 | def addSessionF(self): 287 | self.close() 288 | self.main.addSession() 289 | 290 | def launch(self): 291 | if self.listeW.currentItem(): 292 | for i in self.liste: 293 | if i.title == self.listeW.currentItem().text(): 294 | self.close() 295 | i.load() 296 | break 297 | 298 | def showUpdate(self, liste): 299 | self.liste = liste 300 | self.listeW.updateList(self.liste) 301 | self.show() 302 | 303 | def delete(self): 304 | if self.listeW.currentItem(): 305 | for i in self.liste: 306 | if i.title == self.listeW.currentItem().text(): 307 | self.close() 308 | if self.texte == "Historique": 309 | self.main.removeHistory(i.url) 310 | elif self.texte == "Sessions": 311 | self.main.removeSession() 312 | elif self.texte == "Raccourcis URL": 313 | self.main.removeRaccourci() 314 | else: 315 | self.main.removeFav(i.url) 316 | 317 | def deleteAll(self): 318 | self.listeW.deleteAllItems() 319 | if self.texte == "Historique": 320 | self.main.removeAllHistory() 321 | elif self.texte == "Sessions": 322 | self.main.removeAllSession() 323 | elif self.texte == "Raccourcis URL": 324 | self.main.removeAllRaccourci() 325 | else: 326 | self.main.removeAllFav() 327 | 328 | 329 | class InformationBox(QWidget): 330 | def __init__(self, main, about): 331 | super(InformationBox, self).__init__() 332 | self.about = about 333 | self.main = main 334 | self.button = QPushButton("Site") 335 | if self.about == "Browthon": 336 | self.setFixedSize(500, 350) 337 | self.setWindowTitle("Informations sur Browthon") 338 | self.title = QLabel("Browthon") 339 | self.description = QLabel(self.main.versionAll + "\nCréé par PastaGames\n\nSite :") 340 | self.button.clicked.connect(lambda: self.openWebsite("http://pastagames.fr.nf")) 341 | self.image = QPixmap("logo.png") 342 | elif self.about == "PyQt": 343 | self.setFixedSize(500, 350) 344 | self.setWindowTitle("Informations sur PyQt") 345 | self.title = QLabel("PyQt") 346 | self.description = QLabel("Version utilisée: " + PYQT_VERSION_STR + "\nCréé par Riverbank Computing\n\nSite :") 347 | self.button.clicked.connect(lambda: self.openWebsite("https://riverbankcomputing.com/software/pyqt/intro")) 348 | self.image = QPixmap("pyqt_logo.png") 349 | elif self.about == "Qt": 350 | self.setFixedSize(500, 350) 351 | self.setWindowTitle("Informations sur Qt") 352 | self.title = QLabel("Qt") 353 | self.description = QLabel("Version : " + QT_VERSION_STR +"\nCréé par The Qt Company\n\nSite :") 354 | self.button.clicked.connect(lambda: self.openWebsite("https://www.qt.io/")) 355 | self.image = QPixmap("qt_logo.png") 356 | self.title.setAlignment(Qt.AlignHCenter) 357 | self.description.setAlignment(Qt.AlignHCenter) 358 | self.title.setFont(self.main.fonts["titre"]) 359 | self.description.setFont(self.main.fonts["description"]) 360 | self.grid = QGridLayout() 361 | self.imageLabel = QLabel() 362 | self.imageLabel.setPixmap(self.image) 363 | self.imageLabel.setAlignment(Qt.AlignHCenter) 364 | self.grid.addWidget(self.imageLabel, 1, 1) 365 | self.grid.addWidget(self.title, 2, 1) 366 | self.grid.addWidget(self.description, 3, 1) 367 | self.grid.addWidget(self.button, 4, 1) 368 | self.setLayout(self.grid) 369 | if self.main.mainWindow.styleSheetParam != "Default": 370 | with open('style/' + self.main.mainWindow.styleSheetParam + ".bss", 'r') as fichier: 371 | bss = parseTheme(fichier.read()) 372 | self.setStyleSheet(bss) 373 | 374 | def openWebsite(self, url): 375 | self.close() 376 | self.main.addOngletWithUrl(url) 377 | 378 | 379 | class AddRaccourciBox(QWidget): 380 | def __init__(self, main, title, text): 381 | super(AddRaccourciBox, self).__init__() 382 | self.main = main 383 | self.result = "" 384 | self.on = True 385 | self.setWindowTitle(title) 386 | self.grid = QGridLayout() 387 | 388 | self.Texte = QLabel(text) 389 | self.Titre = QLineEdit() 390 | self.Url = QLineEdit() 391 | self.bValider = QPushButton("Valider") 392 | 393 | self.bValider.clicked.connect(self.urlEnter) 394 | 395 | self.grid.addWidget(self.Texte, 1, 1) 396 | self.grid.addWidget(self.Titre, 2, 1) 397 | self.grid.addWidget(self.Url, 3, 1) 398 | self.grid.addWidget(self.bValider, 4, 1) 399 | 400 | self.setLayout(self.grid) 401 | if self.main.mainWindow.styleSheetParam != "Default": 402 | with open('style/' + self.main.mainWindow.styleSheetParam + ".bss", 'r') as fichier: 403 | bss = parseTheme(fichier.read()) 404 | self.setStyleSheet(bss) 405 | 406 | def urlEnter(self): 407 | self.result = self.Titre.text() 408 | if self.result == "" or self.result == "ANNULER": 409 | QMessageBox().about(self, "Création annulé", "La création du raccourci a été annulée") 410 | else: 411 | found = False 412 | for i in range(len(self.main.raccourciArray)): 413 | if self.result == self.main.raccourciArray[i].title: 414 | found = True 415 | if found: 416 | QMessageBox().about(self, "Création annulé", "Le raccourci " + self.result + " existe déjà !") 417 | else: 418 | self.url = self.Url.text() 419 | found = False 420 | if "http://" in self.url or "https://" in self.url: 421 | found = True 422 | else: 423 | if "." in self.url: 424 | found = True 425 | if not found: 426 | QMessageBox().about(self, "Création annulé", "Le raccourci " + self.result + " n'a pas un url valide !") 427 | else: 428 | self.main.raccourciArray.append(Item(self.main, self.result, self.url)) 429 | QMessageBox().about(self, "Raccourci créée", "Le raccourci " + self.result + " a été créée !") 430 | self.close() 431 | 432 | 433 | class RemoveRaccourciBox(QWidget): 434 | def __init__(self, main, title, text): 435 | super(RemoveRaccourciBox, self).__init__() 436 | self.main = main 437 | self.result = "" 438 | self.on = True 439 | self.setWindowTitle(title) 440 | self.grid = QGridLayout() 441 | 442 | self.Texte = QLabel(text) 443 | self.Titre = QLineEdit() 444 | self.bValider = QPushButton("Valider") 445 | 446 | self.bValider.clicked.connect(self.urlEnter) 447 | 448 | self.grid.addWidget(self.Texte, 1, 1) 449 | self.grid.addWidget(self.Titre, 2, 1) 450 | self.grid.addWidget(self.bValider, 3, 1) 451 | 452 | self.setLayout(self.grid) 453 | if self.main.mainWindow.styleSheetParam != "Default": 454 | with open('style/' + self.main.mainWindow.styleSheetParam + ".bss", 'r') as fichier: 455 | bss = parseTheme(fichier.read()) 456 | self.setStyleSheet(bss) 457 | 458 | def urlEnter(self): 459 | self.result = self.Titre.text() 460 | if self.result == "" or self.result == "ANNULER": 461 | QMessageBox().about(self, "Suppression annulé", "La suppression du raccourci a été annulée") 462 | else: 463 | found = False 464 | for i in range(len(self.main.raccourciArray)): 465 | if self.result == self.main.raccourciArray[i].title: 466 | del self.main.raccourciArray[i] 467 | found = True 468 | if found: 469 | for i in self.main.raccourciArray: 470 | i.setInteraction(self.main.raccourci) 471 | QMessageBox().about(self, "Raccourci supprimée", "Le raccourci " + self.result + " a été supprimée !") 472 | else: 473 | QMessageBox().about(self, "Raccourci non trouvée", "Le raccourci " + self.result + " n'a pas été trouvé !") 474 | self.close() 475 | 476 | 477 | class NameBox(QWidget): 478 | def __init__(self, main, title, text): 479 | super(NameBox, self).__init__() 480 | self.main = main 481 | self.result = "" 482 | self.on = True 483 | self.setWindowTitle(title) 484 | self.grid = QGridLayout() 485 | 486 | self.Texte = QLabel(text) 487 | self.Url = QLineEdit() 488 | 489 | self.Url.returnPressed.connect(self.urlEnter) 490 | 491 | self.grid.addWidget(self.Texte, 1, 1) 492 | self.grid.addWidget(self.Url, 2, 1) 493 | 494 | self.setLayout(self.grid) 495 | if self.main.mainWindow.styleSheetParam != "Default": 496 | with open('style/' + self.main.mainWindow.styleSheetParam + ".bss", 'r') as fichier: 497 | bss = parseTheme(fichier.read()) 498 | self.setStyleSheet(bss) 499 | 500 | def urlEnter(self): 501 | pass 502 | 503 | 504 | class AddSessionBox(NameBox): 505 | def __init__(self, main, title, text): 506 | super(AddSessionBox, self).__init__(main, title, text) 507 | 508 | def urlEnter(self): 509 | self.result = self.Url.text() 510 | if self.result == "" or self.result == "ANNULER": 511 | QMessageBox().about(self, "Création annulé", "La création de la session a été annulée") 512 | else: 513 | found = False 514 | for i in range(len(self.main.sessionArray)): 515 | if self.result == self.main.sessionArray[i].title: 516 | found = True 517 | if found: 518 | QMessageBox().about(self, "Création annulé", "La session " + self.result + " existe déjà !") 519 | else: 520 | urls = [] 521 | for i in range(self.main.tabOnglet.count()): 522 | urls.append(self.main.tabOnglet.widget(i).url().toString()) 523 | self.main.sessionArray.append(ItemSession(self.main, self.result, urls)) 524 | QMessageBox().about(self, "Session créée", "La session " + self.result + " a été créée !") 525 | self.close() 526 | 527 | 528 | class RemoveSessionBox(NameBox): 529 | def __init__(self, main, title, text): 530 | super(RemoveSessionBox, self).__init__(main, title, text) 531 | 532 | def urlEnter(self): 533 | self.result = self.Url.text() 534 | if self.result == "" or self.result == "ANNULER": 535 | QMessageBox().about(self, "Suppression annulé", "La suppression de la session a été annulée") 536 | else: 537 | found = False 538 | for i in range(len(self.main.sessionArray)): 539 | if self.result == self.main.sessionArray[i].title: 540 | del self.main.sessionArray[i] 541 | found = True 542 | if found: 543 | QMessageBox().about(self, "Session supprimée", "La session " + self.result + " a été supprimée !") 544 | else: 545 | QMessageBox().about(self, "Session non trouvée", "La session " + self.result + " n'a pas été trouvé !") 546 | self.close() -------------------------------------------------------------------------------- /files/addons/Test/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "Name": "Addon Test", 3 | "NameCode": "test", 4 | "Author": "LavaPower", 5 | "Description": "Addon de test", 6 | "Url": "http://pastagames.fr.nf", 7 | "Version": "0.0.1", 8 | "Logo": "logo.png", 9 | "Activation": "False" 10 | } -------------------------------------------------------------------------------- /files/addons/Test/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Browthon/Browthon-Python/06402b908cbd8a0cee55b7902e93bb781cda3e51/files/addons/Test/logo.png -------------------------------------------------------------------------------- /files/addons/Test/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | # coding: utf-8 3 | 4 | import sys 5 | sys.path.append('..') 6 | 7 | 8 | class Test: 9 | def load(self, main): 10 | main.mainWindow.logger.info("Chargement de l'addon Test") 11 | 12 | def keyPress(self, main, event): 13 | main.mainWindow.logger.info("Numéro Touche pressé :", event.key()) 14 | 15 | def enterUrl(self, main, url): 16 | main.mainWindow.logger.info("Url entré : "+url) 17 | 18 | def openOnglet(self, main, url): 19 | main.mainWindow.logger.info("Nouvel onglet avec url : "+url) 20 | 21 | def unload(self, main): 22 | main.mainWindow.logger.info("Déchargement de l'addon test") 23 | 24 | instance = Test 25 | name = "test" -------------------------------------------------------------------------------- /files/addons/Youtubedl/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "Name": "Youtube DL", 3 | "NameCode": "youtubedl", 4 | "Author": "LavaPower", 5 | "Description": "Addon pour télécharger une vidéo youtube", 6 | "Url": "http://pastagames.fr.nf/browthon", 7 | "Version": "0.0.1", 8 | "Logo": "logo.png", 9 | "Activation": "False" 10 | } -------------------------------------------------------------------------------- /files/addons/Youtubedl/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Browthon/Browthon-Python/06402b908cbd8a0cee55b7902e93bb781cda3e51/files/addons/Youtubedl/logo.png -------------------------------------------------------------------------------- /files/addons/Youtubedl/youtubedl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.6 2 | # coding: utf-8 3 | 4 | import sys 5 | sys.path.append('..') 6 | 7 | 8 | class Youtubedl: 9 | def load(self, main): 10 | self.main = main 11 | self.main.menu.addAction("YoutubeDL", lambda: self.downloadVideo(self)) 12 | self.main.mainWindow.logger.info("Chargement de l'addon YoutubeDL") 13 | 14 | def downloadVideo(self): 15 | if "youtube.com/watch" in self.main.browser.url().toString(): 16 | urls = self.main.browser.url().toString().split(".") 17 | for i in range(len(urls)): 18 | if urls[i] == "youtube": 19 | urls[i] = "pwnyoutube" 20 | break 21 | url = ".".join(urls) 22 | self.main.urlInput.enterUrlGiven(url) 23 | 24 | def unload(self, main): 25 | self.main.mainWindow.logger.info("Déchargement de l'addon test") 26 | 27 | instance = Youtubedl 28 | name = "youtubedl" -------------------------------------------------------------------------------- /files/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Browthon/Browthon-Python/06402b908cbd8a0cee55b7902e93bb781cda3e51/files/logo.png -------------------------------------------------------------------------------- /files/pyqt_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Browthon/Browthon-Python/06402b908cbd8a0cee55b7902e93bb781cda3e51/files/pyqt_logo.png -------------------------------------------------------------------------------- /files/qt_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Browthon/Browthon-Python/06402b908cbd8a0cee55b7902e93bb781cda3e51/files/qt_logo.png -------------------------------------------------------------------------------- /files/style/Blue.bss: -------------------------------------------------------------------------------- 1 | QWidget { 2 | background-color: #2a4ab5; 3 | border-color: #2a4ab5; 4 | } 5 | 6 | QMenuBar { 7 | background-color: #2a4ab5; 8 | } 9 | 10 | QMenuBar::item { 11 | color: #f5f5f5; 12 | } 13 | 14 | QListWidget::item { 15 | color: #f5f5f5; 16 | } 17 | 18 | QMainWindow { 19 | background-color: #2a4ab5; 20 | } 21 | 22 | QPushButton { 23 | background-color: #274ed1; 24 | color: #f5f5f5; 25 | } 26 | 27 | QLineEdit { 28 | background-color: #274ed1; 29 | color: #f5f5f5; 30 | } 31 | 32 | QLabel { 33 | color: #f5f5f5; 34 | } 35 | 36 | QMenu { 37 | background-color: #2a4ab5; /* sets background of the menu */ 38 | border: 1px solid black; 39 | } 40 | 41 | QMenu::item { 42 | color: #f5f5f5; 43 | } 44 | 45 | QTabWidget::pane { 46 | border-top: 2px solid #C2C7CB; 47 | } 48 | 49 | QTabWidget::tab-bar { 50 | left: 5px; 51 | } 52 | 53 | QTabBar::tab { 54 | background: #274ed1; 55 | border: 2px solid #2a4ab5; 56 | border-top-left-radius: 4px; 57 | border-top-right-radius: 4px; 58 | min-width: 8ex; 59 | padding: 2px; 60 | color: #f5f5f5; 61 | } 62 | 63 | QTabBar::tab:hover { 64 | background: #2851dc; 65 | } 66 | 67 | QTabBar::tab:selected { 68 | background: #2851dc; 69 | } 70 | 71 | QTabBar::tab:!selected { 72 | margin-top: 2px; 73 | background: #274ed1; 74 | } -------------------------------------------------------------------------------- /files/style/Dark.bss: -------------------------------------------------------------------------------- 1 | QWidget { 2 | background-color: #3f3f3f; 3 | border-color: #3f3f3f; 4 | } 5 | 6 | QMenuBar { 7 | background-color: #3f3f3f; 8 | } 9 | 10 | QMenuBar::item { 11 | color: #f5f5f5; 12 | } 13 | 14 | QMainWindow { 15 | background-color: #3f3f3f; 16 | } 17 | 18 | QPushButton { 19 | background-color: #565656; 20 | color: #f5f5f5; 21 | } 22 | 23 | QListWidget::item { 24 | color: #f5f5f5; 25 | } 26 | 27 | QLineEdit { 28 | background-color: #565656; 29 | color: #f5f5f5; 30 | } 31 | 32 | QLabel { 33 | color: #f5f5f5; 34 | } 35 | 36 | QMenu { 37 | background-color: #3f3f3f; /* sets background of the menu */ 38 | border: 1px solid black; 39 | } 40 | 41 | QMenu::item { 42 | color: #f5f5f5; 43 | } 44 | 45 | QTabWidget::pane { 46 | border-top: 2px solid #C2C7CB; 47 | } 48 | 49 | QTabWidget::tab-bar { 50 | left: 5px; 51 | } 52 | 53 | QTabBar::tab { 54 | background: #565656; 55 | border: 2px solid #3f3f3f; 56 | border-top-left-radius: 4px; 57 | border-top-right-radius: 4px; 58 | min-width: 8ex; 59 | padding: 2px; 60 | color: #f5f5f5; 61 | } 62 | 63 | QTabBar::tab:hover { 64 | background: #595959; 65 | } 66 | 67 | QTabBar::tab:selected { 68 | background: #595959; 69 | } 70 | 71 | QTabBar::tab:!selected { 72 | margin-top: 2px; 73 | background: #565656; 74 | } -------------------------------------------------------------------------------- /files/style/Red.bss: -------------------------------------------------------------------------------- 1 | QWidget { 2 | background-color: #c01e1e; 3 | border-color: #c01e1e; 4 | } 5 | 6 | QMenuBar { 7 | background-color: #c01e1e; 8 | } 9 | 10 | QMenuBar::item { 11 | color: #f5f5f5; 12 | } 13 | 14 | QListWidget::item { 15 | color: #f5f5f5; 16 | } 17 | 18 | QMainWindow { 19 | background-color: #c01e1e; 20 | } 21 | 22 | QPushButton { 23 | background-color: #d72020; 24 | color: #f5f5f5; 25 | } 26 | 27 | QLineEdit { 28 | background-color: #d72020; 29 | color: #f5f5f5; 30 | } 31 | 32 | QLabel { 33 | color: #f5f5f5; 34 | } 35 | 36 | QMenu { 37 | background-color: #c01e1e; /* sets background of the menu */ 38 | border: 1px solid black; 39 | } 40 | 41 | QMenu::item { 42 | color: #f5f5f5; 43 | } 44 | 45 | QTabWidget::pane { 46 | border-top: 2px solid #C2C7CB; 47 | } 48 | 49 | QTabWidget::tab-bar { 50 | left: 5px; 51 | } 52 | 53 | QTabBar::tab { 54 | background: #d72020; 55 | border: 2px solid #c01e1e; 56 | border-top-left-radius: 4px; 57 | border-top-right-radius: 4px; 58 | min-width: 8ex; 59 | padding: 2px; 60 | color: #f5f5f5; 61 | } 62 | 63 | QTabBar::tab:hover { 64 | background: #e42323; 65 | } 66 | 67 | QTabBar::tab:selected { 68 | background: #e42323; 69 | } 70 | 71 | QTabBar::tab:!selected { 72 | margin-top: 2px; 73 | background: #d72020; 74 | } --------------------------------------------------------------------------------