obj-$(CONFIG_QT) += displayglwidget.o moc_displayglwidget.o
obj-$(CONFIG_QT) += displayswwidget.o moc_displayswwidget.o
obj-$(CONFIG_QT) += displayswapper.o moc_displayswapper.o
+obj-$(CONFIG_QT) += transwidget.o
obj-$(CONFIG_QT) += mainwindow.o moc_mainwindow.o
obj-$(CONFIG_QT) += skinbezelitem.o
obj-$(CONFIG_QT) += skinkeyitem.o moc_skinkeyitem.o
* Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
+ * Jihye Won <jihye.won1@samsung.com>
* Hyunjin Lee <hyunjin816.lee@samsung.com>
* SungMin Ha <sungmin82.ha@samsung.com>
* GiWoong Kim <giwoong.kim@samsung.com>
this->screenWidget = NULL;
this->captureRequestHandler = NULL;
this->captureRequestData = NULL;
+ this->transWidget = NULL;
/* windowing */
setWindowTitle(EMULATOR_TITLE);
event->ignore();
}
}
+
+/* emulator move function */
+void MainWindow::createTransWidget()
+{
+ qDebug("create transparent widget");
+
+ if (this->uiInfo == NULL) {
+ qWarning("UiInfo object is null.");
+ return;
+ }
+
+ this->transWidget = new TransWidget(this);
+ this->transWidget->show();
+}
+
+void MainWindow::setTransWidget(TransWidget *widget)
+{
+ this->transWidget = widget;
+}
+
+TransWidget *MainWindow::getTransWidget()
+{
+ return this->transWidget;
+}
+
* Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
+ * Jihye Won <jihye.won1@samsung.com>
* Hyunjin Lee <hyunjin816.lee@samsung.com>
* SungMin Ha <sungmin82.ha@samsung.com>
* GiWoong Kim <giwoong.kim@samsung.com>
#include "controller/dockingcontroller.h"
#include "controller/floatingcontroller.h"
#include "input/keyboardshortcut.h"
+#include "transwidget.h"
class MainWindow : public QWidget
{
void startDisplaySwapper();
void terminateDisplaySwapper();
+ /* emulator move function */
+ void createTransWidget();
+ void setTransWidget(TransWidget *widget);
+ TransWidget *getTransWidget();
+
public slots:
void showContextMenu(const QPoint& pos);
void (*captureRequestHandler)(void *data);
void *captureRequestData;
+
+ /* emulator move function */
+ TransWidget *transWidget;
};
#endif // MAINWINDOW_H
/* Always On Top menu */
createOnTopItem(menu, item);
break;
+ case MenuItemType::moveItem:
+ /* Move menu */
+ createMoveItem(menu, item);
+ break;
case MenuItemType::switchItem:
/* Rotate menu */
createSwitchItem(menu, item);
item->setAction(actionTopMost);
}
+void ContextMenu::createMoveItem(QMenu *menu, MenuItem *item)
+{
+ if (menu == NULL || item == NULL) {
+ return;
+ }
+
+ QString menuName = item->getName();
+ actionMove = menu->addAction(
+ menuName.isEmpty() ? MENU_MOVE_ITEM_TEXT : menuName);
+ connect(actionMove, SIGNAL(triggered()), this, SLOT(slotMove()));
+
+ /* shortcut */
+ QMap<QString, QKeySequence> shortcutMap = item->getShortcutMap();
+ QShortcut *shortcut = NULL;
+
+ if (shortcutMap.isEmpty() == false) {
+ shortcut = new QShortcut(
+ item->getShortcutMap().begin().value(), parent);
+ connect(shortcut, SIGNAL(activated()), this, SLOT(slotMove()));
+
+ actionMove->setShortcut(shortcut->key());
+ }
+
+ item->setAction(actionMove);
+}
+
void ContextMenu::createSwitchItem(QMenu *menu, MenuItem *item)
{
if (menu == NULL || item == NULL) {
qDebug() << "shortcut:" << actionTopMost->text() << actionTopMost->isChecked();
}
+void ContextMenu::slotMove()
+{
+ if (parent->getTransWidget() == NULL) {
+ parent->createTransWidget();
+ parent->getTransWidget()->setCursor(Qt::SizeAllCursor);
+ }
+}
+
void ContextMenu::slotSwitch(int index)
{
qDebug("switch: %d", index);
void slotDetailedInfo();
void slotTopMost(bool on);
void slotTopMostShortcut();
-
+ void slotMove();
void slotSwitch(int index);
void slotSwitchShortcutPrev();
void slotSwitchShortcutNext();
void createInfoItem(QMenu *menu, MenuItem *item);
void createOnTopItem(QMenu *menu, MenuItem *item);
+ void createMoveItem(QMenu *menu, MenuItem *item);
void createSwitchItem(QMenu *menu, MenuItem *item);
void createScaleItem(QMenu *menu, MenuItem *item);
void createControllerItem(QMenu *menu, MenuItem *item);
QAction *actionDetailedInfo;
QAction *actionTopMost;
+ QAction *actionMove;
QAction *actionShell;
QAction *actionControlPanel;
QAction *actionScreenShot;
advancedItem,
infoItem,
onTopItem,
+ moveItem,
switchItem,
scaleItem,
controllerItem,
/* context menu */
#define MENU_ONTOP_ITEM_TEXT "Always on Top"
+#define MENU_MOVE_ITEM_TEXT "Move"
#define MENU_SWITCH_ITEM_TEXT "Switch"
#define MENU_SCALE_ITEM_TEXT "Scale"
#define MENU_CONTROLLER_ITEM_TEXT "Controller"
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jihye Won <jihye.won1@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@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 "transwidget.h"
+#include <QDesktopWidget>
+#include <QMouseEvent>
+#include "mainwindow.h"
+
+TransWidget::TransWidget(QWidget *parent) : QWidget(parent)
+{
+ qDebug("transparent widget is created.");
+
+#if defined(CONFIG_DARWIN)
+ setWindowFlags(Qt::Window);
+ setWindowFlags(Qt::FramelessWindowHint);
+#elif defined(CONFIG_LINUX)
+ setWindowFlags(Qt::FramelessWindowHint);
+#endif
+
+ setAttribute(Qt::WA_NoSystemBackground);
+ setAttribute(Qt::WA_TranslucentBackground);
+ setAttribute(Qt::WA_DeleteOnClose);
+ resize(parent->size());
+ qDebug() << "transparent widget size: " << parent->size();
+ installEventFilter(this);
+ isGrab = false;
+}
+
+/* override */
+bool TransWidget::eventFilter(QObject *obj, QEvent *event)
+{
+ TransWidget *widget = dynamic_cast<TransWidget *>(obj);
+
+ if (widget != NULL) {
+
+ QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent *>(event);
+ if (mouseEvent == NULL) {
+ return QObject::eventFilter(obj, event);
+ }
+
+ MainWindow *parent = qobject_cast<MainWindow*>(this->parent());
+ if (parent == NULL) {
+ qWarning() << "parent object(MainWindow) is null.";
+ return QObject::eventFilter(obj, event);
+ }
+
+ if (event->type() == QEvent::MouseButtonPress) {
+ if (mouseEvent->button() == Qt::LeftButton) {
+ isGrab = true;
+ grabPos = parent->mapToGlobal(QPoint(0,0)) - mouseEvent->globalPos();
+ }
+ if (mouseEvent->button() == Qt::RightButton) {
+ mouseEvent->ignore(); /* filtering */
+ return true;
+ }
+ } else if (event->type() == QEvent::MouseMove) {
+ if(isGrab == true) {
+ parent->move(mouseEvent->globalPos() + grabPos);
+ }
+ } else if (event->type() == QEvent::MouseButtonRelease) {
+ qDebug() << "The position of the emulator: " << this->mapToGlobal(QPoint(0,0));
+ close();
+ return true;
+ }
+ }
+
+ return QObject::eventFilter(obj, event);
+}
+
+TransWidget::~TransWidget()
+{
+ qDebug("destroy transparent widget");
+ removeEventFilter(this);
+ MainWindow *parent = qobject_cast<MainWindow*>(this->parent());
+ if (parent == NULL) {
+ qWarning() << "parent object(MainWindow) is null.";
+ } else {
+ parent->setTransWidget(NULL);
+ }
+}
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jihye Won <jihye.won1@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@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 TRANSWIDGET_H
+#define TRANSWIDGET_H
+
+#include <QWidget>
+#include <QEvent>
+
+class TransWidget : public QWidget
+{
+public:
+ explicit TransWidget(QWidget *parent = 0);
+ ~TransWidget();
+ bool isGrab;
+ QPoint grabPos;
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *event);
+};
+
+#endif // TRANSWIDGET_H
#define ADVANCED_MENU_KEYWORD "advancedItem"
#define INFO_MENU_KEYWORD "infoItem"
#define ONTOP_MENU_KEYWORD "onTopItem"
+#define MOVE_MENU_KEYWORD "moveItem"
#define SWITCH_MENU_KEYWORD "switchItem"
#define SCALE_MENU_KEYWORD "scaleItem"
#define CONTROLLER_MENU_KEYWORD "controllerItem"
if (token == QXmlStreamReader::StartElement) {
if (xml.name() == SEPARATOR_MENU_KEYWORD) {
item = new MenuItem(MenuItemType::separator, NULL);
- if (item != NULL) {
- list.append(item);
- }
} else if (xml.name() == ADVANCED_MENU_KEYWORD) {
item = (MenuItem *)parseAdvancedMenuItem(xml);
- if (item != NULL) {
- list.append(item);
- }
} else if (xml.name() == INFO_MENU_KEYWORD) {
item = parseGeneralMenuItem(xml, MenuItemType::infoItem);
- if (item != NULL) {
- list.append(item);
- }
} else if (xml.name() == ONTOP_MENU_KEYWORD) {
item = parseGeneralMenuItem(xml, MenuItemType::onTopItem);
- if (item != NULL) {
- list.append(item);
- }
+ } else if (xml.name() == MOVE_MENU_KEYWORD) {
+ item = parseGeneralMenuItem(xml, MenuItemType::moveItem);
} else if (xml.name() == SWITCH_MENU_KEYWORD) {
item = parseGeneralMenuItem(xml, MenuItemType::switchItem);
- if (item != NULL) {
- list.append(item);
- }
} else if (xml.name() == SCALE_MENU_KEYWORD) {
item = (MenuItem *)parseScaleMenuItem(xml);
- if (item != NULL) {
- list.append(item);
- }
} else if (xml.name() == CONTROLLER_MENU_KEYWORD) {
item = parseGeneralMenuItem(xml, MenuItemType::controllerItem);
- if (item != NULL) {
- list.append(item);
- }
} else if (xml.name() == HOSTKBD_MENU_KEYWORD) {
item = parseGeneralMenuItem(xml, MenuItemType::hostKeyboardItem);
- if (item != NULL) {
- list.append(item);
- }
} else if (xml.name() == SHELL_MENU_KEYWORD) {
item = parseGeneralMenuItem(xml, MenuItemType::shellItem);
- if (item != NULL) {
- list.append(item);
- }
} else if (xml.name() == ECP_MENU_KEYWORD) {
item = parseGeneralMenuItem(xml, MenuItemType::controlPanelItem);
- if (item != NULL) {
- list.append(item);
- }
} else if (xml.name() == SCREENSHOT_MENU_KEYWORD) {
item = parseGeneralMenuItem(xml, MenuItemType::screenShotItem);
- if (item != NULL) {
- list.append(item);
- }
} else if (xml.name() == ABOUT_MENU_KEYWORD) {
item = parseGeneralMenuItem(xml, MenuItemType::aboutItem);
- if (item != NULL) {
- list.append(item);
- }
} else if (xml.name() == FORCECLOSE_MENU_KEYWORD) {
item = parseGeneralMenuItem(xml, MenuItemType::forceCloseItem);
- if (item != NULL) {
- list.append(item);
- }
} else if (xml.name() == CLOSE_MENU_KEYWORD) {
item = parseGeneralMenuItem(xml, MenuItemType::closeItem);
- if (item != NULL) {
- list.append(item);
- }
+ }
+
+ if (item != NULL) {
+ list.append(item);
}
}