GUI config: propose default name for log file

This commit is contained in:
Jean-Francois Dockes 2019-03-13 08:58:15 +01:00
parent a68350c5a6
commit 57298d98be
5 changed files with 34 additions and 13 deletions

View File

@ -236,9 +236,12 @@ void ConfParamBoolW::loadValue()
ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink cflink,
const QString& lbltxt,
const QString& tltptxt,
bool isdir
bool isdir,
QString dirloc,
QString dfltnm
)
: ConfParamW(parent, cflink), m_isdir(isdir)
: ConfParamW(parent, cflink), m_isdir(isdir), m_dirloc(dirloc),
m_dfltnm(dfltnm)
{
if (!createCommon(lbltxt, tltptxt))
return;
@ -274,7 +277,7 @@ void ConfParamFNW::loadValue()
void ConfParamFNW::showBrowserDialog()
{
QString s = myGetFileName(m_isdir);
QString s = myGetFileName(m_isdir, "", false, m_dirloc, m_dfltnm);
if (!s.isEmpty())
m_le->setText(s);
}

View File

@ -166,7 +166,11 @@ namespace confgui {
const QString& tltptxt);
virtual void loadValue();
public slots:
virtual void setEnabled(bool i) {if(m_cb) ((QWidget*)m_cb)->setEnabled(i);}
virtual void setEnabled(bool i) {
if(m_cb) {
((QWidget*)m_cb)->setEnabled(i);
}
}
public:
QCheckBox *m_cb;
};
@ -176,14 +180,16 @@ namespace confgui {
Q_OBJECT
public:
ConfParamFNW(QWidget *parent, ConfLink cflink,
const QString& lbltxt,
const QString& tltptxt, bool isdir = false);
const QString& lbltxt,
const QString& tltptxt, bool isdir = false,
QString dirloc = QString(),
QString dfltnm = QString()
);
virtual void loadValue();
protected slots:
void showBrowserDialog();
public slots:
virtual void setEnabled(bool i)
{
virtual void setEnabled(bool i) {
if(m_le) ((QWidget*)m_le)->setEnabled(i);
if(m_pb) ((QWidget*)m_pb)->setEnabled(i);
}
@ -191,6 +197,8 @@ namespace confgui {
QLineEdit *m_le;
QPushButton *m_pb;
bool m_isdir;
QString m_dirloc;
QString m_dfltnm;
};
// String list

View File

@ -394,7 +394,9 @@ ConfTopPanelW::ConfTopPanelW(QWidget *parent, ConfNull *config)
ConfLink(new ConfLinkRclRep(config, "logfilename")),
tr("Log file name"),
tr("The file where the messages will be written.<br>"
"Use 'stderr' for terminal output"), false);
"Use 'stderr' for terminal output"), false,
u8s2qs(tmplocation()),
"log-recoll.txt");
gl1->addWidget(w, gridrow++, 1);

View File

@ -418,7 +418,8 @@ int main(int argc, char **argv)
return app.exec();
}
QString myGetFileName(bool isdir, QString caption, bool filenosave)
QString myGetFileName(bool isdir, QString caption, bool filenosave,
QString dirloc, QString dfltnm)
{
LOGDEB1("myFileDialog: isdir " << isdir << "\n");
QFileDialog dialog(0, caption);
@ -436,7 +437,12 @@ QString myGetFileName(bool isdir, QString caption, bool filenosave)
QUrl("clsid:B4BFCC3A-DB2C-424C-B029-7FE99A87C641"));
}
#endif
if (!dirloc.isEmpty()) {
dialog.setDirectory(dirloc);
}
if (!dfltnm.isEmpty()) {
dialog.selectFile(dfltnm);
}
if (isdir) {
dialog.setFileMode(QFileDialog::Directory);
dialog.setOptions(QFileDialog::ShowDirsOnly);
@ -460,4 +466,3 @@ QString myGetFileName(bool isdir, QString caption, bool filenosave)
}
return QString();
}

View File

@ -62,6 +62,9 @@ inline QString u8s2qs(const std::string us)
/** Specialized version of the qt file dialog. Can't use getOpenFile()
etc. cause they hide dot files... */
extern QString myGetFileName(bool isdir, QString caption = QString(),
bool filenosave = false);
bool filenosave = false,
QString dirlocation = QString(),
QString dlftnm = QString()
);
#endif /* _RECOLL_H_INCLUDED_ */