2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
#include "widgets/basewidget.hpp"
|
2017-06-11 09:31:45 +02:00
|
|
|
#include "widgets/notebook.hpp"
|
|
|
|
#include "widgets/titlebar.hpp"
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2017-04-18 02:07:14 +02:00
|
|
|
#ifdef USEWINSDK
|
2017-04-12 17:46:44 +02:00
|
|
|
#include <platform/borderless/qwinwidget.h>
|
2017-04-18 02:07:14 +02:00
|
|
|
#endif
|
|
|
|
|
2017-01-18 04:52:47 +01:00
|
|
|
#include <QMainWindow>
|
2017-01-28 22:35:23 +01:00
|
|
|
#include <boost/property_tree/ptree.hpp>
|
2017-06-26 16:41:20 +02:00
|
|
|
#include <pajlada/settings/serialize.hpp>
|
|
|
|
#include <pajlada/settings/settingdata.hpp>
|
2017-01-18 04:52:47 +01:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
class ChannelManager;
|
2017-06-26 16:41:20 +02:00
|
|
|
class ColorScheme;
|
2017-07-23 14:16:13 +02:00
|
|
|
class CompletionManager;
|
2017-06-13 21:13:58 +02:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace widgets {
|
2017-01-18 21:30:23 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
class MainWindow : public BaseWidget
|
2016-12-29 17:31:07 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-07-23 14:16:13 +02:00
|
|
|
explicit MainWindow(ChannelManager &_channelManager, ColorScheme &_colorScheme,
|
|
|
|
CompletionManager &_completionManager);
|
2016-12-29 17:31:07 +01:00
|
|
|
~MainWindow();
|
2017-01-16 03:15:07 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void layoutVisibleChatWidgets(Channel *channel = nullptr);
|
|
|
|
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
2017-01-28 22:35:23 +01:00
|
|
|
|
|
|
|
void load(const boost::property_tree::ptree &tree);
|
|
|
|
boost::property_tree::ptree save();
|
|
|
|
void loadDefaults();
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
bool isLoaded() const;
|
|
|
|
|
|
|
|
Notebook &getNotebook();
|
2017-01-28 22:35:23 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
protected:
|
|
|
|
virtual void closeEvent(QCloseEvent *event) override;
|
|
|
|
|
2017-01-28 22:35:23 +01:00
|
|
|
private:
|
2017-07-02 14:28:37 +02:00
|
|
|
virtual void refreshTheme() override;
|
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
ChannelManager &channelManager;
|
2017-06-26 16:41:20 +02:00
|
|
|
ColorScheme &colorScheme;
|
2017-07-23 14:16:13 +02:00
|
|
|
CompletionManager &completionManager;
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
Notebook notebook;
|
2017-06-26 16:41:20 +02:00
|
|
|
bool loaded = false;
|
|
|
|
TitleBar titleBar;
|
|
|
|
|
2017-07-27 23:32:15 +02:00
|
|
|
/*
|
2017-06-26 16:41:20 +02:00
|
|
|
class QRectWrapper : public pajlada::Settings::ISettingData, public QRect
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QRectWrapper()
|
|
|
|
: QRect(-1, -1, -1, -1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
pajlada::Signals::Signal<const QRectWrapper &> valueChanged;
|
|
|
|
|
|
|
|
const QRectWrapper &getValueRef() const
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual rapidjson::Value marshalInto(rapidjson::Document &d) override
|
|
|
|
{
|
|
|
|
using namespace pajlada::Settings;
|
|
|
|
|
|
|
|
rapidjson::Value obj(rapidjson::kObjectType);
|
|
|
|
|
|
|
|
auto _x = serializeToJSON<int>::serialize(this->x(), d.GetAllocator());
|
|
|
|
auto _y = serializeToJSON<int>::serialize(this->y(), d.GetAllocator());
|
|
|
|
auto _width = serializeToJSON<int>::serialize(this->width(), d.GetAllocator());
|
|
|
|
auto _height = serializeToJSON<int>::serialize(this->height(), d.GetAllocator());
|
|
|
|
|
|
|
|
obj.AddMember("x", _x, d.GetAllocator());
|
|
|
|
obj.AddMember("y", _y, d.GetAllocator());
|
|
|
|
obj.AddMember("width", _width, d.GetAllocator());
|
|
|
|
obj.AddMember("height", _height, d.GetAllocator());
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool unmarshalFrom(rapidjson::Document &document) override
|
|
|
|
{
|
|
|
|
using namespace pajlada::Settings;
|
|
|
|
|
|
|
|
auto vXp = this->getValueWithSuffix("/x", document);
|
|
|
|
auto vYp = this->getValueWithSuffix("/y", document);
|
|
|
|
auto vWidthp = this->getValueWithSuffix("/width", document);
|
|
|
|
auto vHeightp = this->getValueWithSuffix("/height", document);
|
|
|
|
if (vXp != nullptr) {
|
|
|
|
this->setX(deserializeJSON<int>::deserialize(*vXp));
|
|
|
|
this->filled = true;
|
|
|
|
}
|
|
|
|
if (vYp != nullptr) {
|
|
|
|
this->setY(deserializeJSON<int>::deserialize(*vYp));
|
|
|
|
this->filled = true;
|
|
|
|
}
|
|
|
|
if (vWidthp != nullptr) {
|
|
|
|
this->setWidth(deserializeJSON<int>::deserialize(*vWidthp));
|
|
|
|
this->filled = true;
|
|
|
|
}
|
|
|
|
if (vHeightp != nullptr) {
|
|
|
|
this->setHeight(deserializeJSON<int>::deserialize(*vHeightp));
|
|
|
|
this->filled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void registerDocument(rapidjson::Document &d) override
|
|
|
|
{
|
|
|
|
this->valueChanged.connect([this, &d](const auto &) {
|
|
|
|
this->marshalInto(d); //
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
QRectWrapper &operator=(const QRect &rhs)
|
|
|
|
{
|
|
|
|
static_cast<QRect &>(*this) = rhs;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setValue(const QRect &rhs)
|
|
|
|
{
|
|
|
|
static_cast<QRect &>(*this) = rhs;
|
|
|
|
}
|
|
|
|
};
|
2017-07-27 23:32:15 +02:00
|
|
|
*/
|
2017-06-26 16:41:20 +02:00
|
|
|
|
2017-08-12 12:09:26 +02:00
|
|
|
// pajlada::Settings::Setting<QRectWrapper> windowGeometry;
|
2017-07-23 14:16:13 +02:00
|
|
|
|
|
|
|
friend class Notebook;
|
2016-12-29 17:31:07 +01:00
|
|
|
};
|
2017-01-28 22:35:23 +01:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|