Cherry-picking upstream version 0.9.0+20151014.
This commit is contained in:
parent
67fad63273
commit
5816ab7af9
@ -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<const CustomCommandItem *>(item);
|
||||
if (nullptr != cust_i)
|
||||
{
|
||||
for (int i = mSourceModel->rowCount(sourceParent); 0 <= i; --i)
|
||||
{
|
||||
const AppLinkItem * app_i = qobject_cast<const AppLinkItem *>(mSourceModel->command(i));
|
||||
if (nullptr != app_i && cust_i->exec() == app_i->exec() && app_i->compare(re))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return accept;
|
||||
}
|
||||
|
||||
|
||||
|
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,3 +1,9 @@
|
||||
lxqt-runner (0.9.0+20151014-1) experimental; urgency=medium
|
||||
|
||||
* Cherry-picked upstream version 0.9.0+20151014.
|
||||
|
||||
-- Alf Gaida <agaida@siduction.org> Sun, 25 Oct 2015 01:36:42 +0200
|
||||
|
||||
lxqt-runner (0.9.0+20150831-1) experimental; urgency=medium
|
||||
|
||||
[ Alf Gaida ]
|
||||
|
@ -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 = "";
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user