summaryrefslogtreecommitdiffstats
path: root/tdeio/tdefile
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2018-04-30 17:00:31 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2018-04-30 17:00:31 +0900
commitbcdfbb95e94db26bf984443ce583d919a330058c (patch)
treeffdb824e6ba90ba7537bff7d2345614284bf7b4a /tdeio/tdefile
parent8d36253e9dff75025d43d1e98938d308444a0344 (diff)
downloadtdelibs-bcdfbb95e94db26bf984443ce583d919a330058c.tar.gz
tdelibs-bcdfbb95e94db26bf984443ce583d919a330058c.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>
Diffstat (limited to 'tdeio/tdefile')
-rw-r--r--tdeio/tdefile/kopenwith.cpp55
-rw-r--r--tdeio/tdefile/kopenwith.h4
-rw-r--r--tdeio/tdefile/kopenwith_p.h12
3 files changed, 41 insertions, 30 deletions
diff --git a/tdeio/tdefile/kopenwith.cpp b/tdeio/tdefile/kopenwith.cpp
index 6688fc387..0633b7f07 100644
--- a/tdeio/tdefile/kopenwith.cpp
+++ b/tdeio/tdefile/kopenwith.cpp
@@ -70,32 +70,36 @@
// ----------------------------------------------------------------------
KAppTreeListItem::KAppTreeListItem( TDEListView* 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 TDEApplicationTree::addDesktopGroup( const TQString &relPath, KAppTreeListI
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 TDEApplicationTree::addDesktopGroup( const TQString &relPath, KAppTreeListI
icon = service->icon();
text = service->name();
exec = service->exec();
+ desktopPath = service->desktopEntryPath();
}
else if (p->isType(KST_KServiceGroup))
{
@@ -229,13 +231,13 @@ void TDEApplicationTree::addDesktopGroup( const TQString &relPath, KAppTreeListI
}
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 TDEApplicationTree::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 TDEApplicationTree::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 TDEApplicationTree( 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/tdeio/tdefile/kopenwith.h b/tdeio/tdefile/kopenwith.h
index 90c43ceb1..e0482b87a 100644
--- a/tdeio/tdefile/kopenwith.h
+++ b/tdeio/tdefile/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/tdeio/tdefile/kopenwith_p.h b/tdeio/tdefile/kopenwith_p.h
index a0f7eb77c..4f6d53107 100644
--- a/tdeio/tdefile/kopenwith_p.h
+++ b/tdeio/tdefile/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( TDEListView* 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 );
};
/* ------------------------------------------------------------------------- */