summaryrefslogtreecommitdiff
path: root/tizen/src/ui/generalskinview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tizen/src/ui/generalskinview.cpp')
-rw-r--r--tizen/src/ui/generalskinview.cpp125
1 files changed, 125 insertions, 0 deletions
diff --git a/tizen/src/ui/generalskinview.cpp b/tizen/src/ui/generalskinview.cpp
new file mode 100644
index 0000000000..1a8afad351
--- /dev/null
+++ b/tizen/src/ui/generalskinview.cpp
@@ -0,0 +1,125 @@
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jihye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@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 <QWidget>
+
+#include "generalskinview.h"
+#include "mainwindow.h"
+
+GeneralSkinView::GeneralSkinView(QGraphicsScene *scene, QWidget *parent)
+ : MainView(scene, parent)
+{
+}
+
+GeneralSkinView::~GeneralSkinView()
+{
+ qDebug("destroy general skin view");
+}
+
+/* override */
+void GeneralSkinView::resizeEvent(QResizeEvent *event)
+{
+ qDebug() << "resize general skin view:" << size();
+ SkinView::resizeEvent(event);
+}
+
+/* override */
+void GeneralSkinView::mousePressEvent(QMouseEvent *event)
+{
+ SkinView::mousePressEvent(event);
+
+ if (event->button() == Qt::LeftButton) {
+ grabWindow(event->globalPos());
+ }
+}
+
+/* override */
+void GeneralSkinView::mouseReleaseEvent(QMouseEvent *event)
+{
+ SkinView::mouseReleaseEvent(event);
+
+ if (event->button() == Qt::LeftButton) {
+ releaseWindow();
+ }
+}
+
+/* override */
+void GeneralSkinView::mouseMoveEvent(QMouseEvent *event)
+{
+ SkinView::mouseMoveEvent(event);
+
+ if (isGrabWindow() == true) {
+ win->move(grabWinPos + (event->globalPos() - grabPos));
+ }
+}
+
+void GeneralSkinView::createItems()
+{
+ qDebug() << "create items for general skin view";
+
+ QBrush backBrush(QColor(244, 244, 244));
+ QPen linePen(QColor(205, 205, 205), 1, Qt::SolidLine);
+ QSize size = win->getUiInfo()->getMainSize();
+ scene()->addRect(BORDER_SIZE, BORDER_SIZE, size.width() - BORDER_SIZE * 2, HEADER_HEIGHT, QPen(Qt::NoPen), backBrush);
+ scene()->addLine(BORDER_SIZE, HEADER_HEIGHT + BORDER_SIZE, size.width() - BORDER_SIZE, HEADER_HEIGHT + BORDER_SIZE, linePen);
+
+ if (BORDER_SIZE > 0) {
+ QPen boaderPen(QColor(0, 138, 248), BORDER_SIZE * 2, Qt::SolidLine);
+ scene()->addRect(0, 0, size.width(), size.height(), boaderPen);
+ }
+
+ QGraphicsTextItem *title = new QGraphicsTextItem(win->getUiInfo()->getVmName());
+ title->setDefaultTextColor(QColor(88, 88, 88));
+ scene()->addItem(title);
+ QRectF rect = title->boundingRect();
+ int y = (HEADER_HEIGHT - rect.height()) / 2;
+ title->setPos(BORDER_SIZE + 5, BORDER_SIZE + y);
+}
+
+QSize GeneralSkinView::getMainSize()
+{
+ QSize size = win->getUiInfo()->getMainForm()->
+ skinImg[LayoutForm::normal].size() * win->getUiInfo()->getUiState()->getScaleFactor();
+
+ size.setWidth(size.width() + BORDER_SIZE * 2);
+ size.setHeight(size.height() + HEADER_HEIGHT + BORDER_SIZE * 2);
+
+ return size;
+}
+
+QRegion GeneralSkinView::getMainRegion()
+{
+ QImage *mainImage = &(win->getUiInfo()->getMainForm()->skinImg[LayoutForm::normal]);
+ QImage regionImage = mainImage->scaled(
+ mainImage->width() * win->getUiInfo()->getUiState()->getScaleFactor() + BORDER_SIZE * 2,
+ mainImage->height() * win->getUiInfo()->getUiState()->getScaleFactor()
+ + HEADER_HEIGHT + BORDER_SIZE * 2).createAlphaMask();
+
+ return QRegion(QBitmap::fromImage(regionImage));
+}