Browse Source

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>
pull/1/head
Michele Calgaro 1 year ago
parent
commit
bcdfbb95e9
3 changed files with 41 additions and 30 deletions
  1. +32
    -23
      tdeio/tdefile/kopenwith.cpp
  2. +2
    -2
      tdeio/tdefile/kopenwith.h
  3. +7
    -5
      tdeio/tdefile/kopenwith_p.h

+ 32
- 23
tdeio/tdefile/kopenwith.cpp View File

@@ -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

+ 2
- 2
tdeio/tdefile/kopenwith.h View File

@@ -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();

+ 7
- 5
tdeio/tdefile/kopenwith_p.h View File

@@ -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 );
};

/* ------------------------------------------------------------------------- */

Loading…
Cancel
Save