Pencil2D Animation
Download
Community
News
Docs
Contribute
app/src/basedockwidget.cpp Source File
Main Page
Related Pages
Classes
Files
File List
Loading...
Searching...
No Matches
app
src
basedockwidget.cpp
1
/*
2
3
Pencil2D - Traditional Animation Software
4
Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5
Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7
This program is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License
9
as published by the Free Software Foundation; version 2 of the License.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
*/
17
18
#include <QLayout>
19
#include <QResizeEvent>
20
21
#include "basedockwidget.h"
22
#include "platformhandler.h"
23
24
BaseDockWidget::BaseDockWidget(
QWidget
* pParent)
25
:
QDockWidget
(pParent,
Qt
::
Tool
)
26
{
27
28
#ifdef __APPLE__
29
if
(PlatformHandler::isDarkMode())
30
{
31
setStyleSheet(
"QDockWidget::title { background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #4e4f4d, stop: 1 #424241); "
32
"background-repeat: repeat-x; text-align: center;"
33
"border-style: solid; border-bottom-color: #000000;"
34
"border-width: 1px; }"
);
35
}
36
#endif
37
38
}
39
40
BaseDockWidget::~BaseDockWidget()
41
{
42
}
43
44
void
BaseDockWidget::resizeEvent(
QResizeEvent
*event)
45
{
46
QDockWidget::resizeEvent
(
event
);
47
48
// Not sure where the -2 comes from, but the event width is always 2 more than what is passed to FlowLayout::setGeometry
49
int
minHeight = getMinHeightForWidth(
event
->size().width() - 2);
50
51
if
(minHeight < 0)
return
;
52
53
#ifdef __APPLE__
54
// For some reason the behavior of minimumSize and the margin changes on mac when floating, so we need to do this
55
#else
56
int
top, bottom;
57
layout
()->
getContentsMargins
(
nullptr
, &top,
nullptr
, &bottom);
58
minHeight += top + bottom;
59
#endif
60
setMinimumSize
(
QSize
(
layout
()->
minimumSize
().
width
(), minHeight));
61
}
62
63
int
BaseDockWidget::getMinHeightForWidth(
int
width)
64
{
65
Q_UNUSED(
width
)
66
return
-1;
67
}
QDockWidget
QDockWidget::event
virtual bool event(QEvent *event) override
QLayout::getContentsMargins
void getContentsMargins(int *left, int *top, int *right, int *bottom) const const
QResizeEvent
QSize
Qt
Qt::Tool
Tool
QWidget
QWidget::layout
QLayout * layout() const const
QWidget::setMinimumSize
void setMinimumSize(const QSize &)
QWidget::resizeEvent
virtual void resizeEvent(QResizeEvent *event)
QWidget::width
width