1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

save/restore status of the splitter

This commit is contained in:
krepa098 2014-08-11 14:07:27 +02:00
parent c9d04748dd
commit 6bb85c65b8
4 changed files with 21 additions and 3 deletions

View File

@ -225,7 +225,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSplitter" name="centralWidget"> <widget class="QSplitter" name="mainSplitter">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>

View File

@ -106,6 +106,7 @@ void Settings::load()
useNativeDecoration = s.value("nativeDecoration", true).toBool(); useNativeDecoration = s.value("nativeDecoration", true).toBool();
windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray(); windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray();
windowState = s.value("windowState", QByteArray()).toByteArray(); windowState = s.value("windowState", QByteArray()).toByteArray();
splitterState = s.value("splitterState", QByteArray()).toByteArray();
s.endGroup(); s.endGroup();
s.beginGroup("Privacy"); s.beginGroup("Privacy");
@ -166,6 +167,7 @@ void Settings::save(QString path)
s.setValue("nativeDecoration", useNativeDecoration); s.setValue("nativeDecoration", useNativeDecoration);
s.setValue("windowGeometry", windowGeometry); s.setValue("windowGeometry", windowGeometry);
s.setValue("windowState", windowState); s.setValue("windowState", windowState);
s.setValue("splitterState", splitterState);
s.endGroup(); s.endGroup();
s.beginGroup("Privacy"); s.beginGroup("Privacy");
@ -383,6 +385,16 @@ void Settings::setWindowState(const QByteArray &value)
windowState = value; windowState = value;
} }
QByteArray Settings::getSplitterState() const
{
return splitterState;
}
void Settings::setSplitterState(const QByteArray &value)
{
splitterState = value;
}
bool Settings::isMinimizeOnCloseEnabled() const bool Settings::isMinimizeOnCloseEnabled() const
{ {
return minimizeOnClose; return minimizeOnClose;

View File

@ -124,6 +124,9 @@ public:
QByteArray getWindowState() const; QByteArray getWindowState() const;
void setWindowState(const QByteArray &value); void setWindowState(const QByteArray &value);
QByteArray getSplitterState() const;
void setSplitterState(const QByteArray &value);
private: private:
Settings(); Settings();
Settings(Settings &settings) = delete; Settings(Settings &settings) = delete;
@ -163,6 +166,7 @@ private:
bool useNativeDecoration; bool useNativeDecoration;
QByteArray windowGeometry; QByteArray windowGeometry;
QByteArray windowState; QByteArray windowState;
QByteArray splitterState;
// ChatView // ChatView
int firstColumnHandlePos; int firstColumnHandlePos;

View File

@ -55,6 +55,7 @@ Widget::Widget(QWidget *parent)
//restore window state //restore window state
restoreGeometry(Settings::getInstance().getWindowGeometry()); restoreGeometry(Settings::getInstance().getWindowGeometry());
restoreState(Settings::getInstance().getWindowState()); restoreState(Settings::getInstance().getWindowState());
ui->mainSplitter->restoreState(Settings::getInstance().getSplitterState());
if (Settings::getInstance().getUseNativeDecoration()) if (Settings::getInstance().getUseNativeDecoration())
{ {
@ -147,8 +148,8 @@ Widget::Widget(QWidget *parent)
//ui->friendList->viewport()->installEventFilter(this); //ui->friendList->viewport()->installEventFilter(this);
// disable proportional scaling // disable proportional scaling
ui->centralWidget->setStretchFactor(0,0); ui->mainSplitter->setStretchFactor(0,0);
ui->centralWidget->setStretchFactor(1,1); ui->mainSplitter->setStretchFactor(1,1);
ui->statusButton->setObjectName("offline"); ui->statusButton->setObjectName("offline");
ui->statusButton->style()->polish(ui->statusButton); ui->statusButton->style()->polish(ui->statusButton);
@ -253,6 +254,7 @@ void Widget::closeEvent(QCloseEvent *event)
{ {
Settings::getInstance().setWindowGeometry(saveGeometry()); Settings::getInstance().setWindowGeometry(saveGeometry());
Settings::getInstance().setWindowState(saveState()); Settings::getInstance().setWindowState(saveState());
Settings::getInstance().setSplitterState(ui->mainSplitter->saveState());
QWidget::closeEvent(event); QWidget::closeEvent(event);
} }