Windows: implement GUI to start the windows task scheduler for batch indexing
This commit is contained in:
parent
c444a66bc8
commit
c849f96cc3
@ -17,7 +17,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="mainExplainLBL">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2005 J.F.Dockes
|
/* Copyright (C) 2005-2019 J.F.Dockes
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -24,8 +24,12 @@
|
|||||||
#include "listdialog.h"
|
#include "listdialog.h"
|
||||||
#include "confgui/confguiindex.h"
|
#include "confgui/confguiindex.h"
|
||||||
#include "idxsched.h"
|
#include "idxsched.h"
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "winschedtool.h"
|
||||||
|
#else
|
||||||
#include "crontool.h"
|
#include "crontool.h"
|
||||||
#include "rtitool.h"
|
#include "rtitool.h"
|
||||||
|
#endif
|
||||||
#include "snippets_w.h"
|
#include "snippets_w.h"
|
||||||
#include "fragbuts.h"
|
#include "fragbuts.h"
|
||||||
#include "specialindex.h"
|
#include "specialindex.h"
|
||||||
@ -197,17 +201,19 @@ void RclMain::execIndexSched()
|
|||||||
}
|
}
|
||||||
void RclMain::showIndexSched(bool modal)
|
void RclMain::showIndexSched(bool modal)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
QMessageBox::information(this, tr("Index scheduling"),
|
|
||||||
tr("Sorry, not available under Windows for now, use the File menu entries "
|
|
||||||
"to update the index"));
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
LOGDEB("showIndexSched()\n" );
|
LOGDEB("showIndexSched()\n" );
|
||||||
if (indexSched == 0) {
|
if (indexSched == 0) {
|
||||||
indexSched = new IdxSchedW(this);
|
indexSched = new IdxSchedW(this);
|
||||||
connect(new QShortcut(quitKeySeq, indexSched), SIGNAL (activated()),
|
connect(new QShortcut(quitKeySeq, indexSched), SIGNAL (activated()),
|
||||||
this, SLOT (fileExit()));
|
this, SLOT (fileExit()));
|
||||||
|
#ifdef _WIN32
|
||||||
|
indexSched->cronCLB->setText(tr("Batch scheduling"));
|
||||||
|
indexSched->cronCLB->setDescription(
|
||||||
|
tr("The tool will let you decide at what time indexing should run. "
|
||||||
|
" It uses the Windows task scheduler."));
|
||||||
|
indexSched->mainExplainLBL->hide();
|
||||||
|
indexSched->rtidxCLB->hide();
|
||||||
|
#endif
|
||||||
connect(indexSched->cronCLB, SIGNAL(clicked()),
|
connect(indexSched->cronCLB, SIGNAL(clicked()),
|
||||||
this, SLOT(execCronTool()));
|
this, SLOT(execCronTool()));
|
||||||
if (theconfig && theconfig->isDefaultConfig()) {
|
if (theconfig && theconfig->isDefaultConfig()) {
|
||||||
@ -242,11 +248,16 @@ void RclMain::execCronTool()
|
|||||||
{
|
{
|
||||||
showCronTool(true);
|
showCronTool(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::showCronTool(bool modal)
|
void RclMain::showCronTool(bool modal)
|
||||||
{
|
{
|
||||||
LOGDEB("showCronTool()\n" );
|
LOGDEB("showCronTool()\n" );
|
||||||
if (cronTool == 0) {
|
if (cronTool == 0) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
cronTool = new WinSchedToolW(0);
|
||||||
|
#else
|
||||||
cronTool = new CronToolW(0);
|
cronTool = new CronToolW(0);
|
||||||
|
#endif
|
||||||
connect(new QShortcut(quitKeySeq, cronTool), SIGNAL (activated()),
|
connect(new QShortcut(quitKeySeq, cronTool), SIGNAL (activated()),
|
||||||
this, SLOT (fileExit()));
|
this, SLOT (fileExit()));
|
||||||
} else {
|
} else {
|
||||||
@ -271,6 +282,7 @@ void RclMain::execRTITool()
|
|||||||
}
|
}
|
||||||
void RclMain::showRTITool(bool modal)
|
void RclMain::showRTITool(bool modal)
|
||||||
{
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
LOGDEB("showRTITool()\n" );
|
LOGDEB("showRTITool()\n" );
|
||||||
if (rtiTool == 0) {
|
if (rtiTool == 0) {
|
||||||
rtiTool = new RTIToolW(0);
|
rtiTool = new RTIToolW(0);
|
||||||
@ -286,6 +298,7 @@ void RclMain::showRTITool(bool modal)
|
|||||||
} else {
|
} else {
|
||||||
rtiTool->show();
|
rtiTool->show();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::showUIPrefs()
|
void RclMain::showUIPrefs()
|
||||||
|
|||||||
@ -41,6 +41,7 @@ class ExecCmd;
|
|||||||
class Preview;
|
class Preview;
|
||||||
class ResTable;
|
class ResTable;
|
||||||
class CronToolW;
|
class CronToolW;
|
||||||
|
class WinSchedToolW;
|
||||||
class RTIToolW;
|
class RTIToolW;
|
||||||
class FragButs;
|
class FragButs;
|
||||||
class SpecIdxW;
|
class SpecIdxW;
|
||||||
@ -179,7 +180,11 @@ private:
|
|||||||
UIPrefsDialog *uiprefs{0};
|
UIPrefsDialog *uiprefs{0};
|
||||||
ConfIndexW *indexConfig{0};
|
ConfIndexW *indexConfig{0};
|
||||||
IdxSchedW *indexSched{0};
|
IdxSchedW *indexSched{0};
|
||||||
|
#ifdef _WIN32
|
||||||
|
WinSchedToolW *cronTool{0};
|
||||||
|
#else
|
||||||
CronToolW *cronTool{0};
|
CronToolW *cronTool{0};
|
||||||
|
#endif
|
||||||
RTIToolW *rtiTool{0};
|
RTIToolW *rtiTool{0};
|
||||||
SpellW *spellform{0};
|
SpellW *spellform{0};
|
||||||
FragButs *fragbuts{0};
|
FragButs *fragbuts{0};
|
||||||
|
|||||||
@ -21,7 +21,7 @@ HEADERS += \
|
|||||||
advshist.h \
|
advshist.h \
|
||||||
confgui/confgui.h \
|
confgui/confgui.h \
|
||||||
confgui/confguiindex.h \
|
confgui/confguiindex.h \
|
||||||
crontool.h \
|
winschedtool.h \
|
||||||
widgets/editdialog.h \
|
widgets/editdialog.h \
|
||||||
firstidx.h \
|
firstidx.h \
|
||||||
fragbuts.h \
|
fragbuts.h \
|
||||||
@ -36,7 +36,6 @@ HEADERS += \
|
|||||||
rclmain_w.h \
|
rclmain_w.h \
|
||||||
reslist.h \
|
reslist.h \
|
||||||
restable.h \
|
restable.h \
|
||||||
rtitool.h \
|
|
||||||
searchclause_w.h \
|
searchclause_w.h \
|
||||||
snippets_w.h \
|
snippets_w.h \
|
||||||
specialindex.h \
|
specialindex.h \
|
||||||
@ -52,7 +51,7 @@ SOURCES += \
|
|||||||
advshist.cpp \
|
advshist.cpp \
|
||||||
confgui/confgui.cpp \
|
confgui/confgui.cpp \
|
||||||
confgui/confguiindex.cpp \
|
confgui/confguiindex.cpp \
|
||||||
crontool.cpp \
|
winschedtool.cpp \
|
||||||
fragbuts.cpp \
|
fragbuts.cpp \
|
||||||
guiutils.cpp \
|
guiutils.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
@ -72,7 +71,6 @@ SOURCES += \
|
|||||||
respopup.cpp \
|
respopup.cpp \
|
||||||
reslist.cpp \
|
reslist.cpp \
|
||||||
restable.cpp \
|
restable.cpp \
|
||||||
rtitool.cpp \
|
|
||||||
searchclause_w.cpp \
|
searchclause_w.cpp \
|
||||||
snippets_w.cpp \
|
snippets_w.cpp \
|
||||||
spell_w.cpp \
|
spell_w.cpp \
|
||||||
@ -86,7 +84,7 @@ SOURCES += \
|
|||||||
|
|
||||||
FORMS = \
|
FORMS = \
|
||||||
advsearch.ui \
|
advsearch.ui \
|
||||||
crontool.ui \
|
winschedtool.ui \
|
||||||
widgets/editdialog.ui \
|
widgets/editdialog.ui \
|
||||||
firstidx.ui \
|
firstidx.ui \
|
||||||
idxsched.ui \
|
idxsched.ui \
|
||||||
@ -95,7 +93,6 @@ FORMS = \
|
|||||||
ptrans.ui \
|
ptrans.ui \
|
||||||
rclmain.ui \
|
rclmain.ui \
|
||||||
restable.ui \
|
restable.ui \
|
||||||
rtitool.ui \
|
|
||||||
specialindex.ui \
|
specialindex.ui \
|
||||||
spell.ui \
|
spell.ui \
|
||||||
snippets.ui \
|
snippets.ui \
|
||||||
|
|||||||
89
src/qtgui/winschedtool.cpp
Normal file
89
src/qtgui/winschedtool.cpp
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/* Copyright (C) 2019 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.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
#include "autoconfig.h"
|
||||||
|
#include "winschedtool.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "recoll.h"
|
||||||
|
#include "smallut.h"
|
||||||
|
#include "rclutil.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "execmd.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void WinSchedToolW::init()
|
||||||
|
{
|
||||||
|
if (!theconfig) {
|
||||||
|
QMessageBox::warning(0, tr("Error"),
|
||||||
|
tr("Configuration not initialized"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(startPB, SIGNAL(clicked()), this, SLOT(startWinScheduler()));
|
||||||
|
|
||||||
|
// thisexecpath returns the directory
|
||||||
|
string recollindex = path_cat(path_thisexecpath(), "recollindex.exe");
|
||||||
|
LOGDEB("WinSchedTool: recollindex: " << recollindex << endl);
|
||||||
|
|
||||||
|
string batchfile = path_cat(theconfig->getConfDir(), "winsched.bat");
|
||||||
|
LOGDEB("WinSchedTool: batch file " << batchfile << endl);
|
||||||
|
|
||||||
|
if (!path_exists(batchfile)) {
|
||||||
|
FILE *fp = fopen(batchfile.c_str(), "w");
|
||||||
|
fprintf(fp, "%s -c %s\n", recollindex.c_str(),
|
||||||
|
theconfig->getConfDir().c_str());
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
QString blurb = tr(
|
||||||
|
"<h3>Recoll indexing batch scheduling</h3>"
|
||||||
|
"<p>We use the standard Windows task scheduler for this. The program "
|
||||||
|
"will be started when you click the button below.</p>"
|
||||||
|
"<p>You can use either the full interface "
|
||||||
|
"(<i>Create task</i> in the menu on the right), or the simplified "
|
||||||
|
"<i>Create Basic task</i> wizard. In both cases Copy/Paste the "
|
||||||
|
"batch file path listed below as the <i>Action</i> to be performed."
|
||||||
|
"Once created, you will find your task in the <i>WPD</i> section "
|
||||||
|
"of the task library.</p>"
|
||||||
|
);
|
||||||
|
|
||||||
|
blurb.append("</p><p><tt>").append(u8s2qs(batchfile)).append("</tt></p>");
|
||||||
|
explainLBL->setText(blurb);
|
||||||
|
explainLBL->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinSchedToolW::startWinScheduler()
|
||||||
|
{
|
||||||
|
if (m_cmd) {
|
||||||
|
int status;
|
||||||
|
if (m_cmd->maybereap(&status)) {
|
||||||
|
delete m_cmd;
|
||||||
|
} else {
|
||||||
|
QMessageBox::warning(0, "Recoll",
|
||||||
|
tr("Command already started"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_cmd = new ExecCmd();
|
||||||
|
vector<string> lcmd{"c:/windows/system32/taskschd.msc"};
|
||||||
|
m_cmd->startExec("rclstartw", lcmd, false, false);
|
||||||
|
}
|
||||||
42
src/qtgui/winschedtool.h
Normal file
42
src/qtgui/winschedtool.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* Copyright (C) 2019 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.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
#ifndef _WINSCHEDTOOL_W_H_INCLUDED_
|
||||||
|
#define _WINSCHEDTOOL_W_H_INCLUDED_
|
||||||
|
|
||||||
|
#include "ui_winschedtool.h"
|
||||||
|
|
||||||
|
class QPushButton;
|
||||||
|
class ExecCmd;
|
||||||
|
|
||||||
|
class WinSchedToolW : public QDialog, public Ui::WinSchedToolW {
|
||||||
|
Q_OBJECT;
|
||||||
|
public:
|
||||||
|
WinSchedToolW(QWidget * parent = 0)
|
||||||
|
: QDialog(parent) {
|
||||||
|
setupUi(this);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
QPushButton *startButton{nullptr};
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void startWinScheduler();
|
||||||
|
private:
|
||||||
|
void init();
|
||||||
|
ExecCmd *m_cmd{nullptr};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _WINSCHEDTOOL_W_H_INCLUDED_ */
|
||||||
94
src/qtgui/winschedtool.ui
Normal file
94
src/qtgui/winschedtool.ui
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>WinSchedToolW</class>
|
||||||
|
<widget class="QDialog" name="WinSchedToolW">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>508</width>
|
||||||
|
<height>416</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Recoll Batch indexing</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="explainLBL">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>1</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>Qt::RichText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="startPB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Start Windows Task Scheduler tool</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>WinSchedToolW</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>WinSchedToolW</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
@ -83,7 +83,7 @@ static bool path_isdriveabs(const string& s)
|
|||||||
#include <Shlwapi.h>
|
#include <Shlwapi.h>
|
||||||
#pragma comment(lib, "shlwapi.lib")
|
#pragma comment(lib, "shlwapi.lib")
|
||||||
|
|
||||||
static string path_thisexecpath()
|
string path_thisexecpath()
|
||||||
{
|
{
|
||||||
wchar_t text[MAX_PATH];
|
wchar_t text[MAX_PATH];
|
||||||
GetModuleFileNameW(NULL, text, MAX_PATH);
|
GetModuleFileNameW(NULL, text, MAX_PATH);
|
||||||
|
|||||||
@ -36,6 +36,10 @@ extern bool path_empty(const std::string& path);
|
|||||||
/// e.g. /usr/share/recoll. Depends on OS and config
|
/// e.g. /usr/share/recoll. Depends on OS and config
|
||||||
extern const std::string& path_pkgdatadir();
|
extern const std::string& path_pkgdatadir();
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
extern std::string path_thisexecpath();
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Transcode to utf-8 if possible or url encoding, for display.
|
/// Transcode to utf-8 if possible or url encoding, for display.
|
||||||
extern bool printableUrl(const std::string& fcharset,
|
extern bool printableUrl(const std::string& fcharset,
|
||||||
const std::string& in, std::string& out);
|
const std::string& in, std::string& out);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user