Fix button graphics when button was pressed or disabled. Add disabled state to button...
authorMarcin Kaźmierczak <marcin@marcin-desktop.(none)>
Thu, 23 Dec 2010 15:24:12 +0000 (16:24 +0100)
committerMarcin Kaźmierczak <marcin@marcin-desktop.(none)>
Thu, 23 Dec 2010 15:24:12 +0000 (16:24 +0100)
14 files changed:
data/button/buttonCenterDisabled.png [new file with mode: 0644]
data/button/buttonCenterPushed.png [new file with mode: 0644]
data/button/buttonLeftDisabled.png [new file with mode: 0644]
data/button/buttonLeftPushed.png [new file with mode: 0644]
data/button/buttonRightDisabled.png [new file with mode: 0644]
data/button/buttonRightPushed.png [new file with mode: 0644]
data/button/checkbox.png [new file with mode: 0644]
data/button/checkboxChecked.png [new file with mode: 0644]
data/gui.qrc
src/mdictionary/gui/DictManagerWidget.cpp
src/mdictionary/gui/DictManagerWidget.h
src/mdictionary/qml/Button.qml
src/mdictionary/qml/DictManagerWidget.qml
src/mdictionary/qml/IconButton.qml

diff --git a/data/button/buttonCenterDisabled.png b/data/button/buttonCenterDisabled.png
new file mode 100644 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
index 0000000..df9013e
Binary files /dev/null and b/data/button/checkboxChecked.png differ
index 70533fe..28c0c87 100644 (file)
         <file>button/buttonR.png</file>
         <file>button/go-previous.png</file>
         <file>progressBar/background.png</file>
+        <file>button/buttonCenterDisabled.png</file>
+        <file>button/buttonCenterPushed.png</file>
+        <file>button/buttonRightDisabled.png</file>
+        <file>button/buttonRightPushed.png</file>
+        <file>button/buttonLeftDisabled.png</file>
+        <file>button/buttonLeftPushed.png</file>
+        <file>button/checkbox.png</file>
+        <file>button/checkboxChecked.png</file>
     </qresource>
 </RCC>
index 5084125..692ea26 100644 (file)
@@ -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<CommonDictInterface*, bool> dicts = guiInterface->getDictionaries();
 
     if (model == 0){
+        qDebug("ok");
         model = new DictManagerModel(dicts, this);
     } else {
+        qDebug("lol");
         model->clear();
         model->setDictionaries(dicts);
     }
index 15befcb..f988659 100644 (file)
@@ -35,6 +35,7 @@
 #include "DictManagerModel.h"
 #include <QtDeclarative/QDeclarativeView>
 #include <QtDeclarative/QDeclarativeContext>
+#include <QDebug>
 
 
 /*!
index a21cf2f..224a548 100644 (file)
@@ -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" }
         }
     ]
 
index 2f7c1a0..83cce28 100644 (file)
@@ -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
                     }
                 }
             }
index 9b66836..7fc32ea 100644 (file)
@@ -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" }
         }
     ]
 }