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(parent->getMainWindow());
71 generalCon->createHeaderBarAndBorder(scene(), false);
72 QList<HWKeyButton *> buttons
73 = generalCon->createButtons(scene(), parentWidget(), conForm);
77 void DockingConView::grabWindow(QMouseEvent *event)
79 SkinView::grabWindow(event->globalPos());
81 eventPos = event->pos();
85 void DockingConView::releaseWindow()
87 SkinView::releaseWindow();
89 eventPos = SKINVIEW_NULLITY_POSITION;
90 setConViewStatus(CONVIEW_NORMAL);
94 QRegion DockingConView::getKeyWinRegion(
95 QWidget *base, QRect &keyRect, LayoutForm::SkinImgType type)
97 return ((MainWindow *)parent->parentWidget())->
98 getUiInfo()->getConKeyRegion(base, keyRect, type);
102 void DockingConView::resizeEvent(QResizeEvent *event)
106 SkinView::resizeEvent(event);
110 void DockingConView::mousePressEvent(QMouseEvent *event)
112 SkinView::mousePressEvent(event);
114 if (bezelItem->isHWKeyHandling() == true) {
119 if (event->button() == Qt::LeftButton) {
122 QWidget *win = parent->parentWidget();
123 rubberPos.setX(win->pos().x() + parent->pos().x());
124 rubberPos.setY(win->pos().y() + parent->pos().y());
126 if (rubberBand != NULL) {
127 rubberBand->setGeometry(QRect(rubberPos, size()));
134 void DockingConView::mouseDoubleClickEvent(QMouseEvent *event)
136 SkinView::mouseDoubleClickEvent(event);
142 void DockingConView::mouseReleaseEvent(QMouseEvent *event)
144 SkinView::mouseReleaseEvent(event);
146 if (bezelItem->isHWKeyHandling() == true) {
151 if (event->button() == Qt::LeftButton) {
152 if (isGrabWindow() == true) {
153 if (rubberBand != NULL) {
157 if (getConViewStatus() == CONVIEW_DRAG_OUT) {
159 MainWindow *win = ((MainWindow *)parent->parent());
160 win->getUiState()->getConState()->setRecentlyFloatPos(
161 event->globalPos() - eventPos);
163 win->getUiState()->getConState()->getConFormIndex(), -1);
172 void DockingConView::mouseMoveEvent(QMouseEvent *event)
174 SkinView::mouseMoveEvent(event);
176 if (bezelItem->isHWKeyHandling() == true) {
181 if (isGrabWindow() == true) {
182 if (rubberBand != NULL) {
183 rubberBand->setGeometry(
184 QRect(rubberPos + (event->globalPos() - grabPos), size()));
186 setConViewStatus(CONVIEW_DRAG_OUT);
190 void DockingConView::setConViewStatus(conViewStatus status)
192 conViewStat = status;
195 int DockingConView::getConViewStatus()
200 DockingConView::~DockingConView()
202 qDebug("destroy docking controller view");
204 if (rubberBand != NULL) {