Frontend: Properly “gray out” most disabled widgets (a lot of them weren't)
authorWuzzy <Wuzzy2@mail.ru>
Fri, 16 Mar 2018 19:05:11 +0100
changeset 13228 d23742ccf92b
parent 13227 26c739440bef
child 13230 d5a029299407
Frontend: Properly “gray out” most disabled widgets (a lot of them weren't)
QTfrontend/hedgewars.qrc
QTfrontend/res/css/qt.css
QTfrontend/res/dropdown_disabled.png
QTfrontend/res/lock_disabled.png
QTfrontend/res/spin_down_disabled.png
QTfrontend/res/spin_up_disabled.png
QTfrontend/res/unlock_disabled.png
QTfrontend/ui/page/pagescheme.cpp
QTfrontend/ui/page/pagescheme.h
QTfrontend/ui/widget/colorwidget.cpp
QTfrontend/ui/widget/gamecfgwidget.cpp
QTfrontend/ui/widget/hedgehogerWidget.cpp
QTfrontend/ui/widget/mapContainer.cpp
QTfrontend/ui/widget/teamselhelper.cpp
--- a/QTfrontend/hedgewars.qrc	Fri Mar 16 16:35:08 2018 +0100
+++ b/QTfrontend/hedgewars.qrc	Fri Mar 16 19:05:11 2018 +0100
@@ -80,6 +80,7 @@
         <file>res/camera.png</file>
         <file>res/Settings.png</file>
         <file>res/dropdown.png</file>
+        <file>res/dropdown_disabled.png</file>
         <file>res/new.png</file>
         <file>res/edit.png</file>
         <file>res/delete.png</file>
@@ -115,7 +116,9 @@
         <file>res/lightbulb_on.png</file>
         <file>res/lightbulb_off.png</file>
         <file>res/spin_up.png</file>
+        <file>res/spin_up_disabled.png</file>
         <file>res/spin_down.png</file>
+        <file>res/spin_down_disabled.png</file>
         <file>res/PlaySound.png</file>
         <file>res/hh_small.png</file>
         <file>res/btnDisabled.png</file>
@@ -181,7 +184,9 @@
         <file>res/info.png</file>
         <file>res/kick.png</file>
         <file>res/lock.png</file>
+        <file>res/lock_disabled.png</file>
         <file>res/unlock.png</file>
+        <file>res/unlock_disabled.png</file>
         <file>res/StatsMedal1.png</file>
         <file>res/StatsMedal2.png</file>
         <file>res/StatsMedal3.png</file>
--- a/QTfrontend/res/css/qt.css	Fri Mar 16 16:35:08 2018 +0100
+++ b/QTfrontend/res/css/qt.css	Fri Mar 16 19:05:11 2018 +0100
@@ -56,6 +56,19 @@
 border-color: yellow;
 }
 
+TeamShowWidget QPushButton {
+icon-size: 48px;
+text-align: left;
+background-color: #0d0544;
+color: orange;
+font: bold;
+border-width: 2px;
+margin: 6px 0px 6px 0px;
+}
+TeamShowWidget QPushButton:disabled {
+color: #a0a0a0;
+}
+
 QToolButton {
 background-color: #11084A;
 }
@@ -76,6 +89,11 @@
 #mapPreview {
 background-color: #0d0544;
 }
+#mapPreview:disabled{
+border-color: #a0a0a0;
+background-color: #0d0544;
+color: #ffffff;
+}
 
 QLineEdit, QLabel, QHeaderView, QListWidget, QListView, QTableView,
 QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView,
@@ -111,10 +129,6 @@
 border-top-left-radius: 0px;
 }
 
-QLineEdit:disabled, QSpinBox:disabled {
-border-color: gray;
-}
-
 GameCFGWidget {
 border: none;
 }
@@ -166,10 +180,16 @@
 QSpinBox::up-arrow {
 image: url(":/res/spin_up.png");
 }
+QSpinBox::up-arrow:disabled {
+image: url(":/res/spin_up_disabled.png");
+}
 
 QSpinBox::down-arrow {
 image: url(":/res/spin_down.png");
 }
