diff --git a/src/filewidgets/kfilewidget.h b/src/filewidgets/kfilewidget.h --- a/src/filewidgets/kfilewidget.h +++ b/src/filewidgets/kfilewidget.h @@ -612,6 +612,7 @@ Q_PRIVATE_SLOT(d, void _k_zoomInIconsSize()) Q_PRIVATE_SLOT(d, void _k_slotIconSizeSliderMoved(int)) Q_PRIVATE_SLOT(d, void _k_slotIconSizeChanged(int)) + Q_PRIVATE_SLOT(d, void _k_slotViewDoubleClicked(const QModelIndex&)) }; #endif diff --git a/src/filewidgets/kfilewidget.cpp b/src/filewidgets/kfilewidget.cpp --- a/src/filewidgets/kfilewidget.cpp +++ b/src/filewidgets/kfilewidget.cpp @@ -197,6 +197,7 @@ void _k_zoomInIconsSize(); void _k_slotIconSizeSliderMoved(int); void _k_slotIconSizeChanged(int); + void _k_slotViewDoubleClicked(const QModelIndex&); void addToRecentDocuments(); @@ -1176,8 +1177,10 @@ emit q->selectionChanged(); } - // 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 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. + // Double clicking however will override this, regardless of single/double click mouse setting, + // see: _k_slotViewDoubleClicked if (operationMode == KFileWidget::Saving) { locationEdit->setFocus(); } else { @@ -1858,6 +1861,8 @@ 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(); @@ -2171,6 +2176,14 @@ QApplication::sendEvent(iconSizeSlider, &toolTipEvent); } +void KFileWidgetPrivate::_k_slotViewDoubleClicked(const QModelIndex &index) +{ + // double clicking to save should only work on files + if (operationMode == KFileWidget::Saving && index.isValid() && ops->selectedItems().first().isFile()) { + q->slotOk(); + } +} + static QString getExtensionFromPatternList(const QStringList &patternList) { // qDebug();