[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    [PATCH] kdeutils/khexedit UI Inconsistency OK APPLY buttons
From:       Willy De la Court <Willy.DelaCourt () pandora ! be>
Date:       2003-04-01 16:33:51
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Patch comments
- ------------------------------------------------------
UI Inconsistency OK APPLY buttons
Apply diabled when nothing is changed
Ok only saves when something is changed
- ------------------------------------------------------

I'll wait 2 days for comments on this before commiting.
- -- 
Simple things make people happy.
Willy De la Court
PGP Public Key at http://www.linux-lovers.be/download/public_key.asc
PGP Key fingerprint = 784E E18F 7F85 9C7C AC1A D5FB FE08 686C 37C7 A689
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+ib9w/ghobDfHpokRAnWSAJ9Bof0jMcL2F4UebsDA0aGu5vHxeQCg7IqD
ya8/qZkA+yY6nqkMW2tR5Sk=
=VyAn
-----END PGP SIGNATURE-----

["kdeutils_khexedit.applyok.patch" (text/x-diff)]

Index: optiondialog.cc
===================================================================
RCS file: /home/kde/kdeutils/khexedit/optiondialog.cc,v
retrieving revision 1.39
diff -u -p -r1.39 optiondialog.cc
--- optiondialog.cc	7 Mar 2003 22:11:27 -0000	1.39
+++ optiondialog.cc	1 Apr 2003 16:30:49 -0000
@@ -75,6 +75,8 @@ COptionDialog::COptionDialog( QWidget *p
   setupColorPage();
   setupFilePage();
   setupMiscPage();
+  enableButton( Apply, false );
+  configChanged = false;
 }
 
 
@@ -82,6 +84,11 @@ COptionDialog::~COptionDialog( void )
 {
 }
 
+void COptionDialog::slotChanged()
+{
+  enableButton( Apply, true );
+  configChanged = true;
+}
 
 void COptionDialog::showEvent( QShowEvent *e )
 {
@@ -110,6 +117,8 @@ void COptionDialog::setupLayoutPage( voi
   mLayout.formatCombo->insertStringList( modeList );
   connect( mLayout.formatCombo, SIGNAL(activated(int)),
 	   SLOT(slotModeSelectorChanged(int)) );
+  connect( mLayout.formatCombo, SIGNAL(activated(int)),
+    SLOT(slotChanged()) );
   gbox->addWidget( mLayout.formatCombo, 0, 1 );
 
   //
@@ -121,12 +130,16 @@ void COptionDialog::setupLayoutPage( voi
   mLayout.lineSizeSpin->setRange( 1, 10000 );
   connect( mLayout.lineSizeSpin, SIGNAL(valueChanged(int)),
 	   SLOT(slotLineSizeChanged(int) ) );
+  connect( mLayout.lineSizeSpin, SIGNAL(valueChanged(int)),
+    SLOT(slotChanged()) );
   gbox->addWidget( mLayout.lineSizeSpin, 1, 1 );
 
   mLayout.columnSizeSpin = new QSpinBox( page );
   mLayout.columnSizeSpin->setRange( 1, 10000 );
   connect( mLayout.columnSizeSpin, SIGNAL(valueChanged(int)),
 	   SLOT(slotColumnSizeChanged(int) ) );
+  connect( mLayout.columnSizeSpin, SIGNAL(valueChanged(int)),
+    SLOT(slotChanged() ) );
   gbox->addWidget( mLayout.columnSizeSpin, 2, 1 );
 
   text = i18n("Default l&ine size [bytes]:");
@@ -144,10 +157,14 @@ void COptionDialog::setupLayoutPage( voi
   text = i18n("Line size is &fixed (use scrollbar when required)");
   mLayout.lockLineCheck = new QCheckBox( text, page );
   gbox->addMultiCellWidget( mLayout.lockLineCheck, 4, 4, 0, 1, AlignLeft );
+  connect( mLayout.lockLineCheck, SIGNAL(toggled(bool)),
+    SLOT(slotChanged()) );
 
   text = i18n("Loc&k column at end of line (when column size>1)");
   mLayout.lockColumnCheck = new QCheckBox( text, page );
   gbox->addMultiCellWidget( mLayout.lockColumnCheck, 5, 5, 0, 1 );
+  connect( mLayout.lockColumnCheck, SIGNAL(toggled(bool)),
+    SLOT(slotChanged()) );
 
   hline = new QFrame( page );
   hline->setFrameStyle( QFrame::Sunken | QFrame::HLine );
@@ -161,6 +178,8 @@ void COptionDialog::setupLayoutPage( voi
 
   mLayout.gridCombo = new QComboBox( false, page );
   mLayout.gridCombo->insertStringList( gridList );
+  connect( mLayout.gridCombo, SIGNAL(activated(int)),
+    SLOT(slotChanged()) );
 
   text = i18n("&Gridlines between text:");
   label = new QLabel( mLayout.gridCombo, text, page );
@@ -171,10 +190,14 @@ void COptionDialog::setupLayoutPage( voi
   mLayout.leftSepWidthSpin = new QSpinBox( page );
   mLayout.leftSepWidthSpin->setRange( 0, 20 );
   gbox->addWidget( mLayout.leftSepWidthSpin, 8, 1 );
+  connect( mLayout.leftSepWidthSpin, SIGNAL(valueChanged(int)),
+    SLOT(slotChanged()) );
 
   mLayout.rightSepWidthSpin = new QSpinBox( page );
   mLayout.rightSepWidthSpin->setRange( 0, 20 );
   gbox->addWidget( mLayout.rightSepWidthSpin, 9, 1 );
+  connect( mLayout.rightSepWidthSpin, SIGNAL(valueChanged(int)),
+    SLOT(slotChanged()) );
 
   text = i18n("&Left separator width [pixels]:");
   mLayout.leftSepLabel = new QLabel( mLayout.leftSepWidthSpin, text, page );
@@ -187,10 +210,14 @@ void COptionDialog::setupLayoutPage( voi
   mLayout.separatorSpin = new QSpinBox( page );
   mLayout.separatorSpin->setRange( 0, 20 );
   gbox->addWidget( mLayout.separatorSpin, 10, 1 );
+  connect( mLayout.separatorSpin, SIGNAL(valueChanged(int)),
+    SLOT(slotChanged()) );
 
   mLayout.edgeSpin = new QSpinBox( page );
   mLayout.edgeSpin->setRange( 0, 20 );
   gbox->addWidget( mLayout.edgeSpin, 11, 1 );
+  connect( mLayout.edgeSpin, SIGNAL(valueChanged(int)),
+    SLOT(slotChanged()) );
 
   text = i18n("&Separator margin width [pixels]:");
   label = new QLabel( mLayout.separatorSpin, text, page );
@@ -205,9 +232,13 @@ void COptionDialog::setupLayoutPage( voi
   gbox->addMultiCellWidget( mLayout.columnCheck, 12, 12, 0, 1, AlignLeft );
   connect( mLayout.columnCheck, SIGNAL(toggled(bool)),
 	   SLOT( slotColumnSepCheck(bool)));
+  connect( mLayout.columnCheck, SIGNAL(toggled(bool)),
+    SLOT( slotChanged()));
 
   mLayout.columnSepSpin = new QSpinBox( page );
   mLayout.columnSepSpin->setRange( 1, 100 );
+  connect( mLayout.columnSepSpin, SIGNAL(valueChanged(int)),
+    SLOT(slotChanged()) );
 
   text = i18n("Column separa&tion [pixels]:");
   mLayout.columnSepLabel = new QLabel( mLayout.columnSepSpin, text, page );
@@ -235,6 +266,8 @@ void COptionDialog::setupCursorPage( voi
   mCursor.blinkCheck = new QCheckBox( i18n("Do not b&link"), group );
   connect( mCursor.blinkCheck, SIGNAL(toggled(bool)),
 	   SLOT( slotBlinkIntervalCheck(bool)));
+  connect( mCursor.blinkCheck, SIGNAL(toggled(bool)),
+    SLOT( slotChanged()));
 
   QHBox *hbox = new QHBox( group );
   mCursor.blinkLabel = new QLabel( i18n("&Blink interval [ms]:" ), hbox );
@@ -244,6 +277,8 @@ void COptionDialog::setupCursorPage( voi
   mCursor.blinkSpin->setSteps( 100, 100 );
   mCursor.blinkSpin->setValue( 500 );
   mCursor.blinkLabel->setBuddy(mCursor.blinkSpin);
+  connect( mCursor.blinkSpin, SIGNAL(valueChanged(int)),
+    SLOT( slotChanged()));
 
   group = new QVButtonGroup( i18n("Shape"), page );
   group->layout()->setMargin( spacingHint() );
@@ -253,8 +288,12 @@ void COptionDialog::setupCursorPage( voi
   mCursor.blockCheck = new QCheckBox( text, group );
   connect( mCursor.blockCheck, SIGNAL(toggled(bool)),
 	   SLOT( slotBlockCursorCheck(bool)));
+  connect( mCursor.blockCheck, SIGNAL(toggled(bool)),
+    SLOT( slotChanged()));
   text = i18n("Use &thick cursor in insert mode");
   mCursor.thickCheck = new QCheckBox( text, group );
+  connect( mCursor.thickCheck, SIGNAL(toggled(bool)),
+    SLOT( slotChanged()));
 
   text = i18n("Cursor Behavior When Editor Loses Focus");
   group = new QVButtonGroup( text, page );
@@ -266,6 +305,12 @@ void COptionDialog::setupCursorPage( voi
   mCursor.hideRadio = new QRadioButton( i18n("H&ide"), group, "radio2" );
   text = i18n("Do &nothing");
   mCursor.nothingRadio = new QRadioButton( text, group, "radio3" );
+  connect( mCursor.stopRadio, SIGNAL(toggled(bool)),
+    SLOT( slotChanged()));
+  connect( mCursor.hideRadio, SIGNAL(toggled(bool)),
+    SLOT( slotChanged()));
+  connect( mCursor.nothingRadio, SIGNAL(toggled(bool)),
+    SLOT( slotChanged()));
 
   topLayout->addStretch(10);
 }
@@ -284,6 +329,8 @@ void COptionDialog::setupColorPage( void
   mColor.checkSystem = new QCheckBox( text, page );
   connect( mColor.checkSystem, SIGNAL(toggled(bool)),
 	   SLOT( slotColorSystem(bool)));
+  connect( mColor.checkSystem, SIGNAL(toggled(bool)),
+    SLOT( slotChanged()));
   topLayout->addWidget( mColor.checkSystem );
 
   QFrame *hline = new QFrame( page );
@@ -317,6 +364,7 @@ void COptionDialog::setupColorPage( void
     mColor.colorList->insertItem( listItem );
   }
   mColor.colorList->setCurrentItem(0);
+  connect( mColor.colorList, SIGNAL( dataChanged() ), this, SLOT( slotChanged() ) );
 }
 
 
@@ -333,6 +381,8 @@ void COptionDialog::setupFontPage( void 
   mFont.checkSystem = new QCheckBox( text, page );
   connect( mFont.checkSystem, SIGNAL(toggled(bool)),
 	   this, SLOT( slotFontSystem(bool)));
+  connect( mFont.checkSystem, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
   topLayout->addWidget( mFont.checkSystem );
 
   QFrame *hline = new QFrame( page );
@@ -343,6 +393,8 @@ void COptionDialog::setupFontPage( void 
   topLayout->addWidget( mFont.chooser );
   mFont.chooser->setFont( QFont( "courier", 12, QFont::Bold, FALSE ), true );
   mFont.chooser->setSampleText( i18n("KHexEdit editor font") );
+  connect( mFont.chooser, SIGNAL(fontSelected(const QFont &)),
+    this, SLOT( slotChanged()));
 
   hline = new QFrame( page );
   hline->setFrameStyle( QFrame::Sunken | QFrame::HLine );
@@ -353,6 +405,8 @@ void COptionDialog::setupFontPage( void 
 
   mFont.nonPrintInput = new QLineEdit( page );
   mFont.nonPrintInput->setMaxLength( 1 );
+  connect( mFont.nonPrintInput, SIGNAL(textChanged(const QString &)),
+    this, SLOT( slotChanged()));
 
   text = i18n("&Map non printable characters to:");
   QLabel *nonPrintLabel = new QLabel( mFont.nonPrintInput, text, page );
@@ -383,6 +437,8 @@ void COptionDialog::setupFilePage( void 
   modeList.append( i18n("All Recent Documents") );
   mFile.openCombo->insertStringList( modeList );
   mFile.openCombo->setMinimumWidth( mFile.openCombo->sizeHint().width() );
+  connect( mFile.openCombo, SIGNAL(activated(int)),
+    this, SLOT( slotChanged()));
 
   text = i18n("Open doc&uments on startup:");
   QLabel *label = new QLabel( mFile.openCombo, text, page );
@@ -393,6 +449,8 @@ void COptionDialog::setupFilePage( void 
   text = i18n("&Jump to previous cursor position on startup");
   mFile.gotoOffsetCheck = new QCheckBox( text, page );
   topLayout->addWidget( mFile.gotoOffsetCheck, 0, AlignLeft );
+  connect( mFile.gotoOffsetCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
 
   QFrame *hline = new QFrame( page );
   hline->setFrameStyle( QFrame::Sunken | QFrame::HLine );
@@ -401,14 +459,20 @@ void COptionDialog::setupFilePage( void 
   text = i18n("Open document with &write proctection enabled");
   mFile.writeProtectCheck = new QCheckBox( text, page );
   topLayout->addWidget( mFile.writeProtectCheck, 0, AlignLeft );
+  connect( mFile.writeProtectCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
 
   text = i18n("&Keep cursor position after reloading document");
   mFile.reloadOffsetCheck = new QCheckBox( text, page );
   topLayout->addWidget( mFile.reloadOffsetCheck, 0, AlignLeft );
+  connect( mFile.reloadOffsetCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
 
   text = i18n("&Make a backup when saving document");
   mFile.backupCheck = new QCheckBox( text, page );
   topLayout->addWidget( mFile.backupCheck, 0, AlignLeft );
+  connect( mFile.backupCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
 
   hline = new QFrame( page );
   hline->setFrameStyle( QFrame::Sunken | QFrame::HLine );
@@ -417,6 +481,8 @@ void COptionDialog::setupFilePage( void 
   text = i18n("Don't &save \"Recent\" document list on exit");
   mFile.discardRecentCheck = new QCheckBox( text, page );
   topLayout->addWidget( mFile.discardRecentCheck, 0, AlignLeft );
+  connect( mFile.discardRecentCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
 
   text = i18n("Cl&ear \"Recent\" Document List");
   QPushButton *discardRecentButton = new QPushButton( page );
@@ -444,39 +510,57 @@ void COptionDialog::setupMiscPage( void 
   text = i18n("Auto&matic copy to clipboard when selection is ready");
   mMisc.autoCheck = new QCheckBox( text, page );
   topLayout->addWidget( mMisc.autoCheck, 0, AlignLeft );
+  connect( mMisc.autoCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
 
   text = i18n("&Editor starts in \"insert\" mode" );
   mMisc.insertCheck = new QCheckBox( text, page );
   topLayout->addWidget( mMisc.insertCheck, 0, AlignLeft );
+  connect( mMisc.insertCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
 
   text = i18n("Confirm &wrapping (to beginning or end) during search");
   mMisc.confirmWrapCheck = new QCheckBox( text, page );
   topLayout->addWidget( mMisc.confirmWrapCheck, 0, AlignLeft );
+  connect( mMisc.confirmWrapCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
 
   text = i18n("Cursor jumps to &nearest byte when moved");
   mMisc.cursorJumpCheck = new QCheckBox( text, page );
   topLayout->addWidget( mMisc.cursorJumpCheck, 0, AlignLeft );
+  connect( mMisc.cursorJumpCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
 
   QVButtonGroup *group = new QVButtonGroup( i18n("Sounds"), page );
   group->layout()->setMargin( spacingHint() );
   topLayout->addWidget( group );
   text = i18n("Make sound on data &input (eg. typing) failure");
   mMisc.inputCheck = new QCheckBox( text, group );
+  connect( mMisc.inputCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
   text = i18n("Make sound on &fatal failure");
   mMisc.fatalCheck = new QCheckBox( text, group );
+  connect( mMisc.fatalCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
 
   group = new QVButtonGroup( i18n("Bookmark Visibility"), page );
   group->layout()->setMargin( spacingHint() );
   topLayout->addWidget( group );
   text = i18n("Use visible bookmarks in the offset column");
   mMisc.bookmarkColumnCheck = new QCheckBox( text, group );
+  connect( mMisc.bookmarkColumnCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
   text = i18n("Use visible bookmarks in the editor fields");
   mMisc.bookmarkEditorCheck = new QCheckBox( text, group );
+  connect( mMisc.bookmarkEditorCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
 
   text = i18n("Confirm when number of printed pages will e&xceed limit");
   mMisc.thresholdCheck = new QCheckBox( text, page );
   connect( mMisc.thresholdCheck, SIGNAL(clicked()),
 	   SLOT( slotThresholdConfirm()));
+  connect( mMisc.thresholdCheck, SIGNAL(toggled(bool)),
+    this, SLOT( slotChanged()));
   topLayout->addWidget( mMisc.thresholdCheck, 0, AlignLeft );
 
   QGridLayout *glay = new QGridLayout( 3, 3 );
@@ -488,6 +572,8 @@ void COptionDialog::setupMiscPage( void 
   mMisc.thresholdSpin->setRange( 5, INT_MAX );
   mMisc.thresholdSpin->setSteps( 5, 5 );
   mMisc.thresholdSpin->setValue( 5 );
+  connect( mMisc.thresholdSpin, SIGNAL(valueChanged(int)),
+    this, SLOT( slotChanged()));
 
   text = i18n("&Threshold [pages]:" );
   mMisc.thresholdLabel = new QLabel( mMisc.thresholdSpin, text, page );
@@ -503,6 +589,8 @@ void COptionDialog::setupMiscPage( void 
   mMisc.undoSpin->setRange( 10, 10000 );
   mMisc.undoSpin->setSteps( 5, 5 );
   mMisc.undoSpin->setValue( 50 );
+  connect( mMisc.undoSpin, SIGNAL(valueChanged(int)),
+    this, SLOT( slotChanged()));
 
   label = new QLabel( mMisc.undoSpin, i18n("&Undo limit:"), page );
   glay->addWidget( label, 2, 0 );
@@ -638,7 +726,8 @@ void COptionDialog::slotDefault( void )
 
 void COptionDialog::slotOk( void )
 {
-  slotApply();
+  if( configChanged )
+    slotApply();
   accept();
 }
 
@@ -774,6 +863,8 @@ void COptionDialog::slotApply( void )
     }
     break;
   }
+  enableButton( Apply, false );
+  configChanged = false;
 }
 
 void COptionDialog::setLayout( SDisplayLayout &layout, SDisplayLine &line )
@@ -920,6 +1011,8 @@ void COptionDialog::setState( SDisplaySt
   setFont( state.font );
   setFile( state.misc );
   setMisc( state.misc );
+  enableButton( Apply, false );
+  configChanged = false;
 }
 
 
@@ -1002,6 +1095,7 @@ void CColorListBox::newColor( int index 
     if( KColorDialog::getColor( c, this ) != QDialog::Rejected )
     {
       setColor( index, c );
+      emit dataChanged();
     }
   }
 }
Index: optiondialog.h
===================================================================
RCS file: /home/kde/kdeutils/khexedit/optiondialog.h,v
retrieving revision 1.11
diff -u -p -r1.11 optiondialog.h
--- optiondialog.h	7 Mar 2003 22:06:49 -0000	1.11
+++ optiondialog.h	1 Apr 2003 16:30:49 -0000
@@ -64,6 +64,8 @@ class CColorListBox : public KListBox
   private:
     int mCurrentOnDragEnter;
 
+  signals:
+    void dataChanged();
 };
 
 
@@ -131,7 +133,7 @@ class COptionDialog : public KDialogBase
     virtual void slotDefault( void );
     virtual void slotOk( void );
     virtual void slotApply( void );
-
+    void slotChanged();
 
   private:
     struct SLayoutWidgets
@@ -249,7 +251,7 @@ class COptionDialog : public KDialogBase
     SFontWidgets   mFont;
     SFileWidgets   mFile;
     SMiscWidgets   mMisc;
-
+    bool configChanged;
 
 };
 

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic