|
From: <dhu...@us...> - 2007-01-24 13:47:28
|
Revision: 244
http://svn.sourceforge.net/qcell/?rev=244&view=rev
Author: dhubleizh
Date: 2007-01-24 05:47:27 -0800 (Wed, 24 Jan 2007)
Log Message:
-----------
- BetterDockWidget implemented on top of QDockWidget to make floating widget adjust their size to minimum required
Modified Paths:
--------------
trunk/qcell/visgui/MainWindow.cpp
trunk/qcell/visgui/MainWindow.h
trunk/qcell/visgui/visgui.pro
Added Paths:
-----------
trunk/qcell/visgui/BetterDockWidget.cpp
trunk/qcell/visgui/BetterDockWidget.h
Added: trunk/qcell/visgui/BetterDockWidget.cpp
===================================================================
--- trunk/qcell/visgui/BetterDockWidget.cpp (rev 0)
+++ trunk/qcell/visgui/BetterDockWidget.cpp 2007-01-24 13:47:27 UTC (rev 244)
@@ -0,0 +1,34 @@
+/**@file BetterDockWidget.cpp
+ * @author czarny
+ * @date
+ * Created: \xB6ro 24 sty 2007 14:15:49 CET \n
+ * Last Update: \xB6ro 24 sty 2007 14:15:49 CET
+ */
+
+#include "BetterDockWidget.h"
+
+BetterDockWidget::BetterDockWidget ( const QString & title, QWidget * parent/*0*/, Qt::WindowFlags flags/*0 */)
+ : QDockWidget(title, parent, flags)
+{
+ connect(this, SIGNAL(topLevelChanged(bool)),
+ this, SLOT(shrinkOnFloat())
+ );
+}
+
+BetterDockWidget::BetterDockWidget ( QWidget * parent/*0*/, Qt::WindowFlags flags/*0 */)
+ : QDockWidget(parent, flags)
+{
+ connect(this, SIGNAL(topLevelChanged(bool)),
+ this, SLOT(shrinkOnFloat())
+ );
+}
+
+BetterDockWidget::~BetterDockWidget()
+{
+}
+
+void BetterDockWidget::shrinkOnFloat()
+{
+ adjustSize();
+}
+
Added: trunk/qcell/visgui/BetterDockWidget.h
===================================================================
--- trunk/qcell/visgui/BetterDockWidget.h (rev 0)
+++ trunk/qcell/visgui/BetterDockWidget.h 2007-01-24 13:47:27 UTC (rev 244)
@@ -0,0 +1,27 @@
+/**@file BetterDockWidget.h
+ * @author czarny
+ * @date
+ * Created: \xB6ro 24 sty 2007 14:13:00 CET \n
+ * Last Update: \xB6ro 24 sty 2007 14:13:00 CET
+ * @brief Make QDockWidgets shrink as they become floating
+ */
+
+#ifndef __BETTERDOCKWIDGET_H__
+#define __BETTERDOCKWIDGET_H__
+
+#include <QDockWidget>
+#include <QObject>
+
+class BetterDockWidget: public QDockWidget
+{
+ Q_OBJECT
+protected slots:
+ void shrinkOnFloat();
+public:
+ BetterDockWidget (const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0);
+ BetterDockWidget (QWidget * parent = 0, Qt::WindowFlags flags = 0);
+
+ ~BetterDockWidget();
+};
+
+#endif // __BETTERDOCKWIDGET_H__
Modified: trunk/qcell/visgui/MainWindow.cpp
===================================================================
--- trunk/qcell/visgui/MainWindow.cpp 2007-01-24 12:49:43 UTC (rev 243)
+++ trunk/qcell/visgui/MainWindow.cpp 2007-01-24 13:47:27 UTC (rev 244)
@@ -48,20 +48,26 @@
// basetools, SLOT(setItem(int, int, QTableWidgetItem*))
// );
+// QSizePolicy sp(QSizePolicy::Minimum, QSizePolicy::Minimum);
// View 3D Tools
- dock3D = new QDockWidget(this);
+ dock3D = new BetterDockWidget(this);
dock3D->hide();
dock3D->setDisabled(true);
+// dock3D->setSizePolicy(sp);
View3DTools* view3DTools = new View3DTools(this);
dock3D->setWindowTitle(tr("3D Tools"));
dock3D->setWidget(view3DTools);
((QVBoxLayout*)dock3D->layout())->addStretch();
+ dock3D->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::RightDockWidgetArea, dock3D);
QAction* v3d_action = dock3D->toggleViewAction();
v3d_action->setText(tr("&3D Tools"));
menu_View->addAction(v3d_action);
+// connect(dock3D, SIGNAL(topLevelChanged(bool)),
+// this, SLOT(test())
+// );
connect(view3DTools, SIGNAL(ViewModeUpdated(int)),
sw, SLOT(perspectiveUpdate(int)));
connect(view3DTools, SIGNAL(maskSet(int, int, int)),
@@ -74,13 +80,14 @@
);
// View 2D Tools
- dock2D = new QDockWidget(this);
+ dock2D = new BetterDockWidget(this);
dock2D->hide();
dock2D->setDisabled(true);
View2DTextTools* view2DTextTools = new View2DTextTools(this);
dock2D->setWindowTitle(tr("2D Text Tools"));
dock2D->setWidget(view2DTextTools);
((QVBoxLayout*)dock2D->layout())->addStretch();
+ dock2D->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::RightDockWidgetArea, dock2D);
QAction* v2d_action = dock2D->toggleViewAction();
@@ -105,13 +112,14 @@
);
// View 1D Tools
- dock1D = new QDockWidget(this);
+ dock1D = new BetterDockWidget(this);
dock1D->hide();
dock1D->setDisabled(true);
View1DTextTools* view1DTextTools = new View1DTextTools(this);
dock1D->setWindowTitle(tr("1D Text Tools"));
dock1D->setWidget(view1DTextTools);
((QVBoxLayout*)dock1D->layout())->addStretch();
+ dock1D->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::RightDockWidgetArea, dock1D);
QAction* v1d_action = dock1D->toggleViewAction();
@@ -170,12 +178,13 @@
QStringList parser_types, file_types;
// Elemental dock widget
- elemental_dock = new QDockWidget(this);
+ elemental_dock = new BetterDockWidget(this);
// We don't want it appear at the beginning
elemental_dock->hide();
elemental_dock->setWidget(new ElementalRulesWidget());
elemental_dock->setWindowTitle(tr("Elemental rules"));
+ elemental_dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::LeftDockWidgetArea, elemental_dock);
// We want to be able to show or hide the widget from View menu
QAction* elemental_action = elemental_dock->toggleViewAction();
@@ -1133,3 +1142,8 @@
}
}
+void MainWindow::test()
+{
+ dock3D->adjustSize();
+}
+
Modified: trunk/qcell/visgui/MainWindow.h
===================================================================
--- trunk/qcell/visgui/MainWindow.h 2007-01-24 12:49:43 UTC (rev 243)
+++ trunk/qcell/visgui/MainWindow.h 2007-01-24 13:47:27 UTC (rev 244)
@@ -16,6 +16,7 @@
#include "ElementalRules.h"
#include "NewWorldWizard.h"
#include "NewNeighbourhoodWizard.h"
+#include "BetterDockWidget.h"
#include <view3dtools.h>
#include <view2dtexttools.h>
#include <view1dtexttools.h>
@@ -45,6 +46,8 @@
Q_OBJECT
signals:
void unlockGUI();
+public slots:
+ void test();
public:
MainWindow(QWidget* parent = 0);
@@ -106,9 +109,9 @@
Calculator calc;
ElementalRules* elemental_rules;
QDockWidget* elemental_dock;
- QDockWidget* dock3D;
- QDockWidget* dock2D;
- QDockWidget* dock1D;
+ BetterDockWidget* dock3D;
+ BetterDockWidget* dock2D;
+ BetterDockWidget* dock1D;
QList<CalculationData*> data;
LocalFunction* local_function;
Neighbourhood* neighbourhood;
Modified: trunk/qcell/visgui/visgui.pro
===================================================================
--- trunk/qcell/visgui/visgui.pro 2007-01-24 12:49:43 UTC (rev 243)
+++ trunk/qcell/visgui/visgui.pro 2007-01-24 13:47:27 UTC (rev 244)
@@ -25,6 +25,7 @@
RuleProperties.h \
NewWorldWizard.h \
NewNeighbourhoodWizard.h \
+ BetterDockWidget.h \
../baseheaders/Client.h \
../baseheaders/ClientInfo.h \
../baseheaders/BaseDataTypes.h \
@@ -51,6 +52,7 @@
RuleProperties.cpp \
NewWorldWizard.cpp \
NewNeighbourhoodWizard.cpp \
+ BetterDockWidget.cpp \
../basesources/Client.cpp \
../basesources/ClientInfo.cpp \
../basesources/Neighbourhood.cpp \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|