From 162e257b96f0f2ebc167e8121f16459350c76539 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 21 Apr 2011 11:53:45 +0200 Subject: [PATCH] Added the persistence of the dockpalettes width. --- src/core/UBSettings.cpp | 3 +++ src/core/UBSettings.h | 8 ++++++++ src/gui/UBLibPalette.cpp | 9 ++++++++- src/gui/UBLibPalette.h | 2 ++ src/gui/UBNavigatorPalette.cpp | 5 +++-- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 956e12a6..3a907292 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -168,6 +168,9 @@ void UBSettings::init() appEnableAutomaticSoftwareUpdates = new UBSetting(this, "App", "EnableAutomaticSoftwareUpdates", true); appEnableSoftwareUpdates = new UBSetting(this, "App", "EnableSoftwareUpdates", true); appToolBarOrientationVertical = new UBSetting(this, "App", "ToolBarOrientationVertical", true); + navigPaletteWidth = new UBSetting(this, "Board", "NavigPaletteWidth", 300); + libPaletteWidth = new UBSetting(this, "Board", "LibPaletteWidth", 300); + appIsInSoftwareUpdateProcess = new UBSetting(this, "App", "IsInSoftwareUpdateProcess", false); appLastSessionDocumentUUID = new UBSetting(this, "App", "LastSessionDocumentUUID", ""); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index 20cc2ea5..6c9b7a14 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -310,6 +310,14 @@ class UBSettings : public QObject UBSetting* gipThumbnailWidth; UBSetting* soundThumbnailWidth; + UBSetting* navigPaletteWidth; + UBSetting* libPaletteWidth; + + /* + static int navigPaletteWidth; + static int libPaletteWidth; + */ + public slots: void setPenWidthIndex(int index); diff --git a/src/gui/UBLibPalette.cpp b/src/gui/UBLibPalette.cpp index 8494e064..d64827b6 100644 --- a/src/gui/UBLibPalette.cpp +++ b/src/gui/UBLibPalette.cpp @@ -17,9 +17,10 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare mIcon = QPixmap(":images/paletteLibrary.png"); setAcceptDrops(true); - resize(300, height()); + resize(UBSettings::settings()->libPaletteWidth->get().toInt(), height()); setContentsMargins(border(), 0, 0, 0); mCollapseWidth = 180; + mLastWidth = 300; mLayout = new QVBoxLayout(this); mLayout->setMargin(3); @@ -158,3 +159,9 @@ void UBLibPalette::showFolder() mActionBar->setButtons(mActionBar->previousButtonSet()); mStackedWidget->setCurrentIndex(ID_NAVIGATOR); } + +void UBLibPalette::resizeEvent(QResizeEvent *event) +{ + UBDockPalette::resizeEvent(event); + UBSettings::settings()->libPaletteWidth->set(width()); +} diff --git a/src/gui/UBLibPalette.h b/src/gui/UBLibPalette.h index 0bd66ab1..7dc6c6f8 100644 --- a/src/gui/UBLibPalette.h +++ b/src/gui/UBLibPalette.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "UBDockPalette.h" #include "UBLibNavigatorWidget.h" @@ -33,6 +34,7 @@ protected: void dropEvent(QDropEvent *pEvent); void dragMoveEvent(QDragMoveEvent* pEvent); void mouseMoveEvent(QMouseEvent *event); + void resizeEvent(QResizeEvent *event); private slots: void showProperties(UBLibElement* elem); diff --git a/src/gui/UBNavigatorPalette.cpp b/src/gui/UBNavigatorPalette.cpp index 28232297..958f5676 100644 --- a/src/gui/UBNavigatorPalette.cpp +++ b/src/gui/UBNavigatorPalette.cpp @@ -17,8 +17,8 @@ UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):UBDock setOrientation(eUBDockOrientation_Left); setMaximumWidth(300); mIcon = QPixmap(":images/paletteNavigator.png"); - resize(maximumWidth(), height()); - + resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height()); + mLastWidth = 300; setContentsMargins(0, 0, border(), 0); // Build the gui @@ -135,6 +135,7 @@ void UBNavigatorPalette::resizeEvent(QResizeEvent *event) { mNavigator->setMinimumHeight(height() - 2*border()); } + UBSettings::settings()->navigPaletteWidth->set(width()); } void UBNavigatorPalette::timerEvent(QTimerEvent *event)