Windows: GUI "Open" works
This commit is contained in:
parent
6eb2fd3622
commit
0dea7a849d
10 changed files with 135 additions and 15 deletions
|
@ -399,7 +399,9 @@ void RclMain::execViewer(const map<string, string>& subs, bool istempfile,
|
||||||
// Also substitute inside the unsplitted command line and display
|
// Also substitute inside the unsplitted command line and display
|
||||||
// in status bar
|
// in status bar
|
||||||
pcSubst(cmd, ncmd, subs);
|
pcSubst(cmd, ncmd, subs);
|
||||||
|
#ifndef _WIN32
|
||||||
ncmd += " &";
|
ncmd += " &";
|
||||||
|
#endif
|
||||||
QStatusBar *stb = statusBar();
|
QStatusBar *stb = statusBar();
|
||||||
if (stb) {
|
if (stb) {
|
||||||
string fcharset = theconfig->getDefCharset(true);
|
string fcharset = theconfig->getDefCharset(true);
|
||||||
|
@ -417,7 +419,7 @@ void RclMain::execViewer(const map<string, string>& subs, bool istempfile,
|
||||||
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 *ecmd = new ExecCmd(ExecCmd::EXF_SHOWWINDOW);
|
||||||
m_viewers.push_back(ecmd);
|
m_viewers.push_back(ecmd);
|
||||||
ecmd->startExec(execpath, lcmd, false, false);
|
ecmd->startExec(execpath, lcmd, false, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,11 @@ LANGUAGE = C++
|
||||||
|
|
||||||
QT += webkit
|
QT += webkit
|
||||||
|
|
||||||
# QT += dbus
|
DEFINES += BUILDING_RECOLL
|
||||||
# QMAKE_CXXFLAGS += -DUSE_ZEITGEIST
|
DEFINES -= UNICODE
|
||||||
|
DEFINES -= _UNICODE
|
||||||
|
DEFINES += _MBCS
|
||||||
|
DEFINES += PSAPI_VERSION=1
|
||||||
|
|
||||||
QT += xml
|
QT += xml
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets webkitwidgets printsupport
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets webkitwidgets printsupport
|
||||||
|
@ -106,7 +109,7 @@ windows {
|
||||||
contains(QMAKE_CC, cl){
|
contains(QMAKE_CC, cl){
|
||||||
# Visual Studio
|
# Visual Studio
|
||||||
}
|
}
|
||||||
LIBS += C:/recoll/src/build-librecoll-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/librecoll.dll
|
LIBS += C:/recoll/src/windows/build-librecoll-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/librecoll.dll
|
||||||
}
|
}
|
||||||
|
|
||||||
TRANSLATIONS = \
|
TRANSLATIONS = \
|
||||||
|
|
|
@ -153,7 +153,7 @@ public:
|
||||||
};
|
};
|
||||||
bool ExecCmd::Internal::o_useVfork = false;
|
bool ExecCmd::Internal::o_useVfork = false;
|
||||||
|
|
||||||
ExecCmd::ExecCmd()
|
ExecCmd::ExecCmd(int)
|
||||||
{
|
{
|
||||||
m = new Internal();
|
m = new Internal();
|
||||||
if (m)
|
if (m)
|
||||||
|
|
|
@ -176,7 +176,14 @@ class ExecCmd {
|
||||||
*/
|
*/
|
||||||
bool requestChildExit();
|
bool requestChildExit();
|
||||||
|
|
||||||
ExecCmd();
|
enum ExFlags {EXF_NONE,
|
||||||
|
// Only does anything on windows. Used when starting
|
||||||
|
// a viewer. The default is to hide the window,
|
||||||
|
// because it avoids windows appearing and
|
||||||
|
// disappearing when executing stuff for previewing
|
||||||
|
EXF_SHOWWINDOW = 1,
|
||||||
|
};
|
||||||
|
ExecCmd(int flags = 0);
|
||||||
~ExecCmd();
|
~ExecCmd();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -361,6 +361,10 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top,
|
||||||
case EPERM:
|
case EPERM:
|
||||||
case EACCES:
|
case EACCES:
|
||||||
case ENOENT:
|
case ENOENT:
|
||||||
|
#ifdef _WIN32
|
||||||
|
// We get this quite a lot, don't know why. To be checked.
|
||||||
|
case EINVAL:
|
||||||
|
#endif
|
||||||
goto out;
|
goto out;
|
||||||
default:
|
default:
|
||||||
status = FtwError;
|
status = FtwError;
|
||||||
|
|
|
@ -255,8 +255,9 @@ static int getVMMBytes(HANDLE hProcess)
|
||||||
|
|
||||||
class ExecCmd::Internal {
|
class ExecCmd::Internal {
|
||||||
public:
|
public:
|
||||||
Internal()
|
Internal(int flags)
|
||||||
: m_advise(0), m_provide(0), m_timeoutMs(1000), m_rlimit_as_mbytes(0) {
|
: m_advise(0), m_provide(0), m_timeoutMs(1000), m_rlimit_as_mbytes(0),
|
||||||
|
m_flags(flags) {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,6 +266,7 @@ public:
|
||||||
ExecCmdProvide *m_provide;
|
ExecCmdProvide *m_provide;
|
||||||
int m_timeoutMs;
|
int m_timeoutMs;
|
||||||
int m_rlimit_as_mbytes;
|
int m_rlimit_as_mbytes;
|
||||||
|
int m_flags;
|
||||||
|
|
||||||
// We need buffered I/O for getline. The Unix version uses netcon's
|
// We need buffered I/O for getline. The Unix version uses netcon's
|
||||||
string m_buf; // Buffer. Only used when doing getline()s
|
string m_buf; // Buffer. Only used when doing getline()s
|
||||||
|
@ -360,9 +362,9 @@ private:
|
||||||
bool m_active;
|
bool m_active;
|
||||||
};
|
};
|
||||||
|
|
||||||
ExecCmd::ExecCmd()
|
ExecCmd::ExecCmd(int flags)
|
||||||
{
|
{
|
||||||
m = new Internal();
|
m = new Internal(flags);
|
||||||
if (m) {
|
if (m) {
|
||||||
m->reset();
|
m->reset();
|
||||||
}
|
}
|
||||||
|
@ -703,7 +705,11 @@ int ExecCmd::startExec(const string &cmd, const vector<string>& args,
|
||||||
// This structure specifies the STDIN and STDOUT handles for redirection.
|
// This structure specifies the STDIN and STDOUT handles for redirection.
|
||||||
ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
|
ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
|
||||||
siStartInfo.cb = sizeof(STARTUPINFO);
|
siStartInfo.cb = sizeof(STARTUPINFO);
|
||||||
siStartInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
|
if (m->m_flags & EXF_SHOWWINDOW) {
|
||||||
|
siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
|
||||||
|
} else {
|
||||||
|
siStartInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
|
||||||
|
}
|
||||||
siStartInfo.hStdOutput = hOutputWrite;
|
siStartInfo.hStdOutput = hOutputWrite;
|
||||||
siStartInfo.hStdInput = hInputRead;
|
siStartInfo.hStdInput = hInputRead;
|
||||||
siStartInfo.hStdError = hErrorWrite;
|
siStartInfo.hStdError = hErrorWrite;
|
||||||
|
|
|
@ -22,7 +22,10 @@ xallexcepts = \
|
||||||
|
|
||||||
[view]
|
[view]
|
||||||
# Pseudo entry used if the 'use desktop' preference is set in the GUI
|
# Pseudo entry used if the 'use desktop' preference is set in the GUI
|
||||||
application/x-all = cmd /c start %u
|
# Could not get the cmd-based ones to work (tried quoting "start %u" too)
|
||||||
|
#application/x-all = c:/Windows/System32/cmd /c start %u
|
||||||
|
#application/x-all = cmd /c start %u
|
||||||
|
application/x-all = rclstartw %f
|
||||||
|
|
||||||
####### Special ones
|
####### Special ones
|
||||||
# Open the parent epub document for epub parts instead of opening them as
|
# Open the parent epub document for epub parts instead of opening them as
|
||||||
|
@ -53,7 +56,10 @@ application/x-dvi = evince --page-index=%p --find=%s %f
|
||||||
application/x-lyx = lyx %f
|
application/x-lyx = lyx %f
|
||||||
application/x-scribus = scribus %f
|
application/x-scribus = scribus %f
|
||||||
|
|
||||||
application/msword = libreoffice %f
|
#application/msword = libreoffice %f
|
||||||
|
application/msword = \
|
||||||
|
"C:/Program Files (x86)/LibreOffice 5/program/soffice.exe" %f
|
||||||
|
|
||||||
application/vnd.ms-excel = libreoffice %f
|
application/vnd.ms-excel = libreoffice %f
|
||||||
application/vnd.ms-powerpoint = libreoffice %f
|
application/vnd.ms-powerpoint = libreoffice %f
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ LIBR=C:/recoll/src/windows/build-librecoll-Desktop_Qt_5_5_0_MinGW_32bit-Debug/de
|
||||||
GUIBIN=C:/Users/Bill/recoll/src/build-recoll-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/recoll.exe
|
GUIBIN=C:/Users/Bill/recoll/src/build-recoll-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/recoll.exe
|
||||||
RCLIDX=C:/recoll/src/windows/build-recollindex-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/recollindex.exe
|
RCLIDX=C:/recoll/src/windows/build-recollindex-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/recollindex.exe
|
||||||
RCLQ=C:/recoll/src/windows/build-recollq-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/recollq.exe
|
RCLQ=C:/recoll/src/windows/build-recollq-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/recollq.exe
|
||||||
|
RCLS=C:/recoll/src/windows/build-rclstartw-Desktop_Qt_5_5_0_MinGW_32bit-Debug/debug/rclstartw.exe
|
||||||
################
|
################
|
||||||
# Script:
|
# Script:
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ copyrecoll()
|
||||||
cc $GUIBIN $DESTDIR
|
cc $GUIBIN $DESTDIR
|
||||||
cc $RCLIDX $DESTDIR
|
cc $RCLIDX $DESTDIR
|
||||||
cc $RCLQ $DESTDIR
|
cc $RCLQ $DESTDIR
|
||||||
|
cc $RCLS $DESTDIR
|
||||||
|
|
||||||
cc $RECOLL/sampleconf/fields $DESTDIR/Share/examples
|
cc $RECOLL/sampleconf/fields $DESTDIR/Share/examples
|
||||||
cc $RECOLL/sampleconf/fragbuts.xml $DESTDIR/Share/examples
|
cc $RECOLL/sampleconf/fragbuts.xml $DESTDIR/Share/examples
|
||||||
|
|
33
src/windows/qmkrecoll/rclstartw.pro
Normal file
33
src/windows/qmkrecoll/rclstartw.pro
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
QT -= core gui
|
||||||
|
|
||||||
|
TARGET = rclstartw
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
DEFINES += BUILDING_RECOLL
|
||||||
|
DEFINES -= UNICODE
|
||||||
|
DEFINES -= _UNICODE
|
||||||
|
DEFINES += _MBCS
|
||||||
|
DEFINES += PSAPI_VERSION=1
|
||||||
|
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
../rclstartw.cpp
|
||||||
|
|
||||||
|
INCLUDEPATH += ../../common ../../index ../../internfile ../../query \
|
||||||
|
../../unac ../../utils ../../aspell ../../rcldb ../../qtgui \
|
||||||
|
../../xaposix ../../confgui ../../bincimapmime
|
||||||
|
|
||||||
|
windows {
|
||||||
|
contains(QMAKE_CC, gcc){
|
||||||
|
# MingW
|
||||||
|
QMAKE_CXXFLAGS += -std=c++11 -Wno-unused-parameter
|
||||||
|
}
|
||||||
|
contains(QMAKE_CC, cl){
|
||||||
|
# Visual Studio
|
||||||
|
}
|
||||||
|
LIBS += \
|
||||||
|
-liconv -lshlwapi -lpsapi -lkernel32
|
||||||
|
|
||||||
|
INCLUDEPATH += ../../windows
|
||||||
|
}
|
58
src/windows/rclstartw.cpp
Normal file
58
src/windows/rclstartw.cpp
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/* Copyright (C) 2015 J.F.Dockes
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the
|
||||||
|
* Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
#include "autoconfig.h"
|
||||||
|
|
||||||
|
#include <shellapi.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
// This exists only because I could not find any way to get "cmd /c
|
||||||
|
// start fn" to work when executed from the recoll GUI. Otoh,
|
||||||
|
// cygstart, which uses ShellExecute() did work... So this is just a
|
||||||
|
// simpler cygstart
|
||||||
|
static char *thisprog;
|
||||||
|
static char usage [] ="rclstartw <fn>\n"
|
||||||
|
" Will use ShellExecute to open the arg with the default app\n";
|
||||||
|
|
||||||
|
static void Usage(FILE *fp = stderr)
|
||||||
|
{
|
||||||
|
fprintf(fp, "%s: usage:\n%s", thisprog, usage);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
thisprog = argv[0];
|
||||||
|
argc--; argv++;
|
||||||
|
|
||||||
|
if (argc != 1) {
|
||||||
|
Usage();
|
||||||
|
}
|
||||||
|
char *fn = strdup(argv[0]);
|
||||||
|
|
||||||
|
// Do we need this ?
|
||||||
|
//https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx
|
||||||
|
//CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
||||||
|
|
||||||
|
int ret = (int)ShellExecute(NULL, "open", fn, NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
if (ret) {
|
||||||
|
fprintf(stderr, "ShellExecute returned %d\n", ret);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue