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

List:       kde-core-devel
Subject:    'Follow the leader' dialogs
From:       Zack Rusin <zack () kde ! org>
Date:       2002-08-03 23:45:24
[Download RAW message or body]

Nope, I couldn't come up with a worse subject (believe me I tried). 
Yesterday I talked a little bit on irc with Martijn about Mac OS X gui. 
He said that they have this very cool feature where all dialogs of a 
window fallow the parent once the parent is moved. Well, I don't have 
access to Mac OSX and wanted to check this feature out so I of course 
implemented it just to see how it feels and I must say I like it. For 
now I put it in the KDialogBase, I'm attaching a patch for those of you 
who also don't have access to Mac OS X, the code is trivial. The 
question is - do we want this? Do we want our dialogs to follow the 
parent?

Zack

-- 
Stress is when you wake up screaming and you realize you haven't
fallen asleep yet. 

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

? semantic.cache
Index: kdialogbase.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kdialogbase.cpp,v
retrieving revision 1.71
diff -u -3 -p -r1.71 kdialogbase.cpp
--- kdialogbase.cpp	2002/03/18 22:38:58	1.71
+++ kdialogbase.cpp	2002/08/03 23:37:27
@@ -101,6 +101,8 @@ KDialogBase::KDialogBase( QWidget *paren
    mIsActivated(false), mShowTile(false), mMessageBoxMode(false),
    mButtonOrientation(Horizontal)
 {
+  if ( parent )
+    parent->installEventFilter( this );
   d = new KDialogBasePrivate;
   setCaption( caption );
 
@@ -124,6 +126,8 @@ KDialogBase::KDialogBase( int dialogFace
    mIsActivated(false), mShowTile(false), mMessageBoxMode(false),
    mButtonOrientation(Horizontal)
 {
+  if ( parent )
+    parent->installEventFilter( this );
   d = new KDialogBasePrivate;
   setCaption( caption );
 
@@ -153,6 +157,8 @@ KDialogBase::KDialogBase( const QString 
    mIsActivated(false), mShowTile(false), mMessageBoxMode(true),
    mButtonOrientation(Horizontal),mEscapeButton(escapeButton)
 {
+  if ( parent )
+    parent->installEventFilter( this );
   d = new KDialogBasePrivate;
 
   setCaption( caption );
@@ -164,11 +170,11 @@ KDialogBase::KDialogBase( const QString 
 
   buttonMask &= Details|Yes|No|Cancel;
 
-  makeButtonBox( buttonMask, defaultButton, 
+  makeButtonBox( buttonMask, defaultButton,
                  no.text().isEmpty()  ? KStdGuiItem::no()  : no,
                  yes.text().isEmpty() ? KStdGuiItem::yes() : yes );
 
-  setButtonCancelText( cancel.text().isEmpty() ? 
+  setButtonCancelText( cancel.text().isEmpty() ?
                        KStdGuiItem::cancel().text() : cancel.text() );
 
   mIsActivated = true;
@@ -1518,7 +1524,23 @@ void KDialogBase::closeEvent( QCloseEven
     }
 }
 
+bool KDialogBase::eventFilter( QObject *o, QEvent *e )
+{
+    if ( e->type() == QEvent::Move ) {
+        QMoveEvent *m = static_cast<QMoveEvent*>(e);
+        QPoint diff = m->pos() - m->oldPos();
+        QPoint npos = QWidget::pos();
+        /*kdDebug()<<"#### Event filer pos.x = "
+                 << QWidget::pos().x() << ", pos.y = "<<QWidget::pos().y()
+                 <<" npos.x = "<<npos.x()<<", npos.y() = "<<npos.y()
+                 <<" diff.x = "<<diff.x()<<", diff.y = "<<diff.y()
+                 <<endl;*/
+        move( npos + diff );
+    }
+    return QWidget::eventFilter( o, e );
+}
 
+
 bool KDialogBase::haveBackgroundTile()
 {
   return( mTile == 0 || mTile->get() == 0 ? false : true );
@@ -1623,12 +1645,12 @@ void KDialogBase::saveDialogSize( const 
    int scnum = QApplication::desktop()->screenNumber(parentWidget());
    QRect desk = QApplication::desktop()->screenGeometry(scnum);
    KConfig *kc = KGlobal::config();
-   
+
    if( kc )
    {
       KConfigGroupSaver cs(kc, groupName);
       QSize sizeToSave = size();
-      
+
       kc->writeEntry( QString::fromLatin1("Width %1").arg( desk.width()),
 		      QString::number( sizeToSave.width()), true, global);
       kc->writeEntry( QString::fromLatin1("Height %1").arg( desk.height()),
Index: kdialogbase.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kdialogbase.h,v
retrieving revision 1.72
diff -u -3 -p -r1.72 kdialogbase.h
--- kdialogbase.h	2002/08/01 14:19:52	1.72
+++ kdialogbase.h	2002/08/03 23:37:27
@@ -1283,6 +1283,7 @@ class KDialogBase : public KDialog
      * will take place.
      */
     virtual void closeEvent( QCloseEvent *e );
+    bool eventFilter( QObject *, QEvent * );
 
   protected slots:
     /**


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

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