mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fixed compiling
This commit is contained in:
parent
7f18cefee4
commit
86ae71f674
|
@ -22,6 +22,8 @@ Application::Application()
|
|||
logging::init();
|
||||
SettingsManager::getInstance().load();
|
||||
|
||||
this->windowManager.initMainWindow();
|
||||
|
||||
// Initialize everything we need
|
||||
this->emoteManager.loadGlobalEmotes();
|
||||
|
||||
|
|
|
@ -4,37 +4,39 @@
|
|||
namespace chatterino {
|
||||
void CommandManager::execCommand(QString command)
|
||||
{
|
||||
if (command == "selectr") {
|
||||
selectSplitRelative(1, 0);
|
||||
}
|
||||
if (command == "selectl") {
|
||||
selectSplitRelative(-1, 0);
|
||||
}
|
||||
if (command == "selectu") {
|
||||
selectSplitRelative(0, -1);
|
||||
}
|
||||
if (command == "selectd") {
|
||||
selectSplitRelative(0, 1);
|
||||
}
|
||||
// if (command == "selectr") {
|
||||
// selectSplitRelative(false, 1);
|
||||
// }
|
||||
// if (command == "selectl") {
|
||||
// selectSplitRelative(false, -1);
|
||||
// }
|
||||
// if (command == "selectu") {
|
||||
// selectSplitRelative(true, -1);
|
||||
// }
|
||||
// if (command == "selectd") {
|
||||
// selectSplitRelative(true, 1);
|
||||
// }
|
||||
|
||||
if (command == "mover") {
|
||||
moveSplitRelative(1, 0);
|
||||
moveSplitRelative(false, 1);
|
||||
}
|
||||
if (command == "movel") {
|
||||
moveSplitRelative(-1, 0);
|
||||
moveSplitRelative(false, -1);
|
||||
}
|
||||
if (command == "moveu") {
|
||||
moveSplitRelative(0, -1);
|
||||
moveSplitRelative(true, -1);
|
||||
}
|
||||
if (command == "moved") {
|
||||
moveSplitRelative(0, 1);
|
||||
moveSplitRelative(true, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void CommandManager::selectSplitRelative(int dx, int dy)
|
||||
{
|
||||
WindowManager::instance->getCurrentWindow().getNotebook().getSelectedPage();
|
||||
}
|
||||
//void CommandManager::selectSplitRelative(bool vertical, int offset)
|
||||
//{
|
||||
// SplitContainer *container = WindowManager::instance->
|
||||
//
|
||||
// if (vertical)
|
||||
//}
|
||||
|
||||
void CommandManager::moveSplitRelative(int dx, int dy)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ public:
|
|||
CommandManager() = delete;
|
||||
|
||||
void execCommand(QString command);
|
||||
void selectSplitRelative(int dx, int dy);
|
||||
// void selectSplitRelative(int dx, int dy);
|
||||
void moveSplitRelative(int dx, int dy);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -107,6 +107,11 @@ void Notebook::select(SplitContainer *page)
|
|||
this->performLayout();
|
||||
}
|
||||
|
||||
int Notebook::tabCount()
|
||||
{
|
||||
return this->pages.size();
|
||||
}
|
||||
|
||||
SplitContainer *Notebook::tabAt(QPoint point, int &index)
|
||||
{
|
||||
int i = 0;
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
|
||||
void performLayout(bool animate = true);
|
||||
|
||||
int tabCount();
|
||||
SplitContainer *tabAt(QPoint point, int &index);
|
||||
void rearrangePage(SplitContainer *page, int index);
|
||||
|
||||
|
|
|
@ -66,10 +66,6 @@ Window::Window(ChannelManager &_channelManager, ColorScheme &_colorScheme,
|
|||
}
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
{
|
||||
}
|
||||
|
||||
void Window::repaintVisibleChatWidgets(Channel *channel)
|
||||
{
|
||||
auto *page = this->notebook.getSelectedPage();
|
||||
|
@ -128,6 +124,8 @@ void Window::closeEvent(QCloseEvent *)
|
|||
{
|
||||
// Save closing window position
|
||||
// this->windowGeometry = this->geometry();
|
||||
|
||||
this->closed();
|
||||
}
|
||||
|
||||
void Window::refreshTheme()
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
//#endif
|
||||
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/signals2.hpp>
|
||||
#include <pajlada/settings/serialize.hpp>
|
||||
#include <pajlada/settings/settingdata.hpp>
|
||||
|
||||
|
@ -27,7 +28,6 @@ class Window : public BaseWidget
|
|||
public:
|
||||
explicit Window(ChannelManager &_channelManager, ColorScheme &_colorScheme,
|
||||
CompletionManager &_completionManager, bool isMainWindow);
|
||||
~Window();
|
||||
|
||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
||||
|
||||
|
@ -39,6 +39,8 @@ public:
|
|||
|
||||
Notebook &getNotebook();
|
||||
|
||||
boost::signals2::signal<void()> closed;
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
|
|
|
@ -20,6 +20,12 @@ WindowManager::WindowManager(ChannelManager &_channelManager, ColorScheme &_colo
|
|||
WindowManager::instance = this;
|
||||
}
|
||||
|
||||
void WindowManager::initMainWindow()
|
||||
{
|
||||
this->selectedWindow = this->mainWindow =
|
||||
new widgets::Window(this->channelManager, this->colorScheme, this->completionManager, true);
|
||||
}
|
||||
|
||||
static const std::string &getSettingsPath()
|
||||
{
|
||||
static std::string path = (Path::getAppdataPath() + "uilayout.json").toStdString();
|
||||
|
@ -53,18 +59,12 @@ void WindowManager::repaintGifEmotes()
|
|||
|
||||
widgets::Window &WindowManager::getMainWindow()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->windowMutex);
|
||||
|
||||
if (this->mainWindow == nullptr) {
|
||||
this->mainWindow = new widgets::Window(this->channelManager, this->colorScheme,
|
||||
this->completionManager, true);
|
||||
}
|
||||
|
||||
return *this->mainWindow;
|
||||
}
|
||||
|
||||
widgets::Window &WindowManager::getCurrentWindow()
|
||||
widgets::Window &WindowManager::getSelectedWindow()
|
||||
{
|
||||
return *this->selectedWindow;
|
||||
}
|
||||
|
||||
widgets::Window &WindowManager::createWindow()
|
||||
|
@ -72,7 +72,6 @@ widgets::Window &WindowManager::createWindow()
|
|||
auto *window = new widgets::Window(this->channelManager, this->colorScheme,
|
||||
this->completionManager, false);
|
||||
|
||||
std::lock_guard<std::mutex> lock(this->windowMutex);
|
||||
window->loadDefaults();
|
||||
|
||||
this->windows.push_back(window);
|
||||
|
@ -80,6 +79,21 @@ widgets::Window &WindowManager::createWindow()
|
|||
return *window;
|
||||
}
|
||||
|
||||
int WindowManager::windowCount()
|
||||
{
|
||||
return this->windows.size();
|
||||
}
|
||||
|
||||
widgets::Window *WindowManager::windowAt(int index)
|
||||
{
|
||||
if (index < 0 || index >= this->windows.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
qDebug() << "getting window at bad index" << index;
|
||||
|
||||
return this->windows.at(index);
|
||||
}
|
||||
|
||||
void WindowManager::load()
|
||||
{
|
||||
const auto &settingsPath = getSettingsPath();
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
#include "widgets/window.hpp"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class ChannelManager;
|
||||
|
@ -25,13 +23,16 @@ public:
|
|||
void layoutVisibleChatWidgets(Channel *channel = nullptr);
|
||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
||||
void repaintGifEmotes();
|
||||
void initMainWindow();
|
||||
// void updateAll();
|
||||
|
||||
widgets::Window &getMainWindow();
|
||||
widgets::Window &getCurrentWindow();
|
||||
|
||||
widgets::Window &getSelectedWindow();
|
||||
widgets::Window &createWindow();
|
||||
|
||||
int windowCount();
|
||||
widgets::Window *windowAt(int index);
|
||||
|
||||
void load();
|
||||
void save();
|
||||
|
||||
|
@ -39,11 +40,10 @@ public:
|
|||
boost::signals2::signal<void()> layout;
|
||||
|
||||
private:
|
||||
std::mutex windowMutex;
|
||||
std::vector<widgets::Window *> windows;
|
||||
|
||||
// TODO(pajlada): Store as a value instead of a pointer
|
||||
widgets::Window *mainWindow = nullptr;
|
||||
widgets::Window *selectedWindow = nullptr;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
Loading…
Reference in a new issue