Changeset View
Changeset View
Standalone View
Standalone View
libs/kasten/gui/shell/viewareabox.cpp
Show All 19 Lines | 1 | /* | |||
---|---|---|---|---|---|
20 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | 20 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
21 | */ | 21 | */ | ||
22 | 22 | | |||
23 | #include "viewareabox.h" | 23 | #include "viewareabox.h" | ||
24 | 24 | | |||
25 | // Qt | 25 | // Qt | ||
26 | #include <QVBoxLayout> | 26 | #include <QVBoxLayout> | ||
27 | #include <QShortcut> | 27 | #include <QShortcut> | ||
28 | #include <QDragEnterEvent> | ||||
28 | 29 | | |||
29 | 30 | | |||
30 | namespace Kasten | 31 | namespace Kasten | ||
31 | { | 32 | { | ||
32 | 33 | | |||
33 | ViewAreaBox::ViewAreaBox( QWidget* centralWidget, QWidget* parent ) | 34 | ViewAreaBox::ViewAreaBox( QWidget* centralWidget, QWidget* parent ) | ||
34 | : QWidget( parent ), | 35 | : QWidget( parent ), | ||
35 | mCentralWidget( centralWidget ), | 36 | mCentralWidget( centralWidget ), | ||
36 | mBottomWidget( nullptr ) | 37 | mBottomWidget( nullptr ) | ||
37 | { | 38 | { | ||
38 | setFocusProxy( mCentralWidget ); | 39 | setFocusProxy( mCentralWidget ); | ||
39 | 40 | | |||
40 | QVBoxLayout* layout = new QVBoxLayout( this ); | 41 | QVBoxLayout* layout = new QVBoxLayout( this ); | ||
41 | layout->setMargin( 0 ); | 42 | layout->setMargin( 0 ); | ||
42 | layout->setSpacing( 0 ); | 43 | layout->setSpacing( 0 ); | ||
43 | if( mCentralWidget ) | 44 | if( mCentralWidget ) | ||
44 | layout->addWidget( mCentralWidget ); | 45 | layout->addWidget( mCentralWidget ); | ||
45 | 46 | | |||
46 | mEscapeShortcut = new QShortcut( Qt::Key_Escape, this ); | 47 | mEscapeShortcut = new QShortcut( Qt::Key_Escape, this ); | ||
47 | mEscapeShortcut->setEnabled( false ); | 48 | mEscapeShortcut->setEnabled( false ); | ||
49 | setAcceptDrops(true); | ||||
48 | connect( mEscapeShortcut, &QShortcut::activated, this, &ViewAreaBox::onDone ); // TODO: better use onCancelled | 50 | connect( mEscapeShortcut, &QShortcut::activated, this, &ViewAreaBox::onDone ); // TODO: better use onCancelled | ||
49 | } | 51 | } | ||
50 | 52 | | |||
51 | 53 | | |||
52 | QWidget* ViewAreaBox::centralWidget() const { return mCentralWidget; } | 54 | QWidget* ViewAreaBox::centralWidget() const { return mCentralWidget; } | ||
53 | QWidget* ViewAreaBox::bottomWidget() const { return mBottomWidget; } | 55 | QWidget* ViewAreaBox::bottomWidget() const { return mBottomWidget; } | ||
54 | 56 | | |||
55 | void ViewAreaBox::setCentralWidget( QWidget* centralWidget ) | 57 | void ViewAreaBox::setCentralWidget( QWidget* centralWidget ) | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 85 | { | |||
105 | mEscapeShortcut->setEnabled( (bottomWidget != nullptr) ); | 107 | mEscapeShortcut->setEnabled( (bottomWidget != nullptr) ); | ||
106 | } | 108 | } | ||
107 | 109 | | |||
108 | void ViewAreaBox::onDone() | 110 | void ViewAreaBox::onDone() | ||
109 | { | 111 | { | ||
110 | setBottomWidget( nullptr ); | 112 | setBottomWidget( nullptr ); | ||
111 | } | 113 | } | ||
112 | 114 | | |||
115 | void ViewAreaBox::dragEnterEvent(QDragEnterEvent *event) | ||||
116 | { | ||||
117 | event->acceptProposedAction(); | ||||
118 | } | ||||
119 | | ||||
120 | void ViewAreaBox::dropEvent(QDropEvent *event) | ||||
121 | { | ||||
kossebau: Should be like this for consistency:
```
emit receivedDropEvent(event);
```
| |||||
122 | emit receivedDropEvent(event); | ||||
123 | } | ||||
124 | | ||||
113 | ViewAreaBox::~ViewAreaBox() | 125 | ViewAreaBox::~ViewAreaBox() | ||
114 | { | 126 | { | ||
115 | delete mBottomWidget; | 127 | delete mBottomWidget; | ||
116 | if( mCentralWidget ) | 128 | if( mCentralWidget ) | ||
117 | mCentralWidget->setParent( nullptr ); | 129 | mCentralWidget->setParent( nullptr ); | ||
118 | } | 130 | } | ||
119 | 131 | | |||
120 | } | 132 | } |
Should be like this for consistency: