#define SHORTCUT_KEYWORD "shortcut"
#define MENULIST_KEYWORD "menuList"
+/* Qt Qlayout has a minimum size */
+#define QT_LAYOUT_MINIMUM (73)
+
XmlLayoutParser::XmlLayoutParser(QString path, UIInformation *uiInfo)
{
this->xmlPath = path;
if (form->conImg[ControllerForm::normal].size() == QSize(0, 0)) {
qDebug("general purpose con form");
- SkinPainter painter("controller-skin", QSize(
- GPC_KEYBUTTON_WIDTH + (GPC_SCROLLBAR_WIDTH + GPC_SCROLLBAR_HSPACING),
- GPC_HEAD_SPACING + (GPC_KEYBUTTON_HEIGHT * GPC_KEYBUTTON_DEFAULT_CNT) +
- (GPC_KEYBUTTON_VSPACING * (GPC_KEYBUTTON_DEFAULT_CNT - 1))), 0,
- QPoint(GPC_SCROLLBAR_WIDTH, GPC_HEAD_SPACING - 1), uiInfo->getVMColor());
+ int keyCount = form->keyList.count();
+
+ int width = GPC_KEYBUTTON_WIDTH;
+ int height = GPC_HEAD_SPACING;
+ if (keyCount < GPC_KEYBUTTON_DEFAULT_CNT) {
+ height += (GPC_KEYBUTTON_HEIGHT * keyCount) +
+ (GPC_KEYBUTTON_VSPACING * (keyCount - 1)) +
+ GPC_TAIL_SPACING;
+ } else {
+ width += (GPC_SCROLLBAR_WIDTH + GPC_SCROLLBAR_HSPACING);
+ height += (GPC_KEYBUTTON_HEIGHT * GPC_KEYBUTTON_DEFAULT_CNT) +
+ (GPC_KEYBUTTON_VSPACING * (GPC_KEYBUTTON_DEFAULT_CNT - 1)) +
+ GPC_TAIL_SPACING;
+ }
+
+ SkinPainter painter("controller-skin",
+ QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)),
+ 0, QPoint(14, GPC_HEAD_SPACING - 1),
+ uiInfo->getVMColor());
form->setGeneralPurpose(true);
form->conImg[ControllerForm::normal] = painter.getSkinImage();
return dockPos;
}
+/* override */
void DockingController::showEvent(QShowEvent *event)
{
if (menu != NULL) {
menu->setChecked(true);
}
+
+ QWidget::showEvent(event);
}
+/* override */
void DockingController::closeEvent(QCloseEvent *event) {
if (menu != NULL) {
menu->setChecked(false);
MainWindow *win = ((MainWindow *)this->parent());
win->getUIState()->conState.dockingCon = NULL;
+
+ QWidget::closeEvent(event);
}
DockingController::~DockingController()
} else {
GeneralPurposeCon *generalCon = new GeneralPurposeCon(this, keyList,
QSize(conForm->centerRect.width(),
- conForm->centerRect.height() - (GPC_HEAD_SPACING + GPC_TAIL_SPACING)));
- scene()->addWidget(generalCon);
+ conForm->centerRect.height() - GPC_HEAD_SPACING));
QPoint topLeft = conForm->centerRect.topLeft();
generalCon->move(topLeft.x(), topLeft.y() + GPC_HEAD_SPACING);
return conView;
}
+/* override */
void FloatingController::showEvent(QShowEvent *event)
{
if (menu != NULL) {
menu->setChecked(true);
}
- setRegion(&(conForm->conImg[ControllerForm::normal]));
+ QImage *baseImage = &(conForm->conImg[ControllerForm::normal]);
+ if (baseImage->isNull() == true) {
+ qWarning("invalid image for region");
+ } else {
+ setMask(QRegion(QBitmap::fromImage(baseImage->createAlphaMask())));
+ }
+
+ QWidget::showEvent(event);
+}
+
+/* override */
+void FloatingController::setMask(const QRegion ®ion)
+{
+ if (region.isEmpty() == false) {
+ QWidget::setMask(region);
+ }
}
+/* override */
void FloatingController::closeEvent(QCloseEvent *event) {
if (menu != NULL) {
menu->setChecked(false);
MainWindow *win = ((MainWindow *)this->parent());
win->getUIState()->conState.floatingCon = NULL;
-}
-
-void FloatingController::setRegion(QImage *baseImage)
-{
- qDebug("set region");
-
- if (baseImage->isNull() == true) {
- qWarning("invalid image for region");
- return;
- }
- setMask(QRegion(QBitmap::fromImage(baseImage->createAlphaMask())));
+ QWidget::closeEvent(event);
}
FloatingController::~FloatingController()
protected:
void showEvent(QShowEvent *event);
+ void setMask(const QRegion ®ion);
void closeEvent(QCloseEvent *event);
- void setRegion(QImage *baseImage);
-
private:
FloatingConView *conView;
ControllerForm *conForm;
GeneralPurposeCon *generalCon = new GeneralPurposeCon(this, keyList,
QSize(conForm->centerRect.width(),
conForm->centerRect.height() - (GPC_HEAD_SPACING + GPC_TAIL_SPACING)));
- scene()->addWidget(generalCon);
QPoint topLeft = conForm->centerRect.topLeft();
generalCon->move(topLeft.x(), topLeft.y() + GPC_HEAD_SPACING);
*
*/
+#include "config-host.h"
+
#include "generalpurposecon.h"
#include "hwkeybutton.h"
QVBoxLayout *layout = new QVBoxLayout(buttonGroup);
layout->setMargin(0);
+
+#ifndef CONFIG_DARWIN
layout->setSpacing(GPC_KEYBUTTON_VSPACING);
+#else
+ /* need more spacing on MacOS */
+ layout->setSpacing(GPC_KEYBUTTON_VSPACING + 11);
+#endif
HardwareKey *hwKey = NULL;
HWKeyButton *keyButton = NULL;
"margin: 14px 2px 14px 2px;"
"background-color: QLinearGradient(x1: 1, y1: 0, x2: 0, y2: 0," +
"stop: 0 #3C3C3C, stop: 1 #737373);"
- "border-radius: 2px;"
+ "border-radius: 3px;"
"}"
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {"
"background: none;"