1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

Remove ImageFinder plugin

This commit is contained in:
David Rosca 2018-03-03 12:50:27 +01:00
parent 0495b46d16
commit d0e924db51
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
16 changed files with 0 additions and 627 deletions

View File

@ -4,7 +4,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/plugins")
add_subdirectory(AutoScroll)
add_subdirectory(FlashCookieManager)
add_subdirectory(GreaseMonkey)
add_subdirectory(ImageFinder)
add_subdirectory(MouseGestures)
add_subdirectory(PIM)
add_subdirectory(StatusBarIcons)

View File

@ -1,22 +0,0 @@
set( ImageFinder_SRCS
imagefinderplugin.cpp
imagefinder.cpp
imagefindersettings.cpp
)
ecm_create_qm_loader( ImageFinder_SRCS falkon_imagefinder_qt )
set( ImageFinder_UIS
imagefindersettings.ui
)
qt5_wrap_ui(UIS ${ImageFinder_UIS})
set( ImageFinder_RSCS
imagefinder.qrc
)
qt5_add_resources(RSCS ${ImageFinder_RSCS})
add_library(ImageFinder MODULE ${ImageFinder_SRCS} ${UIS} ${RSCS})
install(TARGETS ImageFinder DESTINATION ${FALKON_INSTALL_PLUGINDIR})
target_link_libraries(ImageFinder FalkonPrivate)

View File

@ -1,2 +0,0 @@
#! /bin/sh
$EXTRACT_TR_STRINGS `find . -name '*.cpp' -o -name '*.h' -o -name '*.ui'` -o $podir/falkon_imagefinder_qt.pot

Binary file not shown.

Before

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 869 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 846 B

View File

@ -1,84 +0,0 @@
/* ============================================================
* ImageFinder plugin for Falkon
* Copyright (C) 2016 Vladislav Tronko <innermous@gmail.com>
*
* 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/>.
* ============================================================ */
#include "imagefinder.h"
#include <QApplication>
#include <QSettings>
#include <QUrl>
#include "qzcommon.h"
ImageFinder::ImageFinder(const QString &settingsFile, QObject *parent)
: QObject(parent)
, m_settingsFile(settingsFile)
, m_searchEngine(SearchEngine::Google)
{
QSettings settings(m_settingsFile, QSettings::IniFormat);
settings.beginGroup(QSL("ImageFinder"));
m_searchEngine = static_cast<SearchEngine>(settings.value(QSL("SearchEngine")).toInt());
settings.endGroup();
}
ImageFinder::SearchEngine ImageFinder::searchEngine() const
{
return m_searchEngine;
}
void ImageFinder::setSearchEngine(ImageFinder::SearchEngine searchEngine)
{
m_searchEngine = searchEngine;
QSettings settings(m_settingsFile, QSettings::IniFormat);
settings.beginGroup(QSL("ImageFinder"));
settings.setValue(QSL("SearchEngine"), m_searchEngine);
settings.endGroup();
}
QString ImageFinder::searchEngineName(SearchEngine engine) const
{
if (engine == SearchEngine::None)
engine = m_searchEngine;
QStringList searchEngines;
searchEngines << QSL("Google") << QSL("Yandex") << QSL("TinEye");
return searchEngines.at(engine);
}
QUrl ImageFinder::getSearchQuery(const QUrl &imageUrl, SearchEngine engine)
{
if (engine == SearchEngine::None)
engine = m_searchEngine;
switch (engine)
{
case SearchEngine::Google:
return QUrl(QSL("https://www.google.com/searchbyimage?site=search&image_url=%1").arg(imageUrl.toString()));
break;
case SearchEngine::Yandex:
return QUrl(QSL("https://yandex.com/images/search?&img_url=%1&rpt=imageview").arg(imageUrl.toString()));
break;
case SearchEngine::TinEye:
return QUrl(QSL("http://www.tineye.com/search?url=%1").arg(imageUrl.toString()));
break;
default: return QUrl();
}
}

View File

@ -1,50 +0,0 @@
/* ============================================================
* ImageFinder plugin for Falkon
* Copyright (C) 2016 Vladislav Tronko <innermous@gmail.com>
*
* 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/>.
* ============================================================ */
#ifndef IMAGEFINDER_H
#define IMAGEFINDER_H
#include <QObject>
class WebView;
class ImageFinder : public QObject
{
Q_OBJECT
public:
enum SearchEngine {
None = -1,
Google = 0,
Yandex,
TinEye
};
explicit ImageFinder(const QString &settingsFile, QObject *parent = Q_NULLPTR);
SearchEngine searchEngine() const;
void setSearchEngine(SearchEngine searchEngine);
QString searchEngineName(SearchEngine engine = SearchEngine::None) const;
QUrl getSearchQuery(const QUrl &imageUrl, SearchEngine engine = SearchEngine::None);
private:
QString m_settingsFile;
SearchEngine m_searchEngine;
};
#endif // IMAGEFINDER_H

