Ref T592, navigator dialog

* movable by mouse
* UI border
This commit is contained in:
Klaus Basan
2019-04-05 03:14:56 +02:00
committed by Mat Sutcliffe
parent d33b913e62
commit eb5670abef
3 changed files with 48 additions and 33 deletions

View File

@@ -183,12 +183,42 @@ namespace BlackGui
void CNavigatorDialog::mouseMoveEvent(QMouseEvent *event)
{
if (!handleMouseMoveEvent(event)) { QDialog::mouseMoveEvent(event); } ;
if (handleMouseMoveEvent(event)) { return; }
// frameless has moving already, but here we also do it dor dialog
if (!this->isFrameless())
{
if (event->buttons() & Qt::LeftButton)
{
this->move(event->globalPos() - m_framelessDragPosition);
event->accept();
return;
}
}
QDialog::mouseMoveEvent(event);
}
void CNavigatorDialog::mousePressEvent(QMouseEvent *event)
{
if (!handleMousePressEvent(event)) { QDialog::mousePressEvent(event); }
if (handleMousePressEvent(event)) { return; }
// frameless has moving already, but here we also do it dor dialog
if (!this->isFrameless())
{
if (event->buttons() & Qt::LeftButton)
{
m_framelessDragPosition = this->mapToParent(event->pos());
event->accept();
return;
}
}
QDialog::mousePressEvent(event);
}
void CNavigatorDialog::mouseReleaseEvent(QMouseEvent *event)
{
m_framelessDragPosition = QPoint();
QDialog::mouseReleaseEvent(event);
}
void CNavigatorDialog::changeEvent(QEvent *evt)
@@ -264,8 +294,8 @@ namespace BlackGui
void CNavigatorDialog::insertOwnActions()
{
// add some space for frameless navigators where I can move the navigator
QAction *a = new QAction(CIcons::empty16(), "move navigator here", this);
if (this->actions().isEmpty())
QAction *a = nullptr; // new QAction(CIcons::empty16(), "move navigator here", this);
if (a && this->actions().isEmpty())
{
this->addAction(a);
}
@@ -274,7 +304,7 @@ namespace BlackGui
this->insertAction(this->actions().first(), a);
}
bool c;
bool c = false;
if (sGui)
{
a = new QAction(CIcons::swiftLauncher16(), "Start launcher", this);
@@ -319,7 +349,7 @@ namespace BlackGui
int h = 16 * gridLayout->rowCount();
// margins
QMargins margins = gridLayout->contentsMargins() + this->contentsMargins();
const QMargins margins = gridLayout->contentsMargins() + this->contentsMargins();
h = h + margins.top() + margins.bottom();
w = w + margins.left() + margins.right();
@@ -352,7 +382,7 @@ namespace BlackGui
contextMenu->addAction("Adjust margins", this, &CNavigatorDialog::dummyFunction);
contextMenu->addAction(m_marginMenuAction);
contextMenu->addSeparator();
contextMenu->addAction(CIcons::load16(), "Restore state", this, &CNavigatorDialog::restoreFromSettings);
contextMenu->addAction(CIcons::load16(), "Restore from settings", this, &CNavigatorDialog::restoreFromSettings);
contextMenu->addAction(CIcons::save16(), "Save state", this, &CNavigatorDialog::saveToSettings);
}
} // ns

View File

@@ -22,11 +22,11 @@
#include <QTimer>
#include <QGridLayout>
#include <QTimer>
#include <QPoint>
class QEvent;
class QMenu;
class QMouseEvent;
class QPoint;
class QWidget;
namespace Ui { class CNavigatorDialog; }
@@ -82,6 +82,7 @@ namespace BlackGui
//! @{
virtual void mouseMoveEvent(QMouseEvent *event) override;
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseReleaseEvent(QMouseEvent *event) override;
virtual void changeEvent(QEvent *evt) override;
virtual void windowFlagsChanged() override;
virtual void paintEvent(QPaintEvent *event) override;

View File

@@ -6,16 +6,10 @@
<rect>
<x>0</x>
<y>0</y>
<width>48</width>
<height>381</height>
<width>20</width>
<height>278</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>16</width>
@@ -23,33 +17,23 @@
</size>
</property>
<property name="windowTitle">
<string>Navigator</string>
<string>swift Navigator</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gl_NavigatorDialog">
<property name="leftMargin">
<number>0</number>
<number>1</number>
</property>
<property name="topMargin">
<number>0</number>
<number>1</number>
</property>
<property name="rightMargin">
<number>0</number>
<number>1</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="fr_NavigatorDialogInner">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<widget class="QFrame" name="fr_NavigatorDialogInner"/>
</item>
</layout>
</widget>