┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmmanuel Pescosta <[email protected]>2012-12-13 22:54:09 +0100
committerEmmanuel Pescosta <[email protected]>2012-12-13 22:54:09 +0100
commit3535a20207245cf8b1325ada9007469d0d1c3ec7 (patch)
tree1a59a4703377877584b283c7f5c3f506f3cf7737 /src
parente348bc58267b3dc06f2fc044f9e5ce5a5dfcd087 (diff)
Fix Bug 304299 - Dolphin launches multiple instances of a program when multiple files are selected
BUG: 304299 REVIEW: 107305
Diffstat (limited to 'src')
-rw-r--r--src/dolphinpart.cpp9
-rw-r--r--src/dolphinpart.h4
-rw-r--r--src/dolphinviewcontainer.cpp10
-rw-r--r--src/dolphinviewcontainer.h6
-rw-r--r--src/views/dolphinview.cpp31
-rw-r--r--src/views/dolphinview.h6
6 files changed, 53 insertions, 13 deletions
diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp
index ccc91fd7d..627ba79c5 100644
--- a/src/dolphinpart.cpp
+++ b/src/dolphinpart.cpp
@@ -90,6 +90,8 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
this, SLOT(slotErrorMessage(QString)));
connect(m_view, SIGNAL(itemActivated(KFileItem)),
this, SLOT(slotItemActivated(KFileItem)));
+ connect(m_view, SIGNAL(itemsActivated(KFileItemList)),
+ this, SLOT(slotItemsActivated(KFileItemList)));
connect(m_view, SIGNAL(tabRequested(KUrl)),
this, SLOT(createNewWindow(KUrl)));
connect(m_view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
@@ -367,6 +369,13 @@ void DolphinPart::slotItemActivated(const KFileItem& item)
emit m_extension->openUrlRequest(item.targetUrl(), args, browserArgs);
}
+void DolphinPart::slotItemsActivated(const KFileItemList& items)
+{
+ foreach (const KFileItem& item, items) {
+ slotItemActivated(item);
+ }
+}
+
void DolphinPart::createNewWindow(const KUrl& url)
{
// TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
diff --git a/src/dolphinpart.h b/src/dolphinpart.h
index e5693b363..7881ded43 100644
--- a/src/dolphinpart.h
+++ b/src/dolphinpart.h
@@ -129,6 +129,10 @@ private Q_SLOTS:
*/
void slotItemActivated(const KFileItem& item);
/**
+ * Handles activation of multiple items
+ */
+ void slotItemsActivated(const KFileItemList& items);
+ /**
* Creates a new window showing the content of \a url.
*/
void createNewWindow(const KUrl& url);
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp
index 6e99437d9..c27550ae1 100644
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -29,6 +29,7 @@
#include <KDesktopFile>
#include <KFileItemDelegate>
+#include <KFileItemActions>
#include <KFilePlacesModel>
#include <KLocale>
#include <KIconEffect>
@@ -108,6 +109,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool)));
connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem)));
connect(m_view, SIGNAL(itemActivated(KFileItem)), this, SLOT(slotItemActivated(KFileItem)));
+ connect(m_view, SIGNAL(itemsActivated(KFileItemList)), this, SLOT(slotItemsActivated(KFileItemList)));
connect(m_view, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(redirect(KUrl,KUrl)));
connect(m_view, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
connect(m_view, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
@@ -509,6 +511,14 @@ void DolphinViewContainer::slotItemActivated(const KFileItem& item)
item.run();
}
+void DolphinViewContainer::slotItemsActivated(const KFileItemList& items)
+{
+ Q_ASSERT(items.count() >= 2);
+
+ KFileItemActions fileItemActions(this);
+ fileItemActions.runPreferredApplications(items, QString());
+}
+
void DolphinViewContainer::showItemInfo(const KFileItem& item)
{
if (item.isNull()) {
diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h
index 0300273c1..e2d1b1875 100644
--- a/src/dolphinviewcontainer.h
+++ b/src/dolphinviewcontainer.h
@@ -215,6 +215,12 @@ private slots:
void slotItemActivated(const KFileItem& item);
/**
+ * Handles activation of multiple files. The files get started by
+ * the corresponding applications.
+ */
+ void slotItemsActivated(const KFileItemList& items);
+
+ /**
* Shows the information for the item \a item inside the statusbar. If the
* item is null, the default statusbar information is shown.
*/
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 57c94a33b..941083fde 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -792,29 +792,34 @@ void DolphinView::slotItemsActivated(const QSet<int>& indexes)
{
Q_ASSERT(indexes.count() >= 2);
- KFileItemList items;
-
- QSetIterator<int> it(indexes);
- while (it.hasNext()) {
- const int index = it.next();
- items.append(m_model->fileItem(index));
- }
-
- if (items.count() > 5) {
- QString question = i18np("Are you sure you want to open 1 item?", "Are you sure you want to open %1 items?", items.count());
+ if (indexes.count() > 5) {
+ QString question = i18np("Are you sure you want to open 1 item?", "Are you sure you want to open %1 items?", indexes.count());
const int answer = KMessageBox::warningYesNo(this, question);
if (answer != KMessageBox::Yes) {
return;
}
}
- foreach (const KFileItem& item, items) {
- if (item.isDir()) {
+ KFileItemList items;
+ items.reserve(indexes.count());
+
+ QSetIterator<int> it(indexes);
+ while (it.hasNext()) {
+ const int index = it.next();
+ KFileItem item = m_model->fileItem(index);
+
+ if (item.isDir()) { // Open folders in new tabs
emit tabRequested(item.url());
} else {
- emit itemActivated(item);
+ items.append(item);
}
}
+
+ if (items.count() == 1) {
+ emit itemActivated(items.first());
+ } else if (items.count() > 1) {
+ emit itemsActivated(items);
+ }
}
void DolphinView::slotItemMiddleClicked(int index)
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index 6d15ebf32..a2fe9f62a 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -386,6 +386,12 @@ signals:
void itemActivated(const KFileItem& item);
/**
+ * Is emitted when multiple items have been activated by e. g.
+ * context menu open with.
+ */
+ void itemsActivated(const KFileItemList& items);
+
+ /**
* Is emitted if items have been added or deleted.
*/
void itemCountChanged();