return conView;
}
+MainWindow *DockingController::getMainWindow()
+{
+ return win;
+}
+
int DockingController::getDockPos()
{
return dockPos;
ControllerForm *getConForm();
DockingConView *getConView();
+ MainWindow *getMainWindow();
int getDockPos();
void updateGeometry();
GeneralPurposeCon *generalCon = new GeneralPurposeCon();
QList<HWKeyButton *> buttons
= generalCon->createButtons(parentWidget(), conForm);
+
+ for (int i = 0; i < buttons.count(); i++) {
+ HWKeyButton *button = buttons.at(i);
+ if (button->getSlot() == NULL) {
+ continue;
+ }
+ connect(button, SIGNAL(clicked()),
+ parent->getMainWindow()->getPopupMenu(), button->getSlot());
+ }
}
}
FloatingController::FloatingController(ControllerForm *conForm,
QAction *menu, QWidget *parent) : QDialog(parent)
{
+ this->win = (MainWindow *)parent;
this->conForm = conForm;
this->menu = menu;
return conView;
}
+MainWindow *FloatingController::getMainWindow()
+{
+ return win;
+}
+
/* override */
void FloatingController::showEvent(QShowEvent *event)
{
#include "layout/controllerform.h"
#include "floatingconview.h"
+class MainWindow;
+
class FloatingController : public QDialog
{
Q_OBJECT
ControllerForm *getConForm();
FloatingConView *getConView();
+ MainWindow *getMainWindow();
protected:
void showEvent(QShowEvent *event);
void reject();
private:
+ MainWindow *win;
FloatingConView *conView;
ControllerForm *conForm;
QAction *menu;
GeneralPurposeCon *generalCon = new GeneralPurposeCon();
QList<HWKeyButton *> buttons
= generalCon->createButtons(parentWidget(), conForm);
+
+ for (int i = 0; i < buttons.count(); i++) {
+ HWKeyButton *button = buttons.at(i);
+ if (button->getSlot() == NULL) {
+ continue;
+ }
+ connect(button, SIGNAL(clicked()),
+ parent->getMainWindow()->getPopupMenu(), button->getSlot());
+ }
}
}
topLeft.setY(topLeft.y() + GPC_HEAD_SPACING);
QList<HWKeyButton *> buttonList;
+
// H/W key list
createKeyList(parent, form->getKeyList(), topLeft, buttonList);
+ topLeft.setY(topLeft.y()
+ + (GPC_KEYBUTTON_VSPACING + GPC_KEYBUTTON_HEIGHT) * form->getKeyList().count());
+
+ // Menu key list
+ for (int i = 0; i < form->getSubFormList().count(); i++) {
+ ControllerForm *subForm = form->getSubFormList().at(i);
+ createKeyList(parent, subForm->getKeyList(), topLeft, buttonList);
+ topLeft.setY(topLeft.y()
+ + (GPC_KEYBUTTON_VSPACING + GPC_KEYBUTTON_HEIGHT) * subForm->getKeyList().count());
+ }
return buttonList;
}
-void GeneralPurposeCon::createKeyList(QWidget *parent, QList<HardwareKey *> keyList, QPoint topLeft, QList<HWKeyButton *> &buttonList)
+void GeneralPurposeCon::createKeyList(QWidget *parent, QList<HardwareKey *> keyList,
+ QPoint topLeft, QList<HWKeyButton *> &buttonList)
{
HardwareKey *hwKey = NULL;
HWKeyButton *keyButton = NULL;
"color:#2E2E2E; background-color:#CCCCCC;"
"}"
);
+
+ //FIXME: set slot for menu button
+ if (hwKey->getKeycode() == 0) {
+ QString name = hwKey->getName();
+ if (QString::compare(name, "Control Panel") == 0) {
+ slot = SLOT(slotControlPanel());
+ } else if (QString::compare(name, "Screen Shot") == 0) {
+ slot = SLOT(slotRequestScreenshot());
+ } else if (QString::compare(name, "Rotate") == 0) {
+ slot = SLOT(slotSwitchShortcutNext());
+ } else if (QString::compare(name, "Shell") == 0) {
+ slot = SLOT(slotShell());
+ } else {
+ slot = NULL;
+ }
+ } else {
+ slot = NULL;
+ }
}
/* override */
{
const int keycode = hwKey->getKeycode();
- qDebug() << hwKey->getName() << "key button pressed:" << keycode;
- do_hw_key_event(KEY_PRESSED, keycode);
+ if (keycode > 0) {
+ qDebug() << hwKey->getName() << "key button pressed:" << keycode;
+ do_hw_key_event(KEY_PRESSED, keycode);
+ }
QPushButton::mousePressEvent(event);
}
{
const int keycode = hwKey->getKeycode();
- qDebug() << hwKey->getName() << "key button released:" << keycode;
- do_hw_key_event(KEY_RELEASED, keycode);
+ if (keycode > 0) {
+ qDebug() << hwKey->getName() << "key button released:" << keycode;
+ do_hw_key_event(KEY_RELEASED, keycode);
+ }
QPushButton::mouseReleaseEvent(event);
}
+const char *HWKeyButton::getSlot()
+{
+ return slot;
+}
+
HWKeyButton::~HWKeyButton()
{
/* do nothing */
public:
HWKeyButton(QWidget *parent, HardwareKey *hwKey, QSize size);
~HWKeyButton();
+ virtual const char *getSlot();
protected:
void mousePressEvent(QMouseEvent *event);
private:
HardwareKey *hwKey;
+ const char *slot;
};
#endif // HWKEYBUTTON_H
return centeralRect;
}
+QList<ControllerForm *> &ControllerForm::getSubFormList()
+{
+ return subFormList;
+}
+
ControllerForm::~ControllerForm()
{
qDebug("destroy con layout");
void setCenteralRect(const QRect &rect);
QRect getCenteralRect();
+ QList<ControllerForm *> &getSubFormList();
private:
QRect centeralRect;
+ QList<ControllerForm *> subFormList;
};
#endif // CONTROLLERFORM_H
int KeycodeType::getShortPressKeycode()
{
- if (shortPress <= 0) {
- qWarning() << "invalid short press keycode:" << shortPress;
+ if (shortPress < 0) {
+ qWarning() << "invalid short press key code:" << shortPress;
}
return shortPress;
<file>images/controller-skin/VolumeUp_hover.png</file>
<file>images/controller-skin/VolumeUp_normal.png</file>
<file>images/controller-skin/VolumeUp_pushed.png</file>
+ <file>images/controller-skin/Shell_hover.png</file>
+ <file>images/controller-skin/Shell_normal.png</file>
+ <file>images/controller-skin/Shell_pushed.png</file>
+ <file>images/controller-skin/Rotate_hover.png</file>
+ <file>images/controller-skin/Rotate_normal.png</file>
+ <file>images/controller-skin/Rotate_pushed.png</file>
+ <file>images/controller-skin/Screen Shot_hover.png</file>
+ <file>images/controller-skin/Screen Shot_normal.png</file>
+ <file>images/controller-skin/Screen Shot_pushed.png</file>
+ <file>images/controller-skin/Control Panel_hover.png</file>
+ <file>images/controller-skin/Control Panel_normal.png</file>
+ <file>images/controller-skin/Control Panel_pushed.png</file>
<file>icons/emulator_icon.ico</file>
<file>icons/shell.png</file>
<shortcut>Ctrl+Shift+[</shortcut>
</key>
</keyList>
+ <form name="Menu Window">
+ <keyList>
+ <key name="Rotate">
+ <shortcut>Ctrl+Shift+Left</shortcut>
+ </key>
+ <key name="Shell">
+ <shortcut>Ctrl+Shift+S</shortcut>
+ </key>
+ <key name="Control Panel">
+ <shortcut>Ctrl+Shift+P</shortcut>
+ </key>
+ <key name="Screen Shot">
+ <shortcut>Ctrl+Shift+F12</shortcut>
+ </key>
+ </keyList>
+ </form>
</form>
</ControllerUI>
<shortcut>Ctrl+Shift+F8</shortcut>
</key>
</keyList>
+ <form name="Menu Window">
+ <keyList>
+ <key name="Rotate">
+ <shortcut>Ctrl+Shift+Left</shortcut>
+ </key>
+ <key name="Shell">
+ <shortcut>Ctrl+Shift+S</shortcut>
+ </key>
+ <key name="Control Panel">
+ <shortcut>Ctrl+Shift+P</shortcut>
+ </key>
+ <key name="Screen Shot">
+ <shortcut>Ctrl+Shift+F12</shortcut>
+ </key>
+ </keyList>
+ </form>
</form>
</ControllerUI>
drawSkin(path, centerPatch, degree, tagLeftTop, tagColor);
}
-SkinPainter::SkinPainter(QSize centerPatch, int degree)
+SkinPainter::SkinPainter(QSize centerPatch, int degree, QList<Separator *> separators)
{
- drawSkin(centerPatch, degree);
+ drawSkin(centerPatch, degree, separators);
}
-void SkinPainter::drawSkin(QSize center, int degree) {
+void SkinPainter::drawSkin(QSize center, int degree, QList<Separator *> separators) {
qDebug() << "draw skin surface";
QRect centeralRect(0, 0, center.width(), center.height());
QPainter painter(&image);
painter.fillRect(centeralRect, QBrush(QColor(244, 244, 244)));
+ // add separators
+ for (int i = 0; i < separators.count(); i++) {
+ Separator *s = separators.at(i);
+ painter.setPen(s->pen);
+ painter.drawLine(0, s->hOffset, center.width(), s->hOffset);
+ }
+
/* rotate */
QTransform transform;
skin = new QPixmap(image.transformed(transform.rotate(degree)));
#include "layout/displaytype.h"
+struct Separator
+{
+ int hOffset;
+ QPen pen;
+};
+
class SkinPainter
{
public:
SkinPainter(const QString &patchPath, QSize centerPatch, int degree,
QPoint tagLeftTop, QColor tagColor);
- SkinPainter(QSize centerPatch, int degree);
+ SkinPainter(QSize centerPatch, int degree, QList<Separator *> separators);
~SkinPainter();
QImage getSkinImage() const;
private:
void drawSkin(QString patchPath, QSize center, int degree,
QPoint tagLeftTop, QColor tagColor);
- void drawSkin(QSize center, int degree);
+ void drawSkin(QSize center, int degree, QList<Separator *> separators);
QPixmap *skin;
QRect centeralRect;
} else if (xml.name() == HOVER_KEYWORD) {
/* hover */
form->setHoverType(parseHover(xml, depth + 1));
+ } else if (xml.name() == FORM_KEYWORD) {
+ /* sub form */
+ QWARN_INDENT(depth + 1) << "undefined element: " << xml.name();
+ ControllerForm *subform = parseControllerForm(xml, depth + 1);
+ if (subform != NULL) {
+ form->getSubFormList().append(subform);
+ }
} else {
QWARN_INDENT(depth + 1) << "undefined element: " << xml.name();
}
void XmlLayoutParser::makeGeneralCon(ControllerForm *form)
{
- const int keyCount = form->getKeyList().count();
+ int keyCount = form->getKeyList().count();
int width = GPC_KEYBUTTON_WIDTH + GPC_KEYBUTTON_HSPACING;
int height = GPC_HEAD_SPACING;
height += (GPC_KEYBUTTON_HEIGHT * keyCount) +
- (GPC_KEYBUTTON_VSPACING * (keyCount - 1)) + GPC_TAIL_SPACING;
+ (GPC_KEYBUTTON_VSPACING * (keyCount - 1));
+
+ // add sub form
+ QList<Separator *> sList;
+ QPen pen(QColor(205, 205, 205), 1, Qt::SolidLine);
+ for (int i = 0; i < form->getSubFormList().count(); i++) {
+ // for separator
+ Separator *s = new Separator();
+ s->pen = pen;
+ s->hOffset = height + GPC_KEYBUTTON_VSPACING / 2;
+ sList.append(s);
+
+ ControllerForm *subForm = form->getSubFormList().at(i);
+ keyCount = subForm->getKeyList().count();
+
+ height += (GPC_KEYBUTTON_HEIGHT * keyCount) +
+ (GPC_KEYBUTTON_VSPACING * keyCount);
+ }
+
+ height += GPC_TAIL_SPACING;
- SkinPainter painter(QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)), 0);
+ SkinPainter painter(QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)), 0, sList);
form->skinImg[LayoutForm::normal] = painter.getSkinImage();
form->setCenteralRect(painter.getCenteralRect());