summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasiliy Ulyanov <v.ulyanov@samsung.com>2014-10-17 11:52:35 +0400
committerVasiliy Ulyanov <v.ulyanov@samsung.com>2014-11-05 10:10:56 +0300
commit74a46818f05112884b668827e137cdcff1045814 (patch)
treefcedaab743448b2d082ad6b2e4fce772038d74f5
parent63e9157f842b6e4f0a8fa145138d2873ecc1fc96 (diff)
downloadqemu-74a46818f05112884b668827e137cdcff1045814.tar.gz
qemu-74a46818f05112884b668827e137cdcff1045814.tar.bz2
qemu-74a46818f05112884b668827e137cdcff1045814.zip
Qt5 skin: integrate with VIGS capture interface
Change-Id: I9511d9ab981d75f1caf65a8b587c1591d0b0854a Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
-rw-r--r--hw/vigs/vigs_qt5.cpp12
-rw-r--r--tizen/src/display/qt5_supplement.cpp31
-rw-r--r--tizen/src/ui/mainwindow.cpp42
-rw-r--r--tizen/src/ui/mainwindow.h7
-rw-r--r--tizen/src/ui/menu/contextmenu.cpp11
-rw-r--r--tizen/src/ui/menu/contextmenu.h1
6 files changed, 98 insertions, 6 deletions
diff --git a/hw/vigs/vigs_qt5.cpp b/hw/vigs/vigs_qt5.cpp
index 7bef344997..e31184dc16 100644
--- a/hw/vigs/vigs_qt5.cpp
+++ b/hw/vigs/vigs_qt5.cpp
@@ -38,6 +38,12 @@ extern QApplication *qt5App;
extern QOpenGLContext *qt5GLContext;
extern QSurfaceFormat qt5GLFormat;
+extern void qt5_register_capture_request_listener(void *listener,
+ void (*handler)(void *));
+extern void qt5_unregister_capture_request_listener(void *listener);
+extern void qt5_process_captured(bool captured, void *pixels,
+ int width, int height);
+
bool vigs_qt5_enabled(void)
{
return qt5App != NULL;
@@ -142,16 +148,16 @@ void *vigs_qt5_gl_context_create(bool is_gl2)
void vigs_qt5_register_capture_request_listener(void *listener,
void (*handler)(void *))
{
- /* TODO implement: mainwin->register() */
+ qt5_register_capture_request_listener(listener, handler);
}
void vigs_qt5_unregister_capture_request_listener(void *listener)
{
- /* TODO implement: mainwin->unregister() */
+ qt5_unregister_capture_request_listener(listener);
}
void vigs_qt5_process_captured(bool captured, void *pixels,
int width, int height)
{
- /* TODO implement: mainwin->process() */
+ qt5_process_captured(captured, pixels, width, height);
}
diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp
index b5bb7188ca..b21bc447e1 100644
--- a/tizen/src/display/qt5_supplement.cpp
+++ b/tizen/src/display/qt5_supplement.cpp
@@ -55,6 +55,9 @@ QApplication *qt5App = NULL;
static int argc = 0;
static char *argv[0];
+static void *captureRequestListener;
+static void (*captureRequestHandler)(void *);
+
static MainWindow *mainwindow;
static UIInformation *uiInfo;
@@ -173,6 +176,7 @@ void qt5_gui_init(void)
qDebug("start!");
mainwindow = new MainWindow(uiInfo);
+ mainwindow->setCaptureRequestHandler(captureRequestListener, captureRequestHandler);
/* position */
QRect hostBounds = UIUtil::getHostScreenBounds();
@@ -288,6 +292,33 @@ void qt5_refresh_internal(void)
qt5App->processEvents();
}
+void qt5_register_capture_request_listener(void *listener, void (*handler)(void *))
+{
+ if (mainwindow) {
+ mainwindow->setCaptureRequestHandler(listener, handler);
+ }
+
+ captureRequestListener = listener;
+ captureRequestHandler = handler;
+}
+
+void qt5_unregister_capture_request_listener(void *listener)
+{
+ if (mainwindow) {
+ mainwindow->unsetCaptureRequestHandler(listener);
+ }
+
+ captureRequestListener = NULL;
+ captureRequestHandler = NULL;
+}
+
+void qt5_process_captured(bool captured, void *pixels, int width, int height)
+{
+ if (mainwindow) {
+ mainwindow->processCaptured(captured, pixels, width, height);
+ }
+}
+
void qMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp
index c00cc2dd36..d514824774 100644
--- a/tizen/src/ui/mainwindow.cpp
+++ b/tizen/src/ui/mainwindow.cpp
@@ -81,6 +81,9 @@ MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent)
skinView = NULL;
display = NULL;
+ captureRequestHandler = NULL;
+ captureRequestData = NULL;
+
/* windowing */
setWindowTitle("Emulator");
setWindowIcon(QIcon(QPixmap(":/icons/emulator_icon.ico")));
@@ -323,6 +326,45 @@ void MainWindow::scale(int scale)
adjustSize();
}
+void MainWindow::capture(void)
+{
+ qDebug("window screen capture: handler(%p), data(%p)",
+ captureRequestHandler, captureRequestData);
+
+ if (captureRequestHandler && captureRequestData) {
+ captureRequestHandler(captureRequestData);
+ }
+}
+
+void MainWindow::setCaptureRequestHandler(void *data, void (*handler)(void *))
+{
+ captureRequestHandler = handler;
+ captureRequestData = data;
+}
+
+void MainWindow::unsetCaptureRequestHandler(void *data)
+{
+ captureRequestHandler = NULL;
+ captureRequestData = NULL;
+}
+
+void MainWindow::processCaptured(bool captured, void *pixels,
+ int width, int height)
+{
+ qDebug("window process captured: %d %p[%dx%d]",
+ captured, pixels, width, height);
+
+ if (captured) {
+ /* TODO Perform what is needed here */
+ QString path("/tmp/screenshot.png");
+ QImage image = QImage((uchar *)pixels, width, height,
+ QImage::Format_RGB32);
+ bool saved = image.save(path, "PNG");
+
+ qDebug() << path << " " << saved;
+ }
+}
+
void MainWindow::setTopMost(bool on)
{
popupMenu->slotTopMost(on);
diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h
index 4a636403dc..6b50dcec6b 100644
--- a/tizen/src/ui/mainwindow.h
+++ b/tizen/src/ui/mainwindow.h
@@ -76,6 +76,10 @@ public:
UIState *getUIState(void);
void rotate(int angle);
void scale(int scale);
+ void capture(void);
+ void setCaptureRequestHandler(void *data, void (*handler)(void *));
+ void unsetCaptureRequestHandler(void *data);
+ void processCaptured(bool captured, void *pixels, int width, int height);
void setTopMost(bool on);
DockingController *getDockingCon();
FloatingController *getFloatingCon();
@@ -107,6 +111,9 @@ private:
QThread *swapperThread;
DisplaySwapper *swapper;
+
+ void (*captureRequestHandler)(void *data);
+ void *captureRequestData;
};
#endif // MAINWINDOW_H
diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp
index 2ec3c081c9..cec6373eea 100644
--- a/tizen/src/ui/menu/contextmenu.cpp
+++ b/tizen/src/ui/menu/contextmenu.cpp
@@ -181,12 +181,10 @@ void ContextMenu::createItems() {
/* = Advanced menu = */
QMenu *advancedMenu = addMenu(QIcon(QPixmap(":/icons/advanced.png")), "Ad&vanced");
-#if 0
/* Advanced > Screen Shot menu */
action = advancedMenu->addAction("Screen Shot");
action->setIcon(QIcon(QPixmap(":/icons/screen_shot.png")));
- // TODO:
-#endif
+ connect(action, SIGNAL(triggered()), this, SLOT(slotScreenshot()));
/* = Host Keyboard menu = */
QMenu *keyboardMenu = advancedMenu->addMenu(
@@ -468,6 +466,13 @@ void ContextMenu::slotControlPanel()
}
}
+void ContextMenu::slotScreenshot()
+{
+ qDebug("screenshot");
+
+ parent->capture();
+}
+
void ContextMenu::slotHostKeyboard(bool on)
{
qDebug("host keyboard : %s", on? "on" : "off");
diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h
index 2edb4321ce..a8e4212f88 100644
--- a/tizen/src/ui/menu/contextmenu.h
+++ b/tizen/src/ui/menu/contextmenu.h
@@ -69,6 +69,7 @@ public slots:
void slotCloseCon();
void slotShell();
void slotControlPanel();
+ void slotScreenshot();
void slotHostKeyboard(bool on);
void slotAbout();
void slotForceClose();