Commit 8468d1c9 authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

Added setViewAndWindowGeometry to core scripting functions.


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@18670 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e1568a21
......@@ -727,6 +727,7 @@ public slots:
void unblockSceneGraphUpdates();
void setView(QString view);
void setViewAndWindowGeometry(QString view);
//===========================================================================
/** @name Scripting functions for controlling view modes
......
......@@ -349,6 +349,10 @@ void Core::setView(QString view) {
coreWidget_->slotSetView(view);
}
void Core::setViewAndWindowGeometry(QString view) {
coreWidget_->slotSetViewAndWindowGeometry(view);
}
//=============================================================================
//== Script Special Functions =================================================
//=============================================================================
......
......@@ -924,6 +924,9 @@ public:
/// Set the supplied serialized view
void slotSetView( QString view );
/// Set the supplied serialized view
void slotSetViewAndWindowGeometry( QString view );
/// Copy view from the last active examiner
void slotCopyView( );
......
......@@ -574,9 +574,9 @@ void CoreWidget::viewerSnapshotDialog() {
if (dialog.metaData_storeView_cb->isChecked()) {
QSize window_size;
if (isMaximized())
window_size = QSize(0,0);
window_size = QSize(-width(), -height());
else
window_size = QSize (width(),height());
window_size = QSize (width(), height());
int splitter_size = 0;
if (OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight",true).toBool())
......@@ -891,6 +891,43 @@ void CoreWidget::slotSetView( QString view ) {
examiner_widgets_[PluginFunctions::activeExaminer()]->actionSetView(view);
}
void CoreWidget::slotSetViewAndWindowGeometry(QString view) {
const unsigned int viewerId = PluginFunctions::activeExaminer();
QSize windowSize(0, 0);
int splitterWidth = 0;
examiner_widgets_[viewerId]->decodeView (view, &windowSize, &splitterWidth);
if (windowSize.height() != 0 && windowSize.width() != 0) {
if (windowSize.width() < 0) {
windowSize *= -1;
showNormal();
resize(windowSize);
showMaximized();
} else {
showNormal();
resize(windowSize);
}
}
if (splitterWidth > 0) {
QList<int> splitter_sizes = toolSplitter_->sizes();
if (splitter_sizes.size() < 2) {
std::cerr << "The tool splitter has less than two children. This "
"shouldn't happen." << std::endl;
} else {
const size_t primary_idx = OpenFlipperSettings().value(
"Core/Gui/ToolBoxes/ToolBoxOnTheRight",true).toBool()
? 1 : 0;
const int diff = splitterWidth - splitter_sizes[primary_idx];
splitter_sizes[primary_idx] += diff;
splitter_sizes[1-primary_idx] -= diff;
}
toolSplitter_->setSizes(splitter_sizes);
}
}
void CoreWidget::slotPasteViewAndWindow()
{
QSize size;
......
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