Commit afaf6a51 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

BUG #15506: Add border around active view.

Changed pqViewFrame to use a QFrame around the "central widget". We
set the border color for this frame to be either blue or same as
background. By using contents margin, we get the same effect as a 1
pixel white border inside the blue border.
parent a3edfa3c
......@@ -575,6 +575,7 @@ set (Module_UI_FILES
Resources/UI/pqSplineWidget.ui
Resources/UI/pqSpreadSheetViewDecorator.ui
Resources/UI/pqTimerLogDisplay.ui
Resources/UI/pqViewFrame.ui
Resources/UI/pqWriterDialog.ui
)
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>pqViewFrame</class>
<widget class="QWidget" name="pqViewFrame">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="TitleBar" native="true">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="TitleBarLayout">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="TitleLabel">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="CentralWidgetFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<layout class="QVBoxLayout" name="CentralWidgetFrameLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -147,7 +147,6 @@ namespace
{
QWidget* viewWidget = pqview->widget();
frame->setCentralWidget(viewWidget);
viewWidget->setParent(frame);
}
}
......
This diff is collapsed.
......@@ -37,10 +37,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QPointer>
#include <QMap>
#include <QUuid>
#include <QScopedPointer>
class QDragEnterEvent;
class QDragMoveEvent;
class QDropEvent;
class QFrame;
class QLabel;
class QMenu;
class QToolBar;
......@@ -63,13 +65,16 @@ public:
void setTitle(const QString& text);
QString title() const;
/// Get/Set the central widget shown in this frame.
/// Get/Set the central widget shown in this frame. Similar to
/// QLayout::addWidget, this call takes the ownership of the widget and the
/// widget will be deleted with pqViewFrame is deleted or another widget is set
/// using setCentralWidget().
void setCentralWidget(QWidget* widget);
QWidget* centralWidget() const;
/// Get/Set the border BorderColor. The border is only drawn when the
/// borderVisibility is set to true.
void setBorderColor(const QColor& clr) { this->BorderColor = clr; }
void setBorderColor(const QColor& clr);
const QColor& borderColor() const { return this->BorderColor; }
/// Get/Set the border visibility.
......@@ -81,8 +86,8 @@ public:
enum StandardButton
{
NoButton =0x0000,
SplitVertical =0x0001,
SplitHorizontal =0x0002,
SplitHorizontal =0x0001,
SplitVertical =0x0002,
Maximize =0x0004,
Restore =0x0008,
Close =0x0010
......@@ -104,8 +109,7 @@ public:
void removeTitleBarActions();
/// Provides access to the context menu.
QMenu* contextMenu() const
{ return this->ContextMenu; }
QMenu* contextMenu() const;
/// provides access to the unique id assigned to the frame.
QUuid uniqueID() const
......@@ -120,36 +124,35 @@ signals:
/// Fired to indicate the positions for the two frames need to be swapped.
void swapPositions(const QString& other);
public slots:
/// set whether the border is visible.
void setBorderVisibility(bool val)
void setBorderVisibility(bool val)
{
this->BorderVisible = val;
this->updateLayout();
this->updateComponentVisibilities();
}
/// set whether the title-bar is visible.
void setTitleBarVisibility(bool val)
{
this->TitleBarVisible = val;
this->updateLayout();
this->updateComponentVisibilities();
}
void setDecorationsVisibility(bool val)
{
this->DecorationsVisible = val;
this->updateLayout();
this->updateComponentVisibilities();
}
/// event filter to handle drag/drop events.
virtual bool eventFilter(QObject*, QEvent*);
protected:
/// updates the layout.
void updateLayout();
void updateTitleBar();
void paintEvent(QPaintEvent* event);
/// Updates the visibilities for various components of the pqViewFrame based
/// on flags set on the instance.
virtual void updateComponentVisibilities();
/// methods to manage drag-drop.
void drag();
......@@ -167,20 +170,25 @@ protected:
bool BorderVisible;
QColor BorderColor;
StandardButtons Buttons;
QPointer<QWidget> CentralWidget;
QPointer<QWidget> TitleBar;
QPointer<QToolBar> ToolBar;
QPointer<QLabel> TitleLabel;
QMenu* ContextMenu;
QPointer<QWidget> CentralWidget;
QPointer<QMenu> ContextMenu;
QUuid UniqueID;
QPoint DragStartPosition;
QMap<StandardButton, QPointer<QToolButton> > StandardToolButtons;
typedef QMap<StandardButton, QPointer<QToolButton> > StandardToolButtonsMap;
StandardToolButtonsMap StandardToolButtons;
QPalette PaletteWithBorder;
QPalette PaletteWithoutBorder;
QString PlainTitle;
private:
Q_DISABLE_COPY(pqViewFrame)
/// creates a tool button for the action.
QToolButton* createButton(QAction* action);
class pqInternals;
const QScopedPointer<pqInternals> Internals;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(pqViewFrame::StandardButtons);
......
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