[Kget] [Bug 56997] settings saved on click on cancel button

Pino Toscano toscano.pino at tiscali.it
Fri Mar 4 23:03:32 CET 2005


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=56997         
toscano.pino tiscali it changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From toscano.pino tiscali it  2005-03-04 23:03 -------
CVS commit by pino: 

Backporting fix for bug #56997 (normal): settings saved on click on cancel button

BUGS: 56997


  M +42 -35    dlgPreferences.cpp   1.18.8.1
  M +8 -4      dlgPreferences.h   1.6.8.1


--- kdenetwork/kget/dlgPreferences.cpp  #1.18:1.18.8.1
 @ -59,5 +59,4  @ DlgPreferences::DlgPreferences(QWidget *
     conDlg = new DlgConnection(page);
     topLayout->addWidget(conDlg);
-    connect( conDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
 
     page = addPage(i18n("Automation"));
 @ -66,5 +65,4  @ DlgPreferences::DlgPreferences(QWidget *
     topLayout->addWidget(autDlg);
     topLayout->addStretch();
-    connect( autDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
 
     page = addPage(i18n("Limits"));
 @ -73,5 +71,4  @ DlgPreferences::DlgPreferences(QWidget *
     topLayout->addWidget(limDlg);
     topLayout->addStretch();
-    connect( limDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
 
     page = addPage(i18n("Advanced"));
 @ -80,5 +77,4  @ DlgPreferences::DlgPreferences(QWidget *
     topLayout->addWidget(advDlg);
     topLayout->addStretch();
-    connect( advDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
 
     // page = addPage(i18n("Search"));
 @ -92,5 +88,4  @ DlgPreferences::DlgPreferences(QWidget *
     topLayout->addWidget(dirDlg);
     topLayout->addStretch();
-    connect( dirDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
 
     page = addPage(i18n("System"));
 @ -99,19 +94,16  @ DlgPreferences::DlgPreferences(QWidget *
     topLayout->addWidget(sysDlg);
     topLayout->addStretch();
-    connect( sysDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
 
     // type of connection influences autoDisconnect & timedDisconnect features
     connect(conDlg, SIGNAL(typeChanged(int)), autDlg, SLOT(slotTypeChanged(int)));
 
-    connect(this, SIGNAL(applyClicked()), SLOT(applySettings()));
+    loadAllData();
 
-    conDlg->setData();
-    autDlg->setData();
-    limDlg->setData();
-    advDlg->setData();
-    //        seaDlg->setData();
-    dirDlg->setData();
-    sysDlg->setData();
-    enableButton( Apply, false );
+    connect( conDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
+    connect( autDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
+    connect( limDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
+    connect( advDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
+    connect( dirDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
+    connect( sysDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
 }
 
 @ -119,26 +111,8  @ DlgPreferences::DlgPreferences(QWidget *
 void DlgPreferences::slotChanged()
 {
+    changed = true;
     enableButton( Apply, true );
 }
 
-
-void
-DlgPreferences::closeEvent(QCloseEvent * e)
-{
-    kmain->m_paPreferences->setEnabled(true);
-    KDialogBase::closeEvent(e);
-}
-
-
-void DlgPreferences::done(int r)
-{
-    if (r != Rejected) {
-        applySettings();
-    }
-
-    hide();
-}
-
-
 void DlgPreferences::applySettings()
 {
 @ -152,4 +126,37  @ void DlgPreferences::applySettings()
 
     ksettings.save();
+    changed = false;
+    enableButton( Apply, false );
+}
+
+void DlgPreferences::slotOk()
+{
+    if ( changed )
+        applySettings();
+    accept();
+}
+
+void DlgPreferences::slotCancel()
+{
+    if ( changed )
+        loadAllData();
+    reject();
+}
+
+void DlgPreferences::slotApply()
+{
+    applySettings();
+}
+
+void DlgPreferences::loadAllData()
+{
+    conDlg->setData();
+    autDlg->setData();
+    limDlg->setData();
+    advDlg->setData();
+    //        seaDlg->setData();
+    dirDlg->setData();
+    sysDlg->setData();
+    changed = false;
     enableButton( Apply, false );
 }

--- kdenetwork/kget/dlgPreferences.h  #1.6:1.6.8.1
 @ -50,6 +50,4  @ Q_OBJECT public:
     ~DlgPreferences()
     {}
-protected:
-    void closeEvent(QCloseEvent *);
 
 private:
 @ -64,8 +62,14  @ private:
     DlgSystem *sysDlg;
 
+    bool changed;
+
+    void loadAllData();
+
 protected slots:
-    virtual void done(int r);
     void applySettings();
     void slotChanged();
+    virtual void slotOk();
+    virtual void slotCancel();
+    virtual void slotApply();
 
 };



More information about the Kget mailing list