diff --git a/commanditemmodel.cpp b/commanditemmodel.cpp index ebde856..b439aa3 100644 --- a/commanditemmodel.cpp +++ b/commanditemmodel.cpp @@ -97,7 +97,7 @@ void CommandItemModel::clearHistory() /************************************************ ************************************************/ -bool CommandItemModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourceParent*/) const +bool CommandItemModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QRegExp re(filterRegExp()); @@ -109,7 +109,23 @@ bool CommandItemModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sour if (!item) return false; - return item->compare(re); + bool accept = item->compare(re); + if (accept) + { + //check if CustomCommand can be filtered out (equivalent app link is shown) + const CustomCommandItem * cust_i = qobject_cast(item); + if (nullptr != cust_i) + { + for (int i = mSourceModel->rowCount(sourceParent); 0 <= i; --i) + { + const AppLinkItem * app_i = qobject_cast(mSourceModel->command(i)); + if (nullptr != app_i && cust_i->exec() == app_i->exec() && app_i->compare(re)) + return false; + } + } + } + + return accept; } diff --git a/debian/changelog b/debian/changelog index bd608db..276a22b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +lxqt-runner (0.9.0+20151014-1) experimental; urgency=medium + + * Cherry-picked upstream version 0.9.0+20151014. + + -- Alf Gaida Sun, 25 Oct 2015 01:36:42 +0200 + lxqt-runner (0.9.0+20150831-1) experimental; urgency=medium [ Alf Gaida ] diff --git a/providers.cpp b/providers.cpp index 9556089..4936789 100644 --- a/providers.cpp +++ b/providers.cpp @@ -57,7 +57,7 @@ /************************************************ ************************************************/ -QString expandCommand(const QString &command, QStringList *arguments=0) +static QString expandCommand(const QString &command, QStringList *arguments=0) { QString program; wordexp_t words; @@ -83,7 +83,35 @@ QString expandCommand(const QString &command, QStringList *arguments=0) /************************************************ ************************************************/ -bool startProcess(QString command) +static QString which(const QString &progName) +{ + if (progName.isEmpty()) + return ""; + + if (progName.startsWith(QDir::separator())) + { + QFileInfo fileInfo(progName); + if (fileInfo.isExecutable() && fileInfo.isFile()) + return fileInfo.absoluteFilePath(); + } + + QStringList dirs = QString(getenv("PATH")).split(":"); + + foreach (QString dir, dirs) + { + QFileInfo fileInfo(QDir(dir), progName); + if (fileInfo.isExecutable() && fileInfo.isFile()) + return fileInfo.absoluteFilePath(); + } + + return ""; +} + + +/************************************************ + + ************************************************/ +static bool startProcess(QString command) { QStringList args; QString program = expandCommand(command, &args); @@ -153,6 +181,7 @@ AppLinkItem::AppLinkItem(const QDomElement &element): mCommand = element.attribute("exec"); mProgram = QFileInfo(element.attribute("exec")).baseName().section(" ", 0, 0); mDesktopFile = element.attribute("desktopFile"); + initExec(); QMetaObject::invokeMethod(this, "updateIcon", Qt::QueuedConnection); } @@ -170,6 +199,7 @@ AppLinkItem::AppLinkItem(MenuCacheApp* app): char* path = menu_cache_item_get_file_path(MENU_CACHE_ITEM(app)); mDesktopFile = QString::fromLocal8Bit(path); g_free(path); + initExec(); QMetaObject::invokeMethod(this, "updateIcon", Qt::QueuedConnection); // qDebug() << "FOUND: " << mIconName << ", " << mCommand; } @@ -201,6 +231,7 @@ void AppLinkItem::operator=(const AppLinkItem &other) mCommand = other.mCommand; mProgram = other.mProgram; mDesktopFile = other.mDesktopFile; + mExec = other.mExec; mIconName = other.mIconName; mIcon = other.icon(); @@ -245,6 +276,20 @@ bool AppLinkItem::compare(const QRegExp ®Exp) const } +/************************************************ + + ************************************************/ +void AppLinkItem::initExec() +{ + static const QRegExp split_re{QStringLiteral("\\s")}; + XdgDesktopFile desktop; + if (desktop.load(mDesktopFile)) + { + QStringList cmd = desktop.value(QStringLiteral("Exec")).toString().split(split_re); + if (0 < cmd.size()) + mExec = which(expandCommand(cmd[0])); + } +} /************************************************ @@ -503,34 +548,6 @@ CustomCommandItem::CustomCommandItem(CustomCommandProvider *provider): } -/************************************************ - - ************************************************/ -QString which(const QString &progName) -{ - if (progName.isEmpty()) - return ""; - - if (progName.startsWith(QDir::separator())) - { - QFileInfo fileInfo(progName); - if (fileInfo.isExecutable() && fileInfo.isFile()) - return fileInfo.absoluteFilePath(); - } - - QStringList dirs = QString(getenv("PATH")).split(":"); - - foreach (QString dir, dirs) - { - QFileInfo fileInfo(QDir(dir), progName); - if (fileInfo.isExecutable() && fileInfo.isFile()) - return fileInfo.absoluteFilePath(); - } - - return ""; -} - - /************************************************ ************************************************/ @@ -539,10 +556,10 @@ void CustomCommandItem::setCommand(const QString &command) mCommand = command; mTitle = mCommand; - QString program = which(expandCommand(command)); + mExec = which(expandCommand(command)); - if (!program.isEmpty()) - mComment = QString("%1 %2").arg(program, command.section(' ', 1)); + if (!mExec.isEmpty()) + mComment = QString("%1 %2").arg(mExec, command.section(' ', 1)); else mComment = ""; diff --git a/providers.h b/providers.h index 013497a..8bc6b4d 100644 --- a/providers.h +++ b/providers.h @@ -121,16 +121,20 @@ public: bool run() const; bool compare(const QRegExp ®Exp) const; QString command() const { return mCommand; } + QString exec() const { return mExec; } void operator=(const AppLinkItem &other); virtual unsigned int rank(const QString &pattern) const; private slots: void updateIcon(); +private: + void initExec(); private: QString mDesktopFile; QString mIconName; QString mCommand; + QString mExec; //!< the expanded executable (full path) from desktop file Exec key QString mProgram; }; @@ -201,6 +205,8 @@ class CustomCommandProvider; class CustomCommandItem: public CommandProviderItem { + Q_OBJECT + public: CustomCommandItem(CustomCommandProvider *provider); @@ -209,10 +215,12 @@ public: QString command() const { return mCommand; } void setCommand(const QString &command); + QString exec() const { return mExec; } virtual unsigned int rank(const QString &pattern) const; private: QString mCommand; + QString mExec; //!< the expanded executable (full path) CustomCommandProvider *mProvider; };