GUI: add possibility to call script from link in result paragraph html
This commit is contained in:
parent
43e0f4eab4
commit
26c7e1c690
@ -58,6 +58,7 @@
|
|||||||
#ifdef RCL_USE_ASPELL
|
#ifdef RCL_USE_ASPELL
|
||||||
#include "rclaspell.h"
|
#include "rclaspell.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "appformime.h"
|
||||||
#include "respopup.h"
|
#include "respopup.h"
|
||||||
|
|
||||||
static const QKeySequence quitKeySeq("Ctrl+q");
|
static const QKeySequence quitKeySeq("Ctrl+q");
|
||||||
@ -927,6 +928,27 @@ void ResList::linkWasClicked(const QUrl &url)
|
|||||||
resultPageBack();
|
resultPageBack();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Run script. Link format Rnn|Script Name
|
||||||
|
case 'R':
|
||||||
|
{
|
||||||
|
int i = atoi(ascurl.c_str() + 1) - 1;
|
||||||
|
QString s = url.toString();
|
||||||
|
int bar = s.indexOf("|");
|
||||||
|
if (bar == -1 || bar >= s.size()-1)
|
||||||
|
break;
|
||||||
|
string cmdname = qs2utf8s(s.right(s.size() - (bar + 1)));
|
||||||
|
DesktopDb ddb(path_cat(theconfig->getConfDir(), "scripts"));
|
||||||
|
DesktopDb::AppDef app;
|
||||||
|
if (ddb.appByName(cmdname, app)) {
|
||||||
|
QAction act(QString::fromUtf8(app.name.c_str()), this);
|
||||||
|
QVariant v(QString::fromUtf8(app.command.c_str()));
|
||||||
|
act.setData(v);
|
||||||
|
m_popDoc = i;
|
||||||
|
menuOpenWith(&act);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
// Spelling: replacement suggestion clicked
|
// Spelling: replacement suggestion clicked
|
||||||
case 'S':
|
case 'S':
|
||||||
{
|
{
|
||||||
|
|||||||
@ -48,6 +48,7 @@
|
|||||||
#include "respopup.h"
|
#include "respopup.h"
|
||||||
#include "rclmain_w.h"
|
#include "rclmain_w.h"
|
||||||
#include "multisave.h"
|
#include "multisave.h"
|
||||||
|
#include "appformime.h"
|
||||||
|
|
||||||
static const QKeySequence quitKeySeq("Ctrl+q");
|
static const QKeySequence quitKeySeq("Ctrl+q");
|
||||||
static const QKeySequence closeKeySeq("Ctrl+w");
|
static const QKeySequence closeKeySeq("Ctrl+w");
|
||||||
@ -781,6 +782,25 @@ void ResTable::linkWasClicked(const QUrl &url)
|
|||||||
emit editRequested(m_detaildoc);
|
emit editRequested(m_detaildoc);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Run script. Link format Rnn|Script Name
|
||||||
|
case 'R':
|
||||||
|
{
|
||||||
|
int bar = s.indexOf("|");
|
||||||
|
if (bar == -1 || bar >= s.size()-1)
|
||||||
|
break;
|
||||||
|
string cmdname = qs2utf8s(s.right(s.size() - (bar + 1)));
|
||||||
|
DesktopDb ddb(path_cat(theconfig->getConfDir(), "scripts"));
|
||||||
|
DesktopDb::AppDef app;
|
||||||
|
if (ddb.appByName(cmdname, app)) {
|
||||||
|
QAction act(QString::fromUtf8(app.name.c_str()), this);
|
||||||
|
QVariant v(QString::fromUtf8(app.command.c_str()));
|
||||||
|
act.setData(v);
|
||||||
|
menuOpenWith(&act);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOGERR(("ResTable::linkWasClicked: bad link [%s]\n", ascurl));
|
LOGERR(("ResTable::linkWasClicked: bad link [%s]\n", ascurl));
|
||||||
break;// ??
|
break;// ??
|
||||||
|
|||||||
@ -151,6 +151,22 @@ bool DesktopDb::allApps(vector<AppDef> *apps)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DesktopDb::appByName(const string& nm, AppDef& app)
|
||||||
|
{
|
||||||
|
for (AppMap::const_iterator it = m_appMap.begin();
|
||||||
|
it != m_appMap.end(); it++) {
|
||||||
|
for (vector<AppDef>::const_iterator it1 = it->second.begin();
|
||||||
|
it1 != it->second.end(); it1++) {
|
||||||
|
if (!nm.compare(it1->name)) {
|
||||||
|
app.name = it1->name;
|
||||||
|
app.command = it1->command;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const string& DesktopDb::getReason()
|
const string& DesktopDb::getReason()
|
||||||
{
|
{
|
||||||
return m_reason;
|
return m_reason;
|
||||||
|
|||||||
@ -33,6 +33,8 @@ public:
|
|||||||
AppDef(const std::string& nm, const std::string& cmd)
|
AppDef(const std::string& nm, const std::string& cmd)
|
||||||
: name(nm), command(cmd)
|
: name(nm), command(cmd)
|
||||||
{}
|
{}
|
||||||
|
AppDef() {}
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string command;
|
std::string command;
|
||||||
};
|
};
|
||||||
@ -64,6 +66,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool allApps(vector<AppDef> *apps);
|
bool allApps(vector<AppDef> *apps);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get app with given name
|
||||||
|
*/
|
||||||
|
bool appByName(const string& nm, AppDef& app);
|
||||||
|
|
||||||
typedef map<string, vector<DesktopDb::AppDef> > AppMap;
|
typedef map<string, vector<DesktopDb::AppDef> > AppMap;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user