diff --git a/src/qtgui/rclm_view.cpp b/src/qtgui/rclm_view.cpp index cddeccd6..c3026b93 100644 --- a/src/qtgui/rclm_view.cpp +++ b/src/qtgui/rclm_view.cpp @@ -37,6 +37,12 @@ using namespace std; +// Browser list used if xdg-open fails for opening the help doc +static const vector browser_list{ + "opera", "google-chrome", "chromium-browser", + "palemoon", "iceweasel", "firefox", "konqueror", "epiphany"}; + + // Start native viewer or preview for input Doc. This is used to allow // using recoll from another app (e.g. Unity Scope) to view embedded // result docs (docs with an ipath). . We act as a proxy to extract @@ -45,12 +51,11 @@ using namespace std; void RclMain::viewUrl() { if (m_urltoview.isEmpty() || !rcldb) - return; + return; QUrl qurl(m_urltoview); - LOGDEB("RclMain::viewUrl: Path [" << - ((const char *)qurl.path().toLocal8Bit()) << "] fragment [" - << ((const char *)qurl.fragment().toLocal8Bit()) << "]\n"); + LOGDEB("RclMain::viewUrl: Path [" << qs2path(qurl.path()) << + "] fragment [" << qs2path(qurl.fragment()) << "]\n"); /* In theory, the url might not be for a file managed by the fs indexer so that the make_udi() call here would be @@ -58,13 +63,12 @@ void RclMain::viewUrl() inside internfile and have some url magic to indicate the appropriate indexer/identification scheme */ string udi; - make_udi((const char *)qurl.path().toLocal8Bit(), - (const char *)qurl.fragment().toLocal8Bit(), udi); + make_udi(qs2path(qurl.path()), qs2path(qurl.fragment()), udi); Rcl::Doc doc; Rcl::Doc idxdoc; // idxdoc.idxi == 0 -> works with base index only if (!rcldb->getDoc(udi, idxdoc, doc) || doc.pc == -1) - return; + return; // StartNativeViewer needs a db source to call getEnclosing() on. Rcl::Query *query = new Rcl::Query(rcldb.get()); @@ -79,22 +83,22 @@ void RclMain::viewUrl() string apptag; doc.getmeta(Rcl::Doc::keyapptg, &apptag); string viewer = theconfig->getMimeViewerDef(doc.mimetype, apptag, - prefs.useDesktopOpen); + prefs.useDesktopOpen); if (viewer.empty()) { - startPreview(doc); + startPreview(doc); } else { - hide(); - startNativeViewer(doc); - // We have a problem here because xdg-open will exit - // immediately after starting the command instead of waiting - // for it, so we can't wait either and we don't know when we - // can exit (deleting the temp file). As a bad workaround we - // sleep some time then exit. The alternative would be to just - // prevent the temp file deletion completely, leaving it - // around forever. Better to let the user save a copy if he - // wants I think. - sleep(30); - fileExit(); + hide(); + startNativeViewer(doc); + // We have a problem here because xdg-open will exit + // immediately after starting the command instead of waiting + // for it, so we can't wait either and we don't know when we + // can exit (deleting the temp file). As a bad workaround we + // sleep some time then exit. The alternative would be to just + // prevent the temp file deletion completely, leaving it + // around forever. Better to let the user save a copy if he + // wants I think. + sleep(30); + fileExit(); } } @@ -103,17 +107,14 @@ void RclMain::viewUrl() * (xdg-open etc.) failed */ static bool lookForHtmlBrowser(string &exefile) { - vector blist{"opera", "google-chrome", "chromium-browser", - "palemoon", "iceweasel", "firefox", "konqueror", "epiphany"}; - const char *path = getenv("PATH"); if (path == 0) { - path = "/usr/local/bin:/usr/bin:/bin"; + path = "/usr/local/bin:/usr/bin:/bin"; } // Look for each browser - for (const auto& entry : blist) { - if (ExecCmd::which(entry, exefile, path)) - return true; + for (const auto& entry : browser_list) { + if (ExecCmd::which(entry, exefile, path)) + return true; } exefile.clear(); return false; @@ -126,11 +127,11 @@ void RclMain::openWith(Rcl::Doc doc, string cmdspec) // Split the command line vector lcmd; if (!stringToStrings(cmdspec, lcmd)) { - QMessageBox::warning( + 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; + return; } // Look for the command to execute in the exec path and the filters @@ -165,12 +166,12 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) // Look for appropriate viewer string cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag, - prefs.useDesktopOpen); + prefs.useDesktopOpen); if (cmdplusattr.empty()) { - QMessageBox::warning(0, "Recoll", - tr("No external viewer configured for mime type [") - + doc.mimetype.c_str() + "]"); - return; + QMessageBox::warning(0, "Recoll", + tr("No external viewer configured for mime type [") + + doc.mimetype.c_str() + "]"); + return; } LOGDEB("StartNativeViewer: viewerdef from config: " << cmdplusattr << endl); @@ -191,59 +192,59 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) // Split the command line vector lcmd; if (!stringToStrings(cmd, lcmd)) { - QMessageBox::warning( + 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; + return; } // Look for the command to execute in the exec path and the filters // directory string execpath; if (!ExecCmd::which(lcmd.front(), execpath)) { - execpath = theconfig->findFilter(lcmd.front()); - // findFilter returns its input param if the filter is not in - // the normal places. As we already looked in the path, we - // have no use for a simple command name here (as opposed to - // mimehandler which will just let execvp do its thing). Erase - // execpath so that the user dialog will be started further - // down. - if (!execpath.compare(lcmd.front())) - execpath.erase(); + execpath = theconfig->findFilter(lcmd.front()); + // findFilter returns its input param if the filter is not in + // the normal places. As we already looked in the path, we + // have no use for a simple command name here (as opposed to + // mimehandler which will just let execvp do its thing). Erase + // execpath so that the user dialog will be started further + // down. + if (!execpath.compare(lcmd.front())) + execpath.erase(); - // Specialcase text/html because of the help browser need - if (execpath.empty() && !doc.mimetype.compare("text/html") && - apptag.empty()) { - if (lookForHtmlBrowser(execpath)) { - lcmd.clear(); - lcmd.push_back(execpath); - lcmd.push_back("%u"); - } - } + // Specialcase text/html because of the help browser need + if (execpath.empty() && !doc.mimetype.compare("text/html") && + apptag.empty()) { + if (lookForHtmlBrowser(execpath)) { + lcmd.clear(); + lcmd.push_back(execpath); + lcmd.push_back("%u"); + } + } } // Command not found: start the user dialog to help find another one: if (execpath.empty()) { - QString mt = QString::fromUtf8(doc.mimetype.c_str()); - QString message = tr("The viewer specified in mimeview for %1: %2" - " is not found.\nDo you want to start the " - " preferences dialog ?") + QString mt = QString::fromUtf8(doc.mimetype.c_str()); + 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(path2qs(lcmd.front())); - switch(QMessageBox::warning(0, "Recoll", message, - "Yes", "No", 0, 0, 1)) { - case 0: - showUIPrefs(); - if (uiprefs) - uiprefs->showViewAction(mt); - break; - case 1: - break; - } + switch(QMessageBox::warning(0, "Recoll", message, + "Yes", "No", 0, 0, 1)) { + case 0: + showUIPrefs(); + if (uiprefs) + uiprefs->showViewAction(mt); + break; + case 1: + break; + } // The user will have to click on the link again to try the // new command. - return; + return; } // Get rid of the command name. lcmd is now argv[1...n] lcmd.erase(lcmd.begin()); @@ -270,42 +271,42 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) } if (wantsparentfile && !urlisfileurl(doc.url)) { - QMessageBox::warning(0, "Recoll", - tr("Viewer command line for %1 specifies " - "parent file but URL is http[s]: unsupported") - .arg(QString::fromUtf8(doc.mimetype.c_str()))); - return; + QMessageBox::warning(0, "Recoll", + tr("Viewer command line for %1 specifies " + "parent file but URL is http[s]: unsupported") + .arg(QString::fromUtf8(doc.mimetype.c_str()))); + return; } if (wantsfile && wantsparentfile) { - QMessageBox::warning(0, "Recoll", - tr("Viewer command line for %1 specifies both " - "file and parent file value: unsupported") - .arg(QString::fromUtf8(doc.mimetype.c_str()))); - return; + QMessageBox::warning(0, "Recoll", + tr("Viewer command line for %1 specifies both " + "file and parent file value: unsupported") + .arg(QString::fromUtf8(doc.mimetype.c_str()))); + return; } - + string url = doc.url; string fn = fileurltolocalpath(doc.url); Rcl::Doc pdoc; if (wantsparentfile) { - // We want the path for the parent document. For example to - // open the chm file, not the internal page. Note that we just - // override the other file name in this case. - if (!m_source || !m_source->getEnclosing(doc, pdoc)) { - QMessageBox::warning(0, "Recoll", - tr("Cannot find parent document")); - return; - } - // Override fn with the parent's : - fn = fileurltolocalpath(pdoc.url); + // We want the path for the parent document. For example to + // open the chm file, not the internal page. Note that we just + // override the other file name in this case. + if (!m_source || !m_source->getEnclosing(doc, pdoc)) { + QMessageBox::warning(0, "Recoll", + tr("Cannot find parent document")); + return; + } + // Override fn with the parent's : + fn = fileurltolocalpath(pdoc.url); - // If the parent document has an ipath too, we need to create - // a temp file even if the command takes an ipath - // parameter. We have no viewer which could handle a double - // embedding. Will have to change if such a one appears. - if (!pdoc.ipath.empty()) { - groksipath = false; - } + // If the parent document has an ipath too, we need to create + // a temp file even if the command takes an ipath + // parameter. We have no viewer which could handle a double + // embedding. Will have to change if such a one appears. + if (!pdoc.ipath.empty()) { + groksipath = false; + } } // Can't remember what enterHistory was actually for. Set it to @@ -320,20 +321,20 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) // there is an ipath that it won't understand, we need a temp file: theconfig->setKeyDir(fn.empty() ? "" : path_getfather(fn)); if (((wantsfile || wantsparentfile) && fn.empty()) || - (!groksipath && !doc.ipath.empty()) ) { - TempFile temp; - Rcl::Doc& thedoc = wantsparentfile ? pdoc : doc; - if (!FileInterner::idocToFile(temp, string(), theconfig, thedoc)) { - QMessageBox::warning(0, "Recoll", - tr("Cannot extract document or create " - "temporary file")); - return; - } - enterHistory = true; + (!groksipath && !doc.ipath.empty()) ) { + TempFile temp; + Rcl::Doc& thedoc = wantsparentfile ? pdoc : doc; + if (!FileInterner::idocToFile(temp, string(), theconfig, thedoc)) { + QMessageBox::warning(0, "Recoll", + tr("Cannot extract document or create " + "temporary file")); + return; + } + enterHistory = true; istempfile = true; - rememberTempFile(temp); - fn = temp.filename(); - url = path_pathtofileurl(fn); + rememberTempFile(temp); + fn = temp.filename(); + url = path_pathtofileurl(fn); } // If using an actual file, check that it exists, and if it is @@ -354,7 +355,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) } if (temp.ok()) { istempfile = true; - rememberTempFile(temp); + rememberTempFile(temp); fn = temp.filename(); url = path_pathtofileurl(fn); } @@ -381,14 +382,14 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term) // If we are not called with a page number (which would happen for a call // from the snippets window), see if we can compute a page number anyway. if (pagenum == -1) { - pagenum = 1; - string lterm; - if (m_source) - pagenum = m_source->getFirstMatchPage(doc, lterm); - if (pagenum == -1) - pagenum = 1; - else // We get the match term used to compute the page - term = QString::fromUtf8(lterm.c_str()); + pagenum = 1; + string lterm; + if (m_source) + pagenum = m_source->getFirstMatchPage(doc, lterm); + if (pagenum == -1) + pagenum = 1; + else // We get the match term used to compute the page + term = QString::fromUtf8(lterm.c_str()); } char cpagenum[20]; sprintf(cpagenum, "%d", pagenum); @@ -445,20 +446,20 @@ void RclMain::execViewer(const map& subs, bool enterHistory, #endif QStatusBar *stb = statusBar(); if (stb) { - string prcmd; + string prcmd; #ifdef _WIN32 prcmd = ncmd; #else - string fcharset = theconfig->getDefCharset(true); - transcode(ncmd, prcmd, fcharset, "UTF-8"); + string fcharset = theconfig->getDefCharset(true); + transcode(ncmd, prcmd, fcharset, "UTF-8"); #endif - QString msg = tr("Executing: [") + - QString::fromUtf8(prcmd.c_str()) + "]"; - stb->showMessage(msg, 10000); + QString msg = tr("Executing: [") + + QString::fromUtf8(prcmd.c_str()) + "]"; + stb->showMessage(msg, 10000); } if (enterHistory) - historyEnterDoc(rcldb.get(), g_dynconf, doc); + historyEnterDoc(rcldb.get(), g_dynconf, doc); // Do the zeitgeist thing zg_send_event(ZGSEND_OPEN, doc); @@ -497,8 +498,8 @@ void RclMain::startManual(const string& index) #endif if (!indexempty) { - usermanual += "#"; - usermanual += index; + usermanual += "#"; + usermanual += index; } Rcl::Doc doc; if (has_wh && indexempty) { diff --git a/src/qtgui/respopup.cpp b/src/qtgui/respopup.cpp index aeef5a59..7feb93f1 100644 --- a/src/qtgui/respopup.cpp +++ b/src/qtgui/respopup.cpp @@ -37,7 +37,7 @@ QMenu *create(QWidget *me, int opts, std::shared_ptr source, LOGDEB("ResultPopup::create: opts " << opts << " haspages " << doc.haspages << " " <<(source ? "Source not null" : "Source is Null") << " " << (source ? (source->snippetsCapable() ? - "snippetsCapable" : "not snippetsCapable") : "") + "snippetsCapable":"not snippetsCapable") : "") << "\n"); string apptag; @@ -46,7 +46,7 @@ QMenu *create(QWidget *me, int opts, std::shared_ptr source, popup->addAction(QWidget::tr("&Preview"), me, SLOT(menuPreview())); if (!theconfig->getMimeViewerDef(doc.mimetype, apptag, 0).empty()) { - popup->addAction(QWidget::tr("&Open"), me, SLOT(menuEdit())); + popup->addAction(QWidget::tr("&Open"), me, SLOT(menuEdit())); } bool needopenwith = true; @@ -105,17 +105,17 @@ QMenu *create(QWidget *me, int opts, std::shared_ptr source, popup->addAction(QWidget::tr("Copy &URL"), me, SLOT(menuCopyURL())); if ((opts&showSaveOne) && (!doc.isFsFile() || !doc.ipath.empty())) - popup->addAction(QWidget::tr("&Write to File"), me, + popup->addAction(QWidget::tr("&Write to File"), me, SLOT(menuSaveToFile())); if ((opts&showSaveSel)) - popup->addAction(QWidget::tr("Save selection to files"), - me, SLOT(menuSaveSelection())); + popup->addAction(QWidget::tr("Save selection to files"), + me, SLOT(menuSaveSelection())); Rcl::Doc pdoc; if (source && source->getEnclosing(doc, pdoc)) { - popup->addAction(QWidget::tr("Preview P&arent document/folder"), - me, SLOT(menuPreviewParent())); + popup->addAction(QWidget::tr("Preview P&arent document/folder"), + me, SLOT(menuPreviewParent())); } // Open parent is useful even if there is no parent because we open // the enclosing folder. @@ -124,16 +124,16 @@ QMenu *create(QWidget *me, int opts, std::shared_ptr source, me, SLOT(menuOpenParent())); if (opts & showExpand) - popup->addAction(QWidget::tr("Find &similar documents"), - me, SLOT(menuExpand())); + popup->addAction(QWidget::tr("Find &similar documents"), + me, SLOT(menuExpand())); if (doc.haspages && source && source->snippetsCapable()) - popup->addAction(QWidget::tr("Open &Snippets window"), - me, SLOT(menuShowSnippets())); + popup->addAction(QWidget::tr("Open &Snippets window"), + me, SLOT(menuShowSnippets())); if ((opts & showSubs) && rcldb && rcldb->hasSubDocs(doc)) - popup->addAction(QWidget::tr("Show subdocuments / attachments"), - me, SLOT(menuShowSubDocs())); + popup->addAction(QWidget::tr("Show subdocuments / attachments"), + me, SLOT(menuShowSubDocs())); return popup; } @@ -142,12 +142,12 @@ Rcl::Doc getParent(std::shared_ptr source, Rcl::Doc& doc) { Rcl::Doc pdoc; if (!source || !source->getEnclosing(doc, pdoc)) { - // No parent doc: show enclosing folder with app configured for - // directories + // No parent doc: show enclosing folder with app configured for + // directories pdoc.url = url_parentfolder(doc.url); - pdoc.meta[Rcl::Doc::keychildurl] = doc.url; - pdoc.meta[Rcl::Doc::keyapptg] = "parentopen"; - pdoc.mimetype = "inode/directory"; + pdoc.meta[Rcl::Doc::keychildurl] = doc.url; + pdoc.meta[Rcl::Doc::keyapptg] = "parentopen"; + pdoc.mimetype = "inode/directory"; } return pdoc; } @@ -169,12 +169,9 @@ void copyFN(const Rcl::Doc &doc) void copyURL(const Rcl::Doc &doc) { - string url = url_encode(doc.url, 7); - QApplication::clipboard()->setText(url.c_str(), - QClipboard::Selection); - QApplication::clipboard()->setText(url.c_str(), - QClipboard::Clipboard); + QString url = path2qs(doc.url); + QApplication::clipboard()->setText(url, QClipboard::Selection); + QApplication::clipboard()->setText(url, QClipboard::Clipboard); } } - diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp index 6241e911..9efefbca 100644 --- a/src/qtgui/restable.cpp +++ b/src/qtgui/restable.cpp @@ -405,14 +405,14 @@ QVariant RecollModel::data(const QModelIndex& index, int role) const int ecnt; string data1; if (!transcode(data, data1, "UTF-8", "UTF-8", &ecnt) || ecnt > 0) { - data = url_encode(data); + data = url_encode(data, 7); } } #endif list lr; g_hiliter.plaintorich(data, lr, m_hdata); - return QString::fromUtf8(lr.front().c_str()); + return u8s2qs(lr.front()); } void RecollModel::saveAsCSV(std::fstream& fp) diff --git a/src/qtgui/rtitool.cpp b/src/qtgui/rtitool.cpp index d5480297..f4f52c7c 100644 --- a/src/qtgui/rtitool.cpp +++ b/src/qtgui/rtitool.cpp @@ -45,7 +45,7 @@ static const char *desktopfiletext = "[Desktop Entry]\n" "Name=Recoll real time indexer\n" "Comment=Runs in background to extract and index text from modified " - "documents\n" + "documents\n" "Icon=system-run\n" "Exec=recollindex -w 60 -m\n" "Terminal=false\n" @@ -61,10 +61,10 @@ static const char *desktopfiletext = void RTIToolW::init() { connect(this->sesCB, SIGNAL(clicked(bool)), - this, SLOT(sesclicked(bool))); + this, SLOT(sesclicked(bool))); string autostartfile = path_cat(path_home(), rautostartfile); if (path_exists(autostartfile)) { - sesCB->setChecked(true); + sesCB->setChecked(true); } } @@ -72,7 +72,7 @@ void RTIToolW::sesclicked(bool on) { nowCB->setEnabled(on); if (!on) - nowCB->setChecked(false); + nowCB->setChecked(false); } void RTIToolW::accept() @@ -81,98 +81,95 @@ void RTIToolW::accept() string autostartfile = path_cat(path_home(), rautostartfile); if (sesCB->isChecked()) { - // Setting up daemon indexing autostart + // Setting up daemon indexing autostart - if (path_exists(autostartfile)) { - QString msg = tr("Replacing: ") + - QString::fromLocal8Bit(autostartfile.c_str()); - - QMessageBox::Button rep = - QMessageBox::question(this, tr("Replacing file"), msg, - QMessageBox::Ok | QMessageBox::Cancel); - if (rep != QMessageBox::Ok) { - goto out; - } - } + if (path_exists(autostartfile)) { + QString msg = tr("Replacing: ") + path2qs(autostartfile); + + QMessageBox::Button rep = + QMessageBox::question(this, tr("Replacing file"), msg, + QMessageBox::Ok | QMessageBox::Cancel); + if (rep != QMessageBox::Ok) { + goto out; + } + } - string text; - if (theconfig) { - string sourcefile = path_cat(theconfig->getDatadir(), "examples"); - sourcefile = path_cat(sourcefile, "recollindex.desktop"); - if (path_exists(sourcefile)) { - file_to_string(sourcefile, text); - } - } - if (text.empty()) - text = desktopfiletext; + string text; + if (theconfig) { + string sourcefile = path_cat(theconfig->getDatadir(), "examples"); + sourcefile = path_cat(sourcefile, "recollindex.desktop"); + if (path_exists(sourcefile)) { + file_to_string(sourcefile, text); + } + } + if (text.empty()) + text = desktopfiletext; - // Try to create .config and autostart anyway. If they exists this will - // do nothing. An error will be detected when we try to create the file - string dir = path_cat(path_home(), ".config"); - mkdir(dir.c_str(), 0700); - dir = path_cat(dir, "autostart"); - mkdir(dir.c_str(), 0700); + // Try to create .config and autostart anyway. If they exists this will + // do nothing. An error will be detected when we try to create the file + string dir = path_cat(path_home(), ".config"); + mkdir(dir.c_str(), 0700); + dir = path_cat(dir, "autostart"); + mkdir(dir.c_str(), 0700); string reason; if (!stringtofile(text, autostartfile.c_str(), reason)) { - QString msg = tr("Can't create: ") + - QString::fromLocal8Bit(autostartfile.c_str()); - QMessageBox::warning(0, tr("Warning"), msg, QMessageBox::Ok); - return; - } + QString msg = tr("Can't create: ") + path2qs(autostartfile); + QMessageBox::warning(0, tr("Warning"), msg, QMessageBox::Ok); + return; + } - if (nowCB->isChecked()) { - ExecCmd cmd; - vector args; - int status; + if (nowCB->isChecked()) { + ExecCmd cmd; + vector args; + int status; - args.push_back("-m"); - args.push_back("-w"); - args.push_back("0"); - status = cmd.doexec("recollindex", args, 0, 0); - if (status) { - QMessageBox::warning(0, tr("Warning"), - tr("Could not execute recollindex"), - QMessageBox::Ok); - goto out; - } - } + args.push_back("-m"); + args.push_back("-w"); + args.push_back("0"); + status = cmd.doexec("recollindex", args, 0, 0); + if (status) { + QMessageBox::warning(0, tr("Warning"), + tr("Could not execute recollindex"), + QMessageBox::Ok); + goto out; + } + } - exitdial = true; + exitdial = true; } else { - // Turning autostart off - if (path_exists(autostartfile)) { - QString msg = tr("Deleting: ") + - QString::fromLocal8Bit(autostartfile.c_str()); - - QMessageBox::Button rep = - QMessageBox::question(this, tr("Deleting file"), msg, - QMessageBox::Ok | QMessageBox::Cancel); - if (rep == QMessageBox::Ok) { - exitdial = true; - unlink(autostartfile.c_str()); - if (theconfig) { - Pidfile pidfile(theconfig->getPidfile()); - pid_t pid; - if ((pid = pidfile.open()) != 0) { - QMessageBox::Button rep = - QMessageBox::question(this, - tr("Removing autostart"), - tr("Autostart file deleted. Kill current process too ?"), - QMessageBox::Yes | QMessageBox::No); - if (rep == QMessageBox::Yes) { - kill(pid, SIGTERM); - } - } - } - } - } else { - exitdial = true; - } + // Turning autostart off + if (path_exists(autostartfile)) { + QString msg = tr("Deleting: ") + path2qs(autostartfile); + + QMessageBox::Button rep = + QMessageBox::question(this, tr("Deleting file"), msg, + QMessageBox::Ok | QMessageBox::Cancel); + if (rep == QMessageBox::Ok) { + exitdial = true; + unlink(autostartfile.c_str()); + if (theconfig) { + Pidfile pidfile(theconfig->getPidfile()); + pid_t pid; + if ((pid = pidfile.open()) != 0) { + QMessageBox::Button rep = + QMessageBox::question( + this, tr("Removing autostart"), + tr("Autostart file deleted. Kill current process too ?"), + QMessageBox::Yes | QMessageBox::No); + if (rep == QMessageBox::Yes) { + kill(pid, SIGTERM); + } + } + } + } + } else { + exitdial = true; + } } out: if (exitdial) - QDialog::accept(); + QDialog::accept(); } #endif diff --git a/src/qtgui/webcache.cpp b/src/qtgui/webcache.cpp index 2effb028..e508338d 100644 --- a/src/qtgui/webcache.cpp +++ b/src/qtgui/webcache.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 J.F.Dockes +/* Copyright (C) 2016-2020 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 @@ -37,6 +37,7 @@ #include "conftree.h" #include "rclmain_w.h" #include "smallut.h" +#include "log.h" using namespace std; @@ -160,15 +161,16 @@ QVariant WebcacheModel::data(const QModelIndex& index, int role) const void WebcacheModel::setSearchFilter(const QString& _txt) { - SimpleRegexp re(qs2utf8s(_txt), SimpleRegexp::SRE_NOSUB); + SimpleRegexp re( + qs2utf8s(_txt), SimpleRegexp::SRE_NOSUB|SimpleRegexp::SRE_ICASE); m->disp.clear(); for (unsigned int i = 0; i < m->all.size(); i++) { if (re(m->all[i].url)) { m->disp.push_back(m->all[i]); } else { - //qDebug() << "match failed. exp" << _txt << "data" << - // m->all[i].url.c_str(); + LOGDEB1(" WebcacheMOdel::filter: match failed. exp" << + qs2utf8s(_txt) << "data" << m->all[i].url); } } emit dataChanged(createIndex(0,0), createIndex(1, m->all.size())); @@ -197,19 +199,19 @@ WebcacheEdit::WebcacheEdit(RclMain *parent) wl = settings.value(cwnm).toStringList(); QHeaderView *header = tableview->horizontalHeader(); if (header) { - if (int(wl.size()) == header->count()) { - for (int i = 0; i < header->count(); i++) { - header->resizeSection(i, wl[i].toInt()); - } - } + if (int(wl.size()) == header->count()) { + for (int i = 0; i < header->count(); i++) { + header->resizeSection(i, wl[i].toInt()); + } + } } connect(header, SIGNAL(sectionResized(int,int,int)), this, SLOT(saveColState())); header = tableview->verticalHeader(); if (header) { - header->setDefaultSectionSize(QApplication::fontMetrics().height() + - ROWHEIGHTPAD); + header->setDefaultSectionSize(QApplication::fontMetrics().height() + + ROWHEIGHTPAD); } int width = settings.value(wwnm, 0).toInt(); @@ -223,7 +225,7 @@ WebcacheEdit::WebcacheEdit(RclMain *parent) connect(new QShortcut(closeKS, this), SIGNAL (activated()), this, SLOT (close())); connect(tableview, SIGNAL(customContextMenuRequested(const QPoint&)), - this, SLOT(createPopupMenu(const QPoint&))); + this, SLOT(createPopupMenu(const QPoint&))); } @@ -279,13 +281,11 @@ void WebcacheEdit::copyURL() QModelIndexList selection = tableview->selectionModel()->selectedRows(); if (selection.size() != 1) return; - string url = m_model->getURL(selection[0].row()); + const string& url = m_model->getURL(selection[0].row()); if (!url.empty()) { - url = url_encode(url, 7); - QApplication::clipboard()->setText(url.c_str(), - QClipboard::Selection); - QApplication::clipboard()->setText(url.c_str(), - QClipboard::Clipboard); + QString qurl = path2qs(url); + QApplication::clipboard()->setText(qurl, QClipboard::Selection); + QApplication::clipboard()->setText(qurl, QClipboard::Clipboard); } } @@ -295,8 +295,8 @@ void WebcacheEdit::saveColState() QHeaderView *header = tableview->horizontalHeader(); QStringList newwidths; for (int vi = 0; vi < header->count(); vi++) { - int li = header->logicalIndex(vi); - newwidths.push_back(lltodecstr(header->sectionSize(li)).c_str()); + int li = header->logicalIndex(vi); + newwidths.push_back(lltodecstr(header->sectionSize(li)).c_str()); } QSettings settings;