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

List:       kde-release-team
Subject:    Backporting to 4.1.80
From:       Rafael =?utf-8?q?Fern=C3=A1ndez_L=C3=B3pez?= <ereslibre () kde ! org>
Date:       2008-12-02 1:08:20
Message-ID: 200812020208.23816.ereslibre () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi there,

I have tried to backport some patches that were going to be useful while I 
found out that I had no karma to commit on tags.

I am placing patches here, with the explanation:

backport.diff:

This patch corresponds to revisions 891277, 891278, 891359 and 891377 in 
trunk.

The aiming of this is to behave more perfectly by don't accepting the 
open/save dialog when you are going to save. Instead you click one time, and 
you can still modify the filename to add for instance a "_2" and then accept 
the dialog.

It also fixes other internal problems for stability shake.

backport2.diff:

This was already backported, but made KMail do some strangenesses on its 
previous version. I believe all problems are fixed now, and I couldn't find any 
regressions. For this reason I would like to see this patch readded.

Basically, it allows users that have the need of special characters being able 
to write them when the autocompletion box is shown.

This means that I, as a spanish user can't write "música" when writing "m", 
because the autocompletion was popped up and when writing it would look like 
"m'usica".

This is a problem regarding event sending. With the tooltip approach this is 
treated as a different thing, since it is not a toplevel window (as Popup was).

backport3.diff:

As discussed on usability mailing lists, it is very probably that the 
open/save dialog looks amazingly cluttered. This removes two actions from the 
main toolbar (icon and detail view switching), since this is not going to be 
_that_ used very probably.


Comments ?


Regards,
Rafael Fernández López.

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

diff --git a/kfile/kfilewidget.cpp b/kfile/kfilewidget.cpp
index 8c19783..2d57b6b 100644
--- a/kfile/kfilewidget.cpp
+++ b/kfile/kfilewidget.cpp
@@ -185,6 +185,7 @@ public:
     void _k_zoomOutIconsSize();
     void _k_zoomInIconsSize();
     void _k_slotIconSizeSliderMoved(int);
+    void _k_slotViewDoubleClicked(const QModelIndex&);
 
     void addToRecentDocuments();
 
@@ -721,6 +722,7 @@ void KFileWidget::slotOk()
 
     const KFileItemList items = d->ops->selectedItems();
     const QString locationEditCurrentText(KShell::tildeExpand(d->locationEditCurrentText()));
 +
     KUrl::List locationEditCurrentTextList(d->tokenize(locationEditCurrentText));
     KFile::Modes mode = d->ops->mode();
 
