-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgui.h
More file actions
212 lines (180 loc) · 6.78 KB
/
gui.h
File metadata and controls
212 lines (180 loc) · 6.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
** MIT License
**
** Copyright(c) 2021 Alec Musasa
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this softwareand associated documentation files(the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions :
**
** The above copyright noticeand this permission notice shall be included in all
** copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
** SOFTWARE.
*/
#pragma once
#include "version_info.h"
#include "resource.h"
#include "collab/collab.h"
#include "helper_functions.h"
// lecui
#include <liblec/lecui/instance.h>
#include <liblec/lecui/controls.h>
#include <liblec/lecui/appearance.h>
#include <liblec/lecui/utilities/timer.h>
#include <liblec/lecui/utilities/splash.h>
#include <liblec/lecui/utilities/tray_icon.h>
#include <liblec/lecui/widgets/widget.h>
#include <liblec/lecui/containers/page.h>
#include <liblec/lecui/containers/pane.h>
// leccore
#include <liblec/leccore/settings.h>
#include <liblec/leccore/web_update.h>
#include <liblec/leccore/file.h>
// lecnet
#include <liblec/lecnet.h>
// STL
#include <functional>
using namespace liblec;
using snap_type = lecui::rect::snap_type;
#ifdef _WIN64
#define architecture "64bit"
#else
#define architecture "32bit"
#endif
// the main form
class main_form : public lecui::form {
const std::string _instance_guid = "{5AFD8741-0231-431C-B765-8DA09A22346B}";
const std::string _install_guid_32 = "{45F2F3E8-AE98-4459-8F4F-836B4A79AD22}";
const std::string _install_guid_64 = "{1F4BBE94-5058-4D4E-A6E8-4F1F7A562BD1}";
const std::string _update_xml_url = "https://raw.githubusercontent.com/alecmus/collab/master/latest_update.xml";
static const float _margin;
static const lecui::size _design_size, _design_size_minimum;
static const float _icon_size;
static const float _info_size;
// font sizes, in points
static const float _title_font_size;
static const float _highlight_font_size;
static const float _detail_font_size;
static const float _ui_font_size;
static const float _caption_font_size;
static const float _review_font_size;
// computed ideal label heights, in pixels
float _title_height = 0.f;
float _highlight_height = 0.f;
float _detail_height = 0.f;
float _ui_font_height = 0.f;
float _caption_height = 0.f;
static const std::string _sample_text;
static const std::string _font;
static const lecui::color _online;
static const lecui::color _busy;
lecui::color _caption_color;
lecui::controls _ctrls{ *this };
lecui::page_manager _page_man{ *this };
lecui::appearance _apprnc{ *this };
lecui::dimensions _dim{ *this };
lecui::instance_manager _instance_man{ *this, _instance_guid };
lecui::widget_manager _widget_man{ *this };
lecui::timer_manager _timer_man{ *this };
lecui::splash _splash{ *this };
bool _restart_now = false;
// 1. If application is installed and running from an install directory this will be true.
// 2. If application is installed and not running from an install directory this will also
// be true unless there is a .portable file in the same directory.
// 3. If application is not installed then portable mode will be used whether or not a .portable
// file exists in the same directory.
bool _installed;
bool _real_portable_mode;
bool _system_tray_mode;
std::string _install_location_32, _install_location_64;
leccore::settings& _settings;
leccore::registry_settings _reg_settings{ leccore::registry::scope::current_user };
leccore::ini_settings _ini_settings{ "collab.ini" };
bool _setting_darktheme = false;
bool _setting_autocheck_updates = true;
leccore::check_update _check_update{ _update_xml_url };
leccore::check_update::update_info _update_info;
bool _setting_autodownload_updates = false;
bool _update_check_initiated_manually = false;
leccore::download_update _download_update;
std::string _update_directory;
bool _setting_autostart = false;
std::string _folder, _node_folder, _cert_folder, _files_folder, _files_staging_folder;
std::vector<collab::session> _previous_sessions;
std::vector<collab::message> _previous_messages;
std::vector<collab::file> _previous_files;
std::vector<collab::review> _previous_reviews;
const bool _cleanup_mode;
const bool _update_mode;
const bool _recent_update_mode;
lecui::tray_icon _tray_icon{ *this };
bool _update_details_displayed = false;
leccore::file::exclusive_lock* _lock_file = nullptr;
std::string _database_file;
std::string _avatar_file;
collab _collab; // collaboration object
std::string _current_session_unique_id;
std::string _message_sent_just_now;
std::string _current_session_file_hash;
// concurrency control related to the log
liblec::mutex _log_mutex;
struct event_info {
std::string time;
std::string event;
};
std::vector<event_info> _log_queue;
std::map<std::string, collab::file> _session_files;
bool on_initialize(std::string& error);
bool on_layout(std::string& error);
void on_start();
void on_close();
void on_shutdown();
void add_side_pane();
void add_top_status_pane();
void add_back_button();
void add_home_page();
void add_help_page();
void add_settings_page();
void add_log_page();
void updates();
void on_update_check();
void on_update_download();
bool installed();
void create_update_status();
void close_update_status();
void on_close_update_status();
void on_darktheme(bool on);
void on_autostart(bool on);
void on_autocheck_updates(bool on);
void on_autodownload_updates(bool on);
void on_select_location();
void new_session();
void user();
bool join_session(const collab::session& session);
lecui::containers::pane& add_chat_pane(lecui::containers::pane& collaboration_pane, const lecui::rect& ref_rect);
lecui::containers::pane& add_files_pane(lecui::containers::pane& collaboration_pane, const lecui::rect& ref_rect);
void set_avatar(const std::string& image_data);
void update_session_list();
void update_session_chat_messages();
void update_session_chat_files();
void update_file_reviews();
int map_extension_to_resource(const std::string& extension);
void log(const std::string& event);
void update_log();
public:
main_form(const std::string& caption, bool restarted);
~main_form();
bool restart_now() {
return _restart_now;
}
};