View File

@ -1,9 +0,0 @@
<RCC>
<qresource prefix="/imgfinder">
<file>metadata.desktop</file>
<file>data/icon.png</file>
<file>data/google.png</file>
<file>data/yandex.png</file>
<file>data/tineye.png</file>
</qresource>
</RCC>

View File

@ -1,100 +0,0 @@
/* ============================================================
* ImageFinder plugin for Falkon
* Copyright (C) 2016 Vladislav Tronko <innermous@gmail.com>
*
* 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/>.
* ============================================================ */
#include "imagefinderplugin.h"
#include "imagefindersettings.h"
#include "imagefinder.h"
#include "webview.h"
#include "webhittestresult.h"
#include "pluginproxy.h"
#include "mainapplication.h"
#include "enhancedmenu.h"
#include "../config.h"
#include "desktopfile.h"
#include <QMenu>
ImageFinderPlugin::ImageFinderPlugin()
: QObject()
, m_finder(Q_NULLPTR)
{
}
DesktopFile ImageFinderPlugin::metaData() const
{
return DesktopFile(QSL(":imgfinder/metadata.desktop"));
}
void ImageFinderPlugin::init(InitState state, const QString &settingsPath)
{
m_finder = new ImageFinder(settingsPath + QL1S("/extensions.ini"), this);
Q_UNUSED(state);
}
void ImageFinderPlugin::unload()
{
}
bool ImageFinderPlugin::testPlugin()
{
// Require the version that the plugin was built with
return (Qz::VERSION == QLatin1String(FALKON_VERSION));
}
void ImageFinderPlugin::showSettings(QWidget *parent)
{
if (!m_settings) {
m_settings = new ImageFinderSettings(m_finder, parent);
}
m_settings.data()->show();
m_settings.data()->raise();
}
void ImageFinderPlugin::populateWebViewMenu(QMenu *menu, WebView *view, const WebHitTestResult &r)
{
// Don't let local files fool you
if (r.imageUrl().scheme() != QL1S("http") && r.imageUrl().scheme() != QL1S("https")) return;
if (!r.imageUrl().isEmpty()) {
QString engineName = m_finder->searchEngineName();
Action* action = new Action(tr("Search image in ") + engineName);
action->setIcon(QIcon(QSL(":/imgfinder/data/%1.png").arg(engineName.toLower())));
action->setData(m_finder->getSearchQuery(r.imageUrl()));
connect(action, SIGNAL(triggered()), view, SLOT(openUrlInSelectedTab()));
connect(action, SIGNAL(ctrlTriggered()), view, SLOT(openUrlInBackgroundTab()));
menu->addAction(action);
Menu* swMenu = new Menu(tr("Search image with..."), menu);
swMenu->setCloseOnMiddleClick(true);
for (int i = 0; i < 3; ++i)
{
ImageFinder::SearchEngine e = static_cast<ImageFinder::SearchEngine>(i);
QString engineName = m_finder->searchEngineName(e);
Action* act = new Action(engineName);
act->setIcon(QIcon(QSL(":/imgfinder/data/%1.png").arg(engineName.toLower())));
act->setData(m_finder->getSearchQuery(r.imageUrl(), e));
connect(act, SIGNAL(triggered()), view, SLOT(openUrlInSelectedTab()));
connect(act, SIGNAL(ctrlTriggered()), view, SLOT(openUrlInBackgroundTab()));
swMenu->addAction(act);
}
menu->addMenu(swMenu);
}
}

View File

@ -1,49 +0,0 @@
/* ============================================================
* ImageFinder plugin for Falkon
* Copyright (C) 2016 Vladislav Tronko <innermous@gmail.com>
*
* 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/>.
* ============================================================ */
#ifndef IMAGEFINDERPLUGIN_H
#define IMAGEFINDERPLUGIN_H
#include "plugininterface.h"
class ImageFinder;
class ImageFinderSettings;
class ImageFinderPlugin : public QObject, public PluginInterface
{
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "Falkon.Browser.plugin.ImageFinderPlugin")
public:
explicit ImageFinderPlugin();
DesktopFile metaData() const override;
void init(InitState state, const QString &settingsPath) override;
void unload() override;
bool testPlugin() override;
void showSettings(QWidget *parent) override;
void populateWebViewMenu(QMenu *menu, WebView *view, const WebHitTestResult &r) override;
private:
ImageFinder *m_finder;
QPointer<ImageFinderSettings> m_settings;
};
#endif // IMAGEFINDERPLUGIN_H

View File

@ -1,47 +0,0 @@
/* ============================================================
* ImageFinder plugin for Falkon
* Copyright (C) 2016 Vladislav Tronko <innermous@gmail.com>
*
* 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/>.
* ============================================================ */
#include "imagefindersettings.h"
#include "ui_imagefindersettings.h"
#include "imagefinder.h"
ImageFinderSettings::ImageFinderSettings(ImageFinder* finder, QWidget* parent)
: QDialog(parent)
, ui(new Ui::ImageFinderSettings)
, m_finder(finder)
{
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ImageFinderSettings::accepted);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ImageFinderSettings::close);
ui->cboxEngines->setCurrentIndex(m_finder->searchEngine());
}
ImageFinderSettings::~ImageFinderSettings()
{
delete ui;
}
void ImageFinderSettings::accepted()
{
int index = ui->cboxEngines->currentIndex();
ImageFinder::SearchEngine engine = static_cast<ImageFinder::SearchEngine>(index);
m_finder->setSearchEngine(engine);
close();
}

View File

@ -1,47 +0,0 @@
/* ============================================================
* ImageFinder plugin for Falkon
* Copyright (C) 2016 Vladislav Tronko <innermous@gmail.com>
*
* 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/>.
* ============================================================ */
#ifndef IMAGEFINDERSETTINGS_H
#define IMAGEFINDERSETTINGS_H
#include <QDialog>
namespace Ui
{
class ImageFinderSettings;
}
class ImageFinder;
class ImageFinderSettings : public QDialog
{
Q_OBJECT
public:
explicit ImageFinderSettings(ImageFinder* finder, QWidget* parent = Q_NULLPTR);
~ImageFinderSettings();
private Q_SLOTS:
void accepted();
private:
Ui::ImageFinderSettings* ui;
ImageFinder* m_finder;
};
#endif // IMAGEFINDERSETTINGS_H

View File

@ -1,187 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImageFinderSettings</class>
<widget class="QWidget" name="ImageFinderSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>449</width>
<height>182</height>
</rect>
</property>
<property name="windowTitle">
<string>ImageFinder Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="imagefinder.qrc">:/imgfinder/data/icon.png</pixmap>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:xx-large; font-weight:600;&quot;&gt;ImageFinder&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;h3&gt;Search engine&lt;/h3&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cboxEngines">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>Google</string>
</property>
<property name="icon">
<iconset resource="imagefinder.qrc">
<normaloff>:/imgfinder/data/google.png</normaloff>:/imgfinder/data/google.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Yandex</string>
</property>
<property name="icon">
<iconset resource="imagefinder.qrc">
<normaloff>:/imgfinder/data/yandex.png</normaloff>:/imgfinder/data/yandex.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>TinEye</string>
</property>
<property name="icon">
<iconset resource="imagefinder.qrc">
<normaloff>:/imgfinder/data/tineye.png</normaloff>:/imgfinder/data/tineye.png</iconset>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="imagefinder.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -1,29 +0,0 @@
[Desktop Entry]
Name=ImageFinder
Name[ca]=ImageFinder
Name[ca@valencia]=ImageFinder
Name[en_GB]=ImageFinder
Name[fi]=ImageFinder
Name[nl]=ImageFinder
Name[pt]=Pesquisa de Imagens
Name[sv]=ImageFinder
Name[uk]=Пошук зображень
Name[x-test]=xxImageFinderxx
Comment=Provides context menu with reverse image search engine support
Comment[ca]=Proporciona un menú contextual amb suport pel motor de cerca inversa d'imatges
Comment[ca@valencia]=Proporciona un menú contextual amb suport pel motor de busca inversa d'imatges
Comment[en_GB]=Provides context menu with reverse image search engine support
Comment[fi]=Tarjoaa kontekstivalikon käänteisen kuvahaun tuen moottorille
Comment[nl]=Biedt contextmenu met ondersteuningsengine voor omgekeerd afbeeldingen zoeken
Comment[pt]=Oferece um menu de contexto com suporte para pesquisa inversa de imagens nos motores de busca
Comment[sv]=Tillhandahåller sammanhangsberoende meny med stöd för omvänd bildsöktjänst
Comment[uk]=Забезпечує роботу пунктів контекстного меню для зворотного пошуку зображень за допомогою служб пошуку
Comment[x-test]=xxProvides context menu with reverse image search engine supportxx
Icon=:imgfinder/data/icon.png
Type=Service
X-Falkon-Author=Vladislav Tronko
X-Falkon-Email=innermous@gmail.com
X-Falkon-Version=0.2.0
X-Falkon-Settings=true