2020-06-08 19:18:50 +02:00
|
|
|
#ifndef KRISTALL_HPP
|
|
|
|
#define KRISTALL_HPP
|
|
|
|
|
2020-06-28 13:11:00 +02:00
|
|
|
#include <QDir>
|
2020-06-08 19:18:50 +02:00
|
|
|
#include <QSettings>
|
2020-06-10 00:31:56 +02:00
|
|
|
#include <QClipboard>
|
2020-06-21 21:29:30 +02:00
|
|
|
#include <QSslCertificate>
|
2020-06-08 19:18:50 +02:00
|
|
|
|
2020-06-11 02:17:32 +02:00
|
|
|
#include "identitycollection.hpp"
|
2020-06-16 00:41:57 +02:00
|
|
|
#include "ssltrust.hpp"
|
2020-06-16 22:01:59 +02:00
|
|
|
#include "favouritecollection.hpp"
|
2020-06-28 16:30:52 +02:00
|
|
|
#include "protocolsetup.hpp"
|
|
|
|
#include "documentstyle.hpp"
|
2021-01-06 09:37:26 +01:00
|
|
|
#include "cachehandler.hpp"
|
2021-03-17 11:54:43 +01:00
|
|
|
#include "localization.hpp"
|
2020-06-11 02:17:32 +02:00
|
|
|
|
2020-06-18 20:10:20 +02:00
|
|
|
enum class Theme : int
|
|
|
|
{
|
2020-06-21 23:13:34 +02:00
|
|
|
os_default = -1,
|
2020-06-18 20:10:20 +02:00
|
|
|
light = 0,
|
|
|
|
dark = 1,
|
|
|
|
};
|
|
|
|
|
2021-01-01 09:26:15 +01:00
|
|
|
enum class UIDensity : int
|
|
|
|
{
|
|
|
|
compact = 0,
|
|
|
|
classic = 1
|
|
|
|
};
|
|
|
|
|
2021-01-09 05:55:52 +01:00
|
|
|
enum class RequestState : int
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
Started = 1,
|
|
|
|
HostFound = 2,
|
|
|
|
Connected = 3,
|
|
|
|
|
|
|
|
StartedWeb = 255,
|
|
|
|
};
|
|
|
|
|
2021-02-16 10:40:36 +01:00
|
|
|
enum class IconTheme : int
|
|
|
|
{
|
|
|
|
automatic = -1,
|
|
|
|
dark = 0,
|
|
|
|
light = 1
|
|
|
|
};
|
|
|
|
|
2021-03-07 08:32:35 +01:00
|
|
|
enum class AnsiEscRenderMode : int
|
|
|
|
{
|
|
|
|
ignore = 0,
|
|
|
|
render = 1,
|
|
|
|
strip = 2
|
|
|
|
};
|
|
|
|
|
2021-03-17 06:06:31 +01:00
|
|
|
struct NamedUrl
|
2021-03-17 05:43:36 +01:00
|
|
|
{
|
|
|
|
QUrl location;
|
|
|
|
QString title;
|
|
|
|
};
|
|
|
|
|
2020-06-18 20:10:20 +02:00
|
|
|
struct GenericSettings
|
|
|
|
{
|
|
|
|
enum TextDisplay {
|
|
|
|
FormattedText,
|
|
|
|
PlainText,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum RedirectionWarning {
|
|
|
|
WarnNever = 0,
|
|
|
|
WarnOnSchemeChange = 1,
|
|
|
|
WarnOnHostChange = 2,
|
|
|
|
WarnAlways = -1,
|
|
|
|
};
|
|
|
|
|
2021-03-15 12:57:36 +01:00
|
|
|
enum SessionRestoreBehaviour {
|
|
|
|
NoSessionRestore = 0,
|
|
|
|
RestoreLastSession = 1,
|
|
|
|
};
|
|
|
|
|
2020-06-18 20:10:20 +02:00
|
|
|
QString start_page = "about:favourites";
|
2021-02-15 06:38:45 +01:00
|
|
|
QString search_engine = "gemini://geminispace.info/search?%1";
|
2020-06-18 20:10:20 +02:00
|
|
|
Theme theme = Theme::light;
|
2021-02-16 10:40:36 +01:00
|
|
|
IconTheme icon_theme = IconTheme::automatic;
|
2021-02-20 21:48:45 +01:00
|
|
|
IconTheme explicit_icon_theme = IconTheme::dark;
|
2021-01-01 09:26:15 +01:00
|
|
|
UIDensity ui_density = UIDensity::compact;
|
2020-06-18 20:10:20 +02:00
|
|
|
TextDisplay text_display = FormattedText;
|
|
|
|
bool enable_text_decoration = false;
|
|
|
|
bool use_os_scheme_handler = false;
|
2020-12-30 06:38:06 +01:00
|
|
|
bool show_hidden_files_in_dirs = false;
|
2020-12-31 07:14:33 +01:00
|
|
|
bool fancy_urlbar = true;
|
2021-02-13 08:57:24 +01:00
|
|
|
bool fancy_quotes = true;
|
2021-02-26 23:23:59 +01:00
|
|
|
bool emojis_enabled = true;
|
2021-03-08 02:02:05 +01:00
|
|
|
bool strip_nav = false;
|
2021-11-20 15:16:34 +01:00
|
|
|
bool close_window_with_last_tab = false;
|
2021-03-07 08:32:35 +01:00
|
|
|
AnsiEscRenderMode ansi_escapes = AnsiEscRenderMode::render;
|
2021-01-02 02:20:34 +01:00
|
|
|
|
|
|
|
// This is set automatically
|
|
|
|
QColor fancy_urlbar_dim_colour;
|
|
|
|
|
2020-06-18 20:10:20 +02:00
|
|
|
TextDisplay gophermap_display = FormattedText;
|
|
|
|
int max_redirections = 5;
|
|
|
|
RedirectionWarning redirection_policy = WarnOnHostChange;
|
|
|
|
|
2020-06-19 19:23:50 +02:00
|
|
|
// 5 seconds network timeout
|
|
|
|
int network_timeout = 5000;
|
|
|
|
|
2020-12-29 08:42:59 +01:00
|
|
|
// Additional toolbar items
|
2021-02-18 10:24:11 +01:00
|
|
|
bool enable_home_btn = false,
|
|
|
|
enable_newtab_btn = true,
|
|
|
|
enable_root_btn = false,
|
|
|
|
enable_parent_btn = false;
|
2020-12-29 08:42:59 +01:00
|
|
|
|
2021-01-08 05:34:54 +01:00
|
|
|
// In-memory caching
|
2021-01-08 10:46:56 +01:00
|
|
|
int cache_limit = 1000;
|
|
|
|
int cache_threshold = 125;
|
2021-02-18 07:44:17 +01:00
|
|
|
int cache_life = 60;
|
|
|
|
bool cache_unlimited_life = true;
|
2021-01-08 05:34:54 +01:00
|
|
|
|
2021-03-15 12:57:36 +01:00
|
|
|
SessionRestoreBehaviour session_restore_behaviour = RestoreLastSession;
|
|
|
|
|
2020-06-18 20:10:20 +02:00
|
|
|
void load(QSettings & settings);
|
|
|
|
void save(QSettings & settings) const;
|
|
|
|
};
|
|
|
|
|
2020-06-21 21:29:30 +02:00
|
|
|
//! Converts the certificate to a standardized fingerprint representation
|
|
|
|
//! also commonly used in browsers:
|
|
|
|
//! `:`-separated SHA256 hash
|
|
|
|
QString toFingerprintString(QSslCertificate const & certificate);
|
|
|
|
|
2021-03-06 14:26:06 +01:00
|
|
|
// Forward declaration
|
|
|
|
class MainWindow;
|
|
|
|
|
2020-06-28 13:11:00 +02:00
|
|
|
///
|
|
|
|
/// Kristall directory structure:
|
|
|
|
/// ~/.cache/kristall/
|
|
|
|
/// ./offline-pages/${HOST}/${HASHED_URL}
|
|
|
|
/// : Contains "mime/type\r\n${BLOB}"
|
|
|
|
/// ~/.config/kristall/
|
|
|
|
/// ./themes/${THEME_ID}/theme.qss
|
|
|
|
/// ./styles/${STYLE_ID}.ini
|
|
|
|
/// ./config.ini
|
|
|
|
///
|
|
|
|
namespace kristall
|
|
|
|
{
|
2021-03-06 20:26:21 +01:00
|
|
|
//! Whether emojis are supprted in current build configuration
|
|
|
|
extern const bool EMOJIS_SUPPORTED;
|
2020-06-28 16:30:52 +02:00
|
|
|
|
2021-03-06 20:26:21 +01:00
|
|
|
struct Trust
|
|
|
|
{
|
|
|
|
SslTrust gemini;
|
|
|
|
SslTrust https;
|
|
|
|
};
|
2021-01-06 09:37:26 +01:00
|
|
|
|
2021-03-06 20:26:21 +01:00
|
|
|
struct Dirs
|
|
|
|
{
|
2020-06-28 16:30:52 +02:00
|
|
|
|
2021-03-06 20:26:21 +01:00
|
|
|
QDir config_root;
|
|
|
|
QDir cache_root;
|
2020-06-28 16:30:52 +02:00
|
|
|
|
|
|
|
//! Contains files per host
|
2021-03-06 20:26:21 +01:00
|
|
|
QDir offline_pages;
|
2020-06-28 16:30:52 +02:00
|
|
|
|
|
|
|
//! Contains custom UI themes for kristall
|
2021-03-06 20:26:21 +01:00
|
|
|
QDir themes;
|
2020-06-28 16:30:52 +02:00
|
|
|
|
|
|
|
//! Contains custom document styles / presets
|
2021-03-06 20:26:21 +01:00
|
|
|
QDir styles;
|
|
|
|
};
|
|
|
|
|
2021-03-17 10:42:50 +01:00
|
|
|
struct Globals
|
|
|
|
{
|
2021-03-06 20:26:21 +01:00
|
|
|
ProtocolSetup protocols;
|
|
|
|
|
|
|
|
QSettings * settings;
|
|
|
|
IdentityCollection identities;
|
|
|
|
QClipboard * clipboard;
|
|
|
|
FavouriteCollection favourites;
|
|
|
|
GenericSettings options;
|
|
|
|
|
|
|
|
DocumentStyle document_style;
|
|
|
|
|
|
|
|
CacheHandler cache;
|
|
|
|
|
|
|
|
Trust trust;
|
|
|
|
|
|
|
|
Dirs dirs;
|
2021-03-17 10:42:50 +01:00
|
|
|
|
2021-03-17 11:54:43 +01:00
|
|
|
std::unique_ptr<Localization> localization;
|
2021-03-06 20:26:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
//! returns the instance of the globals structure
|
|
|
|
Globals & globals();
|
2020-06-28 16:30:52 +02:00
|
|
|
|
2021-03-06 15:26:07 +01:00
|
|
|
//! Forwards the current settings to all windows
|
|
|
|
void applySettings();
|
|
|
|
|
|
|
|
//! Saves the current settings to disk
|
2020-06-28 16:30:52 +02:00
|
|
|
void saveSettings();
|
2020-06-29 00:08:56 +02:00
|
|
|
|
|
|
|
void setTheme(Theme theme);
|
2021-01-01 09:26:15 +01:00
|
|
|
|
2021-02-16 10:40:36 +01:00
|
|
|
void setIconTheme(IconTheme icotheme, Theme uitheme);
|
|
|
|
|
2021-01-01 09:26:15 +01:00
|
|
|
void setUiDensity(UIDensity density, bool previewing);
|
2021-01-04 00:43:42 +01:00
|
|
|
|
2021-02-20 23:59:01 +01:00
|
|
|
void saveWindowState();
|
|
|
|
|
2021-03-06 14:26:06 +01:00
|
|
|
//! Registers a main window as a proper kristall application window
|
|
|
|
//! that can be tracked by the application.
|
|
|
|
void registerAppWindow(MainWindow * window);
|
|
|
|
|
2021-03-06 15:26:07 +01:00
|
|
|
//! Opens a new window with the default page open.
|
|
|
|
//! @param load_default Loads the default/start page instead of about:blank
|
|
|
|
MainWindow * openNewWindow(bool load_default);
|
|
|
|
|
|
|
|
//! Opens a new window with the given url.
|
|
|
|
MainWindow * openNewWindow(QUrl const & url);
|
|
|
|
|
|
|
|
//! Opens a new window with the given list of urls.
|
|
|
|
//! If the list is empty, no new tab will spawned.
|
|
|
|
MainWindow * openNewWindow(QVector<QUrl> const & urls);
|
2021-03-17 06:06:31 +01:00
|
|
|
MainWindow * openNewWindow(QVector<NamedUrl> const & urls);
|
2021-03-15 11:54:48 +01:00
|
|
|
|
|
|
|
//! Returns the number of currently open windows
|
|
|
|
int getWindowCount();
|
|
|
|
|
|
|
|
//! Saves the current session including all windows, tabs and positions.
|
|
|
|
void saveSession();
|
2021-03-17 10:42:50 +01:00
|
|
|
|
|
|
|
//! Saves the currently used locale
|
|
|
|
void saveLocale();
|
2020-06-28 13:11:00 +02:00
|
|
|
}
|
|
|
|
|
2020-06-08 19:18:50 +02:00
|
|
|
#endif // KRISTALL_HPP
|