From c8266b4d21c06a95ea86d7214e62069ad7d2c8b6 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Mon, 2 Feb 2015 21:05:38 +0900 Subject: [PATCH] ui: apply layout switching concept in place of rotation Change-Id: I88683f3ea3454aeab1e783e365b6c799b790002e Signed-off-by: GiWoong Kim --- tizen/src/display/xmllayoutparser.cpp | 46 +++++-- tizen/src/display/xmllayoutparser.h | 1 + tizen/src/ui/Makefile.objs | 1 + tizen/src/ui/controllerform.cpp | 5 + tizen/src/ui/controllerform.h | 6 +- tizen/src/ui/displaybase.cpp | 14 +- tizen/src/ui/displaytype.cpp | 46 +++++++ tizen/src/ui/displaytype.h | 49 +++++++ tizen/src/ui/floatingcontroller.cpp | 2 +- tizen/src/ui/mainform.cpp | 14 +- tizen/src/ui/mainform.h | 11 +- tizen/src/ui/mainwindow.cpp | 12 +- tizen/src/ui/mainwindow.h | 4 +- tizen/src/ui/menu/contextmenu.cpp | 61 +++------ tizen/src/ui/menu/contextmenu.h | 6 +- tizen/src/ui/menu/screenshot.cpp | 129 ++++++++++-------- tizen/src/ui/menu/screenshot.h | 28 ++-- .../resource/mobile-720x1280-3btn/layout.xml | 12 +- tizen/src/ui/skinview.cpp | 27 ++-- tizen/src/ui/skinview.h | 8 +- tizen/src/ui/uiinformation.cpp | 10 +- tizen/src/ui/uiinformation.h | 1 + tizen/src/ui/uistate.cpp | 29 +--- tizen/src/ui/uistate.h | 3 +- 24 files changed, 332 insertions(+), 193 deletions(-) create mode 100644 tizen/src/ui/displaytype.cpp create mode 100644 tizen/src/ui/displaytype.h diff --git a/tizen/src/display/xmllayoutparser.cpp b/tizen/src/display/xmllayoutparser.cpp index f2f2be8ced..f824aad511 100644 --- a/tizen/src/display/xmllayoutparser.cpp +++ b/tizen/src/display/xmllayoutparser.cpp @@ -59,6 +59,35 @@ QRect XmlLayoutParser::parseRegion(QXmlStreamReader &xml) return QRect(left, top, width, height); } +DisplayType *XmlLayoutParser::parseDisplay(QXmlStreamReader &xml) +{ + QRect displayRegion; + int angle = 0; + + QXmlStreamReader::TokenType token = xml.readNext(); + + while (xml.atEnd() == false && (xml.name() == "display" && + token == QXmlStreamReader::EndElement) == false) /* ~ */ + { + if (token == QXmlStreamReader::StartElement) { + if (xml.name() == "region") { + /* region */ + displayRegion = parseRegion(xml); + qDebug("- display : (%d,%d %dx%d)", + displayRegion.x(), displayRegion.y(), + displayRegion.width(), displayRegion.height()); + } else if (xml.name() == "angle") { + /* angle */ + angle = xml.readElementText().toInt(); + } + } + + token = xml.readNext(); + } + + return new DisplayType(displayRegion, angle); +} + HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml) { QString keyName; @@ -79,6 +108,7 @@ HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml) { if (token == QXmlStreamReader::StartElement) { if (xml.name() == "region") { + /* region */ keyRegion = parseRegion(xml); } else if (xml.name() == "keycode") { /* keycode */ @@ -122,14 +152,16 @@ int XmlLayoutParser::parseKeyList( MainForm *XmlLayoutParser::parseMainForm( QXmlStreamReader &xml, QString skinPath) { - MainForm *form = new MainForm(); + QString formName = ""; /* attribute */ QXmlStreamAttributes attributes = xml.attributes(); if (attributes.hasAttribute("name")) { - form->name = attributes.value("name").toString(); + formName = attributes.value("name").toString(); } + MainForm *form = new MainForm(formName); + QXmlStreamReader::TokenType token = xml.readNext(); while (xml.atEnd() == false && (xml.name() == "form" && @@ -137,13 +169,8 @@ MainForm *XmlLayoutParser::parseMainForm( { if (token == QXmlStreamReader::StartElement) { if (xml.name() == "display") { - xml.readNextStartElement(); - - /* region */ - form->displayRegion = parseRegion(xml); - qDebug("- display : (%d,%d %dx%d)", - form->displayRegion.x(), form->displayRegion.y(), - form->displayRegion.width(), form->displayRegion.height()); + /* display */ + form->displayType = parseDisplay(xml); } else if (xml.name() == "normalImage") { /* normal image */ QString normalImageFileName = xml.readElementText(); @@ -178,6 +205,7 @@ ControllerForm *XmlLayoutParser::parseControllerForm( { QString formName = ""; + /* attribute */ QXmlStreamAttributes attributes = xml.attributes(); if (attributes.hasAttribute("name")) { formName = attributes.value("name").toString(); diff --git a/tizen/src/display/xmllayoutparser.h b/tizen/src/display/xmllayoutparser.h index 223b6ddb93..c187eb511c 100644 --- a/tizen/src/display/xmllayoutparser.h +++ b/tizen/src/display/xmllayoutparser.h @@ -41,6 +41,7 @@ public: XmlLayoutParser(); QRect parseRegion(QXmlStreamReader &xml); + DisplayType *parseDisplay(QXmlStreamReader &xml); HardwareKey *parseKey(QXmlStreamReader &xml); int parseKeyList(QXmlStreamReader &xml, QList &list); MainForm *parseMainForm(QXmlStreamReader &xml, QString skinPath); diff --git a/tizen/src/ui/Makefile.objs b/tizen/src/ui/Makefile.objs index 641bea87b2..66a13983e1 100644 --- a/tizen/src/ui/Makefile.objs +++ b/tizen/src/ui/Makefile.objs @@ -17,6 +17,7 @@ obj-$(CONFIG_QT) += hardwarekey.o obj-$(CONFIG_QT) += mainwindow.o moc_mainwindow.o obj-$(CONFIG_QT) += skinbezelitem.o obj-$(CONFIG_QT) += skinkeyitem.o moc_skinkeyitem.o +obj-$(CONFIG_QT) += displaytype.o obj-$(CONFIG_QT) += mainform.o obj-$(CONFIG_QT) += keyboardhelper.o obj-$(CONFIG_QT) += skinview.o diff --git a/tizen/src/ui/controllerform.cpp b/tizen/src/ui/controllerform.cpp index 808d119d4c..7e6f47fcaf 100644 --- a/tizen/src/ui/controllerform.cpp +++ b/tizen/src/ui/controllerform.cpp @@ -34,6 +34,11 @@ ControllerForm::ControllerForm(QString name) this->name = name; } +QString ControllerForm::getName() +{ + return name; +} + ControllerForm::~ControllerForm() { qDebug("destroy con layout"); diff --git a/tizen/src/ui/controllerform.h b/tizen/src/ui/controllerform.h index 02c9b7393f..e6e2183486 100644 --- a/tizen/src/ui/controllerform.h +++ b/tizen/src/ui/controllerform.h @@ -42,7 +42,8 @@ public: ControllerForm(QString name); ~ControllerForm(); - QString name; + QString getName(); + QImage conImg[2]; QList keyList; @@ -50,6 +51,9 @@ public: normal = 0, pressed = 1 }; + +private: + QString name; }; #endif // CONTROLLERFORM_H diff --git a/tizen/src/ui/displaybase.cpp b/tizen/src/ui/displaybase.cpp index 344a165432..964f7737e5 100644 --- a/tizen/src/ui/displaybase.cpp +++ b/tizen/src/ui/displaybase.cpp @@ -36,15 +36,13 @@ uint32_t qt5_window_height = 0; int qt5_window_angle = 0; DisplayBase::DisplayBase(QSize resolution, QWidget *w) -: resolution(resolution), - widget(w), - isDragging(false) + : resolution(resolution), widget(w), isDragging(false) { /* initialize */ // TODO: compare display region with resolution MainWindow *win = ((MainWindow *)w->parent()->parent()); - rotateAngle = win->getUIState()->mainFormAngle; + rotateAngle = win->uiInfo->getMainFormDisplayType()->getAngle(); scaleFactor = win->getUIState()->getScaleFactor(); } @@ -98,10 +96,10 @@ void DisplayBase::handleResize(QResizeEvent *event) const qreal sx = scaleFactor; const qreal sy = scaleFactor; - widget->setGeometry(form->displayRegion.x() * sx, - form->displayRegion.y() * sy, - form->displayRegion.width() * sx, - form->displayRegion.height() * sy); + widget->setGeometry(form->displayType->region.x() * sx, + form->displayType->region.y() * sy, + form->displayType->region.width() * sx, + form->displayType->region.height() * sy); qt5_window_width = widget->width(); qt5_window_height = widget->height(); diff --git a/tizen/src/ui/displaytype.cpp b/tizen/src/ui/displaytype.cpp new file mode 100644 index 0000000000..90a708ff2a --- /dev/null +++ b/tizen/src/ui/displaytype.cpp @@ -0,0 +1,46 @@ +/* + * 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 "displaytype.h" + +DisplayType::DisplayType(QRect region, int angle) +{ + this->region = region; + this->angle = angle; +} + +int DisplayType::getAngle() +{ + return angle % 360; +} + +DisplayType::~DisplayType() +{ + /* do nothing */ +} diff --git a/tizen/src/ui/displaytype.h b/tizen/src/ui/displaytype.h new file mode 100644 index 0000000000..7e2bb35179 --- /dev/null +++ b/tizen/src/ui/displaytype.h @@ -0,0 +1,49 @@ +/* + * 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 DISPLAYTYPE_H +#define DISPLAYTYPE_H + +#include + +class DisplayType +{ +public: + DisplayType(QRect region, int angle); + ~DisplayType(); + + int getAngle(); + + QRect region; + +private: + int angle; +}; + +#endif // DISPLAYTYPE_H diff --git a/tizen/src/ui/floatingcontroller.cpp b/tizen/src/ui/floatingcontroller.cpp index 0616eff4e7..f37ef6a25c 100644 --- a/tizen/src/ui/floatingcontroller.cpp +++ b/tizen/src/ui/floatingcontroller.cpp @@ -40,7 +40,7 @@ FloatingController::FloatingController(ControllerForm *conForm, setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog); setAttribute(Qt::WA_DeleteOnClose); - setWindowTitle(conForm->name); + setWindowTitle(conForm->getName()); QHBoxLayout *layout = new QHBoxLayout(this); layout->setMargin(0); diff --git a/tizen/src/ui/mainform.cpp b/tizen/src/ui/mainform.cpp index c707786292..6bb55237b8 100644 --- a/tizen/src/ui/mainform.cpp +++ b/tizen/src/ui/mainform.cpp @@ -29,15 +29,25 @@ #include "mainform.h" -MainForm::MainForm() : - displayRegion(0, 0, 0, 0) +MainForm::MainForm(QString name) { + this->name = name; + this->displayType = NULL; +} + +QString MainForm::getName() +{ + return name; } MainForm::~MainForm() { qDebug("destroy main form"); + if (displayType != NULL) { + delete displayType; + } + for (int i = 0; i < keyList.count(); i++) { delete keyList.at(i); } diff --git a/tizen/src/ui/mainform.h b/tizen/src/ui/mainform.h index c53ce68654..4462277998 100644 --- a/tizen/src/ui/mainform.h +++ b/tizen/src/ui/mainform.h @@ -32,6 +32,7 @@ #include +#include "displaytype.h" #include "hardwarekey.h" class MainForm @@ -39,18 +40,22 @@ class MainForm Q_ENUMS(SkinImgType) public: - MainForm(); + MainForm(QString name); ~MainForm(); - QString name; + QString getName(); + + DisplayType *displayType; QImage skinImg[2]; - QRect displayRegion; QList keyList; enum SkinImgType { normal = 0, pressed = 1 }; + +private: + QString name; }; #endif // MAINFORM_H diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index 2646346ebb..e7f1bc15e8 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -309,19 +309,19 @@ void MainWindow::setRegion() setMask(uiInfo->getUiRegion()); } -void MainWindow::rotate(int angle) +void MainWindow::switchForm(int index) { - qDebug("window rotate : %d", angle); + qDebug("window switch : %d", index); - getUIState()->mainFormAngle = angle; + getUIState()->mainFormIndex = index; - skinView->rotate(); - display->rotate(getUIState()->mainFormAngle); + skinView->update(); + display->rotate(uiInfo->getMainFormDisplayType()->getAngle()); adjustSize(); } -void MainWindow::scale(int scale) +void MainWindow::scaleForm(int scale) { qDebug("window scale : %d", scale); diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h index 6fa2563c88..75cfd36940 100644 --- a/tizen/src/ui/mainwindow.h +++ b/tizen/src/ui/mainwindow.h @@ -75,8 +75,8 @@ public: UIState *getUIState(void); QLabel *getScreenWidget(); - void rotate(int angle); - void scale(int scale); + void switchForm(int angle); + void scaleForm(int scale); void capture(void); void setCaptureRequestHandler(void *data, void (*handler)(void *)); void unsetCaptureRequestHandler(void *data); diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index 85f40024a1..e5d255e423 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -81,37 +81,21 @@ void ContextMenu::createItems() { connect(actionTopMost, SIGNAL(triggered(bool)), this, SLOT(slotTopMost(bool))); /* = Rotate menu = */ - if (win->uiInfo->mainFormList.count() > 1) { - QMenu *rotateMenu = addMenu(QIcon(QPixmap(":/icons/rotate.png")), "&Rotate"); - QActionGroup *rotateGroup = new QActionGroup(this); - rotateMapper = new QSignalMapper(this); - connect(rotateMapper, SIGNAL(mapped(int)), this, SLOT(slotRotate(int))); - - action = rotateMenu->addAction("Portrait"); - action->setActionGroup(rotateGroup); - action->setCheckable(true); - rotateMapper->setMapping(action, 0); - connect(action, SIGNAL(triggered()), rotateMapper, SLOT(map())); - - action = rotateMenu->addAction("Landscape"); - action->setActionGroup(rotateGroup); - action->setCheckable(true); - rotateMapper->setMapping(action, 270); - connect(action, SIGNAL(triggered()), rotateMapper, SLOT(map())); - - action = rotateMenu->addAction("Reverse Portrait"); - action->setActionGroup(rotateGroup); - action->setCheckable(true); - rotateMapper->setMapping(action, 180); - connect(action, SIGNAL(triggered()), rotateMapper, SLOT(map())); - - action = rotateMenu->addAction("Reverse Landscape"); - action->setActionGroup(rotateGroup); - action->setCheckable(true); - rotateMapper->setMapping(action, 90); - connect(action, SIGNAL(triggered()), rotateMapper, SLOT(map())); + if (win->uiInfo->mainFormList.isEmpty() == false) { + QMenu *switchMenu = addMenu(QIcon(QPixmap(":/icons/rotate.png")), "&Rotate"); + QActionGroup *switchGroup = new QActionGroup(this); + switchMapper = new QSignalMapper(this); + connect(switchMapper, SIGNAL(mapped(int)), this, SLOT(slotSwitch(int))); + + for (int i = 0; i < win->uiInfo->mainFormList.count(); i++) { + action = switchMenu->addAction(win->uiInfo->mainFormList.at(i)->getName()); + action->setActionGroup(switchGroup); + action->setCheckable(true); + switchMapper->setMapping(action, i); + connect(action, SIGNAL(triggered()), switchMapper, SLOT(map())); + } - action = (QAction *)rotateMapper->mapping(win->getUIState()->mainFormAngle); + action = (QAction *)switchMapper->mapping(win->getUIState()->getMainFormIndex()); action->setChecked(true); } /* =============== */ @@ -153,9 +137,8 @@ void ContextMenu::createItems() { /* ============== */ /* = Controller menu = */ - QMenu *controllerMenu = NULL; if (win->uiInfo->conFormList.isEmpty() == false) { - controllerMenu = addMenu("Controller"); + QMenu *controllerMenu = addMenu("Controller"); QActionGroup *controllerGroup = new QActionGroup(this); controllerMapper = new QSignalMapper(this); connect(controllerMapper, SIGNAL(mapped(int)), this, SLOT(slotController(int))); @@ -167,7 +150,7 @@ void ContextMenu::createItems() { connect(action, SIGNAL(triggered()), this, SLOT(slotCloseCon())); for (int i = 0; i < win->uiInfo->conFormList.count(); i++) { - action = controllerMenu->addAction(win->uiInfo->conFormList.at(i)->name); + action = controllerMenu->addAction(win->uiInfo->conFormList.at(i)->getName()); action->setActionGroup(controllerGroup); action->setCheckable(true); controllerMapper->setMapping(action, i); @@ -306,18 +289,18 @@ void ContextMenu::slotTopMost(bool on) parent->getUIState()->setOnTop(on); } -void ContextMenu::slotRotate(int angle) +void ContextMenu::slotSwitch(int index) { - qDebug("rotate : %d", angle); + qDebug("switch : %d", index); - parent->rotate(angle); + parent->switchForm(index); } void ContextMenu::slotScale(int scale) { qDebug("scale : %d", scale); - parent->scale(scale); + parent->scaleForm(scale); } void ContextMenu::slotController(int index) @@ -640,9 +623,9 @@ void ContextMenu::slotClose() longPressTimer->start(); } -QSignalMapper *ContextMenu::getRotateMapper() +QSignalMapper *ContextMenu::getSwitchMapper() { - return rotateMapper; + return switchMapper; } QSignalMapper *ContextMenu::getScaleMapper() diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h index 33a2b1d5d9..3ee839956b 100644 --- a/tizen/src/ui/menu/contextmenu.h +++ b/tizen/src/ui/menu/contextmenu.h @@ -55,7 +55,7 @@ public: explicit ContextMenu(QWidget *parent = 0); ~ContextMenu(); - QSignalMapper *getRotateMapper(); + QSignalMapper *getSwitchMapper(); QSignalMapper *getScaleMapper(); QSignalMapper *getControllerMapper(); Screenshot *screenshotDialog; @@ -65,7 +65,7 @@ signals: public slots: void slotDetailedInfo(); void slotTopMost(bool on); - void slotRotate(int angle); + void slotSwitch(int index); void slotScale(int scale); void slotController(int index); void slotCloseCon(); @@ -92,7 +92,7 @@ private: AboutDialog *aboutDialog; QTimer *longPressTimer; - QSignalMapper *rotateMapper; + QSignalMapper *switchMapper; QSignalMapper *scaleMapper; QSignalMapper *controllerMapper; diff --git a/tizen/src/ui/menu/screenshot.cpp b/tizen/src/ui/menu/screenshot.cpp index c672cd45de..8456608cea 100644 --- a/tizen/src/ui/menu/screenshot.cpp +++ b/tizen/src/ui/menu/screenshot.cpp @@ -27,25 +27,54 @@ * */ -#include #include + #include "screenshot.h" #include "screenshotview.h" #include "mainwindow.h" -void Screenshot::copy() { +Screenshot::Screenshot(QWidget *parent, const QPixmap &pixmap) : + QDialog(parent), screenshotPixmap(pixmap) +{ + this->win = (MainWindow *)parent->parent(); + + QString vmname = win->uiInfo->vmName + " : " + + QString::number(get_device_serial_number()); + resize(win->uiInfo->getMainSize()); + setWindowTitle("Screen Shot - " + vmname); + + createItems(); + + setImage(); + + toolbar->addAction(saveAct); + toolbar->addAction(copyAct); + toolbar->addAction(refreshAct); + toolbar->addWidget(slider); + gridlayout->addWidget(toolbar, 0, 0); + gridlayout->addWidget(view, 1, 0); + gridlayout->addWidget(statusBar, 2, 0); + + this->setLayout(gridlayout); +} + +void Screenshot::copy() +{ qDebug("copy"); + QClipboard* clipboard = QApplication::clipboard(); QPixmap pixmap(screenshotPixmap); clipboard->clear(); clipboard->setPixmap(pixmap); } -QString Screenshot::getRatio() { +QString Screenshot::getRatio() +{ return ratioStr; } -void Screenshot::setRatio(int level) { +void Screenshot::setRatio(int level) +{ switch (level) { case 0: ratio = 0.125; @@ -69,23 +98,28 @@ void Screenshot::setRatio(int level) { ratioStr = QString::number(ratio * 100).append("%"); } -void Screenshot::scaleChanged(int level) { +void Screenshot::scaleChanged(int level) +{ qDebug("scale changed: %d", level); + sliderLevel = level; QPixmap pixmap(screenshotPixmap); setRatio(level); scene->clear(); - scene->addPixmap(pixmap.scaled(pixmap.size() * ratio, Qt::KeepAspectRatio, Qt::FastTransformation)); + scene->addPixmap(pixmap.scaled(pixmap.size() * ratio, + Qt::KeepAspectRatio, Qt::FastTransformation)); slider->setToolTip(ratioStr); updateStatusBar(); } -int Screenshot::getSliderLevel() { +int Screenshot::getSliderLevel() +{ return sliderLevel; } -void Screenshot::refresh(const QPixmap &pixmap) { +void Screenshot::refresh(const QPixmap &pixmap) +{ qDebug("refresh"); this->frameBuf = pixmap; @@ -95,6 +129,7 @@ void Screenshot::refresh(const QPixmap &pixmap) { slider->setValue(3); scene->clear(); + // TODO: once QMatrix rm; rm.rotate(getRotateAngle()); screenshotPixmap = screenshotPixmap.transformed(rm); @@ -102,31 +137,34 @@ void Screenshot::refresh(const QPixmap &pixmap) { slider->setToolTip(ratioStr); } -void Screenshot::setStatusBar(qreal posX, qreal posY) { - this->posX = QString::number(posX); - this->posY = QString::number(posY); +void Screenshot::setStatusBar(qreal xx, qreal yy) +{ + posX = QString::number(xx); + posY = QString::number(yy); - statusBar->showMessage("x: " + this->posX + ", y:" + this->posY - + " (Resolution: " + QString::number(screenshotPixmap.width()) + "x" + QString::number(screenshotPixmap.height()) - + ", " + qPrintable(getRatio()) + ")"); + updateStatusBar(); } -void Screenshot::updateStatusBar() { - statusBar->showMessage("x: " + this->posX + ", y:" + this->posY - + " (Resolution: " + QString::number(screenshotPixmap.width()) + "x" + QString::number(screenshotPixmap.height()) - + ", " + qPrintable(getRatio()) + ")"); +void Screenshot::updateStatusBar() +{ + statusBar->showMessage("x: " + posX + ", y:" + posY + + " (" + QString::number(screenshotPixmap.width()) + + "x" + QString::number(screenshotPixmap.height()) + + ", " + qPrintable(getRatio()) + ")"); } -bool Screenshot::save() { +bool Screenshot::save() +{ qDebug("save"); - QString vmname = ((MainWindow *) this->parent()->parent())->uiInfo->vmName; + + QString vmname = win->uiInfo->vmName; QDateTime currentDateTime = QDateTime::currentDateTime(); QString date = currentDateTime.toString("yyyy-MM-dd-HHmmss"); QString defaultFile = QDir::homePath() + QDir::separator() + vmname + "-" + date + ".png"; QString filterName = "Image files (*.png *.jpg *.jpeg *.bmp)"; QString filename = QFileDialog::getSaveFileName(this, "Save Image", defaultFile, filterName); - if(filename.isEmpty()) { + if (filename.isEmpty()) { qDebug("can not have file"); return false; } else { @@ -137,15 +175,14 @@ bool Screenshot::save() { } } -int Screenshot::getRotateAngle() { - int rotateAngle = ((MainWindow *)(this->parent()->parent()))->getUIState()->mainFormAngle; - // Too many logs are printed while mouse is moved. - // Thus comment out this line. - //qDebug("rotatedAngle: %d", rotateAngle); - return rotateAngle; +int Screenshot::getRotateAngle() +{ + return win->uiInfo->getMainFormDisplayType()->getAngle(); } -void Screenshot::makeWidgets() { +void Screenshot::createItems() +{ + statusBar = new QStatusBar(); toolbar = new QToolBar(this); slider = new QSlider(Qt::Horizontal, this); @@ -179,7 +216,8 @@ void Screenshot::makeWidgets() { SLOT(slotRequestScreenshot())); } -void Screenshot::setImage() { +void Screenshot::setImage() +{ scene = new QGraphicsScene(this); qDebug() << screenshotPixmap; @@ -201,40 +239,19 @@ void Screenshot::setImage() { view->horizontalScrollBar()->setValue(1); } -Screenshot::Screenshot(QWidget *parent, const QPixmap &pixmap) : - QDialog(parent), screenshotPixmap(pixmap) { - QString vmname = ((MainWindow *) parent->parent())->uiInfo->vmName + " : " - + QString::number(get_device_serial_number()); - MainWindow *mainWindow = (MainWindow *) parent->parent(); - this->resize(mainWindow->uiInfo->getMainSize()); - setWindowTitle("Screen Shot - " + vmname); - - makeWidgets(); - - setImage(); - - statusBar = new QStatusBar; - - toolbar->addAction(saveAct); - toolbar->addAction(copyAct); - toolbar->addAction(refreshAct); - toolbar->addWidget(slider); - gridlayout->addWidget(toolbar, 0, 0); - gridlayout->addWidget(view, 1, 0); - gridlayout->addWidget(statusBar, 2, 0); - - this->setLayout(gridlayout); -} - -void Screenshot::showEvent(QShowEvent *event) { +void Screenshot::showEvent(QShowEvent *event) +{ Q_UNUSED(event) + // TODO: QWidget *win = ((QWidget *) this->parent()); move(win->geometry().center().x(), win->geometry().center().y() - (geometry().size().height() / 2)); } -Screenshot::~Screenshot() { +Screenshot::~Screenshot() +{ qDebug("distructor"); + ((ContextMenu *)this->parent())->screenshotDialog = NULL; } diff --git a/tizen/src/ui/menu/screenshot.h b/tizen/src/ui/menu/screenshot.h index ff111af2f6..d132e09048 100644 --- a/tizen/src/ui/menu/screenshot.h +++ b/tizen/src/ui/menu/screenshot.h @@ -32,16 +32,21 @@ #include -class Screenshot: public QDialog { -Q_OBJECT +class MainWindow; + +class Screenshot : public QDialog +{ + Q_OBJECT public: explicit Screenshot(QWidget *me, const QPixmap &screenshot); ~Screenshot(); - void setStatusBar(qreal posX, qreal poxY); + + void setStatusBar(qreal xx, qreal yy); int getSliderLevel(); int getRotateAngle(); QString getRatio(); + QPixmap frameBuf; public slots: @@ -51,24 +56,20 @@ protected: void showEvent(QShowEvent *event); QGraphicsScene* scene; -private slots: - bool save(); - void copy(); - void scaleChanged(int level); - private: - void makeWidgets(); + void createItems(); void setImage(); void setRatio(int level); void updateStatusBar(); + MainWindow *win; QString posX; QString posY; QGridLayout *gridlayout; QGraphicsView* view; int sliderLevel; QLabel *label; - QSlider* slider; + QSlider *slider; QPixmap screenshotPixmap; QToolBar *toolbar; @@ -82,6 +83,11 @@ private: QAction *saveAct; QAction *copyAct; QAction *refreshAct; + +private slots: + bool save(); + void copy(); + void scaleChanged(int level); }; -#endif +#endif // SCREENSHOT_H diff --git a/tizen/src/ui/resource/mobile-720x1280-3btn/layout.xml b/tizen/src/ui/resource/mobile-720x1280-3btn/layout.xml index 1dc0a1c798..3516246c07 100644 --- a/tizen/src/ui/resource/mobile-720x1280-3btn/layout.xml +++ b/tizen/src/ui/resource/mobile-720x1280-3btn/layout.xml @@ -3,8 +3,9 @@ 2.4
- + + 0 default_0.png default_0_p.png @@ -42,8 +43,9 @@
- + + 270 default_L90.png default_L90_p.png @@ -81,8 +83,9 @@
- + + 180 default_180.png default_180_p.png @@ -120,8 +123,9 @@
- + + 90 default_R90.png default_R90_p.png diff --git a/tizen/src/ui/skinview.cpp b/tizen/src/ui/skinview.cpp index c06f7566a1..33bbc0dc57 100644 --- a/tizen/src/ui/skinview.cpp +++ b/tizen/src/ui/skinview.cpp @@ -42,19 +42,17 @@ SkinView::SkinView(QGraphicsScene *scene, QWidget *parent) : setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setAlignment(Qt::AlignLeft | Qt::AlignTop); - grabWinPos = QPoint(-1, -1); - grabPos = QPoint(-1, -1); + this->win = ((MainWindow *)parent); + this->grabWinPos = QPoint(-1, -1); + this->grabPos = QPoint(-1, -1); - createItems(); + createItems(win->uiInfo->getMainForm()); kbd = new KeyboardHelper(); } -void SkinView::createItems() +void SkinView::createItems(MainForm *form) { - MainWindow *win = ((MainWindow *)this->parent()); - MainForm *form = win->uiInfo->getMainForm(); - /* bezel */ SkinBezelItem *bezelItem = new SkinBezelItem(form->skinImg[MainForm::normal]); scene()->addItem(bezelItem); @@ -72,10 +70,11 @@ void SkinView::createItems() } } -void SkinView::rotate() +void SkinView::update() { scene()->clear(); - createItems(); + + createItems(win->uiInfo->getMainForm()); adjustSize(); } @@ -86,8 +85,6 @@ void SkinView::resizeEvent(QResizeEvent *event) qDebug("resize skin view"); - MainWindow *win = ((MainWindow *)this->parent()); - /* geometry */ const int width = win->uiInfo->getUiSize().width(); const int height = win->uiInfo->getUiSize().height(); @@ -132,8 +129,6 @@ void SkinView::mouseReleaseEvent(QMouseEvent *event) void SkinView::mouseMoveEvent(QMouseEvent *event) { - QWidget *win = ((QWidget *)this->parent()); - if (grabPos != QPoint(-1, -1)) { win->move(grabWinPos + (event->globalPos() - grabPos)); } @@ -144,17 +139,17 @@ void SkinView::mouseMoveEvent(QMouseEvent *event) void SkinView::focusOutEvent(QFocusEvent *event) { qDebug() << "focus out!"; - this->kbd->autoKeyRelease(); + kbd->autoKeyRelease(); } void SkinView::keyPressEvent(QKeyEvent *event) { - this->kbd->keyPressed(event); + kbd->keyPressed(event); } void SkinView::keyReleaseEvent(QKeyEvent *event) { - this->kbd->keyReleased(event); + kbd->keyReleased(event); } SkinView::~SkinView() diff --git a/tizen/src/ui/skinview.h b/tizen/src/ui/skinview.h index abbdc42303..b89e08631e 100644 --- a/tizen/src/ui/skinview.h +++ b/tizen/src/ui/skinview.h @@ -32,15 +32,18 @@ #include +#include "mainform.h" #include "keyboardhelper.h" +class MainWindow; + class SkinView : public QGraphicsView { public: SkinView(QGraphicsScene *scene, QWidget *parent = 0); ~SkinView(); - void rotate(); + void update(); protected: void resizeEvent(QResizeEvent *event); @@ -52,12 +55,13 @@ protected: void keyReleaseEvent(QKeyEvent *event); void focusOutEvent(QFocusEvent *event); + MainWindow *win; QPoint grabWinPos; QPoint grabPos; KeyboardHelper *kbd; private: - void createItems(); + void createItems(MainForm *form); }; #endif // SKINVIEW_H diff --git a/tizen/src/ui/uiinformation.cpp b/tizen/src/ui/uiinformation.cpp index 0b7e878eb9..aae6c92550 100644 --- a/tizen/src/ui/uiinformation.cpp +++ b/tizen/src/ui/uiinformation.cpp @@ -36,6 +36,7 @@ UIInformation::UIInformation() : skinPath = "./"; } +/* form */ MainForm *UIInformation::getMainForm() { int index = uiState.getMainFormIndex(); @@ -43,12 +44,17 @@ MainForm *UIInformation::getMainForm() if (index > (mainFormList.count() - 1) || index < 0) { qWarning("invalid form found"); - uiState.mainFormAngle = 0; + uiState.mainFormIndex = 0; } return mainFormList.at(index); } +DisplayType *UIInformation::getMainFormDisplayType() +{ + return getMainForm()->displayType; +} + ControllerForm *UIInformation::getConForm() { int index = uiState.conState.getConFormIndex(); @@ -62,6 +68,7 @@ ControllerForm *UIInformation::getConForm() return conFormList.at(index); } +/* size */ QSize UIInformation::getMainSize() { MainForm *mainForm = getMainForm(); @@ -97,6 +104,7 @@ QSize UIInformation::getUiSize() return uiSize; } +/* region */ QRegion UIInformation::getMainRegion() { MainForm *mainForm = getMainForm(); diff --git a/tizen/src/ui/uiinformation.h b/tizen/src/ui/uiinformation.h index 14e7fa3225..4c172b960d 100644 --- a/tizen/src/ui/uiinformation.h +++ b/tizen/src/ui/uiinformation.h @@ -56,6 +56,7 @@ public: UIState uiState; /* runtime information */ MainForm *getMainForm(); /* current */ + DisplayType *getMainFormDisplayType(); ControllerForm *getConForm(); QSize getMainSize(); QSize getConSize(); diff --git a/tizen/src/ui/uistate.cpp b/tizen/src/ui/uistate.cpp index 938d7c8588..7fed73ae05 100644 --- a/tizen/src/ui/uistate.cpp +++ b/tizen/src/ui/uistate.cpp @@ -30,7 +30,7 @@ #include "uistate.h" UIState::UIState() : - mainFormAngle(0), mainFormScale(100) + mainFormIndex(0), mainFormScale(100) { onTop = false; conState.conFormIndex = 0; @@ -40,34 +40,9 @@ UIState::UIState() : conState.recentlyFloatPos = QPoint(-1, -1); } -int UIState::getMainFormIndex(int angle) -{ - // TODO: map - - int index = 0; - - switch(angle) { - case 90: /* Reverse Landscape */ - index = 3; - break; - case 180: /* Reverse Portrait */ - index = 2; - break; - case 270: /* Landscape */ - index = 1; - break; - case 0: - default: - index = 0; - break; - } - - return index; -} - int UIState::getMainFormIndex() { - return getMainFormIndex(mainFormAngle); + return mainFormIndex; } qreal UIState::getScaleFactor(int scale) diff --git a/tizen/src/ui/uistate.h b/tizen/src/ui/uistate.h index 392881bf10..a77e9c507d 100644 --- a/tizen/src/ui/uistate.h +++ b/tizen/src/ui/uistate.h @@ -52,7 +52,6 @@ class UIState public: UIState(); - int getMainFormIndex(int angle); int getMainFormIndex(); /* current */ qreal getScaleFactor(int scale); qreal getScaleFactor(); /* current */ @@ -60,7 +59,7 @@ public: void setOnTop(bool on); bool isOnTop(); - int mainFormAngle; + int mainFormIndex; int mainFormScale; /* percentage */ ControllerState conState; -- 2.34.1