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

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, ...@@ -146,6 +146,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
windowMenu_(0), windowMenu_(0),
AC_ShowViewModeControls_(0), AC_ShowViewModeControls_(0),
AC_ShowToolbox_(0), AC_ShowToolbox_(0),
pickToolBarExternal_(0),
cursorPainter_(0), cursorPainter_(0),
sceneGraphDialog_(0), sceneGraphDialog_(0),
fileMenu_(0), fileMenu_(0),
......
...@@ -668,6 +668,9 @@ public: ...@@ -668,6 +668,9 @@ public:
typedef std::map<QToolBar*,QGraphicsItem*> PickToolBarMap; typedef std::map<QToolBar*,QGraphicsItem*> PickToolBarMap;
PickToolBarMap curPickingToolbarItems_; PickToolBarMap curPickingToolbarItems_;
/// Extra toolbar not in scene for picking
QToolBar* pickToolBarExternal_;
/// Cursor handling /// Cursor handling
CursorPainter* cursorPainter_; CursorPainter* cursorPainter_;
......
...@@ -181,23 +181,59 @@ void CoreWidget::setActivePickToolBar(QToolBar* _tool) { ...@@ -181,23 +181,59 @@ void CoreWidget::setActivePickToolBar(QToolBar* _tool) {
if(_tool != 0) { if(_tool != 0) {
// Hide all picking toolbars // Hide all picking toolbars
hidePickToolBar(); 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); PickToolBarMap::iterator ret = curPickingToolbarItems_.find(_tool);
if(ret == curPickingToolbarItems_.end()) { if(ret == curPickingToolbarItems_.end()) {
// Add widget
QGraphicsItem* item = glScene_->addWidget(_tool); // Set horizontal orientation
// Put it into center of the screen _tool->setOrientation(Qt::Horizontal);
int midP = (glScene_->width() / 2) - (int)(_tool->width() / 2);
item->setPos(midP, 3); // Update size as the orientation changed
item->show(); _tool->adjustSize();
curPickingToolbarItems_.insert(std::pair<QToolBar*,QGraphicsItem*>(_tool,item));
// 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 { } else {
// Widget has already been added once, so just show it // Widget has already been added once, so just show it
ret->second->show(); 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 { } else {
hidePickToolBar(); hidePickToolBar();
} }
...@@ -207,11 +243,23 @@ void CoreWidget::setActivePickToolBar(QToolBar* _tool) { ...@@ -207,11 +243,23 @@ void CoreWidget::setActivePickToolBar(QToolBar* _tool) {
void CoreWidget::hidePickToolBar() { void CoreWidget::hidePickToolBar() {
// Hide all picking toolbars // Hide all picking toolbars
for(PickToolBarMap::iterator it = curPickingToolbarItems_.begin(); for(PickToolBarMap::iterator it = curPickingToolbarItems_.begin();
it != curPickingToolbarItems_.end(); ++it) { it != curPickingToolbarItems_.end(); ++it) {
it->second->hide(); 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 ...@@ -59,7 +59,7 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB
plugins_(_plugins), plugins_(_plugins),
coreKeys_(_core), coreKeys_(_core),
keys_(_invKeys), keys_(_invKeys),
translationIndexChanged_(false), restartRequired_(false),
exitOnClose_(false) exitOnClose_(false)
{ {
setupUi(this); setupUi(this);
...@@ -229,7 +229,7 @@ void OptionsWidget::switchStackedWidget() { ...@@ -229,7 +229,7 @@ void OptionsWidget::switchStackedWidget() {
} }
void OptionsWidget::slotTranslationIndexChanged(int /*_index*/) { void OptionsWidget::slotTranslationIndexChanged(int /*_index*/) {
translationIndexChanged_ = true; restartRequired_ = true;
} }
void OptionsWidget::updateViewerSettings(int _row){ void OptionsWidget::updateViewerSettings(int _row){
...@@ -622,7 +622,10 @@ void OptionsWidget::slotApply() { ...@@ -622,7 +622,10 @@ void OptionsWidget::slotApply() {
OpenFlipperSettings().setValue("Core/Gui/ToolBoxes/ToolBoxOnTheRight", (toolBoxOrientation->currentIndex() == 0)); OpenFlipperSettings().setValue("Core/Gui/ToolBoxes/ToolBoxOnTheRight", (toolBoxOrientation->currentIndex() == 0));
// Render picking toolbar into scene // 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() ) if ( iconDefault->isChecked() )
OpenFlipperSettings().setValue("Core/Toolbar/iconSize", 0); OpenFlipperSettings().setValue("Core/Toolbar/iconSize", 0);
...@@ -734,20 +737,20 @@ void OptionsWidget::slotApply() { ...@@ -734,20 +737,20 @@ void OptionsWidget::slotApply() {
((double) backgroundColor_.blueF()), ((double) backgroundColor_.blueF()),
1.0)); 1.0));
// Show warning message that restart is required if language has been changed... switch ( translation->currentIndex() ){
if(translationIndexChanged_) { 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!"), int restart = QMessageBox::information(this, tr("Restart required!"),
tr("The changes will take effect after next restart. Do you want to close OpenFlipper now?"), tr("The changes will take effect after next restart. Do you want to close OpenFlipper now?"),
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if(restart == QMessageBox::Yes) exitOnClose_ = true; 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(); applyShortcuts();
......
...@@ -231,7 +231,7 @@ private: ...@@ -231,7 +231,7 @@ private:
/** Used to track whether another language has been selected /** Used to track whether another language has been selected
*/ */
bool translationIndexChanged_; bool restartRequired_;
bool exitOnClose_; bool exitOnClose_;
......
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
<property name="title"> <property name="title">
<string>Pick Toolbar</string> <string>Pick Toolbar</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_30">
<item> <item>
<layout class="QFormLayout" name="formLayout_6"> <layout class="QFormLayout" name="formLayout_6">
<item row="0" column="0"> <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