SettingsDialog::SettingsDialog(QWidget* parent, int flags) : BaseWindow(OnlyCloseButton, NoResize, parent) , m_propertyMapper(new SettingsPropertyMapper(this)) , editRssRule(NULL) , deleteRssRule(NULL) { setupUi(this); previousFocuse = NULL; settings = QApplicationSettings::getInstance(); rcon = RconWebService::getInstance(); tracker = TorrentTracker::getInstance(); FillDTTab(); FillRestrictionTab(); FillFilteringGroups(); FillGeneralTab(); FillHDDTab(); FillWebUITab(); SetupSchedullerTab(); FillKeyMapTab(); FillNetworkTab(); FillRssTab(); setupCustomWindow(); QPushButton* applyButton = buttonBox->button(QDialogButtonBox::Apply); if (applyButton != NULL) { applyButton->setEnabled(false); } setupWindowIcons(); StyleEngene* style = StyleEngene::getInstance(); connect(style, SIGNAL(styleChanged()), this, SLOT(setupWindowIcons())); connect(m_propertyMapper.get(), SIGNAL(GotChanges()), SLOT(EnableApplyButton())); connect(m_propertyMapper.get(), SIGNAL(NoChanges()), SLOT(DisableApplyButton())); }
BOOL CProfileAssociationPage::OnInit() { m_pcpTarget = new CProfile(m_csProfile); if (m_pcpTarget) { // Set profile filename SetDlgItemText(m_hwnd, ProfileFilename, m_pcpTarget->GetName()); // Update ICON to show installed/non-installed status. HICON hIcon = LoadIcon(CGlobals::Instance(), MAKEINTRESOURCE(m_pcpTarget->IsInstalled() ? DefaultIcon : UninstalledIcon)); if (hIcon) { SendDlgItemMessage(m_hwnd, StatusIcon, STM_SETICON, (WPARAM) hIcon, 0); } // Clean up add/delete list. m_cuaAdd.Empty(); m_cuaDelete.Empty(); // Build tentitive association list. ConstructAssociations(); // And then, fill up device listbox UpdateDeviceListBox(); // And set focus on AddButton. SetFocus(GetDlgItem(m_hwnd,AddButton)); DisableApplyButton(); SettingChanged(FALSE); return TRUE; } else { return FALSE; } }
BOOL CProfileAssociationPage::OnNotify(int idCtrl, LPNMHDR pnmh) { switch (pnmh -> code) { case PSN_APPLY: { if (SettingChanged()) { // Disable apply button, because current request are // going to be "Applied". DisableApplyButton(); // We are going to update changed. SettingChanged(FALSE); // Remove any associations we're removing while (m_cuaDelete.Count()) { m_pcpTarget->Dissociate(m_pcpTarget->DeviceName(m_cuaDelete[0])); m_cuaDelete.Remove(0); } // Add any associations we're adding while (m_cuaAdd.Count()) { m_pcpTarget->Associate(m_pcpTarget->DeviceName(m_cuaAdd[0])); m_cuaAdd.Remove(0); } // Re-create CProfile object. // // !!! Need to be done some performance work here. delete m_pcpTarget; m_pcpTarget = new CProfile(m_csProfile); if (!m_pcpTarget) { // BUGBUG proper error should happen. return FALSE; } // Re-Build tentitive association list. ConstructAssociations(); UpdateDeviceListBox(); // check the install status to refect icon. HICON hIcon = LoadIcon(CGlobals::Instance(), MAKEINTRESOURCE(m_pcpTarget->IsInstalled() ? DefaultIcon : UninstalledIcon)); if (hIcon) { SendDlgItemMessage(m_hwnd, StatusIcon, STM_SETICON, (WPARAM) hIcon, 0); } } break; } } return TRUE; }