@@ -829,7 +831,8 @@ void KFileWidget::slotOk()
     } else if (locationEditCurrentTextList.count()) {
         // if we are on file or files mode, and we have an absolute url written by
         // the user, convert it to relative
-        if (!(mode & KFile::Directory) && \
QDir::isAbsolutePath(locationEditCurrentText)) { +        if \
(!locationEditCurrentText.isEmpty() && !(mode & KFile::Directory) && +            \
QDir::isAbsolutePath(locationEditCurrentText)) {  KUrl _url(locationEditCurrentText);
             KUrl url(_url.path(KUrl::RemoveTrailingSlash));
             url.setFileName(QString());
@@ -1024,7 +1027,11 @@ void KFileWidgetPrivate::_k_fileSelected(const KFileItem &i)
         emit q->selectionChanged();
     }
 
-    q->slotOk();
+    // if we are saving, let another chance to the user before accepting the dialog \
(or trying to +    // accept). This way the user can choose a file and add a "_2" for \
instance to the filename +    if (operationMode != KFileWidget::Saving) {
+        q->slotOk();
+    }
 }
 
 
@@ -1540,9 +1547,13 @@ KUrl::List KFileWidgetPrivate::tokenize( const QString& line ) \
const  
     const int count = line.count( QLatin1Char( '"' ) );
     if ( count == 0 ) { // no " " -> assume one single file
-        u.setFileName( line );
-        if ( u.isValid() )
-            urls.append( u );
+        if (!QDir::isAbsolutePath(line)) {
+            u.setFileName( line );
+            if ( u.isValid() )
+                urls.append( u );
+        } else {
+            urls << KUrl(line);
+        }
 
         return urls;
     }
@@ -1563,7 +1574,7 @@ KUrl::List KFileWidgetPrivate::tokenize( const QString& line ) \
const  KUrl _u( u );
         KUrl currUrl( name );
 
-        if ( currUrl.isRelative() ) {
+        if ( !QDir::isAbsolutePath(currUrl.url()) ) {
             _u.setFileName( name );
         } else {
             // we allow to insert various absolute paths like:
@@ -1653,6 +1664,8 @@ void KFileWidget::showEvent(QShowEvent* event)
         d->ops->setView( KFile::Default );
         d->ops->view()->setSizePolicy( QSizePolicy( QSizePolicy::Maximum, \
QSizePolicy::Maximum ) );  d->hasView = true;
+
+        connect(d->ops->view(), SIGNAL(doubleClicked(QModelIndex)), this, \
SLOT(_k_slotViewDoubleClicked(QModelIndex)));  }
     d->ops->clearHistory();
 
@@ -1724,6 +1737,13 @@ void KFileWidgetPrivate::readConfig(KConfigGroup &configGroup)
     if ( cm != KGlobalSettings::completionMode() )
         locationEdit->setCompletionMode( cm );
 
+    // since we delayed this moment, initialize the directory of the completion \
object to +    // our current directory (that was very probably set on the \
constructor) +    KUrlCompletion *completion = \
dynamic_cast<KUrlCompletion*>(locationEdit->completionObject()); +    if (completion) \
{ +        completion->setDir(ops->url().url());
+    }
+
     // show or don't show the speedbar
     _k_toggleSpeedbar( configGroup.readEntry( ShowSpeedbar, true ) );
 
@@ -1930,6 +1950,14 @@ void KFileWidgetPrivate::_k_slotIconSizeSliderMoved(int \
_value)  QApplication::sendEvent(iconSizeSlider, &toolTipEvent);
 }
 
+void KFileWidgetPrivate::_k_slotViewDoubleClicked(const QModelIndex &index)
+{
+    if (!index.isValid()) {
+        return;
+    }
+    q->slotOk();
+}
+
 static QString getExtensionFromPatternList(const QStringList &patternList)
 {
 //     kDebug(kfile_area);
diff --git a/kfile/kfilewidget.h b/kfile/kfilewidget.h
index 2e9d3e6..2341ac8 100644
--- a/kfile/kfilewidget.h
+++ b/kfile/kfilewidget.h
@@ -466,6 +466,7 @@ private:
     Q_PRIVATE_SLOT(d, void _k_zoomOutIconsSize())
     Q_PRIVATE_SLOT(d, void _k_zoomInIconsSize())
     Q_PRIVATE_SLOT(d, void _k_slotIconSizeSliderMoved(int))
+    Q_PRIVATE_SLOT(d, void _k_slotViewDoubleClicked(const QModelIndex&))
 };
 
 #endif /* KABSTRACTFILEWIDGET_H */


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

diff --git a/kdeui/widgets/kcompletionbox.cpp b/kdeui/widgets/kcompletionbox.cpp
index 5477e5d..7e32f13 100644
--- a/kdeui/widgets/kcompletionbox.cpp
+++ b/kdeui/widgets/kcompletionbox.cpp
@@ -54,16 +54,11 @@ KCompletionBox::KCompletionBox( QWidget *parent )
     d->upwardBox       = false;
     d->emitSelected    = true;
 
-    setWindowFlags( Qt::Popup ); // calls setVisible, so must be done after \
initializations +    setWindowFlags( Qt::ToolTip ); // calls setVisible, so must be \
done after initializations  
     setLineWidth( 1 );
     setFrameStyle( QFrame::Box | QFrame::Plain );
 
-    if ( parent ) {
-        setFocusProxy( parent );
-    } else
-        setFocusPolicy( Qt::NoFocus );
-
     setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
@@ -113,14 +108,29 @@ void KCompletionBox::slotActivated( QListWidgetItem *item )
 bool KCompletionBox::eventFilter( QObject *o, QEvent *e )
 {
     int type = e->type();
+    QWidget *wid = qobject_cast<QWidget*>(o);
+
+    if (o == this) {
+        return false;
+    }
+
+    if (wid && (wid == d->m_parent || wid->windowFlags() & Qt::Window) && 
+               (type == QEvent::Move || type == QEvent::Resize)) {
+        hide();
+        return false;
+    }
 
-    if ((o==this) && (type==QEvent::KeyPress)) {
-	//not sure if this is a work around for a Qt bug or a fix for changed qt behaviour, \
                at least it makes the kcombobox work again for me
-	QApplication::sendEvent(d->m_parent,e);
-	return true;
+    if (type == QEvent::MouseButtonPress && (wid && !isAncestorOf(wid))) {
+        if (!d->emitSelected && currentItem() && !qobject_cast<QScrollBar*>(o)) {
+          Q_ASSERT(currentItem());
+          emit currentTextChanged(currentItem()->text() );
+        }
+        hide();
+        e->accept();
+        return true;
     }
 
-    if ( o == d->m_parent ) {
+    if (wid && wid->isAncestorOf(d->m_parent)) {
         if ( isVisible() ) {
             if ( type == QEvent::KeyPress ) {
                 QKeyEvent *ev = static_cast<QKeyEvent *>( e );
@@ -193,8 +203,7 @@ bool KCompletionBox::eventFilter( QObject *o, QEvent *e )
                     default:
                         break;
                 }
-            }
-            else if ( type == QEvent::ShortcutOverride ) {
+            } else if ( type == QEvent::ShortcutOverride ) {
                 // Override any accelerators that match
                 // the key sequences we use here...
                 QKeyEvent *ev = static_cast<QKeyEvent *>( e );
@@ -229,44 +238,17 @@ bool KCompletionBox::eventFilter( QObject *o, QEvent *e )
                     default:
                         break;
                 }
-            }
-
-            // parent gets a click -> we hide
-            else if ( type == QEvent::Resize ||
-                      type == QEvent::Close || type == QEvent::Hide ) {
-                hide();
-            }
-            
-            else if ( type == QEvent::FocusOut ) {
+            } else if ( type == QEvent::FocusOut ) {
                   QFocusEvent* event = static_cast<QFocusEvent*>( e );
                   if (event->reason() != Qt::PopupFocusReason)
                     hide();
             }
-            
-        }
-    }
-
-    // any mouse-click on something else than "this" makes us hide
-    else if ( type == QEvent::MouseButtonPress ) {
-        QMouseEvent *ev = static_cast<QMouseEvent *>( e );
-        if ( !rect().contains( ev->pos() )) // this widget
-            hide();
-
-        if ( !d->emitSelected && currentItem() && !qobject_cast<QScrollBar*>(o) )
-        {
-          Q_ASSERT( currentItem() );
-
-          emit currentTextChanged( currentItem()->text() );
-          hide();
-          ev->accept();  // Consume the mouse click event...
-          return true;
         }
     }
 
     return KListWidget::eventFilter( o, e );
 }
 
-
 void KCompletionBox::popup()
 {
     if ( count() == 0 )
@@ -283,12 +265,6 @@ void KCompletionBox::popup()
         else if ( size().height() != sizeHint().height() )
             sizeAndPosition();
     }
-
-    // Make sure we give the focus back to the parent widget (ereslibre)
-    if ( parentWidget() ) {
-        QFocusEvent focusEvent( QEvent::FocusIn );
-        QApplication::sendEvent( parentWidget(), &focusEvent );
-    }
 }
 
 void KCompletionBox::sizeAndPosition()
