summaryrefslogtreecommitdiffstats
path: root/kio/kfile
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2018-04-30 17:00:31 +0900
committerSlávek Banko <slavek.banko@axis.cz>2018-04-30 11:57:39 +0200
commit9660b501112de866241eca33f1bfe07d3aeaac52 (patch)
treea6e80b661d05996362b44bbe49379a1b9454694a /kio/kfile
parent9c636b46cb281e3aa8678f011ede6722021cab04 (diff)
downloadtdelibs-9660b501112de866241eca33f1bfe07d3aeaac52.tar.gz
tdelibs-9660b501112de866241eca33f1bfe07d3aeaac52.zip
Fixed service lookup in KOpenWithDlg. Default is now to lookup by
desktop path and not by name, to avoid returning the wrong service when two or more .desktop files where using the same "Name" field. This resolves bug 2734 (together with the changes made in applications/kcmautostart) Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit bcdfbb95e94db26bf984443ce583d919a330058c)
Diffstat (limited to 'kio/kfile')
-rw-r--r--kio/kfile/kopenwith.cpp55
-rw-r--r--kio/kfile/kopenwith.h4
-rw-r--r--kio/kfile/kopenwith_p.h12
3 files changed, 41 insertions, 30 deletions
diff --git a/kio/kfile/kopenwith.cpp b/kio/kfile/kopenwith.cpp
index 2a3e7e690..54d157f98 100644
--- a/kio/kfile/kopenwith.cpp
+++ b/kio/kfile/kopenwith.cpp
@@ -70,32 +70,36 @@
// ----------------------------------------------------------------------
KAppTreeListItem::KAppTreeListItem( KListView* parent, const TQString & name,
- const TQPixmap& pixmap, bool parse, bool dir, const TQString &p, const TQString &c )
+ const TQPixmap& pixmap, bool parse, bool dir,
+ const TQString &p, const TQString &c, const TQString &dp )
: TQListViewItem( parent, name )
{
- init(pixmap, parse, dir, p, c);
+ init(pixmap, parse, dir, p, c, dp);
}
// ----------------------------------------------------------------------
KAppTreeListItem::KAppTreeListItem( TQListViewItem* parent, const TQString & name,
- const TQPixmap& pixmap, bool parse, bool dir, const TQString &p, const TQString &c )
+ const TQPixmap& pixmap, bool parse, bool dir,
+ const TQString &p, const TQString &c, const TQString &dp )
: TQListViewItem( parent, name )
{
- init(pixmap, parse, dir, p, c);
+ init(pixmap, parse, dir, p, c, dp);
}
// ----------------------------------------------------------------------
-void KAppTreeListItem::init(const TQPixmap& pixmap, bool parse, bool dir, const TQString &_path, const TQString &_exec)
+void KAppTreeListItem::init(const TQPixmap& pixmap, bool parse, bool dir,
+ const TQString &_path, const TQString &_exec, const TQString &_desktopPath)
{
setPixmap(0, pixmap);
parsed = parse;
directory = dir;
path = _path; // relative path
- exec = _exec;
+ exec = _exec; // executable command
+ desktopPath = _desktopPath; // .desktop file path
}
@@ -193,10 +197,7 @@ void KApplicationTree::addDesktopGroup( const TQString &relPath, KAppTreeListIte
for( KServiceGroup::List::ConstIterator it = list.begin();
it != list.end(); it++)
{
- TQString icon;
- TQString text;
- TQString relPath;
- TQString exec;
+ TQString icon, text, relPath, exec, desktopPath;
bool isDir = false;
KSycocaEntry *p = (*it);
if (p->isType(KST_KService))
@@ -209,6 +210,7 @@ void KApplicationTree::addDesktopGroup( const TQString &relPath, KAppTreeListIte
icon = service->icon();
text = service->name();
exec = service->exec();
+ desktopPath = service->desktopEntryPath();
}
else if (p->isType(KST_KServiceGroup))
{
@@ -229,13 +231,13 @@ void KApplicationTree::addDesktopGroup( const TQString &relPath, KAppTreeListIte
}
TQPixmap pixmap = appIcon( icon );
-
+
if (item)
newItem = new KAppTreeListItem( item, text, pixmap, false, isDir,
- relPath, exec );
+ relPath, exec, desktopPath );
else
newItem = new KAppTreeListItem( this, text, pixmap, false, isDir,
- relPath, exec );
+ relPath, exec, desktopPath );
if (isDir)
newItem->setExpandable( true );
}
@@ -255,7 +257,7 @@ void KApplicationTree::slotItemHighlighted(TQListViewItem* i)
currentitem = item;
if( (!item->directory ) && (!item->exec.isEmpty()) )
- emit highlighted( item->text(0), item->exec );
+ emit highlighted( item->text(0), item->exec, item->desktopPath );
}
@@ -272,7 +274,7 @@ void KApplicationTree::slotSelectionChanged(TQListViewItem* i)
currentitem = item;
if( ( !item->directory ) && (!item->exec.isEmpty() ) )
- emit selected( item->text(0), item->exec );
+ emit selected( item->text(0), item->exec, item->desktopPath );
}
// ----------------------------------------------------------------------
@@ -350,7 +352,7 @@ KOpenWithDlg::KOpenWithDlg( const TQString &serviceType, const TQString& value,
TQWidget *parent)
:TQDialog( parent, "openwith", true )
{
- setCaption(i18n("Choose Application for %1").arg(serviceType));
+ setCaption(i18n("Choose Application for %1").arg(serviceType));
TQString text = i18n("<qt>Select the program for the file type: <b>%1</b>. "
"If the program is not listed, enter the name or click "
"the browse button.</qt>").arg(serviceType);
@@ -459,10 +461,10 @@ void KOpenWithDlg::init( const TQString& _text, const TQString& _value )
m_pTree = new KApplicationTree( this );
topLayout->addWidget(m_pTree);
- connect( m_pTree, TQT_SIGNAL( selected( const TQString&, const TQString& ) ),
- TQT_SLOT( slotSelected( const TQString&, const TQString& ) ) );
- connect( m_pTree, TQT_SIGNAL( highlighted( const TQString&, const TQString& ) ),
- TQT_SLOT( slotHighlighted( const TQString&, const TQString& ) ) );
+ connect( m_pTree, TQT_SIGNAL( selected( const TQString&, const TQString&, const TQString& ) ),
+ TQT_SLOT( slotSelected( const TQString&, const TQString&, const TQString& ) ) );
+ connect( m_pTree, TQT_SIGNAL( highlighted( const TQString&, const TQString&, const TQString& ) ),
+ TQT_SLOT( slotHighlighted( const TQString&, const TQString&, const TQString& ) ) );
connect( m_pTree, TQT_SIGNAL( doubleClicked(TQListViewItem*) ),
TQT_SLOT( slotDbClick() ) );
@@ -543,7 +545,7 @@ void KOpenWithDlg::slotClear()
// ----------------------------------------------------------------------
-void KOpenWithDlg::slotSelected( const TQString& /*_name*/, const TQString& _exec )
+void KOpenWithDlg::slotSelected( const TQString& /*_name*/, const TQString& _exec, const TQString& /*_desktopPath*/ )
{
kdDebug(250)<<"KOpenWithDlg::slotSelected"<<endl;
KService::Ptr pService = d->curService;
@@ -554,11 +556,18 @@ void KOpenWithDlg::slotSelected( const TQString& /*_name*/, const TQString& _exe
// ----------------------------------------------------------------------
-void KOpenWithDlg::slotHighlighted( const TQString& _name, const TQString& )
+void KOpenWithDlg::slotHighlighted( const TQString& _name, const TQString& _exec, const TQString& _desktopPath )
{
kdDebug(250)<<"KOpenWithDlg::slotHighlighted"<<endl;
qName = _name;
- d->curService = KService::serviceByName( qName );
+ // Look up by desktop path first, to avoid returning wrong results in case multiple .desktop files
+ // contain the same name for different services (such as Konsole)
+ // Try by name only if first search fails (this should never happen normally)
+ d->curService = KService::serviceByDesktopPath( _desktopPath )
+ if (!d->curService)
+ {
+ d->curService = KService::serviceByName( qName );
+ }
if (!m_terminaldirty)
{
// ### indicate that default value was restored
diff --git a/kio/kfile/kopenwith.h b/kio/kfile/kopenwith.h
index 3dceb10bc..0a2096b59 100644
--- a/kio/kfile/kopenwith.h
+++ b/kio/kfile/kopenwith.h
@@ -129,8 +129,8 @@ public slots:
* The slot for clearing the edit widget
*/
void slotClear();
- void slotSelected( const TQString&_name, const TQString& _exec );
- void slotHighlighted( const TQString& _name, const TQString& _exec );
+ void slotSelected( const TQString&_name, const TQString& _exec, const TQString& _desktopPath );
+ void slotHighlighted( const TQString& _name, const TQString& _exec, const TQString& _desktopPath );
void slotTextChanged();
void slotTerminalToggled(bool);
void slotDbClick();
diff --git a/kio/kfile/kopenwith_p.h b/kio/kfile/kopenwith_p.h
index f395d94bd..60645b41f 100644
--- a/kio/kfile/kopenwith_p.h
+++ b/kio/kfile/kopenwith_p.h
@@ -43,18 +43,20 @@ class KAppTreeListItem : public TQListViewItem
bool directory;
TQString path;
TQString exec;
+ TQString desktopPath;
protected:
int compare(TQListViewItem *i, int col, bool ascending ) const;
TQString key(int column, bool ascending) const;
- void init(const TQPixmap& pixmap, bool parse, bool dir, const TQString &_path, const TQString &exec);
+ void init(const TQPixmap& pixmap, bool parse, bool dir,
+ const TQString &_path, const TQString &exec, const TQString &_desktopPath);
public:
KAppTreeListItem( KListView* parent, const TQString & name, const TQPixmap& pixmap,
- bool parse, bool dir, const TQString &p, const TQString &c );
+ bool parse, bool dir, const TQString &p, const TQString &c, const TQString &dp );
KAppTreeListItem( TQListViewItem* parent, const TQString & name, const TQPixmap& pixmap,
- bool parse, bool dir, const TQString &p, const TQString &c );
+ bool parse, bool dir, const TQString &p, const TQString &c, const TQString &dp );
bool isDirectory();
protected:
@@ -92,8 +94,8 @@ public slots:
void slotSelectionChanged(TQListViewItem* i);
signals:
- void selected( const TQString& _name, const TQString& _exec );
- void highlighted( const TQString& _name, const TQString& _exec );
+ void selected( const TQString& _name, const TQString& _exec, const TQString& _desktopPath );
+ void highlighted( const TQString& _name, const TQString& _exec, const TQString& _desktopPath );
};
/* ------------------------------------------------------------------------- */