A lot of changes
Remove unused constructor of messages::Message Fixed LimitedQueueSnapshot _-prefixes Changed LimitedQueueSnapshot's usage of int to std::size_t ColorScheme is no longer a singleton Created a "BaseWidget" class which is pretty much a QWidget except it has a reference of ColorScheme since most widgets will need a reference to the style they should use. BaseWidget can be implemented either with a BaseWidget parent (which will copy the ColorScheme reference from the parent) or with a normal QWidget parent and an explicit ColorScheme reference. Save main window geometry on close Fix font changing in the Settings Dialog Update settings library version
This commit is contained in:
@@ -19,12 +19,12 @@
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
MainWindow::MainWindow(ChannelManager &_channelManager, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
MainWindow::MainWindow(ChannelManager &_channelManager, ColorScheme &_colorScheme)
|
||||
: BaseWidget(_colorScheme, nullptr)
|
||||
, channelManager(_channelManager)
|
||||
, colorScheme(_colorScheme)
|
||||
, notebook(this->channelManager, this)
|
||||
, _loaded(false)
|
||||
, _titleBar()
|
||||
, windowGeometry("/windows/0/geometry")
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
|
||||
@@ -44,10 +44,17 @@ MainWindow::MainWindow(ChannelManager &_channelManager, QWidget *parent)
|
||||
// }
|
||||
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background, ColorScheme::getInstance().TabPanelBackground);
|
||||
palette.setColor(QPalette::Background, this->colorScheme.TabPanelBackground);
|
||||
setPalette(palette);
|
||||
|
||||
resize(1280, 800);
|
||||
if (this->windowGeometry->isFilled()) {
|
||||
// Load geometry from settings file
|
||||
this->setGeometry(this->windowGeometry.getValueRef());
|
||||
} else {
|
||||
// Set default geometry
|
||||
// Default position is in the middle of the current monitor or the primary monitor
|
||||
this->resize(1280, 800);
|
||||
}
|
||||
|
||||
// Initialize program-wide hotkeys
|
||||
{
|
||||
@@ -122,7 +129,7 @@ void MainWindow::load(const boost::property_tree::ptree &tree)
|
||||
{
|
||||
this->notebook.load(tree);
|
||||
|
||||
_loaded = true;
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
boost::property_tree::ptree MainWindow::save()
|
||||
@@ -140,12 +147,12 @@ void MainWindow::loadDefaults()
|
||||
{
|
||||
this->notebook.loadDefaults();
|
||||
|
||||
_loaded = true;
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
bool MainWindow::isLoaded() const
|
||||
{
|
||||
return _loaded;
|
||||
return loaded;
|
||||
}
|
||||
|
||||
Notebook &MainWindow::getNotebook()
|
||||
@@ -153,5 +160,11 @@ Notebook &MainWindow::getNotebook()
|
||||
return this->notebook;
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
// Save closing window position
|
||||
this->windowGeometry = this->geometry();
|
||||
}
|
||||
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user