[kde-doc-english] [kstars] kstars: In the Geographic Location form, inform users of validation errors.

Akarsh Simha akarsh.simha at kdemail.net
Thu Dec 18 04:43:16 UTC 2014


Git commit 1034254a467fe229a6c5629465088d594554e355 by Akarsh Simha.
Committed on 18/12/2014 at 04:30.
Pushed by asimha into branch 'master'.

In the Geographic Location form, inform users of validation errors.

Daniel just reported a bug on the bugzilla about a usability issue in
the Geographic Location form.

The issue is that users are not informed of validation errors, so it's
not obvious as to why the 'Add City to List' button is grayed
out. (Also, counterintuitively, the longitude box comes before the
latitude box. Maybe this should be changed too...).

This commit fixes the problem by including a label that displays the
appropriate error message.

Thanks, Daniel! I was looking for some low-hanging fruit :)

BUG: 341965
GUI:

M  +22   -3    kstars/dialogs/locationdialog.cpp
M  +78   -1    kstars/dialogs/locationdialog.ui
M  +0    -2    kstars/tools/observinglist.cpp

http://commits.kde.org/kstars/1034254a467fe229a6c5629465088d594554e355

diff --git a/kstars/dialogs/locationdialog.cpp b/kstars/dialogs/locationdialog.cpp
index b55dde0..f9cbc33 100644
--- a/kstars/dialogs/locationdialog.cpp
+++ b/kstars/dialogs/locationdialog.cpp
@@ -94,8 +94,10 @@ LocationDialog::LocationDialog( QWidget* parent ) :
     nameModified = false;
     ld->AddCityButton->setEnabled( false );    
 
+    ld->errorLabel->setText( QString() );
+
     initCityList();
-    resize (640, 480);    
+    resize (640, 480);
 }
 
 void LocationDialog::initCityList() {
@@ -575,12 +577,29 @@ void LocationDialog::dataChanged() {
     ld->AddCityButton->setEnabled( nameModified && !ld->NewCityName->text().isEmpty() &&
                                    !ld->NewCountryName->text().isEmpty() &&
                                    checkLongLat() );
-
-
     if (SelectedCity)
         ld->UpdateButton->setEnabled(SelectedCity->isReadOnly() == false && !ld->NewCityName->text().isEmpty()
                                  && !ld->NewCountryName->text().isEmpty() &&
                                  checkLongLat());
+
+    if( !addCityEnabled() ) {
+        if( ld->NewCityName->text().isEmpty() ) {
+            ld->errorLabel->setText( xi18n( "Cannot add new location -- city name blank" ) );
+        }
+        else if( ld->NewCountryName->text().isEmpty() ) {
+            ld->errorLabel->setText( xi18n( "Cannot add new location -- country name blank" ) );
+        }
+        else if( !checkLongLat() ) {
+            ld->errorLabel->setText( xi18n( "Cannot add new location -- invalid latitude / longitude" ) );
+        }
+        else {
+            ld->errorLabel->setText( xi18n( "Cannot add new location -- please check all fields" ) );
+        }
+    }
+    else {
+        ld->errorLabel->setText( QString() );
+    }
+
 }
 
 void LocationDialog::slotOk() {
diff --git a/kstars/dialogs/locationdialog.ui b/kstars/dialogs/locationdialog.ui
index 1c2fee1..366f8cd 100644
--- a/kstars/dialogs/locationdialog.ui
+++ b/kstars/dialogs/locationdialog.ui
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>760</width>
+    <width>776</width>
     <height>559</height>
    </rect>
   </property>
@@ -545,6 +545,83 @@
           </item>
          </layout>
         </item>
+        <item>
+         <widget class="QLabel" name="errorLabel">
+          <property name="palette">
+           <palette>
+            <active>
+             <colorrole role="WindowText">
+              <brush brushstyle="SolidPattern">
+               <color alpha="255">
+                <red>255</red>
+                <green>0</green>
+                <blue>0</blue>
+               </color>
+              </brush>
+             </colorrole>
+             <colorrole role="Text">
+              <brush brushstyle="SolidPattern">
+               <color alpha="255">
+                <red>0</red>
+                <green>0</green>
+                <blue>0</blue>
+               </color>
+              </brush>
+             </colorrole>
+            </active>
+            <inactive>
+             <colorrole role="WindowText">
+              <brush brushstyle="SolidPattern">
+               <color alpha="255">
+                <red>255</red>
+                <green>0</green>
+                <blue>0</blue>
+               </color>
+              </brush>
+             </colorrole>
+             <colorrole role="Text">
+              <brush brushstyle="SolidPattern">
+               <color alpha="255">
+                <red>0</red>
+                <green>0</green>
+                <blue>0</blue>
+               </color>
+              </brush>
+             </colorrole>
+            </inactive>
+            <disabled>
+             <colorrole role="WindowText">
+              <brush brushstyle="SolidPattern">
+               <color alpha="255">
+                <red>190</red>
+                <green>190</green>
+                <blue>190</blue>
+               </color>
+              </brush>
+             </colorrole>
+             <colorrole role="Text">
+              <brush brushstyle="SolidPattern">
+               <color alpha="255">
+                <red>190</red>
+                <green>190</green>
+                <blue>190</blue>
+               </color>
+              </brush>
+             </colorrole>
+            </disabled>
+           </palette>
+          </property>
+          <property name="font">
+           <font>
+            <weight>75</weight>
+            <bold>true</bold>
+           </font>
+          </property>
+          <property name="text">
+           <string/>
+          </property>
+         </widget>
+        </item>
        </layout>
       </item>
      </layout>
diff --git a/kstars/tools/observinglist.cpp b/kstars/tools/observinglist.cpp
index cb06041..8b891e3 100644
--- a/kstars/tools/observinglist.cpp
+++ b/kstars/tools/observinglist.cpp
@@ -1310,5 +1310,3 @@ QString ObservingList::getObjectName(const SkyObject *o, bool translated)
     return finalObjectName;
 
 }
-
-


More information about the kde-doc-english mailing list