From: GiWoong Kim Date: Thu, 25 Sep 2014 05:47:15 +0000 (+0900) Subject: controller: added docking controller X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F82%2F29082%2F2;p=sdk%2Femulator%2Fqemu.git controller: added docking controller Change-Id: Iaf2e99bd876dc1481155f3f121e5d7d343812dd1 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ui/Makefile.objs b/tizen/src/ui/Makefile.objs index 01a36bdb82..882329bf29 100644 --- a/tizen/src/ui/Makefile.objs +++ b/tizen/src/ui/Makefile.objs @@ -6,6 +6,7 @@ $(obj)/qrc_resource.cpp: $(TIZEN_UI)/resource/resource.qrc rcc -name resource $< -o $@ obj-$(CONFIG_QT) += controllerform.o +obj-$(CONFIG_QT) += dockingcontroller.o moc_dockingcontroller.o obj-$(CONFIG_QT) += floatingcontroller.o moc_floatingcontroller.o obj-$(CONFIG_QT) += displaybase.o obj-$(CONFIG_QT) += displayglwidget.o moc_displayglwidget.o @@ -26,6 +27,9 @@ obj-$(CONFIG_QT) += xml/ obj-$(CONFIG_QT) += menu/ +$(obj)/moc_dockingcontroller.o: $(obj)/moc_dockingcontroller.cpp +$(obj)/moc_dockingcontroller.cpp: $(obj)/dockingcontroller.h + moc $< -o $@ $(obj)/moc_floatingcontroller.o: $(obj)/moc_floatingcontroller.cpp $(obj)/moc_floatingcontroller.cpp: $(obj)/floatingcontroller.h moc $< -o $@ diff --git a/tizen/src/ui/dockingcontroller.cpp b/tizen/src/ui/dockingcontroller.cpp new file mode 100644 index 0000000000..f1123779f4 --- /dev/null +++ b/tizen/src/ui/dockingcontroller.cpp @@ -0,0 +1,76 @@ +/* + * 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 + +#include "dockingcontroller.h" +#include "mainwindow.h" + +DockingController::DockingController(ControllerForm *conForm, QGraphicsScene *conScene, + QAction *menu, QWidget *parent) : SkinControllerView(conForm, conScene, parent) +{ + this->conForm = conForm; + this->menu = menu; + + setAttribute(Qt::WA_DeleteOnClose); + setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); +} + +void DockingController::showEvent(QShowEvent *event) +{ + menu->setChecked(true); + //setRegion(conForm->conImg[ControllerForm::normal]); +} + +void DockingController::closeEvent(QCloseEvent *event) { + menu->setChecked(false); + + MainWindow *win = ((MainWindow *)this->parent()); + win->getUIState()->conState.dockingCon = NULL; +} + +void DockingController::setRegion(QImage baseImage) +{ + qDebug("set region"); + + /* + if (baseImage.isNull() == true) { + qWarning("invalid image for region"); + return; + } + + QImage region = baseImage.createAlphaMask(); + setMask(QRegion(QBitmap::fromImage(region))); + */ +} + +DockingController::~DockingController() +{ + qDebug("destroy docking contoller"); +} diff --git a/tizen/src/ui/dockingcontroller.h b/tizen/src/ui/dockingcontroller.h new file mode 100644 index 0000000000..765c8a1457 --- /dev/null +++ b/tizen/src/ui/dockingcontroller.h @@ -0,0 +1,58 @@ +/* + * 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 DOCKINGCONTROLLER_H +#define DOCKINGCONTROLLER_H + +#include + +#include "controllerform.h" +#include "skincontrollerview.h" + +class DockingController : public SkinControllerView +{ + Q_OBJECT + +public: + explicit DockingController(ControllerForm *conForm, QGraphicsScene *conScene, + QAction *menu, QWidget *parent = 0); + ~DockingController(); + +protected: + void showEvent(QShowEvent *event); + void closeEvent(QCloseEvent *event); + + void setRegion(QImage baseImage); + +private: + ControllerForm *conForm; + QAction *menu; +}; + +#endif // DOCKINGCONTROLLER_H diff --git a/tizen/src/ui/floatingcontroller.cpp b/tizen/src/ui/floatingcontroller.cpp index fd2a6ca6a2..9188d53272 100644 --- a/tizen/src/ui/floatingcontroller.cpp +++ b/tizen/src/ui/floatingcontroller.cpp @@ -83,5 +83,5 @@ void FloatingController::setRegion(QImage baseImage) FloatingController::~FloatingController() { - qDebug("destroy contoller"); + qDebug("destroy floating contoller"); } diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index cbde5f5689..b597adb625 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -81,7 +81,6 @@ MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) : popupMenu = NULL; skinView = NULL; display = NULL; - conView = NULL; /* windowing */ setWindowTitle("Emulator"); @@ -183,6 +182,11 @@ UIState *MainWindow::getUIState() return &(uiInfo->uiState); } +DockingController *MainWindow::getDockingCon() +{ + return getUIState()->conState.dockingCon; +} + FloatingController *MainWindow::getFloatingCon() { return getUIState()->conState.floatingCon; @@ -206,14 +210,16 @@ void MainWindow::openController(int index, bool docking) } if (docking == true) { + QAction *action = (QAction *)popupMenu->getControllerMapper()->mapping(index); conScene = new QGraphicsScene(this); - conView = new SkinControllerView(conForm, conScene, this); - conView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + getUIState()->conState.dockingCon = + new DockingController(conForm, conScene, action, this); - winLayout->addWidget(conView); + winLayout->addWidget(getDockingCon()); } else { QAction *action = (QAction *)popupMenu->getControllerMapper()->mapping(index); - getUIState()->conState.floatingCon = new FloatingController(conForm, action, this); + getUIState()->conState.floatingCon = + new FloatingController(conForm, action, this); QPoint globalPos = mapToGlobal(QPoint(0, 0)); getFloatingCon()->move(globalPos.x() + size().width(), globalPos.y()); @@ -223,14 +229,15 @@ void MainWindow::openController(int index, bool docking) void MainWindow::closeController() { - if (conView != NULL) { + if (getDockingCon() != NULL) { qDebug("close docking controller"); - conView->close(); - conScene->clear(); + winLayout->removeWidget(getDockingCon()); + + getDockingCon()->close(); + getUIState()->conState.dockingCon = NULL; - delete conView; - conView = NULL; + conScene->clear(); delete conScene; conScene = NULL; } @@ -239,6 +246,7 @@ void MainWindow::closeController() qDebug("close floating controller"); getFloatingCon()->close(); + getUIState()->conState.floatingCon = NULL; } } diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h index 816f51be99..74b5e37e5c 100644 --- a/tizen/src/ui/mainwindow.h +++ b/tizen/src/ui/mainwindow.h @@ -42,6 +42,7 @@ #include "skinbezelitem.h" #include "uiinformation.h" #include "skincontrollerview.h" +#include "dockingcontroller.h" #include "floatingcontroller.h" extern "C" { @@ -76,6 +77,7 @@ public: UIState *getUIState(void); void rotate(int angle); void scale(int scale); + DockingController *getDockingCon(); FloatingController *getFloatingCon(); void openController(int index, bool docking); void closeController(); @@ -99,10 +101,10 @@ private: QHBoxLayout *winLayout; QGraphicsScene *skinScene; QGraphicsScene *conScene; - ContextMenu *popupMenu; SkinView* skinView; DisplayBase *display; - SkinControllerView *conView; + ContextMenu *popupMenu; + QThread *swapperThread; DisplaySwapper *swapper; }; diff --git a/tizen/src/ui/uistate.h b/tizen/src/ui/uistate.h index cd80091b93..280ee37b33 100644 --- a/tizen/src/ui/uistate.h +++ b/tizen/src/ui/uistate.h @@ -32,11 +32,13 @@ #include +#include "dockingcontroller.h" #include "floatingcontroller.h" class ControllerState { public: + DockingController *dockingCon; FloatingController *floatingCon; };