From: Marcin Kaźmierczak Date: Thu, 23 Dec 2010 15:24:12 +0000 (+0100) Subject: Fix button graphics when button was pressed or disabled. Add disabled state to button... X-Git-Url: http://vcs.maemo.org/git/?p=mdictionary;a=commitdiff_plain;h=324ea22239273504192afe5aea525224d1ce343f Fix button graphics when button was pressed or disabled. Add disabled state to button.qml. Add checkbox graphics. --- diff --git a/data/button/buttonCenterDisabled.png b/data/button/buttonCenterDisabled.png new file mode 100644 index 0000000..2621381 Binary files /dev/null and b/data/button/buttonCenterDisabled.png differ diff --git a/data/button/buttonCenterPushed.png b/data/button/buttonCenterPushed.png new file mode 100644 index 0000000..58203c0 Binary files /dev/null and b/data/button/buttonCenterPushed.png differ diff --git a/data/button/buttonLeftDisabled.png b/data/button/buttonLeftDisabled.png new file mode 100644 index 0000000..ef89fb8 Binary files /dev/null and b/data/button/buttonLeftDisabled.png differ diff --git a/data/button/buttonLeftPushed.png b/data/button/buttonLeftPushed.png new file mode 100644 index 0000000..976abd6 Binary files /dev/null and b/data/button/buttonLeftPushed.png differ diff --git a/data/button/buttonRightDisabled.png b/data/button/buttonRightDisabled.png new file mode 100644 index 0000000..db3fc2b Binary files /dev/null and b/data/button/buttonRightDisabled.png differ diff --git a/data/button/buttonRightPushed.png b/data/button/buttonRightPushed.png new file mode 100644 index 0000000..30206c5 Binary files /dev/null and b/data/button/buttonRightPushed.png differ diff --git a/data/button/checkbox.png b/data/button/checkbox.png new file mode 100644 index 0000000..fe9872f Binary files /dev/null and b/data/button/checkbox.png differ diff --git a/data/button/checkboxChecked.png b/data/button/checkboxChecked.png new file mode 100644 index 0000000..df9013e Binary files /dev/null and b/data/button/checkboxChecked.png differ diff --git a/data/gui.qrc b/data/gui.qrc index 70533fe..28c0c87 100644 --- a/data/gui.qrc +++ b/data/gui.qrc @@ -16,5 +16,13 @@ button/buttonR.png button/go-previous.png progressBar/background.png + button/buttonCenterDisabled.png + button/buttonCenterPushed.png + button/buttonRightDisabled.png + button/buttonRightPushed.png + button/buttonLeftDisabled.png + button/buttonLeftPushed.png + button/checkbox.png + button/checkboxChecked.png diff --git a/src/mdictionary/gui/DictManagerWidget.cpp b/src/mdictionary/gui/DictManagerWidget.cpp index 5084125..692ea26 100644 --- a/src/mdictionary/gui/DictManagerWidget.cpp +++ b/src/mdictionary/gui/DictManagerWidget.cpp @@ -54,7 +54,6 @@ void DictManagerWidget::initalizeUI() { ctxt = qmlView->rootContext(); refreshDictsList(); - //model = new DictManagerModel(, this); ctxt->setContextProperty("dictModel", &(*model)); QGraphicsObject *rootObject = qmlView->rootObject(); @@ -131,10 +130,10 @@ void DictManagerWidget::initalizeUI() { //closeButton = new QPushButton(tr("Save")); //buttonGroup->addWidget(closeButton); - setMinimumWidth(sizeHint().width()*1.2); - setMaximumWidth(sizeHint().width()*2); - setMinimumHeight(sizeHint().height()); - setMaximumHeight(sizeHint().height()*2); +// setMinimumWidth(sizeHint().width()*1.2); +// setMaximumWidth(sizeHint().width()*2); +// setMinimumHeight(sizeHint().height()); +// setMaximumHeight(sizeHint().height()*2); //connect(closeButton, SIGNAL(clicked()), this, SLOT(save())); #endif } @@ -146,8 +145,10 @@ void DictManagerWidget::refreshDictsList() { QHash dicts = guiInterface->getDictionaries(); if (model == 0){ + qDebug("ok"); model = new DictManagerModel(dicts, this); } else { + qDebug("lol"); model->clear(); model->setDictionaries(dicts); } diff --git a/src/mdictionary/gui/DictManagerWidget.h b/src/mdictionary/gui/DictManagerWidget.h index 15befcb..f988659 100644 --- a/src/mdictionary/gui/DictManagerWidget.h +++ b/src/mdictionary/gui/DictManagerWidget.h @@ -35,6 +35,7 @@ #include "DictManagerModel.h" #include #include +#include /*! diff --git a/src/mdictionary/qml/Button.qml b/src/mdictionary/qml/Button.qml index a21cf2f..224a548 100644 --- a/src/mdictionary/qml/Button.qml +++ b/src/mdictionary/qml/Button.qml @@ -27,15 +27,15 @@ BorderImage { style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true } - Rectangle { - id: shade - anchors.centerIn: parent; - radius: parent.height*.4; - color: "black"; - opacity: 0 - width: parent.width; - height: parent.height; - } +// Rectangle { +// id: shade +// anchors.centerIn: parent; +// radius: parent.height*.4; +// color: "black"; +// opacity: 0 +// width: parent.width; +// height: parent.height; +// } Image { id: image1 @@ -68,11 +68,20 @@ BorderImage { states: [ State { - name: "pressed"; when: mouseArea.pressed == true - PropertyChanges { target: shade; opacity: 0.4 } - PropertyChanges { target: image1; opacity: 0.5 } - PropertyChanges { target: image3; opacity: 0.5 } - PropertyChanges { target: image2; opacity: 0.5 } + name: "pressed"; + when: (mouseArea.pressed == true && button.enabled == true); + + PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" } + PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" } + PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" } + }, + State { + name: "disabled"; + when: (button.enabled == false); + + PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" } + PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" } + PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" } } ] diff --git a/src/mdictionary/qml/DictManagerWidget.qml b/src/mdictionary/qml/DictManagerWidget.qml index 2f7c1a0..83cce28 100644 --- a/src/mdictionary/qml/DictManagerWidget.qml +++ b/src/mdictionary/qml/DictManagerWidget.qml @@ -42,11 +42,16 @@ Rectangle { id: dictListDelegate Item { width: rectangle1.width - height: typeText.height + height: { + if (nameText.height + 10 > logo.height) + return nameText.height + 10; + else + return logo.height; + } MouseArea{ anchors.fill: parent onClicked: { - dictTypeList.currentIndex = number + dictList.currentIndex = number } onDoubleClicked: { selectedRow(number) @@ -54,15 +59,48 @@ Rectangle { } Row { //image zaznacz/odznacz - //image logo + anchors.fill: parent + Image { + id: checkbox +// source: "qrc:/button/checkbox.png" + height: { + var aspectRatio = sourceSize.height / sourceSize.width + return logo.width * aspectRatio + } + anchors.verticalCenter: parent.verticalCenter + width: nameText.height + 10 + states: [ + State { + name: "checked"; + when: (isSelected == true); + + PropertyChanges { target: checkbox; source: "qrc:/button/checkboxChecked.png" } + }, + State { + name: "unchecked"; + when: (isSelected == false); + + PropertyChanges { target: checkbox; source: "qrc:/button/checkbox.png" } + } + ] + } + Image { id: logo source: iconPath + height: { + var aspectRatio = sourceSize.height / sourceSize.width + return logo.width * aspectRatio + } + anchors.verticalCenter: parent.verticalCenter + width: nameText.height + 10 } Text { id: nameText text: name -// width: rectangle1.width + anchors.left: logo.right + anchors.leftMargin: 5 + anchors.verticalCenter: parent.verticalCenter } } } diff --git a/src/mdictionary/qml/IconButton.qml b/src/mdictionary/qml/IconButton.qml index 9b66836..7fc32ea 100644 --- a/src/mdictionary/qml/IconButton.qml +++ b/src/mdictionary/qml/IconButton.qml @@ -58,37 +58,21 @@ Rectangle { source: "qrc:/button/buttonR.png" } - Rectangle { - id: shade - z: 4 - anchors.centerIn: parent; - color: "black"; - radius: 20; - opacity: 1; - width: rectangle.width; - height: rectangle.height; - } states: [ State { - name: "enable"; - when: (mouseArea.pressed == false && rectangle.enabled == true); - PropertyChanges { target: shade; - opacity: 0; } - }, - State { name: "disable"; when: (rectangle.enabled == false); - PropertyChanges { target: shade; - color: "black"; - opacity: .5; } + PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" } + PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" } + PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" } }, State { name: "clicked"; when: (mouseArea.pressed == true && rectangle.enabled == true); - PropertyChanges { target: shade; - color: "#fffead" - opacity: 0.5; } + PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" } + PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" } + PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" } } ] }