annotate include/gui/window.h @ 187:9613d72b097e

*: multiple performance improvements like marking `static const` when it makes sense... date: change old stupid heap-based method to a structure which should make copying the thing actually make a copy. also many performance-based changes, like removing the std::tie dependency and forward-declaring nlohmann json *: replace every instance of QString::fromUtf8 to Strings::ToQString. the main difference is that our function will always convert exactly what is in the string, while some other times it would only convert up to the nearest NUL byte
author Paper <mrpapersonic@gmail.com>
date Wed, 06 Dec 2023 13:43:54 -0500
parents c8375765f0fc
children 4d461ef7d424
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
1 #ifndef __window_h
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
2 #define __window_h
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
3 #include "core/config.h"
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
4 #include <QMainWindow>
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
5 #include <memory>
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
6
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
7 /* *could* be forward-declared, but this causes
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
8 any file that #includes this to have to #include
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
9 these as well due to unique_ptr */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
10 #include <QWidget>
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
11 #include <QStackedWidget>
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
12 #include <QCloseEvent>
170
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
13 #include <QThread>
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
14 #include "gui/widgets/sidebar.h"
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
15
170
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
16 Q_DECLARE_METATYPE(std::vector<std::string>);
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
17
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
18 class PlayingThread : public QThread {
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
19 Q_OBJECT
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
20
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
21 public:
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
22 PlayingThread(QObject* object = nullptr) : QThread(object) {}
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
23
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
24 private:
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
25 void run() override;
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
26
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
27 signals:
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
28 void Done(const std::vector<std::string>& files);
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
29 };
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
30
95
8043152ef9d4 include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents: 79
diff changeset
31 class MainWindow final : public QMainWindow {
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
32 Q_OBJECT
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
33
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
34 public:
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
35 MainWindow(QWidget* parent = nullptr);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
36 void SetActivePage(QWidget* page);
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
37 void CreateBars();
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
38 void AddMainWidgets();
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
39 void RetranslateUI();
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
40 void AsyncSynchronize(QStackedWidget* stack);
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
41 void changeEvent(QEvent* event) override;
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
42 void showEvent(QShowEvent* event) override;
4
5af270662505 Set override functions as override
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
43 void closeEvent(QCloseEvent* event) override;
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
44
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
45 private:
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
46 std::unique_ptr<QWidget> main_widget = nullptr;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
47 std::unique_ptr<QStackedWidget> stack = nullptr;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
48 std::unique_ptr<SideBar> sidebar = nullptr;
170
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
49
c8375765f0fc window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
50 std::unique_ptr<PlayingThread> thread = nullptr;
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
51 };
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
52
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
53 #endif // __window_h