Skip to content

Commit

Permalink
save/restore docks : - ID: 3091386
Browse files Browse the repository at this point in the history
Patch supplied by Rallaz, thanks!

git-svn-id: https://librecad.svn.sourceforge.net/svnroot/librecad/trunk@97 c6892bbe-2a20-4548-a94f-41916fb2bb95
  • Loading branch information
rvt committed Nov 13, 2010
1 parent 8a0ba34 commit 8c8b80b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
22 changes: 22 additions & 0 deletions src/lib/engine/rs_settings.cpp
Expand Up @@ -126,6 +126,28 @@ RS_String RS_Settings::readEntry(const RS_String& key,

}

QByteArray RS_Settings::readByteArrayEntry(const RS_String& key,
const RS_String& def,
bool* ok) {
QVariant ret = readEntryCache(key);
if (!ret.isValid()) {

QSettings s(companyKey, appKey);
// RVT_PORT not supported anymore s.insertSearchPath(QSettings::Windows, companyKey);

if (ok!=NULL) {
*ok=s.contains(QString("%1%2").arg(group).arg(key));
}

ret = s.value(QString("%1%2").arg(group).arg(key), QVariant(def));

addToCache(key, ret);
}

return ret.toByteArray();

}

int RS_Settings::readNumEntry(const RS_String& key, int def, bool* ok) {

// lookup:
Expand Down
3 changes: 3 additions & 0 deletions src/lib/engine/rs_settings.h
Expand Up @@ -79,6 +79,9 @@ class RS_Settings {
RS_String readEntry(const RS_String& key,
const RS_String& def = RS_String::null,
bool* ok = 0);
QByteArray readByteArrayEntry(const RS_String& key,
const RS_String& def = RS_String::null,
bool* ok = 0);
int readNumEntry(const RS_String& key, int def=0, bool* ok=0);


Expand Down
23 changes: 12 additions & 11 deletions src/main/qc_applicationwindow.cpp
Expand Up @@ -54,12 +54,9 @@
#include <qpainter.h>
#include <qprinter.h>
#include <qtimer.h>
#include <q3textstream.h>
#include <q3vbox.h>

#include <q3dockwindow.h>
#include <qeventloop.h>
#include <q3textedit.h>

#include "rs_application.h"
#include "rs_actiondrawlinefree.h"
Expand Down Expand Up @@ -1302,14 +1299,18 @@ void QC_ApplicationWindow::initToolBar() {

fileToolBar = new QToolBar( "File Operations", this);
fileToolBar->setSizePolicy(toolBarPolicy);
fileToolBar->setObjectName ( "FileTB" );

editToolBar = new QToolBar( "Edit Operations", this);
editToolBar->setSizePolicy(toolBarPolicy);
editToolBar->setObjectName ( "EditTB" );
zoomToolBar = new QToolBar( "Zoom Operations", this);
zoomToolBar->setSizePolicy(toolBarPolicy);
zoomToolBar->setObjectName ( "ZoomTB" );

penToolBar = new QG_PenToolBar("Pen Selection", this);
penToolBar->setSizePolicy(toolBarPolicy);
penToolBar->setObjectName ( "PenTB" );

connect(penToolBar, SIGNAL(penChanged(RS_Pen)),
this, SLOT(slotPenChanged(RS_Pen)));
Expand All @@ -1318,6 +1319,7 @@ void QC_ApplicationWindow::initToolBar() {
QSizePolicy optionWidgetBarPolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
optionWidget->setMinimumSize(440,30);
optionWidget->setSizePolicy(optionWidgetBarPolicy);
optionWidget->setObjectName ( "ToolTB" );

//optionWidget->setFixedExtentHeight(26);
//optionWidget->setHorizontallyStretchable(true);
Expand All @@ -1328,6 +1330,7 @@ void QC_ApplicationWindow::initToolBar() {
t->setMinimumSize(59,250);
QSizePolicy policy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
t->setSizePolicy(policy);
t->setObjectName ( "CADTB" );
// t->setFixedExtentWidth(59);
// t->setVerticallyStretchable(true);
addToolBar(Qt::LeftToolBarArea, t);
Expand Down Expand Up @@ -1410,11 +1413,8 @@ void QC_ApplicationWindow::initSettings() {
*/
void QC_ApplicationWindow::restoreDocks() {
RS_SETTINGS->beginGroup("/Geometry");
QString docks = RS_SETTINGS->readEntry("/DockWindows", "");
restoreState ( RS_SETTINGS->readByteArrayEntry("/DockWindows", ""));
RS_SETTINGS->endGroup();

Q3TextStream ts(&docks, QIODevice::ReadOnly);
// RVT_PORT ts >> *this;
}


Expand All @@ -1423,8 +1423,6 @@ void QC_ApplicationWindow::restoreDocks() {
*/
void QC_ApplicationWindow::storeSettings() {
RS_DEBUG->print("QC_ApplicationWindow::storeSettings()");
QString docks;
Q3TextStream ts(&docks, QIODevice::WriteOnly);

RS_SETTINGS->beginGroup("/RecentFiles");
for (int i=0; i<recentFiles->count(); ++i) {
Expand All @@ -1438,8 +1436,7 @@ void QC_ApplicationWindow::storeSettings() {
RS_SETTINGS->writeEntry("/WindowHeight", height());
RS_SETTINGS->writeEntry("/WindowX", x());
RS_SETTINGS->writeEntry("/WindowY", y());
// RVT_PORT ts << *this;
RS_SETTINGS->writeEntry("/DockWindows", docks);
RS_SETTINGS->writeEntry("/DockWindows", QVariant (saveState()));
RS_SETTINGS->endGroup();

RS_DEBUG->print("QC_ApplicationWindow::storeSettings(): OK");
Expand All @@ -1464,6 +1461,7 @@ void QC_ApplicationWindow::initView() {

RS_DEBUG->print(" layer widget..");
dw = new QDockWidget( "Layer", this);
dw->setObjectName ( "LayerDW" );
layerWidget = new QG_LayerWidget(actionHandler, dw, "Layer");
layerWidget->setFocusPolicy(Qt::NoFocus);
connect(layerWidget, SIGNAL(escape()),
Expand All @@ -1486,6 +1484,7 @@ void QC_ApplicationWindow::initView() {

RS_DEBUG->print(" block widget..");
dw = new QDockWidget("Block", this);
dw->setObjectName ( "BlockDW" );
// dw->setResizeEnabled(true);
blockWidget = new QG_BlockWidget(actionHandler, dw, "Block");
blockWidget->setFocusPolicy(Qt::NoFocus);
Expand All @@ -1504,6 +1503,7 @@ void QC_ApplicationWindow::initView() {

RS_DEBUG->print(" library widget..");
dw = new QDockWidget("Library", this);
dw->setObjectName ( "LibraryDW" );
libraryWidget = new QG_LibraryWidget(dw, "Library");
libraryWidget->setActionHandler(actionHandler);
libraryWidget->setFocusPolicy(Qt::NoFocus);
Expand All @@ -1526,6 +1526,7 @@ void QC_ApplicationWindow::initView() {

RS_DEBUG->print(" command widget..");
dw = new QDockWidget("Command", this);
dw->setObjectName ( "CommandDW" );
// dw->setResizeEnabled(true);
commandWidget = new QG_CommandWidget(dw, "Command");
commandWidget->setActionHandler(actionHandler);
Expand Down

0 comments on commit 8c8b80b

Please sign in to comment.