2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-01-15 16:38:30 +01:00
|
|
|
|
2018-08-11 22:23:06 +02:00
|
|
|
#include "common/Channel.hpp"
|
|
|
|
#include "common/FlagsEnum.hpp"
|
2018-07-15 14:03:41 +02:00
|
|
|
#include "common/Singleton.hpp"
|
2020-09-19 17:14:10 +02:00
|
|
|
#include "common/WindowDescriptors.hpp"
|
2018-11-21 21:37:41 +01:00
|
|
|
#include "pajlada/settings/settinglistener.hpp"
|
2018-06-26 17:20:03 +02:00
|
|
|
#include "widgets/splits/SplitContainer.hpp"
|
2017-01-15 16:38:30 +01:00
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace chatterino {
|
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
class Settings;
|
|
|
|
class Paths;
|
2018-08-11 22:23:06 +02:00
|
|
|
class Window;
|
|
|
|
class SplitContainer;
|
|
|
|
|
|
|
|
enum class MessageElementFlag;
|
|
|
|
using MessageElementFlags = FlagsEnum<MessageElementFlag>;
|
|
|
|
enum class WindowType;
|
2018-08-02 14:23:27 +02:00
|
|
|
|
2018-10-21 15:32:28 +02:00
|
|
|
enum class SettingsDialogPreference;
|
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
class WindowManager final : public Singleton
|
2017-01-15 16:38:30 +01:00
|
|
|
{
|
2018-04-28 15:20:18 +02:00
|
|
|
public:
|
2018-04-27 22:11:19 +02:00
|
|
|
WindowManager();
|
2017-01-15 16:38:30 +01:00
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
static void encodeChannel(IndirectChannel channel, QJsonObject &obj);
|
2020-09-19 17:14:10 +02:00
|
|
|
static IndirectChannel decodeChannel(const SplitDescriptor &descriptor);
|
2018-07-06 19:23:47 +02:00
|
|
|
|
2018-10-21 15:32:28 +02:00
|
|
|
void showSettingsDialog(
|
|
|
|
SettingsDialogPreference preference = SettingsDialogPreference());
|
2018-10-07 16:18:30 +02:00
|
|
|
|
|
|
|
// Show the account selector widget at point
|
2018-01-24 15:08:22 +01:00
|
|
|
void showAccountSelectPopup(QPoint point);
|
|
|
|
|
2018-10-07 16:18:30 +02:00
|
|
|
// Tell a channel (or all channels if channel is nullptr) to redo their
|
|
|
|
// layout
|
2018-06-04 16:10:54 +02:00
|
|
|
void layoutChannelViews(Channel *channel = nullptr);
|
2018-10-07 16:18:30 +02:00
|
|
|
|
|
|
|
// Force all channel views to redo their layout
|
|
|
|
// This is called, for example, when the emote scale or timestamp format has
|
|
|
|
// changed
|
2018-06-04 16:10:54 +02:00
|
|
|
void forceLayoutChannelViews();
|
2017-04-13 19:25:33 +02:00
|
|
|
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
|
|
|
void repaintGifEmotes();
|
|
|
|
|
2018-06-26 17:06:17 +02:00
|
|
|
Window &getMainWindow();
|
|
|
|
Window &getSelectedWindow();
|
2019-08-26 11:26:58 +02:00
|
|
|
Window &createWindow(WindowType type, bool show = true);
|
2017-04-13 19:25:33 +02:00
|
|
|
|
2017-12-14 00:25:06 +01:00
|
|
|
int windowCount();
|
2018-06-26 17:06:17 +02:00
|
|
|
Window *windowAt(int index);
|
2017-12-14 00:25:06 +01:00
|
|
|
|
2020-04-13 13:15:51 +02:00
|
|
|
QPoint emotePopupPos();
|
|
|
|
void setEmotePopupPos(QPoint pos);
|
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
virtual void initialize(Settings &settings, Paths &paths) override;
|
2018-07-07 11:41:01 +02:00
|
|
|
virtual void save() override;
|
2018-04-06 23:31:34 +02:00
|
|
|
void closeAll();
|
2017-01-26 21:04:01 +01:00
|
|
|
|
2018-06-04 16:10:54 +02:00
|
|
|
int getGeneration() const;
|
|
|
|
void incGeneration();
|
|
|
|
|
2018-08-07 07:55:31 +02:00
|
|
|
MessageElementFlags getWordFlags();
|
2018-06-28 19:38:57 +02:00
|
|
|
void updateWordTypeMask();
|
|
|
|
|
2018-10-07 16:18:30 +02:00
|
|
|
// Sends an alert to the main window
|
|
|
|
// It reads the `longAlert` setting to decide whether the alert will expire
|
|
|
|
// or not
|
2018-10-07 12:55:44 +02:00
|
|
|
void sendAlert();
|
|
|
|
|
2018-10-07 18:27:40 +02:00
|
|
|
// Queue up a save in the next 10 seconds
|
|
|
|
// If a save was already queued up, we reset the to happen in 10 seconds
|
|
|
|
// again
|
|
|
|
void queueSave();
|
|
|
|
|
2018-11-14 17:26:08 +01:00
|
|
|
/// Signals
|
|
|
|
pajlada::Signals::NoArgSignal gifRepaintRequested;
|
|
|
|
|
|
|
|
// This signal fires whenever views rendering a channel, or all views if the
|
|
|
|
// channel is a nullptr, need to redo their layout
|
|
|
|
pajlada::Signals::Signal<Channel *> layoutRequested;
|
|
|
|
|
|
|
|
pajlada::Signals::NoArgSignal wordFlagsChanged;
|
|
|
|
|
2020-02-15 17:16:10 +01:00
|
|
|
// This signal fires every 100ms and can be used to trigger random things that require a recheck.
|
|
|
|
// It is currently being used by the "Tooltip Preview Image" system to recheck if an image is ready to be rendered.
|
|
|
|
pajlada::Signals::NoArgSignal miscUpdate;
|
|
|
|
|
2017-01-15 16:38:30 +01:00
|
|
|
private:
|
2018-07-06 19:23:47 +02:00
|
|
|
void encodeNodeRecusively(SplitContainer::Node *node, QJsonObject &obj);
|
2018-06-04 16:10:54 +02:00
|
|
|
|
2020-09-19 17:14:10 +02:00
|
|
|
// Load window layout from the window-layout.json file
|
|
|
|
WindowLayout loadWindowLayoutFromFile() const;
|
|
|
|
|
|
|
|
// Apply a window layout for this window manager.
|
|
|
|
void applyWindowLayout(const WindowLayout &layout);
|
|
|
|
|
|
|
|
// Contains the full path to the window layout file, e.g. /home/pajlada/.local/share/Chatterino/Settings/window-layout.json
|
|
|
|
const QString windowLayoutFilePath;
|
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
bool initialized_ = false;
|
2017-01-15 16:38:30 +01:00
|
|
|
|
2020-04-13 13:15:51 +02:00
|
|
|
QPoint emotePopupPos_;
|
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
std::atomic<int> generation_{0};
|
2018-04-20 22:33:28 +02:00
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
std::vector<Window *> windows_;
|
2018-05-16 14:55:45 +02:00
|
|
|
|
2018-08-11 22:23:06 +02:00
|
|
|
Window *mainWindow_{};
|
|
|
|
Window *selectedWindow_{};
|
2018-06-28 19:38:57 +02:00
|
|
|
|
2018-08-11 22:23:06 +02:00
|
|
|
MessageElementFlags wordFlags_{};
|
2018-11-21 21:37:41 +01:00
|
|
|
pajlada::SettingListener wordFlagsListener_;
|
2018-10-07 18:27:40 +02:00
|
|
|
|
|
|
|
QTimer *saveTimer;
|
2020-02-15 17:16:10 +01:00
|
|
|
QTimer miscUpdateTimer_;
|
2017-01-15 16:38:30 +01:00
|
|
|
};
|
2017-01-28 22:35:23 +01:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace chatterino
|