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("Select the program for the file type: %1. " "If the program is not listed, enter the name or click " "the browse button.").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"<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"<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 ); }; /* ------------------------------------------------------------------------- */