From: Roy Marples Date: Thu, 20 Nov 2014 08:00:27 +0000 (+0000) Subject: Change the icons in the combox box when saving / clearing config. X-Git-Tag: dhcpcd-ui-0.7.5~28 X-Git-Url: https://roy.marples.name/git Change the icons in the combox box when saving / clearing config. Discard now works correctly. --- diff --git a/src/dhcpcd-qt/dhcpcd-preferences.cpp b/src/dhcpcd-qt/dhcpcd-preferences.cpp index 032f10b..2e0217a 100644 --- a/src/dhcpcd-qt/dhcpcd-preferences.cpp +++ b/src/dhcpcd-qt/dhcpcd-preferences.cpp @@ -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); diff --git a/src/dhcpcd-qt/dhcpcd-preferences.h b/src/dhcpcd-qt/dhcpcd-preferences.h index c90e92d..b2bc7a4 100644 --- a/src/dhcpcd-qt/dhcpcd-preferences.h +++ b/src/dhcpcd-qt/dhcpcd-preferences.h @@ -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);