diff --git a/src/qtgui/advsearch_w.cpp b/src/qtgui/advsearch_w.cpp index fcffa509..e218f176 100644 --- a/src/qtgui/advsearch_w.cpp +++ b/src/qtgui/advsearch_w.cpp @@ -439,9 +439,8 @@ void AdvSearch::runSearch() if (!subtreeCMB->currentText().isEmpty()) { QString current = subtreeCMB->currentText(); - Rcl::SearchDataClausePath *pathclause = - new Rcl::SearchDataClausePath((const char*)current.toLocal8Bit(), - direxclCB->isChecked()); + Rcl::SearchDataClausePath *pathclause = new Rcl::SearchDataClausePath( + qs2path(current), direxclCB->isChecked()); if (sdata->getTp() == SCLT_AND) { sdata->addClause(pathclause); } else { @@ -506,7 +505,7 @@ void AdvSearch::fromSearch(std::shared_ptr sdata) dynamic_cast(sdata->m_query[i]); // We can only use one such clause. There should be only one too // if this is sfrom aved search data. - QString qdir = QString::fromLocal8Bit(cs->gettext().c_str()); + QString qdir = path2qs(cs->gettext()); subtreeCMB->setEditText(qdir); direxclCB->setChecked(cs->getexclude()); continue; diff --git a/src/qtgui/confgui/confguiindex.cpp b/src/qtgui/confgui/confguiindex.cpp index 56714d8b..a30bab97 100644 --- a/src/qtgui/confgui/confguiindex.cpp +++ b/src/qtgui/confgui/confguiindex.cpp @@ -173,7 +173,7 @@ void ConfIndexW::showPrefs(bool modal) if (nullptr == m_w) { QString title = u8s2qs("Recoll - Index Settings: "); - title += QString::fromLocal8Bit(m_rclconf->getConfDir().c_str()); + title += path2qs(m_rclconf->getConfDir()); conflinkfactory = MyConfLinkFactRCL(&m_conf, &sknull); if (nullptr == (m_w = new ConfTabsW(this, title, &conflinkfactory))) { return; diff --git a/src/qtgui/fragbuts.cpp b/src/qtgui/fragbuts.cpp index c93ca379..c587cf78 100644 --- a/src/qtgui/fragbuts.cpp +++ b/src/qtgui/fragbuts.cpp @@ -155,10 +155,9 @@ FragButs::FragButs(QWidget* parent) copyfile(src.c_str(), m_fn.c_str(), reason); } if (!file_to_string(m_fn, data, &reason)) { - QMessageBox::warning(0, "Recoll", - tr("%1 not found.").arg( - QString::fromLocal8Bit(m_fn.c_str()))); - LOGERR("Fragbuts:: can't read [" << (m_fn) << "]\n" ); + QMessageBox::warning( + 0, "Recoll", tr("%1 not found.").arg(path2qs(m_fn))); + LOGERR("Fragbuts:: can't read [" << m_fn << "]\n"); return; } FragButsParser parser(this, m_buttons); @@ -169,8 +168,7 @@ FragButs::FragButs(QWidget* parent) xmlInputSource.setData(QString::fromUtf8(data.c_str())); if (!reader.parse(xmlInputSource)) { QMessageBox::warning(0, "Recoll", tr("%1:\n %2") - .arg(QString::fromLocal8Bit(m_fn.c_str())) - .arg(parser.errorMessage)); + .arg(path2qs(m_fn)).arg(parser.errorMessage)); return; } for (vector::iterator it = m_buttons.begin(); diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index f1eaa408..a413fd0c 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -159,9 +159,9 @@ static void recollCleanup() void applyStyleSheet(const QString& ssfname) { - const char *cfname = (const char *)ssfname.toLocal8Bit(); - LOGDEB0("Applying style sheet: [" << (cfname) << "]\n" ); - if (cfname && *cfname) { + const char *cfname = qs2path(ssfname).c_str(); + LOGDEB0("Applying style sheet: [" << cfname << "]\n"); + if (*cfname) { string stylesheet; file_to_string(cfname, stylesheet); qApp->setStyleSheet(QString::fromUtf8(stylesheet.c_str())); @@ -356,7 +356,7 @@ int main(int argc, char **argv) QString msg = app.translate ("Main", "\"history\" file is damaged, please check " - "or remove it: ") + QString::fromLocal8Bit(historyfile.c_str()); + "or remove it: ") + path2qs(historyfile); QMessageBox::critical(0, "Recoll", msg); exit(1); } diff --git a/src/qtgui/multisave.cpp b/src/qtgui/multisave.cpp index 39accf85..c1e92298 100644 --- a/src/qtgui/multisave.cpp +++ b/src/qtgui/multisave.cpp @@ -51,8 +51,8 @@ void multiSave(QWidget *p, vector& docs) QWidget::tr("Choose exactly one directory")); return; } - string dir((const char *)dirl[0].toLocal8Bit()); - LOGDEB2("multiSave: got dir " << (dir) << "\n" ); + string dir(qs2path(dirl[0])); + LOGDEB2("multiSave: got dir " << dir << "\n"); /* Save doc to files in target directory. Issues: - It is quite common to have docs in the array with the same @@ -80,7 +80,7 @@ void multiSave(QWidget *p, vector& docs) if (!listdir(dir, reason, existingNames)) { QMessageBox::warning(0, "Recoll", QWidget::tr("Could not read directory: ") + - QString::fromLocal8Bit(reason.c_str())); + path2qs(reason)); return; } @@ -110,8 +110,7 @@ void multiSave(QWidget *p, vector& docs) if (!suffix.empty()) ss << "." << suffix; - string fn = - (const char *)QString::fromUtf8(ss.str().c_str()).toLocal8Bit(); + string fn = qs2path(u8s2qs(ss.str())); if (existingNames.find(fn) == existingNames.end() && toBeCreated.find(fn) == toBeCreated.end()) { toBeCreated.insert(fn); @@ -132,12 +131,9 @@ void multiSave(QWidget *p, vector& docs) // There is still a race condition here, should we care ? TempFile temp;// not used if (!FileInterner::idocToFile(temp, fn, theconfig, docs[i], false)) { - QMessageBox::warning(0, "Recoll", - QWidget::tr("Cannot extract document: ") + - QString::fromLocal8Bit(docs[i].url.c_str()) + - " | " + - QString::fromLocal8Bit(docs[i].ipath.c_str()) - ); + QMessageBox::warning( + 0, "Recoll", QWidget::tr("Cannot extract document: ") + + path2qs(docs[i].url) + " | " + u8s2qs(docs[i].ipath)); } } } diff --git a/src/qtgui/preview_w.cpp b/src/qtgui/preview_w.cpp index a1c6710a..aa4769ab 100644 --- a/src/qtgui/preview_w.cpp +++ b/src/qtgui/preview_w.cpp @@ -483,7 +483,7 @@ void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum) if (doc.getmeta(Rcl::Doc::keytt, &ctitle) && !ctitle.empty()) { title = QString::fromUtf8(ctitle.c_str(), ctitle.length()); } else { - title = QString::fromLocal8Bit(path_getsimple(doc.url).c_str()); + title = path2qs(path_getsimple(doc.url)); } if (title.length() > 20) { title = title.left(10) + "..." + title.right(10); @@ -641,7 +641,7 @@ bool Preview::runLoadThread(LoadThread& lthr, QTimer& tT, QEventLoop& loop, if (!lthr.missing.empty()) { explain = QString::fromUtf8("
") + tr("Missing helper program: ") + - QString::fromLocal8Bit(lthr.missing.c_str()); + path2qs(lthr.missing); QMessageBox::warning(0, "Recoll", tr("Can't turn doc into internal " "representation for ") + @@ -700,8 +700,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) setCurTabProps(idoc, docnum); QString msg = QString("Loading: %1 (size %2 bytes)") - .arg(QString::fromLocal8Bit(idoc.url.c_str())) - .arg(QString::fromUtf8(idoc.fbytes.c_str())); + .arg(path2qs(idoc.url)).arg(u8s2qs(idoc.fbytes)); QProgressDialog progress(msg, tr("Cancel"), 0, 0, this); progress.setMinimumDuration(2000); @@ -774,7 +773,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum) string path = fileurltolocalpath(idoc.url); if (!path.empty()) { path = path_getfather(path); - QStringList paths(QString::fromLocal8Bit(path.c_str())); + QStringList paths(path2qs(path)); editor->setSearchPaths(paths); } #endif @@ -1034,16 +1033,16 @@ void PreviewTextEdit::displayFields() LOGDEB1("PreviewTextEdit::displayFields()\n"); QString txt = "\n"; - txt += "" + QString::fromLocal8Bit(m_url.c_str()); + txt += "" + path2qs(m_url); if (!m_ipath.empty()) - txt += "|" + QString::fromUtf8(m_ipath.c_str()); + txt += "|" + u8s2qs(m_ipath); txt += "

"; txt += "
\n"; for (const auto& entry: m_fdoc.meta) { - if (!entry.second.empty()) - txt += "
" + QString::fromUtf8(entry.first.c_str()) + "
" - + "
" + QString::fromUtf8(escapeHtml(entry.second).c_str()) - + "
\n"; + if (!entry.second.empty()) { + txt += "
" + u8s2qs(entry.first) + "
" + + "
" + u8s2qs(escapeHtml(entry.second)) + "
\n"; + } } txt += "
"; setHtml(txt); diff --git a/src/qtgui/ptrans_w.cpp b/src/qtgui/ptrans_w.cpp index 57476a89..0c4e0b0d 100644 --- a/src/qtgui/ptrans_w.cpp +++ b/src/qtgui/ptrans_w.cpp @@ -48,7 +48,7 @@ void EditTrans::init(const string& dbdir) connect(cancelPB, SIGNAL(clicked()), this, SLOT(close())); QString lab = whatIdxLA->text(); - lab.append(QString::fromLocal8Bit(m_dbdir.c_str())); + lab.append(path2qs(m_dbdir)); whatIdxLA->setText(lab); QStringList labels(tr("Source path")); @@ -64,12 +64,10 @@ void EditTrans::init(const string& dbdir) for (vector::const_iterator it = opaths.begin(); it != opaths.end(); it++) { transTW->setRowCount(row+1); - transTW->setItem(row, 0, new QTableWidgetItem( - QString::fromLocal8Bit(it->c_str()))); + transTW->setItem(row, 0, new QTableWidgetItem(path2qs(*it))); string npath; conftrans->get(*it, npath, m_dbdir); - transTW->setItem(row, 1, new QTableWidgetItem( - QString::fromLocal8Bit(npath.c_str()))); + transTW->setItem(row, 1, new QTableWidgetItem(path2qs(npath))); row++; } @@ -93,9 +91,9 @@ void EditTrans::on_savePB_clicked() for (int row = 0; row < transTW->rowCount(); row++) { QTableWidgetItem *item0 = transTW->item(row, 0); - string from = path_canon((const char *)item0->text().toLocal8Bit()); + string from = path_canon(qs2path(item0->text())); QTableWidgetItem *item1 = transTW->item(row, 1); - string to = path_canon((const char*)item1->text().toLocal8Bit()); + string to = path_canon(qs2path(item1->text())); conftrans->set(from, to, m_dbdir); } conftrans->holdWrites(false); diff --git a/src/qtgui/rclm_preview.cpp b/src/qtgui/rclm_preview.cpp index 1f3e9571..2d2b2d0f 100644 --- a/src/qtgui/rclm_preview.cpp +++ b/src/qtgui/rclm_preview.cpp @@ -68,7 +68,7 @@ bool RclMain::containerUpToDate(Rcl::Doc& doc) string sig; if (!FileInterner::makesig(theconfig, doc, sig)) { QMessageBox::warning(0, "Recoll", tr("Can't access file: ") + - QString::fromLocal8Bit(doc.url.c_str())); + path2qs(doc.url)); // Let's try the preview anyway... return true; } diff --git a/src/qtgui/rclm_saveload.cpp b/src/qtgui/rclm_saveload.cpp index 53eb9fc7..b9f21057 100644 --- a/src/qtgui/rclm_saveload.cpp +++ b/src/qtgui/rclm_saveload.cpp @@ -30,6 +30,7 @@ #include "xmltosd.h" #include "searchdata.h" #include "copyfile.h" +#include "pathut.h" using namespace std; using namespace Rcl; @@ -42,9 +43,9 @@ static QString prevDir() string defpath = path_cat(theconfig->getConfDir(), "saved_queries"); if (prevdir.isEmpty()) { if (!path_exists(defpath)) { - mkdir(defpath.c_str(), 0700); + path_makepath(defpath, 0700); } - return QString::fromLocal8Bit(defpath.c_str()); + return path2qs(defpath); } else { return prevdir; } @@ -86,7 +87,7 @@ void RclMain::saveLastQuery() return; } - string tofile((const char *)s.toLocal8Bit()); + string tofile(qs2path(s)); // Work around qt 5.9-11 bug (linux at least): defaultSuffix is // not added to saved file name @@ -113,7 +114,7 @@ void RclMain::loadSavedQuery() if (s.isEmpty()) return; - string fromfile((const char *)s.toLocal8Bit()); + string fromfile(qs2path(s)); string xml, reason; if (!file_to_string(fromfile, xml, &reason)) { QMessageBox::warning(this, tr("Read failed"), diff --git a/src/qtgui/rclm_view.cpp b/src/qtgui/rclm_view.cpp index 54986e10..cddeccd6 100644 --- a/src/qtgui/rclm_view.cpp +++ b/src/qtgui/rclm_view.cpp @@ -126,11 +126,10 @@ void RclMain::openWith(Rcl::Doc doc, string cmdspec) // Split the command line vector lcmd; if (!stringToStrings(cmdspec, lcmd)) { - QMessageBox::warning(0, "Recoll", - tr("Bad desktop app spec for %1: [%2]\n" - "Please check the desktop file") - .arg(QString::fromUtf8(doc.mimetype.c_str())) - .arg(QString::fromLocal8Bit(cmdspec.c_str()))); + QMessageBox::warning( + 0, "Recoll", tr("Bad desktop app spec for %1: [%2]\n" + "Please check the desktop file") + .arg(u8s2qs(doc.mimetype)).arg(path2qs(cmdspec))); return; } @@ -192,11 +191,10 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) // Split the command line vector lcmd; if (!stringToStrings(cmd, lcmd)) { - QMessageBox::warning(0, "Recoll", - tr("Bad viewer command line for %1: [%2]\n" - "Please check the mimeview file") - .arg(QString::fromUtf8(doc.mimetype.c_str())) - .arg(QString::fromLocal8Bit(cmd.c_str()))); + QMessageBox::warning( + 0, "Recoll", tr("Bad viewer command line for %1: [%2]\n" + "Please check the mimeview file") + .arg(u8s2qs(doc.mimetype)).arg(path2qs(cmd))); return; } @@ -231,7 +229,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) QString message = tr("The viewer specified in mimeview for %1: %2" " is not found.\nDo you want to start the " " preferences dialog ?") - .arg(mt).arg(QString::fromLocal8Bit(lcmd.front().c_str())); + .arg(mt).arg(path2qs(lcmd.front())); switch(QMessageBox::warning(0, "Recoll", message, "Yes", "No", 0, 0, 1)) { @@ -348,11 +346,9 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) } TempFile temp; if (FileInterner::isCompressed(fn, theconfig)) { - if (!FileInterner::maybeUncompressToTemp(temp, fn, theconfig, - doc)) { - QMessageBox::warning(0, "Recoll", - tr("Can't uncompress file: ") + - QString::fromLocal8Bit(fn.c_str())); + if (!FileInterner::maybeUncompressToTemp(temp, fn, theconfig,doc)) { + QMessageBox::warning( + 0, "Recoll", tr("Can't uncompress file: ") + path2qs(fn)); return; } } diff --git a/src/qtgui/rclm_wins.cpp b/src/qtgui/rclm_wins.cpp index 69cf2c3d..e2e25a91 100644 --- a/src/qtgui/rclm_wins.cpp +++ b/src/qtgui/rclm_wins.cpp @@ -345,7 +345,7 @@ void RclMain::showMissingHelpers() tr("External applications/commands needed for your file types " "and not found, as stored by the last indexing pass in "); msg += ""; - msg += QString::fromLocal8Bit(theconfig->getConfDir().c_str()); + msg += path2qs(theconfig->getConfDir()); msg += "/missing:
\n";
     if (!miss.empty()) {
 	msg += QString::fromUtf8(miss.c_str());
@@ -451,10 +451,9 @@ void RclMain::newDupsW(const Rcl::Doc, const vector dups)
     for (vector::const_iterator it = dups.begin(); 
 	 it != dups.end(); it++) {
 	if (it->ipath.empty()) 
-	    editor->append(QString::fromLocal8Bit(it->url.c_str()));
+	    editor->append(path2qs(it->url));
 	else 
-	    editor->append(QString::fromLocal8Bit(it->url.c_str()) + " | " +
-			   QString::fromUtf8(it->ipath.c_str()));
+	    editor->append(path2qs(it->url) + " | " + u8s2qs(it->ipath));
     }
     editor->moveCursor(QTextCursor::Start);
     editor->ensureCursorVisible();
diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp
index 378ae8a3..af87896f 100644
--- a/src/qtgui/rclmain_w.cpp
+++ b/src/qtgui/rclmain_w.cpp
@@ -138,8 +138,7 @@ void RclMain::init()
     // idxstatus file. Make sure it exists before trying to watch it
     // (case where we're started on an older index, or if the status
     // file was deleted since indexing)
-    QString idxfn = 
-        QString::fromLocal8Bit(theconfig->getIdxStatusFile().c_str());
+    QString idxfn = path2qs(theconfig->getIdxStatusFile());
     QFile qf(idxfn);
     qf.open(QIODevice::ReadWrite);
     qf.setPermissions(QFile::ReadOwner|QFile::WriteOwner);
@@ -719,8 +718,7 @@ void RclMain::startSearch(std::shared_ptr sdata, bool issimple)
     }
 
     if (prefs.synFileEnable && !prefs.synFile.isEmpty()) {
-        string sf = (const char *)prefs.synFile.toLocal8Bit();
-        if (!rcldb->setSynGroupsFile(sf)) {
+        if (!rcldb->setSynGroupsFile(qs2path(prefs.synFile))) {
             QMessageBox::warning(0, "Recoll",
                                  tr("Can't set synonyms file (parse error?)"));
             return;
@@ -932,12 +930,9 @@ void RclMain::on_actionSortByDateDesc_toggled(bool on)
 
 void RclMain::saveDocToFile(Rcl::Doc doc)
 {
-    QString s = 
-        QFileDialog::getSaveFileName(this, //parent
-                                     tr("Save file"), 
-                                     QString::fromLocal8Bit(path_home().c_str())
-            );
-    string tofile((const char *)s.toLocal8Bit());
+    QString s = QFileDialog::getSaveFileName(
+        this, tr("Save file"), path2qs(path_home()));
+    string tofile = qs2path(s);
     TempFile temp; // not used because tofile is set.
     if (!FileInterner::idocToFile(temp, tofile, theconfig, doc)) {
         QMessageBox::warning(0, "Recoll",
diff --git a/src/qtgui/recoll.h b/src/qtgui/recoll.h
index 96f6101a..9f2204ba 100644
--- a/src/qtgui/recoll.h
+++ b/src/qtgui/recoll.h
@@ -59,6 +59,22 @@ inline QString u8s2qs(const std::string us)
 {
     return QString::fromUtf8(us.c_str());
 }
+inline QString path2qs(const std::string& us)
+{
+#ifdef _WIN32
+    return QString::fromUtf8(us.c_str());
+#else
+    return QString::fromLocal8Bit(us.c_str());
+#endif
+}
+inline std::string qs2path(const QString& qs)
+{
+#ifdef _WIN32
+    return qs2utf8s(qs);
+#else
+    return (const char*)qs.toLocal8Bit();
+#endif
+}
 
 /** Specialized version of the qt file dialog. Can't use getOpenFile()
    etc. cause they hide dot files... */
diff --git a/src/qtgui/respopup.cpp b/src/qtgui/respopup.cpp
index 9d6c36d2..aeef5a59 100644
--- a/src/qtgui/respopup.cpp
+++ b/src/qtgui/respopup.cpp
@@ -29,12 +29,16 @@
 
 namespace ResultPopup {
 
-QMenu *create(QWidget *me, int opts, std::shared_ptr source, Rcl::Doc& doc)
+QMenu *create(QWidget *me, int opts, std::shared_ptr source,
+              Rcl::Doc& doc)
 {
     QMenu *popup = new QMenu(me);
 
-    LOGDEB("ResultPopup::create: opts "  << (opts) << " haspages "  << (doc.haspages) << " "  << (source ? "Source not null" : "Source is Null") << " "  << (source ? (source->snippetsCapable() ? 
-		      "snippetsCapable" : "not snippetsCapable") : "") << "\n" );
+    LOGDEB("ResultPopup::create: opts " << opts << " haspages " <<
+           doc.haspages << " " <<(source ? "Source not null" : "Source is Null")
+           << " "  << (source ? (source->snippetsCapable() ? 
+                                 "snippetsCapable" : "not snippetsCapable") : "")
+           << "\n");
 
     string apptag;
     doc.getmeta(Rcl::Doc::keyapptg, &apptag);
@@ -158,7 +162,7 @@ void copyFN(const Rcl::Doc &doc)
     // conversion, but it's probably better (less worse...) to
     // make a "best effort" tentative and try to convert from the
     // locale's charset than accept the default conversion.
-    QString qfn = QString::fromLocal8Bit(doc.url.c_str()+7);
+    QString qfn = path2qs(doc.url.c_str()+7);
     QApplication::clipboard()->setText(qfn, QClipboard::Selection);
     QApplication::clipboard()->setText(qfn, QClipboard::Clipboard);
 }
diff --git a/src/qtgui/spell_w.cpp b/src/qtgui/spell_w.cpp
index 7fb824b2..201cb785 100644
--- a/src/qtgui/spell_w.cpp
+++ b/src/qtgui/spell_w.cpp
@@ -312,7 +312,7 @@ void SpellW::showStats()
     resTW->setItem(row++, 1,
                    new QTableWidgetItem(QString::number(st.fileerrors)));
 
-    baseWordLE->setText(QString::fromLocal8Bit(theconfig->getDbDir().c_str()));
+    baseWordLE->setText(path2qs(theconfig->getDbDir()));
 
     int64_t dbkbytes = fsTreeBytes(theconfig->getDbDir()) / 1024;
     if (dbkbytes < 0) {
diff --git a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp
index 007c1199..ed5909d3 100644
--- a/src/qtgui/uiprefs_w.cpp
+++ b/src/qtgui/uiprefs_w.cpp
@@ -187,16 +187,16 @@ void UIPrefsDialog::setFromPrefs()
     if (qssFile.isEmpty()) {
         stylesheetPB->setText(tr("Choose"));
     } else {
-        string nm = path_getsimple((const char *)qssFile.toLocal8Bit());
-        stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
+        string nm = path_getsimple(qs2path(qssFile));
+        stylesheetPB->setText(path2qs(nm));
     }
 
     snipCssFile = prefs.snipCssFile;
     if (snipCssFile.isEmpty()) {
         snipCssPB->setText(tr("Choose"));
     } else {
-        string nm = path_getsimple((const char *)snipCssFile.toLocal8Bit());
-        snipCssPB->setText(QString::fromLocal8Bit(nm.c_str()));
+        string nm = path_getsimple(qs2path(snipCssFile));
+        snipCssPB->setText(path2qs(nm));
     }
     snipwMaxLenSB->setValue(prefs.snipwMaxLength);
     snipwByPageCB->setChecked(prefs.snipwSortByPage);
@@ -240,21 +240,21 @@ void UIPrefsDialog::setFromPrefs()
     if (synFile.isEmpty()) {
         synFilePB->setText(tr("Choose"));
     } else {
-        string nm = path_getsimple((const char *)synFile.toLocal8Bit());
-        synFilePB->setText(QString::fromLocal8Bit(nm.c_str()));
+        string nm = path_getsimple(qs2path(synFile));
+        synFilePB->setText(path2qs(nm));
     }
 
     // Initialize the extra indexes listboxes
     idxLV->clear();
     for (const auto& dbdir : prefs.allExtraDbs) {
         QListWidgetItem *item = 
-            new QListWidgetItem(QString::fromLocal8Bit(dbdir.c_str()), idxLV);
+            new QListWidgetItem(path2qs(dbdir), idxLV);
         if (item) 
             item->setCheckState(Qt::Unchecked);
     }
     for (const auto& dbdir : prefs.activeExtraDbs) {
         auto items =
-            idxLV->findItems (QString::fromLocal8Bit(dbdir.c_str()), 
+            idxLV->findItems(path2qs(dbdir), 
                               Qt::MatchFixedString|Qt::MatchCaseSensitive);
         for (auto& entry : items) {
             entry->setCheckState(Qt::Checked);
@@ -377,10 +377,9 @@ void UIPrefsDialog::accept()
     for (int i = 0; i < idxLV->count(); i++) {
         QListWidgetItem *item = idxLV->item(i);
         if (item) {
-            prefs.allExtraDbs.push_back((const char *)item->text().toLocal8Bit());
+            prefs.allExtraDbs.push_back(qs2path(item->text()));
             if (item->checkState() == Qt::Checked) {
-                prefs.activeExtraDbs.push_back((const char *)
-                                               item->text().toLocal8Bit());
+                prefs.activeExtraDbs.push_back(qs2path(item->text()));
             }
         }
     }
@@ -463,9 +462,9 @@ void UIPrefsDialog::showFontDialog()
 void UIPrefsDialog::showStylesheetDialog()
 {
     qssFile = myGetFileName(false, "Select stylesheet file", true);
-    string nm = path_getsimple((const char *)qssFile.toLocal8Bit());
+    string nm = path_getsimple(qs2path(qssFile));
     if (!nm.empty()) {
-        stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
+        stylesheetPB->setText(path2qs(nm));
     } else {
         stylesheetPB->setText(tr("Choose"));
     }
@@ -479,8 +478,8 @@ void UIPrefsDialog::resetStylesheet()
 void UIPrefsDialog::showSnipCssDialog()
 {
     snipCssFile = myGetFileName(false, "Select snippets window CSS file", true);
-    string nm = path_getsimple((const char *)snipCssFile.toLocal8Bit());
-    snipCssPB->setText(QString::fromLocal8Bit(nm.c_str()));
+    string nm = path_getsimple(qs2path(snipCssFile));
+    snipCssPB->setText(path2qs(nm));
 }
 void UIPrefsDialog::resetSnipCss()
 {
@@ -493,8 +492,8 @@ void UIPrefsDialog::showSynFileDialog()
     synFile = myGetFileName(false, "Select synonyms file", true);
     if (synFile.isEmpty())
         return;
-    string nm = path_getsimple((const char *)synFile.toLocal8Bit());
-    synFilePB->setText(QString::fromLocal8Bit(nm.c_str()));
+    string nm = path_getsimple(qs2path(synFile));
+    synFilePB->setText(path2qs(nm));
 }
 
 void UIPrefsDialog::resetReslistFont()
@@ -539,7 +538,7 @@ void UIPrefsDialog::extraDbEditPtrans()
     } else if (idxLV->selectedItems().size() == 1) {
         QListWidgetItem *item = idxLV->selectedItems()[0];
         QString qd = item->data(Qt::DisplayRole).toString();
-        dbdir = (const char *)qd.toLocal8Bit();
+        dbdir = qs2path(qd);
     } else {
         QMessageBox::warning(
             0, "Recoll", tr("At most one index should be selected"));
@@ -629,7 +628,7 @@ void UIPrefsDialog::addExtraDbPB_clicked()
 
     if (input.isEmpty())
         return;
-    string dbdir = (const char *)input.toLocal8Bit();
+    string dbdir = qs2path(input);
     if (path_exists(path_cat(dbdir, "recoll.conf"))) {
         // Chosen dir is config dir.
         RclConfig conf(&dbdir);
@@ -646,8 +645,8 @@ void UIPrefsDialog::addExtraDbPB_clicked()
     LOGDEB("ExtraDbDial: got: ["  << (dbdir) << "]\n" );
     bool stripped;
     if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
-        QMessageBox::warning(0, "Recoll", 
-                             tr("The selected directory does not appear to be a Xapian index"));
+        QMessageBox::warning(0, "Recoll", tr("The selected directory does not "
+                                             "appear to be a Xapian index"));
         return;
     }
     if (o_index_stripchars != stripped) {
@@ -657,14 +656,13 @@ void UIPrefsDialog::addExtraDbPB_clicked()
         return;
     }
     if (samedir(dbdir, theconfig->getDbDir())) {
-        QMessageBox::warning(0, "Recoll", 
-                             tr("This is the main/local index!"));
+        QMessageBox::warning(0, "Recoll", tr("This is the main/local index!"));
         return;
     }
 
     for (int i = 0; i < idxLV->count(); i++) {
         QListWidgetItem *item = idxLV->item(i);
-        string existingdir = (const char *)item->text().toLocal8Bit();
+        string existingdir = qs2path(item->text());
         if (samedir(dbdir, existingdir)) {
             QMessageBox::warning(
                 0, "Recoll", tr("The selected directory is already in the "
@@ -673,8 +671,7 @@ void UIPrefsDialog::addExtraDbPB_clicked()
         }
     }
 
-    QListWidgetItem *item = 
-        new QListWidgetItem(QString::fromLocal8Bit(dbdir.c_str()), idxLV);
+    QListWidgetItem *item = new QListWidgetItem(path2qs(dbdir), idxLV);
     item->setCheckState(Qt::Checked);
     idxLV->sortItems();
 }