ControllerLayout *layout = new ControllerLayout();
layout->conImg[ControllerLayout::normal].load(
- fileInfo.absolutePath() + "/" + layoutType->mainImageName());
+ fileInfo.absolutePath() + "/" + layoutType->mainImageName());
+ layout->conImg[ControllerLayout::pressed].load(
+ fileInfo.absolutePath() + "/" + layoutType->pressedImageName());
keyListType = layoutType->keyListType();
if (keyListType != NULL) {
ControllerWidget::ControllerWidget(ControllerLayout *conLayout, QWidget *parent) :
QLabel(parent)
{
+ //setStyleSheet("background: transparent");
setStyleSheet("border-style: none");
+ setWindowFlags(Qt::FramelessWindowHint);
+ setAttribute(Qt::WA_TranslucentBackground);
+
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
explicit ControllerWidget(ControllerLayout *conLayout, QWidget *parent = 0);
~ControllerWidget();
+protected:
+
private:
SkinControllerView *conView;
};
#include <QtWidgets>
#include "mainwindow.h"
-#include "displaywidget.h"
#include "skinlayout.h"
-#include "skincontrollerview.h"
-#include "controllerwidget.h"
QOpenGLContext *qt5GLContext = NULL;
QSurfaceFormat qt5GLFormat;
c.wakeAll();
}
+
MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) :
QWidget(parent)
{
skinView = NULL;
display = NULL;
conView = NULL;
+ con = NULL;
/* windowing */
setWindowTitle("Emulator");
//setStyleSheet("background:transparent;");
//setAttribute(Qt::WA_TranslucentBackground);
- //setWindowFlags(Qt::FramelessWindowHint);
+ setWindowFlags(Qt::FramelessWindowHint);
QHBoxLayout *winLayout = new QHBoxLayout(this);
winLayout->setMargin(0);
winLayout->setSpacing(0);
-
/* scene */
QGraphicsScene* skinScene = new QGraphicsScene(this);
-
/* view */
skinView = new SkinView(skinScene, this);
- skinView->setStyleSheet("background: transparent");
- //skinView->setStyleSheet("border-style: none");
- skinView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- skinView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
winLayout->addWidget(skinView);
if (uiInfo->controllerList.count() > 0) {
/* floated controller */
ControllerLayout *conLayout = uiInfo->controllerList.at(0);
- ControllerWidget *con = new ControllerWidget(conLayout);
+ con = new ControllerWidget(conLayout);
con->show();
}
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
SLOT(showContextMenu(const QPoint&)));
+ /* swapper */
swapperThread = new QThread(this);
swapper = new DisplaySwapper(context);
void MainWindow::showContextMenu(const QPoint& pos)
{
- QPoint globalPos = this->mapToGlobal(pos);
- // for QAbstractScrollArea and derived classes you would use:
- // QPoint globalPos = myWidget->viewport()->mapToGlobal(pos);
-
- QAction* selectedItem = popupMenu->exec(globalPos);
+ QAction* selectedItem = popupMenu->exec(mapToGlobal(pos));
if (selectedItem) {
//qDebug("%s", selectedItem->text().toLocal8Bit().data());
} else {
return &(uiInfo->uiState);
}
+ControllerWidget *MainWindow::getController()
+{
+ return con;
+}
+
+void MainWindow::resizeEvent(QResizeEvent *event)
+{
+ qDebug("resize main window");
+
+ resize(skinView->size());
+}
+
void MainWindow::rotate(int angle)
{
qDebug("window rotate : %d", angle);
skinView->rotate();
display->rotate(getUIState()->layoutAngle);
+
+ adjustSize();
}
void MainWindow::scale(int scale)
skinView->adjustSize();
display->scale(getUIState()->layoutScale);
+
+ adjustSize();
}
void MainWindow::updateSkin() // TODO: temp
#include "skinbezelitem.h"
#include "uiinformation.h"
#include "skincontrollerview.h"
+#include "controllerwidget.h"
extern "C" {
#include "skin/maruskin_operation.h"
UIState *getUIState(void);
void rotate(int angle);
void scale(int scale);
+ ControllerWidget *getController();
UIInformation *uiInfo;
QLabel *getLabel();
void showContextMenu(const QPoint& pos);
protected:
+ void resizeEvent(QResizeEvent *event);
+
void updateSkin();
void setRegion(QImage baseImage);
void closeEvent(QCloseEvent *);
SkinControllerView *conView;
QThread *swapperThread;
DisplaySwapper *swapper;
+
+ ControllerWidget *con;
};
#endif // MAINWINDOW_H
QGraphicsView(scene, parent)
{
setStyleSheet("background: transparent");
+ //setAttribute(Qt::WA_TranslucentBackground);
setStyleSheet("border-style: none");
+
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
setAlignment(Qt::AlignLeft | Qt::AlignTop);
+ grabWinPos = QPoint(-1, -1);
+ grabPos = QPoint(-1, -1);
+
createItems(conLayout);
}
Q_UNUSED(event)
}
+void SkinControllerView::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton) {
+ QWidget *win = ((QWidget *) this->parent());
+ grabWinPos = win->pos();
+ grabPos = event->globalPos();
+ }
+
+ QGraphicsView::mousePressEvent(event);
+}
+
+void SkinControllerView::mouseReleaseEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton) {
+ grabPos = QPoint(-1, -1);
+ }
+
+ QGraphicsView::mouseReleaseEvent(event);
+}
+
+void SkinControllerView::mouseMoveEvent(QMouseEvent *event)
+{
+ QWidget *win = ((QWidget *)this->parent());
+
+ if (grabPos != QPoint(-1, -1)) {
+ win->move(grabWinPos + (event->globalPos() - grabPos));
+ }
+
+ QGraphicsView::mouseMoveEvent(event);
+}
+
SkinControllerView::~SkinControllerView()
{
qDebug("destroy scontroller view");
protected:
void resizeEvent(QResizeEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+
+ QPoint grabWinPos;
+ QPoint grabPos;
+
private:
void createItems(ControllerLayout *conLayout);
};
SkinView::SkinView(QGraphicsScene *scene, QWidget *parent) :
QGraphicsView(scene, parent)
{
+ setStyleSheet("border-style: none");
+
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setAlignment(Qt::AlignLeft | Qt::AlignTop);
grabWinPos = QPoint(-1, -1);