#include "qt5_supplement.h"
#include "mainwindow.h"
-#include "uiinformation.h"
#include "hardwarekey.h"
-#include "floatingcontroller.h"
#include "xmllayoutparser.h"
#include "uiutil.h"
rcc -name resource $< -o $@
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) += controller/
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 $@
$(obj)/moc_displayglwidget.o: $(obj)/moc_displayglwidget.cpp
$(obj)/moc_displayglwidget.cpp: $(obj)/displayglwidget.h
moc $< -o $@
-obj-$(CONFIG_QT) += generalpurposecon.o
\ No newline at end of file
+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) += generalpurposecon.o
+
+$(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 $@
\ No newline at end of file
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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 "dockingcontroller.h"
+#include "mainwindow.h"
+
+DockingController::DockingController(ControllerForm *conForm,
+ QAction *menu, int dockPos, QWidget *parent) : QWidget(parent)
+{
+ this->conForm = conForm;
+ this->menu = menu;
+ this->dockPos = dockPos;
+
+ setStyleSheet("border-style: none");
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->setMargin(0);
+ layout->setSpacing(0);
+
+ if (dockPos & Qt::AlignCenter) {
+ layout->setAlignment(Qt::AlignCenter);
+ } else if (dockPos & Qt::AlignTop) {
+ layout->setAlignment(Qt::AlignTop);
+ } else if (dockPos & Qt::AlignBottom) {
+ layout->setAlignment(Qt::AlignBottom);
+ }
+
+ QGraphicsScene *conScene = new QGraphicsScene(this);
+ conScene->setBackgroundBrush(Qt::black);
+
+ conView = new DockingConView(conForm, conScene, this);
+ conView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+ layout->addWidget(conView);
+}
+
+DockingConView *DockingController::getConView()
+{
+ return conView;
+}
+
+int DockingController::getDockPos()
+{
+ return dockPos;
+}
+
+void DockingController::showEvent(QShowEvent *event)
+{
+ if (menu != NULL) {
+ menu->setChecked(true);
+ }
+}
+
+void DockingController::closeEvent(QCloseEvent *event) {
+ if (menu != NULL) {
+ menu->setChecked(false);
+ }
+
+ MainWindow *win = ((MainWindow *)this->parent());
+ win->getUIState()->conState.dockingCon = NULL;
+}
+
+DockingController::~DockingController()
+{
+ qDebug("destroy docking controller");
+}
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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 <QDialog>
+
+#include "controllerform.h"
+#include "dockingconview.h"
+
+class DockingController : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit DockingController(ControllerForm *conForm,
+ QAction *menu, int dockPos, QWidget *parent = 0);
+ ~DockingController();
+
+ DockingConView *getConView();
+ int getDockPos();
+
+protected:
+ void showEvent(QShowEvent *event);
+ void closeEvent(QCloseEvent *event);
+
+private:
+ DockingConView *conView;
+ ControllerForm *conForm;
+ QAction *menu;
+ int dockPos;
+};
+
+#endif // DOCKINGCONTROLLER_H
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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"
+#include "controller/generalpurposecon.h"
+
+DockingConView::DockingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent)
+ : QGraphicsView(scene, parent)
+{
+ this->parent = (DockingController *)parent;
+
+ setStyleSheet("background: transparent");
+ 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 */
+ bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]);
+ scene()->addItem(bezelItem);
+
+ /* HW keys */
+ keyList = conForm->keyList;
+
+ if (conForm->isGeneralPurpose() == false) {
+ HardwareKey *hwKey = NULL;
+ for (int i = 0; i < keyList.count(); i++) {
+ hwKey = keyList.at(i);
+ if (hwKey != NULL) {
+ new SkinKeyItem(bezelItem, hwKey,
+ conForm->conImg[ControllerForm::pressed].copy(hwKey->region),
+ conForm->getHoverType());
+ }
+ }
+ } else {
+ GeneralPurposeCon *generalCon = new GeneralPurposeCon(this, keyList,
+ QSize(conForm->centerRect.width(),
+ conForm->centerRect.height() - (GPC_HEAD_SPACING + GPC_TAIL_SPACING)));
+ scene()->addWidget(generalCon);
+
+ QPoint topLeft = conForm->centerRect.topLeft();
+ generalCon->move(topLeft.x(), topLeft.y() + GPC_HEAD_SPACING);
+ }
+}
+
+void DockingConView::resizeEvent(QResizeEvent *event)
+{
+ Q_UNUSED(event)
+
+ /* do nothing */
+}
+
+void DockingConView::mousePressEvent(QMouseEvent *event)
+{
+ QGraphicsView::mousePressEvent(event);
+
+ if (bezelItem->isHWKeyHandling() == true) {
+ /* do nothing */
+ return;
+ }
+
+ if (event->button() == Qt::LeftButton) {
+ QWidget *win = parent->parentWidget();
+
+ grabPos = event->globalPos();
+ eventPos = event->pos();
+ rubberPos.setX(win->pos().x() + parent->pos().x());
+ rubberPos.setY(win->pos().y() + pos().y());
+
+ if (rubberBand != NULL) {
+ rubberBand->setGeometry(QRect(rubberPos, size()));
+ rubberBand->show();
+ }
+ }
+}
+
+void DockingConView::mouseReleaseEvent(QMouseEvent *event)
+{
+ QGraphicsView::mouseReleaseEvent(event);
+
+ if (bezelItem->isHWKeyHandling() == true) {
+ /* do nothing */
+ return;
+ }
+
+ if (event->button() == Qt::LeftButton) {
+ if (grabPos != QPoint(-1, -1)) {
+ if (rubberBand != NULL) {
+ rubberBand->hide();
+ }
+
+ /* toggle */
+ MainWindow *win = ((MainWindow *)parent->parent());
+ win->getUIState()->conState.recentlyFloatPos = event->globalPos() - eventPos;
+
+ win->openController(win->getUIState()->conState.conFormIndex, -1);
+ return;
+ }
+ }
+}
+
+void DockingConView::mouseMoveEvent(QMouseEvent *event)
+{
+ QGraphicsView::mouseMoveEvent(event);
+
+ if (bezelItem->isHWKeyHandling() == true) {
+ /* do nothing */
+ return;
+ }
+
+ if (grabPos != QPoint(-1, -1) && rubberBand != NULL) {
+ rubberBand->setGeometry(
+ QRect(rubberPos + (event->globalPos() - grabPos), size()));
+ }
+}
+
+QList<HardwareKey *> DockingConView::getKeyList()
+{
+ return keyList;
+}
+
+DockingConView::~DockingConView()
+{
+ qDebug("destroy docking controller view");
+
+ if (rubberBand != NULL) {
+ rubberBand->close();
+ delete rubberBand;
+ rubberBand = NULL;
+ }
+}
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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 <QRubberBand>
+
+#include "skinview.h"
+#include "skinbezelitem.h"
+#include "controllerform.h"
+
+class DockingController;
+
+class DockingConView : public QGraphicsView
+{
+public:
+ DockingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0);
+ ~DockingConView();
+ QList<HardwareKey *> getKeyList();
+
+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);
+
+ DockingController *parent;
+ SkinBezelItem *bezelItem;
+ QRubberBand *rubberBand;
+ QList<HardwareKey *> keyList;
+};
+
+#endif // DOCKINGCONVIEW_H
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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 "floatingcontroller.h"
+#include "mainwindow.h"
+
+FloatingController::FloatingController(ControllerForm *conForm,
+ QAction *menu, QWidget *parent) : QDialog(parent)
+{
+ this->conForm = conForm;
+ this->menu = menu;
+
+ setStyleSheet("border-style: none");
+ setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ setWindowTitle(conForm->getName());
+
+ QHBoxLayout *layout = new QHBoxLayout(this);
+ layout->setMargin(0);
+ layout->setSpacing(0);
+
+ QGraphicsScene *conScene = new QGraphicsScene(this);
+ conScene->setBackgroundBrush(Qt::black);
+
+ conView = new FloatingConView(conForm, conScene, this);
+ conView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+ layout->addWidget(conView);
+}
+
+FloatingConView *FloatingController::getConView()
+{
+ return conView;
+}
+
+void FloatingController::showEvent(QShowEvent *event)
+{
+ if (menu != NULL) {
+ menu->setChecked(true);
+ }
+
+ setRegion(&(conForm->conImg[ControllerForm::normal]));
+}
+
+void FloatingController::closeEvent(QCloseEvent *event) {
+ if (menu != NULL) {
+ menu->setChecked(false);
+ }
+
+ MainWindow *win = ((MainWindow *)this->parent());
+ win->getUIState()->conState.floatingCon = NULL;
+}
+
+void FloatingController::setRegion(QImage *baseImage)
+{
+ qDebug("set region");
+
+ if (baseImage->isNull() == true) {
+ qWarning("invalid image for region");
+ return;
+ }
+
+ setMask(QRegion(QBitmap::fromImage(baseImage->createAlphaMask())));
+}
+
+FloatingController::~FloatingController()
+{
+ qDebug("destroy floating controller");
+}
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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 FLOATINGCONTROLLER_H
+#define FLOATINGCONTROLLER_H
+
+#include <QDialog>
+
+#include "controllerform.h"
+#include "floatingconview.h"
+
+class FloatingController : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit FloatingController(ControllerForm *conForm, QAction *menu, QWidget *parent = 0);
+ ~FloatingController();
+
+ FloatingConView *getConView();
+
+protected:
+ void showEvent(QShowEvent *event);
+ void closeEvent(QCloseEvent *event);
+
+ void setRegion(QImage *baseImage);
+
+private:
+ FloatingConView *conView;
+ ControllerForm *conForm;
+ QAction *menu;
+};
+
+#endif // FLOATINGCONTROLLER_H
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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"
+#include "controller/generalpurposecon.h"
+
+#define DOCKABLE_AREA_WIDTH 30
+
+FloatingConView::FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent)
+ : QGraphicsView(scene, parent)
+{
+ this->parent = (FloatingController *)parent;
+
+ setStyleSheet("background: transparent");
+ setStyleSheet("border-style: none");
+
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setAlignment(Qt::AlignLeft | Qt::AlignTop);
+
+ conPos = QPoint(-1, -1);
+ grabPos = QPoint(-1, -1);
+ rubberBand = new QRubberBand(QRubberBand::Rectangle, NULL);
+
+ createItems(conForm);
+}
+
+void FloatingConView::createItems(ControllerForm *conForm)
+{
+ /* bezel */
+ bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]);
+ scene()->addItem(bezelItem);
+
+ /* HW keys */
+ keyList = conForm->keyList;
+
+ if (conForm->isGeneralPurpose() == false) {
+ HardwareKey *hwKey = NULL;
+ for (int i = 0; i < keyList.count(); i++) {
+ hwKey = keyList.at(i);
+ if (hwKey != NULL) {
+ new SkinKeyItem(bezelItem, hwKey,
+ conForm->conImg[ControllerForm::pressed].copy(hwKey->region),
+ conForm->getHoverType());
+ }
+ }
+ } else {
+ GeneralPurposeCon *generalCon = new GeneralPurposeCon(this, keyList,
+ QSize(conForm->centerRect.width(),
+ conForm->centerRect.height() - (GPC_HEAD_SPACING + GPC_TAIL_SPACING)));
+ scene()->addWidget(generalCon);
+
+ QPoint topLeft = conForm->centerRect.topLeft();
+ generalCon->move(topLeft.x(), topLeft.y() + GPC_HEAD_SPACING);
+ }
+}
+
+void FloatingConView::resizeEvent(QResizeEvent *event)
+{
+ //qDebug("resize con view");
+
+ Q_UNUSED(event)
+}
+
+int FloatingConView::isDockable(QWidget *object, QWidget *subject)
+{
+ const int heightOneThird = object->size().height() / 3;
+
+ /* MainWindow */
+ QRect rectDockableRC(object->pos().x() + object->size().width() - 1,
+ object->pos().y() + heightOneThird,
+ DOCKABLE_AREA_WIDTH,
+ heightOneThird);
+
+ QRect rectDockableRT(object->pos().x() + object->size().width() - 1,
+ object->pos().y(),
+ DOCKABLE_AREA_WIDTH,
+ heightOneThird);
+
+ QRect rectDockableRB(object->pos().x() + object->size().width() - 1,
+ object->pos().y() + (heightOneThird * 2),
+ DOCKABLE_AREA_WIDTH,
+ heightOneThird);
+
+ /* ControllerWidget */
+ QRect rectTarget(subject->pos().x() - 1,
+ subject->pos().y(),
+ DOCKABLE_AREA_WIDTH,
+ subject->size().height());
+
+ // TODO: define recursive function
+ QRect interRC = rectTarget.intersected(rectDockableRC);
+ QRect interRT = rectTarget.intersected(rectDockableRT);
+ QRect interRB = rectTarget.intersected(rectDockableRB);
+
+ QRect *interBiggest = NULL;
+
+ if ((interRC.width() * interRC.height()) < (interRT.width() * interRT.height())) {
+ interBiggest = &interRT;
+ } else {
+ interBiggest = &interRC;
+ }
+
+ if ((interBiggest->width() * interBiggest->height()) < (interRB.width() * interRB.height())) {
+ interBiggest = &interRB;
+ }
+
+ if (interBiggest != NULL &&
+ interBiggest->isNull() == false && interBiggest->isEmpty() == false) {
+ if (interBiggest == &interRC) {
+ return Qt::AlignRight | Qt::AlignCenter;
+ } else if (interBiggest == &interRT) {
+ return Qt::AlignRight | Qt::AlignTop;
+ } else if (interBiggest == &interRB) {
+ return Qt::AlignRight | Qt::AlignBottom;
+ }
+ }
+
+ return -1;
+}
+
+void FloatingConView::mousePressEvent(QMouseEvent *event)
+{
+ QGraphicsView::mousePressEvent(event);
+
+ if (bezelItem->isHWKeyHandling() == true) {
+ /* do nothing */
+ return;
+ }
+
+ if (event->button() == Qt::LeftButton) {
+ grabPos = event->globalPos();
+ conPos = parent->pos();
+ }
+}
+
+void FloatingConView::mouseReleaseEvent(QMouseEvent *event)
+{
+ QGraphicsView::mouseReleaseEvent(event);
+
+ if (bezelItem->isHWKeyHandling() == true) {
+ /* do nothing */
+ return;
+ }
+
+ if (event->button() == Qt::LeftButton) {
+ grabPos = QPoint(-1, -1);
+ if (rubberBand != NULL) {
+ rubberBand->hide();
+ }
+ }
+
+ const FloatingController *con = parent;
+ MainWindow *win = ((MainWindow *)con->parent());
+
+ int dockPos = isDockable((QWidget *)win, (QWidget *)parent);
+ if (dockPos != -1) {
+ /* toggle */
+ win->openController(win->getUIState()->conState.conFormIndex, dockPos);
+ return;
+ }
+}
+
+void FloatingConView::mouseMoveEvent(QMouseEvent *event)
+{
+ QGraphicsView::mouseMoveEvent(event);
+
+ if (bezelItem->isHWKeyHandling() == true) {
+ /* do nothing */
+ return;
+ }
+
+ if (grabPos != QPoint(-1, -1)) {
+ /* draw guide for dockable position */
+ const FloatingController *con = parent;
+ MainWindow *win = ((MainWindow *)con->parent());
+
+ if (rubberBand != NULL) {
+ int dockPos = isDockable((QWidget *)win, (QWidget *)con);
+ if (dockPos != -1) {
+ int vShift = 0;
+
+ if (win->size().height() > size().height()) {
+ if (dockPos & Qt::AlignCenter) {
+ vShift = (win->size().height() / 2) - (size().height() / 2);
+ } else if (dockPos & Qt::AlignBottom) {
+ vShift = win->size().height() - size().height();
+ }
+ }
+
+ QPoint rubberPos(win->pos().x() + win->size().width(),
+ win->pos().y() + vShift);
+ rubberBand->setGeometry(QRect(rubberPos, size()));
+ rubberBand->show();
+ } else {
+ rubberBand->hide();
+ }
+ }
+
+ parent->move(conPos + (event->globalPos() - grabPos));
+ }
+}
+
+QList<HardwareKey *> FloatingConView::getKeyList()
+{
+ return keyList;
+}
+
+FloatingConView::~FloatingConView()
+{
+ qDebug("destroy floating controller view");
+
+ if (rubberBand != NULL) {
+ rubberBand->close();
+ delete rubberBand;
+ rubberBand = NULL;
+ }
+}
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * 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 <QRubberBand>
+
+#include "skinview.h"
+#include "skinbezelitem.h"
+#include "controllerform.h"
+
+class FloatingController;
+
+class FloatingConView : public QGraphicsView
+{
+public:
+ FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0);
+ ~FloatingConView();
+ QList<HardwareKey *> getKeyList();
+
+protected:
+ void resizeEvent(QResizeEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+
+ int isDockable(QWidget *object, QWidget *subject);
+
+ QPoint grabPos;
+ QPoint conPos;
+
+private:
+ void createItems(ControllerForm *conForm);
+
+ FloatingController *parent;
+ SkinBezelItem *bezelItem;
+ QRubberBand *rubberBand;
+ QList<HardwareKey *> keyList;
+};
+
+#endif // FLOATINGCONVIEW_H
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
- *
- * 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 "dockingcontroller.h"
-#include "mainwindow.h"
-
-DockingController::DockingController(ControllerForm *conForm,
- QAction *menu, int dockPos, QWidget *parent) : QWidget(parent)
-{
- this->conForm = conForm;
- this->menu = menu;
- this->dockPos = dockPos;
-
- setStyleSheet("border-style: none");
- setAttribute(Qt::WA_DeleteOnClose);
-
- QVBoxLayout *layout = new QVBoxLayout(this);
- layout->setMargin(0);
- layout->setSpacing(0);
-
- if (dockPos & Qt::AlignCenter) {
- layout->setAlignment(Qt::AlignCenter);
- } else if (dockPos & Qt::AlignTop) {
- layout->setAlignment(Qt::AlignTop);
- } else if (dockPos & Qt::AlignBottom) {
- layout->setAlignment(Qt::AlignBottom);
- }
-
- QGraphicsScene *conScene = new QGraphicsScene(this);
- conScene->setBackgroundBrush(Qt::black);
-
- conView = new DockingConView(conForm, conScene, this);
- conView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
- layout->addWidget(conView);
-}
-
-DockingConView *DockingController::getConView()
-{
- return conView;
-}
-
-int DockingController::getDockPos()
-{
- return dockPos;
-}
-
-void DockingController::showEvent(QShowEvent *event)
-{
- if (menu != NULL) {
- menu->setChecked(true);
- }
-}
-
-void DockingController::closeEvent(QCloseEvent *event) {
- if (menu != NULL) {
- menu->setChecked(false);
- }
-
- MainWindow *win = ((MainWindow *)this->parent());
- win->getUIState()->conState.dockingCon = NULL;
-}
-
-DockingController::~DockingController()
-{
- qDebug("destroy docking controller");
-}
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
- *
- * 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 <QDialog>
-
-#include "controllerform.h"
-#include "dockingconview.h"
-
-class DockingController : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit DockingController(ControllerForm *conForm,
- QAction *menu, int dockPos, QWidget *parent = 0);
- ~DockingController();
-
- DockingConView *getConView();
- int getDockPos();
-
-protected:
- void showEvent(QShowEvent *event);
- void closeEvent(QCloseEvent *event);
-
-private:
- DockingConView *conView;
- ControllerForm *conForm;
- QAction *menu;
- int dockPos;
-};
-
-#endif // DOCKINGCONTROLLER_H
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
- *
- * 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"
-#include "controller/generalpurposecon.h"
-
-DockingConView::DockingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent)
- : QGraphicsView(scene, parent)
-{
- this->parent = (DockingController *)parent;
-
- setStyleSheet("background: transparent");
- 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 */
- bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]);
- scene()->addItem(bezelItem);
-
- /* HW keys */
- keyList = conForm->keyList;
-
- if (conForm->isGeneralPurpose() == false) {
- HardwareKey *hwKey = NULL;
- for (int i = 0; i < keyList.count(); i++) {
- hwKey = keyList.at(i);
- if (hwKey != NULL) {
- new SkinKeyItem(bezelItem, hwKey,
- conForm->conImg[ControllerForm::pressed].copy(hwKey->region),
- conForm->getHoverType());
- }
- }
- } else {
- GeneralPurposeCon *generalCon = new GeneralPurposeCon(this, keyList,
- QSize(conForm->centerRect.width(),
- conForm->centerRect.height() - (GPC_HEAD_SPACING + GPC_TAIL_SPACING)));
- scene()->addWidget(generalCon);
-
- QPoint topLeft = conForm->centerRect.topLeft();
- generalCon->move(topLeft.x(), topLeft.y() + GPC_HEAD_SPACING);
- }
-}
-
-void DockingConView::resizeEvent(QResizeEvent *event)
-{
- Q_UNUSED(event)
-
- /* do nothing */
-}
-
-void DockingConView::mousePressEvent(QMouseEvent *event)
-{
- QGraphicsView::mousePressEvent(event);
-
- if (bezelItem->isHWKeyHandling() == true) {
- /* do nothing */
- return;
- }
-
- if (event->button() == Qt::LeftButton) {
- QWidget *win = parent->parentWidget();
-
- grabPos = event->globalPos();
- eventPos = event->pos();
- rubberPos.setX(win->pos().x() + parent->pos().x());
- rubberPos.setY(win->pos().y() + pos().y());
-
- if (rubberBand != NULL) {
- rubberBand->setGeometry(QRect(rubberPos, size()));
- rubberBand->show();
- }
- }
-}
-
-void DockingConView::mouseReleaseEvent(QMouseEvent *event)
-{
- QGraphicsView::mouseReleaseEvent(event);
-
- if (bezelItem->isHWKeyHandling() == true) {
- /* do nothing */
- return;
- }
-
- if (event->button() == Qt::LeftButton) {
- if (grabPos != QPoint(-1, -1)) {
- if (rubberBand != NULL) {
- rubberBand->hide();
- }
-
- /* toggle */
- MainWindow *win = ((MainWindow *)parent->parent());
- win->getUIState()->conState.recentlyFloatPos = event->globalPos() - eventPos;
-
- win->openController(win->getUIState()->conState.conFormIndex, -1);
- return;
- }
- }
-}
-
-void DockingConView::mouseMoveEvent(QMouseEvent *event)
-{
- QGraphicsView::mouseMoveEvent(event);
-
- if (bezelItem->isHWKeyHandling() == true) {
- /* do nothing */
- return;
- }
-
- if (grabPos != QPoint(-1, -1) && rubberBand != NULL) {
- rubberBand->setGeometry(
- QRect(rubberPos + (event->globalPos() - grabPos), size()));
- }
-}
-
-QList<HardwareKey *> DockingConView::getKeyList()
-{
- return keyList;
-}
-
-DockingConView::~DockingConView()
-{
- qDebug("destroy docking controller view");
-
- if (rubberBand != NULL) {
- rubberBand->close();
- delete rubberBand;
- rubberBand = NULL;
- }
-}
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
- *
- * 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 <QRubberBand>
-
-#include "skinview.h"
-#include "skinbezelitem.h"
-#include "controllerform.h"
-
-class DockingController;
-
-class DockingConView : public QGraphicsView
-{
-public:
- DockingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0);
- ~DockingConView();
- QList<HardwareKey *> getKeyList();
-
-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);
-
- DockingController *parent;
- SkinBezelItem *bezelItem;
- QRubberBand *rubberBand;
- QList<HardwareKey *> keyList;
-};
-
-#endif // DOCKINGCONVIEW_H
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
- *
- * 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 "floatingcontroller.h"
-#include "mainwindow.h"
-
-FloatingController::FloatingController(ControllerForm *conForm,
- QAction *menu, QWidget *parent) : QDialog(parent)
-{
- this->conForm = conForm;
- this->menu = menu;
-
- setStyleSheet("border-style: none");
- setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
- setAttribute(Qt::WA_DeleteOnClose);
-
- setWindowTitle(conForm->getName());
-
- QHBoxLayout *layout = new QHBoxLayout(this);
- layout->setMargin(0);
- layout->setSpacing(0);
-
- QGraphicsScene *conScene = new QGraphicsScene(this);
- conScene->setBackgroundBrush(Qt::black);
-
- conView = new FloatingConView(conForm, conScene, this);
- conView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
- layout->addWidget(conView);
-}
-
-FloatingConView *FloatingController::getConView()
-{
- return conView;
-}
-
-void FloatingController::showEvent(QShowEvent *event)
-{
- if (menu != NULL) {
- menu->setChecked(true);
- }
-
- setRegion(&(conForm->conImg[ControllerForm::normal]));
-}
-
-void FloatingController::closeEvent(QCloseEvent *event) {
- if (menu != NULL) {
- menu->setChecked(false);
- }
-
- MainWindow *win = ((MainWindow *)this->parent());
- win->getUIState()->conState.floatingCon = NULL;
-}
-
-void FloatingController::setRegion(QImage *baseImage)
-{
- qDebug("set region");
-
- if (baseImage->isNull() == true) {
- qWarning("invalid image for region");
- return;
- }
-
- setMask(QRegion(QBitmap::fromImage(baseImage->createAlphaMask())));
-}
-
-FloatingController::~FloatingController()
-{
- qDebug("destroy floating controller");
-}
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
- *
- * 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 FLOATINGCONTROLLER_H
-#define FLOATINGCONTROLLER_H
-
-#include <QDialog>
-
-#include "controllerform.h"
-#include "floatingconview.h"
-
-class FloatingController : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit FloatingController(ControllerForm *conForm, QAction *menu, QWidget *parent = 0);
- ~FloatingController();
-
- FloatingConView *getConView();
-
-protected:
- void showEvent(QShowEvent *event);
- void closeEvent(QCloseEvent *event);
-
- void setRegion(QImage *baseImage);
-
-private:
- FloatingConView *conView;
- ControllerForm *conForm;
- QAction *menu;
-};
-
-#endif // FLOATINGCONTROLLER_H
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
- *
- * 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"
-#include "controller/generalpurposecon.h"
-
-#define DOCKABLE_AREA_WIDTH 30
-
-FloatingConView::FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent)
- : QGraphicsView(scene, parent)
-{
- this->parent = (FloatingController *)parent;
-
- setStyleSheet("background: transparent");
- setStyleSheet("border-style: none");
-
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setAlignment(Qt::AlignLeft | Qt::AlignTop);
-
- conPos = QPoint(-1, -1);
- grabPos = QPoint(-1, -1);
- rubberBand = new QRubberBand(QRubberBand::Rectangle, NULL);
-
- createItems(conForm);
-}
-
-void FloatingConView::createItems(ControllerForm *conForm)
-{
- /* bezel */
- bezelItem = new SkinBezelItem(conForm->conImg[ControllerForm::normal]);
- scene()->addItem(bezelItem);
-
- /* HW keys */
- keyList = conForm->keyList;
-
- if (conForm->isGeneralPurpose() == false) {
- HardwareKey *hwKey = NULL;
- for (int i = 0; i < keyList.count(); i++) {
- hwKey = keyList.at(i);
- if (hwKey != NULL) {
- new SkinKeyItem(bezelItem, hwKey,
- conForm->conImg[ControllerForm::pressed].copy(hwKey->region),
- conForm->getHoverType());
- }
- }
- } else {
- GeneralPurposeCon *generalCon = new GeneralPurposeCon(this, keyList,
- QSize(conForm->centerRect.width(),
- conForm->centerRect.height() - (GPC_HEAD_SPACING + GPC_TAIL_SPACING)));
- scene()->addWidget(generalCon);
-
- QPoint topLeft = conForm->centerRect.topLeft();
- generalCon->move(topLeft.x(), topLeft.y() + GPC_HEAD_SPACING);
- }
-}
-
-void FloatingConView::resizeEvent(QResizeEvent *event)
-{
- //qDebug("resize con view");
-
- Q_UNUSED(event)
-}
-
-int FloatingConView::isDockable(QWidget *object, QWidget *subject)
-{
- const int heightOneThird = object->size().height() / 3;
-
- /* MainWindow */
- QRect rectDockableRC(object->pos().x() + object->size().width() - 1,
- object->pos().y() + heightOneThird,
- DOCKABLE_AREA_WIDTH,
- heightOneThird);
-
- QRect rectDockableRT(object->pos().x() + object->size().width() - 1,
- object->pos().y(),
- DOCKABLE_AREA_WIDTH,
- heightOneThird);
-
- QRect rectDockableRB(object->pos().x() + object->size().width() - 1,
- object->pos().y() + (heightOneThird * 2),
- DOCKABLE_AREA_WIDTH,
- heightOneThird);
-
- /* ControllerWidget */
- QRect rectTarget(subject->pos().x() - 1,
- subject->pos().y(),
- DOCKABLE_AREA_WIDTH,
- subject->size().height());
-
- // TODO: define recursive function
- QRect interRC = rectTarget.intersected(rectDockableRC);
- QRect interRT = rectTarget.intersected(rectDockableRT);
- QRect interRB = rectTarget.intersected(rectDockableRB);
-
- QRect *interBiggest = NULL;
-
- if ((interRC.width() * interRC.height()) < (interRT.width() * interRT.height())) {
- interBiggest = &interRT;
- } else {
- interBiggest = &interRC;
- }
-
- if ((interBiggest->width() * interBiggest->height()) < (interRB.width() * interRB.height())) {
- interBiggest = &interRB;
- }
-
- if (interBiggest != NULL &&
- interBiggest->isNull() == false && interBiggest->isEmpty() == false) {
- if (interBiggest == &interRC) {
- return Qt::AlignRight | Qt::AlignCenter;
- } else if (interBiggest == &interRT) {
- return Qt::AlignRight | Qt::AlignTop;
- } else if (interBiggest == &interRB) {
- return Qt::AlignRight | Qt::AlignBottom;
- }
- }
-
- return -1;
-}
-
-void FloatingConView::mousePressEvent(QMouseEvent *event)
-{
- QGraphicsView::mousePressEvent(event);
-
- if (bezelItem->isHWKeyHandling() == true) {
- /* do nothing */
- return;
- }
-
- if (event->button() == Qt::LeftButton) {
- grabPos = event->globalPos();
- conPos = parent->pos();
- }
-}
-
-void FloatingConView::mouseReleaseEvent(QMouseEvent *event)
-{
- QGraphicsView::mouseReleaseEvent(event);
-
- if (bezelItem->isHWKeyHandling() == true) {
- /* do nothing */
- return;
- }
-
- if (event->button() == Qt::LeftButton) {
- grabPos = QPoint(-1, -1);
- if (rubberBand != NULL) {
- rubberBand->hide();
- }
- }
-
- const FloatingController *con = parent;
- MainWindow *win = ((MainWindow *)con->parent());
-
- int dockPos = isDockable((QWidget *)win, (QWidget *)parent);
- if (dockPos != -1) {
- /* toggle */
- win->openController(win->getUIState()->conState.conFormIndex, dockPos);
- return;
- }
-}
-
-void FloatingConView::mouseMoveEvent(QMouseEvent *event)
-{
- QGraphicsView::mouseMoveEvent(event);
-
- if (bezelItem->isHWKeyHandling() == true) {
- /* do nothing */
- return;
- }
-
- if (grabPos != QPoint(-1, -1)) {
- /* draw guide for dockable position */
- const FloatingController *con = parent;
- MainWindow *win = ((MainWindow *)con->parent());
-
- if (rubberBand != NULL) {
- int dockPos = isDockable((QWidget *)win, (QWidget *)con);
- if (dockPos != -1) {
- int vShift = 0;
-
- if (win->size().height() > size().height()) {
- if (dockPos & Qt::AlignCenter) {
- vShift = (win->size().height() / 2) - (size().height() / 2);
- } else if (dockPos & Qt::AlignBottom) {
- vShift = win->size().height() - size().height();
- }
- }
-
- QPoint rubberPos(win->pos().x() + win->size().width(),
- win->pos().y() + vShift);
- rubberBand->setGeometry(QRect(rubberPos, size()));
- rubberBand->show();
- } else {
- rubberBand->hide();
- }
- }
-
- parent->move(conPos + (event->globalPos() - grabPos));
- }
-}
-
-QList<HardwareKey *> FloatingConView::getKeyList()
-{
- return keyList;
-}
-
-FloatingConView::~FloatingConView()
-{
- qDebug("destroy floating controller view");
-
- if (rubberBand != NULL) {
- rubberBand->close();
- delete rubberBand;
- rubberBand = NULL;
- }
-}
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
- *
- * 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 <QRubberBand>
-
-#include "skinview.h"
-#include "skinbezelitem.h"
-#include "controllerform.h"
-
-class FloatingController;
-
-class FloatingConView : public QGraphicsView
-{
-public:
- FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0);
- ~FloatingConView();
- QList<HardwareKey *> getKeyList();
-
-protected:
- void resizeEvent(QResizeEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
-
- int isDockable(QWidget *object, QWidget *subject);
-
- QPoint grabPos;
- QPoint conPos;
-
-private:
- void createItems(ControllerForm *conForm);
-
- FloatingController *parent;
- SkinBezelItem *bezelItem;
- QRubberBand *rubberBand;
- QList<HardwareKey *> keyList;
-};
-
-#endif // FLOATINGCONVIEW_H
#include "displaybase.h"
#include "skinbezelitem.h"
#include "uiinformation.h"
-#include "dockingcontroller.h"
-#include "floatingcontroller.h"
+#include "controller/dockingcontroller.h"
+#include "controller/floatingcontroller.h"
#include "keyboardshortcut.h"
extern "C" {
#ifndef UISTATE_H
#define UISTATE_H
-#include "dockingcontroller.h"
-#include "floatingcontroller.h"
+#include "controller/dockingcontroller.h"
+#include "controller/floatingcontroller.h"
class ControllerState
{