Change the icons in the combox box when saving / clearing config.
authorRoy Marples <roy@marples.name>
Thu, 20 Nov 2014 08:00:27 +0000 (08:00 +0000)
committerRoy Marples <roy@marples.name>
Thu, 20 Nov 2014 08:00:27 +0000 (08:00 +0000)
Discard now works correctly.

src/dhcpcd-qt/dhcpcd-preferences.cpp
src/dhcpcd-qt/dhcpcd-preferences.h

index 032f10b379c1bcd23adedd6ec8bca568098d77e6..2e0217a7c58c6ae83f138bbfda8e203079c7d18e 100644 (file)
@@ -60,6 +60,7 @@ DhcpcdPreferences::DhcpcdPreferences(DhcpcdQt *parent)
 
        name = NULL;
        config = NULL;
+       configIndex = -1;
        eWhat = eBlock = NULL;
        iface = NULL;
 
@@ -235,7 +236,9 @@ void DhcpcdPreferences::listBlocks(const QString &txt)
 
 void DhcpcdPreferences::clearConfig()
 {
+       QIcon icon = DhcpcdQt::getIcon("actions", "document-new");
 
+       blocks->setItemIcon(blocks->currentIndex(), icon);
        autoConf->setChecked(true);
        ip->setText("");
        router->setText("");
@@ -353,7 +356,7 @@ bool DhcpcdPreferences::writeConfig(bool *cancel)
                *cancel = true;
                return false;
        case QMessageBox::Discard:
-               *cancel = true;
+               *cancel = false;
                return true;
        default:
                break;
@@ -374,6 +377,12 @@ bool DhcpcdPreferences::writeConfig(bool *cancel)
                    .arg(strerror(errno)));
                goto err;
        }
+
+       /* Braces to avoid jump error */
+       {
+               QIcon icon = DhcpcdQt::getIcon("actions", "document-save");
+               blocks->setItemIcon(configIndex, icon);
+       }
        return true;
 
 err:
@@ -422,6 +431,11 @@ void DhcpcdPreferences::showBlock(const QString &txt)
        } else
                config = NULL;
 
+       if (config == NULL)
+               configIndex = -1;
+       else
+               configIndex = blocks->currentIndex();
+
        showConfig();
        bool enabled = dhcpcd_config_writeable(con) && eBlock != NULL;
        autoConf->setEnabled(enabled);
index c90e92dc6efec8c4a91173c4bdbec3b70c77480f..b2bc7a473c4d7b52e91c9e7c1d4a2ca88420d6c3 100644 (file)
@@ -66,6 +66,7 @@ private:
 
        DHCPCD_IF *iface;
        char *name;
+       int configIndex;
        DHCPCD_OPTION *config;
        const char *getString(QLineEdit *le);
        bool setOption(const char *opt, const char *val, bool *ret);