+QSpinBox::down-arrow:disabled {
+image: url(":/res/spin_down_disabled.png");
+}
 
 QSpinBox::down-button {
 background: transparent;
@@ -192,6 +212,9 @@
 QComboBox::down-arrow {
 image: url(":/res/dropdown.png");
 }
+QComboBox::down-arrow:disabled {
+image: url(":/res/dropdown_disabled.png");
+}
 
 VertScrArea {
 background-position: bottom center;
@@ -287,6 +310,11 @@
 
 :disabled{
 color: #a0a0a0;
+border-color: #a0a0a0;
+}
+QListWidget:item:selected:disabled, QListView:item:selected:disabled{
+color: rgba(13, 5, 68, 70%);
+background-color: #a0a0a0;
 }
 SquareLabel, ItemNum {
 background-color: #000000;
@@ -297,6 +325,9 @@
 margin: 2px 0px;
 background-color: #ffcc00;
 }
+QSlider::groove::horizontal:disabled {
+background-color: #a0a0a0;
+}
 
 QSlider::handle::horizontal {
 border: 0px;
@@ -306,6 +337,9 @@
 height: 6px;
 border-radius: 3px;
 }
+QSlider::handle::horizontal:disabled {
+background-color: #a0a0a0;
+}
 
 HatButton, ThemeButton {
 text-align: left;
Binary file QTfrontend/res/dropdown_disabled.png has changed
Binary file QTfrontend/res/lock_disabled.png has changed
Binary file QTfrontend/res/spin_down_disabled.png has changed
Binary file QTfrontend/res/spin_up_disabled.png has changed
Binary file QTfrontend/res/unlock_disabled.png has changed
--- a/QTfrontend/ui/page/pagescheme.cpp	Fri Mar 16 16:35:08 2018 +0100
+++ b/QTfrontend/ui/page/pagescheme.cpp	Fri Mar 16 19:05:11 2018 +0100
@@ -494,15 +494,14 @@
     LE_ScriptParam->setMaxLength(240);
     glBSLayout->addWidget(LE_ScriptParam,17,2,1,1);
 
-
-    l = new QLabel(gbBasicSettings);
-    l->setText(QLabel::tr("Scheme Name:"));
+    L_name = new QLabel(gbBasicSettings);
+    L_name->setText(QLabel::tr("Scheme Name:"));
 
     LE_name = new QLineEdit(this);
     LE_name->setWhatsThis(tr("Name of this scheme"));
 
     gl->addWidget(LE_name,15,1,1,5);
-    gl->addWidget(l,15,0,1,1);
+    gl->addWidget(L_name,15,0,1,1);
 
     return pageLayout;
 }
@@ -641,6 +640,7 @@
     gbGameModes->setEnabled(n >= c);
     gbBasicSettings->setEnabled(n >= c);
     LE_name->setEnabled(n >= c);
+    L_name->setEnabled(n >= c);
 }
 
 
--- a/QTfrontend/ui/page/pagescheme.h	Fri Mar 16 16:35:08 2018 +0100
+++ b/QTfrontend/ui/page/pagescheme.h	Fri Mar 16 19:05:11 2018 +0100
@@ -94,6 +94,7 @@
         QSpinBox * SB_GetAwayTime;
         QComboBox * CB_WorldEdge;
         QLineEdit * LE_name;
+        QLabel * L_name;
         QLineEdit * LE_ScriptParam;
 
         QGroupBox * gbGameModes;
--- a/QTfrontend/ui/widget/colorwidget.cpp	Fri Mar 16 16:35:08 2018 +0100
+++ b/QTfrontend/ui/widget/colorwidget.cpp	Fri Mar 16 19:05:11 2018 +0100
@@ -30,7 +30,7 @@
 
     QStandardItem * item = m_colorsModel->item(m_color);
 
-    setStyleSheet(QString("border: 2px solid orange; border-radius: 8px; background: %1").arg(item->data().value<QColor>().name()));
+    setStyleSheet(QString("* { border: 2px solid #ffcc00; border-radius: 8px; background: %1 } :disabled { border-color: #a0a0a0; }").arg(item->data().value<QColor>().name()));
     /*
     QPalette p = palette();
     p.setColor(QPalette::Window, item->data().value<QColor>());
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp	Fri Mar 16 16:35:08 2018 +0100
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp	Fri Mar 16 19:05:11 2018 +0100
@@ -130,11 +130,12 @@
     SchemeWidgetLayout->addWidget(new QLabel(QLabel::tr("Scheme"), SchemeWidget), 0, 0);
 
     QPixmap pmEdit(":/res/edit.png");
+    QIcon iconEdit = QIcon(pmEdit);
 
     QPushButton * goToSchemePage = new QPushButton(SchemeWidget);
     goToSchemePage->setWhatsThis(tr("Edit schemes"));
     goToSchemePage->setIconSize(pmEdit.size());
-    goToSchemePage->setIcon(pmEdit);
+    goToSchemePage->setIcon(iconEdit);
     goToSchemePage->setMaximumWidth(pmEdit.width() + 6);
     SchemeWidgetLayout->addWidget(goToSchemePage, 0, 3);
     connect(goToSchemePage, SIGNAL(clicked()), this, SLOT(jumpToSchemes()));
@@ -159,8 +160,10 @@
     bindEntries->setWhatsThis(tr("Game scheme will auto-select a weapon"));
     bindEntries->setChecked(true);
     bindEntries->setMaximumWidth(42);
-    bindEntries->setStyleSheet( "QCheckBox::indicator:checked   { image: url(\":/res/lock.png\"); }"
-                                "QCheckBox::indicator:unchecked { image: url(\":/res/unlock.png\");   }" );
+    bindEntries->setStyleSheet( "QCheckBox::indicator:checked:enabled    { image: url(\":/res/lock.png\"); }"
+                                "QCheckBox::indicator:checked:disabled   { image: url(\":/res/lock_disabled.png\"); }"
+                                "QCheckBox::indicator:unchecked:enabled  { image: url(\":/res/unlock.png\");   }"
+                                "QCheckBox::indicator:unchecked:disabled { image: url(\":/res/unlock_disabled.png\");   }" );
     SchemeWidgetLayout->addWidget(bindEntries, 0, 1, 0, 1, Qt::AlignVCenter);
 
     connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &)));
--- a/QTfrontend/ui/widget/hedgehogerWidget.cpp	Fri Mar 16 16:35:08 2018 +0100
+++ b/QTfrontend/ui/widget/hedgehogerWidget.cpp	Fri Mar 16 19:05:11 2018 +0100
@@ -63,6 +63,7 @@
 void CHedgehogerWidget::setNonInteractive()
 {
     nonInteractive=true;
+    repaint();
 }
 
 void CHedgehogerWidget::setHHNum(unsigned int num)
@@ -105,6 +106,8 @@
     }
 
     QPainter painter(this);
+    if(nonInteractive)
+        painter.setPen(QPen(QColor("#FFA0A0A0")));
     painter.setFont(QFont("MS Shell Dlg", 10, QFont::Bold));
     painter.drawText(this->width() - 12, 23, QString::number(numItems));
 
--- a/QTfrontend/ui/widget/mapContainer.cpp	Fri Mar 16 16:35:08 2018 +0100
+++ b/QTfrontend/ui/widget/mapContainer.cpp	Fri Mar 16 19:05:11 2018 +0100
@@ -98,10 +98,15 @@
     twoColumnLayout->addLayout(rightLayout, 0);
     QVBoxLayout * drawnControls = new QVBoxLayout();
 
+    /* Map type label */
+
+    QLabel* lblMapType = new QLabel(tr("Map type:"));
+    topLayout->setSpacing(10);
+    topLayout->addWidget(lblMapType, 0);
+    m_childWidgets << lblMapType;
+
     /* Map type combobox */
 
-    topLayout->setSpacing(10);
-    topLayout->addWidget(new QLabel(tr("Map type:")), 0);
     cType = new QComboBox(this);
     topLayout->addWidget(cType, 1);
     cType->insertItem(0, tr("Image map"), MapModel::StaticMap);
@@ -148,6 +153,7 @@
     QLabel * lblMapPreviewText = new QLabel(this);
     lblMapPreviewText->setText(tr("Map preview:"));
     leftLayout->addWidget(lblMapPreviewText, 0);
+    m_childWidgets << lblMapPreviewText;
 
     /* Map Preview */
 
@@ -158,6 +164,7 @@
     mapPreview->setContentsMargins(0, 0, 0, 0);
     leftLayout->addWidget(mapPreview, 0);
     connect(mapPreview, SIGNAL(clicked()), this, SLOT(previewClicked()));
+    m_childWidgets << mapPreview;
 
     /* Bottom-Left layout */
 
@@ -168,6 +175,7 @@
 
     lblMapList = new QLabel(this);
     rightLayout->addWidget(lblMapList, 0);
+    m_childWidgets << lblMapList;
 
     /* Static maps list */
 
@@ -329,7 +337,12 @@
     pc.fillRect(centered.rect(), linearGrad);
     pc.drawPixmap(-3, -3, finalImage);*/
 
-    mapPreview->setIcon(QIcon(finalImage));
+    // Set the map preview image. Make sure it is always colored the same,
+    // no matter if disabled or not.
+    QIcon mapPreviewIcon = QIcon();
+    mapPreviewIcon.addPixmap(finalImage, QIcon::Normal);
+    mapPreviewIcon.addPixmap(finalImage, QIcon::Disabled);
+    mapPreview->setIcon(mapPreviewIcon);
     mapPreview->setIconSize(finalImage.size());
 }
 
--- a/QTfrontend/ui/widget/teamselhelper.cpp	Fri Mar 16 16:35:08 2018 +0100
+++ b/QTfrontend/ui/widget/teamselhelper.cpp	Fri Mar 16 19:05:11 2018 +0100
@@ -57,15 +57,6 @@
     butt->setFlat(true);
     butt->setToolTip(team.owner());
     mainLayout.addWidget(butt);
-    butt->setStyleSheet("QPushButton{"
-                        "icon-size: 48px;"
-                        "text-align: left;"
-                        "background-color: #0d0544;"
-                        "color: orange;"
-                        "font: bold;"
-                        "border-width: 2px;"
-                        "margin: 6px 0px 6px 0px;"
-                        "}");
 
     if(m_isPlaying)
     {