diff -Nru albert-0.11.3/debian/changelog albert-0.12.0/debian/changelog --- albert-0.11.3/debian/changelog 2017-05-17 10:49:22.000000000 +0000 +++ albert-0.12.0/debian/changelog 2017-06-13 10:40:30.000000000 +0000 @@ -1,3 +1,9 @@ +albert (0.12.0-1~webupd8~zesty0) zesty; urgency=medium + + * New upstream release + + -- Alin Andrei Tue, 13 Jun 2017 13:40:29 +0200 + albert (0.11.3-1~webupd8~zesty0) zesty; urgency=medium * New upstream release diff -Nru albert-0.11.3/src/lib/albert/src/albert/albert.cpp albert-0.12.0/src/lib/albert/src/albert/albert.cpp --- albert-0.11.3/src/lib/albert/src/albert/albert.cpp 2017-05-28 21:57:15.000000000 +0000 +++ albert-0.12.0/src/lib/albert/src/albert/albert.cpp 2017-06-09 16:29:43.000000000 +0000 @@ -69,7 +69,7 @@ app = new QApplication(argc, argv); app->setApplicationName("albert"); app->setApplicationDisplayName("Albert"); - app->setApplicationVersion("v0.11.2"); + app->setApplicationVersion("v0.12.0"); app->setQuitOnLastWindowClosed(false); QString icon = XdgIconLookup::iconPath("albert"); if ( icon.isEmpty() ) icon = ":app_icon"; @@ -170,11 +170,11 @@ // Show newsbox in case of major version change if ( app->applicationVersion().section('.', 1, 1) != lastUsedVersion.section('.', 1, 1) ){ // Do whatever is neccessary on first run - QMessageBox(QMessageBox::Information, "First run", + QMessageBox(QMessageBox::Information, "Major version changed", QString("You are now using Albert %1. Albert is still in the alpha " "stage. This means things may change unexpectedly. Check " "the " - "news to see what changed.") + "news to read about the things that changed.") .arg(app->applicationVersion()) ).exec(); } @@ -300,10 +300,8 @@ bool alfred_note_shown = settings.value("alfred_note_shown", false).toBool(); if ( !alfred_note_shown ) { QMessageBox(QMessageBox::Information, "Note", - "This is free and open source software. We are " - "not affiliated with Alfred or Running with " - "Crayons Ltd. Please do not bother them with " - "support questions. They cannot help you.").exec(); + "This is standalone free and open source software. This project is not " + "related or affiliated to any other projects or corporations.").exec(); settings.setValue("alfred_note_shown", true); } diff -Nru albert-0.11.3/src/plugins/files/src/main.cpp albert-0.12.0/src/plugins/files/src/main.cpp --- albert-0.11.3/src/plugins/files/src/main.cpp 2017-05-28 21:57:15.000000000 +0000 +++ albert-0.12.0/src/plugins/files/src/main.cpp 2017-06-09 16:29:43.000000000 +0000 @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -30,6 +30,7 @@ #include #include #include +#include #include "configwidget.h" #include "file.h" #include "main.h" @@ -44,7 +45,7 @@ using namespace Core; -namespace { +namespace { const char* CFG_PATHS = "paths"; const char* CFG_FILTERS = "filters"; @@ -66,6 +67,17 @@ bool followSymlinks; }; +enum class PatternType { + Include, + Exclude +}; + +struct IgnoreEntry { + IgnoreEntry(QRegularExpression regex, PatternType type) : regex(regex), type(type) {} + QRegularExpression regex; + PatternType type; +}; + } @@ -120,10 +132,10 @@ indexIntervalTimer.start(); // Run the indexer thread + qDebug() << "Start indexing files."; futureWatcher.setFuture(QtConcurrent::run(this, &FilesPrivate::indexFiles, indexSettings)); // Notification - qDebug() << "Start indexing files."; emit q->statusInfo("Indexing files ..."); } @@ -175,7 +187,8 @@ filters |= QDir::Hidden; // Anonymous function that implemnents the index recursion - std::function indexRecursion = [&](const QFileInfo& fileInfo){ + std::function)> indexRecursion = + [&](const QFileInfo& fileInfo, const vector &ignoreEntries){ if (abort) return; @@ -199,51 +212,82 @@ // Remember that this dir has been indexed to avoid loops indexedDirs.insert(canonicalPath); - // Ignore ignorefile by default - std::vector ignores; - ignores.push_back(QRegExp(IGNOREFILE, Qt::CaseSensitive, QRegExp::Wildcard)); - // Read the ignore file, see http://doc.qt.io/qt-5/qregexp.html#wildcard-matching + vector localIgnoreEntries = ignoreEntries; QFile file(QDir(canonicalPath).filePath(IGNOREFILE)); - if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) { QTextStream in(&file); - while (!in.atEnd()) - ignores.push_back(QRegExp(in.readLine().trimmed(), Qt::CaseSensitive, QRegExp::Wildcard)); + while ( !in.atEnd() ) { + QString pattern = QDir::cleanPath(in.readLine()); + + if ( pattern.isEmpty() || pattern.startsWith("#") ) + continue; + + // Replace ** and * by their regex analogons + pattern.replace(QRegularExpression("(?>(); + for ( const QString &rootDir : indexSettings.rootDirs ) { + // Index rootdir, ignore ignorefile by default + vector ignores = {IgnoreEntry( + QRegularExpression(QString("%1$").arg(IGNOREFILE)), + PatternType::Exclude)}; + indexRecursion(QFileInfo(rootDir), ignores); + if ( abort ) + return vector>(); } // Serialize data QFile file(QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)). filePath(QString("%1.txt").arg(q->Core::Extension::id))); - if (file.open(QIODevice::WriteOnly|QIODevice::Text)) { + if ( file.open(QIODevice::WriteOnly|QIODevice::Text) ) { qDebug() << qPrintable(QString("Serializing files to '%1'").arg(file.fileName())); QTextStream out(&file); for (const shared_ptr &item : newIndex) diff -Nru albert-0.11.3/src/plugins/terminal/src/main.cpp albert-0.12.0/src/plugins/terminal/src/main.cpp --- albert-0.11.3/src/plugins/terminal/src/main.cpp 2017-05-28 21:57:15.000000000 +0000 +++ albert-0.12.0/src/plugins/terminal/src/main.cpp 2017-06-09 16:29:43.000000000 +0000 @@ -100,18 +100,18 @@ item->setSubtext(QString("Run '%1' in terminal").arg(commandline)); item->setCompletionString(query->searchTerm()); item->setIconPath(d->iconPath); + std::vector> actions; - actions.push_back(std::make_shared( - "Execute in the terminal", [=](){ + actions.push_back(std::make_shared("Execute in the shell", + [shell, commandline](){ + QProcess::startDetached(shell, {"-c", commandline}); + })); + actions.push_back(std::make_shared("Execute in the terminal", [=](){ QStringList tokens = Util::ShellLexer::split(terminalCommand); tokens << shell << "-ic" << QString("%1; exec %2").arg(commandline, shell); QProcess::startDetached(tokens.takeFirst(), tokens); })); - actions.push_back(std::make_shared( - "Execute in the shell without terminal", - [shell, commandline](){ - QProcess::startDetached(shell, {"-c", commandline}); - })); + item->setActions(std::move(actions)); // Add results to query diff -Nru albert-0.11.3/src/plugins/websearch/CMakeLists.txt albert-0.12.0/src/plugins/websearch/CMakeLists.txt --- albert-0.11.3/src/plugins/websearch/CMakeLists.txt 2017-05-28 21:57:15.000000000 +0000 +++ albert-0.12.0/src/plugins/websearch/CMakeLists.txt 2017-06-09 16:29:43.000000000 +0000 @@ -9,7 +9,8 @@ ) qt5_wrap_ui(UI - configwidget.ui + forms/configwidget.ui + forms/searchengineeditor.ui ) qt5_add_resources(QRC @@ -20,7 +21,7 @@ add_library(${PROJECT_NAME} SHARED ${SRC} ${UI} ${QRC}) # Set INCLUDE_DIRS and INTERFACE_INCLUDE_DIRS -target_include_directories(${PROJECT_NAME} PRIVATE src/) +target_include_directories(${PROJECT_NAME} PRIVATE src/ forms/) # Link target to libraries target_link_libraries(${PROJECT_NAME} diff -Nru albert-0.11.3/src/plugins/websearch/configwidget.ui albert-0.12.0/src/plugins/websearch/configwidget.ui --- albert-0.11.3/src/plugins/websearch/configwidget.ui 2017-05-28 21:57:15.000000000 +0000 +++ albert-0.12.0/src/plugins/websearch/configwidget.ui 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ - - - Websearch::ConfigWidget - - - - 0 - 0 - 293 - 161 - - - - - - - Qt::ScrollBarAsNeeded - - - Qt::ScrollBarAlwaysOff - - - QAbstractScrollArea::AdjustToContents - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - false - - - false - - - false - - - true - - - false - - - - - - - - - New - - - - - - - Set icon - - - - - - - Move up - - - - - - - Remove - - - - - - - Restore - - - - - - - Move down - - - - - - - Qt::Horizontal - - - - 0 - 0 - - - - - - - - - - - diff -Nru albert-0.11.3/src/plugins/websearch/forms/configwidget.ui albert-0.12.0/src/plugins/websearch/forms/configwidget.ui --- albert-0.11.3/src/plugins/websearch/forms/configwidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ albert-0.12.0/src/plugins/websearch/forms/configwidget.ui 2017-06-09 16:29:43.000000000 +0000 @@ -0,0 +1,90 @@ + + + Websearch::ConfigWidget + + + + + + Qt::ScrollBarAsNeeded + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContents + + + QAbstractItemView::InternalMove + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + false + + + false + + + true + + + false + + + + + + + + + Qt::Horizontal + + + + 0 + 0 + + + + + + + + + .. + + + + + + + + .. + + + + + + + Restore + + + + + + + + + + diff -Nru albert-0.11.3/src/plugins/websearch/forms/searchengineeditor.ui albert-0.12.0/src/plugins/websearch/forms/searchengineeditor.ui --- albert-0.11.3/src/plugins/websearch/forms/searchengineeditor.ui 1970-01-01 00:00:00.000000000 +0000 +++ albert-0.12.0/src/plugins/websearch/forms/searchengineeditor.ui 2017-06-09 16:29:43.000000000 +0000 @@ -0,0 +1,194 @@ + + + Websearch::SearchEngineEditor + + + + 0 + 0 + 420 + 320 + + + + Edit search engine + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Click to set an icon for the search engine. + + + + 96 + 96 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Name: + + + + + + + Name of the search engine. + + + Name of the search engine + + + + + + + Trigger: + + + + + + + The query prefix that triggers this engine. Note that it may make sense to append a space to the trigger prefix. + + + The query prefix that triggers this engine + + + + + + + URL: + + + + + + + The URL containing a %s that will be replaced by the query. + + + The URL containing a %s that will be replaced by the query + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + lineEdit_name + lineEdit_trigger + lineEdit_url + toolButton_icon + + + + + buttonBox + accepted() + Websearch::SearchEngineEditor + accept() + + + 275 + 310 + + + 157 + 274 + + + + + buttonBox + rejected() + Websearch::SearchEngineEditor + reject() + + + 343 + 310 + + + 286 + 274 + + + + + diff -Nru albert-0.11.3/src/plugins/websearch/src/configwidget.cpp albert-0.12.0/src/plugins/websearch/src/configwidget.cpp --- albert-0.11.3/src/plugins/websearch/src/configwidget.cpp 2017-05-28 21:57:15.000000000 +0000 +++ albert-0.12.0/src/plugins/websearch/src/configwidget.cpp 2017-06-09 16:29:43.000000000 +0000 @@ -19,6 +19,7 @@ #include #include "configwidget.h" #include "enginesmodel.h" +#include "searchengineeditor.h" #include "main.h" /** ***************************************************************************/ @@ -40,17 +41,11 @@ connect(ui.pushButton_remove, &QPushButton::clicked, this, &ConfigWidget::onButton_remove); - connect(ui.pushButton_setIcon, &QPushButton::clicked, - this, &ConfigWidget::onButton_setIcon); - - connect(ui.pushButton_moveUp, &QPushButton::clicked, - this, &ConfigWidget::onButton_moveUp); - - connect(ui.pushButton_moveDown, &QPushButton::clicked, - this, &ConfigWidget::onButton_moveDown); - connect(ui.pushButton_restoreDefaults, &QPushButton::clicked, this, &ConfigWidget::onButton_restoreDefaults); + + connect(ui.tableView_searches, &QTableView::activated, + this, &ConfigWidget::onActivated); } @@ -62,15 +57,50 @@ /** ***************************************************************************/ +void Websearch::ConfigWidget::onActivated(QModelIndex index) { + int row = index.row(); + SearchEngineEditor searchEngineEditor(extension_->engines()[static_cast(row)], this); + + if (searchEngineEditor.exec()){ + // Set the new engine + const SearchEngine & searchEngine = searchEngineEditor.searchEngine(); + enginesModel_->setData(enginesModel_->index(row, 0), searchEngine.name, Qt::DisplayRole); + enginesModel_->setData(enginesModel_->index(row, 0), searchEngine.iconPath, Qt::DecorationRole); + enginesModel_->setData(enginesModel_->index(row, 1), searchEngine.trigger, Qt::DisplayRole); + enginesModel_->setData(enginesModel_->index(row, 2), searchEngine.url, Qt::DisplayRole); + } + ui.tableView_searches->reset(); +} + + + +/** ***************************************************************************/ void Websearch::ConfigWidget::onButton_new() { - int row = (ui.tableView_searches->currentIndex().isValid()) - ? ui.tableView_searches->currentIndex().row() - : ui.tableView_searches->model()->rowCount(); - ui.tableView_searches->model()->insertRow(row); - - QModelIndex index = ui.tableView_searches->model()->index(row, 0, QModelIndex()); - ui.tableView_searches->setCurrentIndex(index); - ui.tableView_searches->edit(index); + + // Open search engine editor + SearchEngine searchEngine; + searchEngine.iconPath = ":default"; + SearchEngineEditor searchEngineEditor(searchEngine, this); + + if (searchEngineEditor.exec()){ + + // Insert new row in model + int row = (ui.tableView_searches->currentIndex().isValid()) + ? ui.tableView_searches->currentIndex().row() + : ui.tableView_searches->model()->rowCount(); + enginesModel_->insertRow(row); + + // Set the new engine + searchEngine = searchEngineEditor.searchEngine(); + enginesModel_->setData(enginesModel_->index(row, 0), searchEngine.name, Qt::DisplayRole); + enginesModel_->setData(enginesModel_->index(row, 0), searchEngine.iconPath, Qt::DecorationRole); + enginesModel_->setData(enginesModel_->index(row, 1), searchEngine.trigger, Qt::DisplayRole); + enginesModel_->setData(enginesModel_->index(row, 2), searchEngine.url, Qt::DisplayRole); + + // Set current + QModelIndex index = ui.tableView_searches->model()->index(row, 0, QModelIndex()); + ui.tableView_searches->setCurrentIndex(index); + } } @@ -92,46 +122,6 @@ } - -/** ***************************************************************************/ -void Websearch::ConfigWidget::onButton_moveUp() { - ui.tableView_searches->model()->moveRows( - QModelIndex(), ui.tableView_searches->currentIndex().row(), - 1, - QModelIndex(), ui.tableView_searches->currentIndex().row() - 1); -} - - - -/** ***************************************************************************/ -void Websearch::ConfigWidget::onButton_moveDown() { - ui.tableView_searches->model()->moveRows( - QModelIndex(), ui.tableView_searches->currentIndex().row(), - 1, - QModelIndex(), ui.tableView_searches->currentIndex().row() + 2); -} - - - -/** ***************************************************************************/ -void Websearch::ConfigWidget::onButton_setIcon() { - int row = ui.tableView_searches->currentIndex().row(); - if (row < 0 || ui.tableView_searches->model()->rowCount() <= row) - return; - - QString fileName = - QFileDialog::getOpenFileName( - this, - tr("Choose icon"), - QStandardPaths::writableLocation(QStandardPaths::HomeLocation), - tr("Images (*.png *.svg)")); - if(fileName.isEmpty()) - return; - - ui.tableView_searches->model()->setData(ui.tableView_searches->currentIndex(), fileName, Qt::DecorationRole); -} - - /** ***************************************************************************/ void Websearch::ConfigWidget::onButton_restoreDefaults() { diff -Nru albert-0.11.3/src/plugins/websearch/src/configwidget.h albert-0.12.0/src/plugins/websearch/src/configwidget.h --- albert-0.11.3/src/plugins/websearch/src/configwidget.h 2017-05-28 21:57:15.000000000 +0000 +++ albert-0.12.0/src/plugins/websearch/src/configwidget.h 2017-06-09 16:29:43.000000000 +0000 @@ -35,11 +35,9 @@ private: + void onActivated(QModelIndex index); void onButton_new(); void onButton_remove(); - void onButton_moveUp(); - void onButton_moveDown(); - void onButton_setIcon(); void onButton_restoreDefaults(); Extension *extension_; diff -Nru albert-0.11.3/src/plugins/websearch/src/enginesmodel.cpp albert-0.12.0/src/plugins/websearch/src/enginesmodel.cpp --- albert-0.11.3/src/plugins/websearch/src/enginesmodel.cpp 2017-05-28 21:57:15.000000000 +0000 +++ albert-0.12.0/src/plugins/websearch/src/enginesmodel.cpp 2017-06-09 16:29:43.000000000 +0000 @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include "enginesmodel.h" #include "main.h" @@ -147,7 +149,7 @@ return false; switch (role) { - case Qt::EditRole: { + case Qt::DisplayRole: { if ( !value.canConvert(QMetaType::QString) ) return false; QString s = value.toString(); @@ -177,23 +179,38 @@ } case Qt::DecorationRole: { QFileInfo fileInfo(value.toString()); - QString newFilePath; - uint i = 0; + + if ( !fileInfo.exists() ) + return false; // Remove icon from cache iconCache.erase(extension_->engines()[static_cast(index.row())].iconPath); - // Build the new generic path and copy the file into cache dir - do { - newFilePath = QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)) - .filePath(QString("%1-%2.%3") - .arg(extension_->engines()[static_cast(index.row())].name) - .arg(i++) - .arg(fileInfo.suffix())); - } while (!QFile::copy(fileInfo.filePath(), newFilePath)); + // Create extension dir if necessary + QDir dataDir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); + if ( !dataDir.exists(extension_->Core::Extension::id) ) { + if ( !dataDir.mkdir(extension_->Core::Extension::id) ) { + qWarning() << "Could not create extension data dir."; + return false; + } + } + + dataDir.cd(extension_->Core::Extension::id); + + // Build the new random path + QString newFilePath = dataDir.filePath(QString("%1.%2") + .arg(QUuid::createUuid().toString()) + .arg(fileInfo.suffix())); + + // Copy the file into data dir + if ( !QFile::copy(fileInfo.filePath(), newFilePath) ) { + qWarning() << "Could not copy icon to cache."; + return false; + } - // Set the copied file as icon + // Remove old icon and set the copied file as icon std::vector newEngines = extension_->engines(); + QFile::remove(newEngines[static_cast(index.row())].iconPath); newEngines[static_cast(index.row())].iconPath = newFilePath; extension_->setEngines(newEngines); @@ -213,9 +230,9 @@ /** ***************************************************************************/ Qt::ItemFlags Websearch::EnginesModel::flags(const QModelIndex &index) const { if (index.isValid()) - return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable; + return QAbstractTableModel::flags(index) | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled; else - return Qt::NoItemFlags; + return QAbstractTableModel::flags(index) | Qt::ItemIsDropEnabled; } @@ -257,7 +274,8 @@ /** ***************************************************************************/ -bool Websearch::EnginesModel::moveRows(const QModelIndex &src, int srcRow, int cnt, const QModelIndex &dst, int dstRow) { +bool Websearch::EnginesModel::moveRows(const QModelIndex &srcParent, int srcRow, int cnt, + const QModelIndex &dstParent, int dstRow) { if ( srcRow < 0 || cnt < 1 || dstRow < 0 || static_cast(extension_->engines().size()) < srcRow + cnt - 1 || static_cast(extension_->engines().size()) < dstRow || @@ -265,7 +283,7 @@ return false; std::vector newEngines = extension_->engines(); - beginMoveRows(src, srcRow, srcRow + cnt - 1, dst, dstRow); + beginMoveRows(srcParent, srcRow, srcRow + cnt - 1, dstParent, dstRow); newEngines.insert(newEngines.begin() + dstRow, extension_->engines().begin() + srcRow, extension_->engines().begin() + srcRow + cnt); @@ -289,3 +307,26 @@ endResetModel(); } + + +/** ***************************************************************************/ +Qt::DropActions Websearch::EnginesModel::supportedDropActions() const { + return Qt::MoveAction; +} + + + +/** ***************************************************************************/ +bool Websearch::EnginesModel::dropMimeData(const QMimeData *data, + Qt::DropAction /*action*/, + int dstRow, + int /*column*/, + const QModelIndex &/*parent*/) { + QByteArray encoded = data->data("application/x-qabstractitemmodeldatalist"); + QDataStream stream(&encoded, QIODevice::ReadOnly); + int srcRow = 0; + if (!stream.atEnd()) + stream >> srcRow; + moveRows(QModelIndex(), srcRow, 1, QModelIndex(), dstRow); + return false; +} diff -Nru albert-0.11.3/src/plugins/websearch/src/enginesmodel.h albert-0.12.0/src/plugins/websearch/src/enginesmodel.h --- albert-0.11.3/src/plugins/websearch/src/enginesmodel.h 2017-05-28 21:57:15.000000000 +0000 +++ albert-0.12.0/src/plugins/websearch/src/enginesmodel.h 2017-06-09 16:29:43.000000000 +0000 @@ -38,6 +38,8 @@ bool insertRows (int position, int rows, const QModelIndex & parent = QModelIndex()) override; bool removeRows (int position, int rows, const QModelIndex & parent = QModelIndex()) override; bool moveRows(const QModelIndex &sourceRow, int srcRow, int cnt, const QModelIndex & dst, int destinationChild) override; + Qt::DropActions supportedDropActions() const override; + bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; void restoreDefaults(); diff -Nru albert-0.11.3/src/plugins/websearch/src/main.cpp albert-0.12.0/src/plugins/websearch/src/main.cpp --- albert-0.11.3/src/plugins/websearch/src/main.cpp 2017-05-28 21:57:15.000000000 +0000 +++ albert-0.12.0/src/plugins/websearch/src/main.cpp 2017-06-09 16:29:43.000000000 +0000 @@ -252,7 +252,7 @@ {"Amazon", "ama ", ":amazon", "http://www.amazon.com/s/?field-keywords=%s"}, {"Ebay", "eb ", ":ebay", "http://www.ebay.com/sch/i.html?_nkw=%s"}, {"GitHub", "gh ", ":github", "https://github.com/search?utf8=✓&q=%s"}, - {"Wikipedia", "wp ", ":wikipedia", "https://wikipedia.org/w/index.php?search=%s"}, + {"Wikipedia", "wiki ",":wikipedia", "https://en.wikipedia.org/w/index.php?search=%s"}, {"Wolfram Alpha", "=", ":wolfram", "https://www.wolframalpha.com/input/?i=%s"} }; diff -Nru albert-0.11.3/src/plugins/websearch/src/searchengineeditor.cpp albert-0.12.0/src/plugins/websearch/src/searchengineeditor.cpp --- albert-0.11.3/src/plugins/websearch/src/searchengineeditor.cpp 1970-01-01 00:00:00.000000000 +0000 +++ albert-0.12.0/src/plugins/websearch/src/searchengineeditor.cpp 2017-06-09 16:29:43.000000000 +0000 @@ -0,0 +1,61 @@ +// albert - a simple application launcher for linux +// Copyright (C) 2014-2017 Manuel Schneider +// +// 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 . + +#include +#include +#include "searchengineeditor.h" + + + +/** ***************************************************************************/ +Websearch::SearchEngineEditor::SearchEngineEditor(const SearchEngine &searchEngine, QWidget *parent) + : QDialog(parent), searchEngine_(searchEngine) { + + ui.setupUi(this); + setWindowModality(Qt::WindowModal); + + ui.lineEdit_name->setText(searchEngine.name); + ui.lineEdit_trigger->setText(searchEngine.trigger); + ui.lineEdit_url->setText(searchEngine.url); + ui.toolButton_icon->setIcon(QIcon(searchEngine.iconPath)); + + connect(ui.lineEdit_name, &QLineEdit::textChanged, + [this](const QString & text){ searchEngine_.name = text; }); + + connect(ui.lineEdit_trigger, &QLineEdit::textChanged, + [this](const QString & text){ searchEngine_.trigger = text; }); + + connect(ui.lineEdit_url, &QLineEdit::textChanged, + [this](const QString & text){ searchEngine_.url = text; }); + + connect(ui.toolButton_icon, &QToolButton::clicked, + [this](){ + + QString fileName = + QFileDialog::getOpenFileName( + this, + tr("Choose icon"), + QStandardPaths::writableLocation(QStandardPaths::HomeLocation), + tr("Images (*.png *.svg)")); + + if(fileName.isEmpty()) + return; + + searchEngine_.iconPath = fileName; + ui.toolButton_icon->setIcon(QIcon(fileName)); + }); + +} diff -Nru albert-0.11.3/src/plugins/websearch/src/searchengineeditor.h albert-0.12.0/src/plugins/websearch/src/searchengineeditor.h --- albert-0.11.3/src/plugins/websearch/src/searchengineeditor.h 1970-01-01 00:00:00.000000000 +0000 +++ albert-0.12.0/src/plugins/websearch/src/searchengineeditor.h 2017-06-09 16:29:43.000000000 +0000 @@ -0,0 +1,40 @@ +// albert - a simple application launcher for linux +// Copyright (C) 2014-2017 Manuel Schneider +// +// 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 . + +#pragma once +#include +#include "ui_searchengineeditor.h" +#include "searchengine.h" + +namespace Websearch { + +class SearchEngineEditor : public QDialog +{ + Q_OBJECT + +public: + + explicit SearchEngineEditor(const SearchEngine &searchEngine, QWidget *parent = 0); + const SearchEngine &searchEngine() { return searchEngine_; } + +private: + + SearchEngine searchEngine_; + Ui::SearchEngineEditor ui; + +}; + +} diff -Nru albert-0.11.3/src/plugins/websearch/src/searchengine.h albert-0.12.0/src/plugins/websearch/src/searchengine.h --- albert-0.11.3/src/plugins/websearch/src/searchengine.h 2017-05-28 21:57:15.000000000 +0000 +++ albert-0.12.0/src/plugins/websearch/src/searchengine.h 2017-06-09 16:29:43.000000000 +0000 @@ -19,7 +19,8 @@ namespace Websearch { -struct SearchEngine { +class SearchEngine { +public: QString name; QString trigger; QString iconPath;