Commit 1a26749f authored by Jan Möbius's avatar Jan Möbius

Reintroduce option to render pick toolbar outside of glScene

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12185 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 719c55bb
......@@ -146,6 +146,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
windowMenu_(0),
AC_ShowViewModeControls_(0),
AC_ShowToolbox_(0),
pickToolBarExternal_(0),
cursorPainter_(0),
sceneGraphDialog_(0),
fileMenu_(0),
......
......@@ -668,6 +668,9 @@ public:
typedef std::map<QToolBar*,QGraphicsItem*> PickToolBarMap;
PickToolBarMap curPickingToolbarItems_;
/// Extra toolbar not in scene for picking
QToolBar* pickToolBarExternal_;
/// Cursor handling
CursorPainter* cursorPainter_;
......
......@@ -181,23 +181,59 @@ void CoreWidget::setActivePickToolBar(QToolBar* _tool) {
if(_tool != 0) {
// Hide all picking toolbars
hidePickToolBar();
// Hide all picking toolbars
hidePickToolBar();
// Try to find toolbar in local map
if ( OpenFlipperSettings().value("Core/Gui/ToolBars/PickToolbarInScene",true).toBool() ) {
// Try to find toolbar in local map ( if it is in the gl scene
PickToolBarMap::iterator ret = curPickingToolbarItems_.find(_tool);
if(ret == curPickingToolbarItems_.end()) {
// Add widget
QGraphicsItem* item = glScene_->addWidget(_tool);
// Put it into center of the screen
int midP = (glScene_->width() / 2) - (int)(_tool->width() / 2);
item->setPos(midP, 3);
item->show();
curPickingToolbarItems_.insert(std::pair<QToolBar*,QGraphicsItem*>(_tool,item));
// Set horizontal orientation
_tool->setOrientation(Qt::Horizontal);
// Update size as the orientation changed
_tool->adjustSize();
// Add widget to the gl scene
QGraphicsItem* item = glScene_->addWidget(_tool);
// Put it into center of the screen
int midP = (glScene_->width() / 2) - (int)(_tool->width() / 2);
item->setPos(midP, 3);
item->show();
// Remember it as being part of the scene
curPickingToolbarItems_.insert(std::pair<QToolBar*,QGraphicsItem*>(_tool,item));
} else {
// Widget has already been added once, so just show it
ret->second->show();
// Widget has already been added once, so just show it
ret->second->show();
}
} else {
// Try to find toolbar in local map
// If its in there, we need to remove it from the graphics scene before adding it
// to the side toolbar.
PickToolBarMap::iterator ret = curPickingToolbarItems_.find(_tool);
if(ret != curPickingToolbarItems_.end()) {
glScene_->removeItem(ret->second);
ret->first->setParent(0);
// remove from list of widgets in glScene
curPickingToolbarItems_.erase(ret);
}
pickToolBarExternal_ = _tool;
// size
pickToolBarExternal_->setOrientation(Qt::Vertical);
pickToolBarExternal_->adjustSize();
addToolBar(Qt::LeftToolBarArea,_tool);
_tool->show();
}
} else {
hidePickToolBar();
}
......@@ -207,11 +243,23 @@ void CoreWidget::setActivePickToolBar(QToolBar* _tool) {
void CoreWidget::hidePickToolBar() {
// Hide all picking toolbars
for(PickToolBarMap::iterator it = curPickingToolbarItems_.begin();
it != curPickingToolbarItems_.end(); ++it) {
it->second->hide();
}
// Hide all picking toolbars
for(PickToolBarMap::iterator it = curPickingToolbarItems_.begin();
it != curPickingToolbarItems_.end(); ++it) {
it->second->hide();
}
// if a toolbar is in the global scene, we remove it here.
if ( pickToolBarExternal_ != 0 ) {
pickToolBarExternal_->hide();
removeToolBar(pickToolBarExternal_);
pickToolBarExternal_->setParent(0);
pickToolBarExternal_ = 0;
}
}
//-----------------------------------------------------------------------------
......
......@@ -59,7 +59,7 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB
plugins_(_plugins),
coreKeys_(_core),
keys_(_invKeys),
translationIndexChanged_(false),
restartRequired_(false),
exitOnClose_(false)
{
setupUi(this);
......@@ -229,7 +229,7 @@ void OptionsWidget::switchStackedWidget() {
}
void OptionsWidget::slotTranslationIndexChanged(int /*_index*/) {
translationIndexChanged_ = true;
restartRequired_ = true;
}
void OptionsWidget::updateViewerSettings(int _row){
......@@ -622,7 +622,10 @@ void OptionsWidget::slotApply() {
OpenFlipperSettings().setValue("Core/Gui/ToolBoxes/ToolBoxOnTheRight", (toolBoxOrientation->currentIndex() == 0));
// Render picking toolbar into scene
OpenFlipperSettings().setValue("Core/Gui/ToolBars/PickToolbarInScene", pickToolbarInScene->isChecked());
if ( OpenFlipperSettings().value("Core/Gui/ToolBars/PickToolbarInScene",true).toBool() != pickToolbarInScene->isChecked() ) {
OpenFlipperSettings().setValue("Core/Gui/ToolBars/PickToolbarInScene", pickToolbarInScene->isChecked());
restartRequired_ = true;
}
if ( iconDefault->isChecked() )
OpenFlipperSettings().setValue("Core/Toolbar/iconSize", 0);
......@@ -734,20 +737,20 @@ void OptionsWidget::slotApply() {
((double) backgroundColor_.blueF()),
1.0));
// Show warning message that restart is required if language has been changed...
if(translationIndexChanged_) {
switch ( translation->currentIndex() ){
case 0 : OpenFlipperSettings().setValue("Core/Language/Translation","en_US"); break;
case 1 : OpenFlipperSettings().setValue("Core/Language/Translation","de_DE"); break;
default: OpenFlipperSettings().setValue("Core/Language/Translation","locale"); break;
}
// Show warning message that restart is required if language or in scene toolbar has been changed...
if(restartRequired_) {
int restart = QMessageBox::information(this, tr("Restart required!"),
tr("The changes will take effect after next restart. Do you want to close OpenFlipper now?"),
QMessageBox::Yes | QMessageBox::No);
if(restart == QMessageBox::Yes) exitOnClose_ = true;
}
switch ( translation->currentIndex() ){
case 0 : OpenFlipperSettings().setValue("Core/Language/Translation","en_US"); break;
case 1 : OpenFlipperSettings().setValue("Core/Language/Translation","de_DE"); break;
default: OpenFlipperSettings().setValue("Core/Language/Translation","locale"); break;
}
applyShortcuts();
......
......@@ -231,7 +231,7 @@ private:
/** Used to track whether another language has been selected
*/
bool translationIndexChanged_;
bool restartRequired_;
bool exitOnClose_;
......
......@@ -170,7 +170,7 @@
<property name="title">
<string>Pick Toolbar</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_30">
<item>
<layout class="QFormLayout" name="formLayout_6">
<item row="0" column="0">
......
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