@@ -363,14 +339,12 @@ void KCompletionBox::setVisible( bool visible )
 
 QRect KCompletionBox::calculateGeometry() const
 {
-    if (count() == 0)
+    QRect visualRect;
+    if (count() == 0 || !(visualRect = visualItemRect(item(0))).isValid())
         return QRect();
 
     int x = 0, y = 0;
-
-    Q_ASSERT( visualItemRect(item(0)).isValid() );
-
-    int ih = visualItemRect(item(0)).height();
+    int ih = visualRect.height();
     int h = qMin( 15 * ih, (int) count() * ih ) + 2*frameWidth();
 
     int w = (d->m_parent) ? d->m_parent->width() : \
KListWidget::minimumSizeHint().width();


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

diff --git a/kfile/kfilewidget.cpp b/kfile/kfilewidget.cpp
index fdad083..205ec8c 100644
--- a/kfile/kfilewidget.cpp
+++ b/kfile/kfilewidget.cpp
@@ -477,17 +477,23 @@ KFileWidget::KFileWidget( const KUrl& _startDir, QWidget *parent )
     QAction *separator2 = new QAction(this);
     separator2->setSeparator(true);
 
+    QAction *separator3 = new QAction(this);
+    separator3->setSeparator(true);
+
     d->toolbar->addAction(coll->action("back" ));
     d->toolbar->addAction(coll->action("forward"));
     d->toolbar->addAction(coll->action("up"));
     d->toolbar->addAction(coll->action("reload"));
     d->toolbar->addAction(separator);
+    d->toolbar->addAction(coll->action("short view"));
+    d->toolbar->addAction(coll->action("detailed view"));
+    d->toolbar->addAction(separator2);
     d->toolbar->addAction(coll->action("inline preview"));
     d->toolbar->addWidget(midSpacer);
     d->toolbar->addAction(furtherAction);
     d->toolbar->addWidget(d->iconSizeSlider);
     d->toolbar->addAction(closerAction);
-    d->toolbar->addAction(separator2);
+    d->toolbar->addAction(separator3);
     d->toolbar->addAction(coll->action("mkdir"));
     d->toolbar->addAction(menu);
 

["signature.asc" (application/pgp-signature)]

_______________________________________________
release-team mailing list
release-team@kde.org
https://mail.kde.org/mailman/listinfo/release-team


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

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