mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-19 17:57:22 +01:00
see #2468 object tree panel is not docable/floating window anymore
This commit is contained in:
parent
9561f4b2c5
commit
79ca86edb8
@ -949,7 +949,7 @@ void FWWindow::prepareViewMenu()
|
||||
m_mainWindow->actionEditor_panel->setEnabled(true);
|
||||
|
||||
m_mainWindow->actionObject_Tree->setChecked(
|
||||
activeProject()->m_panel->treeDockWidget->isVisible());
|
||||
activeProject()->m_panel->treePanelFrame->isVisible());
|
||||
m_mainWindow->actionEditor_panel->setChecked(
|
||||
m_mainWindow->editorDockWidget->isVisible());
|
||||
m_mainWindow->actionUndo_view->setChecked(
|
||||
|
||||
@ -163,6 +163,22 @@ ObjectTreeView::ObjectTreeView(ProjectPanel* project,
|
||||
// setSortingEnabled(true);
|
||||
}
|
||||
|
||||
void ObjectTreeView::paintEvent(QPaintEvent *ev)
|
||||
{
|
||||
// testing for #2475
|
||||
// QPalette pal = palette();
|
||||
// qDebug() << "ObjectTreeView::paintEvent"
|
||||
// << "color(QPalette::Highlight)="
|
||||
// << pal.color(QPalette::Highlight);
|
||||
|
||||
QStyleOptionViewItem option = viewOptions();
|
||||
qDebug() << "ObjectTreeView::paintEvent"
|
||||
<< "QStyleOptionViewItem.state=" << int(option.state);
|
||||
|
||||
|
||||
QTreeWidget::paintEvent(ev);
|
||||
}
|
||||
|
||||
bool ObjectTreeView::event( QEvent *event )
|
||||
{
|
||||
if (event->type() == QEvent::ToolTip)
|
||||
@ -280,6 +296,8 @@ FWObject* ObjectTreeView::getCurrentObject()
|
||||
|
||||
void ObjectTreeView::focusInEvent(QFocusEvent* ev)
|
||||
{
|
||||
qDebug() << "ObjectTreeView::focusInEvent";
|
||||
|
||||
QTreeWidget::focusInEvent(ev);
|
||||
QTreeWidgetItem *ci = currentItem();
|
||||
if (ci) repaint();
|
||||
@ -287,6 +305,8 @@ void ObjectTreeView::focusInEvent(QFocusEvent* ev)
|
||||
|
||||
void ObjectTreeView::focusOutEvent(QFocusEvent* ev)
|
||||
{
|
||||
qDebug() << "ObjectTreeView::focusOutEvent";
|
||||
|
||||
QTreeWidget::focusOutEvent(ev);
|
||||
|
||||
if (fwbdebug)
|
||||
|
||||
@ -6,8 +6,6 @@
|
||||
|
||||
Author: Vadim Kurland vadim@fwbuilder.org
|
||||
|
||||
$Id$
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
@ -48,7 +46,8 @@ namespace libfwbuilder {
|
||||
|
||||
class ProjectPanel;
|
||||
|
||||
class ObjectTreeView : public QTreeWidget {
|
||||
class ObjectTreeView : public QTreeWidget
|
||||
{
|
||||
|
||||
Q_OBJECT;
|
||||
|
||||
@ -103,6 +102,8 @@ protected:
|
||||
|
||||
void startDrag(Qt::DropActions supportedActions);
|
||||
|
||||
virtual void paintEvent(QPaintEvent *ev);
|
||||
|
||||
public:
|
||||
|
||||
ObjectTreeView(ProjectPanel* project,
|
||||
|
||||
@ -1035,12 +1035,6 @@ void ProjectPanel::showEvent(QShowEvent *ev)
|
||||
if (fwbdebug) qDebug() << "ProjectPanel::showEvent " << this
|
||||
<< "title " << mdiWindow->windowTitle();
|
||||
|
||||
connect(m_panel->treeDockWidget, SIGNAL(topLevelChanged(bool)),
|
||||
this, SLOT(topLevelChangedForTreePanel(bool)));
|
||||
connect(m_panel->treeDockWidget, SIGNAL(visibilityChanged(bool)),
|
||||
this, SLOT(visibilityChangedForTreePanel(bool)));
|
||||
|
||||
m_panel->treeDockWidget->raise();
|
||||
QWidget::showEvent(ev);
|
||||
|
||||
// we get this event when MDI window is maximized or restored
|
||||
@ -1068,11 +1062,6 @@ void ProjectPanel::closeEvent(QCloseEvent * ev)
|
||||
return;
|
||||
}
|
||||
|
||||
disconnect(m_panel->treeDockWidget, SIGNAL(topLevelChanged(bool)),
|
||||
this, SLOT(topLevelChangedForTreePanel(bool)));
|
||||
disconnect(m_panel->treeDockWidget, SIGNAL(visibilityChanged(bool)),
|
||||
this, SLOT(visibilityChangedForTreePanel(bool)));
|
||||
|
||||
saveState();
|
||||
fileClose();
|
||||
|
||||
@ -1270,134 +1259,8 @@ void ProjectPanel::updateLastModifiedTimestampForAllFirewalls()
|
||||
|
||||
void ProjectPanel::toggleViewTree(bool f)
|
||||
{
|
||||
if (f) m_panel->treeDockWidget->show();
|
||||
else m_panel->treeDockWidget->hide();
|
||||
}
|
||||
|
||||
|
||||
/* Make the objectTree dock zero width if the objectTree is floating,
|
||||
or if it's not visible. Then the rules editor will take up the
|
||||
full width */
|
||||
void ProjectPanel::adjustDockWidths(bool makeZeroWidth)
|
||||
{
|
||||
/* These can be static since they are the same for every window
|
||||
(they come from the .ui file) */
|
||||
static int dockMinSize = 0;
|
||||
static int dockMaxSize = 0;
|
||||
if (dockMinSize == 0 && dockMaxSize == 0) {
|
||||
dockMinSize = m_panel->treeDockWidgetParentFrame->minimumWidth();
|
||||
dockMaxSize = m_panel->treeDockWidgetParentFrame->maximumWidth();
|
||||
}
|
||||
|
||||
if (makeZeroWidth) {
|
||||
m_panel->treeDockWidgetParentFrame->setMinimumWidth(0);
|
||||
m_panel->treeDockWidgetParentFrame->setMaximumWidth(0);
|
||||
} else {
|
||||
m_panel->treeDockWidgetParentFrame->setMinimumWidth(dockMinSize);
|
||||
m_panel->treeDockWidgetParentFrame->setMaximumWidth(dockMaxSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Signal QDockWidget::topLevelChanged is called after dock widget
|
||||
* is made floating or docked.
|
||||
*/
|
||||
void ProjectPanel::topLevelChangedForTreePanel(bool f)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug() << "ProjectPanel::topLevelChangedForTreePanel f=" << f;
|
||||
|
||||
/*
|
||||
* QDockWidget object uses native decorators on Windows and Mac
|
||||
* and therefore gets window title bar there. On X11 QT emulates
|
||||
* title bar and allows dragging of the floating dock widget only
|
||||
* if its parent is QMainWindow. Here is a hack: we reparent the
|
||||
* widget in order to satisfy their requirements and make floating
|
||||
* panel widget draggable on all platforms. Need to reparent it
|
||||
* back and stick it into the layout of the ProjectPanel when it
|
||||
* is docked.
|
||||
*/
|
||||
|
||||
adjustDockWidths(f);
|
||||
|
||||
m_panel->treeDockWidget->blockSignals(true);
|
||||
|
||||
if (f) // window becomes detached
|
||||
{
|
||||
QString file_name = getFileName(); // full path
|
||||
QFileInfo fi(file_name);
|
||||
QString short_name = fi.fileName();
|
||||
m_panel->treeDockWidget->setParent(mw);
|
||||
m_panel->treeDockWidget->setWindowTitle(short_name);
|
||||
mw->addDockWidget(Qt::LeftDockWidgetArea, m_panel->treeDockWidget);
|
||||
m_panel->treeDockWidget->show();
|
||||
m_panel->treeDockWidget->blockSignals(false);
|
||||
} else
|
||||
{
|
||||
#if QT_VERSION < 0x040500
|
||||
// See bug #973 for details
|
||||
QTimer::singleShot(0, this, SLOT(setTreeDockPosition()));
|
||||
#else
|
||||
// Setting widget position here causes crash on Qt < 4.5.
|
||||
mw->removeDockWidget(m_panel->treeDockWidget);
|
||||
m_panel->treeDockWidget->setWindowTitle("");
|
||||
m_panel->treeDockWidget->setParent(m_panel->treeDockWidgetParentFrame);
|
||||
m_panel->treeDockWidgetParentFrame->layout()->addWidget(m_panel->treeDockWidget);
|
||||
m_panel->treeDockWidget->show();
|
||||
m_panel->treeDockWidget->blockSignals(false);
|
||||
#endif
|
||||
}
|
||||
m_panel->treeDockWidget->setFloating(f);
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug() << "ProjectPanel::topLevelChangedForTreePanel check 1";
|
||||
qDebug() << "m_panel->treeDockWidget->isWindow()="
|
||||
<< m_panel->treeDockWidget->isWindow();
|
||||
}
|
||||
|
||||
if ( ! m_panel->treeDockWidget->isWindow())
|
||||
{
|
||||
#if QT_VERSION >= 0x040500
|
||||
if (fwbdebug) qDebug() << "Calling loadMainSplitter()";
|
||||
loadMainSplitter();
|
||||
#endif
|
||||
} else
|
||||
{
|
||||
// expand rules
|
||||
collapseTree();
|
||||
m_panel->treeDockWidget->widget()->update();
|
||||
}
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug() << "ProjectPanel::topLevelChangedForTreePanel check 2";
|
||||
}
|
||||
|
||||
void ProjectPanel::visibilityChangedForTreePanel(bool f)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug() << "ProjectPanel::visibilityChangedForTreePanel f="
|
||||
<< f
|
||||
<< "isVisible()=" << m_panel->treeDockWidget->isVisible()
|
||||
<< "isWindow()=" << m_panel->treeDockWidget->isWindow()
|
||||
<< "mdiWindow->isMaximized()=" << mdiWindow->isMaximized();
|
||||
|
||||
adjustDockWidths(!m_panel->treeDockWidget->isVisible() ||
|
||||
m_panel->treeDockWidget->isFloating());
|
||||
|
||||
#if 0
|
||||
if (m_panel->treeDockWidget->isVisible() &&
|
||||
! m_panel->treeDockWidget->isWindow()) // visible and not floating
|
||||
{
|
||||
loadMainSplitter();
|
||||
} else
|
||||
{
|
||||
// expand rules
|
||||
collapseTree();
|
||||
m_panel->treeDockWidget->widget()->update();
|
||||
}
|
||||
#endif
|
||||
if (f) m_panel->treePanelFrame->show();
|
||||
else m_panel->treePanelFrame->hide();
|
||||
}
|
||||
|
||||
void ProjectPanel::setActive()
|
||||
@ -1405,18 +1268,6 @@ void ProjectPanel::setActive()
|
||||
undoStack->setActive(true);
|
||||
}
|
||||
|
||||
#if QT_VERSION < 0x040500
|
||||
void ProjectPanel::setTreeDockPosition()
|
||||
{
|
||||
mw->removeDockWidget(m_panel->treeDockWidget);
|
||||
m_panel->treeDockWidget->setParent(m_panel->treeDockWidgetParentFrame);
|
||||
m_panel->treeDockWidgetParentFrame->layout()->addWidget(m_panel->treeDockWidget);
|
||||
m_panel->treeDockWidget->blockSignals(false);
|
||||
m_panel->treeDockWidget->show();
|
||||
loadMainSplitter();
|
||||
}
|
||||
#endif
|
||||
|
||||
void ProjectPanel::splitterPositionChanged(int,int)
|
||||
{
|
||||
saveMainSplitter();
|
||||
|
||||
@ -234,14 +234,10 @@ public:
|
||||
void setActive();
|
||||
|
||||
private:
|
||||
void adjustDockWidths(bool makeZeroWidth);
|
||||
|
||||
public slots:
|
||||
void newObject();
|
||||
|
||||
void topLevelChangedForTreePanel(bool topLevel);
|
||||
void visibilityChangedForTreePanel(bool topLevel);
|
||||
|
||||
virtual void back();
|
||||
virtual void lockObject();
|
||||
virtual void unlockObject();
|
||||
@ -299,10 +295,6 @@ public:
|
||||
|
||||
void aboutToActivate();
|
||||
|
||||
#if QT_VERSION < 0x040500
|
||||
void setTreeDockPosition();
|
||||
#endif
|
||||
|
||||
void splitterPositionChanged(int, int);
|
||||
|
||||
public:
|
||||
|
||||
@ -145,6 +145,8 @@ void ProjectPanel::saveMainSplitter()
|
||||
{
|
||||
QString fileName ;
|
||||
if (rcs!=NULL) fileName = rcs->getFileName();
|
||||
|
||||
#ifdef TREE_IS_DOCKABLE
|
||||
// Save position of splitters regardless of the window state
|
||||
// Do not save if one of tree panel is floating
|
||||
if (!m_panel->treeDockWidget->isWindow())
|
||||
@ -161,6 +163,20 @@ void ProjectPanel::saveMainSplitter()
|
||||
qDebug() << out1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
QList<int> sl = m_panel->topSplitter->sizes();
|
||||
QString arg = QString("%1,%2").arg(sl[0]).arg(sl[1]);
|
||||
if (sl[0] || sl[1])
|
||||
st->setStr("Window/" + fileName + "/MainWindowSplitter", arg );
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
QString out1 = " save Window/" + fileName + "/MainWindowSplitter";
|
||||
out1+= " " + arg;
|
||||
qDebug() << out1;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void ProjectPanel::loadMainSplitter()
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
<property name="childrenCollapsible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QFrame" name="treeDockWidgetParentFrame">
|
||||
<widget class="QFrame" name="treePanelFrame">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
@ -40,25 +40,12 @@
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="treeDockWidgetParentFrameLayout">
|
||||
<property name="margin">
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QDockWidget" name="treeDockWidget">
|
||||
<property name="floating">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::LeftDockWidgetArea</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -86,10 +73,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QFrame" name="rulesDockWidgetParentFrame">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user