├── .gitattributes
├── .gitignore
├── README.md
├── boorulist.json
├── builds
└── latest
│ ├── macos
│ └── QBooru.app
│ │ └── Contents
│ │ ├── Frameworks
│ │ ├── QtConcurrent.framework
│ │ │ ├── QtConcurrent
│ │ │ ├── Resources
│ │ │ └── Versions
│ │ │ │ ├── 5
│ │ │ │ ├── QtConcurrent
│ │ │ │ └── Resources
│ │ │ │ │ └── Info.plist
│ │ │ │ └── Current
│ │ ├── QtCore.framework
│ │ │ ├── QtCore
│ │ │ ├── Resources
│ │ │ └── Versions
│ │ │ │ ├── 5
│ │ │ │ ├── QtCore
│ │ │ │ └── Resources
│ │ │ │ │ └── Info.plist
│ │ │ │ └── Current
│ │ ├── QtDBus.framework
│ │ │ ├── QtDBus
│ │ │ ├── Resources
│ │ │ └── Versions
│ │ │ │ ├── 5
│ │ │ │ ├── QtDBus
│ │ │ │ └── Resources
│ │ │ │ │ └── Info.plist
│ │ │ │ └── Current
│ │ ├── QtGui.framework
│ │ │ ├── QtGui
│ │ │ ├── Resources
│ │ │ └── Versions
│ │ │ │ ├── 5
│ │ │ │ ├── QtGui
│ │ │ │ └── Resources
│ │ │ │ │ └── Info.plist
│ │ │ │ └── Current
│ │ ├── QtNetwork.framework
│ │ │ ├── QtNetwork
│ │ │ ├── Resources
│ │ │ └── Versions
│ │ │ │ ├── 5
│ │ │ │ ├── QtNetwork
│ │ │ │ └── Resources
│ │ │ │ │ └── Info.plist
│ │ │ │ └── Current
│ │ ├── QtPrintSupport.framework
│ │ │ ├── QtPrintSupport
│ │ │ ├── Resources
│ │ │ └── Versions
│ │ │ │ ├── 5
│ │ │ │ ├── QtPrintSupport
│ │ │ │ └── Resources
│ │ │ │ │ └── Info.plist
│ │ │ │ └── Current
│ │ └── QtWidgets.framework
│ │ │ ├── QtWidgets
│ │ │ ├── Resources
│ │ │ └── Versions
│ │ │ ├── 5
│ │ │ ├── QtWidgets
│ │ │ └── Resources
│ │ │ │ └── Info.plist
│ │ │ └── Current
│ │ ├── Info.plist
│ │ ├── MacOS
│ │ ├── QBooru
│ │ ├── QBooru.sh
│ │ └── conf
│ │ │ ├── boorulist.json
│ │ │ ├── changelog.html
│ │ │ ├── configuration.json
│ │ │ ├── derpibooruDefault.png
│ │ │ └── icon.ico
│ │ ├── PkgInfo
│ │ ├── PlugIns
│ │ ├── bearer
│ │ │ ├── libqcorewlanbearer.dylib
│ │ │ └── libqgenericbearer.dylib
│ │ ├── imageformats
│ │ │ ├── libqdds.dylib
│ │ │ ├── libqgif.dylib
│ │ │ ├── libqicns.dylib
│ │ │ ├── libqico.dylib
│ │ │ ├── libqjp2.dylib
│ │ │ ├── libqjpeg.dylib
│ │ │ ├── libqmng.dylib
│ │ │ ├── libqtga.dylib
│ │ │ ├── libqtiff.dylib
│ │ │ ├── libqwbmp.dylib
│ │ │ └── libqwebp.dylib
│ │ ├── platforms
│ │ │ └── libqcocoa.dylib
│ │ └── printsupport
│ │ │ └── libcocoaprintersupport.dylib
│ │ └── Resources
│ │ ├── icon.icns
│ │ └── qt.conf
│ └── windows
│ ├── QBooru.exe
│ └── conf
│ ├── boorulist.json
│ ├── changelog.html
│ ├── configuration.json
│ ├── derpibooruDefault.png
│ └── icon.ico
├── changelog.html
├── changelog.md
├── doc
└── uml
│ ├── class.wsd
│ └── class
│ ├── controller.wsd
│ ├── model.wsd
│ └── view.wsd
├── src
├── v2
│ ├── QBooru.pro
│ ├── const.h
│ ├── controller
│ │ ├── boorupixmapdownloader.cpp
│ │ ├── boorupixmapdownloader.h
│ │ ├── boorusdatabase.cpp
│ │ ├── boorusdatabase.h
│ │ ├── boorusearchengine.cpp
│ │ ├── boorusearchengine.h
│ │ ├── connectionmanager.cpp
│ │ ├── connectionmanager.h
│ │ ├── qconfigfile.cpp
│ │ ├── qconfigfile.h
│ │ ├── qsearchworker.cpp
│ │ └── qsearchworker.h
│ ├── empty.png
│ ├── json
│ │ ├── assertions.h
│ │ ├── autolink.h
│ │ ├── config.h
│ │ ├── features.h
│ │ ├── forwards.h
│ │ ├── json.h
│ │ ├── json_batchallocator.h
│ │ ├── json_internalarray.inl
│ │ ├── json_internalmap.inl
│ │ ├── json_reader.cpp
│ │ ├── json_tool.h
│ │ ├── json_value.cpp
│ │ ├── json_valueiterator.inl
│ │ ├── json_writer.cpp
│ │ ├── reader.h
│ │ ├── sconscript
│ │ ├── value.h
│ │ ├── version.h.in
│ │ └── writer.h
│ ├── main.cpp
│ ├── mainwidget.cpp
│ ├── mainwidget.h
│ ├── model
│ │ ├── api.cpp
│ │ ├── api.h
│ │ ├── boorupicture.cpp
│ │ ├── boorupicture.h
│ │ ├── boorusite.cpp
│ │ ├── boorusite.h
│ │ ├── jsonobject.cpp
│ │ └── jsonobject.h
│ ├── tests.cpp
│ ├── tests.h
│ ├── utils
│ │ ├── conversion.cpp
│ │ ├── conversion.h
│ │ ├── file.cpp
│ │ ├── file.h
│ │ ├── json.cpp
│ │ ├── json.h
│ │ ├── output.cpp
│ │ ├── output.h
│ │ ├── qnamredirect.cpp
│ │ └── qnamredirect.h
│ └── view
│ │ ├── clickablelabel.cpp
│ │ ├── clickablelabel.h
│ │ ├── qboorupicture.cpp
│ │ ├── qboorupicture.h
│ │ ├── qboorupictureinfowidget.cpp
│ │ ├── qboorupictureinfowidget.h
│ │ ├── qboorupictureviewer.cpp
│ │ ├── qboorupictureviewer.h
│ │ ├── qboorutab.cpp
│ │ ├── qboorutab.h
│ │ ├── qmaingrid.cpp
│ │ ├── qmaingrid.h
│ │ ├── qpageswitcher.cpp
│ │ ├── qpageswitcher.h
│ │ ├── qsearchwidget.cpp
│ │ └── qsearchwidget.h
└── viewer
│ ├── BooruHeaders
│ ├── booru_search_engine.cpp
│ ├── booru_search_engine.h
│ ├── boorutag.cpp
│ ├── boorutag.h
│ ├── boorutaglist.cpp
│ ├── boorutaglist.h
│ ├── generic_booru_image.cpp
│ ├── generic_booru_image.h
│ └── headers.h
│ ├── QBooru.pro
│ ├── QBooru.pro.user.6320f66
│ ├── QBooruTemplate.app
│ └── Contents
│ │ ├── Info.plist
│ │ ├── MacOS
│ │ └── QBooru.sh
│ │ ├── PkgInfo
│ │ └── _Info.plist
│ ├── Widget
│ ├── BooruSettingsWidgetClass.cpp
│ ├── BooruSettingsWidgetClass.h
│ ├── booruSettingsTabClass.cpp
│ ├── booruSettingsTabClass.h
│ ├── clickableLabel.cpp
│ ├── clickableLabel.h
│ ├── fullscreenImageTabClass.cpp
│ ├── fullscreenImageTabClass.h
│ ├── grabberwidget.cpp
│ ├── grabberwidget.h
│ ├── imageTabClass.cpp
│ ├── imageTabClass.h
│ ├── optionTabClass.cpp
│ ├── optionTabClass.h
│ ├── qdownloadwidget.cpp
│ ├── qdownloadwidget.h
│ ├── qstartupwidget.cpp
│ ├── qstartupwidget.h
│ ├── searchTabClass.cpp
│ ├── searchTabClass.h
│ ├── viewerTabClass.cpp
│ └── viewerTabClass.h
│ ├── Workers
│ ├── caching_thread.cpp
│ ├── caching_thread.h
│ ├── cookiejar.cpp
│ ├── cookiejar.h
│ ├── downloadworker.cpp
│ ├── downloadworker.h
│ ├── file_downloader.cpp
│ ├── file_downloader.h
│ ├── image_loading_thread.cpp
│ ├── image_loading_thread.h
│ ├── imagegrabber.cpp
│ ├── imagegrabber.h
│ ├── qnamredirect.cpp
│ ├── qnamredirect.h
│ ├── searchloggingworker.cpp
│ ├── searchloggingworker.h
│ ├── viewer_loading_thread.cpp
│ └── viewer_loading_thread.h
│ ├── classBooruSite.cpp
│ ├── classBooruSite.h
│ ├── config_file.cpp
│ ├── config_file.h
│ ├── constantes.h
│ ├── constantes_linux.h
│ ├── constantes_mac.h
│ ├── constantes_win.h
│ ├── derpibooruDefault.png
│ ├── fileutils.cpp
│ ├── fileutils.h
│ ├── fonctions
│ ├── fonctions.cpp
│ ├── fonctions.h
│ ├── fonctions_conversion.cpp
│ ├── fonctions_conversion.h
│ ├── fonctions_json.cpp
│ ├── fonctions_json.h
│ ├── fonctions_qt.cpp
│ └── fonctions_qt.h
│ ├── fonctions_all.h
│ ├── icon.icns
│ ├── icon.ico
│ ├── json
│ ├── assertions.h
│ ├── autolink.h
│ ├── config.h
│ ├── features.h
│ ├── forwards.h
│ ├── json.h
│ ├── json_batchallocator.h
│ ├── json_internalarray.inl
│ ├── json_internalmap.inl
│ ├── json_reader.cpp
│ ├── json_tool.h
│ ├── json_value.cpp
│ ├── json_valueiterator.inl
│ ├── json_writer.cpp
│ ├── reader.h
│ ├── sconscript
│ ├── value.h
│ ├── version.h.in
│ └── writer.h
│ ├── main.cpp
│ ├── myapp.rc
│ ├── widget.cpp
│ └── widget.h
└── versions.json
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # QBooru
2 |
3 | ## Summary
4 | QBooru is a lightweight Windows, Linux and MacOS client that allows users to see pictures from most booru sites, and download them, for example :
5 |
6 | - Gelbooru
7 | - Danbooru
8 | - Konachan
9 | - Yandere
10 | - Safebooru
11 | - Rule34
12 |
13 |
14 | At the moment, it supports 4 APIs :
15 |
16 | - Gelbooru
17 | - Danbooru 2
18 | - Moebooru
19 | - Derpibooru
20 |
21 |
22 | Searchs are done by the JSON APIs. Thumbnails are cached locally, and are re-used by the program if needed.
23 |
24 | ## Interface
25 | The current interface allows users to chose how many pictures they want, within 3-5 rows and 5-8 columns.
26 | The recommended size is 3*5, as it fits perfectly the smallest window size.
27 |
28 | Search tab example : http://puu.sh/cK0pj.jpg
29 |
30 | ## Configuration
31 | Users can change nearly all the parameters through the Option tab, or by editing the configuration.json file.
32 | Boorus can be added, edited, and deleted through the Booru tab in the software, but they can also be edited manually in the configuration file.
33 |
34 | ## Build instructions (Linux)
35 |
36 | - Clone the git repo
37 | - Install Qt and Qt creator
38 |
39 | - Pacman :
sudo pacman -S qt5 qtcreator
40 | - Yaourt :
yaourt -S qt5 qtcreator
41 |
42 | - Load the .pro file in QtCreator (Qt >= 5)
43 | - Put the now built executable in a folder with full R/W permissions
44 | - Run it
45 |
46 |
47 | ## Build instructions (MacOS)
48 |
49 | - Clone the git repo (Path shouldn't contain non-ASCII characters)
50 | - Install XCode from App Store
51 | - Install Qt
52 |
53 | - MacPorts :
sudo port install qt5
54 | - Homebrew :
brew install qt55
(Homebrew has bug with macdeployqt on Qt >= 5.6)
55 | - Also you can install Qt from official site
56 |
57 | - Make sure that qmake and macdeployqt is linked
58 | - Cd into
builds
directory
59 | - Run
qmake ../src/viewer/QBooru.pro && make && make clean
60 | - Put the now built executable in a folder with full R/W permissions
61 | - Run it
62 |
63 |
64 | ## Credits
65 | cdunn2001 : https://github.com/open-source-parsers/jsoncpp for making the JSON parser JsonCPP
66 |
--------------------------------------------------------------------------------
/boorulist.json:
--------------------------------------------------------------------------------
1 | {
2 | "boorus":
3 | [
4 | {
5 | "base_url" : "http://gelbooru.com",
6 | "name" : "Gelbooru",
7 | "siteTypeInt" : 1,
8 | "site_type_string" : "gelbooru"
9 | },
10 | {
11 | "base_url" : "http://safebooru.org",
12 | "name" : "Safebooru",
13 | "siteTypeInt" : 1,
14 | "site_type_string" : "gelbooru"
15 | },
16 | {
17 | "base_url" : "http://yande.re",
18 | "name" : "Yandere",
19 | "siteTypeInt" : 2,
20 | "site_type_string" : "moebooru"
21 | },
22 | {
23 | "base_url" : "http://konachan.com",
24 | "name" : "Konachan",
25 | "siteTypeInt" : 2,
26 | "site_type_string" : "moebooru"
27 | },
28 | {
29 | "base_url" : "http://rule34.xxx",
30 | "name" : "Rule34",
31 | "siteTypeInt" : 1,
32 | "site_type_string" : "gelbooru"
33 | },
34 | {
35 | "base_url" : "http://danbooru.donmai.us",
36 | "name" : "Danbooru",
37 | "siteTypeInt" : 3,
38 | "site_type_string" : "danbooru2"
39 | },
40 | {
41 | "base_url" : "http://e621.net",
42 | "name" : "E621",
43 | "siteTypeInt" : 4,
44 | "site_type_string" : "e621"
45 | }
46 |
47 | ]
48 | }
49 |
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtConcurrent.framework/QtConcurrent:
--------------------------------------------------------------------------------
1 | Versions/Current/QtConcurrent
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtConcurrent.framework/Resources:
--------------------------------------------------------------------------------
1 | Versions/Current/Resources
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtConcurrent.framework/Versions/5/QtConcurrent:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/Frameworks/QtConcurrent.framework/Versions/5/QtConcurrent
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtConcurrent.framework/Versions/5/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundlePackageType
6 | FMWK
7 | CFBundleShortVersionString
8 | 5.5
9 | CFBundleVersion
10 | 5.5.1
11 | CFBundleGetInfoString
12 | Created by Qt/QMake
13 | CFBundleSignature
14 | ????
15 | CFBundleExecutable
16 | QtConcurrent
17 | CFBundleIdentifier
18 | org.qt-project.QtConcurrent
19 | NOTE
20 | Please, do NOT change this file -- It was generated by Qt/QMake.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtConcurrent.framework/Versions/Current:
--------------------------------------------------------------------------------
1 | 5
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtCore.framework/QtCore:
--------------------------------------------------------------------------------
1 | Versions/Current/QtCore
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtCore.framework/Resources:
--------------------------------------------------------------------------------
1 | Versions/Current/Resources
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtCore.framework/Versions/5/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundlePackageType
6 | FMWK
7 | CFBundleShortVersionString
8 | 5.5
9 | CFBundleVersion
10 | 5.5.1
11 | CFBundleGetInfoString
12 | Created by Qt/QMake
13 | CFBundleSignature
14 | ????
15 | CFBundleExecutable
16 | QtCore
17 | CFBundleIdentifier
18 | org.qt-project.QtCore
19 | NOTE
20 | Please, do NOT change this file -- It was generated by Qt/QMake.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtCore.framework/Versions/Current:
--------------------------------------------------------------------------------
1 | 5
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtDBus.framework/QtDBus:
--------------------------------------------------------------------------------
1 | Versions/Current/QtDBus
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtDBus.framework/Resources:
--------------------------------------------------------------------------------
1 | Versions/Current/Resources
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtDBus.framework/Versions/5/QtDBus:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/Frameworks/QtDBus.framework/Versions/5/QtDBus
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtDBus.framework/Versions/5/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundlePackageType
6 | FMWK
7 | CFBundleShortVersionString
8 | 5.5
9 | CFBundleVersion
10 | 5.5.1
11 | CFBundleGetInfoString
12 | Created by Qt/QMake
13 | CFBundleSignature
14 | ????
15 | CFBundleExecutable
16 | QtDBus
17 | CFBundleIdentifier
18 | org.qt-project.QtDBus
19 | NOTE
20 | Please, do NOT change this file -- It was generated by Qt/QMake.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtDBus.framework/Versions/Current:
--------------------------------------------------------------------------------
1 | 5
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtGui.framework/QtGui:
--------------------------------------------------------------------------------
1 | Versions/Current/QtGui
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtGui.framework/Resources:
--------------------------------------------------------------------------------
1 | Versions/Current/Resources
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtGui.framework/Versions/5/QtGui:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/Frameworks/QtGui.framework/Versions/5/QtGui
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtGui.framework/Versions/5/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundlePackageType
6 | FMWK
7 | CFBundleShortVersionString
8 | 5.5
9 | CFBundleVersion
10 | 5.5.1
11 | CFBundleGetInfoString
12 | Created by Qt/QMake
13 | CFBundleSignature
14 | ????
15 | CFBundleExecutable
16 | QtGui
17 | CFBundleIdentifier
18 | org.qt-project.QtGui
19 | NOTE
20 | Please, do NOT change this file -- It was generated by Qt/QMake.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtGui.framework/Versions/Current:
--------------------------------------------------------------------------------
1 | 5
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtNetwork.framework/QtNetwork:
--------------------------------------------------------------------------------
1 | Versions/Current/QtNetwork
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtNetwork.framework/Resources:
--------------------------------------------------------------------------------
1 | Versions/Current/Resources
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtNetwork.framework/Versions/5/QtNetwork:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/Frameworks/QtNetwork.framework/Versions/5/QtNetwork
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtNetwork.framework/Versions/5/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundlePackageType
6 | FMWK
7 | CFBundleShortVersionString
8 | 5.5
9 | CFBundleVersion
10 | 5.5.1
11 | CFBundleGetInfoString
12 | Created by Qt/QMake
13 | CFBundleSignature
14 | ????
15 | CFBundleExecutable
16 | QtNetwork
17 | CFBundleIdentifier
18 | org.qt-project.QtNetwork
19 | NOTE
20 | Please, do NOT change this file -- It was generated by Qt/QMake.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtNetwork.framework/Versions/Current:
--------------------------------------------------------------------------------
1 | 5
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtPrintSupport.framework/QtPrintSupport:
--------------------------------------------------------------------------------
1 | Versions/Current/QtPrintSupport
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtPrintSupport.framework/Resources:
--------------------------------------------------------------------------------
1 | Versions/Current/Resources
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundlePackageType
6 | FMWK
7 | CFBundleShortVersionString
8 | 5.5
9 | CFBundleVersion
10 | 5.5.1
11 | CFBundleGetInfoString
12 | Created by Qt/QMake
13 | CFBundleSignature
14 | ????
15 | CFBundleExecutable
16 | QtPrintSupport
17 | CFBundleIdentifier
18 | org.qt-project.QtPrintSupport
19 | NOTE
20 | Please, do NOT change this file -- It was generated by Qt/QMake.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtPrintSupport.framework/Versions/Current:
--------------------------------------------------------------------------------
1 | 5
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtWidgets.framework/QtWidgets:
--------------------------------------------------------------------------------
1 | Versions/Current/QtWidgets
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtWidgets.framework/Resources:
--------------------------------------------------------------------------------
1 | Versions/Current/Resources
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtWidgets.framework/Versions/5/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundlePackageType
6 | FMWK
7 | CFBundleShortVersionString
8 | 5.5
9 | CFBundleVersion
10 | 5.5.1
11 | CFBundleGetInfoString
12 | Created by Qt/QMake
13 | CFBundleSignature
14 | ????
15 | CFBundleExecutable
16 | QtWidgets
17 | CFBundleIdentifier
18 | org.qt-project.QtWidgets
19 | NOTE
20 | Please, do NOT change this file -- It was generated by Qt/QMake.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Frameworks/QtWidgets.framework/Versions/Current:
--------------------------------------------------------------------------------
1 | 5
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSPrincipalClass
6 | NSApplication
7 | CFBundleIconFile
8 | icon.icns
9 | CFBundlePackageType
10 | APPL
11 | CFBundleGetInfoString
12 | Created by Qt/QMake
13 | CFBundleSignature
14 | ????
15 | CFBundleExecutable
16 | QBooru.sh
17 | CFBundleIdentifier
18 | com.FlorentUguet.QBooru
19 | NOTE
20 | This file was generated by Qt/QMake.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/MacOS/QBooru:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/MacOS/QBooru
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/MacOS/QBooru.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | cd "${0%/*}"
3 | ./QBooru
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/MacOS/conf/boorulist.json:
--------------------------------------------------------------------------------
1 | {
2 | "boorus":
3 | [
4 | {
5 | "base_url" : "http://gelbooru.com",
6 | "name" : "Gelbooru",
7 | "siteTypeInt" : 1,
8 | "site_type_string" : "gelbooru"
9 | },
10 | {
11 | "base_url" : "http://safebooru.org",
12 | "name" : "Safebooru",
13 | "siteTypeInt" : 1,
14 | "site_type_string" : "gelbooru"
15 | },
16 | {
17 | "base_url" : "http://yande.re",
18 | "name" : "Yandere",
19 | "siteTypeInt" : 2,
20 | "site_type_string" : "moebooru"
21 | },
22 | {
23 | "base_url" : "http://konachan.com",
24 | "name" : "Konachan",
25 | "siteTypeInt" : 2,
26 | "site_type_string" : "moebooru"
27 | },
28 | {
29 | "base_url" : "http://rule34.xxx",
30 | "name" : "Rule34",
31 | "siteTypeInt" : 1,
32 | "site_type_string" : "gelbooru"
33 | },
34 | {
35 | "base_url" : "http://danbooru.donmai.us",
36 | "name" : "Danbooru",
37 | "siteTypeInt" : 3,
38 | "site_type_string" : "danbooru2"
39 | },
40 | {
41 | "base_url" : "http://e621.net",
42 | "name" : "E621",
43 | "siteTypeInt" : 4,
44 | "site_type_string" : "e621"
45 | }
46 |
47 | ]
48 | }
49 |
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/MacOS/conf/changelog.html:
--------------------------------------------------------------------------------
1 |
2 | - 1.11.0.0
3 |
4 | - Please go to https://github.com/FlorentUguet/QBooru/raw/master/builds/archive/Qt%205.5/Qt%205.5.zip to download the required DLLs for that version
5 | - Built under Qt 5.5
6 | - Lots of small fixes
7 |
8 |
9 |
10 | - 1.10.5.1
11 |
12 | - Fixed a bug where the full URL of Gelbooru pictures wasn't found
13 |
14 |
15 | - 1.10.5
16 |
17 | - Picture-downloading functions are now in the BooruImage class
18 | - Search funcs merged in BooruSearchEngine class
19 |
20 |
21 |
22 | - 1.10.3
23 |
24 | - Added a list of preset boorus
25 | - Some fixes regarding the main fuctions
26 |
27 |
28 |
29 | - 1.10.0
30 |
31 | - All SDL functions removed
32 | - SDL.dll and SDL_image.dll removed from latest builds
33 |
34 |
35 |
36 | - 1.9.0
37 |
38 | - Gelbooru API changed from XML to JSON
39 | - You need to change the Gelbooru sites' settings with the following instructions, or refer to "search_file_path" and "search_url" in https://github.com/FlorentUguet/QBooru/releases/download/v1.9.0/configuration.json
40 | - Please change in your Gelbooru based website settings the search File extensions from XML to JSON
41 | - Please add to the search URL in your Gelbooru based website settings the term "&json=1"
42 |
43 |
44 |
45 | - 1.8.0
46 |
47 | - New updater
48 | - Lots of fixes on Gelbooru
49 | - Some fixes on the threaded parts
50 | - Lots of getter/setter fixes
51 |
52 |
53 |
54 | - 1.7.4
55 |
56 | - Threaded everything
57 | - Unified Boorus
58 | - Fixed all Danbooru issues
59 | - Cleaned up log outputs
60 | - Changed output method for caching
61 |
62 |
63 |
64 | - 1.5.0
65 |
66 | - Added Danbooru support
67 | - Lots of variable cleaning, enhancements with std::string
68 |
69 |
70 |
71 | - 1.4.0
72 |
73 | - Log behaviour enhanced
74 | - You can know define a default search rating
75 |
76 |
77 |
78 | - 1.3.0
79 |
80 | - Built under Qt 5.3
81 | - Added a check that generates a default config file if needed
82 |
83 |
84 | - 1.2.0
85 |
86 | - Started a new fully modulable way of adding Boorus
87 | - Lots of adds in Configuration files
88 | - More complete program log
89 |
90 |
91 |
92 | - 1.1.0
93 |
94 | - Added proper config file
95 | - Added proper log file
96 | - More complete program log
97 | - Better layout on search page
98 | - Viewer now adapt the medium preview with the window's size
99 | - Arrow keys support on Viewer Tab
100 |
101 |
102 |
103 | - 1.0.0
104 |
105 | - App is now QBooru :D
106 | - Completely reworked code. Went from QT Designer to code for UI
107 | - Added a fullscreen viewer on the Viewer Tab
108 | - Lightened the UI and the loading times
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/MacOS/conf/derpibooruDefault.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/MacOS/conf/derpibooruDefault.png
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/MacOS/conf/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/MacOS/conf/icon.ico
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PkgInfo:
--------------------------------------------------------------------------------
1 | APPL????
2 |
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/bearer/libqcorewlanbearer.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/bearer/libqcorewlanbearer.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/bearer/libqgenericbearer.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/bearer/libqgenericbearer.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqdds.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqdds.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqgif.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqgif.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqicns.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqicns.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqico.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqico.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqjp2.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqjp2.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqjpeg.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqjpeg.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqmng.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqmng.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqtga.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqtga.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqtiff.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqtiff.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqwbmp.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqwbmp.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqwebp.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/imageformats/libqwebp.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/platforms/libqcocoa.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/platforms/libqcocoa.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/PlugIns/printsupport/libcocoaprintersupport.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/PlugIns/printsupport/libcocoaprintersupport.dylib
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Resources/icon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/macos/QBooru.app/Contents/Resources/icon.icns
--------------------------------------------------------------------------------
/builds/latest/macos/QBooru.app/Contents/Resources/qt.conf:
--------------------------------------------------------------------------------
1 | [Paths]
2 | Plugins = PlugIns
3 | Imports = Resources/qml
4 | Qml2Imports = Resources/qml
5 |
--------------------------------------------------------------------------------
/builds/latest/windows/QBooru.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/windows/QBooru.exe
--------------------------------------------------------------------------------
/builds/latest/windows/conf/boorulist.json:
--------------------------------------------------------------------------------
1 | {
2 | "boorus":
3 | [
4 | {
5 | "base_url" : "http://gelbooru.com",
6 | "name" : "Gelbooru",
7 | "siteTypeInt" : 1,
8 | "site_type_string" : "gelbooru"
9 | },
10 | {
11 | "base_url" : "http://safebooru.org",
12 | "name" : "Safebooru",
13 | "siteTypeInt" : 1,
14 | "site_type_string" : "gelbooru"
15 | },
16 | {
17 | "base_url" : "http://yande.re",
18 | "name" : "Yandere",
19 | "siteTypeInt" : 2,
20 | "site_type_string" : "moebooru"
21 | },
22 | {
23 | "base_url" : "http://konachan.com",
24 | "name" : "Konachan",
25 | "siteTypeInt" : 2,
26 | "site_type_string" : "moebooru"
27 | },
28 | {
29 | "base_url" : "http://rule34.xxx",
30 | "name" : "Rule34",
31 | "siteTypeInt" : 1,
32 | "site_type_string" : "gelbooru"
33 | },
34 | {
35 | "base_url" : "http://danbooru.donmai.us",
36 | "name" : "Danbooru",
37 | "siteTypeInt" : 3,
38 | "site_type_string" : "danbooru2"
39 | },
40 | {
41 | "base_url" : "http://e621.net",
42 | "name" : "E621",
43 | "siteTypeInt" : 4,
44 | "site_type_string" : "e621"
45 | }
46 |
47 | ]
48 | }
49 |
--------------------------------------------------------------------------------
/builds/latest/windows/conf/changelog.html:
--------------------------------------------------------------------------------
1 |
2 | - 1.11.0.0
3 |
4 | - Please go to https://github.com/FlorentUguet/QBooru/raw/master/builds/archive/Qt%205.5/Qt%205.5.zip to download the required DLLs for that version
5 | - Built under Qt 5.5
6 | - Lots of small fixes
7 |
8 |
9 |
10 | - 1.10.5.1
11 |
12 | - Fixed a bug where the full URL of Gelbooru pictures wasn't found
13 |
14 |
15 | - 1.10.5
16 |
17 | - Picture-downloading functions are now in the BooruImage class
18 | - Search funcs merged in BooruSearchEngine class
19 |
20 |
21 |
22 | - 1.10.3
23 |
24 | - Added a list of preset boorus
25 | - Some fixes regarding the main fuctions
26 |
27 |
28 |
29 | - 1.10.0
30 |
31 | - All SDL functions removed
32 | - SDL.dll and SDL_image.dll removed from latest builds
33 |
34 |
35 |
36 | - 1.9.0
37 |
38 | - Gelbooru API changed from XML to JSON
39 | - You need to change the Gelbooru sites' settings with the following instructions, or refer to "search_file_path" and "search_url" in https://github.com/FlorentUguet/QBooru/releases/download/v1.9.0/configuration.json
40 | - Please change in your Gelbooru based website settings the search File extensions from XML to JSON
41 | - Please add to the search URL in your Gelbooru based website settings the term "&json=1"
42 |
43 |
44 |
45 | - 1.8.0
46 |
47 | - New updater
48 | - Lots of fixes on Gelbooru
49 | - Some fixes on the threaded parts
50 | - Lots of getter/setter fixes
51 |
52 |
53 |
54 | - 1.7.4
55 |
56 | - Threaded everything
57 | - Unified Boorus
58 | - Fixed all Danbooru issues
59 | - Cleaned up log outputs
60 | - Changed output method for caching
61 |
62 |
63 |
64 | - 1.5.0
65 |
66 | - Added Danbooru support
67 | - Lots of variable cleaning, enhancements with std::string
68 |
69 |
70 |
71 | - 1.4.0
72 |
73 | - Log behaviour enhanced
74 | - You can know define a default search rating
75 |
76 |
77 |
78 | - 1.3.0
79 |
80 | - Built under Qt 5.3
81 | - Added a check that generates a default config file if needed
82 |
83 |
84 | - 1.2.0
85 |
86 | - Started a new fully modulable way of adding Boorus
87 | - Lots of adds in Configuration files
88 | - More complete program log
89 |
90 |
91 |
92 | - 1.1.0
93 |
94 | - Added proper config file
95 | - Added proper log file
96 | - More complete program log
97 | - Better layout on search page
98 | - Viewer now adapt the medium preview with the window's size
99 | - Arrow keys support on Viewer Tab
100 |
101 |
102 |
103 | - 1.0.0
104 |
105 | - App is now QBooru :D
106 | - Completely reworked code. Went from QT Designer to code for UI
107 | - Added a fullscreen viewer on the Viewer Tab
108 | - Lightened the UI and the loading times
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/builds/latest/windows/conf/derpibooruDefault.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/windows/conf/derpibooruDefault.png
--------------------------------------------------------------------------------
/builds/latest/windows/conf/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/builds/latest/windows/conf/icon.ico
--------------------------------------------------------------------------------
/doc/uml/class.wsd:
--------------------------------------------------------------------------------
1 | @startuml class
2 | !include class/controller.wsd
3 | !include class/model.wsd
4 | !include class/view.wsd
5 |
6 | 'Controllers
7 | BooruPixmapDownloader o-- BooruPicture
8 | BoorusDatabase o-- BooruSite
9 | BooruSearchEngine o-- BooruSite
10 | QSearchWorker o-- BooruPicture
11 |
12 | 'Views
13 | QBooruPicture o-- BooruPicture
14 | QBooruPictureInfo o-- BooruPicture
15 | QMainGrid *-- BooruPixmapDownloader
16 | QSearchWidget *-- QSearchWorker
17 |
18 |
19 | @enduml
--------------------------------------------------------------------------------
/doc/uml/class/controller.wsd:
--------------------------------------------------------------------------------
1 | @startuml class-controller
2 |
3 | class BooruPixmapDownloader{
4 |
5 | }
6 |
7 | class BoorusDatabase{
8 |
9 | }
10 |
11 | class ConnectionManager{
12 |
13 | }
14 |
15 | class QSearchWorker{
16 |
17 | }
18 |
19 | class BooruSearchEngine{
20 |
21 | }
22 |
23 | QSearchWorker o-- ConnectionManager
24 | BooruPixmapDownloader o-- ConnectionManager
25 | QSearchWorker *-- BooruSearchEngine
26 |
27 |
28 | @enduml
--------------------------------------------------------------------------------
/doc/uml/class/model.wsd:
--------------------------------------------------------------------------------
1 | @startuml class-model
2 |
3 | class BooruPicture{
4 | int id
5 | string created_at
6 | string author
7 | string source
8 | int score
9 | int size
10 | vector taglist
11 | string tags
12 | int width
13 | int heught
14 | string[] urls
15 | string[] files
16 | string url_show
17 | string rating
18 | string extension
19 | BooruSite parent
20 | }
21 |
22 | class BooruSite{
23 | string name
24 | string main_url
25 | string search_url
26 | string show_url
27 | string login_url
28 | int start_page
29 | bool needs_login
30 | API api
31 | }
32 |
33 | class API{
34 | string name
35 | string main_url
36 | string search_url
37 | string show_url
38 | string login_url
39 | int start_page
40 | }
41 |
42 | BooruPicture o-- BooruSite
43 | BooruSite o-- API
44 |
45 | @enduml
46 |
--------------------------------------------------------------------------------
/doc/uml/class/view.wsd:
--------------------------------------------------------------------------------
1 | @startuml class-view
2 |
3 | class QBooru{
4 | --UI--
5 | --Data--
6 | }
7 |
8 | class QBooruPicture{
9 | --UI--
10 | --Data--
11 | }
12 |
13 | class QBooruPictureInfo{
14 | --UI--
15 | --Data--
16 | }
17 |
18 | class QBooruPictureViewer{
19 | --UI--
20 | --Data--
21 | }
22 |
23 | class QBooruTab{
24 | --UI--
25 | --Data--
26 | }
27 |
28 | class QMainGrid{
29 | --UI--
30 | --Data--
31 | }
32 |
33 | class QPageSwitcher{
34 | --UI--
35 | --Data--
36 | }
37 |
38 | class QSearchWidget{
39 | --UI--
40 | --Data--
41 | }
42 |
43 | QBooru *-- QBooruTab
44 | QBooru *-- QBooruPictureViewer
45 | QBooruPictureViewer *-- QBooruPictureInfo
46 | QBooruPictureViewer *-- QBooruPicture
47 |
48 | QBooruTab *-- QMainGrid
49 | QBooruTab *-- QSearchWidget
50 | QBooruTab *-- QPageSwitcher
51 |
52 | QMainGrid *-- QBooruPicture
53 |
54 | 'Included Classes
55 | @enduml
--------------------------------------------------------------------------------
/src/v2/QBooru.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2016-05-18T21:57:26
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core gui network
8 |
9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10 |
11 | TARGET = QBooru
12 | TEMPLATE = app
13 |
14 |
15 | SOURCES += main.cpp\
16 | mainwidget.cpp \
17 | model/boorupicture.cpp \
18 | controller/boorusearchengine.cpp \
19 | json/json_internalarray.inl \
20 | json/json_internalmap.inl \
21 | json/json_reader.cpp \
22 | json/json_value.cpp \
23 | json/json_valueiterator.inl \
24 | json/json_writer.cpp \
25 | model/api.cpp \
26 | model/boorusite.cpp \
27 | utils/json.cpp \
28 | utils/output.cpp \
29 | utils/file.cpp \
30 | model/jsonobject.cpp \
31 | controller/connectionmanager.cpp \
32 | tests.cpp \
33 | controller/boorusdatabase.cpp \
34 | view/qboorupicture.cpp \
35 | utils/conversion.cpp \
36 | view/qmaingrid.cpp \
37 | controller/boorupixmapdownloader.cpp \
38 | controller/qsearchworker.cpp \
39 | utils/qnamredirect.cpp \
40 | view/qsearchwidget.cpp \
41 | view/qboorupictureviewer.cpp \
42 | view/qboorupictureinfowidget.cpp \
43 | view/clickablelabel.cpp \
44 | view/qboorutab.cpp \
45 | view/qpageswitcher.cpp
46 |
47 | HEADERS += mainwidget.h \
48 | model/boorupicture.h \
49 | controller/boorusearchengine.h \
50 | json/assertions.h \
51 | json/autolink.h \
52 | json/config.h \
53 | json/features.h \
54 | json/forwards.h \
55 | json/json.h \
56 | json/json_batchallocator.h \
57 | json/json_tool.h \
58 | json/reader.h \
59 | json/value.h \
60 | json/version.h.in \
61 | json/writer.h \
62 | model/api.h \
63 | model/boorusite.h \
64 | utils/json.h \
65 | utils/output.h \
66 | utils/file.h \
67 | model/jsonobject.h \
68 | controller/connectionmanager.h \
69 | tests.h \
70 | controller/boorusdatabase.h \
71 | view/qboorupicture.h \
72 | utils/conversion.h \
73 | view/qmaingrid.h \
74 | controller/boorupixmapdownloader.h \
75 | const.h \
76 | controller/qsearchworker.h \
77 | utils/qnamredirect.h \
78 | view/qsearchwidget.h \
79 | view/qboorupictureviewer.h \
80 | view/qboorupictureinfowidget.h \
81 | view/clickablelabel.h \
82 | view/qboorutab.h \
83 | view/qpageswitcher.h
84 |
85 | DISTFILES += \
86 | json/sconscript \
87 | config/config.ini
88 |
89 | macx { # Mac OS
90 | CONFIG += c++11
91 | CONFIG -= app_bundle
92 | }
93 |
--------------------------------------------------------------------------------
/src/v2/const.h:
--------------------------------------------------------------------------------
1 | #ifndef CONST_H
2 | #define CONST_H
3 |
4 | #define PATH_CACHE "cache/"
5 |
6 | #endif // CONST_H
7 |
--------------------------------------------------------------------------------
/src/v2/controller/boorupixmapdownloader.cpp:
--------------------------------------------------------------------------------
1 | #include "boorupixmapdownloader.h"
2 |
3 | #include "model/boorupicture.h"
4 | #include "controller/connectionmanager.h"
5 |
6 | BooruPixmapDownloader::BooruPixmapDownloader(BooruPicture* pic, bool overwrite, QObject *parent) : QObject(parent)
7 | {
8 | this->url = QString::fromStdString(pic->getThumbnailUrl());
9 | this->path = QString::fromStdString(pic->getThumbnailPath());
10 | this->id = pic->getID();
11 | this->overwrite = overwrite;
12 | }
13 |
14 | BooruPixmapDownloader::BooruPixmapDownloader(QString url, QString path, bool overwrite, QObject *parent) : QObject(parent)
15 | {
16 | this->url = url;
17 | this->path = path;
18 | id = 0;
19 | this->overwrite = overwrite;
20 | }
21 |
22 | BooruPixmapDownloader::BooruPixmapDownloader(BooruPicture* pic, int type, bool overwrite, QObject *parent) : QObject(parent)
23 | {
24 | this->url = QString::fromStdString(pic->getURL(type));
25 | this->path = QString::fromStdString(pic->getFile(type));
26 | id = pic->getID();
27 | this->overwrite = overwrite;
28 | }
29 |
30 | void BooruPixmapDownloader::process()
31 | {
32 | ConnectionManager::downloadFile(this->url,this->path,this->overwrite);
33 | QPixmap p(this->path);
34 |
35 | emit pixmapLoaded(p);
36 | emit finished();
37 | }
38 |
--------------------------------------------------------------------------------
/src/v2/controller/boorupixmapdownloader.h:
--------------------------------------------------------------------------------
1 | #ifndef BOORUPIXMAPDOWNLOADER_H
2 | #define BOORUPIXMAPDOWNLOADER_H
3 |
4 | #include
5 | #include
6 |
7 | class Connectionmanager;
8 | class BooruPicture;
9 |
10 | class BooruPixmapDownloader : public QObject
11 | {
12 | Q_OBJECT
13 | public:
14 | BooruPixmapDownloader(BooruPicture* pic, bool overwrite = false, QObject *parent = nullptr);
15 | BooruPixmapDownloader(QString url, QString path, bool overwrite = false, QObject *parent = nullptr);
16 | BooruPixmapDownloader(BooruPicture* pic, int type, bool overwrite = false, QObject *parent = nullptr);
17 |
18 | signals:
19 | void pixmapLoaded(QPixmap pixmap);
20 | void finished();
21 |
22 | public slots:
23 | void process();
24 |
25 | private:
26 | QString url;
27 | QString path;
28 | int id;
29 | bool overwrite;
30 | };
31 |
32 | #endif // BOORUPIXMAPDOWNLOADER_H
33 |
--------------------------------------------------------------------------------
/src/v2/controller/boorusdatabase.cpp:
--------------------------------------------------------------------------------
1 | #include "boorusdatabase.h"
2 |
3 | BoorusDatabase::BoorusDatabase()
4 | {
5 | settings = new QSettings(QString(DB_FILE),QSettings::IniFormat);
6 | }
7 |
8 | void BoorusDatabase::addBooru(BooruSite* booru)
9 | {
10 | settings->beginGroup(booru->getName().c_str());
11 | settings->setValue("url_main",booru->getMainUrl().c_str());
12 | settings->setValue("url_login",booru->getLoginUrl().c_str());
13 | settings->setValue("url_search",booru->getSearchUrl().c_str());
14 | settings->setValue("url_show",booru->getShowUrl().c_str());
15 | settings->setValue("api_id",booru->getAPI()->getID());
16 | settings->setValue("login_required",booru->needsLogin());
17 | settings->endGroup();
18 | }
19 |
20 | BooruSite* BoorusDatabase::loadFromSettings(QString name)
21 | {
22 | //qDebug() << "Loading booru" << name;
23 |
24 | QString url_main = settings->value(name + "/url_main").toString();
25 | QString url_login = settings->value(name + "/url_login").toString();
26 | QString url_search = settings->value(name + "/url_search").toString();
27 | QString url_show = settings->value(name + "/url_show").toString();
28 | int api_id = settings->value(name + "/api_id").toInt();
29 | bool needsLogin = settings->value(name + "/login_required").toBool();
30 |
31 | return new BooruSite(name.toStdString(),
32 | API::getAPIFromID(api_id),
33 | url_main.toStdString(),
34 | url_search.toStdString(),
35 | url_show.toStdString(),
36 | url_login.toStdString(),
37 | needsLogin);
38 | }
39 |
40 | BooruSite* BoorusDatabase::loadBooru(int i)
41 | {
42 | return loadBoorus().at(i);
43 | }
44 |
45 | std::vector BoorusDatabase::loadBoorus()
46 | {
47 | //qDebug() << settings->allKeys();
48 |
49 | QStringList booru_names = settings->childGroups();
50 | std::vector sites;
51 |
52 | for(int i=0;i
5 | #include
6 | #include
7 |
8 | #include "../model/boorusite.h"
9 |
10 | #define DB_FILE "boorus.ini"
11 |
12 | class BoorusDatabase
13 | {
14 | public:
15 | BoorusDatabase();
16 | void addBooru(BooruSite* booru);
17 |
18 | BooruSite* loadFromSettings(QString name);
19 | BooruSite* loadBooru(int i);
20 | std::vector loadBoorus();
21 |
22 | private:
23 | QSettings *settings;
24 | };
25 |
26 | #endif // BOORUSDATABASE_H
27 |
--------------------------------------------------------------------------------
/src/v2/controller/boorusearchengine.cpp:
--------------------------------------------------------------------------------
1 | #include "boorusearchengine.h"
2 |
3 | BooruSearchEngine::BooruSearchEngine(BooruSite *parent)
4 | {
5 | this->page = 0;
6 | this->limit = 15;
7 | this->tags = "";
8 | this->parent = parent;
9 | }
10 |
11 | QString BooruSearchEngine::generateRequest(QString tags, int page, int limit)
12 | {
13 | return QString::fromStdString(this->parent->getSearchUrl()).arg(tags, QString::number(page), QString::number(limit));
14 | }
15 |
16 | vector BooruSearchEngine::search(QString tags)
17 | {
18 | set(tags);
19 | return search();
20 | }
21 |
22 | vector BooruSearchEngine::search(int page)
23 | {
24 | set(page);
25 | return search();
26 | }
27 |
28 | vector BooruSearchEngine::search(QString tags, int page)
29 | {
30 | set(tags,page);
31 | return search();
32 | }
33 |
34 | vector BooruSearchEngine::search(QString tags, int page, int limit)
35 | {
36 | set(tags,page,limit);
37 | return search();
38 | }
39 |
40 | vector BooruSearchEngine::search()
41 | {
42 | //Builds the URL from the locally stored elements
43 | QString url = generateRequest(tags, page, limit);
44 | outputInfo(L_DEBUG,"Querying " + url.toStdString());
45 |
46 | //Queries the remote file and parses it
47 | QNetworkReply *reply = ConnectionManager::execGetRequest(QUrl(url));
48 | QString json = QString(reply->readAll());
49 |
50 | //Deletes the replie's pointer to prevent memory leaks
51 | delete reply;
52 |
53 | return parse(json);
54 | }
55 |
56 | vector BooruSearchEngine::parse(QString data)
57 | {
58 | outputInfo(L_DEBUG,"Parsing JSON");
59 | Json::Value root = loadJSONString(data.toStdString());
60 | vector pictures;
61 |
62 | int size = 0;
63 |
64 | switch(parent->getAPI()->getID()){
65 | case ID_MOEBOORU:
66 | size = root["posts"].size();
67 | for(int i=0;itags = tags;
91 | }
92 |
93 | void BooruSearchEngine::set(int page)
94 | {
95 | this->page = page;
96 | }
97 |
98 | void BooruSearchEngine::set(QString tags, int page)
99 | {
100 | this->tags = tags;
101 | this->page = page;
102 | }
103 |
104 | void BooruSearchEngine::set(QString tags, int page, int limit)
105 | {
106 | this->tags = tags;
107 | this->page = page;
108 | this->limit = limit;
109 | }
110 |
--------------------------------------------------------------------------------
/src/v2/controller/boorusearchengine.h:
--------------------------------------------------------------------------------
1 | #ifndef BOORUSEARCHENGINE_H
2 | #define BOORUSEARCHENGINE_H
3 |
4 | #include
5 |
6 | #include "connectionmanager.h"
7 |
8 | #include "../model/boorupicture.h"
9 | #include "../model/boorusite.h"
10 | #include "../utils/json.h"
11 | #include "../utils/output.h"
12 |
13 | enum Ratings{
14 | RATING_ALL = 0,
15 | RATING_SAFE,
16 | RATING_QUESTIONNABLE,
17 | RATING_EXPLICIT,
18 | RATING_LIST_END
19 | };
20 |
21 | class BooruSearchEngine
22 | {
23 | public:
24 | BooruSearchEngine(BooruSite* parent);
25 |
26 | QString generateRequest(QString tags, int page, int limit);
27 |
28 | vector search(QString tags);
29 | vector search(int page);
30 | vector search(QString tags, int page);
31 | vector search(QString tags, int page, int limit);
32 | vector search();
33 |
34 | void set(QString tags);
35 | void set(int page);
36 | void set(QString tags, int page);
37 | void set(QString tags, int page, int limit);
38 |
39 | vector parse(QString data);
40 |
41 | private:
42 | QString tags;
43 | int page;
44 | int limit;
45 | BooruSite* parent;
46 | };
47 |
48 | #endif // BOORUSEARCHENGINE_H
49 |
--------------------------------------------------------------------------------
/src/v2/controller/connectionmanager.h:
--------------------------------------------------------------------------------
1 | #ifndef CONNECTIONMANAGER_H
2 | #define CONNECTIONMANAGER_H
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 | #include
16 | #include
17 |
18 | #include "utils/file.h"
19 | #include "utils/output.h"
20 | #include
21 | #include
22 | #include "utils/qnamredirect.h"
23 |
24 | enum ReqType{
25 | GET = 0,
26 | POST
27 | };
28 |
29 | class ConnectionManager
30 | {
31 | public:
32 | ConnectionManager();
33 |
34 | static QList getLoginCookie(std::string url, std::string user, std::string pass);
35 | static QList getLoginCookie(QString url, QString user, QString pass);
36 |
37 | static void downloadFile(QString url, QString path, bool overwrite = false);
38 | static void downloadFile(QUrl url, QString path, bool overwrite = false);
39 |
40 | static QNetworkReply* execPostRequest(QUrl url, QUrlQuery *data = 0);
41 | static QNetworkReply* execGetRequest(QUrl url, QUrlQuery *data = 0);
42 | static QNetworkReply* execRequest(QUrl url, ReqType type = GET, QUrlQuery *data = 0);
43 |
44 | static QUrl findRedirection(QUrl url);
45 |
46 | private:
47 | };
48 |
49 | #endif // CONNECTIONMANAGER_H
50 |
--------------------------------------------------------------------------------
/src/v2/controller/qconfigfile.cpp:
--------------------------------------------------------------------------------
1 | #include "qconfigfile.h"
2 |
3 | QConfigFile::QConfigFile(QObject *parent) : QObject(parent)
4 | {
5 | settings = new QSettings(QString(CONFIG_FILE),QSettings::IniFormat);
6 |
7 | if(!fexists(CONFIG_FILE))
8 | {
9 | initialize();
10 | }
11 |
12 | load();
13 |
14 | }
15 |
16 | void QConfigFile::initialize()
17 | {
18 | /* Display*/
19 | window_h = 768;
20 | window_w = 1024;
21 | pictures_x = 5;
22 | pictures_y = 3;
23 | }
24 |
25 | void QConfigFile::load()
26 | {
27 | window_h = settings->value("Display/windiw_h").toInt();
28 | window_w = settings->value("Display/window_w").toInt();
29 | pictures_x = settings->value("Display/pictures_x").toInt();
30 | pictures_y = settings->value("Display.pictures_y").toInt();
31 | }
32 |
33 | void QConfigFile::save()
34 | {
35 | /* Display*/
36 | settings->beginGroup("Display");
37 | settings->setValue("window_h",window_h);
38 | settings->setValue("window_w",window_w);
39 | settings->setValue("pictures_x",pictures_x);
40 | settings->setValue("pictures_y",pictures_y);
41 | settings->endGroup();
42 | }
43 |
44 | int QConfigFile::getPicturesX()
45 | {
46 | return this->pictures_x;
47 | }
48 |
49 | int QConfigFile::getPicturesY()
50 | {
51 | return this->pictures_y;
52 | }
53 |
54 | int QConfigFile::getWindowH()
55 | {
56 | return this->window_h;
57 | }
58 |
59 | int QConfigFile::getWindowW()
60 | {
61 | return this->window_w;
62 | }
63 |
--------------------------------------------------------------------------------
/src/v2/controller/qconfigfile.h:
--------------------------------------------------------------------------------
1 | #ifndef QCONFIGFILE_H
2 | #define QCONFIGFILE_H
3 |
4 | #define CONFIG_FILE "config.ini"
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | #include "utils/file.h"
12 |
13 | class QConfigFile : public QObject
14 | {
15 | Q_OBJECT
16 | public:
17 | QConfigFile(QObject *parent = 0);
18 | void initialize();
19 |
20 | void load();
21 | void save();
22 |
23 | int getPicturesX();
24 | int getPicturesY();
25 | int getWindowH();
26 | int getWindowW();
27 |
28 |
29 | signals:
30 |
31 | public slots:
32 |
33 | private:
34 | QSettings *settings;
35 | int window_h;
36 | int window_w;
37 |
38 | int pictures_x;
39 | int pictures_y;
40 |
41 | };
42 |
43 | #endif // QCONFIGFILE_H
44 |
--------------------------------------------------------------------------------
/src/v2/controller/qsearchworker.cpp:
--------------------------------------------------------------------------------
1 | #include "qsearchworker.h"
2 |
3 | QSearchWorker::QSearchWorker(BooruSearchEngine* engine, QObject *parent) : QObject(parent)
4 | {
5 | this->engine = engine;
6 | }
7 |
8 |
9 | void QSearchWorker::process()
10 | {
11 | std::vector pictures = engine->search();
12 |
13 | emit results(QVector::fromStdVector(pictures));
14 | emit finished();
15 | }
16 |
--------------------------------------------------------------------------------
/src/v2/controller/qsearchworker.h:
--------------------------------------------------------------------------------
1 | #ifndef QSEARCHWORKER_H
2 | #define QSEARCHWORKER_H
3 |
4 | #include
5 | #include
6 |
7 | #include "controller/boorusearchengine.h"
8 |
9 | class QSearchWorker : public QObject
10 | {
11 | Q_OBJECT
12 | public:
13 | QSearchWorker(BooruSearchEngine* engine, QObject *parent=0);
14 |
15 | signals:
16 | void results(QVector);
17 | void finished();
18 |
19 | public slots:
20 | void process();
21 |
22 | private:
23 | BooruSearchEngine* engine;
24 | };
25 |
26 | #endif // QSEARCHWORKER_H
27 |
--------------------------------------------------------------------------------
/src/v2/empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FuSoftware/QBooru/184aba3b6053e4c37808ed32e4c185ffd095f707/src/v2/empty.png
--------------------------------------------------------------------------------
/src/v2/json/assertions.h:
--------------------------------------------------------------------------------
1 | // Copyright 2007-2010 Baptiste Lepilleur
2 | // Distributed under MIT license, or public domain if desired and
3 | // recognized in your jurisdiction.
4 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5 |
6 | #ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
7 | #define CPPTL_JSON_ASSERTIONS_H_INCLUDED
8 |
9 | #include
10 |
11 | #if !defined(JSON_IS_AMALGAMATION)
12 | #include "config.h"
13 | #endif // if !defined(JSON_IS_AMALGAMATION)
14 |
15 | #if JSON_USE_EXCEPTION
16 | #include
17 | #define JSON_ASSERT(condition) \
18 | assert(condition); // @todo <= change this into an exception throw
19 | #define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message);
20 | #else // JSON_USE_EXCEPTION
21 | #define JSON_ASSERT(condition) assert(condition);
22 |
23 | // The call to assert() will show the failure message in debug builds. In
24 | // release bugs we write to invalid memory in order to crash hard, so that a
25 | // debugger or crash reporter gets the chance to take over. We still call exit()
26 | // afterward in order to tell the compiler that this macro doesn't return.
27 | #define JSON_FAIL_MESSAGE(message) \
28 | { \
29 | assert(false &&message); \
30 | strcpy(reinterpret_cast(666), message); \
31 | exit(123); \
32 | }
33 |
34 | #endif
35 |
36 | #define JSON_ASSERT_MESSAGE(condition, message) \
37 | if (!(condition)) { \
38 | JSON_FAIL_MESSAGE(message) \
39 | }
40 |
41 | #endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
42 |
--------------------------------------------------------------------------------
/src/v2/json/autolink.h:
--------------------------------------------------------------------------------
1 | // Copyright 2007-2010 Baptiste Lepilleur
2 | // Distributed under MIT license, or public domain if desired and
3 | // recognized in your jurisdiction.
4 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5 |
6 | #ifndef JSON_AUTOLINK_H_INCLUDED
7 | #define JSON_AUTOLINK_H_INCLUDED
8 |
9 | #include "config.h"
10 |
11 | #ifdef JSON_IN_CPPTL
12 | #include
13 | #endif
14 |
15 | #if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && \
16 | !defined(JSON_IN_CPPTL)
17 | #define CPPTL_AUTOLINK_NAME "json"
18 | #undef CPPTL_AUTOLINK_DLL
19 | #ifdef JSON_DLL
20 | #define CPPTL_AUTOLINK_DLL
21 | #endif
22 | #include "autolink.h"
23 | #endif
24 |
25 | #endif // JSON_AUTOLINK_H_INCLUDED
26 |
--------------------------------------------------------------------------------
/src/v2/json/features.h:
--------------------------------------------------------------------------------
1 | // Copyright 2007-2010 Baptiste Lepilleur
2 | // Distributed under MIT license, or public domain if desired and
3 | // recognized in your jurisdiction.
4 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5 |
6 | #ifndef CPPTL_JSON_FEATURES_H_INCLUDED
7 | #define CPPTL_JSON_FEATURES_H_INCLUDED
8 |
9 | #if !defined(JSON_IS_AMALGAMATION)
10 | #include "forwards.h"
11 | #endif // if !defined(JSON_IS_AMALGAMATION)
12 |
13 | namespace Json {
14 |
15 | /** \brief Configuration passed to reader and writer.
16 | * This configuration object can be used to force the Reader or Writer
17 | * to behave in a standard conforming way.
18 | */
19 | class JSON_API Features {
20 | public:
21 | /** \brief A configuration that allows all features and assumes all strings
22 | * are UTF-8.
23 | * - C & C++ comments are allowed
24 | * - Root object can be any JSON value
25 | * - Assumes Value strings are encoded in UTF-8
26 | */
27 | static Features all();
28 |
29 | /** \brief A configuration that is strictly compatible with the JSON
30 | * specification.
31 | * - Comments are forbidden.
32 | * - Root object must be either an array or an object value.
33 | * - Assumes Value strings are encoded in UTF-8
34 | */
35 | static Features strictMode();
36 |
37 | /** \brief Initialize the configuration like JsonConfig::allFeatures;
38 | */
39 | Features();
40 |
41 | /// \c true if comments are allowed. Default: \c true.
42 | bool allowComments_;
43 |
44 | /// \c true if root must be either an array or an object value. Default: \c
45 | /// false.
46 | bool strictRoot_;
47 |
48 | /// \c true if dropped null placeholders are allowed. Default: \c false.
49 | bool allowDroppedNullPlaceholders_;
50 |
51 | /// \c true if numeric object key are allowed. Default: \c false.
52 | bool allowNumericKeys_;
53 | };
54 |
55 | } // namespace Json
56 |
57 | #endif // CPPTL_JSON_FEATURES_H_INCLUDED
58 |
--------------------------------------------------------------------------------
/src/v2/json/forwards.h:
--------------------------------------------------------------------------------
1 | // Copyright 2007-2010 Baptiste Lepilleur
2 | // Distributed under MIT license, or public domain if desired and
3 | // recognized in your jurisdiction.
4 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5 |
6 | #ifndef JSON_FORWARDS_H_INCLUDED
7 | #define JSON_FORWARDS_H_INCLUDED
8 |
9 | #if !defined(JSON_IS_AMALGAMATION)
10 | #include "config.h"
11 | #endif // if !defined(JSON_IS_AMALGAMATION)
12 |
13 | namespace Json {
14 |
15 | // writer.h
16 | class FastWriter;
17 | class StyledWriter;
18 |
19 | // reader.h
20 | class Reader;
21 |
22 | // features.h
23 | class Features;
24 |
25 | // value.h
26 | typedef unsigned int ArrayIndex;
27 | class StaticString;
28 | class Path;
29 | class PathArgument;
30 | class Value;
31 | class ValueIteratorBase;
32 | class ValueIterator;
33 | class ValueConstIterator;
34 | #ifdef JSON_VALUE_USE_INTERNAL_MAP
35 | class ValueMapAllocator;
36 | class ValueInternalLink;
37 | class ValueInternalArray;
38 | class ValueInternalMap;
39 | #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
40 |
41 | } // namespace Json
42 |
43 | #endif // JSON_FORWARDS_H_INCLUDED
44 |
--------------------------------------------------------------------------------
/src/v2/json/json.h:
--------------------------------------------------------------------------------
1 | // Copyright 2007-2010 Baptiste Lepilleur
2 | // Distributed under MIT license, or public domain if desired and
3 | // recognized in your jurisdiction.
4 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5 |
6 | #ifndef JSON_JSON_H_INCLUDED
7 | #define JSON_JSON_H_INCLUDED
8 |
9 | #include "autolink.h"
10 | #include "value.h"
11 | #include "reader.h"
12 | #include "writer.h"
13 | #include "features.h"
14 |
15 | #endif // JSON_JSON_H_INCLUDED
16 |
--------------------------------------------------------------------------------
/src/v2/json/json_tool.h:
--------------------------------------------------------------------------------
1 | // Copyright 2007-2010 Baptiste Lepilleur
2 | // Distributed under MIT license, or public domain if desired and
3 | // recognized in your jurisdiction.
4 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5 |
6 | #ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
7 | #define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
8 |
9 | /* This header provides common string manipulation support, such as UTF-8,
10 | * portable conversion from/to string...
11 | *
12 | * It is an internal header that must not be exposed.
13 | */
14 |
15 | namespace Json {
16 |
17 | /// Converts a unicode code-point to UTF-8.
18 | static inline std::string codePointToUTF8(unsigned int cp) {
19 | std::string result;
20 |
21 | // based on description from http://en.wikipedia.org/wiki/UTF-8
22 |
23 | if (cp <= 0x7f) {
24 | result.resize(1);
25 | result[0] = static_cast(cp);
26 | } else if (cp <= 0x7FF) {
27 | result.resize(2);
28 | result[1] = static_cast(0x80 | (0x3f & cp));
29 | result[0] = static_cast(0xC0 | (0x1f & (cp >> 6)));
30 | } else if (cp <= 0xFFFF) {
31 | result.resize(3);
32 | result[2] = static_cast(0x80 | (0x3f & cp));
33 | result[1] = 0x80 | static_cast((0x3f & (cp >> 6)));
34 | result[0] = 0xE0 | static_cast((0xf & (cp >> 12)));
35 | } else if (cp <= 0x10FFFF) {
36 | result.resize(4);
37 | result[3] = static_cast(0x80 | (0x3f & cp));
38 | result[2] = static_cast(0x80 | (0x3f & (cp >> 6)));
39 | result[1] = static_cast(0x80 | (0x3f & (cp >> 12)));
40 | result[0] = static_cast(0xF0 | (0x7 & (cp >> 18)));
41 | }
42 |
43 | return result;
44 | }
45 |
46 | /// Returns true if ch is a control character (in range [0,32[).
47 | static inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }
48 |
49 | enum {
50 | /// Constant that specify the size of the buffer that must be passed to
51 | /// uintToString.
52 | uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1
53 | };
54 |
55 | // Defines a char buffer for use with uintToString().
56 | typedef char UIntToStringBuffer[uintToStringBufferSize];
57 |
58 | /** Converts an unsigned integer to string.
59 | * @param value Unsigned interger to convert to string
60 | * @param current Input/Output string buffer.
61 | * Must have at least uintToStringBufferSize chars free.
62 | */
63 | static inline void uintToString(LargestUInt value, char *¤t) {
64 | *--current = 0;
65 | do {
66 | *--current = char(value % 10) + '0';
67 | value /= 10;
68 | } while (value != 0);
69 | }
70 |
71 | /** Change ',' to '.' everywhere in buffer.
72 | *
73 | * We had a sophisticated way, but it did not work in WinCE.
74 | * @see https://github.com/open-source-parsers/jsoncpp/pull/9
75 | */
76 | static inline void fixNumericLocale(char* begin, char* end) {
77 | while (begin < end) {
78 | if (*begin == ',') {
79 | *begin = '.';
80 | }
81 | ++begin;
82 | }
83 | }
84 |
85 | } // namespace Json {
86 |
87 | #endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
88 | // vim: et ts=2 sts=2 sw=2 tw=0
89 |
--------------------------------------------------------------------------------
/src/v2/json/sconscript:
--------------------------------------------------------------------------------
1 | Import( 'env buildLibrary' )
2 |
3 | buildLibrary( env, Split( """
4 | json_reader.cpp
5 | json_value.cpp
6 | json_writer.cpp
7 | """ ),
8 | 'json' )
9 |
--------------------------------------------------------------------------------
/src/v2/json/version.h.in:
--------------------------------------------------------------------------------
1 | // DO NOT EDIT. This file is generated by CMake from "version"
2 | // and "version.h.in" files.
3 | // Run CMake configure step to update it.
4 | #ifndef JSON_VERSION_H_INCLUDED
5 | # define JSON_VERSION_H_INCLUDED
6 |
7 | # define JSONCPP_VERSION_STRING "@JSONCPP_VERSION@"
8 | # define JSONCPP_VERSION_MAJOR @JSONCPP_VERSION_MAJOR@
9 | # define JSONCPP_VERSION_MINOR @JSONCPP_VERSION_MINOR@
10 | # define JSONCPP_VERSION_PATCH @JSONCPP_VERSION_PATCH@
11 | # define JSONCPP_VERSION_QUALIFIER @JSONCPP_VERSION_QUALIFIER@
12 | # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
13 |
14 | #endif // JSON_VERSION_H_INCLUDED
15 |
--------------------------------------------------------------------------------
/src/v2/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "tests.h"
5 | #include "mainwidget.h"
6 |
7 | int main(int argc, char *argv[])
8 | {
9 | QApplication a(argc, argv);
10 |
11 | test_sample_boorus();
12 |
13 | return a.exec();
14 | }
15 |
--------------------------------------------------------------------------------
/src/v2/mainwidget.cpp:
--------------------------------------------------------------------------------
1 | #include "mainwidget.h"
2 |
3 | #include "view/qboorutab.h"
4 | #include "view/qboorupictureviewer.h"
5 |
6 | MainWidget::MainWidget(QWidget *parent): QWidget(parent)
7 | {
8 | loadUI();
9 | }
10 |
11 | MainWidget::~MainWidget()
12 | {
13 |
14 | }
15 |
16 | void MainWidget::loadUI()
17 | {
18 | this->tab_widget = new QTabWidget(this);
19 | this->viewer = new QBooruPictureViewer(this);
20 |
21 | QVBoxLayout *l = new QVBoxLayout;
22 | l->addWidget(tab_widget);
23 | this->setLayout(l);
24 | }
25 |
26 | void MainWidget::loadBoorus(QVector sites)
27 | {
28 | for(int i=0;iaddBooru(sites[i]);
31 | }
32 |
33 | this->reorderTabs();
34 | }
35 |
36 | void MainWidget::addBooru(BooruSite* site)
37 | {
38 | QBooruTab *tab = new QBooruTab(site, this);
39 | this->tabs.push_back(tab);
40 |
41 | QObject::connect(tab, SIGNAL(pictureClicked(BooruPicture*)), this->viewer, SLOT(loadPicture(BooruPicture*)));
42 | QObject::connect(tab, SIGNAL(pictureClicked(BooruPicture*)), this, SLOT(openViewer()));
43 | }
44 |
45 | void MainWidget::reorderTabs()
46 | {
47 | this->tab_widget->clear();
48 |
49 | //Booru Tabs
50 | for(int i=0;itabs.size();i++)
51 | {
52 | this->tab_widget->addTab(this->tabs[i], this->tabs[i]->getTitle());
53 | }
54 |
55 | //Viewer
56 | this->tab_widget->addTab(this->viewer, "Viewer");
57 | }
58 |
59 | void MainWidget::openViewer()
60 | {
61 | this->tab_widget->setCurrentWidget(this->viewer);
62 | }
63 |
--------------------------------------------------------------------------------
/src/v2/mainwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef MAINWIDGET_H
2 | #define MAINWIDGET_H
3 |
4 | #include
5 |
6 | class QBooruTab;
7 | class QBooruPictureViewer;
8 | class BooruSite;
9 |
10 | class MainWidget : public QWidget
11 | {
12 | Q_OBJECT
13 | public:
14 | MainWidget(QWidget *parent = 0);
15 | ~MainWidget();
16 | void loadUI();
17 |
18 | public slots:
19 | void loadBoorus(QVector sites);
20 | void addBooru(BooruSite* site);
21 | void openViewer();
22 |
23 | private:
24 | void reorderTabs();
25 |
26 | QTabWidget *tab_widget;
27 | QVector tabs;
28 | QBooruPictureViewer *viewer;
29 | };
30 |
31 | #endif // MAINWIDGET_H
32 |
--------------------------------------------------------------------------------
/src/v2/model/api.cpp:
--------------------------------------------------------------------------------
1 | #include "api.h"
2 |
3 | /* Use of %x for the different parameters
4 | * %1 - Tags
5 | * %2 - Page
6 | * %3 - Limit
7 | * /
8 |
9 | /* Static functions/enum */
10 |
11 | API* API::GELBOORU = new API(ID_GELBOORU, "gelbooru", "/index.php?page=dapi&json=1&s=post&q=index&tags=%1&pid=%2&limit=%3", 0, "/search.json", "/index.php?page=post&s=view&id=", "/index.php?page=account&s=login&code=00", "http://gelbooru.com/index.php?page=help&topic=dapi");
12 | API* API::MOEBOORU = new API(ID_MOEBOORU, "moebooru", "/post.json?api_version=2&tags=%1&page=%2&limit=%3", 1, "post.json", "/post/show/", "","https://konachan.com/help/api");
13 | API* API::DANBOORU = new API(ID_DANBOORU, "danbooru2", "/posts.json?tags=%1&page=%2&limit=%3", 1, "posts.json", "/posts/", "","https://danbooru.donmai.us/wiki_pages/43568");
14 | API* API::E621 = new API(ID_E621, "e621", "/post/index.json?tags=%1&page=%2&limit=%3", 1, "posts.json", "/post/show/", "","https://e621.net/help/api");
15 |
16 | API* API::getAPIFromID(int id)
17 | {
18 | for(unsigned int i=0;igetID() == id){
20 | return new API(values().at(i));
21 | }
22 | }
23 |
24 | return NULL;
25 | }
26 |
27 | std::vector values()
28 | {
29 | std::vector vec;
30 | vec.push_back(API::GELBOORU);
31 | vec.push_back(API::MOEBOORU);
32 | vec.push_back(API::DANBOORU);
33 | vec.push_back(API::E621);
34 | return vec;
35 | }
36 |
37 | /* Methods */
38 | API::API(const API* api){
39 | this->id = api->id;
40 | this->name = api->name;
41 | this->url_search = api->url_search;
42 | this->file_search = api->file_search;
43 | this->url_posts = api->url_posts;
44 | this->url_login = api->url_login;
45 | this->source = api->source;
46 | }
47 |
48 | int API::getID() const
49 | {
50 | return this->id;
51 | }
52 |
53 | std::string API::getName() const
54 | {
55 | return this->name;
56 | }
57 | std::string API::getSearchUrl() const
58 | {
59 | return this->url_search;
60 | }
61 | std::string API::getSearchFile() const
62 | {
63 | return this->file_search;
64 | }
65 | std::string API::getPostsUrl() const
66 | {
67 | return this->url_posts;
68 | }
69 | std::string API::getSource() const
70 | {
71 | return this->source;
72 | }
73 |
74 | std::string API::getLoginUrl() const
75 | {
76 | return this->url_login;
77 | }
78 |
79 | int API::getStartPage() const
80 | {
81 | return this->start_page;
82 | }
83 |
--------------------------------------------------------------------------------
/src/v2/model/api.h:
--------------------------------------------------------------------------------
1 | #ifndef API_H
2 | #define API_H
3 |
4 | /* This class will store the different API const
5 | *
6 | * It works like the Java enums
7 | *
8 | * An API stores the URL extensions to the basesite to load different data, such as search pages or posts' root.
9 | *
10 | * The values are in api.cpp
11 | */
12 |
13 | #include
14 | #include
15 |
16 | enum ID{
17 | ID_GELBOORU = 0,
18 | ID_MOEBOORU,
19 | ID_DANBOORU,
20 | ID_E621
21 | };
22 |
23 | class API
24 | {
25 | public:
26 | // Enum value DECLARATIONS - they are defined later
27 | static API* GELBOORU;
28 | static API* MOEBOORU;
29 | static API* DANBOORU;
30 | static API* E621;
31 | static API* getAPIFromID(int id);
32 |
33 | private:
34 | //Private variables
35 | int id;
36 | std::string name;
37 | std::string url_search;
38 | std::string file_search;
39 | std::string url_posts;
40 | std::string url_login;
41 | std::string source;
42 | int start_page;
43 |
44 | private:
45 | //Constructor
46 | API(int id, std::string name, std::string url_search, int start_page, std::string file_search, std::string url_posts, std::string url_login, std::string source)
47 | {
48 | this->id = id;
49 | this->name = name;
50 | this->url_search = url_search;
51 | this->file_search = file_search;
52 | this->url_posts = url_posts;
53 | this->url_login = url_login;
54 | this->source = source;
55 | this->start_page = start_page;
56 | }
57 |
58 | public:
59 | //Properties and methods
60 | //Don't forget they are CONST
61 | API(const API* api);
62 |
63 | int getID()const;
64 | std::string getName()const;
65 | std::string getSearchUrl()const;
66 | std::string getSearchFile()const;
67 | std::string getPostsUrl()const;
68 | std::string getSource()const;
69 | std::string getLoginUrl()const;
70 | int getStartPage()const;
71 | };
72 | static std::vector values();
73 |
74 | #endif // API_H
75 |
--------------------------------------------------------------------------------
/src/v2/model/boorupicture.h:
--------------------------------------------------------------------------------
1 | #ifndef BOORUPICTURE_H
2 | #define BOORUPICTURE_H
3 |
4 | #include
5 | #include
6 | #include //Used for int to std::string conversion
7 | #include //Used to generate the post's age
8 |
9 | //Used to check the Taglist, might be improved
10 | #include
11 | #include
12 |
13 | #include "jsonobject.h"
14 | #include "boorusite.h"
15 |
16 | #include "const.h"
17 | #include "utils/conversion.h"
18 |
19 | enum PictureType{
20 | PREVIEW = 0,
21 | PREVIEW_JPG,
22 | SAMPLE,
23 | FULL,
24 | PICTURE_TYPE_END
25 | };
26 |
27 | class BooruPicture
28 | {
29 | public:
30 | BooruPicture(Json::Value root, BooruSite *parent);
31 |
32 | int getH();
33 | int getW();
34 | int getID();
35 |
36 | std::string getThumbnailUrl();
37 | std::string getThumbnailPath();
38 | std::string getURL(int type);
39 | std::string getFile(int type);
40 | std::string getShowUrl();
41 |
42 | std::string getAuthor();
43 | std::string getCreationDate();
44 | BooruSite* getWebsite();
45 | int getScore();
46 |
47 | private:
48 | void loadGelbooru(Json::Value root);
49 | void loadMoebooru(Json::Value root);
50 | void loadDanbooru(Json::Value root);
51 | void loadE621(Json::Value root);
52 | void loadTags(std::string tags_str);
53 |
54 | BooruSite *parent;
55 |
56 | int id;
57 | std::string created_at;
58 | std::string author;
59 | std::string source;
60 |
61 | int score;
62 | int size;
63 |
64 | vector taglist;
65 | std::string tags;
66 |
67 | int w;
68 | int h;
69 |
70 | std::string url[PICTURE_TYPE_END];
71 | std::string url_show;
72 |
73 | std::string rating;
74 |
75 | std::string file[PICTURE_TYPE_END];
76 | std::string ext;
77 |
78 |
79 | };
80 |
81 | std::string secondsToString(int time);
82 | int postAge(int postDate);
83 |
84 | #endif // BOORUPICTURE_H
85 |
--------------------------------------------------------------------------------
/src/v2/model/boorusite.cpp:
--------------------------------------------------------------------------------
1 | #include "boorusite.h"
2 |
3 | BooruSite::BooruSite()
4 | {
5 |
6 | }
7 |
8 | BooruSite::BooruSite(Json::Value obj)
9 | {
10 | init(obj["name"].asString(), API::getAPIFromID(obj["api"].asInt()), obj["url_main"].asString(), obj["url_search"].asString(), obj["url_show"].asString(), obj["url_login"].asString(), obj["login_required"].asBool());
11 | }
12 |
13 | BooruSite::BooruSite(std::string name, std::string url, int type_id)
14 | {
15 | init(name,url,API::getAPIFromID(type_id));
16 | }
17 |
18 | BooruSite::BooruSite(std::string name, std::string url, API *api)
19 | {
20 | init(name,url,api);
21 | }
22 |
23 | BooruSite::BooruSite(std::string name, API *api, std::string url_main, std::string url_search, std::string url_show, std::string url_login, bool login_required)
24 | {
25 | init(name, api, url_main, url_search, url_show, url_login, login_required);
26 | }
27 |
28 | void BooruSite::init(std::string name, std::string url, API *api){
29 | std::string url_main = url;
30 | std::string url_search = url + api->getSearchUrl();
31 | std::string url_show = url + api->getPostsUrl();
32 | std::string url_login = url + api->getLoginUrl();
33 |
34 | init(name, api, url_main, url_search, url_show, url_login, login_required);
35 | }
36 |
37 | void BooruSite::init(std::string name, API *api, std::string url_main, std::string url_search, std::string url_show, std::string url_login, bool login_required){
38 | this->name = name;
39 | this->api = api;
40 | this->url_main = url_main;
41 | this->url_search = url_search;
42 | this->url_show = url_show;
43 | this->url_login = url_login;
44 | this->login_required = login_required;
45 | }
46 |
47 | std::string BooruSite::getName(){
48 | return this->name;
49 | }
50 |
51 | std::string BooruSite::getMainUrl(){
52 | return this->url_main;
53 | }
54 |
55 | std::string BooruSite::getSearchUrl(){
56 | return this->url_search;
57 | }
58 |
59 | std::string BooruSite::getShowUrl(){
60 | return this->url_show;
61 | }
62 |
63 | std::string BooruSite::getLoginUrl(){
64 | return this->url_login;
65 | }
66 |
67 | bool BooruSite::needsLogin(){
68 | return this->login_required;
69 | }
70 |
71 | API* BooruSite::getAPI(){
72 | return this->api;
73 | }
74 |
75 |
--------------------------------------------------------------------------------
/src/v2/model/boorusite.h:
--------------------------------------------------------------------------------
1 | #ifndef BOORUSITE_H
2 | #define BOORUSITE_H
3 |
4 | /* This class holds the data that will identify different websites
5 | *
6 | * It generates, from the main URL and the API all the required URLs
7 | *
8 | *
9 | */
10 |
11 | #include
12 | #include "api.h"
13 | #include "../json/json.h"
14 |
15 | class BooruSite
16 | {
17 | public:
18 | BooruSite();
19 | BooruSite(Json::Value obj);
20 | BooruSite(std::string name, std::string url, int type_id);
21 | BooruSite(std::string name, std::string url, API *api);
22 | BooruSite(std::string name, API *api, std::string url_main, std::string url_search, std::string url_show, std::string url_login, bool login_required);
23 |
24 | std::string getName();
25 | std::string getMainUrl();
26 | std::string getSearchUrl();
27 | std::string getShowUrl();
28 | std::string getLoginUrl();
29 | int getStartPage();
30 | bool needsLogin();
31 | API *getAPI();
32 |
33 | private:
34 | void init(std::string name, std::string url, API *api);
35 | void init(std::string name, API *api, std::string url_main, std::string url_search, std::string url_show, std::string url_login, bool login_required);
36 |
37 | std::string name;
38 | API *api;
39 |
40 | std::string url_main;
41 | std::string url_search;
42 | std::string url_show;
43 | std::string url_login;
44 |
45 | bool login_required;
46 |
47 | };
48 |
49 | #endif // BOORUSITE_H
50 |
--------------------------------------------------------------------------------
/src/v2/model/jsonobject.cpp:
--------------------------------------------------------------------------------
1 | #include "jsonobject.h"
2 |
3 | JSONObject::JSONObject(Json::Value value)
4 | {
5 | this->root = value;
6 | }
7 |
8 | JSONObject::JSONObject(string str)
9 | {
10 | loadString(str);
11 | }
12 |
13 | void JSONObject::loadString(string str)
14 | {
15 | Json::Value root; // will contains the root value after parsing
16 | Json::Reader reader;
17 | bool parsingSuccessful = reader.parse(str, root) ;
18 | if ( !parsingSuccessful )
19 | {
20 | // report to the user the failure and their locations in the document.
21 | std::cerr << reader.getFormattedErrorMessages() << std::endl;
22 | this->root = Json::nullValue;
23 | }
24 |
25 | this->root = root;
26 | }
27 |
28 | string JSONObject::getString(string tag, string def)
29 | {
30 | try
31 | {
32 | def = this->root[tag].asString();
33 | }
34 | catch(std::exception const& e)
35 | {
36 | cerr << "ERROR : " << e.what() << endl;
37 | }
38 |
39 | return def;
40 | }
41 |
42 | int JSONObject::getInt(string tag, int def)
43 | {
44 | try
45 | {
46 | def = this->root[tag].asInt();
47 | }
48 | catch(std::exception const& e)
49 | {
50 | cerr << "ERROR : " << e.what() << endl;
51 | }
52 |
53 | return def;
54 | }
55 |
56 | double JSONObject::getDouble(string tag, double def)
57 | {
58 | try
59 | {
60 | def = this->root[tag].asDouble();
61 | }
62 | catch(std::exception const& e)
63 | {
64 | cerr << "ERROR : " << e.what() << endl;
65 | }
66 |
67 | return def;
68 | }
69 |
70 | JSONObject* JSONObject::getObject(string tag)
71 | {
72 | try
73 | {
74 | return new JSONObject(this->root[tag]);
75 | }
76 | catch(std::exception const& e)
77 | {
78 | cerr << "ERROR : " << e.what() << endl;
79 | }
80 |
81 | return 0;
82 | }
83 |
84 | void JSONObject::putString(string tag, string s){
85 | root[tag] = s;
86 | }
87 |
88 | void JSONObject::putInt(string tag, int i){
89 | root[tag] = i;
90 | }
91 |
92 | void JSONObject::putDouble(string tag, double d){
93 | root[tag] = d;
94 | }
95 |
--------------------------------------------------------------------------------
/src/v2/model/jsonobject.h:
--------------------------------------------------------------------------------
1 | #ifndef JSONOBJECT_H
2 | #define JSONOBJECT_H
3 |
4 | /*
5 | * This classes is a wrapper for the Json::Value class from JSONCPP
6 | * It allows for more error control than the native one
7 | *
8 | * You can see it a simplified Java JSONObject
9 | */
10 |
11 | #include
12 | #include
13 | #include "../json/json.h"
14 |
15 | using namespace std;
16 |
17 | class JSONObject
18 | {
19 | public:
20 | JSONObject();
21 | JSONObject(Json::Value value);
22 | JSONObject(string str);
23 |
24 | void loadString(string str);
25 |
26 | string getString(string tag, string def);
27 | int getInt(string tag, int def);
28 | double getDouble(string tag, double def);
29 | JSONObject* getObject(string tag);
30 |
31 | void putString(string tag, string s);
32 | void putInt(string tag, int i);
33 | void putDouble(string tag, double d);
34 |
35 | private:
36 | Json::Value root;
37 | };
38 |
39 | #endif // JSONOBJECT_H
40 |
--------------------------------------------------------------------------------
/src/v2/tests.cpp:
--------------------------------------------------------------------------------
1 | #include "tests.h"
2 |
3 | #include "view/qboorutab.h"
4 | #include "mainwidget.h"
5 |
6 | void test_search()
7 | {
8 | BooruSite* site = new BooruSite(string("Safebooru"),std::string("http://safebooru.org"), API::GELBOORU);
9 |
10 | cout << "Site " << site->getName() << " has search url " << site->getSearchUrl() << endl;
11 |
12 | BooruSearchEngine *engine = new BooruSearchEngine(site);
13 |
14 | engine->search("moriya_suwako",0,15);
15 | }
16 |
17 | void test_site()
18 | {
19 | BooruSite* site = new BooruSite(std::string("Safebooru"),std::string("http://safebooru.org"), API::GELBOORU);
20 |
21 | cout << "Site " << site->getName() << " has search url " << site->getSearchUrl() << endl;
22 | }
23 |
24 | void test_database()
25 | {
26 | BoorusDatabase *db = new BoorusDatabase();
27 |
28 | BooruSite* saf = new BooruSite(std::string("Safebooru"),std::string("http://safebooru.org"), API::GELBOORU);
29 | BooruSite* kon = new BooruSite(std::string("Konachan"),std::string("http://konachan.net"), API::MOEBOORU);
30 |
31 | db->addBooru(saf);
32 | db->addBooru(kon);
33 |
34 | std::vector sites = db->loadBoorus();
35 |
36 | cout << sites.size() << " boorus loaded" << endl;
37 | }
38 |
39 | void test_picture()
40 | {
41 | BooruSite* saf = new BooruSite(std::string("Safebooru"),std::string("http://safebooru.org"), API::GELBOORU);
42 |
43 | BooruSearchEngine *engine = new BooruSearchEngine(saf);
44 |
45 | std::vector pics = engine->search("hatsune_miku",0,15);
46 |
47 | std::cout << "Test : " << pics.size() << " pics" << std::endl;
48 |
49 | if(!pics.empty()){
50 | QBooruPicture *p = new QBooruPicture;
51 | p->setBooruPicture(pics.at(0));
52 | p->show();
53 | }else{
54 | exit(-1);
55 | }
56 | }
57 |
58 | void test_maingrid()
59 | {
60 | BooruSite* site = new BooruSite(std::string("Safebooru"),std::string("http://safebooru.org"), API::GELBOORU);
61 | cout << "Site " << site->getName() << " loaded" << endl;
62 |
63 | BooruSearchEngine *engine = new BooruSearchEngine(site);
64 | cout << "Engine loaded" << endl;
65 |
66 | vector pics = engine->search("kawashiro_nitori",0,15);
67 | cout << pics.size() << " pics loaded" << endl;
68 |
69 | QMainGrid *grid = new QMainGrid(5,3);
70 | cout << "Widget initialized" << endl;
71 |
72 | grid->loadPictures(pics);
73 | cout << "Pictures loaded" << endl;
74 |
75 | grid->show();
76 | }
77 |
78 | void test_simple_tab()
79 | {
80 | qRegisterMetaType >("QVector");
81 |
82 | //Webiste
83 | BooruSite* site = new BooruSite(std::string("Yandere"),std::string("https://yande.re"), API::MOEBOORU);
84 | cout << "Site " << site->getName() << " loaded" << endl;
85 |
86 | //Widgets
87 | QBooruTab *t = new QBooruTab(site, 0);
88 | t->show();
89 | }
90 |
91 | void test_sample_boorus()
92 | {
93 | qRegisterMetaType >("QVector");
94 | QVector boorus;
95 |
96 | boorus.push_back(new BooruSite(std::string("Yandere"),std::string("https://yande.re"), API::MOEBOORU));
97 | boorus.push_back(new BooruSite(std::string("Konachan"),std::string("https://konachan.com"), API::MOEBOORU));
98 | boorus.push_back(new BooruSite(std::string("Safebooru"),std::string("http://safebooru.org"), API::GELBOORU));
99 | boorus.push_back(new BooruSite(std::string("E621"),std::string("https://e621.net"), API::E621));
100 |
101 | MainWidget *w = new MainWidget();
102 | w->loadBoorus(boorus);
103 | w->show();
104 | }
105 |
--------------------------------------------------------------------------------
/src/v2/tests.h:
--------------------------------------------------------------------------------
1 | #ifndef TESTS_H
2 | #define TESTS_H
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "model/boorusite.h"
10 | #include "controller/boorusearchengine.h"
11 | #include "controller/boorusdatabase.h"
12 |
13 | #include "view/qboorupicture.h"
14 | #include "view/qmaingrid.h"
15 | #include "view/qsearchwidget.h"
16 |
17 | void test_search();
18 | void test_site();
19 | void test_database();
20 | void test_picture();
21 | void test_maingrid();
22 | void test_simple_tab();
23 | void test_sample_boorus();
24 |
25 | #endif // TESTS_H
26 |
--------------------------------------------------------------------------------
/src/v2/utils/conversion.cpp:
--------------------------------------------------------------------------------
1 | #include "conversion.h"
2 |
3 | std::string intToString(int i)
4 | {
5 | std::stringstream ss;
6 | std::string s;
7 | ss << i;
8 | s = ss.str();
9 |
10 | return s;
11 | }
12 |
--------------------------------------------------------------------------------
/src/v2/utils/conversion.h:
--------------------------------------------------------------------------------
1 | #ifndef CONVERSION_H
2 | #define CONVERSION_H
3 |
4 | #include
5 | #include
6 |
7 | std::string intToString(int i);
8 |
9 | #endif // CONVERSION_H
10 |
--------------------------------------------------------------------------------
/src/v2/utils/file.cpp:
--------------------------------------------------------------------------------
1 | #include "file.h"
2 |
3 | std::string getFileExtension(std::string filename)
4 | {
5 | return filename.substr(filename.find_last_of(".") + 1);
6 | }
7 |
8 | bool fexists(std::string filename)
9 | {
10 | return fexists(filename.c_str());
11 | }
12 |
13 | bool fexists(const char *filename)
14 | {
15 | std::ifstream ifile(filename);
16 | return ifile.is_open();
17 | }
18 |
19 | void createFolder(std::string file)
20 | {
21 | createFolder((QString::fromStdString(file)));
22 | }
23 |
24 | void createFolder(QString file)
25 | {
26 | QFileInfo f(file);
27 |
28 | if(!QDir(f.absoluteDir()).exists())
29 | QDir().mkdir(f.absoluteDir().absolutePath());
30 | }
31 |
--------------------------------------------------------------------------------
/src/v2/utils/file.h:
--------------------------------------------------------------------------------
1 | #ifndef FILE_H
2 | #define FILE_H
3 |
4 | #include
5 | #include
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | std::string getFileExtension(std::string filename);
13 | bool fexists(std::string filename);
14 | bool fexists(const char *filename);
15 |
16 | void createFolder(std::string file);
17 | void createFolder(QString file);
18 |
19 | #endif // FILE_H
20 |
--------------------------------------------------------------------------------
/src/v2/utils/json.cpp:
--------------------------------------------------------------------------------
1 | #include "json.h"
2 |
3 | Json::Value saveAndLoad(Json::Value root, const char* file)
4 | {
5 | /*
6 | * Saves the specified Json::Value to a file.
7 | * Loads the file and returns it's Json::Value root
8 | * */
9 | saveJSONFile(root,file);
10 | root = loadJSONFile(file);
11 | return root;
12 | }
13 |
14 | Json::Value loadJSONString(std::string str)
15 | {
16 | Json::Value root; // will contains the root value after parsing
17 | Json::Reader reader;
18 |
19 | bool parsingSuccessful = reader.parse(str,root);
20 | if ( !parsingSuccessful )
21 | {
22 | // report to the user the failure and their locations in the document.
23 | outputInfo(L_ERROR,
24 | reader.getFormattedErrorMessages());
25 | return Json::nullValue;
26 | }
27 |
28 | return root;
29 | }
30 |
31 | Json::Value loadJSONFile(const char* filePath)
32 | {
33 | Json::Value root; // will contains the root value after parsing
34 | Json::Reader reader;
35 | std::ifstream test(filePath, std::ifstream::binary);
36 | bool parsingSuccessful = reader.parse(test, root) ;
37 | if ( !parsingSuccessful )
38 | {
39 | // report to the user the failure and their locations in the document.
40 | outputInfo(L_ERROR,
41 | reader.getFormattedErrorMessages());
42 | return Json::nullValue;
43 | }
44 |
45 | test.close();
46 |
47 | return root;
48 | }
49 |
50 | void saveJSONFile(Json::Value root, const char* filePath)
51 | {
52 | Json::StyledWriter writer;
53 | std::ofstream mFile;
54 | mFile.open(filePath);
55 | mFile << writer.write(root);
56 | mFile.close();
57 | }
58 |
--------------------------------------------------------------------------------
/src/v2/utils/json.h:
--------------------------------------------------------------------------------
1 | #ifndef JSON_H
2 | #define JSON_H
3 |
4 | #include
5 | #include
6 |
7 | #include "../json/json.h"
8 | #include "output.h"
9 |
10 | Json::Value saveAndLoad(Json::Value root, const char* file);
11 | Json::Value loadJSONString(std::string str);
12 | Json::Value loadJSONFile(const char* filePath);
13 | void saveJSONFile(Json::Value root, const char* filePath);
14 |
15 |
16 | #endif // JSON_H
17 |
--------------------------------------------------------------------------------
/src/v2/utils/output.cpp:
--------------------------------------------------------------------------------
1 | #include "output.h"
2 |
3 | const std::string currentDateTime()
4 | {
5 | time_t now = time(0);
6 | struct tm tstruct;
7 | char buf[80];
8 | tstruct = *localtime(&now);
9 | // Visit http://en.cppreference.com/w/cpp/chrono/c/strftime
10 | // for more information about date/time format
11 | strftime(buf, sizeof(buf), "%Y-%m-%d | %X", &tstruct);
12 |
13 | return buf;
14 | }
15 |
16 | void outputInfo(int type, std::string data)
17 | {
18 | /*
19 | * Outputs formatted messages :
20 | * [TYPE][DATE]|-->DATA
21 | * */
22 |
23 | std::string type_string;
24 | int level = 0;
25 |
26 | switch(type)
27 | {
28 | case L_DEBUG:
29 | type_string = "DEBUG";
30 | level = 2;
31 | break;
32 | case L_INFO:
33 | type_string = "INFO";
34 | level = 3;
35 | break;
36 | case L_WARNING:
37 | type_string = "WARNING";
38 | level = 0;
39 | break;
40 | case L_ERROR:
41 | type_string = "ERROR";
42 | level = 2;
43 | break;
44 | }
45 |
46 | std::cout << "[" << type_string << "]";
47 |
48 | for(int i=0;i " << data << std::endl;
52 | }
53 |
--------------------------------------------------------------------------------
/src/v2/utils/output.h:
--------------------------------------------------------------------------------
1 | #ifndef OUTPUT_H
2 | #define OUTPUT_H
3 |
4 | #include
5 | #include
6 |
7 | enum LogLevel{
8 | L_DEBUG = 0,
9 | L_INFO,
10 | L_WARNING,
11 | L_ERROR
12 | };
13 |
14 | // Get current date/time, format is YYYY-MM-DD.HH:mm:ss
15 | const std::string currentDateTime();
16 | void outputInfo(int type, std::string data);
17 |
18 | #endif // OUTPUT_H
19 |
--------------------------------------------------------------------------------
/src/v2/utils/qnamredirect.cpp:
--------------------------------------------------------------------------------
1 | #include "qnamredirect.h"
2 |
3 | QNAMRedirect::QNAMRedirect()
4 | {
5 | connect(&nam, SIGNAL (finished(QNetworkReply*)),this, SLOT (replyFinished(QNetworkReply*)));
6 | }
7 |
8 | void QNAMRedirect::processUrl(QString url)
9 | {
10 | QUrl file_url(url);
11 |
12 | //qDebug() << QString("QNAMRedirect::replyFinished: Starting from ").append(file_url.toString());
13 |
14 | QNetworkRequest request(file_url);
15 | nam.get(request);
16 | }
17 |
18 |
19 | void QNAMRedirect::replyFinished(QNetworkReply* reply) {
20 | /*
21 | * Reply is finished!
22 | * We'll ask for the reply about the Redirection attribute
23 | * http://doc.trolltech.com/qnetworkrequest.html#Attribute-enum
24 | */
25 | QVariant possibleRedirectUrl =
26 | reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
27 |
28 | /* We'll deduct if the redirection is valid in the redirectUrl function */
29 | QUrl _urlRedirectedTo = this->redirectUrl(possibleRedirectUrl.toUrl(),_urlRedirectedTo);
30 |
31 | /* If the URL is not empty, we're being redirected. */
32 | if(!_urlRedirectedTo.isEmpty()) {
33 | //qDebug() << QString("QNAMRedirect::replyFinished: Redirected to ").append(_urlRedirectedTo.toString());
34 |
35 | /* We'll do another request to the redirection url. */
36 | this->nam.get(QNetworkRequest(_urlRedirectedTo));
37 | }
38 | else {
39 | /*
40 | * We weren't redirected anymore
41 | * so we arrived to the final destination...
42 | */
43 | //qDebug() << QString("QNAMRedirect::replyFinished: Arrived to ").append(reply->url().toString());
44 | last_url = reply->url();
45 | /* ...so this can be cleared. */
46 | _urlRedirectedTo.clear();
47 |
48 | emit finished();
49 | }
50 | /* Clean up. */
51 | reply->deleteLater();
52 | }
53 |
54 |
55 | QUrl QNAMRedirect::redirectUrl(const QUrl& possibleRedirectUrl,
56 | const QUrl& oldRedirectUrl) const {
57 | QUrl redirectUrl;
58 | /*
59 | * Check if the URL is empty and
60 | * that we aren't being fooled into a infinite redirect loop.
61 | * We could also keep track of how many redirects we have been to
62 | * and set a limit to it, but we'll leave that to you.
63 | */
64 | if(!possibleRedirectUrl.isEmpty() &&
65 | possibleRedirectUrl != oldRedirectUrl) {
66 | redirectUrl = possibleRedirectUrl;
67 | }
68 | return redirectUrl;
69 | }
70 |
71 | QUrl QNAMRedirect::getLastRedirect()
72 | {
73 | return this->last_url;
74 | }
75 |
76 |
77 |
--------------------------------------------------------------------------------
/src/v2/utils/qnamredirect.h:
--------------------------------------------------------------------------------
1 | #ifndef QNAMREDIRECT_H
2 | #define QNAMREDIRECT_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | class QNAMRedirect : public QObject
12 | {
13 | Q_OBJECT
14 | public:
15 | QNAMRedirect();
16 | void processUrl(QString url);
17 |
18 | QUrl redirectUrl(const QUrl& possibleRedirectUrl,const QUrl& oldRedirectUrl) const;
19 | QUrl getLastRedirect();
20 |
21 | signals:
22 | void finished();
23 |
24 | public slots:
25 | void replyFinished(QNetworkReply* reply);
26 |
27 | private:
28 | QNetworkAccessManager nam;
29 | QUrl last_url;
30 | };
31 |
32 | #endif // QNAMREDIRECT_H
33 |
--------------------------------------------------------------------------------
/src/v2/view/clickablelabel.cpp:
--------------------------------------------------------------------------------
1 | #include "clickablelabel.h"
2 |
3 | ClickableLabel::ClickableLabel(QWidget* parent, Qt::WindowFlags f)
4 | : QLabel(parent) {
5 |
6 | }
7 |
8 | ClickableLabel::ClickableLabel(QString text, QWidget* parent, Qt::WindowFlags f)
9 | : QLabel(text, parent) {
10 |
11 | }
12 |
13 | ClickableLabel::~ClickableLabel() {}
14 |
15 | void ClickableLabel::mousePressEvent(QMouseEvent* event) {
16 | emit clicked();
17 | }
18 |
--------------------------------------------------------------------------------
/src/v2/view/clickablelabel.h:
--------------------------------------------------------------------------------
1 | #ifndef CLICKABLELABEL_H
2 | #define CLICKABLELABEL_H
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | class ClickableLabel : public QLabel {
9 | Q_OBJECT
10 |
11 | public:
12 | ClickableLabel(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
13 | ClickableLabel(QString text, QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
14 | ~ClickableLabel();
15 |
16 | signals:
17 | void clicked();
18 |
19 | protected:
20 | void mousePressEvent(QMouseEvent* event);
21 |
22 | };
23 |
24 | #endif // CLICKABLELABEL_H
25 |
--------------------------------------------------------------------------------
/src/v2/view/qboorupicture.h:
--------------------------------------------------------------------------------
1 | #ifndef QBOORUPICTURE_H
2 | #define QBOORUPICTURE_H
3 |
4 | #include
5 | #include
6 | #include "clickablelabel.h"
7 |
8 | class BooruPicture;
9 |
10 | class QBooruPicture : public QWidget
11 | {
12 | Q_OBJECT
13 | public:
14 | QBooruPicture(QWidget *parent = 0);
15 | QBooruPicture(BooruPicture *picture, QWidget* parent=0);
16 |
17 | void loadUI();
18 |
19 | signals:
20 | void pictureClicked(BooruPicture* picture);
21 |
22 | public slots:
23 | void setBooruPicture(BooruPicture* picture);
24 | void setBooruPictureEmpty();
25 | void setPixmap(QPixmap pixmap);
26 | void setText(QString text);
27 | void onPictureClicked();
28 |
29 | private:
30 | BooruPicture* picture = 0;
31 | QPixmap pixmap;
32 |
33 | ClickableLabel *labelPicture = 0;
34 | QLabel *labelComment = 0;
35 | };
36 |
37 | #endif // QBOORUPICTURE_H
38 |
--------------------------------------------------------------------------------
/src/v2/view/qboorupictureinfowidget.cpp:
--------------------------------------------------------------------------------
1 | #include "qboorupictureinfowidget.h"
2 |
3 | #include "model/boorupicture.h"
4 |
5 | QBooruPictureInfoWidget::QBooruPictureInfoWidget(QWidget *parent) : QWidget(parent)
6 | {
7 | loadUI();
8 | }
9 |
10 | void QBooruPictureInfoWidget::loadUI()
11 | {
12 | //Labels
13 | this->titles[LABELS::LABEL_UPLOADER] = "Uploader";
14 | this->titles[LABELS::LABEL_BOORU] = "Website";
15 | this->titles[LABELS::LABEL_CREATION] = "Created on";
16 | this->titles[LABELS::LABEL_DIMENSIONS] = "Dimensions";
17 | this->titles[LABELS::LABEL_FULL_URL] = "Picture URL";
18 | this->titles[LABELS::LABEL_ID] = "ID";
19 | this->titles[LABELS::LABEL_RATING] = "Rating";
20 | this->titles[LABELS::LABEL_SCORE] = "Score";
21 | this->titles[LABELS::LABEL_SHOW_URL] = "Website URL";
22 |
23 | //UI
24 | QVBoxLayout *bLayout = new QVBoxLayout();
25 | QGroupBox *b = new QGroupBox("Information", this);
26 | b->setLayout(bLayout);
27 |
28 | for(int i=0;ilabels[i] = new QLabel(this->titles[i], this);
31 | this->labels[i]->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
32 | bLayout->addWidget(this->labels[i]);
33 | }
34 |
35 | b->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
36 |
37 | this->labels[LABEL_SHOW_URL]->setOpenExternalLinks(true);
38 | this->labels[LABEL_FULL_URL]->setOpenExternalLinks(true);
39 |
40 | QVBoxLayout *layout = new QVBoxLayout();
41 | layout->addWidget(b);
42 | this->setLayout(layout);
43 | }
44 |
45 | void QBooruPictureInfoWidget::loadPicture(BooruPicture* picture)
46 | {
47 | setWebsite(QString::fromStdString(picture->getWebsite()->getName()));
48 | setUploader(QString::fromStdString(picture->getAuthor()));
49 | setDimensions(picture->getW(), picture->getH());
50 | setDate(QString::fromStdString(picture->getCreationDate()));
51 | setFullUrl(QString::fromStdString(picture->getURL(PictureType::FULL)));
52 | setId(picture->getID());
53 | setScore(picture->getScore());
54 | setShowUrl(QString::fromStdString(picture->getShowUrl()));
55 |
56 | this->picture = picture;
57 | }
58 |
59 | void QBooruPictureInfoWidget::setLabel(int label, QString text)
60 | {
61 | this->labels[label]->setText(this->titles[label] + " : " + text);
62 | }
63 |
64 | void QBooruPictureInfoWidget::setUploader(QString uploader)
65 | {
66 | setLabel(LABELS::LABEL_UPLOADER, uploader);
67 | }
68 |
69 | void QBooruPictureInfoWidget::setWebsite(QString website)
70 | {
71 | setLabel(LABELS::LABEL_BOORU, website);
72 | }
73 |
74 | void QBooruPictureInfoWidget::setDate(QString date)
75 | {
76 | setLabel(LABELS::LABEL_CREATION, date);
77 | }
78 |
79 | void QBooruPictureInfoWidget::setDimensions(int w, int h)
80 | {
81 | QString s = QString::number(w) + "x" + QString::number(h);
82 | setLabel(LABELS::LABEL_DIMENSIONS, s);
83 | }
84 |
85 | void QBooruPictureInfoWidget::setFullUrl(QString url)
86 | {
87 | QString html = QString("Link");
88 | setLabel(LABELS::LABEL_FULL_URL, html);
89 | }
90 |
91 | void QBooruPictureInfoWidget::setId(int id)
92 | {
93 | setLabel(LABELS::LABEL_ID, QString::number(id));
94 | }
95 |
96 | void QBooruPictureInfoWidget::setScore(int score)
97 | {
98 | setLabel(LABELS::LABEL_SCORE, QString::number(score));
99 | }
100 |
101 | void QBooruPictureInfoWidget::setShowUrl(QString url)
102 | {
103 | QString html = QString("Link");
104 | setLabel(LABELS::LABEL_SHOW_URL, html);
105 | }
106 |
--------------------------------------------------------------------------------
/src/v2/view/qboorupictureinfowidget.h:
--------------------------------------------------------------------------------
1 | #ifndef QBOORUPICTUREINFOWIDGET_H
2 | #define QBOORUPICTUREINFOWIDGET_H
3 |
4 | #include
5 |
6 | class BooruPicture;
7 |
8 | class QBooruPictureInfoWidget : public QWidget
9 | {
10 | Q_OBJECT
11 | public:
12 | QBooruPictureInfoWidget(QWidget *parent = 0);
13 | void loadUI();
14 |
15 | void setLabel(int label, QString text);
16 | void setUploader(QString uploader);
17 | void setWebsite(QString website);
18 | void setDate(QString date);
19 | void setDimensions(int w, int h);
20 | void setFullUrl(QString url);
21 | void setId(int id);
22 | void setScore(int score);
23 | void setShowUrl(QString url);
24 |
25 | enum LABELS
26 | {
27 | LABEL_BOORU = 0,
28 | LABEL_SHOW_URL,
29 | LABEL_FULL_URL,
30 | LABEL_ID,
31 | LABEL_UPLOADER,
32 | LABEL_CREATION,
33 | LABEL_SCORE,
34 | LABEL_RATING,
35 | LABEL_DIMENSIONS,
36 | COUNT
37 | };
38 |
39 | signals:
40 |
41 | public slots:
42 | void loadPicture(BooruPicture* picture);
43 |
44 | private:
45 | BooruPicture *picture = 0;
46 | QLabel *labels[LABELS::COUNT];
47 | QString titles[LABELS::COUNT];
48 |
49 | };
50 |
51 | #endif // QBOORUPICTUREINFOWIDGET_H
52 |
--------------------------------------------------------------------------------
/src/v2/view/qboorupictureviewer.cpp:
--------------------------------------------------------------------------------
1 | #include "qboorupictureviewer.h"
2 |
3 | #include "qboorupictureinfowidget.h"
4 | #include "model/boorupicture.h"
5 | #include "controller/boorupixmapdownloader.h"
6 |
7 | QBooruPictureViewer::QBooruPictureViewer(QWidget *parent) : QWidget(parent)
8 | {
9 | loadUI();
10 | }
11 |
12 | void QBooruPictureViewer::loadUI()
13 | {
14 | this->info_widget = new QBooruPictureInfoWidget(this);
15 | this->label_picture = new QLabel(this);
16 |
17 | this->info_widget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
18 |
19 | QHBoxLayout *layout = new QHBoxLayout();
20 | layout->addWidget(label_picture);
21 | layout->addWidget(info_widget);
22 |
23 | this->setLayout(layout);
24 | }
25 |
26 | void QBooruPictureViewer::loadPicture(BooruPicture *picture)
27 | {
28 | this->info_widget->loadPicture(picture);
29 |
30 | BooruPixmapDownloader* d = new BooruPixmapDownloader(picture, PictureType::SAMPLE, true);
31 | QThread* t = new QThread(this);
32 |
33 | d->moveToThread(t);
34 |
35 | //Thread Management
36 | connect(t, SIGNAL(started()), d, SLOT(process()));
37 | connect(d, SIGNAL(finished()), t, SLOT(quit()));
38 | connect(d, SIGNAL(finished()), d, SLOT(deleteLater()));
39 | connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
40 |
41 | //Output
42 | connect(d, SIGNAL(pixmapLoaded(QPixmap)), this, SLOT(setPixmap(QPixmap)));
43 |
44 | t->start();
45 | }
46 |
47 | void QBooruPictureViewer::setPixmap(QPixmap p)
48 | {
49 | this->label_picture->setPixmap(p);
50 | }
51 |
--------------------------------------------------------------------------------
/src/v2/view/qboorupictureviewer.h:
--------------------------------------------------------------------------------
1 | #ifndef QBOORUPICTUREVIEWER_H
2 | #define QBOORUPICTUREVIEWER_H
3 |
4 | #include
5 |
6 | class QBooruPictureInfoWidget;
7 | class BooruPicture;
8 | class BooruPixmapDownloader;
9 |
10 | class QBooruPictureViewer : public QWidget
11 | {
12 | Q_OBJECT
13 | public:
14 | QBooruPictureViewer(QWidget *parent = nullptr);
15 | void loadUI();
16 |
17 | signals:
18 |
19 | public slots:
20 | void loadPicture(BooruPicture* picture);
21 | void setPixmap(QPixmap p);
22 |
23 | private:
24 | QLabel *label_picture = 0;
25 | QBooruPictureInfoWidget *info_widget = 0;
26 | };
27 |
28 | #endif // QBOORUPICTUREVIEWER_H
29 |
--------------------------------------------------------------------------------
/src/v2/view/qboorutab.cpp:
--------------------------------------------------------------------------------
1 | #include "qboorutab.h"
2 |
3 | #include "qsearchwidget.h"
4 | #include "qmaingrid.h"
5 | #include "qpageswitcher.h"
6 |
7 | QBooruTab::QBooruTab(BooruSite* site, QWidget *parent) : QWidget(parent)
8 | {
9 | this->site = site;
10 | this->loadUI();
11 | }
12 |
13 | void QBooruTab::loadUI()
14 | {
15 | this->search_widget = new QSearchWidget(this->site,15, this);
16 | this->main_grid = new QMainGrid(5,3,this);
17 | this->page_switcher = new QPageSwitcher(this->site, this);
18 |
19 | //Logic
20 | connect(this->search_widget,SIGNAL(loadedPictures(QVector)),this->main_grid,SLOT(loadPictures(QVector)));
21 | connect(this->main_grid, SIGNAL(pictureClicked(BooruPicture*)), this, SIGNAL(pictureClicked(BooruPicture*)));
22 |
23 | connect(this->page_switcher, SIGNAL(openPage(int)), this->search_widget, SLOT(setPage(int)));
24 | connect(this->search_widget, SIGNAL(pageSet(int)), this->page_switcher, SLOT(setCurrentPage(int)));
25 |
26 | //Layout
27 | QVBoxLayout *l = new QVBoxLayout;
28 | l->addWidget(this->search_widget);
29 | l->addWidget(this->main_grid);
30 | l->addWidget(this->page_switcher);
31 | setLayout(l);
32 |
33 |
34 | this->page_switcher->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
35 | this->search_widget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
36 | this->main_grid->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
37 | l->setAlignment(this->search_widget, Qt::AlignTop);
38 | }
39 |
40 | BooruSite* QBooruTab::getBooru()
41 | {
42 | return this->site;
43 | }
44 |
45 | QString QBooruTab::getTitle()
46 | {
47 | return QString::fromStdString(this->site->getName());
48 | }
49 |
--------------------------------------------------------------------------------
/src/v2/view/qboorutab.h:
--------------------------------------------------------------------------------
1 | #ifndef QBOORUTAB_H
2 | #define QBOORUTAB_H
3 |
4 | #include
5 |
6 | class QMainGrid;
7 | class BooruSite;
8 | class BooruPicture;
9 | class QSearchWidget;
10 | class QPageSwitcher;
11 |
12 | class QBooruTab : public QWidget
13 | {
14 | Q_OBJECT
15 | public:
16 | QBooruTab(BooruSite *site, QWidget *parent = nullptr);
17 | void loadUI();
18 | BooruSite* getBooru();
19 | QString getTitle();
20 |
21 | signals:
22 | void pictureClicked(BooruPicture *picture);
23 |
24 | public slots:
25 |
26 | private:
27 | QSearchWidget *search_widget = 0;
28 | QMainGrid *main_grid = 0;
29 | QPageSwitcher *page_switcher = 0;
30 | BooruSite *site = 0;
31 |
32 | };
33 |
34 | #endif // QBOORUTAB_H
35 |
--------------------------------------------------------------------------------
/src/v2/view/qmaingrid.cpp:
--------------------------------------------------------------------------------
1 | #include "qmaingrid.h"
2 |
3 | #include "qboorupicture.h"
4 | #include "model/boorupicture.h"
5 | #include "controller/boorupixmapdownloader.h"
6 |
7 | QMainGrid::QMainGrid(int l, int h, QWidget *parent) : QWidget(parent)
8 | {
9 | this->l = l;
10 | this->h = h;
11 | this->count = l*h;
12 |
13 | //Setting up the main GridLayout
14 | this->grid = new QGridLayout();
15 |
16 |
17 | for(int i=0;iaddWidget(pictureWidgets[index],i,j);
28 | }
29 | }
30 |
31 | setLayout(grid);
32 | }
33 |
34 | void QMainGrid::loadPictures(std::vector pictures)
35 | {
36 | loadPictures(QVector::fromStdVector(pictures));
37 | }
38 |
39 | void QMainGrid::loadPictures(QVector pictures)
40 | {
41 | qDebug() << "Loading pictures";
42 | for(int i=0;isetBooruPicture(pictures[i]);
45 | }
46 | for(int i=pictures.size();isetBooruPictureEmpty();
49 | }
50 | }
51 |
52 | QBooruPicture* QMainGrid::getWidget(int i)
53 | {
54 | return pictureWidgets[i];
55 | }
56 |
57 | QVector QMainGrid::getWidgets()
58 | {
59 | return this->pictureWidgets;
60 | }
61 |
62 | void QMainGrid::setPicture(BooruPicture* pic, int i)
63 | {
64 | pictureWidgets[i]->setBooruPicture(pic);
65 | }
66 |
67 | int QMainGrid::getWidgetCount()
68 | {
69 | return count;
70 | }
71 |
--------------------------------------------------------------------------------
/src/v2/view/qmaingrid.h:
--------------------------------------------------------------------------------
1 | #ifndef QMAINGRID_H
2 | #define QMAINGRID_H
3 |
4 | #include
5 | #include
6 |
7 | class BooruPixmapDownloader;
8 | class BooruPicture;
9 | class QBooruPicture;
10 |
11 | class QMainGrid : public QWidget
12 | {
13 | Q_OBJECT
14 | public:
15 | QMainGrid(int l, int h, QWidget *parent = nullptr);
16 |
17 | QBooruPicture* getWidget(int i);
18 | QVector getWidgets();
19 |
20 | void setPicture(BooruPicture* pic, int i);
21 | int getWidgetCount();
22 |
23 | signals:
24 | void pictureClicked(BooruPicture *picture);
25 |
26 | public slots:
27 | void loadPictures(std::vector pictures);
28 | void loadPictures(QVector pictures);
29 |
30 | private:
31 | int l;
32 | int h;
33 | int count;
34 |
35 | QGridLayout *grid;
36 | QVector pictureWidgets;
37 | QVector threadPool;
38 | QVector workerPool;
39 | };
40 |
41 | #endif // QMAINGRID_H
42 |
--------------------------------------------------------------------------------
/src/v2/view/qpageswitcher.cpp:
--------------------------------------------------------------------------------
1 | #include "qpageswitcher.h"
2 |
3 | #include "model/boorusite.h"
4 |
5 | QPageSwitcher::QPageSwitcher(BooruSite *booru, QWidget *parent) : QWidget(parent)
6 | {
7 | this->booru = booru;
8 | loadUI();
9 | }
10 |
11 | void QPageSwitcher::loadUI()
12 | {
13 | this->pbNextPage = new QPushButton("->", this);
14 | this->pbPreviousPage = new QPushButton("<-", this);
15 | this->lePageNumber = new QLineEdit(this);
16 |
17 | this->lePageNumber->setValidator(new QIntValidator(0, 1024, this));
18 |
19 | this->lePageNumber->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
20 | this->pbNextPage->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
21 | this->pbPreviousPage->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
22 |
23 | QHBoxLayout *layout = new QHBoxLayout;
24 |
25 | layout->addWidget(this->pbPreviousPage);
26 | layout->addWidget(this->lePageNumber);
27 | layout->addWidget(this->pbNextPage);
28 |
29 | this->setLayout(layout);
30 |
31 | connect(this->pbNextPage, SIGNAL(clicked(bool)), this, SLOT(setNextPage()));
32 | connect(this->pbPreviousPage, SIGNAL(clicked(bool)), this, SLOT(setPreviousPage()));
33 |
34 | connect(this->lePageNumber, SIGNAL(returnPressed()), this, SLOT(setNextPage()));
35 |
36 | this->page = this->booru->getAPI()->getStartPage();
37 | this->updatePageNumber();
38 | }
39 |
40 | void QPageSwitcher::setCurrentPage(int page)
41 | {
42 | if(page <= this->booru->getAPI()->getStartPage())
43 | {
44 | this->page = this->booru->getAPI()->getStartPage();
45 | }
46 | else
47 | {
48 | this->page = page;
49 | }
50 |
51 | updatePageNumber();
52 | }
53 |
54 | void QPageSwitcher::setPage()
55 | {
56 | this->page = this->lePageNumber->text().toInt();
57 | updatePageNumber();
58 |
59 | emit openPage(this->page);
60 | }
61 |
62 | void QPageSwitcher::setNextPage()
63 | {
64 | this->page++;
65 | updatePageNumber();
66 |
67 | emit nextPage();
68 | emit openPage(this->page);
69 | }
70 |
71 | void QPageSwitcher::setPreviousPage()
72 | {
73 | this->page--;
74 | updatePageNumber();
75 |
76 | emit previousPage();
77 | emit openPage(this->page);
78 | }
79 |
80 | void QPageSwitcher::updatePageNumber()
81 | {
82 | int offset = 1-this->booru->getAPI()->getStartPage();
83 | this->lePageNumber->setText(QString::number(this->page + offset));
84 |
85 | if(this->page <= this->booru->getAPI()->getStartPage())
86 | {
87 | this->pbPreviousPage->setDisabled(true);
88 | }
89 | else
90 | {
91 | this->pbPreviousPage->setEnabled(true);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/v2/view/qpageswitcher.h:
--------------------------------------------------------------------------------
1 | #ifndef QPAGESWITCHER_H
2 | #define QPAGESWITCHER_H
3 |
4 | #include
5 |
6 | class BooruSite;
7 |
8 | #define PAGE_OFFSET 0
9 |
10 | class QPageSwitcher : public QWidget
11 | {
12 | Q_OBJECT
13 | public:
14 | QPageSwitcher(BooruSite *booru, QWidget *parent = nullptr);
15 | void loadUI();
16 |
17 | signals:
18 | void nextPage();
19 | void previousPage();
20 | void openPage(int page);
21 |
22 | public slots:
23 | void setCurrentPage(int page);
24 |
25 | private slots:
26 | void updatePageNumber();
27 | void setPage();
28 | void setNextPage();
29 | void setPreviousPage();
30 |
31 | private:
32 | QPushButton *pbNextPage = 0;
33 | QPushButton *pbPreviousPage = 0;
34 | QLineEdit *lePageNumber = 0;
35 |
36 | BooruSite *booru = 0;
37 |
38 | int page = 1;
39 | };
40 |
41 | #endif // QPAGESWITCHER_H
42 |
--------------------------------------------------------------------------------
/src/v2/view/qsearchwidget.cpp:
--------------------------------------------------------------------------------
1 | #include "qsearchwidget.h"
2 |
3 | QSearchWidget::QSearchWidget(BooruSite *site, int limit, QWidget *parent) : QWidget(parent)
4 | {
5 | this->site = site;
6 | this->engine = new BooruSearchEngine(site);
7 | this->limit = limit;
8 | this->page = site->getAPI()->getStartPage();
9 | loadUI();
10 | }
11 |
12 | void QSearchWidget::loadUI()
13 | {
14 | pushButtonSearch = new QPushButton("Search",this);
15 | lineEditTags = new QLineEdit();
16 |
17 | QHBoxLayout *l = new QHBoxLayout;
18 | l->addWidget(lineEditTags);
19 | l->addWidget(pushButtonSearch);
20 |
21 | setLayout(l);
22 |
23 | connect(pushButtonSearch,SIGNAL(clicked(bool)),this,SLOT(search()));
24 | connect(lineEditTags,SIGNAL(returnPressed()),this,SLOT(search()));
25 | }
26 |
27 | void QSearchWidget::setPage(int page)
28 | {
29 | this->page = page;
30 | search(page);
31 | }
32 |
33 | void QSearchWidget::search()
34 | {
35 | this->tags = lineEditTags->text();
36 | this->page = this->site->getAPI()->getStartPage();;
37 | emit pageSet(this->page);
38 |
39 | search(this->tags, this->page, this->limit);
40 | }
41 |
42 | void QSearchWidget::search(int page)
43 | {
44 | search(this->tags, page, this->limit);
45 | }
46 |
47 | void QSearchWidget::search(QString tags, int page, int limit)
48 | {
49 | engine->set(tags,page,limit);
50 |
51 | QThread *t = new QThread(this);
52 | worker = new QSearchWorker(engine);
53 |
54 | worker->moveToThread(t);
55 |
56 | //Thread Management
57 | connect(t, SIGNAL(started()), worker, SLOT(process()));
58 | connect(worker, SIGNAL(finished()), t, SLOT(quit()));
59 | connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
60 | connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
61 |
62 | //Output
63 | connect(worker,SIGNAL(results(QVector)),this,SIGNAL(loadedPictures(QVector)));
64 |
65 | t->start();
66 | }
67 |
--------------------------------------------------------------------------------
/src/v2/view/qsearchwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef QSEARCHWIDGET_H
2 | #define QSEARCHWIDGET_H
3 |
4 | #include
5 | #include "controller/qsearchworker.h"
6 | #include "model/boorusite.h"
7 | #include "model/boorupicture.h"
8 |
9 | #define DEFAULT_LIMIT 15
10 |
11 | class QSearchWidget : public QWidget
12 | {
13 | Q_OBJECT
14 | public:
15 | QSearchWidget(BooruSite* site, int limit = DEFAULT_LIMIT, QWidget *parent = nullptr);
16 | signals:
17 | void loadedPictures(QVector pics);
18 | void pageSet(int page);
19 |
20 | public slots:
21 | void setPage(int page);
22 | void search();
23 |
24 | private:
25 | void search(int page);
26 | void search(QString tags, int page, int limit);
27 | void loadUI();
28 |
29 | QLineEdit *lineEditTags;
30 | QPushButton *pushButtonSearch;
31 |
32 | BooruSite *site;
33 | BooruSearchEngine *engine;
34 | QSearchWorker *worker;
35 |
36 | QString tags = "";
37 | int page = 0;
38 | int limit = DEFAULT_LIMIT;
39 | };
40 |
41 | #endif // QSEARCHWIDGET_H
42 |
--------------------------------------------------------------------------------
/src/viewer/BooruHeaders/booru_search_engine.h:
--------------------------------------------------------------------------------
1 | #ifndef BOORUSEARCHENGINE_H
2 | #define BOORUSEARCHENGINE_H
3 |
4 | #include
5 | #include
6 | #include "../fonctions_all.h"
7 | #include "../Workers/cookiejar.h"
8 | #include "../Workers/searchloggingworker.h"
9 |
10 | class BooruSearchEngine : public QObject
11 | {
12 | Q_OBJECT
13 | public:
14 | BooruSearchEngine(QObject *parent = 0);
15 | BooruSearchEngine(BooruSite* booru, QObject *parent = 0);
16 | BooruSearchEngine(BooruSite* booru, std::string tags, int page, QObject *parent = 0);
17 | ~BooruSearchEngine();
18 |
19 | void generateUrlExtension();
20 |
21 | void search();
22 | void search(std::string tags);
23 | void search(int page);
24 | void search(std::string tags, int page);
25 | void search(std::string tags, int page, CookieJar* cookie);
26 |
27 | void setRating(int rating_id);
28 |
29 | void setCookie(CookieJar *cookie);
30 | void setBooru(BooruSite* booru);
31 | void setTags(std::string tags);
32 | void setImageCount(int count);
33 | void setPage(int page);
34 | void setApiKey(std::string key);
35 | void setDump(bool isDump);
36 | int getResultSize();
37 | int logSearch();
38 |
39 | int getPage();
40 | CookieJar *getCookie();
41 | std::string getTags();
42 | bool hasCookie();
43 |
44 | private:
45 | bool has_cookie;
46 | BooruSite* booru;
47 | CookieJar* cookie;
48 |
49 | int image_count;
50 |
51 | std::string tags_org;
52 | std::string tags;
53 | std::string search_extension;
54 | std::string search_url;
55 |
56 | std::string rating_extension;
57 |
58 | std::string derpibooru_api_key;
59 | int page;
60 | int rating_id;
61 | bool isDump;
62 |
63 | SearchLoggingWorker *worker;
64 | QThread *thread;
65 | };
66 |
67 | #endif // BOORUSEARCHENGINE_H
68 |
--------------------------------------------------------------------------------
/src/viewer/BooruHeaders/boorutag.cpp:
--------------------------------------------------------------------------------
1 | #include "boorutag.h"
2 |
3 | BooruTag::BooruTag(Json::Value root, BooruSite *parent)
4 | {
5 | this->site = parent;
6 | loadFromJson(root);
7 | }
8 |
9 | void BooruTag::loadFromJson(Json::Value root)
10 | {
11 | switch(site->getSiteTypeInt())
12 | {
13 | case DERPIBOORU_TYPE:
14 | break;
15 | case GELBOORU_TYPE:
16 | break;
17 | case MOEBOORU_TYPE:
18 | this->id = root["id"].asInt();
19 | this->name = root["name"].asString();
20 | this->count = root["count"].asInt();
21 | this->type = root["type"].asInt();
22 | break;
23 | case DANBOORU2_TYPE:
24 | this->id = root["id"].asInt();
25 | this->name = root["name"].asString();
26 | this->count = root["post_count"].asInt();
27 | this->type = root["category"].asInt();
28 | break;
29 | }
30 |
31 | switch(this->type)
32 | {
33 | case TAG_COMMON:
34 | type_name = "Common";
35 | break;
36 | case TAG_ARTIST:
37 | type_name = "Artist";
38 | break;
39 | case TAG_CHARA:
40 | type_name = "Character";
41 | break;
42 | default:
43 | type_name = "Undefined";
44 | break;
45 | }
46 | }
47 |
48 | int BooruTag::getId()
49 | {
50 | return this->id;
51 | }
52 |
53 | std::string BooruTag::getName()
54 | {
55 | return this->name;
56 | }
57 |
58 | int BooruTag::getCount()
59 | {
60 | return this->count;
61 | }
62 |
63 | int BooruTag::getCategory()
64 | {
65 | return this->type;
66 | }
67 |
68 | std::string BooruTag::getCategoryType()
69 | {
70 | return this->type_name;
71 | }
72 |
--------------------------------------------------------------------------------
/src/viewer/BooruHeaders/boorutag.h:
--------------------------------------------------------------------------------
1 | #ifndef BOORUTAG_H
2 | #define BOORUTAG_H
3 |
4 | #include
5 | #include "./classBooruSite.h"
6 |
7 | enum TagTypes{
8 | TAG_COMMON = 0,
9 | TAG_ARTIST = 1,
10 | TAG_CHARA = 4
11 | };
12 |
13 | class BooruSite;
14 |
15 | class BooruTag
16 | {
17 | public:
18 | BooruTag(Json::Value root, BooruSite *parent);
19 |
20 | void loadFromJson(Json::Value root);
21 | int getId();
22 | std::string getName();
23 | int getCount();
24 | int getCategory();
25 | std::string getCategoryType();
26 |
27 |
28 | private:
29 | BooruSite *site;
30 |
31 | int id;
32 | std::string name;
33 | int count;
34 | int type;
35 | std::string type_name;
36 | };
37 |
38 | #endif // BOORUTAG_H
39 |
40 | /* Moebooru
41 | {
42 | "id": 88647,
43 | "name": ">_<",
44 | "count": 0,
45 | "type": 0,
46 | "ambiguous": false
47 | }
48 | */
49 |
50 |
--------------------------------------------------------------------------------
/src/viewer/BooruHeaders/boorutaglist.cpp:
--------------------------------------------------------------------------------
1 | #include "boorutaglist.h"
2 |
3 | BooruTagList::BooruTagList(string file_path, BooruSite *parent)
4 | {
5 | this->file_path = file_path;
6 | this->site = parent;
7 |
8 | root = loadJSONFile(file_path.c_str());
9 |
10 | loadTags();
11 | }
12 |
13 | void BooruTagList::loadTags()
14 | {
15 | int i = 0;
16 |
17 | max_tag_length = 0;
18 | max_tag_length_index = 0;
19 |
20 | while(root[i].isObject())
21 | {
22 | tags.push_back(new BooruTag(root[i],site));
23 |
24 | if(tags.at(i)->getName().size() > max_tag_length){max_tag_length = tags.at(i)->getName().size();max_tag_length_index = i;}
25 | i = i+1;
26 | }
27 | }
28 |
29 | std::vector BooruTagList::getTags()
30 | {
31 | return this->tags;
32 | }
33 |
34 | BooruTag* BooruTagList::getTag(int i)
35 | {
36 | if(i < tags.size())
37 | {
38 | return tags.at(i);
39 | }
40 | else
41 | {
42 | return 0;
43 | }
44 | }
45 |
46 | int BooruTagList::size()
47 | {
48 | return tags.size();
49 | }
50 |
51 | int BooruTagList::getMaxTagLength()
52 | {
53 | return this->max_tag_length;
54 | }
55 |
56 | int BooruTagList::getMaxTagLengthIndex()
57 | {
58 | return this->max_tag_length_index;
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/src/viewer/BooruHeaders/boorutaglist.h:
--------------------------------------------------------------------------------
1 | #ifndef BOORUTAGLIST_H
2 | #define BOORUTAGLIST_H
3 |
4 | #include
5 | #include
6 |
7 | #include "./fonctions_all.h"
8 |
9 | #include "boorutag.h"
10 |
11 | class BooruSite;
12 | class BooruTag;
13 |
14 | class BooruTagList
15 | {
16 | public:
17 | BooruTagList(std::string file_path, BooruSite *parent);
18 |
19 | void loadTags();
20 | std::vector getTags();
21 | BooruTag* getTag(int i);
22 | int size();
23 | int getMaxTagLength();
24 | int getMaxTagLengthIndex();
25 |
26 | private:
27 | Json::Value root;
28 |
29 | std::vector tags;
30 | std::string file_path;
31 | BooruSite *site;
32 |
33 | int max_tag_length;
34 | int max_tag_length_index;
35 |
36 | };
37 |
38 | #endif // BOORUTAGLIST_H
39 |
--------------------------------------------------------------------------------
/src/viewer/BooruHeaders/generic_booru_image.h:
--------------------------------------------------------------------------------
1 | #ifndef GENERIC_BOORU_IMAGE_H
2 | #define GENERIC_BOORU_IMAGE_H
3 |
4 | #include
5 | #include "constantes.h"
6 |
7 | #include "../fonctions/fonctions.h"
8 | #include "../fonctions/fonctions_json.h"
9 |
10 | #include "../classBooruSite.h"
11 |
12 |
13 | class BooruImage
14 | {
15 | public :
16 |
17 | /*Fonctions*/
18 | BooruImage();
19 | BooruImage(int booru_index);
20 | BooruImage(BooruSite *booru);
21 | ~BooruImage();
22 |
23 | void setBooru(int booru_index);
24 | void setBooru(BooruSite* booru);
25 | void loadData(int picture_index);
26 | void loadTags(std::string tags_str);
27 | void loadPaths();
28 | void loadPaths(std::string download_folder);
29 | void loadPaths(std::string download_folder,std::string prefix);
30 |
31 | void download_thumb();
32 | void download_medium();
33 | void download_full();
34 |
35 | std::string getThumbPath();
36 | std::string getMediumPath();
37 | std::string getFullPath();
38 |
39 | BooruSite* getBooru();
40 |
41 | /*Header*/
42 | int booru_type;
43 |
44 | /*Data*/
45 | int id;
46 | std::string created_at;
47 | std::string author;
48 | std::string source;
49 |
50 | int score;
51 | int file_size;
52 |
53 | std::vector tags;
54 |
55 | std::string file_url;
56 | int width;
57 | int height;
58 |
59 | std::string preview_url;
60 | int preview_height;
61 | int preview_width;
62 | int actual_preview_height;
63 | int actual_preview_width;
64 |
65 | std::string sample_url;
66 | int sample_width;
67 | int sample_height;
68 | int sample_file_size;
69 |
70 | std::string full_url;
71 | int full_height;
72 | int full_width;
73 | int full_file_size;
74 |
75 | char rating;
76 |
77 | int tagNumber;
78 |
79 | private:
80 |
81 | BooruSite* booru;
82 |
83 | /*Paths*/
84 | std::string thumb_path;
85 | std::string medium_path;
86 | std::string full_path;
87 |
88 | };
89 |
90 | #endif // GENERIC_BOORU_IMAGE_H
91 |
--------------------------------------------------------------------------------
/src/viewer/BooruHeaders/headers.h:
--------------------------------------------------------------------------------
1 | #ifndef HEADERS_H
2 | #define HEADERS_H
3 |
4 | #include "../BooruHeaders/generic_booru_image.h"
5 | #include "../BooruHeaders/booru_search_engine.h"
6 |
7 | #endif // HEADERS_H
8 |
9 |
--------------------------------------------------------------------------------
/src/viewer/QBooruTemplate.app/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSPrincipalClass
6 | NSApplication
7 | CFBundleIconFile
8 | icon.icns
9 | CFBundlePackageType
10 | APPL
11 | CFBundleGetInfoString
12 | Created by Qt/QMake
13 | CFBundleSignature
14 | ????
15 | CFBundleExecutable
16 | QBooru
17 | CFBundleIdentifier
18 | com.FlorentUguet.QBooru
19 | NOTE
20 | This file was generated by Qt/QMake.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/viewer/QBooruTemplate.app/Contents/MacOS/QBooru.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | cd "${0%/*}"
3 | ./QBooru
--------------------------------------------------------------------------------
/src/viewer/QBooruTemplate.app/Contents/PkgInfo:
--------------------------------------------------------------------------------
1 | APPL????
2 |
--------------------------------------------------------------------------------
/src/viewer/QBooruTemplate.app/Contents/_Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSPrincipalClass
6 | NSApplication
7 | CFBundleIconFile
8 | icon.icns
9 | CFBundlePackageType
10 | APPL
11 | CFBundleGetInfoString
12 | Created by Qt/QMake
13 | CFBundleSignature
14 | ????
15 | CFBundleExecutable
16 | QBooru.sh
17 | CFBundleIdentifier
18 | com.FlorentUguet.QBooru
19 | NOTE
20 | This file was generated by Qt/QMake.
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/viewer/Widget/BooruSettingsWidgetClass.h:
--------------------------------------------------------------------------------
1 | #ifndef ADDBOORUTABCLASS_H
2 | #define ADDBOORUTABCLASS_H
3 |
4 | #include
5 |
6 | #include "widget.h"
7 | #include "booruSettingsTabClass.h"
8 |
9 | enum Lines{
10 | L_NAME =0,
11 | L_URL,
12 | L_SIZE
13 | };
14 |
15 | const QString label_strings[L_SIZE] = {"Name","Main URL"};
16 |
17 | class BooruSettingsTab;
18 |
19 | class BooruSettings : public QWidget
20 | {
21 | Q_OBJECT
22 |
23 | public:
24 | BooruSettings(BooruSettingsTab *parent = 0);
25 | ~BooruSettings();
26 |
27 | QList generateInputs();
28 |
29 | /*Objets publics*/
30 | QPushButton *saveButton;
31 |
32 | public slots:
33 | void editBooru();
34 | void loadBooru(int index);
35 | void loadPreset(int index);
36 |
37 | private:
38 |
39 | ConfigFile *conf_file;
40 | QSpacerItem *spacer;
41 | BooruSettingsTab *parentWidget;
42 |
43 | QList lineEdits;
44 |
45 | QVBoxLayout *layoutMain;
46 |
47 | QGroupBox *groupBoxMainSettings;
48 | QVBoxLayout *layoutGroupBoxMainSettings;
49 |
50 | QCheckBox *checkBoxPreset;
51 | QComboBox *comboBoxPreset;
52 | QLabel *labelBooruType;
53 | QComboBox *comboBoxBooruType;
54 |
55 | };
56 |
57 | #endif // ADDBOORUTABCLASS_H
58 |
--------------------------------------------------------------------------------
/src/viewer/Widget/booruSettingsTabClass.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "booruSettingsTabClass.h"
4 | #include "BooruSettingsWidgetClass.h"
5 | #include "../classBooruSite.h"
6 | #include "../json/json.h"
7 | #include "widget.h"
8 | #include "fonctions_all.h"
9 |
10 | BooruSettingsTab::BooruSettingsTab(Widget *parent)
11 | {
12 | conf_file = parent->getConfigFile();
13 |
14 | selectedBooru = 0;
15 | mainGridLayout = new QGridLayout;
16 |
17 | parentWidget = parent;
18 |
19 | QLabel *label2 = new QLabel("Edit Booru", this);
20 | label2->setMaximumSize(label2->maximumWidth(),21);
21 | label2->setStyleSheet("qproperty-alignment: AlignCenter;");
22 |
23 | comboBoxBooru = new QComboBox(this);
24 |
25 | loadBoorus();
26 |
27 | editBooruWidget = new BooruSettings(this);
28 |
29 | mainGridLayout->addWidget(label2,0,0);
30 |
31 | mainGridLayout->addWidget(comboBoxBooru,1,0);
32 |
33 | mainGridLayout->addWidget(editBooruWidget,2,0);
34 |
35 | pushbuttonDeleteBooru = new QPushButton("Delete");
36 |
37 | void (QComboBox:: *indexChangedSignal)(int) = &QComboBox::currentIndexChanged;
38 |
39 | connect(editBooruWidget->saveButton,SIGNAL(clicked()), editBooruWidget, SLOT(editBooru()));
40 | connect(editBooruWidget->saveButton,SIGNAL(clicked()), parentWidget, SLOT(refresh()));
41 |
42 | connect(pushbuttonDeleteBooru,SIGNAL(clicked()), this, SLOT(deleteBooru()));
43 | connect(pushbuttonDeleteBooru,SIGNAL(clicked()), parentWidget, SLOT(refresh()));
44 |
45 | connect(comboBoxBooru,
46 | SIGNAL(currentIndexChanged(int)),
47 | editBooruWidget,
48 | SLOT(loadBooru(int)));
49 |
50 | connect(comboBoxBooru,
51 | SIGNAL(currentIndexChanged(int)),
52 | this,
53 | SLOT(refreshActiveBooru(int)));
54 |
55 | mainGridLayout->addWidget(pushbuttonDeleteBooru,3,0);
56 |
57 | setLayout(mainGridLayout);
58 | }
59 |
60 | BooruSettingsTab::~BooruSettingsTab()
61 | {
62 | //clearLayout(mainGridLayout);
63 | }
64 |
65 | void BooruSettingsTab::refreshActiveBooru(int index)
66 | {
67 | selectedBooru = index;
68 | }
69 |
70 | void BooruSettingsTab::loadBoorus()
71 | {
72 | comboBoxBooru->clear();
73 |
74 | for(int i=0; i < conf_file->getBooruNumber(); i++)
75 | {
76 | comboBoxBooru->addItem(QString(conf_file->getBooru(i)->getName().c_str()));
77 | }
78 |
79 | comboBoxBooru->addItem("New Booru");
80 | }
81 |
82 | void BooruSettingsTab::deleteBooru()
83 | {
84 | int booru_number = conf_file->getBooruNumber();
85 |
86 | for(int i=selectedBooru ; igetBoorus().at(i) = conf_file->getBoorus().at(i+1);
89 | }
90 |
91 | conf_file->getBoorus().erase(conf_file->getBoorus().begin()+booru_number);
92 | conf_file->setBooruNumber(booru_number-1);
93 | conf_file->saveFile();
94 | }
95 |
96 | ConfigFile *BooruSettingsTab::getConfigFile()
97 | {
98 | return conf_file;
99 | }
100 |
--------------------------------------------------------------------------------
/src/viewer/Widget/booruSettingsTabClass.h:
--------------------------------------------------------------------------------
1 | #ifndef BOORUSETTINGSTABCLASS_H
2 | #define BOORUSETTINGSTABCLASS_H
3 |
4 | #include
5 |
6 | #include "../widget.h"
7 | #include "BooruSettingsWidgetClass.h"
8 |
9 | class BooruSettings;
10 |
11 | class BooruSettingsTab : public QWidget
12 | {
13 | Q_OBJECT
14 |
15 | public:
16 | BooruSettingsTab(Widget *parent = 0);
17 | ~BooruSettingsTab();
18 |
19 | /*Objets publics*/
20 | QComboBox *comboBoxBooru;
21 | int selectedBooru;
22 | ConfigFile *getConfigFile();
23 |
24 | public slots:
25 | void deleteBooru();
26 | void refreshActiveBooru(int index);
27 | void loadBoorus();
28 |
29 |
30 | private:
31 | ConfigFile *conf_file;
32 |
33 | QSpacerItem *spacer;
34 | Widget *parentWidget;
35 |
36 | QGridLayout *mainGridLayout;
37 |
38 | BooruSettings *editBooruWidget;
39 |
40 | QPushButton *pushbuttonDeleteBooru;
41 |
42 | };
43 |
44 | #endif // BOORUSETTINGSTABCLASS_H
45 |
--------------------------------------------------------------------------------
/src/viewer/Widget/clickableLabel.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "clickableLabel.h"
3 | #include
4 |
5 | ClickableLabel::ClickableLabel( const QString& text, QWidget * parent ) :
6 | QLabel(parent)
7 |
8 | {
9 | this->setText(text);
10 | }
11 |
12 | ClickableLabel::~ClickableLabel()
13 | {
14 | }
15 |
16 | void ClickableLabel::mousePressEvent ( QMouseEvent * event )
17 |
18 | {
19 | emit clicked();
20 | }
21 |
--------------------------------------------------------------------------------
/src/viewer/Widget/clickableLabel.h:
--------------------------------------------------------------------------------
1 | #ifndef CLICKABLELABEL_H
2 | #define CLICKABLELABEL_H
3 |
4 | #include
5 | #include
6 |
7 | class ClickableLabel : public QLabel
8 | {
9 |
10 | Q_OBJECT
11 |
12 | public:
13 | explicit ClickableLabel( const QString& text ="", QWidget * parent = 0 );
14 | ~ClickableLabel();
15 |
16 | signals:
17 | void clicked();
18 |
19 | protected:
20 | void mousePressEvent ( QMouseEvent * event ) ;
21 | };
22 |
23 | #endif // CLICKABLELABEL_H
24 |
--------------------------------------------------------------------------------
/src/viewer/Widget/fullscreenImageTabClass.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | #include "fullscreenImageTabClass.h"
8 | #include
9 |
10 | FullScreenImageTab::FullScreenImageTab(QWidget *parent, QString imagePath)
11 | {
12 | image = new QLabel(this);
13 | scrollAreaTags = new QScrollArea(this);
14 |
15 | QPixmap *imagePixmap = new QPixmap(imagePath);
16 | QHBoxLayout *mainLayout = new QHBoxLayout(this);
17 |
18 | QSize imageSize = imagePixmap->size();
19 | image->setPixmap(QPixmap(imagePath).scaled(imageSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
20 |
21 | scrollAreaTags->setWidget(image);
22 | mainLayout->addWidget(scrollAreaTags);
23 | setLayout(mainLayout);
24 | setWindowState(Qt::WindowMaximized);
25 | setWindowTitle("Fullscreen");
26 |
27 | delete imagePixmap;
28 | }
29 |
30 | FullScreenImageTab::~FullScreenImageTab()
31 | {
32 | SDL_Quit();
33 | }
34 |
--------------------------------------------------------------------------------
/src/viewer/Widget/fullscreenImageTabClass.h:
--------------------------------------------------------------------------------
1 | #ifndef FULLSCREENIMAGETABCLASS_H
2 | #define FULLSCREENIMAGETABCLASS_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | class FullScreenImageTab : public QWidget
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | FullScreenImageTab(QWidget *parent = 0, QString imagePath = "");
16 | ~FullScreenImageTab();
17 |
18 | private:
19 | QScrollArea *scrollAreaTags;
20 | QLabel *image;
21 |
22 | };
23 |
24 | #endif // FULLSCREENIMAGETABCLASS_H
25 |
--------------------------------------------------------------------------------
/src/viewer/Widget/grabberwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef GRABBERWIDGET_H
2 | #define GRABBERWIDGET_H
3 |
4 | #include
5 |
6 | #include "../Workers/imagegrabber.h"
7 | #include "../Workers/cookiejar.h"
8 | #include "../config_file.h"
9 |
10 | class Widget;
11 |
12 | class GrabberWidget : public QWidget
13 | {
14 | Q_OBJECT
15 | public:
16 | GrabberWidget(Widget *parent = 0);
17 |
18 | signals:
19 |
20 | public slots:
21 | void updateProgress(int progress, int total);
22 | void updateStatus(QString status);
23 | void login(int booru_index);
24 | void startProcess();
25 |
26 | private:
27 | QSignalMapper *mapper;
28 |
29 | ImageGrabber* grabber;
30 | ConfigFile *cfg;
31 |
32 | QList checkBoxes;
33 | QList buttonsLogin;
34 |
35 | std::vector cookies;
36 |
37 | QLabel *labelStatus;
38 | QProgressBar *progressBar;
39 | QLineEdit *lineEditTags;
40 | QComboBox *searchRating;
41 | QLineEdit *lineEditLimit;
42 |
43 |
44 | };
45 |
46 | #endif // GRABBERWIDGET_H
47 |
--------------------------------------------------------------------------------
/src/viewer/Widget/imageTabClass.cpp:
--------------------------------------------------------------------------------
1 | #include "imageTabClass.h"
2 | #include "constantes.h"
3 | #include "fonctions_all.h"
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | ImageTab::ImageTab(SearchTab *parent, int imageHostInt) : QWidget(parent)
12 | {
13 |
14 | setParent(parent);
15 |
16 | conf_file = parent->getConfigFile();
17 |
18 | imageHost = imageHostInt;
19 | parentWidget = parent;
20 |
21 | layout = new QVBoxLayout;
22 | imageThumbnail = new ClickableLabel("Thumbnail");
23 | imageDescription = new QLabel("Description");
24 |
25 | imageThumbnail->setPixmap(QPixmap(ICON_PATH));
26 | imageThumbnail->setStyleSheet("qproperty-alignment: AlignCenter;");
27 | imageThumbnail->setMinimumSize(100,100);
28 |
29 | imageDescription->setStyleSheet("qproperty-alignment: AlignCenter;");
30 | imageDescription->setMaximumSize(imageDescription->maximumWidth(),21);
31 |
32 |
33 | imageThumbnail->setAlignment(Qt::AlignCenter);
34 | imageDescription->setAlignment(Qt::AlignCenter);
35 |
36 | layout->addWidget(imageThumbnail);
37 | layout->addWidget(imageDescription);
38 | layout->setSizeConstraint(layout->SetNoConstraint);
39 |
40 | thumbnailPath = QString(ICON_PATH);
41 |
42 | setLayout(layout);
43 | }
44 |
45 | ImageTab::~ImageTab()
46 | {
47 | //clearLayoutSecond(layout);
48 | }
49 |
50 | void ImageTab::loadPicture(QString imagePath, QString comment)
51 | {
52 | this->updateGeometry();
53 |
54 | thumbnailPath = imagePath;
55 | commentString = comment;
56 |
57 | QPixmap pixmap = QPixmap(thumbnailPath);
58 |
59 | QSize imageSize = imageThumbnail->size();
60 | QSize windowSize = parentWidget->size();
61 |
62 | int width = windowSize.width();
63 | int height = windowSize.height();
64 |
65 | if(height < 768){height = 768;}
66 | if(width < 1024){width = 1024;}
67 |
68 | parentWidget->getImageTabsWidget()->updateGeometry();
69 |
70 | imageSize.setWidth(parentWidget->getImageTabsWidget()->width() / conf_file->getPictureColumns());
71 | imageSize.setHeight((parentWidget->getImageTabsWidget()->height() / conf_file->getPictureRow()) - imageDescription->height()*2);
72 |
73 | //outputInfo(L_DEBUG,"Size : " + intToString(imageSize.width()) + "x" + intToString(imageSize.height()));
74 | //imageSize.setWidth(125);
75 | //imageSize.setHeight(125);
76 |
77 | imageThumbnail->setPixmap(pixmap.scaled(imageSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
78 | imageDescription->setText(commentString);
79 | }
80 |
81 | void ImageTab::resizeEvent(QResizeEvent * event)
82 | {
83 | }
84 |
--------------------------------------------------------------------------------
/src/viewer/Widget/imageTabClass.h:
--------------------------------------------------------------------------------
1 | #ifndef IMAGETABCLASS_H
2 | #define IMAGETABCLASS_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | #include "clickableLabel.h"
13 | #include "searchTabClass.h"
14 |
15 | #include "../config_file.h"
16 |
17 | class SearchTab;
18 |
19 | class ImageTab : public QWidget
20 | {
21 | Q_OBJECT
22 |
23 | public:
24 | ImageTab(SearchTab *parent = 0, int imageHostInt = 3);
25 | ~ImageTab();
26 | void loadPicture(QString imagePath, QString comment);
27 | void resizeEvent(QResizeEvent * event);
28 |
29 | /*Objets publics*/
30 | ClickableLabel *imageThumbnail;
31 | QMovie *loadingAnimation;
32 |
33 | private:
34 | ConfigFile *conf_file;
35 | SearchTab *parentWidget;
36 |
37 | QString thumbnailPath;
38 | QString commentString;
39 |
40 | QVBoxLayout *layout;
41 | QLabel *imageDescription;
42 |
43 | int imageHost;
44 |
45 | };
46 |
47 | #endif // IMAGETABCLASS_H
48 |
--------------------------------------------------------------------------------
/src/viewer/Widget/optionTabClass.h:
--------------------------------------------------------------------------------
1 | #ifndef OPTIONTABCLASS_H
2 | #define OPTIONTABCLASS_H
3 |
4 | #define LAYOUT_NUMBER_OPTIONS 8 //Number of layouts in Options tab
5 |
6 | #include
7 |
8 | #include "../widget.h"
9 |
10 | class Widget;
11 |
12 | class OptionTab : public QWidget
13 | {
14 | Q_OBJECT
15 |
16 | public:
17 | OptionTab(Widget *parent = 0);
18 | ~OptionTab();
19 |
20 | void refreshTagTime();
21 |
22 | public slots:
23 | void refreshCacheSize();
24 | void deleteCache();
25 | void refreshTagLists();
26 | void runUpdater();
27 | void resetBoorusSettings();
28 | void resetBooruDownloadPath();
29 | void saveOptions();
30 |
31 | private:
32 |
33 | ConfigFile *conf_file;
34 |
35 | QHBoxLayout *horizontalLayouts[LAYOUT_NUMBER_OPTIONS];
36 |
37 | QSpacerItem *spacer;
38 | Widget *parentWidget;
39 |
40 | QGroupBox *groupBoxSearchSettings;
41 | QVBoxLayout *layoutGroupBoxSearchSettings;
42 |
43 | QVBoxLayout *layoutMain;
44 | QLabel *credits;
45 |
46 | QPushButton *pushButtonUpdater;
47 |
48 | QGroupBox *groupBox;
49 | QVBoxLayout *layoutGroupBox;
50 | QGroupBox *groupBoxCredits;
51 |
52 | QPushButton *pushButtonCache;
53 | QPushButton *pushButtonReset;
54 | QLabel *labelCache;
55 |
56 | QPushButton *pushButtonTags;
57 | QLabel *labelTags;
58 |
59 | QPushButton *pushButtonResetAllDownloadPath;
60 | QLineEdit *lineEditDownloadPath;
61 |
62 | QCheckBox *checkBoxLoadingStartup;
63 | QLabel *labelDefaultRating;
64 | QComboBox *searchRating;
65 | QLabel *labelDefaultBooru;
66 | QComboBox *defaultBooru;
67 | QPushButton *pushButtonRefreshCacheSize;
68 |
69 |
70 | QHBoxLayout *layoutImages[2];
71 | QLabel *labelQuadrillageImages[2];
72 | QComboBox *nbImages[2];
73 |
74 | QTextBrowser *textBrowserChangelog;
75 |
76 | QPushButton *pushButtonSave;
77 |
78 | int imageHost;
79 |
80 | };
81 |
82 | #endif // OPTIONTABCLASS_H
83 |
--------------------------------------------------------------------------------
/src/viewer/Widget/qdownloadwidget.cpp:
--------------------------------------------------------------------------------
1 | #include "qdownloadwidget.h"
2 |
3 | QDownloadWidget::QDownloadWidget(QWidget *parent, bool reboot) : QWidget(parent)
4 | {
5 | this->reboot = reboot;
6 | labelFile = new QLabel("File",this);
7 | labelUrl = new QLabel("URL",this);
8 | progressBar = new QProgressBar(this);
9 | labelProgress = new QLabel("Progress",this);
10 |
11 | QVBoxLayout *layout = new QVBoxLayout;
12 |
13 | layout->addWidget(labelFile);
14 | layout->addWidget(labelUrl);
15 | layout->addWidget(progressBar);
16 | layout->addWidget(labelProgress);
17 |
18 | setLayout(layout);
19 | }
20 |
21 | void QDownloadWidget::download(const char* url, const char* file, bool override)
22 | {
23 | this->url = QString(url);
24 | this->file = QString(file);
25 |
26 | labelFile->setText("File: " + this->file);
27 | labelUrl->setText("URL: " + this->url);
28 | labelProgress->setText("Initializing (May take some time)");
29 |
30 | savefile = new QFile;
31 | savefile->setFileName(this->file);
32 |
33 | if(fexists(file) && !override)
34 | {
35 | progressBar->setValue(100);
36 | labelProgress->setText("Already existing");
37 | }
38 | else
39 | {
40 | //Getting redirection
41 |
42 | QUrl file_url = findRedirection(QUrl(QString(url)));
43 |
44 | //Synchronous download
45 | nam = new QNetworkAccessManager;
46 | QNetworkRequest request;
47 |
48 |
49 | request.setUrl(file_url.toString());
50 | request.setRawHeader("User-Agent", "TulpaDiary");
51 | request.setRawHeader("Content-Type","application/x-www-form-urlencoded");
52 |
53 | reply = nam->get(request);
54 |
55 | connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(onDownloadProgress(qint64,qint64)));
56 | connect(reply,SIGNAL(finished()),this,SLOT(finished()));
57 | }
58 | }
59 |
60 | void QDownloadWidget::onDownloadProgress(qint64 bytesRead,qint64 bytesTotal)
61 | {
62 | labelProgress->setText(QString("Downloading ") + QString::number(bytesRead) + QString("/") + QString::number(bytesTotal));
63 | progressBar->setMaximum(bytesTotal);
64 | progressBar->setValue(bytesRead);
65 | }
66 |
67 | void QDownloadWidget::finished()
68 | {
69 | if(reply->error() != QNetworkReply::NoError)
70 | {
71 | labelProgress->setText("Error : " + reply->error());
72 | qDebug() << "Error while downloading " << url << " : " << reply->error() ;
73 | }
74 | else
75 | {
76 | savefile->open(QIODevice::WriteOnly);
77 | QDataStream out(savefile);
78 | out << reply->readAll();
79 | reply->deleteLater();
80 | savefile->close();
81 |
82 | labelProgress->setText("File saved");
83 |
84 | qDebug() << "Downloaded" << url << "to" << file ;
85 | }
86 |
87 | if(reboot)
88 | {
89 | qApp->exit(EXIT_CODE_UPDATE);
90 | }
91 |
92 | this->close();
93 | }
94 |
--------------------------------------------------------------------------------
/src/viewer/Widget/qdownloadwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef QDOWNLOADWIDGET_H
2 | #define QDOWNLOADWIDGET_H
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include "../constantes.h"
14 | #include "../fonctions_all.h"
15 |
16 | class QDownloadWidget : public QWidget
17 | {
18 | Q_OBJECT
19 | public:
20 | QDownloadWidget(QWidget *parent = 0, bool reboot = false);
21 |
22 | signals:
23 |
24 | public slots:
25 | void download(const char* url, const char* file, bool override = true);
26 | void onDownloadProgress(qint64 bytesRead,qint64 bytesTotal);
27 | void finished();
28 |
29 | private:
30 | QNetworkAccessManager *nam;
31 |
32 | QLabel *labelFile;
33 | QLabel *labelUrl;
34 | QProgressBar *progressBar;
35 | QLabel *labelProgress;
36 |
37 | QString url;
38 | QString file;
39 |
40 | QFile *savefile;
41 | QNetworkReply* reply;
42 |
43 | bool reboot;
44 | };
45 |
46 | #endif // QDOWNLOADWIDGET_H
47 |
--------------------------------------------------------------------------------
/src/viewer/Widget/qstartupwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef QSTARTUPWIDGET_H
2 | #define QSTARTUPWIDGET_H
3 |
4 | #include
5 | #include "../config_file.h"
6 | #include "../fonctions_all.h"
7 |
8 | #include "qdownloadwidget.h"
9 |
10 | class QStartupWidget : public QWidget
11 | {
12 | Q_OBJECT
13 | public:
14 | QStartupWidget(QWidget *parent = 0);
15 |
16 | void loadUI();
17 | void process();
18 | int checkVersions();
19 | void loadConfigFile();
20 | ConfigFile *getCfg();
21 |
22 | signals:
23 | void finished();
24 | void processStatus(QString status);
25 |
26 | public slots:
27 | void updateStatus(QString status);
28 |
29 | private:
30 | ConfigFile *cfg;
31 |
32 | QProgressBar *progressBar;
33 | QLabel *labelStatus;
34 | };
35 |
36 | #endif // QSTARTUPWIDGET_H
37 |
--------------------------------------------------------------------------------
/src/viewer/Widget/searchTabClass.h:
--------------------------------------------------------------------------------
1 | #ifndef SEARCH_TAB_H
2 | #define SEARCH_TAB_H
3 |
4 | #include
5 |
6 | #include "imageTabClass.h"
7 | #include "../config_file.h"
8 |
9 | #include "../BooruHeaders/headers.h"
10 |
11 | #include "../classBooruSite.h"
12 | #include "../Workers/caching_thread.h"
13 | #include "../Workers/image_loading_thread.h"
14 | #include "../Workers/cookiejar.h"
15 |
16 | #include"../Workers/downloadworker.h"
17 |
18 | class Widget;
19 | class ImageTab;
20 | class CachingWorker;
21 | class SearchTabLoadingWorker;
22 | class BooruSite;
23 |
24 | class SearchTab : public QWidget
25 | {
26 | Q_OBJECT
27 |
28 | public:
29 | SearchTab(Widget *parent, BooruSite *site);
30 | ~SearchTab();
31 |
32 | void initialisationMiniatures();
33 | void loadTagViewer(QString tagString);
34 | void loadSearch(int refreshTags);
35 |
36 | void setLoadingState(int i, bool state);
37 | void on_pushButton_pageMoins_clicked();
38 | void on_pushButton_pagePlus_clicked();
39 | void setKeyboard();
40 | void checkPageButtonStatus();
41 | void setRating(const char* rating);
42 |
43 | void updateSearchStatus(int progress, QString text);
44 | ConfigFile *getConfigFile();
45 |
46 | QWidget* getImageTabsWidget();
47 |
48 |
49 | /*Objets*/
50 | BooruImage images[64];
51 | BooruSite* booru;
52 | BooruSearchEngine* booru_search_engine;
53 |
54 | QVBoxLayout *layoutSearchStatus;
55 | QLineEdit *lineEditTags;
56 | QProgressBar *progressBarSearch;
57 | QLabel *labelSearchStatus;
58 |
59 | QThread *thread_pool[64];
60 | CachingWorker *caching_worker_pool[64];
61 |
62 | QThread *thread_pool_loading[64];
63 | SearchTabLoadingWorker *loading_worker[64];
64 | ImageTab *imageTabs[64];
65 |
66 | int picture_number;
67 | int picture_rows;
68 | int picture_columns;
69 |
70 |
71 | protected:
72 | bool eventFilter(QObject *object, QEvent *event);
73 |
74 | signals:
75 |
76 | public slots:
77 | void login();
78 | void searchActionToggled(int sender);
79 | void setViewer(int sender);
80 | void newSearch();
81 | void startLoadingPicture(int i);
82 | void image_loaded(int index);
83 | void startDumpingPicture();
84 | void updateDumping();
85 |
86 | private:
87 | int dump_progress;
88 | ConfigFile *conf_file;
89 | CookieJar* cookie;
90 |
91 | int loaded_pictures;
92 | int recherche;
93 | int progress;
94 |
95 | std::string derpibooruAPIKey;
96 | QString tagsSearched;
97 |
98 | QSignalMapper *signalMapper;
99 | QSignalMapper *buttonMapper;
100 |
101 | bool isAffiched[64];
102 | bool isLoading[64];
103 |
104 | Widget *parentWidget;
105 |
106 | QVBoxLayout *layoutMain;
107 |
108 | QHBoxLayout *layoutSearch;
109 | QHBoxLayout *layoutTags;
110 |
111 | QPushButton *searchButton;
112 | QPushButton *loginButton;
113 | QPushButton *dumpButton;
114 |
115 | QHBoxLayout *layoutSearchRating;
116 | QComboBox *searchRating;
117 |
118 | QWidget *widgetImageTabs;
119 | QGridLayout *layoutImageTabs;
120 |
121 | QHBoxLayout *layoutSearchPage;
122 | QPushButton *pushButtonPageMoins;
123 | QLineEdit *lineEditPageSet;
124 | QPushButton *pushButtonPagePlus;
125 |
126 | };
127 |
128 | #endif // SEARCH_TAB_H
129 |
--------------------------------------------------------------------------------
/src/viewer/Widget/viewerTabClass.h:
--------------------------------------------------------------------------------
1 | #ifndef VIEWERTABCLASS_H
2 | #define VIEWERTABCLASS_H
3 |
4 | #include
5 |
6 | #include "constantes.h"
7 |
8 | #include "BooruHeaders/generic_booru_image.h"
9 |
10 | #include "../widget.h"
11 | #include "../BooruHeaders/headers.h"
12 | #include "../classBooruSite.h"
13 | #include "../Workers/viewer_loading_thread.h"
14 |
15 | class BooruSite;
16 | class ViewerTabLoadingWorker;
17 |
18 | class ViewerTab: public QWidget
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | ViewerTab(Widget *parent = 0);
24 | ~ViewerTab();
25 |
26 | void loadLabelsTags(std::vector tagsArray);
27 |
28 | void loadPicture(int imageHostInt, int tabIndex, int index, int pageIndexInt, BooruSite* booruSite);
29 | void loadPicture();
30 |
31 | void setLoadingState(bool state);
32 |
33 | bool eventFilter(QObject *object, QEvent *event);
34 | void setKeyboard();
35 |
36 | void checkIfDownloaded();
37 |
38 | /*Public objects*/
39 | BooruImage Image;
40 |
41 | BooruSite* booru;
42 |
43 | QLabel *labelLoading;
44 | QLabel *labelImage;
45 |
46 | QProgressBar *progressBar;
47 | QSize thumbZoneSize;
48 | QString imageViewer;
49 |
50 | public slots:
51 | void buttonClicked();
52 | void on_tagSelected(QString tag);
53 | void downloadPicture();
54 | void showPreviousPicture();
55 | void showNextPicture();
56 | void startLoadingPicture();
57 | void imageLoaded();
58 |
59 |
60 | private:
61 | Widget *parentWidget;
62 |
63 | QString fullImagePath;
64 | char* currentTagList;
65 |
66 | QHBoxLayout *layoutMain;
67 |
68 |
69 | QVBoxLayout *layoutInfoTagsSeparator;
70 |
71 | QScrollArea *scrollAreaTags;
72 | QWidget *scrollAreaTagsContents;
73 | QVBoxLayout *layoutTags;
74 | std::vectortags;
75 |
76 | QGroupBox *groupBoxInfo;
77 | QVBoxLayout *layoutGroupBox;
78 | QLabel *labelInfo[16];
79 |
80 | QPushButton *pushButtonDownload;
81 |
82 | QHBoxLayout *layoutSwitchPicture;
83 | QPushButton *pushButtonSwitchMoins;
84 | QPushButton *pushButtonSwitchPlus;
85 |
86 | QLabel *labelPage;
87 |
88 | int imageHost;
89 | int imageIndex;
90 | int pageIndex;
91 | bool isLoading;
92 | QThread *picture_thread;
93 | ViewerTabLoadingWorker *worker;
94 |
95 | };
96 |
97 | #endif // VIEWERTABCLASS_H
98 |
--------------------------------------------------------------------------------
/src/viewer/Workers/caching_thread.cpp:
--------------------------------------------------------------------------------
1 | #include "caching_thread.h"
2 |
3 | // --- CONSTRUCTOR ---
4 | CachingWorker::CachingWorker(const char* url, const char* outfilename, bool needs_output)
5 | {
6 | //file_url = url;
7 | output_text = needs_output;
8 | strncpy(file_url, url, 4096);
9 | strncpy(file_name, outfilename, 4096);
10 | }
11 |
12 | CachingWorker::CachingWorker()
13 | {
14 |
15 | }
16 |
17 | // --- DECONSTRUCTOR ---
18 | CachingWorker::~CachingWorker()
19 | {
20 | // free resources
21 | }
22 |
23 | // --- PROCESS ---
24 | void CachingWorker::process()
25 | {
26 | downloadFile(file_url,file_name,false,output_text,false);
27 | emit finished();
28 | }
29 |
--------------------------------------------------------------------------------
/src/viewer/Workers/caching_thread.h:
--------------------------------------------------------------------------------
1 | #ifndef CACHING_THREAD_H_INCLUDED
2 | #define CACHING_THREAD_H_INCLUDED
3 |
4 | #include
5 | #include
6 | #include "../fonctions_all.h"
7 |
8 | class SearchTab;
9 | class CachingWorker : public QObject
10 | {
11 | Q_OBJECT
12 |
13 | public:
14 | CachingWorker(const char *url, const char *outfilename, bool needs_output);
15 | CachingWorker();
16 | ~CachingWorker();
17 |
18 | char* file_name;
19 | char* file_url;
20 | bool output_text;
21 | int connection_state;
22 |
23 | public slots:
24 | void process();
25 |
26 | signals:
27 | void finished();
28 | void error(QString err);
29 |
30 | private:
31 |
32 | };
33 |
34 | #endif//CACHING_THREAD_H_INCLUDED
35 |
--------------------------------------------------------------------------------
/src/viewer/Workers/cookiejar.cpp:
--------------------------------------------------------------------------------
1 | #include "cookiejar.h"
2 |
3 | CookieJar::CookieJar(QObject *parent) : QNetworkCookieJar(parent), m_loaded(false)
4 | {
5 | path = QString(CONF_PATH) + QString(FILE_NAME);
6 | cookie_location = QString("cookies");
7 | }
8 |
9 | CookieJar::CookieJar(QString booru_name, QObject *parent) : QNetworkCookieJar(parent), m_loaded(false)
10 | {
11 | path = QString(CACHE_PATH) + booru_name + QString("/") + QString(FILE_NAME);
12 | cookie_location = QString("cookies");
13 | }
14 |
15 | void CookieJar::load()
16 | {
17 | if (m_loaded)
18 | return;
19 |
20 | QSettings *settings = new QSettings(path, QSettings::IniFormat);
21 | settings->beginGroup(cookie_location);
22 |
23 | QList savedCookies;
24 |
25 | for(int i=0;iallKeys().size();i++)
26 | {
27 | //Load existing cookies
28 | savedCookies.push_back(QNetworkCookie::parseCookies(settings->value(settings->allKeys().at(i)).toByteArray()).at(0));
29 | }
30 | qDebug() << "Saved cookies at" << path << ":" << savedCookies;
31 |
32 | for (int j = 0; j < savedCookies.count(); j++)
33 | insertCookie(savedCookies.at(j));
34 |
35 | m_loaded = true;
36 | emit cookiesChanged();
37 | }
38 |
39 | void CookieJar::save()
40 | {
41 | if (!m_loaded)
42 | return;
43 |
44 | QList cookies = allCookies();
45 |
46 | qDebug() << "Saving cookies at" << path << ":" << cookies;
47 |
48 | QSettings *settings = new QSettings(path, QSettings::IniFormat);
49 | settings->beginGroup(cookie_location);
50 |
51 | for(int i=0;isetValue(cookies[i].name(), cookies[i].toRawForm());
55 | }
56 | }
57 |
58 | QList CookieJar::cookiesForUrl(const QUrl &url) const
59 | {
60 | // This function is called by the default QNetworkAccessManager::createRequest(),
61 | // which adds the cookies returned by this function to the request being sent.
62 |
63 | CookieJar *that = const_cast(this);
64 | if (!m_loaded)
65 | that->load();
66 |
67 | return QNetworkCookieJar::cookiesForUrl(url);
68 | }
69 |
70 | bool CookieJar::setCookiesFromUrl(const QList &cookieList, const QUrl &url)
71 | {
72 | if (!m_loaded)
73 | load();
74 |
75 | QNetworkCookieJar::setCookiesFromUrl(cookieList, url);
76 | save(); //Save cookie permanently in setting file.
77 | emit cookiesChanged();
78 | return true;
79 | }
80 |
81 | bool CookieJar::isEmpty()
82 | {
83 | if(m_loaded)
84 | {
85 | return this->allCookies().empty();
86 | }
87 | else
88 | {
89 | return true;
90 | }
91 |
92 | }
93 |
94 | QList CookieJar::getAllCookies()
95 | {
96 | return this->allCookies();
97 | }
98 |
99 | QString CookieJar::getUrl()
100 | {
101 | return QString("http://") + this->allCookies().at(0).domain();
102 | }
103 |
104 | QString CookieJar::getCookieData(int id)
105 | {
106 | return QString(this->allCookies().at(id).value());
107 | }
108 |
--------------------------------------------------------------------------------
/src/viewer/Workers/cookiejar.h:
--------------------------------------------------------------------------------
1 | #ifndef COOKIEJAR_H
2 | #define COOKIEJAR_H
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include "../classBooruSite.h"
9 |
10 | #define FILE_NAME "cookies.ini"
11 |
12 | class CookieJar : public QNetworkCookieJar
13 | {
14 | Q_OBJECT
15 | public:
16 | CookieJar(QObject *parent = 0);
17 | CookieJar(QString booru_name, QObject *parent = 0);
18 | void load();
19 | void save();
20 | QList cookiesForUrl(const QUrl &url) const;
21 | bool setCookiesFromUrl(const QList &cookieList, const QUrl &url);
22 | bool isEmpty();
23 | QList getAllCookies();
24 | QString getUrl();
25 | QString getCookieData(int id);
26 |
27 | signals:
28 | void cookiesChanged();
29 |
30 | private:
31 | bool m_loaded;
32 | QString path;
33 | QString cookie_location;
34 | };
35 |
36 | #endif // COOKIEJAR_H
37 |
--------------------------------------------------------------------------------
/src/viewer/Workers/downloadworker.cpp:
--------------------------------------------------------------------------------
1 | #include "downloadworker.h"
2 |
3 | // --- CONSTRUCTOR ---
4 | ImageDownloadWorker::ImageDownloadWorker(BooruImage *image)
5 | {
6 | this->image = image;
7 | }
8 |
9 | ImageDownloadWorker::ImageDownloadWorker()
10 | {
11 |
12 | }
13 |
14 | // --- DECONSTRUCTOR ---
15 | ImageDownloadWorker::~ImageDownloadWorker()
16 | {
17 | // free resources
18 | }
19 |
20 | // --- PROCESS ---
21 | void ImageDownloadWorker::process()
22 | {
23 | image->download_full();
24 | emit finished();
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/src/viewer/Workers/downloadworker.h:
--------------------------------------------------------------------------------
1 | #ifndef DOWNLOADWORKER_H
2 | #define DOWNLOADWORKER_H
3 |
4 | #include
5 | #include "../BooruHeaders/generic_booru_image.h"
6 |
7 | class ImageDownloadWorker : public QObject
8 | {
9 | Q_OBJECT
10 | public:
11 | ImageDownloadWorker(BooruImage *image);
12 | ImageDownloadWorker();
13 | ~ImageDownloadWorker();
14 |
15 | public slots:
16 | void process();
17 |
18 | signals:
19 | void finished();
20 | void error(QString err);
21 |
22 | private:
23 | BooruImage *image;
24 |
25 | };
26 |
27 | #endif // DOWNLOADWORKER_H
28 |
--------------------------------------------------------------------------------
/src/viewer/Workers/file_downloader.cpp:
--------------------------------------------------------------------------------
1 | #include "file_downloader.h"
2 |
3 | FileDownloader::FileDownloader(QObject *parent) : QObject(parent)
4 | {
5 | loop = new QEventLoop(this);
6 | connect(&m_WebCtrl, SIGNAL (finished(QNetworkReply*)),this, SLOT (fileDownloaded(QNetworkReply*)));
7 | connect(this, SIGNAL(saved()), loop, SLOT(quit()));
8 | }
9 |
10 | FileDownloader::FileDownloader(const char *url, const char *filename, QObject *parent) : QObject(parent)
11 | {
12 | loop = new QEventLoop(this);
13 | connect(&m_WebCtrl, SIGNAL (finished(QNetworkReply*)),this, SLOT (fileDownloaded(QNetworkReply*)));
14 | connect(this, SIGNAL(saved()), loop, SLOT(quit()));
15 | download(url, filename);
16 | }
17 |
18 | void FileDownloader::download(const char *url, const char *filename)
19 | {
20 | QString referer = "Dummy referer";
21 |
22 | this->m_Filename = QString(filename);
23 | this->m_Url = QString(url);
24 |
25 | QUrl file_url(m_Url);
26 |
27 | this->m_Url = findRedirection(file_url).toString();
28 | QUrl new_url(m_Url);
29 |
30 | QNetworkRequest request;
31 |
32 | request.setUrl(new_url.toString());
33 | request.setRawHeader("User-Agent", "QBooru");
34 | //request.setRawHeader("Referer", referer);
35 |
36 | m_WebCtrl.get(request);
37 | }
38 |
39 | void FileDownloader::fileDownloaded(QNetworkReply* pReply) {
40 | m_DownloadedData = pReply->readAll();
41 | //emit a signal
42 | delete pReply;
43 |
44 | emit downloaded();
45 |
46 | saveData();
47 | }
48 |
49 | QByteArray FileDownloader::downloadedData() const {
50 | return m_DownloadedData;
51 | }
52 |
53 | void FileDownloader::saveData()
54 | {
55 | QFile file(m_Filename);
56 |
57 | file.open(QIODevice::WriteOnly);
58 | file.write(this->downloadedData());
59 | file.close();
60 | emit saved();
61 | }
62 |
63 | /*Redirection*/
64 | QUrl FileDownloader::findRedirection(QUrl url)
65 | {
66 | QNAMRedirect redirect;
67 | redirect.processUrl(url.toString());
68 |
69 | QEventLoop loop;
70 | QObject::connect(&redirect, SIGNAL(finished()),&loop, SLOT(quit()));
71 | loop.exec();
72 |
73 | qDebug() << "URl :" << redirect.getLastRedirect();
74 | return redirect.getLastRedirect();
75 | }
76 |
--------------------------------------------------------------------------------
/src/viewer/Workers/file_downloader.h:
--------------------------------------------------------------------------------
1 | #ifndef FILEDOWNLOADER_H
2 | #define FILEDOWNLOADER_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | #include "qnamredirect.h"
13 |
14 | #include
15 |
16 | class FileDownloader : public QObject
17 | {
18 | Q_OBJECT
19 | public:
20 | FileDownloader(QObject *parent = 0);
21 | FileDownloader(const char* url, const char* filename, QObject *parent = 0);
22 | void download(const char *url, const char *filename);
23 | QByteArray downloadedData() const;
24 |
25 | QUrl findRedirection(QUrl url);
26 |
27 | signals:
28 | void downloaded();
29 | void saved();
30 |
31 | public slots:
32 | void fileDownloaded(QNetworkReply* pReply);
33 | void saveData();
34 |
35 | private:
36 | QEventLoop *loop;
37 | QString m_Url;
38 | QString m_Filename;
39 | QNetworkAccessManager m_WebCtrl;
40 | QByteArray m_DownloadedData;
41 | };
42 |
43 | #endif // FILEDOWNLOADER_H
44 |
--------------------------------------------------------------------------------
/src/viewer/Workers/image_loading_thread.cpp:
--------------------------------------------------------------------------------
1 | #include "image_loading_thread.h"
2 |
3 | // --- CONSTRUCTOR ---
4 | SearchTabLoadingWorker::SearchTabLoadingWorker()
5 | {
6 | parent_tab = 0;
7 | index = 0;
8 | }
9 |
10 | SearchTabLoadingWorker::SearchTabLoadingWorker(SearchTab *parent, int image_index)
11 | {
12 | parent_tab = parent;
13 | index = image_index;
14 | }
15 |
16 | // --- DECONSTRUCTOR ---
17 | SearchTabLoadingWorker::~SearchTabLoadingWorker()
18 | {
19 | // free resources
20 | }
21 |
22 | // --- PROCESS ---
23 | void SearchTabLoadingWorker::setPicture(SearchTab *parent, int image_index)
24 | {
25 | parent_tab = parent;
26 | index = image_index;
27 | }
28 |
29 | void SearchTabLoadingWorker::process()
30 | {
31 | QString pathFile;
32 | QString uploader;
33 |
34 | parent_tab->setLoadingState(index, true);
35 | parent_tab->thread_pool[index] = new QThread(this);
36 |
37 | parent_tab->images[index].download_thumb();
38 | uploader = QString::number(parent_tab->images[index].width) + QString("x") + QString::number(parent_tab->images[index].height);
39 |
40 | parent_tab->imageTabs[index]->loadPicture(QString(parent_tab->images[index].getThumbPath().c_str()), uploader);
41 |
42 | parent_tab->setLoadingState(index, false);
43 |
44 | emit finished(index);
45 | emit finished();
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/src/viewer/Workers/image_loading_thread.h:
--------------------------------------------------------------------------------
1 | #ifndef IMAGE_LOADING_THREAD_H
2 | #define IMAGE_LOADING_THREAD_H
3 |
4 | #include "../Widget/searchTabClass.h"
5 | #include
6 | #include
7 |
8 | class SearchTabLoadingWorker : public QObject
9 | {
10 | Q_OBJECT
11 |
12 | public:
13 | SearchTabLoadingWorker();
14 | SearchTabLoadingWorker(SearchTab *parent, int image_index);
15 | ~SearchTabLoadingWorker();
16 |
17 | public slots:
18 | void process();
19 | void setPicture(SearchTab *parent, int image_index);
20 |
21 | signals:
22 | void finished(int index);
23 | void finished();
24 | void error(QString err);
25 |
26 | private:
27 | SearchTab *parent_tab;
28 | int index;
29 | };
30 |
31 | #endif // IMAGE_LOADING_THREAD_H
32 |
--------------------------------------------------------------------------------
/src/viewer/Workers/imagegrabber.h:
--------------------------------------------------------------------------------
1 | #ifndef IMAGEGRABBER_H
2 | #define IMAGEGRABBER_H
3 |
4 | #include
5 |
6 | #include "../fonctions_all.h"
7 | #include "../BooruHeaders/booru_search_engine.h"
8 | #include "../BooruHeaders/generic_booru_image.h"
9 |
10 | class ImageGrabber : public QObject
11 | {
12 | Q_OBJECT
13 | public:
14 | ImageGrabber(std::vector boorus, std::string tags, int rating = 0, int limit = 0, QObject *parent = 0);
15 | ImageGrabber(std::vector boorus, std::vector cookies, string tags, int rating = 0, int limit = 0, QObject *parent = 0);
16 | int logSearch(int index);
17 | void setCookie(int index, CookieJar* cookie);
18 |
19 | signals:
20 | void status(QString);
21 | void progress(int,int);
22 |
23 | void search_completed();
24 | void finished();
25 |
26 | public slots:
27 | void grabSearchFiles();
28 | void search();
29 | void dump();
30 |
31 | private:
32 | std::vector images;
33 | std::vector searchEngines;
34 | std::vector boorus;
35 |
36 | std::vector dumped_pics;
37 |
38 | int rating;
39 | int limit;
40 | std::string tags;
41 | };
42 |
43 | #endif // IMAGEGRABBER_H
44 |
--------------------------------------------------------------------------------
/src/viewer/Workers/qnamredirect.cpp:
--------------------------------------------------------------------------------
1 | #include "qnamredirect.h"
2 |
3 | QNAMRedirect::QNAMRedirect()
4 | {
5 | connect(&nam, SIGNAL (finished(QNetworkReply*)),this, SLOT (replyFinished(QNetworkReply*)));
6 | }
7 |
8 | void QNAMRedirect::processUrl(QString url)
9 | {
10 | QUrl file_url(url);
11 |
12 | //qDebug() << QString("QNAMRedirect::replyFinished: Starting from ").append(file_url.toString());
13 |
14 | QNetworkRequest request(file_url);
15 | nam.get(request);
16 | }
17 |
18 |
19 | void QNAMRedirect::replyFinished(QNetworkReply* reply) {
20 | /*
21 | * Reply is finished!
22 | * We'll ask for the reply about the Redirection attribute
23 | * http://doc.trolltech.com/qnetworkrequest.html#Attribute-enum
24 | */
25 | QVariant possibleRedirectUrl =
26 | reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
27 |
28 | /* We'll deduct if the redirection is valid in the redirectUrl function */
29 | QUrl _urlRedirectedTo = this->redirectUrl(possibleRedirectUrl.toUrl(),_urlRedirectedTo);
30 |
31 | /* If the URL is not empty, we're being redirected. */
32 | if(!_urlRedirectedTo.isEmpty()) {
33 | //qDebug() << QString("QNAMRedirect::replyFinished: Redirected to ").append(_urlRedirectedTo.toString());
34 |
35 | /* We'll do another request to the redirection url. */
36 | this->nam.get(QNetworkRequest(_urlRedirectedTo));
37 | }
38 | else {
39 | /*
40 | * We weren't redirected anymore
41 | * so we arrived to the final destination...
42 | */
43 | //qDebug() << QString("QNAMRedirect::replyFinished: Arrived to ").append(reply->url().toString());
44 | last_url = reply->url();
45 | /* ...so this can be cleared. */
46 | _urlRedirectedTo.clear();
47 |
48 | emit finished();
49 | }
50 | /* Clean up. */
51 | reply->deleteLater();
52 | }
53 |
54 |
55 | QUrl QNAMRedirect::redirectUrl(const QUrl& possibleRedirectUrl,
56 | const QUrl& oldRedirectUrl) const {
57 | QUrl redirectUrl;
58 | /*
59 | * Check if the URL is empty and
60 | * that we aren't being fooled into a infinite redirect loop.
61 | * We could also keep track of how many redirects we have been to
62 | * and set a limit to it, but we'll leave that to you.
63 | */
64 | if(!possibleRedirectUrl.isEmpty() &&
65 | possibleRedirectUrl != oldRedirectUrl) {
66 | redirectUrl = possibleRedirectUrl;
67 | }
68 | return redirectUrl;
69 | }
70 |
71 | QUrl QNAMRedirect::getLastRedirect()
72 | {
73 | return this->last_url;
74 | }
75 |
76 |
77 |
--------------------------------------------------------------------------------
/src/viewer/Workers/qnamredirect.h:
--------------------------------------------------------------------------------
1 | #ifndef QNAMREDIRECT_H
2 | #define QNAMREDIRECT_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | class QNAMRedirect : public QObject
12 | {
13 | Q_OBJECT
14 | public:
15 | QNAMRedirect();
16 | void processUrl(QString url);
17 |
18 | QUrl redirectUrl(const QUrl& possibleRedirectUrl,const QUrl& oldRedirectUrl) const;
19 | QUrl getLastRedirect();
20 |
21 | signals:
22 | void finished();
23 |
24 | public slots:
25 | void replyFinished(QNetworkReply* reply);
26 |
27 | private:
28 | QNetworkAccessManager nam;
29 | QUrl last_url;
30 | };
31 |
32 | #endif // QNAMREDIRECT_H
33 |
--------------------------------------------------------------------------------
/src/viewer/Workers/searchloggingworker.cpp:
--------------------------------------------------------------------------------
1 | #include "searchloggingworker.h"
2 |
3 | // --- CONSTRUCTOR ---
4 | SearchLoggingWorker::SearchLoggingWorker(string tags, int rating, int page, BooruSite* booru)
5 | {
6 | this->tags = tags;
7 | this->rating = rating;
8 | this->booru = booru;
9 | this->page = page;
10 | }
11 |
12 | SearchLoggingWorker::SearchLoggingWorker()
13 | {
14 |
15 | }
16 |
17 | // --- DECONSTRUCTOR ---
18 | SearchLoggingWorker::~SearchLoggingWorker()
19 | {
20 | // free resources
21 | }
22 |
23 | // --- PROCESS ---
24 | void SearchLoggingWorker::process()
25 | {
26 | //Sends the tags to be logged on a remote DB
27 | //Only function to need Qt specific classes
28 |
29 | QString user_agent = "QBooru";
30 |
31 | QNetworkAccessManager *manager = new QNetworkAccessManager;
32 | QNetworkRequest request;
33 |
34 | QUrl url(URL_RECORDS); //Main URL
35 | QUrlQuery params;
36 |
37 | request.setUrl(url.toString());
38 | request.setRawHeader("User-Agent", user_agent.toLatin1());
39 | request.setRawHeader("Content-Type","application/x-www-form-urlencoded");
40 |
41 | params.addQueryItem("tag_req", "1");
42 | params.addQueryItem("page", QString::number(page));
43 |
44 | params.addQueryItem("tags", QString(tags.c_str()));
45 | params.addQueryItem("rating", QString::number(rating));
46 | params.addQueryItem("booru_name", QString(booru->getName().c_str()));
47 | params.addQueryItem("booru_url", QString(booru->getBaseUrl().c_str()));
48 |
49 | QByteArray data;
50 | data.append(params.toString()); //POST params
51 |
52 | QNetworkReply* m_pReply = manager->post(request,data);
53 | QTimer timer(0);
54 | timer.setInterval(1000); //1s timeout
55 |
56 | QObject::connect(&timer, SIGNAL(timeout()),m_pReply, SLOT(abort()));
57 | QEventLoop loop;
58 | QObject::connect(m_pReply, SIGNAL(finished()),&loop, SLOT(quit()));
59 | loop.exec();
60 |
61 | //qDebug() << m_pReply->readAll();
62 |
63 | if(m_pReply->error() != QNetworkReply::NoError)
64 | {
65 | outputInfo(L_ERROR,std::string("Error when sending tags : ") + m_pReply->errorString().toStdString());
66 | outputInfo(L_ERROR,std::string("Full reply : ") + m_pReply->readAll().toStdString());
67 | }
68 |
69 | emit finished();
70 | }
71 |
72 |
--------------------------------------------------------------------------------
/src/viewer/Workers/searchloggingworker.h:
--------------------------------------------------------------------------------
1 | #ifndef SEARCHLOGGINGWORKER_H
2 | #define SEARCHLOGGINGWORKER_H
3 |
4 | #include
5 | #include
6 | #include "../fonctions_all.h"
7 | #include "../Workers/cookiejar.h"
8 |
9 | class SearchLoggingWorker : public QObject
10 | {
11 | Q_OBJECT
12 | public:
13 | SearchLoggingWorker(string tags, int rating, int page, BooruSite* booru);
14 | SearchLoggingWorker();
15 | ~SearchLoggingWorker();
16 |
17 | public slots:
18 | void process();
19 |
20 | signals:
21 | void finished();
22 | void error(QString err);
23 |
24 | private:
25 | string tags;
26 | int rating;
27 | int page;
28 | BooruSite* booru;
29 | };
30 |
31 | #endif // SEARCHLOGGINGWORKER_H
32 |
--------------------------------------------------------------------------------
/src/viewer/Workers/viewer_loading_thread.cpp:
--------------------------------------------------------------------------------
1 | #include "viewer_loading_thread.h"
2 |
3 | // --- CONSTRUCTOR ---
4 | ViewerTabLoadingWorker::ViewerTabLoadingWorker(ViewerTab *parent)
5 | {
6 | parent_tab = parent;
7 | }
8 |
9 | // --- DECONSTRUCTOR ---
10 | ViewerTabLoadingWorker::~ViewerTabLoadingWorker()
11 | {
12 | // free resources
13 | }
14 |
15 | // --- PROCESS ---
16 | void ViewerTabLoadingWorker::process()
17 | {
18 | parent_tab->setLoadingState(true);
19 |
20 | parent_tab->Image.download_medium();
21 | parent_tab->imageViewer = QString(parent_tab->Image.getMediumPath().c_str());
22 | parent_tab->labelImage->setPixmap(QPixmap(parent_tab->imageViewer).scaled(parent_tab->thumbZoneSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
23 |
24 | parent_tab->setLoadingState(false);
25 | emit finished();
26 | }
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/viewer/Workers/viewer_loading_thread.h:
--------------------------------------------------------------------------------
1 | #ifndef VIEWER_LOADING_THREAD_H
2 | #define VIEWER_LOADING_THREAD_H
3 |
4 | #include "../Widget/viewerTabClass.h"
5 | #include
6 | #include
7 |
8 | class ViewerTab;
9 |
10 | class ViewerTabLoadingWorker : public QObject
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | ViewerTabLoadingWorker(ViewerTab *parent);
16 | ~ViewerTabLoadingWorker();
17 |
18 | public slots:
19 | void process();
20 |
21 | signals:
22 | void finished();
23 | void error(QString err);
24 |
25 | private:
26 | ViewerTab *parent_tab;
27 | };
28 |
29 | #endif // VIEWER_LOADING_THREAD_H
30 |
--------------------------------------------------------------------------------
/src/viewer/classBooruSite.h:
--------------------------------------------------------------------------------
1 | #ifndef CLASSBOORUSITE_H_INCLUDED
2 | #define CLASSBOORUSITE_H_INCLUDED
3 |
4 | #include
5 | #include "constantes.h"
6 | #include "json/json.h"
7 |
8 | #include "./BooruHeaders/boorutaglist.h"
9 |
10 | using namespace std;
11 |
12 | class BooruTagList;
13 |
14 | class BooruSite
15 | {
16 | public:
17 | BooruSite(string booruName, string booruUrl, int booruType, int booruIndex);
18 | BooruSite(string booruName, string booruUrl, string downloadPath, int booruType, int booruIndex);
19 | BooruSite(string booruName, string booruUrl, string searchUrl, string tagUrl, string postIndexUrl, string downloadPath, int booruType, int booruIndex);
20 | BooruSite(int index);
21 | BooruSite(Json::Value booru_root);
22 | BooruSite();
23 | ~BooruSite();
24 |
25 | Json::Value saveBooruSite(Json::Value root);
26 |
27 | void loadFromJSON(int index);
28 | void loadFromJSON(Json::Value booru_root);
29 |
30 | void loadTagList();
31 |
32 | /*Getters*/
33 | bool isTagListToLoad();
34 | bool isTagListLoaded();
35 | BooruTagList *getTagList();
36 | string getName();
37 | string getTypeString();
38 | string getBaseUrl();
39 | string getSearchUrl();
40 | string getTagUrl();
41 | string getShowIndexUrl();
42 | string getCachePath();
43 | string getDownloadPath();
44 | string getSearchFilePath();
45 | string getTagFilePath();
46 | int getSiteTypeInt();
47 | int getIndex();
48 |
49 | /*Setters*/
50 | void setName(string in_name);
51 | void setBaseUrl(string in_base_url);
52 | void setSearchUrl(string in_search_url);
53 | void setTagUrl(string in_tag_url);
54 | void setShowIndexUrl(string in_show_index_url);
55 | void setCachePath(string in_cache_path);
56 | void setDownloadPath(string in_download_path);
57 | void setSearchFilePath(string in_search_file_path);
58 | void setTagFilePath(string in_tag_file_path);
59 | void setSiteType(int type);
60 | void setIndex(int i);
61 |
62 | private:
63 | BooruTagList *tag_list;
64 |
65 | string name;
66 | string site_type_string;
67 |
68 | string base_url;
69 | string search_url;
70 | string tag_url;
71 | string show_index_url;
72 |
73 | string cache_path;
74 | string download_path;
75 | string search_file_path;
76 | string tag_file_path;
77 |
78 | int siteTypeInt;
79 | int index;
80 |
81 | bool tag_list_loaded;
82 | bool tag_list_to_load;
83 | };
84 |
85 | #endif
86 |
--------------------------------------------------------------------------------
/src/viewer/config_file.h:
--------------------------------------------------------------------------------
1 | #ifndef CONFIGFILE_H
2 | #define CONFIGFILE_H
3 |
4 | #define LAST_CONF_FILE_VERSION 1
5 |
6 | #include "fonctions_all.h"
7 | #include "classBooruSite.h"
8 | #include