menu->setChecked(false);
}
- win->getUiState()->conState.dockingCon = NULL;
+ win->getUiState()->getConState()->setDockingCon(NULL);
deleteLater();
event->accept();
rubberBand->hide();
}
- if (getConViewStatus() != CONVIEW_PRESSED && getConViewStatus() != CONVIEW_DOUBLECLICKED) {
+ if (getConViewStatus() != CONVIEW_PRESSED &&
+ getConViewStatus() != CONVIEW_DOUBLECLICKED) {
/* toggle */
MainWindow *win = ((MainWindow *)parent->parent());
- win->getUiState()->conState.recentlyFloatPos = event->globalPos() - eventPos;
- win->openController(win->getUiState()->conState.conFormIndex, -1);
+ win->getUiState()->getConState()->setRecentlyFloatPos(
+ event->globalPos() - eventPos);
+ win->openController(
+ win->getUiState()->getConState()->getConFormIndex(), -1);
}
}
}
}
MainWindow *win = ((MainWindow *)this->parent());
- win->getUiState()->conState.floatingCon = NULL;
+ win->getUiState()->getConState()->setFloatingCon(NULL);
deleteLater();
event->accept();
int dockPos = isDockable((QWidget *)win, (QWidget *)parent);
if (dockPos != -1) {
/* toggle */
- win->openController(win->getUiState()->conState.conFormIndex, dockPos);
+ win->openController(
+ win->getUiState()->getConState()->getConFormIndex(), dockPos);
return;
}
}
UIState *MainWindow::getUiState()
{
- return &(uiInfo->uiState);
+ return uiInfo->getUiState();
}
const QMatrix &MainWindow::getDisplayMatrix()
DockingController *MainWindow::getDockingCon()
{
- return getUiState()->conState.dockingCon;
+ return getUiState()->getConState()->getDockingCon();
}
FloatingController *MainWindow::getFloatingCon()
{
- return getUiState()->conState.floatingCon;
+ return getUiState()->getConState()->getFloatingCon();
}
void MainWindow::openController(int index, int dockPos)
return;
}
- getUiState()->conState.conFormIndex = index;
+ getUiState()->getConState()->setConFormIndex(index);
QAction *action = NULL;
if (popupMenu != NULL && popupMenu->getControllerMapper() != NULL) {
/* create */
if (dockPos == -1) {
- getUiState()->conState.floatingCon =
- new FloatingController(conForm, action, this);
+ getUiState()->getConState()->setFloatingCon(
+ new FloatingController(conForm, action, this));
} else {
- getUiState()->conState.dockingCon =
- new DockingController(conForm, action, dockPos, this);
- getUiState()->conState.recentlyDockPos = dockPos;
+ getUiState()->getConState()->setDockingCon(
+ new DockingController(conForm, action, dockPos, this));
+ getUiState()->getConState()->setRecentlyDockPos(dockPos);
#ifdef CONFIG_WIN32
/* W/A: Sometimes, QGrahpicsItem's update() does not work with QGLWidget
* on Windows Aero theme. We need to indirectly repaint the items
* through these lines. */
const QSize conViewSize = uiInfo->getConSize();
- getUiState()->conState.dockingCon->getConView()->resize(conViewSize / 2);
- getUiState()->conState.dockingCon->getConView()->resize(conViewSize);
+ getUiState()->getConState()->
+ getDockingCon()->getConView()->resize(conViewSize / 2);
+ getUiState()->getConState()->
+ getDockingCon()->getConView()->resize(conViewSize);
#endif
}
/* arrange */
if (dockPos == -1) {
- if (getUiState()->conState.recentlyFloatPos == QPoint(-1, -1)) {
+ if (getUiState()->getConState()->getRecentlyFloatPos() == QPoint(-1, -1)) {
QPoint globalPos = mapToGlobal(QPoint(0, 0));
getFloatingCon()->move(globalPos.x() + size().width(), globalPos.y());
} else {
- getFloatingCon()->move(getUiState()->conState.recentlyFloatPos);
- getUiState()->conState.recentlyFloatPos = QPoint(-1, -1);
+ getFloatingCon()->move(getUiState()->getConState()->getRecentlyFloatPos());
+ getUiState()->getConState()->setRecentlyFloatPos(QPoint(-1, -1));
}
getFloatingCon()->show();
getDockingCon()->getConForm()->getKeyList());
getDockingCon()->close();
- getUiState()->conState.dockingCon = NULL;
+ getUiState()->getConState()->setDockingCon(NULL);
resize(uiInfo->getUiSize());
}
if (getFloatingCon() != NULL) {
qDebug("close floating controller");
- getUiState()->conState.recentlyFloatPos = getFloatingCon()->pos();
+ getUiState()->getConState()->setRecentlyFloatPos(getFloatingCon()->pos());
/* cancel controller's HW key shortcuts */
keyboardShortcut->cancelHwKeyShortcuts(
getFloatingCon()->getConForm()->getKeyList());
getFloatingCon()->close();
- getUiState()->conState.floatingCon = NULL;
+ getUiState()->getConState()->setFloatingCon(NULL);
}
/* Some part of QGLWidget's surface might be lost on Windows when view changing.
keyboardShortcut->cancelHwKeyShortcuts(uiInfo->getMainForm()->getKeyList());
/* layout switching */
- getUiState()->mainFormIndex = index;
+ getUiState()->setMainFormIndex(index);
/* register new HW key shortcuts */
keyboardShortcut->registerHwKeyShortcuts(uiInfo->getMainForm()->getKeyList());
qDebug("window scale: %d", scale);
/* scale changing */
- getUiState()->mainFormScale = scale;
+ getUiState()->setScalePct(scale);
updateDisplayMatrix();
// TODO: interpolation
action = (QAction *) scaleMapper->mapping(
- parent->getUiState()->mainFormScale);
+ parent->getUiState()->getScalePct());
action->setChecked(true);
} else {
qWarning("cannot create a scaleItem");
qDebug("controller: %d", index);
parent->openController(index,
- parent->getUiState()->conState.recentlyDockPos);
+ parent->getUiState()->getConState()->getRecentlyDockPos());
if (infoDialog != NULL && infoDialog->isVisible() == true) {
/* update controller shortcut info */
qDebug("controller: None");
parent->closeController();
- parent->getUiState()->conState.conFormIndex = -1;
+ parent->getUiState()->getConState()->setConFormIndex(-1);
if (infoDialog != NULL && infoDialog->isVisible() == true) {
/* update controller shortcut info */
}
}
}
- uiInfo->uiState.mainFormScale = scale;
- qDebug("default scale value is %d", uiInfo->uiState.mainFormScale);
+ uiInfo->getUiState()->setScalePct(scale);
+ qDebug("default scale value is %d", uiInfo->getUiState()->getScalePct());
/* GUI */
qDebug("start!");
/* controller */
const int defaultDockPos = Qt::AlignRight | Qt::AlignCenter;
- mainwindow->getUiState()->conState.recentlyDockPos = defaultDockPos;
+ mainwindow->getUiState()->getConState()->setRecentlyDockPos(defaultDockPos);
int conIndex = mruInfo.value(SKIN_PROPERTY_CONTROLLER_INDEX).toInt();
if (conIndex >= 0 && conIndex < uiInfo->conFormList.count()) {
QSettings mruInfo(path, QSettings::IniFormat);
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;
+ mruInfo.setValue(SKIN_PROPERTY_WINDOW_SCALE,
+ uiInfo->getUiState()->getScalePct());
+ mruInfo.setValue(SKIN_PROPERTY_WINDOW_TOPMOST,
+ uiInfo->getUiState()->isOnTop());
+ mruInfo.setValue(SKIN_PROPERTY_CONTROLLER_INDEX,
+ uiInfo->getUiState()->getConState()->getConFormIndex());
+
+ DockingController *con = uiInfo->getUiState()->getConState()->getDockingCon();
if (con != NULL) {
mruInfo.setValue(SKIN_PROPERTY_CONTROLLER_DOCK, con->getDockPos());
} else {
skinPath = "./";
}
+UIState *UIInformation::getUiState()
+{
+ return &uiState;
+}
+
QColor UIInformation::getVMColor()
{
switch(basePort % 10) {
if (index > (mainFormList.count() - 1) || index < 0) {
qWarning("invalid form found");
- index = uiState.mainFormIndex = 0;
+ uiState.setMainFormIndex(0);
+ index = uiState.getMainFormIndex();
}
MainForm *mainForm = mainFormList.at(index);
ControllerForm *UIInformation::getConForm()
{
- int index = uiState.conState.getConFormIndex();
+ int index = uiState.getConState()->getConFormIndex();
if (index > (conFormList.count() - 1) || index < 0) {
qWarning("invalid form found");
QSize uiSize = getMainSize();
/* docking controller */
- if (uiState.conState.dockingCon != NULL) {
+ if (uiState.getConState()->getDockingCon() != NULL) {
QSize conSize = getConSize();
uiSize.setWidth(uiSize.width() + conSize.width());
uiSize.setHeight(qMax(uiSize.height(), conSize.height()));
QRegion uiRegion = getMainRegion();
/* docking controller */
- DockingController *con = uiState.conState.dockingCon;
+ DockingController *con = uiState.getConState()->getDockingCon();
if (con != NULL) {
QRegion conRegion = getConRegion();
QRegion baseRegion;
QRegion keyRegion;
- if (uiState.conState.dockingCon != NULL) {
+ if (uiState.getConState()->getDockingCon() != NULL) {
/* docking controller */
const int shiftW = getMainSize().width();
QList<MainForm *> mainFormList;
QList<ControllerForm *> conFormList;
QList<MenuItem *> menuList;
- QColor hoverColor;
- UIState uiState; /* runtime information */
+ UIState *getUiState();
QColor getVMColor();
MainForm *getMainForm(); /* current */
QRegion getUiRegion(); /* main + docking con */
QRegion getMainKeyRegion(QWidget *base, QRect &keyRect, LayoutForm::SkinImgType type);
QRegion getConKeyRegion(QWidget *base, QRect &keyRect, LayoutForm::SkinImgType type);
+
+private:
+ UIState uiState; /* runtime information */
};
#endif // UIINFORMATION_H
#include "uistate.h"
-UIState::UIState() :
- mainFormIndex(0), mainFormScale(100)
+ControllerState::ControllerState()
{
- onTop = false;
- conState.conFormIndex = 0;
- conState.dockingCon = NULL;
- conState.floatingCon = NULL;
- conState.recentlyDockPos = -1;
- conState.recentlyFloatPos = QPoint(-1, -1);
+ this->conFormIndex = 0;
+ this->dockingCon = NULL;
+ this->recentlyDockPos = -1;
+ this->floatingCon = NULL;
+ this->recentlyFloatPos = QPoint(-1, -1);
+}
+
+void ControllerState::setConFormIndex(int index) {
+ conFormIndex = index;
+}
+
+int ControllerState::getConFormIndex() {
+ return conFormIndex;
+}
+
+/* docking controller */
+void ControllerState::setDockingCon(DockingController *con)
+{
+ dockingCon = con;
+}
+
+DockingController *ControllerState::getDockingCon()
+{
+ return dockingCon;
+}
+
+void ControllerState::setRecentlyDockPos(int pos)
+{
+ recentlyDockPos = pos;
+}
+
+int ControllerState::getRecentlyDockPos()
+{
+ return recentlyDockPos;
+}
+
+/* floating controller */
+void ControllerState::setFloatingCon(FloatingController *con)
+{
+ floatingCon = con;
+}
+
+FloatingController *ControllerState::getFloatingCon()
+{
+ return floatingCon;
+}
+
+void ControllerState::setRecentlyFloatPos(QPoint pos)
+{
+ recentlyFloatPos = pos;
+}
+
+QPoint ControllerState::getRecentlyFloatPos()
+{
+ return recentlyFloatPos;
+}
+
+
+UIState::UIState()
+{
+ this->mainFormIndex = 0;
+ this->mainFormScalePct = 100;
+ this->onTop = false;
+}
+
+void UIState::setMainFormIndex(int index)
+{
+ mainFormIndex = index;
}
int UIState::getMainFormIndex()
return mainFormIndex;
}
+void UIState::setScalePct(int scalePct)
+{
+ mainFormScalePct = scalePct;
+}
+
+int UIState::getScalePct()
+{
+ return mainFormScalePct;
+}
+
qreal UIState::getScaleFactor(int scale)
{
return ((qreal)scale) / 100;
qreal UIState::getScaleFactor()
{
- return getScaleFactor(this->mainFormScale);
+ return getScaleFactor(mainFormScalePct);
}
void UIState::setOnTop(bool on)
{
- qDebug("set on top : %d", on);
+ qDebug("set on top: %d", on);
onTop = on;
}
{
return onTop;
}
+
+ControllerState *UIState::getConState()
+{
+ return &conState;
+}
class ControllerState
{
public:
- inline int getConFormIndex() {
- return conFormIndex;
- }
+ ControllerState();
+ void setConFormIndex(int index);
+ int getConFormIndex();
+
+ void setDockingCon(DockingController *con);
+ DockingController *getDockingCon();
+ void setRecentlyDockPos(int pos);
+ int getRecentlyDockPos();
+
+ void setFloatingCon(FloatingController *con);
+ FloatingController *getFloatingCon();
+ void setRecentlyFloatPos(QPoint pos);
+ QPoint getRecentlyFloatPos();
+
+private:
int conFormIndex;
DockingController *dockingCon;
- FloatingController *floatingCon;
int recentlyDockPos;
+ FloatingController *floatingCon;
QPoint recentlyFloatPos;
};
public:
UIState();
+ void setMainFormIndex(int index);
int getMainFormIndex(); /* current */
+ void setScalePct(int scalePct);
+ int getScalePct();
qreal getScaleFactor(int scale);
qreal getScaleFactor(); /* current */
-
void setOnTop(bool on);
bool isOnTop();
- int mainFormIndex;
- int mainFormScale; /* percentage */
-
- ControllerState conState;
+ ControllerState *getConState();
private:
+ int mainFormIndex;
+ int mainFormScalePct; /* percentage */
bool onTop;
+ ControllerState conState;
};
#endif // UISTATE_H