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

View File

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

View File

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

View File

@ -764,15 +764,19 @@ int ExecCmd::startExec(const string &cmd, const vector<string>& args,
siStartInfo.cb = sizeof(STARTUPINFO); siStartInfo.cb = sizeof(STARTUPINFO);
if (m->m_flags & EXF_SHOWWINDOW) { if (m->m_flags & EXF_SHOWWINDOW) {
siStartInfo.dwFlags |= STARTF_USESTDHANDLES; siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
if (m->m_flags & EXF_MAXIMIZED) {
siStartInfo.dwFlags |= STARTF_USESHOWWINDOW;
siStartInfo.wShowWindow = SW_SHOWMAXIMIZED;
}
} else { } else {
siStartInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; 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.hStdOutput = hOutputWrite;
siStartInfo.hStdInput = hInputRead; siStartInfo.hStdInput = hInputRead;
siStartInfo.hStdError = hErrorWrite; 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); char *envir = mergeEnvironment(m->m_env);