Commit b51bba5a authored by Matthias Möller's avatar Matthias Möller

fix: toolbar will resize to saved position if paste view

refs #375

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14164 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e8b40f98
......@@ -832,13 +832,34 @@ void CoreWidget::delete_garbage() {
}
void CoreWidget::slotPasteView( ) {
QSize size = examiner_widgets_[PluginFunctions::activeExaminer()]->actionPasteView();
QSize size;
int toolBarWidth;
examiner_widgets_[PluginFunctions::activeExaminer()]->actionPasteView(&size,&toolBarWidth);
//resize the toolbox
if (toolBarWidth != -1)
{
QList<int> sizes = toolSplitter_->sizes();
bool onRight = OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight").toBool();
if (onRight)
{
sizes[1] = toolBarWidth;
sizes[0] += toolBarWidth;
}
else
{
sizes[0] = toolBarWidth;
sizes[1] += toolBarWidth;
}
toolSplitter_->setSizes(sizes);
viewerToolbar_->resize(toolBarWidth, viewerToolbar_->height());
}
if (size.isValid())
{
//ask for restoring the window size
QMessageBox msgBox;
msgBox.setText("Restore window size?");
msgBox.setText(QString("Restore window size?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Ok);
......@@ -857,6 +878,8 @@ void CoreWidget::slotPasteView( ) {
}
}
}
}
void CoreWidget::slotCopyView( ) {
......@@ -865,7 +888,7 @@ void CoreWidget::slotCopyView( ) {
size = QSize(0,0);
else
size = QSize (width(),height());
examiner_widgets_[PluginFunctions::activeExaminer()]->actionCopyView(size);
examiner_widgets_[PluginFunctions::activeExaminer()]->actionCopyView(size,viewerToolbar_->width());
}
void CoreWidget::slotCoordSysVisibility(bool _visible){
......
......@@ -980,7 +980,7 @@ void glViewer::moveEvent (QGraphicsSceneMoveEvent *)
//-----------------------------------------------------------------------------
void glViewer::encodeView(QString& _view, const QSize& _windowSize /*= QSize()*/)
void glViewer::encodeView(QString& _view, const QSize& _windowSize /*= QSize()*/, const int _toolBarWidth /*=-1*/)
{
// Get current matrices
const ACG::GLMatrixd m = glstate_->modelview();
......@@ -1000,15 +1000,21 @@ void glViewer::encodeView(QString& _view, const QSize& _windowSize /*= QSize()*/
_view += QString::number(p(3,0)) + " " + QString::number(p(3,1)) + " " + QString::number(p(3,2)) + " " + QString::number(p(3,3)) + "\n";
// add gl width/height, current projection Mode and the ortho mode width to output
_view += QString::number(_windowSize.width()) + " " + QString::number(_windowSize.height()) + " " + QString::number(projectionMode_) + " " + QString::number(properties_.orthoWidth()) + "\n";
_view += QString::number(_windowSize.width()) + " " + QString::number(_windowSize.height()) + " " + QString::number(_toolBarWidth)+ " " + QString::number(projectionMode_) + " " + QString::number(properties_.orthoWidth()) + "\n";
}
//----------------------------------------------------------------------------
bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/)
bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/, int* _toolBarWidth /*= NULL*/)
{
if (_windowSize)
*_windowSize = QSize(-1,-1);
if (_toolBarWidth)
*_toolBarWidth = -1;
if (_view.left(sizeof(VIEW_MAGIC)-1) != QString(VIEW_MAGIC))
return false;
......@@ -1023,7 +1029,7 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/)
int pMode;
// Check if the number of components matches the expected size
if ( split.size() != 36 ) {
if ( split.size() != 37 ) {
std::cerr << "Unable to paste view ... wrong parameter count!! is" << split.size() << std::endl;
return false;
}
......@@ -1082,8 +1088,17 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/)
*_windowSize = QSize(w,h);
}
pMode = split[34].toInt(&ok); if ( !ok ) { std::cerr << "Error in decoding View!" << std::endl; return false; }
properties_.orthoWidth( split[35].toDouble(&ok) ); if ( !ok ) { std::cerr << "Error in decoding View!" << std::endl; return false; }
if (_toolBarWidth)
{
*_toolBarWidth = split[34].toInt(&ok);
if ( !ok )
{
std::cerr << "No toolbar width saved!" << std::endl;
}
}
pMode = split[35].toInt(&ok); if ( !ok ) { std::cerr << "Error in decoding View!" << std::endl; return false; }
properties_.orthoWidth( split[36].toDouble(&ok) ); if ( !ok ) { std::cerr << "Error in decoding View!" << std::endl; return false; }
// Switch to our gl context
makeCurrent();
......@@ -1104,10 +1119,10 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/)
//-----------------------------------------------------------------------------
void glViewer::actionCopyView(const QSize &_windowSize /*=QSize()*/)
void glViewer::actionCopyView(const QSize &_windowSize /*= QSize(-1,-1)*/, const int _toolBarWidth /*= -1*/)
{
QString view;
encodeView(view,_windowSize);
encodeView(view,_windowSize,_toolBarWidth);
QApplication::clipboard()->setText(view);
}
......@@ -1115,13 +1130,11 @@ void glViewer::actionCopyView(const QSize &_windowSize /*=QSize()*/)
//-----------------------------------------------------------------------------
QSize glViewer::actionPasteView()
void glViewer::actionPasteView(QSize * _windowSize /*= NULL*/, int *_toolBarWidth /*= NULL*/)
{
QString view;
view = QApplication::clipboard()->text();
QSize oldSize;
decodeView(view,&oldSize);
return oldSize;
decodeView(view,_windowSize,_toolBarWidth);
}
......
......@@ -265,7 +265,7 @@ public:
if saved, the old window size will be written into _windowSize
\note QSize(0,0) indicates that the window is maximized.
*/
void encodeView(QString& _view, const QSize& _windowSize = QSize(-1,-1));
void encodeView(QString& _view, const QSize& _windowSize = QSize(-1,-1), const int _toolBarWidth = -1);
/** Decode and apply text representation of view encoded by encodeView().
If \c _view was successfully decoded it will immediately be applied
and \c true is returned, \c false is returned else.
......@@ -273,7 +273,7 @@ public:
You can save the current Window size via parameter _windowSize
\note QSize(0,0) indicates that the window was maximized.
*/
bool decodeView(const QString& _view, QSize *_windowSize = NULL);
bool decodeView(const QString& _view, QSize *_windowSize = NULL, int* _toolBarWidth = NULL);
/// initialize modelview matrix to identity
void initModelviewMatrix();
......@@ -354,11 +354,11 @@ public slots:
/** you get the older window size (if saved) back
\note QSize(0,0) indicates that the window is maximized.
*/
QSize actionPasteView();
void actionPasteView(QSize * _windowSize = NULL, int *_toolBarWidth = NULL);
/** if you want to save the windowSize, use the parameter
\note QSize(0,0) indicates that the window is maximized
*/
void actionCopyView(const QSize &_windowSize = QSize());
void actionCopyView(const QSize &_windowSize = QSize(-1,-1), const int _toolBarWidth = -1);
//-------------------------------------------------------------- public signals
signals:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment