Commit 91d81eef authored by Urs Fleisch's avatar Urs Fleisch
Browse files

QML: Format %{qmlpath}, start command processor commands with '@'.

parent 6db462e0
......@@ -30,6 +30,8 @@
#include <QDir>
#include <QCoreApplication>
#include "networkconfig.h"
#include "config.h"
#include "loadtranslation.h"
/**
* Constructor.
......@@ -56,6 +58,7 @@ CommandFormatReplacer::~CommandFormatReplacer() {}
* %f %{file} filename
* %d %{directory} directory name
* %b %{browser} the web browser set in the configuration
* %q %{qmlpath} base directory for QML files
*
* @param code format code
*
......@@ -75,7 +78,8 @@ QString CommandFormatReplacer::getReplacement(const QString& code) const
} shortToLong[] = {
{ "file", 'f' },
{ "directory", 'd' },
{ "browser", 'b' }
{ "browser", 'b' },
{ "qmlpath", 'q' }
};
const char c = code[0].toLatin1();
for (unsigned i = 0; i < sizeof(shortToLong) / sizeof(shortToLong[0]); ++i) {
......@@ -108,6 +112,11 @@ QString CommandFormatReplacer::getReplacement(const QString& code) const
}
} else if (name == QLatin1String("browser")) {
result = NetworkConfig::instance().browser();
#ifdef CFG_QMLDIR
} else if (name == QLatin1String("qmlpath")) {
result = QLatin1String(CFG_QMLDIR);
Utils::prependApplicationDirPathIfRelative(result);
#endif
} else if (name == QLatin1String("url")) {
if (!m_files.empty()) {
QUrl url;
......@@ -160,6 +169,12 @@ QString CommandFormatReplacer::getToolTip(bool onlyRows)
str += QCoreApplication::translate("@default", "Browser");
str += QLatin1String("</td></tr>\n");
#ifdef CFG_QMLDIR
str += QLatin1String("<tr><td>%q</td><td>%{qmlpath}</td><td>");
str += QCoreApplication::translate("@default", "QML base directory");
str += QLatin1String("</td></tr>\n");
#endif
str += QLatin1String("<tr><td>%ua...</td><td>%u{artist}...</td><td>");
str += QCoreApplication::translate("@default", QT_TRANSLATE_NOOP("@default", "Encode as URL"));
str += QLatin1String("</td></tr>\n");
......
......@@ -69,6 +69,7 @@ protected:
* %f %{file} filename
* %d %{directory} directory name
* %b %{browser} the web browser set in the configuration
* %q %{qmlpath} base directory for QML files
*
* @param code format code
*
......
......@@ -201,11 +201,14 @@ void ExternalProcess::launchCommand(const QString& name, const QStringList& args
QStringList arguments = args;
QString program = arguments.takeFirst();
foreach (IUserCommandProcessor* userCommandProcessor,
m_app->getUserCommandProcessors()) {
if (userCommandProcessor->userCommandKeys().contains(program) &&
userCommandProcessor->startUserCommand(program, arguments, showOutput))
return;
if (program.startsWith(QLatin1Char('@'))) {
program = program.mid(1);
foreach (IUserCommandProcessor* userCommandProcessor,
m_app->getUserCommandProcessors()) {
if (userCommandProcessor->userCommandKeys().contains(program) &&
userCommandProcessor->startUserCommand(program, arguments, showOutput))
return;
}
}
m_process->start(program, arguments);
if (!m_process->waitForStarted(10000)) {
......
......@@ -133,6 +133,7 @@ void FileList::contextMenu(const QModelIndex& index, const QPoint& pos)
* %uF list of URLs
* %d directory name
* %b the web browser set in the configuration
* %q the base directory for QML files
*
* @todo %f and %F are full paths, which is inconsistent with the
* export format strings but compatible with .desktop files.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment