2011-12-04 16:54:57 +01:00
|
|
|
/* ============================================================
|
2017-02-07 14:52:56 +01:00
|
|
|
* QupZilla - Qt web browser
|
|
|
|
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
|
2011-12-04 16:54:57 +01:00
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2011-12-02 23:25:27 +01:00
|
|
|
#include "speeddial.h"
|
|
|
|
#include "pagethumbnailer.h"
|
2012-01-11 21:58:25 +01:00
|
|
|
#include "settings.h"
|
2014-03-09 21:51:42 +01:00
|
|
|
#include "datapaths.h"
|
2013-12-25 19:06:58 +01:00
|
|
|
#include "qztools.h"
|
2014-09-29 18:23:42 +02:00
|
|
|
#include "autosaver.h"
|
2011-12-02 23:25:27 +01:00
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QDir>
|
|
|
|
#include <QCryptographicHash>
|
|
|
|
#include <QFileDialog>
|
2015-01-27 11:01:52 +01:00
|
|
|
#include <QWebEnginePage>
|
2012-04-12 15:24:57 +02:00
|
|
|
#include <QImage>
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2012-02-05 17:13:08 +01:00
|
|
|
#define ENSURE_LOADED if (!m_loaded) loadSettings();
|
|
|
|
|
2011-12-02 23:25:27 +01:00
|
|
|
SpeedDial::SpeedDial(QObject* parent)
|
|
|
|
: QObject(parent)
|
2012-01-21 20:27:45 +01:00
|
|
|
, m_maxPagesInRow(4)
|
|
|
|
, m_sizeOfSpeedDials(231)
|
2014-02-01 19:21:49 +01:00
|
|
|
, m_sdcentered(false)
|
2011-12-02 23:25:27 +01:00
|
|
|
, m_loaded(false)
|
|
|
|
, m_regenerateScript(true)
|
|
|
|
{
|
2014-09-29 18:23:42 +02:00
|
|
|
m_autoSaver = new AutoSaver(this);
|
|
|
|
connect(m_autoSaver, SIGNAL(save()), this, SLOT(saveSettings()));
|
2016-02-26 10:43:34 +01:00
|
|
|
connect(this, SIGNAL(pagesChanged()), m_autoSaver, SLOT(changeOccurred()));
|
2014-09-29 18:23:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SpeedDial::~SpeedDial()
|
|
|
|
{
|
|
|
|
m_autoSaver->saveIfNecessary();
|
2011-12-02 23:25:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SpeedDial::loadSettings()
|
|
|
|
{
|
|
|
|
m_loaded = true;
|
|
|
|
|
2012-01-11 21:58:25 +01:00
|
|
|
Settings settings;
|
2011-12-02 23:25:27 +01:00
|
|
|
settings.beginGroup("SpeedDial");
|
2012-09-02 11:42:41 +02:00
|
|
|
QString allPages = settings.value("pages", QString()).toString();
|
2015-09-05 21:03:08 +02:00
|
|
|
setBackgroundImage(settings.value("background", QString()).toString());
|
2012-01-18 21:09:27 +01:00
|
|
|
m_backgroundImageSize = settings.value("backsize", "auto").toString();
|
2012-01-18 20:10:04 +01:00
|
|
|
m_maxPagesInRow = settings.value("pagesrow", 4).toInt();
|
2012-01-19 18:05:21 +01:00
|
|
|
m_sizeOfSpeedDials = settings.value("sdsize", 231).toInt();
|
2015-09-24 17:58:25 +02:00
|
|
|
m_sdcentered = settings.value("sdcenter", false).toBool();
|
2011-12-02 23:25:27 +01:00
|
|
|
settings.endGroup();
|
|
|
|
|
2012-02-05 16:00:23 +01:00
|
|
|
if (allPages.isEmpty()) {
|
2016-01-02 12:38:16 +01:00
|
|
|
allPages = "url:\"https://www.qupzilla.com\"|title:\"QupZilla\";"
|
2012-02-05 16:00:23 +01:00
|
|
|
"url:\"http://blog.qupzilla.com\"|title:\"QupZilla Blog\";"
|
2012-04-17 14:00:32 +02:00
|
|
|
"url:\"https://github.com/QupZilla/qupzilla\"|title:\"QupZilla GitHub\";"
|
2013-08-12 10:34:35 +02:00
|
|
|
"url:\"https://duckduckgo.com\"|title:\"DuckDuckGo\";";
|
2011-12-04 20:35:49 +01:00
|
|
|
}
|
2012-02-05 16:00:23 +01:00
|
|
|
changed(allPages);
|
2011-12-04 20:35:49 +01:00
|
|
|
|
2014-03-09 22:17:13 +01:00
|
|
|
m_thumbnailsDir = DataPaths::currentProfilePath() + "/thumbnails/";
|
2011-12-02 23:25:27 +01:00
|
|
|
|
|
|
|
// If needed, create thumbnails directory
|
|
|
|
if (!QDir(m_thumbnailsDir).exists()) {
|
2014-03-09 21:51:42 +01:00
|
|
|
QDir(DataPaths::currentProfilePath()).mkdir("thumbnails");
|
2011-12-02 23:25:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpeedDial::saveSettings()
|
|
|
|
{
|
2012-02-05 17:13:08 +01:00
|
|
|
ENSURE_LOADED;
|
|
|
|
|
2015-08-28 19:25:45 +02:00
|
|
|
if (m_pages.isEmpty()) {
|
2012-01-08 10:56:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-11 21:58:25 +01:00
|
|
|
Settings settings;
|
2011-12-02 23:25:27 +01:00
|
|
|
settings.beginGroup("SpeedDial");
|
2012-02-05 16:00:23 +01:00
|
|
|
settings.setValue("pages", generateAllPages());
|
2015-09-05 21:03:08 +02:00
|
|
|
settings.setValue("background", m_backgroundImageUrl);
|
2012-01-18 21:09:27 +01:00
|
|
|
settings.setValue("backsize", m_backgroundImageSize);
|
2012-01-18 20:10:04 +01:00
|
|
|
settings.setValue("pagesrow", m_maxPagesInRow);
|
2012-01-19 18:05:21 +01:00
|
|
|
settings.setValue("sdsize", m_sizeOfSpeedDials);
|
2012-07-29 20:58:23 +02:00
|
|
|
settings.setValue("sdcenter", m_sdcentered);
|
2011-12-02 23:25:27 +01:00
|
|
|
settings.endGroup();
|
|
|
|
}
|
|
|
|
|
2012-02-05 16:00:23 +01:00
|
|
|
SpeedDial::Page SpeedDial::pageForUrl(const QUrl &url)
|
|
|
|
{
|
2012-02-05 17:13:08 +01:00
|
|
|
ENSURE_LOADED;
|
|
|
|
|
2015-10-14 19:37:01 +02:00
|
|
|
QString urlString = url.toString();
|
|
|
|
if (urlString.endsWith(QL1C('/')))
|
|
|
|
urlString = urlString.left(urlString.size() - 1);
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2015-08-28 19:25:45 +02:00
|
|
|
foreach (const Page &page, m_pages) {
|
2012-02-05 16:00:23 +01:00
|
|
|
if (page.url == urlString) {
|
|
|
|
return page;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Page();
|
|
|
|
}
|
|
|
|
|
|
|
|
QUrl SpeedDial::urlForShortcut(int key)
|
|
|
|
{
|
2012-02-05 17:13:08 +01:00
|
|
|
ENSURE_LOADED;
|
|
|
|
|
2015-08-28 19:25:45 +02:00
|
|
|
if (key < 0 || m_pages.count() <= key) {
|
2012-02-05 16:00:23 +01:00
|
|
|
return QUrl();
|
|
|
|
}
|
|
|
|
|
2015-08-28 19:25:45 +02:00
|
|
|
return QUrl::fromEncoded(m_pages.at(key).url.toUtf8());
|
2011-12-02 23:25:27 +01:00
|
|
|
}
|
|
|
|
|
2011-12-24 13:31:32 +01:00
|
|
|
void SpeedDial::addPage(const QUrl &url, const QString &title)
|
|
|
|
{
|
2012-02-05 17:13:08 +01:00
|
|
|
ENSURE_LOADED;
|
|
|
|
|
2011-12-24 13:31:32 +01:00
|
|
|
if (url.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-05 16:00:23 +01:00
|
|
|
Page page;
|
2012-07-14 16:19:33 +02:00
|
|
|
page.title = escapeTitle(title);
|
|
|
|
page.url = escapeUrl(url.toString());
|
2011-12-24 13:31:32 +01:00
|
|
|
|
2015-08-28 19:25:45 +02:00
|
|
|
m_pages.append(page);
|
2012-02-05 16:00:23 +01:00
|
|
|
m_regenerateScript = true;
|
2011-12-24 13:31:32 +01:00
|
|
|
|
2012-02-05 16:00:23 +01:00
|
|
|
emit pagesChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpeedDial::removePage(const Page &page)
|
|
|
|
{
|
2012-02-05 17:13:08 +01:00
|
|
|
ENSURE_LOADED;
|
|
|
|
|
2015-10-14 19:37:01 +02:00
|
|
|
if (!page.isValid()) {
|
2012-02-05 16:00:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
removeImageForUrl(page.url);
|
2015-08-28 19:25:45 +02:00
|
|
|
m_pages.removeAll(page);
|
2012-02-05 16:00:23 +01:00
|
|
|
m_regenerateScript = true;
|
2011-12-24 13:31:32 +01:00
|
|
|
|
2012-02-05 16:00:23 +01:00
|
|
|
emit pagesChanged();
|
2011-12-24 13:31:32 +01:00
|
|
|
}
|
|
|
|
|
2012-01-18 20:10:04 +01:00
|
|
|
int SpeedDial::pagesInRow()
|
|
|
|
{
|
2012-02-05 17:13:08 +01:00
|
|
|
ENSURE_LOADED;
|
2012-01-18 20:10:04 +01:00
|
|
|
|
|
|
|
return m_maxPagesInRow;
|
|
|
|
}
|
|
|
|
|
2012-01-19 18:05:21 +01:00
|
|
|
int SpeedDial::sdSize()
|
|
|
|
{
|
2012-02-05 17:13:08 +01:00
|
|
|
ENSURE_LOADED;
|
2012-01-19 18:05:21 +01:00
|
|
|
|
|
|
|
return m_sizeOfSpeedDials;
|
|
|
|
}
|
|
|
|
|
2015-09-24 17:58:25 +02:00
|
|
|
bool SpeedDial::sdCenter()
|
2012-07-29 20:58:23 +02:00
|
|
|
{
|
|
|
|
ENSURE_LOADED;
|
|
|
|
|
|
|
|
return m_sdcentered;
|
|
|
|
}
|
|
|
|
|
2012-01-09 16:23:03 +01:00
|
|
|
QString SpeedDial::backgroundImage()
|
|
|
|
{
|
2012-02-05 17:13:08 +01:00
|
|
|
ENSURE_LOADED;
|
2012-01-09 16:23:03 +01:00
|
|
|
|
2012-01-18 21:09:27 +01:00
|
|
|
return m_backgroundImage;
|
2012-01-09 16:23:03 +01:00
|
|
|
}
|
|
|
|
|
2015-09-05 21:03:08 +02:00
|
|
|
QString SpeedDial::backgroundImageUrl()
|
|
|
|
{
|
|
|
|
return m_backgroundImageUrl;
|
|
|
|
}
|
|
|
|
|
2012-01-09 16:23:03 +01:00
|
|
|
QString SpeedDial::backgroundImageSize()
|
|
|
|
{
|
2012-02-05 17:13:08 +01:00
|
|
|
ENSURE_LOADED;
|
2012-01-09 16:23:03 +01:00
|
|
|
|
2012-01-18 21:09:27 +01:00
|
|
|
return m_backgroundImageSize;
|
2012-01-09 16:23:03 +01:00
|
|
|
}
|
|
|
|
|
2011-12-02 23:25:27 +01:00
|
|
|
QString SpeedDial::initialScript()
|
|
|
|
{
|
2012-02-05 17:13:08 +01:00
|
|
|
ENSURE_LOADED;
|
2011-12-02 23:25:27 +01:00
|
|
|
|
|
|
|
if (!m_regenerateScript) {
|
|
|
|
return m_initialScript;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_regenerateScript = false;
|
|
|
|
m_initialScript.clear();
|
|
|
|
|
2015-08-28 19:25:45 +02:00
|
|
|
foreach (const Page &page, m_pages) {
|
2012-02-05 16:00:23 +01:00
|
|
|
QString imgSource = m_thumbnailsDir + QCryptographicHash::hash(page.url.toUtf8(), QCryptographicHash::Md4).toHex() + ".png";
|
2011-12-02 23:25:27 +01:00
|
|
|
|
|
|
|
if (!QFile(imgSource).exists()) {
|
2015-08-28 20:43:37 +02:00
|
|
|
imgSource = "qrc:html/loading.gif";
|
2011-12-02 23:25:27 +01:00
|
|
|
|
2015-10-14 19:37:01 +02:00
|
|
|
if (!page.isValid()) {
|
2012-09-02 11:42:41 +02:00
|
|
|
imgSource.clear();
|
2011-12-02 23:25:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2015-09-25 16:04:12 +02:00
|
|
|
imgSource = QzTools::pixmapToDataUrl(QPixmap(imgSource)).toString();
|
2011-12-02 23:25:27 +01:00
|
|
|
}
|
|
|
|
|
2012-02-05 16:00:23 +01:00
|
|
|
m_initialScript.append(QString("addBox('%1', '%2', '%3');\n").arg(page.url, page.title, imgSource));
|
2011-12-02 23:25:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return m_initialScript;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpeedDial::changed(const QString &allPages)
|
|
|
|
{
|
2011-12-04 20:35:49 +01:00
|
|
|
if (allPages.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-30 13:43:48 +01:00
|
|
|
const QStringList entries = allPages.split(QLatin1String("\";"), QString::SkipEmptyParts);
|
2015-08-28 19:25:45 +02:00
|
|
|
m_pages.clear();
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2013-03-06 09:05:41 +01:00
|
|
|
foreach (const QString &entry, entries) {
|
2012-02-05 16:00:23 +01:00
|
|
|
if (entry.isEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-12-30 13:43:48 +01:00
|
|
|
const QStringList tmp = entry.split(QLatin1String("\"|"), QString::SkipEmptyParts);
|
2012-02-05 16:00:23 +01:00
|
|
|
if (tmp.count() != 2) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Page page;
|
|
|
|
page.url = tmp.at(0).mid(5);
|
|
|
|
page.title = tmp.at(1).mid(7);
|
|
|
|
|
2015-10-14 19:37:01 +02:00
|
|
|
if (page.url.endsWith(QL1C('/')))
|
|
|
|
page.url = page.url.left(page.url.size() - 1);
|
|
|
|
|
2015-08-28 19:25:45 +02:00
|
|
|
m_pages.append(page);
|
2012-02-05 16:00:23 +01:00
|
|
|
}
|
|
|
|
|
2011-12-02 23:25:27 +01:00
|
|
|
m_regenerateScript = true;
|
2012-02-05 16:00:23 +01:00
|
|
|
emit pagesChanged();
|
2011-12-02 23:25:27 +01:00
|
|
|
}
|
|
|
|
|
2011-12-23 13:47:38 +01:00
|
|
|
void SpeedDial::loadThumbnail(const QString &url, bool loadTitle)
|
2011-12-02 23:25:27 +01:00
|
|
|
{
|
|
|
|
PageThumbnailer* thumbnailer = new PageThumbnailer(this);
|
2012-01-31 21:10:22 +01:00
|
|
|
thumbnailer->setUrl(QUrl::fromEncoded(url.toUtf8()));
|
2011-12-23 13:47:38 +01:00
|
|
|
thumbnailer->setLoadTitle(loadTitle);
|
2013-03-06 09:05:41 +01:00
|
|
|
connect(thumbnailer, SIGNAL(thumbnailCreated(QPixmap)), this, SLOT(thumbnailCreated(QPixmap)));
|
2011-12-02 23:25:27 +01:00
|
|
|
|
|
|
|
thumbnailer->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpeedDial::removeImageForUrl(const QString &url)
|
|
|
|
{
|
2011-12-04 16:54:57 +01:00
|
|
|
QString fileName = m_thumbnailsDir + QCryptographicHash::hash(url.toUtf8(), QCryptographicHash::Md4).toHex() + ".png";
|
2011-12-02 23:25:27 +01:00
|
|
|
|
|
|
|
if (QFile(fileName).exists()) {
|
|
|
|
QFile(fileName).remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-05 21:03:08 +02:00
|
|
|
QStringList SpeedDial::getOpenFileName()
|
2012-01-18 15:05:50 +01:00
|
|
|
{
|
2013-12-30 13:43:48 +01:00
|
|
|
const QString fileTypes = QString("%3(*.png *.jpg *.jpeg *.bmp *.gif *.svg *.tiff)").arg(tr("Image files"));
|
|
|
|
const QString image = QzTools::getOpenFileName("SpeedDial-GetOpenFileName", 0, tr("Select image..."), QDir::homePath(), fileTypes);
|
2012-03-10 23:24:54 +01:00
|
|
|
|
2015-09-05 21:03:08 +02:00
|
|
|
if (image.isEmpty())
|
|
|
|
return QStringList();
|
|
|
|
|
2015-09-25 16:04:12 +02:00
|
|
|
return {QzTools::pixmapToDataUrl(QPixmap(image)).toString(), QUrl::fromLocalFile(image).toEncoded()};
|
2012-01-18 20:10:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-29 14:38:59 +01:00
|
|
|
QString SpeedDial::urlFromUserInput(const QString &url)
|
|
|
|
{
|
2012-07-14 16:19:33 +02:00
|
|
|
return QUrl::fromUserInput(url).toString();
|
2012-01-29 14:38:59 +01:00
|
|
|
}
|
|
|
|
|
2012-01-18 20:10:04 +01:00
|
|
|
void SpeedDial::setBackgroundImage(const QString &image)
|
|
|
|
{
|
2015-09-25 16:04:12 +02:00
|
|
|
m_backgroundImage = QzTools::pixmapToDataUrl(QPixmap(QUrl(image).toLocalFile())).toString();
|
2015-09-05 21:03:08 +02:00
|
|
|
m_backgroundImageUrl = image;
|
2012-01-18 20:10:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SpeedDial::setBackgroundImageSize(const QString &size)
|
|
|
|
{
|
2012-01-18 21:09:27 +01:00
|
|
|
m_backgroundImageSize = size;
|
2012-01-18 20:10:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SpeedDial::setPagesInRow(int count)
|
|
|
|
{
|
|
|
|
m_maxPagesInRow = count;
|
2012-01-18 15:05:50 +01:00
|
|
|
}
|
|
|
|
|
2012-01-19 18:05:21 +01:00
|
|
|
void SpeedDial::setSdSize(int count)
|
|
|
|
{
|
|
|
|
m_sizeOfSpeedDials = count;
|
|
|
|
}
|
|
|
|
|
2015-09-24 17:58:25 +02:00
|
|
|
void SpeedDial::setSdCentered(bool centered)
|
2012-07-29 20:58:23 +02:00
|
|
|
{
|
2015-09-24 17:58:25 +02:00
|
|
|
m_sdcentered = centered;
|
2015-09-05 21:12:54 +02:00
|
|
|
|
2016-02-26 10:43:34 +01:00
|
|
|
m_autoSaver->changeOccurred();
|
2012-07-29 20:58:23 +02:00
|
|
|
}
|
|
|
|
|
2012-04-12 15:24:57 +02:00
|
|
|
void SpeedDial::thumbnailCreated(const QPixmap &pixmap)
|
2011-12-02 23:25:27 +01:00
|
|
|
{
|
|
|
|
PageThumbnailer* thumbnailer = qobject_cast<PageThumbnailer*>(sender());
|
|
|
|
if (!thumbnailer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-23 13:47:38 +01:00
|
|
|
bool loadTitle = thumbnailer->loadTitle();
|
|
|
|
QString title = thumbnailer->title();
|
2011-12-02 23:25:27 +01:00
|
|
|
QString url = thumbnailer->url().toString();
|
2011-12-04 16:54:57 +01:00
|
|
|
QString fileName = m_thumbnailsDir + QCryptographicHash::hash(url.toUtf8(), QCryptographicHash::Md4).toHex() + ".png";
|
2011-12-02 23:25:27 +01:00
|
|
|
|
2012-04-12 15:24:57 +02:00
|
|
|
if (pixmap.isNull()) {
|
2011-12-11 12:34:51 +01:00
|
|
|
fileName = "qrc:/html/broken-page.png";
|
2011-12-23 13:47:38 +01:00
|
|
|
title = tr("Unable to load");
|
2011-12-11 12:34:51 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-04-12 15:24:57 +02:00
|
|
|
if (!pixmap.save(fileName, "PNG")) {
|
2011-12-11 12:34:51 +01:00
|
|
|
qWarning() << "SpeedDial::thumbnailCreated Cannot save thumbnail to " << fileName;
|
|
|
|
}
|
2015-08-28 20:43:37 +02:00
|
|
|
//fileName = QUrl::fromLocalFile(fileName).toString();
|
2011-12-02 23:25:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
m_regenerateScript = true;
|
2015-08-28 20:43:37 +02:00
|
|
|
thumbnailer->deleteLater();
|
2011-12-02 23:25:27 +01:00
|
|
|
|
2015-08-28 20:43:37 +02:00
|
|
|
if (loadTitle)
|
|
|
|
emit pageTitleLoaded(url, title);
|
2012-02-05 16:00:23 +01:00
|
|
|
|
2015-09-25 16:04:12 +02:00
|
|
|
emit thumbnailLoaded(url, QzTools::pixmapToDataUrl(QPixmap(fileName)).toString());
|
2012-02-05 16:00:23 +01:00
|
|
|
}
|
|
|
|
|
2012-07-14 16:19:33 +02:00
|
|
|
QString SpeedDial::escapeTitle(QString title) const
|
|
|
|
{
|
2012-09-04 12:42:45 +02:00
|
|
|
title.replace(QLatin1Char('"'), QLatin1String("""));
|
|
|
|
title.replace(QLatin1Char('\''), QLatin1String("'"));
|
2012-07-14 16:19:33 +02:00
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString SpeedDial::escapeUrl(QString url) const
|
|
|
|
{
|
2012-09-04 12:42:45 +02:00
|
|
|
url.remove(QLatin1Char('"'));
|
|
|
|
url.remove(QLatin1Char('\''));
|
2012-07-14 16:19:33 +02:00
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2012-02-05 16:00:23 +01:00
|
|
|
QString SpeedDial::generateAllPages()
|
|
|
|
{
|
|
|
|
QString allPages;
|
|
|
|
|
2015-08-28 19:25:45 +02:00
|
|
|
foreach (const Page &page, m_pages) {
|
2013-12-30 13:43:48 +01:00
|
|
|
const QString string = QString("url:\"%1\"|title:\"%2\";").arg(page.url, page.title);
|
2012-02-05 16:00:23 +01:00
|
|
|
allPages.append(string);
|
2011-12-02 23:25:27 +01:00
|
|
|
}
|
2011-12-04 19:15:44 +01:00
|
|
|
|
2012-02-05 16:00:23 +01:00
|
|
|
return allPages;
|
2011-12-02 23:25:27 +01:00
|
|
|
}
|