4 * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
7 * GiWoong Kim <giwoong.kim@samsung.com>
8 * Sangho Park <sangho1206.park@samsung.com>
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
30 #include "dockingconview.h"
31 #include "mainwindow.h"
32 #include "skinkeyitem.h"
33 #include "controller/generalpurposecon.h"
34 #include "resource/ui_strings.h"
36 DockingConView::DockingConView(QWidget *parent,
37 ControllerForm *conForm, QGraphicsScene *scene) : SkinView(parent, scene)
39 this->parent = (DockingController *)parent;
40 this->conViewStat = CONVIEW_NORMAL;
42 setFocusPolicy(Qt::NoFocus);
43 setStyleSheet("DockingConView { background: transparent; border-style: none; }" +
44 QString(STYLE_TOOLTIP));
46 rubberPos = SKINVIEW_NULLITY_POSITION;
47 rubberBand = new QRubberBand(QRubberBand::Rectangle, NULL);
52 void DockingConView::createItems(ControllerForm *conForm)
55 bezelItem = createBezelItem(NULL, conForm);
56 scene()->addItem(bezelItem);
58 if (conForm->isGeneralPurpose() == false) {
60 QList<HardwareKey *> &keyList = conForm->getKeyList();
61 HardwareKey *hwKey = NULL;
62 for (int i = 0; i < keyList.count(); i++) {
63 hwKey = keyList.at(i);
65 createKeyItem(bezelItem, conForm, hwKey);
69 GeneralPurposeCon *generalCon = new GeneralPurposeCon();
70 QList<HWKeyButton *> buttons
71 = generalCon->createButtons(parentWidget(), conForm);
73 for (int i = 0; i < buttons.count(); i++) {
74 HWKeyButton *button = buttons.at(i);
75 if (button->getSlot() == NULL) {
78 connect(button, SIGNAL(clicked()),
79 parent->getMainWindow()->getPopupMenu(), button->getSlot());
84 void DockingConView::grabWindow(QMouseEvent *event)
86 SkinView::grabWindow(event->globalPos());
88 eventPos = event->pos();
92 void DockingConView::releaseWindow()
94 SkinView::releaseWindow();
96 eventPos = SKINVIEW_NULLITY_POSITION;
97 setConViewStatus(CONVIEW_NORMAL);
101 QRegion DockingConView::getKeyWinRegion(
102 QWidget *base, QRect &keyRect, LayoutForm::SkinImgType type)
104 return ((MainWindow *)parent->parentWidget())->
105 getUiInfo()->getConKeyRegion(base, keyRect, type);
109 void DockingConView::resizeEvent(QResizeEvent *event)
113 SkinView::resizeEvent(event);
117 void DockingConView::mousePressEvent(QMouseEvent *event)
119 SkinView::mousePressEvent(event);
121 if (bezelItem->isHWKeyHandling() == true) {
126 if (event->button() == Qt::LeftButton) {
129 QWidget *win = parent->parentWidget();
130 rubberPos.setX(win->pos().x() + parent->pos().x());
131 rubberPos.setY(win->pos().y() + parent->pos().y());
133 if (rubberBand != NULL) {
134 rubberBand->setGeometry(QRect(rubberPos, size()));
141 void DockingConView::mouseDoubleClickEvent(QMouseEvent *event)
143 SkinView::mouseDoubleClickEvent(event);
149 void DockingConView::mouseReleaseEvent(QMouseEvent *event)
151 SkinView::mouseReleaseEvent(event);
153 if (bezelItem->isHWKeyHandling() == true) {
158 if (event->button() == Qt::LeftButton) {
159 if (isGrabWindow() == true) {
160 if (rubberBand != NULL) {
164 if (getConViewStatus() == CONVIEW_DRAG_OUT) {
166 MainWindow *win = ((MainWindow *)parent->parent());
167 win->getUiState()->getConState()->setRecentlyFloatPos(
168 event->globalPos() - eventPos);
170 win->getUiState()->getConState()->getConFormIndex(), -1);
179 void DockingConView::mouseMoveEvent(QMouseEvent *event)
181 SkinView::mouseMoveEvent(event);
183 if (bezelItem->isHWKeyHandling() == true) {
188 if (isGrabWindow() == true) {
189 if (rubberBand != NULL) {
190 rubberBand->setGeometry(
191 QRect(rubberPos + (event->globalPos() - grabPos), size()));
193 setConViewStatus(CONVIEW_DRAG_OUT);
197 void DockingConView::setConViewStatus(conViewStatus status)
199 conViewStat = status;
202 int DockingConView::getConViewStatus()
207 DockingConView::~DockingConView()
209 qDebug("destroy docking controller view");
211 if (rubberBand != NULL) {