r15260 by cbradney - #9058: Re-eanble saving of toolbar visibility
scribus-commit
scribus-commit at lists.scribus.net
Wed Jun 23 23:10:30 CEST 2010
Revision: 15260
Author: cbradney
Date: 2010-06-23T21:04:00.037062Z
Commit message: #9058: Re-eanble saving of toolbar visibility
Changeset:
M /trunk/Scribus/scribus/scribus.cpp
M /trunk/Scribus/scribus/ui/sctoolbar.h
M /trunk/Scribus/scribus/prefscontext.cpp
M /trunk/Scribus/scribus/ui/sctoolbar.cpp
Diffs:
Index: scribus/prefscontext.cpp
===================================================================
--- scribus/prefscontext.cpp (revision 15259)
+++ scribus/prefscontext.cpp (revision 15260)
@@ -91,7 +91,7 @@
void PrefsContext::set(const QString& key, const QString& value)
{
- values[key] = value;
+ values.insert(key, value);
}
int PrefsContext::getInt(const QString& key, int defValue)
Index: scribus/ui/sctoolbar.cpp
===================================================================
--- scribus/ui/sctoolbar.cpp (revision 15259)
+++ scribus/ui/sctoolbar.cpp (revision 15260)
@@ -24,6 +24,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include <QCloseEvent>
#include <QEvent>
#include <QMenu>
#include <QPixmap>
@@ -39,9 +40,9 @@
ScToolBar::ScToolBar(const QString& name, const QString &prefName, QMainWindow *parent, Qt::Orientation o)
: QToolBar(name, parent),
- m_name(QString("ToolBar-%1").arg(prefName)),
- m_prefs(PrefsManager::instance()->prefsFile->getContext(m_name))
+ m_name(QString("ToolBar-%1").arg(prefName))
{
+ m_prefs=PrefsManager::instance()->prefsFile->getContext(m_name);
setObjectName(name);
// hide();
parentMW=parent;
@@ -105,22 +106,32 @@
// connect(this, SIGNAL(placeChanged(Q3DockWindow::Place)), this, SLOT(slotPlaceChanged(Q3DockWindow::Place)));
}
-/*
+
void ScToolBar::initVisibility()
{
if (m_prefs->getBool("IsVisible", true))
{
show();
+ /*
if (place() == InDock)
setOrientation(area()->orientation());
else
- setOrientation(floatOrientation);
+ setOrientation(floatOrientation);*/
}
else
hide();
- connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(slotVisibilityChanged(bool)));
+ connectPrefsSlot(true);
}
+void ScToolBar::connectPrefsSlot(bool b)
+{
+ if (b)
+ connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(slotVisibilityChanged(bool)));
+ else
+ disconnect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(slotVisibilityChanged(bool)));
+}
+
+/*
int ScToolBar::position()
{
if (place() == Q3DockWindow::OutsideDock)
@@ -191,12 +202,12 @@
setOrientation(floatOrientation);
}
}
-
+*/
void ScToolBar::slotVisibilityChanged(bool visible)
{
m_prefs->set("IsVisible", visible);
}
-
+/*
void ScToolBar::slotTop()
{
dockTop = !dockTop;
Index: scribus/ui/sctoolbar.h
===================================================================
--- scribus/ui/sctoolbar.h (revision 15259)
+++ scribus/ui/sctoolbar.h (revision 15260)
@@ -46,11 +46,14 @@
// if using name settings depend on the language
ScToolBar(const QString& name, const QString &prefName, QMainWindow *parent, Qt::Orientation o = Qt::Horizontal);
virtual ~ScToolBar();
+ //bit of a hack as saving prefs seems to happen on shutdown and prefs is already in the process of being destroyed
+ void connectPrefsSlot(bool b);
+
// int position();
// void storeDockPosition();
// void moveDock();
-// void initVisibility();
+ void initVisibility();
signals:
void visibilityChanged(bool);
@@ -60,7 +63,7 @@
protected slots:
// void slotPlaceChanged(Q3DockWindow::Place p);
-// void slotVisibilityChanged(bool visible);
+ void slotVisibilityChanged(bool visible);
// void slotTop();
// void slotRight();
// void slotBottom();
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp (revision 15259)
+++ scribus/scribus.cpp (revision 15260)
@@ -425,11 +425,10 @@
modeToolBar = new ModeToolBar(this);
pdfToolBar = new PDFToolBar(this);
- addScToolBar(fileToolBar, "ToolBar-File");
- addScToolBar(editToolBar, "ToolBar-Edit");
- addScToolBar(modeToolBar, "ToolBar-Tools");
- addScToolBar(pdfToolBar, "ToolBar-PDF_Tools");
-
+ addScToolBar(fileToolBar, fileToolBar->objectName());
+ addScToolBar(editToolBar, editToolBar->objectName());
+ addScToolBar(modeToolBar, modeToolBar->objectName());
+ addScToolBar(pdfToolBar, pdfToolBar->objectName());
connect(modeToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarTools"], SLOT(setChecked(bool)));
connect(scrActions["toolsToolbarPDF"], SIGNAL(toggled(bool)), pdfToolBar, SLOT(setVisible(bool)));
connect(pdfToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarPDF"], SLOT(setChecked(bool)));
@@ -1578,6 +1577,10 @@
}
}
}
+ fileToolBar->connectPrefsSlot(false);
+ editToolBar->connectPrefsSlot(false);
+ modeToolBar->connectPrefsSlot(false);
+ pdfToolBar->connectPrefsSlot(false);
propertiesPalette->hide();
outlinePalette->hide();
scrapbookPalette->hide();
@@ -4669,6 +4672,10 @@
propertiesPalette->unsetDoc();
symbolPalette->unsetDoc();
ScCore->pluginManager->savePreferences();
+ fileToolBar->connectPrefsSlot(false);
+ editToolBar->connectPrefsSlot(false);
+ modeToolBar->connectPrefsSlot(false);
+ pdfToolBar->connectPrefsSlot(false);
close();
}
@@ -7740,10 +7747,10 @@
symbolPalette->startup();
// init the toolbars
-// fileToolBar->initVisibility();
-// editToolBar->initVisibility();
-// modeToolBar->initVisibility();
-// pdfToolBar->initVisibility();
+ fileToolBar->initVisibility();
+ editToolBar->initVisibility();
+ modeToolBar->initVisibility();
+ pdfToolBar->initVisibility();
activateWindow();
if (!scriptIsRunning())
More information about the scribus-commit
mailing list