Add maximize=1/0 parameter to gui native viewer defs for opening maximized window on Windows

This commit is contained in:
Jean-Francois Dockes 2016-12-05 12:17:56 +01:00
parent 33e09df833
commit 80e356ffb2
4 changed files with 25 additions and 9 deletions

View File

@ -157,7 +157,10 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
{
string apptag;
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
LOGDEB("RclMain::startNativeViewer: mtype [" << (doc.mimetype) << "] apptag [" << (apptag) << "] page " << (pagenum) << " term [" << ((const char *)(term.toUtf8())) << "] url [" << (doc.url) << "] ipath [" << (doc.ipath) << "]\n" );
LOGDEB("RclMain::startNativeViewer: mtype [" << doc.mimetype <<
"] apptag [" << apptag << "] page " << pagenum << " term [" <<
qs2utf8s(term) << "] url [" << doc.url << "] ipath [" <<
doc.ipath << "]\n");
// Look for appropriate viewer
string cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag,
@ -174,9 +177,15 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
string cmd;
theconfig->valueSplitAttributes(cmdplusattr, cmd, viewerattrs);
bool ignoreipath = false;
int execwflags = 0;
if (viewerattrs.get("ignoreipath", cmdplusattr))
ignoreipath = stringToBool(cmdplusattr);
if (viewerattrs.get("maximize", cmdplusattr)) {
if (stringToBool(cmdplusattr)) {
execwflags |= ExecCmd::EXF_MAXIMIZED;
}
}
// Split the command line
vector<string> lcmd;
if (!stringToStrings(cmd, lcmd)) {
@ -389,13 +398,13 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
it != doc.meta.end(); it++) {
subs[it->first] = it->second;
}
execViewer(subs, enterHistory, execpath, lcmd, cmd, doc);
execViewer(subs, enterHistory, execpath, lcmd, cmd, doc, execwflags);
}
void RclMain::execViewer(const map<string, string>& subs, bool enterHistory,
const string& execpath,
const vector<string>& _lcmd, const string& cmd,
Rcl::Doc doc)
Rcl::Doc doc, int flags)
{
string ncmd;
vector<string> lcmd;
@ -429,7 +438,7 @@ void RclMain::execViewer(const map<string, string>& subs, bool enterHistory,
zg_send_event(ZGSEND_OPEN, doc);
// We keep pushing back and never deleting. This can't be good...
ExecCmd *ecmd = new ExecCmd(ExecCmd::EXF_SHOWWINDOW);
ExecCmd *ecmd = new ExecCmd(ExecCmd::EXF_SHOWWINDOW | flags);
m_viewers.push_back(ecmd);
ecmd->startExec(execpath, lcmd, false, false);
}

View File

@ -252,9 +252,10 @@ private:
virtual void setupResTB(bool combo);
virtual void previewPrevOrNextInTab(Preview *, int sid, int docnum,
bool next);
// flags may contain ExecCmd::EXF_xx values
virtual void execViewer(const map<string, string>& subs, bool enterHistory,
const string& execpath, const vector<string>& lcmd,
const string& cmd, Rcl::Doc doc);
const string& cmd, Rcl::Doc doc, int flags=0);
virtual void setStemLang(const QString& lang);
virtual void onSortCtlChanged();
virtual void showIndexConfig(bool modal);

View File

@ -199,6 +199,8 @@ public:
// because it avoids windows appearing and
// disappearing when executing stuff for previewing
EXF_SHOWWINDOW = 1,
// Windows only: show maximized
EXF_MAXIMIZED = 2,
};
ExecCmd(int flags = 0);
~ExecCmd();

View File

@ -764,15 +764,19 @@ int ExecCmd::startExec(const string &cmd, const vector<string>& args,
siStartInfo.cb = sizeof(STARTUPINFO);
if (m->m_flags & EXF_SHOWWINDOW) {
siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
if (m->m_flags & EXF_MAXIMIZED) {
siStartInfo.dwFlags |= STARTF_USESHOWWINDOW;
siStartInfo.wShowWindow = SW_SHOWMAXIMIZED;
}
} else {
siStartInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
// This is to hide the console when starting a cmd line command from
// the GUI. Also note STARTF_USESHOWWINDOW above
siStartInfo.wShowWindow = SW_HIDE;
}
siStartInfo.hStdOutput = hOutputWrite;
siStartInfo.hStdInput = hInputRead;
siStartInfo.hStdError = hErrorWrite;
// This is to hide the console when starting a cmd line command from
// the GUI. Also note STARTF_USESHOWWINDOW above
siStartInfo.wShowWindow = SW_HIDE;
char *envir = mergeEnvironment(m->m_env);