From: GiWoong Kim Date: Thu, 16 Oct 2014 05:18:15 +0000 (+0900) Subject: menu: read MRU "Always on Top" value from .skin.properties X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F89%2F29389%2F2;p=sdk%2Femulator%2Fqemu.git menu: read MRU "Always on Top" value from .skin.properties Change-Id: I8cc1f6c0af859f35c91294419aceb73e1e0e3b53 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp index 5a362bf93f..dd2ef40300 100644 --- a/tizen/src/display/qt5_supplement.cpp +++ b/tizen/src/display/qt5_supplement.cpp @@ -61,6 +61,7 @@ static UIInformation *uiInfo; #define SKIN_PROPERTY_WINDOW_X "window.x" #define SKIN_PROPERTY_WINDOW_Y "window.y" #define SKIN_PROPERTY_WINDOW_SCALE "window.scale" +#define SKIN_PROPERTY_WINDOW_TOPMOST "window.ontop" #define SKIN_PROPERTY_CONTROLLER_INDEX "controller.index" #define SKIN_PROPERTY_CONTROLLER_DOCK "controller.dock" @@ -182,8 +183,14 @@ void qt5_gui_init(void) } mainwindow->move(xx, yy); + bool onTop = mruInfo.value(SKIN_PROPERTY_WINDOW_TOPMOST).toBool(); + if (onTop == true) { + mainwindow->setTopMost(true); + } + mainwindow->show(); + /* controller */ int conIndex = mruInfo.value(SKIN_PROPERTY_CONTROLLER_INDEX).toInt(); if (conIndex >= 0 && conIndex < uiInfo->conFormList.count()) { int conDockPos = mruInfo.value(SKIN_PROPERTY_CONTROLLER_DOCK).toInt(); @@ -207,6 +214,7 @@ void qt5_destroy() mruInfo.setValue(SKIN_PROPERTY_WINDOW_X, mainwindow->pos().x()); mruInfo.setValue(SKIN_PROPERTY_WINDOW_Y, mainwindow->pos().y()); mruInfo.setValue(SKIN_PROPERTY_WINDOW_SCALE, uiInfo->uiState.mainFormScale); + mruInfo.setValue(SKIN_PROPERTY_WINDOW_TOPMOST, uiInfo->uiState.isOnTop()); mruInfo.setValue(SKIN_PROPERTY_CONTROLLER_INDEX, uiInfo->uiState.conState.conFormIndex); DockingController *con = uiInfo->uiState.conState.dockingCon; diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index 2ca0014349..ca383764ee 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -71,8 +71,8 @@ void DisplaySwapper::display() } } -MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) : - QWidget(parent) +MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) + : QWidget(parent) { this->label = NULL; /* initialize */ @@ -84,7 +84,6 @@ MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) : /* windowing */ setWindowTitle("Emulator"); - /* app icon */ setWindowIcon(QIcon(QPixmap(":/icons/emulator_icon.ico"))); //setStyleSheet("background:transparent;"); @@ -325,6 +324,11 @@ void MainWindow::scale(int scale) adjustSize(); } +void MainWindow::setTopMost(bool on) +{ + popupMenu->slotTopMost(on); +} + MainWindow::~MainWindow() { qDebug("destory main window"); diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h index e68c1d33de..4a636403dc 100644 --- a/tizen/src/ui/mainwindow.h +++ b/tizen/src/ui/mainwindow.h @@ -76,6 +76,7 @@ public: UIState *getUIState(void); void rotate(int angle); void scale(int scale); + void setTopMost(bool on); DockingController *getDockingCon(); FloatingController *getFloatingCon(); void openController(int index, int dockPos); @@ -84,7 +85,7 @@ public: void terminateSwapper(); UIInformation *uiInfo; - QLabel *getLabel(); + QLabel *getLabel(); // TODO: delete public slots: void showContextMenu(const QPoint& pos); diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index e4facb52eb..9e36c4ad93 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -34,42 +34,50 @@ #include "mainwindow.h" #ifdef CONFIG_WIN32 -#include "windows.h" - +#include #else #include #include - #endif - -ContextMenu::ContextMenu(QWidget *parent) : - QMenu(parent) +ContextMenu::ContextMenu(QWidget *parent) : QMenu(parent) { - infoDialog = NULL; - aboutDialog = NULL; - vmName = ((MainWindow *)parent)->uiInfo->vmName + " : " + this->parent = (MainWindow *)parent; + this->infoDialog = NULL; + this->aboutDialog = NULL; + this->vmName = ((MainWindow *)parent)->uiInfo->vmName + " : " + QString::number(get_device_serial_number()); + actionDetailedInfo = NULL; + actionTopMost = NULL; + actionShell = NULL; + actionControlPanel = NULL; + actionAbout = NULL; + actionForceClose = NULL; + actionClose = NULL; + + longPressTimer = new QTimer(this); + createItems(); installEventFilter(this); } void ContextMenu::createItems() { - MainWindow *win = (MainWindow *)this->parent(); + MainWindow *win = parent; + QAction *action = NULL; /* Detailed Info menu */ - QAction *action = addAction(vmName); - action->setIcon(QIcon(QPixmap(":/icons/detailed_info.png"))); - connect(action, SIGNAL(triggered()), this, SLOT(slotDetailedInfo())); + actionDetailedInfo = addAction(vmName); + actionDetailedInfo->setIcon(QIcon(QPixmap(":/icons/detailed_info.png"))); + connect(actionDetailedInfo, SIGNAL(triggered()), this, SLOT(slotDetailedInfo())); addSeparator(); /* Always On Top menu */ - action = addAction("&Always on Top"); - action->setCheckable(true); - connect(action, SIGNAL(triggered(bool)), this, SLOT(slotTopMost(bool))); + actionTopMost = addAction("&Always on Top"); + actionTopMost->setCheckable(true); + connect(actionTopMost, SIGNAL(triggered(bool)), this, SLOT(slotTopMost(bool))); /* = Rotate menu = */ if (win->uiInfo->mainFormList.count() > 1) { @@ -190,33 +198,32 @@ void ContextMenu::createItems() { advancedMenu->addSeparator(); /* Advanced > About menu */ - action = advancedMenu->addAction("&About"); - action->setIcon(QIcon(QPixmap(":/icons/about.png"))); - connect(action, SIGNAL(triggered()), this, SLOT(slotAbout())); + actionAbout = advancedMenu->addAction("&About"); + actionAbout->setIcon(QIcon(QPixmap(":/icons/about.png"))); + connect(actionAbout, SIGNAL(triggered()), this, SLOT(slotAbout())); /* Advanced > Force Close menu */ - action = advancedMenu->addAction("&Force Close"); - action->setIcon(QIcon(QPixmap(":/icons/force_close.png"))); - connect(action, SIGNAL(triggered()), this, SLOT(slotForceClose())); + actionForceClose = advancedMenu->addAction("&Force Close"); + actionForceClose->setIcon(QIcon(QPixmap(":/icons/force_close.png"))); + connect(actionForceClose, SIGNAL(triggered()), this, SLOT(slotForceClose())); /* ================= */ /* Shell menu */ - action = addAction("S&hell"); - action->setIcon(QIcon(QPixmap(":/icons/shell.png"))); - connect(action, SIGNAL(triggered()), this, SLOT(slotShell())); + actionShell = addAction("S&hell"); + actionShell->setIcon(QIcon(QPixmap(":/icons/shell.png"))); + connect(actionShell, SIGNAL(triggered()), this, SLOT(slotShell())); /* Control Panel menu */ - action = addAction("Control &Panel"); - action->setIcon(QIcon(QPixmap(":/icons/control_panel.png"))); - connect(action, SIGNAL(triggered()), this, SLOT(slotControlPanel())); + actionControlPanel = addAction("Control &Panel"); + actionControlPanel->setIcon(QIcon(QPixmap(":/icons/control_panel.png"))); + connect(actionControlPanel, SIGNAL(triggered()), this, SLOT(slotControlPanel())); addSeparator(); /* Close menu */ - longPressTimer = new QTimer(this); - action = addAction("&Close"); - action->setIcon(QIcon(QPixmap(":/icons/close.png"))); - connect(action, SIGNAL(triggered()), this, SLOT(slotClose())); + actionClose = addAction("&Close"); + actionClose->setIcon(QIcon(QPixmap(":/icons/close.png"))); + connect(actionClose, SIGNAL(triggered()), this, SLOT(slotClose())); } bool ContextMenu::eventFilter(QObject *obj, QEvent *event) @@ -242,7 +249,7 @@ void ContextMenu::slotDetailedInfo() qDebug("VM info"); if (infoDialog == NULL) { - infoDialog = new DetailedInfoDialog((QWidget *)this->parent()); + infoDialog = new DetailedInfoDialog((QWidget *)parent); } infoDialog->show(); @@ -252,68 +259,60 @@ void ContextMenu::slotTopMost(bool on) { qDebug("stays on top : %s", on? "on" : "off"); - QWidget *win = (QWidget *)this->parent(); - #ifdef CONFIG_WIN32 - /* - if (on == true) { - win->setWindowFlags(win->windowFlags() | Qt::WindowStaysOnTopHint); - } else { - win->setWindowFlags(win->windowFlags() & ~(Qt::WindowStaysOnTopHint)); - } - - win->show(); - */ - HWND hWnd = (HWND)win->winId(); - HWND hWndInsertAfter = ( (on == true) ? HWND_TOPMOST : HWND_NOTOPMOST); - SetWindowPos(hWnd, hWndInsertAfter, win->pos().x(), win->pos().y(), 0, 0, SWP_NOSIZE); - win->show(); - + HWND hWnd = (HWND)parent->winId(); + HWND hWndInsertAfter = ((on == true) ? HWND_TOPMOST : HWND_NOTOPMOST); + SetWindowPos(hWnd, hWndInsertAfter, parent->pos().x(), parent->pos().y(), 0, 0, SWP_NOSIZE); #else - Display* display = XOpenDisplay (NULL); + Display* display = XOpenDisplay(NULL); if (display == NULL) { qDebug("Error: XOpenDisplay() Failed. Always on top failed."); return; } + XClientMessageEvent event; - memset(&event,0,sizeof(event)); + memset(&event, 0, sizeof(event)); event.type = ClientMessage; - event.window = win->winId(); - event.message_type = XInternAtom (display, "_NET_WM_STATE", False); + event.window = parent->winId(); + event.message_type = XInternAtom(display, "_NET_WM_STATE", False); event.format = 32; - event.data.l[0] = on ? 1 : 0; // 1:_NET_WM_STATE_ADD , 0:_NET_WM_STATE_REMOVE - event.data.l[1] = XInternAtom (display, "_NET_WM_STATE_ABOVE", False); - event.data.l[2] = 0; //unused. + event.data.l[0] = on ? 1 : 0; /* 1:_NET_WM_STATE_ADD, 0:_NET_WM_STATE_REMOVE */ + event.data.l[1] = XInternAtom(display, "_NET_WM_STATE_ABOVE", False); + event.data.l[2] = 0; /* unused */ event.data.l[3] = 0; event.data.l[4] = 0; - XSendEvent (display, DefaultRootWindow(display), False, SubstructureRedirectMask|SubstructureNotifyMask, (XEvent*)&event); + + XSendEvent(display, DefaultRootWindow(display), False, + SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&event); XFlush(display); + XCloseDisplay(display); #endif - + actionTopMost->setChecked(on); + parent->getUIState()->setOnTop(on); } void ContextMenu::slotRotate(int angle) { qDebug("rotate : %d", angle); - ((MainWindow *)this->parent())->rotate(angle); + parent->rotate(angle); } void ContextMenu::slotScale(int scale) { qDebug("scale : %d", scale); - ((MainWindow *)this->parent())->scale(scale); + parent->scale(scale); } void ContextMenu::slotController(int index) { qDebug("controller : %d", index); - MainWindow *win = ((MainWindow *)this->parent()); - win->openController(index, win->getUIState()->conState.recentlyDockPos); + parent->openController(index, + parent->getUIState()->conState.recentlyDockPos); } void ContextMenu::slotShell() @@ -325,7 +324,7 @@ void ContextMenu::slotShell() qDebug() << msg; QMessageBox *msgBox = new QMessageBox(QMessageBox::Information, - "Emulator", msg, QMessageBox::Ok, (QWidget*)this->parent()); + "Emulator", msg, QMessageBox::Ok, (QWidget*)parent); msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setModal(false); msgBox->show(); @@ -350,7 +349,7 @@ void ContextMenu::slotShell() qWarning() << msg; QMessageBox *msgBox = new QMessageBox(QMessageBox::Warning, - "Emulator", msg, QMessageBox::Ok, (QWidget*)this->parent()); + "Emulator", msg, QMessageBox::Ok, (QWidget*)parent); msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setModal(false); msgBox->show(); @@ -383,7 +382,7 @@ void ContextMenu::slotShell() qDebug() << msg; QMessageBox *msgBox = new QMessageBox(QMessageBox::Warning, - "Emulator", msg, QMessageBox::Ok ,(QWidget*)this->parent()); + "Emulator", msg, QMessageBox::Ok ,(QWidget*)parent); msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setModal(false); msgBox->show(); @@ -396,7 +395,7 @@ void ContextMenu::slotControlPanel() { qDebug("Control Panel"); - MainWindow *win = (MainWindow *)this->parent(); + MainWindow *win = (MainWindow *)parent; QString basePortOpt = "base.port=" + QString::number(win->uiInfo->basePort); QString vmNameOpt = "vmname=" + win->uiInfo->vmName; @@ -414,7 +413,7 @@ void ContextMenu::slotControlPanel() qWarning() << msg; QMessageBox *msgBox = new QMessageBox(QMessageBox::Warning, - "Emulator", msg, QMessageBox::Ok, (QWidget*)this->parent()); + "Emulator", msg, QMessageBox::Ok, (QWidget*)parent); msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setModal(false); msgBox->show(); @@ -442,7 +441,7 @@ void ContextMenu::slotControlPanel() qDebug() << msg; QMessageBox *msgBox = new QMessageBox(QMessageBox::Warning, - "Emulator", msg, QMessageBox::Ok, (QWidget*)this->parent()); + "Emulator", msg, QMessageBox::Ok, (QWidget*)parent); msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setModal(false); msgBox->show(); @@ -463,7 +462,7 @@ void ContextMenu::slotAbout() qDebug("about"); if (aboutDialog == NULL) { - aboutDialog = new AboutDialog((QWidget *)this->parent()); + aboutDialog = new AboutDialog((QWidget *)parent); } aboutDialog->show(); @@ -473,7 +472,7 @@ void ContextMenu::slotForceClose() { qDebug("force close"); - QMessageBox *msg = new QMessageBox((QWidget*)this->parent()); + QMessageBox *msg = new QMessageBox((QWidget*)parent); msg->setAttribute(Qt::WA_DeleteOnClose); msg->setWindowTitle("Emulator"); msg->setText("If you force stop an emulator, it may cause some problems.\n" @@ -508,10 +507,10 @@ void ContextMenu::slotClose() qDebug("close"); do_hw_key_event(KEY_PRESSED, HARD_KEY_POWER); - this->longPressTimer->setInterval(CLOSE_POWER_KEY_INTERVAL); - this->longPressTimer->setSingleShot(true); + longPressTimer->setInterval(CLOSE_POWER_KEY_INTERVAL); + longPressTimer->setSingleShot(true); connect(longPressTimer, SIGNAL(timeout()), this, SLOT(slotPwkeyRelease())); - this->longPressTimer->start(); + longPressTimer->start(); } QSignalMapper *ContextMenu::getRotateMapper() @@ -532,4 +531,6 @@ QSignalMapper *ContextMenu::getControllerMapper() ContextMenu::~ContextMenu() { qDebug("destroy menu"); + + longPressTimer->stop(); } diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h index 6738431012..c5ed7a6f8a 100644 --- a/tizen/src/ui/menu/contextmenu.h +++ b/tizen/src/ui/menu/contextmenu.h @@ -36,6 +36,8 @@ #include "detailedinfodialog.h" #include "aboutdialog.h" +class MainWindow; + extern "C" { #include "skin/maruskin_operation.h" #include "skin/maruskin_server.h" @@ -78,6 +80,8 @@ protected: bool eventFilter(QObject *obj, QEvent *event); private: + MainWindow *parent; + QString vmName; DetailedInfoDialog *infoDialog; AboutDialog *aboutDialog; @@ -86,5 +90,13 @@ private: QSignalMapper *rotateMapper; QSignalMapper *scaleMapper; QSignalMapper *controllerMapper; + + QAction *actionDetailedInfo; + QAction *actionTopMost; + QAction *actionShell; + QAction *actionControlPanel; + QAction *actionAbout; + QAction *actionForceClose; + QAction *actionClose; }; #endif // CONTEXTMENU_H diff --git a/tizen/src/ui/uistate.cpp b/tizen/src/ui/uistate.cpp index dff66fdad9..938d7c8588 100644 --- a/tizen/src/ui/uistate.cpp +++ b/tizen/src/ui/uistate.cpp @@ -32,6 +32,7 @@ UIState::UIState() : mainFormAngle(0), mainFormScale(100) { + onTop = false; conState.conFormIndex = 0; conState.dockingCon = NULL; conState.floatingCon = NULL; @@ -78,3 +79,15 @@ qreal UIState::getScaleFactor() { return getScaleFactor(this->mainFormScale); } + +void UIState::setOnTop(bool on) +{ + qDebug("set on top : %d", on); + + onTop = on; +} + +bool UIState::isOnTop() +{ + return onTop; +} diff --git a/tizen/src/ui/uistate.h b/tizen/src/ui/uistate.h index bbd99c56be..392881bf10 100644 --- a/tizen/src/ui/uistate.h +++ b/tizen/src/ui/uistate.h @@ -30,8 +30,6 @@ #ifndef UISTATE_H #define UISTATE_H -#include - #include "dockingcontroller.h" #include "floatingcontroller.h" @@ -59,10 +57,16 @@ public: qreal getScaleFactor(int scale); qreal getScaleFactor(); /* current */ + void setOnTop(bool on); + bool isOnTop(); + int mainFormAngle; int mainFormScale; /* percentage */ ControllerState conState; + +private: + bool onTop; }; #endif // UISTATE_H