?oved utility method from guiutils.cpp to main.cpp
This commit is contained in:
parent
37400d5d4a
commit
cebc4a6b24
4 changed files with 36 additions and 38 deletions
|
@ -27,10 +27,8 @@
|
|||
#include "base64.h"
|
||||
#include "advshist.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QSettings>
|
||||
#include <QStringList>
|
||||
#include <QFileDialog>
|
||||
|
||||
RclDynConf *g_dynconf;
|
||||
AdvSearchHist *g_advshistory;
|
||||
|
@ -151,8 +149,6 @@ void rwSettings(bool writing)
|
|||
SETTING_RW(prefs.reslistfontsize, "/Recoll/prefs/reslist/fontSize", Int,
|
||||
10);
|
||||
|
||||
prefs.fontcolor = QApplication::palette().text().color().name();
|
||||
|
||||
QString rlfDflt = QString::fromUtf8(prefs.dfltResListFormat);
|
||||
if (writing) {
|
||||
if (prefs.reslistformat.compare(rlfDflt)) {
|
||||
|
@ -418,32 +414,3 @@ string PrefsPack::stemlang()
|
|||
}
|
||||
return stemLang;
|
||||
}
|
||||
|
||||
QString myGetFileName(bool isdir, QString caption, bool filenosave)
|
||||
{
|
||||
LOGDEB1(("myFileDialog: isdir %d\n", isdir));
|
||||
QFileDialog dialog(0, caption);
|
||||
|
||||
if (isdir) {
|
||||
dialog.setFileMode(QFileDialog::Directory);
|
||||
dialog.setOptions(QFileDialog::ShowDirsOnly);
|
||||
} else {
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
if (filenosave)
|
||||
dialog.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
else
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
}
|
||||
dialog.setViewMode(QFileDialog::List);
|
||||
QFlags<QDir::Filter> flags = QDir::NoDotAndDotDot | QDir::Hidden;
|
||||
if (isdir)
|
||||
flags |= QDir::Dirs;
|
||||
else
|
||||
flags |= QDir::Dirs | QDir::Files;
|
||||
dialog.setFilter(flags);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
return dialog.selectedFiles().value(0);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
|
@ -168,9 +168,4 @@ extern void rwSettings(bool dowrite);
|
|||
|
||||
extern QString g_stringAllStem, g_stringNoStem;
|
||||
|
||||
/** 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);
|
||||
|
||||
#endif /* _GUIUTILS_H_INCLUDED_ */
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <qcombobox.h>
|
||||
#include <QLocale>
|
||||
#include <QLibraryInfo>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "rcldb.h"
|
||||
#include "rclconfig.h"
|
||||
|
@ -396,3 +397,32 @@ int main(int argc, char **argv)
|
|||
}
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
QString myGetFileName(bool isdir, QString caption, bool filenosave)
|
||||
{
|
||||
LOGDEB1(("myFileDialog: isdir %d\n", isdir));
|
||||
QFileDialog dialog(0, caption);
|
||||
|
||||
if (isdir) {
|
||||
dialog.setFileMode(QFileDialog::Directory);
|
||||
dialog.setOptions(QFileDialog::ShowDirsOnly);
|
||||
} else {
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
if (filenosave)
|
||||
dialog.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
else
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
}
|
||||
dialog.setViewMode(QFileDialog::List);
|
||||
QFlags<QDir::Filter> flags = QDir::NoDotAndDotDot | QDir::Hidden;
|
||||
if (isdir)
|
||||
flags |= QDir::Dirs;
|
||||
else
|
||||
flags |= QDir::Dirs | QDir::Files;
|
||||
dialog.setFilter(flags);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
return dialog.selectedFiles().value(0);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
|
@ -55,4 +55,10 @@ inline std::string qs2utf8s(const QString& qs)
|
|||
{
|
||||
return std::string((const char *)qs.toUtf8());
|
||||
}
|
||||
|
||||
/** 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);
|
||||
|
||||
#endif /* _RECOLL_H_INCLUDED_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue