From: GiWoong Kim Date: Mon, 29 Sep 2014 06:57:06 +0000 (+0900) Subject: controller: view split into two types for docking and floating X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a532e9d0a16b0633680440b96e9fcec08a5b9800;p=sdk%2Femulator%2Fqemu.git controller: view split into two types for docking and floating Change-Id: I080546ebe80f0d3eb365656ef0bbc232ed351957 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ui/Makefile.objs b/tizen/src/ui/Makefile.objs index 2e0f143b01..fbde158636 100644 --- a/tizen/src/ui/Makefile.objs +++ b/tizen/src/ui/Makefile.objs @@ -7,14 +7,15 @@ $(obj)/qrc_resource.cpp: $(TIZEN_UI)/resource/resource.qrc obj-$(CONFIG_QT) += controllerform.o obj-$(CONFIG_QT) += dockingcontroller.o moc_dockingcontroller.o +obj-$(CONFIG_QT) += dockingconview.o obj-$(CONFIG_QT) += floatingcontroller.o moc_floatingcontroller.o +obj-$(CONFIG_QT) += floatingconview.o obj-$(CONFIG_QT) += displaybase.o obj-$(CONFIG_QT) += displayglwidget.o moc_displayglwidget.o obj-$(CONFIG_QT) += displayswwidget.o moc_displayswwidget.o obj-$(CONFIG_QT) += hardwarekey.o obj-$(CONFIG_QT) += mainwindow.o moc_mainwindow.o obj-$(CONFIG_QT) += skinbezelitem.o -obj-$(CONFIG_QT) += skincontrollerview.o obj-$(CONFIG_QT) += skinkeyitem.o moc_skinkeyitem.o obj-$(CONFIG_QT) += mainform.o obj-$(CONFIG_QT) += keyboardhelper.o diff --git a/tizen/src/ui/dockingcontroller.cpp b/tizen/src/ui/dockingcontroller.cpp index f1123779f4..d5d7d6fd5c 100644 --- a/tizen/src/ui/dockingcontroller.cpp +++ b/tizen/src/ui/dockingcontroller.cpp @@ -33,7 +33,7 @@ #include "mainwindow.h" DockingController::DockingController(ControllerForm *conForm, QGraphicsScene *conScene, - QAction *menu, QWidget *parent) : SkinControllerView(conForm, conScene, parent) + QAction *menu, QWidget *parent) : DockingConView(conForm, conScene, parent) { this->conForm = conForm; this->menu = menu; @@ -45,7 +45,6 @@ DockingController::DockingController(ControllerForm *conForm, QGraphicsScene *co void DockingController::showEvent(QShowEvent *event) { menu->setChecked(true); - //setRegion(conForm->conImg[ControllerForm::normal]); } void DockingController::closeEvent(QCloseEvent *event) { diff --git a/tizen/src/ui/dockingcontroller.h b/tizen/src/ui/dockingcontroller.h index 765c8a1457..95ce795a6a 100644 --- a/tizen/src/ui/dockingcontroller.h +++ b/tizen/src/ui/dockingcontroller.h @@ -33,9 +33,9 @@ #include #include "controllerform.h" -#include "skincontrollerview.h" +#include "dockingconview.h" -class DockingController : public SkinControllerView +class DockingController : public DockingConView { Q_OBJECT diff --git a/tizen/src/ui/dockingconview.cpp b/tizen/src/ui/dockingconview.cpp new file mode 100644 index 0000000000..128622ea08 --- /dev/null +++ b/tizen/src/ui/dockingconview.cpp @@ -0,0 +1,134 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "dockingconview.h" +#include "mainwindow.h" +#include "skinkeyitem.h" + +DockingConView::DockingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent) : + QGraphicsView(scene, parent) +{ + setStyleSheet("background: transparent"); + //setAttribute(Qt::WA_TranslucentBackground); + setStyleSheet("border-style: none"); + + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setAlignment(Qt::AlignLeft | Qt::AlignTop); + + rubberPos = QPoint(-1, -1); + grabPos = QPoint(-1, -1); + rubberBand = new QRubberBand(QRubberBand::Rectangle, NULL); + + createItems(conForm); +} + +void DockingConView::createItems(ControllerForm *conForm) +{ + /* bezel */ + SkinBezelItem *bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]); + scene()->addItem(bezelItem); + + /* HW keys */ + QList keyList = conForm->keyList; + + HardwareKey *hwKey = NULL; + for (int i = 0; i < keyList.count(); i++) { + hwKey = keyList.at(i); + if (hwKey != NULL) { + new SkinKeyItem(conForm->conImg[ControllerForm::pressed].copy(hwKey->region), + hwKey, bezelItem); + } + } +} + +void DockingConView::resizeEvent(QResizeEvent *event) +{ + //qDebug("resize con view"); + + Q_UNUSED(event) +} + +void DockingConView::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + QWidget *win = ((QWidget *) this->parent()); + + grabPos = event->globalPos(); + eventPos = event->pos(); + rubberPos = win->pos() + this->pos(); + + if (rubberBand != NULL) { + rubberBand->setGeometry(QRect(rubberPos, size())); + rubberBand->show(); + } + } + + QGraphicsView::mousePressEvent(event); +} + +void DockingConView::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + if (grabPos != QPoint(-1, -1)) { + if (rubberBand != NULL) { + rubberBand->hide(); + } + + MainWindow *win = ((MainWindow *)this->parent()); + win->getUIState()->conState.recentlyFloatPos = event->globalPos() - eventPos; + win->openController(win->getUIState()->conState.conFormIndex, false); + + grabPos = QPoint(-1, -1); + } + } + + QGraphicsView::mouseReleaseEvent(event); +} + +void DockingConView::mouseMoveEvent(QMouseEvent *event) +{ + if (grabPos != QPoint(-1, -1)) { + rubberBand->setGeometry( + QRect(rubberPos + (event->globalPos() - grabPos), size())); + } + + QGraphicsView::mouseMoveEvent(event); +} + +DockingConView::~DockingConView() +{ + qDebug("destroy docking controller view"); + + if (rubberBand != NULL) { + rubberBand->close(); + delete rubberBand; + rubberBand = NULL; + } +} diff --git a/tizen/src/ui/dockingconview.h b/tizen/src/ui/dockingconview.h new file mode 100644 index 0000000000..75450669d6 --- /dev/null +++ b/tizen/src/ui/dockingconview.h @@ -0,0 +1,61 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef DOCKINGCONVIEW_H +#define DOCKINGCONVIEW_H + +#include + +#include "skinview.h" +#include "controllerform.h" + +class DockingConView : public QGraphicsView +{ +public: + DockingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0); + ~DockingConView(); + +protected: + void resizeEvent(QResizeEvent *event); + + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + + QPoint grabPos; + QPoint eventPos; + QPoint rubberPos; + +private: + void createItems(ControllerForm *conForm); + + QRubberBand *rubberBand; +}; + +#endif // DOCKINGCONVIEW_H diff --git a/tizen/src/ui/floatingcontroller.cpp b/tizen/src/ui/floatingcontroller.cpp index 9188d53272..422402b598 100644 --- a/tizen/src/ui/floatingcontroller.cpp +++ b/tizen/src/ui/floatingcontroller.cpp @@ -50,7 +50,7 @@ FloatingController::FloatingController(ControllerForm *conForm, QGraphicsScene *conScene = new QGraphicsScene(this); - conView = new SkinControllerView(conForm, conScene, this); + conView = new FloatingConView(conForm, conScene, this); conView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); layout->addWidget(conView); } diff --git a/tizen/src/ui/floatingcontroller.h b/tizen/src/ui/floatingcontroller.h index 13bb958c54..d70f6ee174 100644 --- a/tizen/src/ui/floatingcontroller.h +++ b/tizen/src/ui/floatingcontroller.h @@ -33,7 +33,7 @@ #include #include "controllerform.h" -#include "skincontrollerview.h" +#include "floatingconview.h" class FloatingController : public QDialog { @@ -50,7 +50,7 @@ protected: void setRegion(QImage baseImage); private: - SkinControllerView *conView; + FloatingConView *conView; ControllerForm *conForm; QAction *menu; }; diff --git a/tizen/src/ui/floatingconview.cpp b/tizen/src/ui/floatingconview.cpp new file mode 100644 index 0000000000..604fa8fb2b --- /dev/null +++ b/tizen/src/ui/floatingconview.cpp @@ -0,0 +1,112 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "floatingconview.h" +#include "mainwindow.h" +#include "skinkeyitem.h" + +FloatingConView::FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent) : + QGraphicsView(scene, parent) +{ + setStyleSheet("background: transparent"); + //setAttribute(Qt::WA_TranslucentBackground); + setStyleSheet("border-style: none"); + + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setAlignment(Qt::AlignLeft | Qt::AlignTop); + + winPos = QPoint(-1, -1); + grabPos = QPoint(-1, -1); + + createItems(conForm); +} + +void FloatingConView::createItems(ControllerForm *conForm) +{ + /* bezel */ + SkinBezelItem *bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]); + scene()->addItem(bezelItem); + + /* HW keys */ + QList keyList = conForm->keyList; + + HardwareKey *hwKey = NULL; + for (int i = 0; i < keyList.count(); i++) { + hwKey = keyList.at(i); + if (hwKey != NULL) { + new SkinKeyItem(conForm->conImg[ControllerForm::pressed].copy(hwKey->region), + hwKey, bezelItem); + } + } +} + +void FloatingConView::resizeEvent(QResizeEvent *event) +{ + //qDebug("resize con view"); + + Q_UNUSED(event) +} + +void FloatingConView::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + QWidget *win = ((QWidget *) this->parent()); + + grabPos = event->globalPos(); + winPos = win->pos(); + } + + QGraphicsView::mousePressEvent(event); +} + +void FloatingConView::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + grabPos = QPoint(-1, -1); + } + + QGraphicsView::mouseReleaseEvent(event); +} + +void FloatingConView::mouseMoveEvent(QMouseEvent *event) +{ + QWidget *win = ((QWidget *)this->parent()); + + if (grabPos != QPoint(-1, -1)) { + win->move(winPos + (event->globalPos() - grabPos)); + } + + QGraphicsView::mouseMoveEvent(event); +} + +FloatingConView::~FloatingConView() +{ + qDebug("destroy floating controller view"); +} diff --git a/tizen/src/ui/floatingconview.h b/tizen/src/ui/floatingconview.h new file mode 100644 index 0000000000..9ae330d568 --- /dev/null +++ b/tizen/src/ui/floatingconview.h @@ -0,0 +1,56 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef FLOATINGCONVIEW_H +#define FLOATINGCONVIEW_H + +#include "skinview.h" +#include "controllerform.h" + +class FloatingConView : public QGraphicsView +{ +public: + FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0); + ~FloatingConView(); + +protected: + void resizeEvent(QResizeEvent *event); + + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + + QPoint grabPos; + QPoint winPos; + +private: + void createItems(ControllerForm *conForm); +}; + +#endif // FLOATINGCONVIEW_H diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index 74531f7839..f7bc27a760 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -229,8 +229,14 @@ void MainWindow::openController(int index, bool docking) if (docking == true) { winLayout->addWidget(getDockingCon()); } else { - QPoint globalPos = mapToGlobal(QPoint(0, 0)); - getFloatingCon()->move(globalPos.x() + size().width(), globalPos.y()); + if (getUIState()->conState.recentlyFloatPos == QPoint(-1, -1)) { + QPoint globalPos = mapToGlobal(QPoint(0, 0)); + getFloatingCon()->move(globalPos.x() + size().width(), globalPos.y()); + } else { + getFloatingCon()->move(getUIState()->conState.recentlyFloatPos); + getUIState()->conState.recentlyFloatPos = QPoint(-1, -1); + } + getFloatingCon()->show(); } } diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h index b02c5d3d53..fcc828eca5 100644 --- a/tizen/src/ui/mainwindow.h +++ b/tizen/src/ui/mainwindow.h @@ -41,7 +41,6 @@ #include "displaybase.h" #include "skinbezelitem.h" #include "uiinformation.h" -#include "skincontrollerview.h" #include "dockingcontroller.h" #include "floatingcontroller.h" diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index 637001c43c..e5090302f2 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -273,7 +273,7 @@ void ContextMenu::slotController(int index) qDebug("controller : %d", index); MainWindow *win = ((MainWindow *)this->parent()); - win->openController(index, false); + win->openController(index, true); } void ContextMenu::slotShell() diff --git a/tizen/src/ui/skincontrollerview.cpp b/tizen/src/ui/skincontrollerview.cpp deleted file mode 100644 index e4ea095743..0000000000 --- a/tizen/src/ui/skincontrollerview.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#include "skincontrollerview.h" -#include "mainwindow.h" -#include "skinkeyitem.h" - -SkinControllerView::SkinControllerView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent) : - QGraphicsView(scene, parent) -{ - setStyleSheet("background: transparent"); - //setAttribute(Qt::WA_TranslucentBackground); - setStyleSheet("border-style: none"); - - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setAlignment(Qt::AlignLeft | Qt::AlignTop); - - grabWinPos = QPoint(-1, -1); - grabPos = QPoint(-1, -1); - - createItems(conForm); -} - -void SkinControllerView::createItems(ControllerForm *conForm) -{ - /* bezel */ - SkinBezelItem *bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]); - scene()->addItem(bezelItem); - - /* HW keys */ - QList keyList = conForm->keyList; - - HardwareKey *hwKey = NULL; - for (int i = 0; i < keyList.count(); i++) { - hwKey = keyList.at(i); - if (hwKey != NULL) { - new SkinKeyItem(conForm->conImg[ControllerForm::pressed].copy(hwKey->region), - hwKey, bezelItem); - } - } -} - -void SkinControllerView::resizeEvent(QResizeEvent *event) -{ - //qDebug("resize con view"); - - Q_UNUSED(event) -} - -void SkinControllerView::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - QWidget *win = ((QWidget *) this->parent()); - grabWinPos = win->pos(); - grabPos = event->globalPos(); - } - - QGraphicsView::mousePressEvent(event); -} - -void SkinControllerView::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - grabPos = QPoint(-1, -1); - } - - QGraphicsView::mouseReleaseEvent(event); -} - -void SkinControllerView::mouseMoveEvent(QMouseEvent *event) -{ - QWidget *win = ((QWidget *)this->parent()); - - if (grabPos != QPoint(-1, -1)) { - win->move(grabWinPos + (event->globalPos() - grabPos)); - } - - QGraphicsView::mouseMoveEvent(event); -} - -SkinControllerView::~SkinControllerView() -{ - qDebug("destroy controller view"); -} diff --git a/tizen/src/ui/skincontrollerview.h b/tizen/src/ui/skincontrollerview.h deleted file mode 100644 index 5ef6bb014e..0000000000 --- a/tizen/src/ui/skincontrollerview.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Qt UI - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#ifndef SKINCONTROLLERVIEW_H -#define SKINCONTROLLERVIEW_H - -#include "skinview.h" -#include "controllerform.h" - -class SkinControllerView : public QGraphicsView -{ -public: - SkinControllerView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0); - ~SkinControllerView(); - -protected: - void resizeEvent(QResizeEvent *event); - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - - QPoint grabWinPos; - QPoint grabPos; - -private: - void createItems(ControllerForm *conForm); -}; - -#endif // SKINCONTROLLERVIEW_H diff --git a/tizen/src/ui/uistate.cpp b/tizen/src/ui/uistate.cpp index 5cde385af0..af8c79d5dd 100644 --- a/tizen/src/ui/uistate.cpp +++ b/tizen/src/ui/uistate.cpp @@ -35,6 +35,7 @@ UIState::UIState() : conState.conFormIndex = 0; conState.dockingCon = NULL; conState.floatingCon = NULL; + conState.recentlyFloatPos = QPoint(-1, -1); } int UIState::getMainFormIndex(int angle) diff --git a/tizen/src/ui/uistate.h b/tizen/src/ui/uistate.h index a35edb09d9..562af2f383 100644 --- a/tizen/src/ui/uistate.h +++ b/tizen/src/ui/uistate.h @@ -45,6 +45,7 @@ public: int conFormIndex; DockingController *dockingCon; FloatingController *floatingCon; + QPoint recentlyFloatPos; }; class UIState