qBittorrent
PluginSelectDialog Class Referencefinal

#include <pluginselectdialog.h>

Inheritance diagram for PluginSelectDialog:
Collaboration diagram for PluginSelectDialog:

Public Member Functions

 PluginSelectDialog (SearchPluginManager *pluginManager, QWidget *parent=nullptr)
 
 ~PluginSelectDialog () override
 
QVector< QTreeWidgetItem * > findItemsWithUrl (const QString &url)
 
QTreeWidgetItem * findItemWithID (const QString &id)
 

Protected Member Functions

void dropEvent (QDropEvent *event) override
 
void dragEnterEvent (QDragEnterEvent *event) override
 

Private Slots

void on_actionUninstall_triggered ()
 
void on_updateButton_clicked ()
 
void on_installButton_clicked ()
 
void on_closeButton_clicked ()
 
void togglePluginState (QTreeWidgetItem *, int)
 
void setRowColor (int row, const QString &color)
 
void displayContextMenu (const QPoint &)
 
void enableSelection (bool enable)
 
void askForLocalPlugin ()
 
void askForPluginUrl ()
 
void iconDownloadFinished (const Net::DownloadResult &result)
 
void checkForUpdatesFinished (const QHash< QString, PluginVersion > &updateInfo)
 
void checkForUpdatesFailed (const QString &reason)
 
void pluginInstalled (const QString &name)
 
void pluginInstallationFailed (const QString &name, const QString &reason)
 
void pluginUpdated (const QString &name)
 
void pluginUpdateFailed (const QString &name, const QString &reason)
 

Private Member Functions

void loadSupportedSearchPlugins ()
 
void addNewPlugin (const QString &pluginName)
 
void startAsyncOp ()
 
void finishAsyncOp ()
 
void finishPluginUpdate ()
 

Private Attributes

Ui::PluginSelectDialog * m_ui
 
SettingValue< QSize > m_storeDialogSize
 
SearchPluginManagerm_pluginManager
 
QStringList m_updatedPlugins
 
int m_asyncOps = 0
 
int m_pendingUpdates = 0
 

Detailed Description

Definition at line 51 of file pluginselectdialog.h.

Constructor & Destructor Documentation

◆ PluginSelectDialog()

PluginSelectDialog::PluginSelectDialog ( SearchPluginManager pluginManager,
QWidget *  parent = nullptr 
)
explicit

Definition at line 63 of file pluginselectdialog.cpp.

64  : QDialog(parent)
65  , m_ui(new Ui::PluginSelectDialog)
67  , m_pluginManager(pluginManager)
68 {
69  m_ui->setupUi(this);
70  setAttribute(Qt::WA_DeleteOnClose);
71 
72  // This hack fixes reordering of first column with Qt5.
73  // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
74  QTableView unused;
75  unused.setVerticalHeader(m_ui->pluginsTree->header());
76  m_ui->pluginsTree->header()->setParent(m_ui->pluginsTree);
77  unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
78 
79  m_ui->pluginsTree->setRootIsDecorated(false);
80  m_ui->pluginsTree->hideColumn(PLUGIN_ID);
81  m_ui->pluginsTree->header()->setSortIndicator(0, Qt::AscendingOrder);
82 
83  m_ui->actionUninstall->setIcon(UIThemeManager::instance()->getIcon("list-remove"));
84 
85  connect(m_ui->actionEnable, &QAction::toggled, this, &PluginSelectDialog::enableSelection);
86  connect(m_ui->pluginsTree, &QTreeWidget::customContextMenuRequested, this, &PluginSelectDialog::displayContextMenu);
87  connect(m_ui->pluginsTree, &QTreeWidget::itemDoubleClicked, this, &PluginSelectDialog::togglePluginState);
88 
90 
97 
99  show();
100 }
Ui::PluginSelectDialog * m_ui
void togglePluginState(QTreeWidgetItem *, int)
void checkForUpdatesFinished(const QHash< QString, PluginVersion > &updateInfo)
void pluginInstallationFailed(const QString &name, const QString &reason)
void displayContextMenu(const QPoint &)
void pluginUpdateFailed(const QString &name, const QString &reason)
SearchPluginManager * m_pluginManager
SettingValue< QSize > m_storeDialogSize
void enableSelection(bool enable)
void pluginInstalled(const QString &name)
void checkForUpdatesFailed(const QString &reason)
void pluginUpdated(const QString &name)
void pluginUpdated(const QString &name)
void pluginInstallationFailed(const QString &name, const QString &reason)
void pluginInstalled(const QString &name)
void checkForUpdatesFinished(const QHash< QString, PluginVersion > &updateInfo)
void checkForUpdatesFailed(const QString &reason)
void pluginUpdateFailed(const QString &name, const QString &reason)
static UIThemeManager * instance()
void resize(QWidget *widget, const QSize &newSize={})
Definition: utils.cpp:54
@ PLUGIN_ID
#define SETTINGS_KEY(name)

References SearchPluginManager::checkForUpdatesFailed(), checkForUpdatesFailed(), SearchPluginManager::checkForUpdatesFinished(), checkForUpdatesFinished(), displayContextMenu(), enableSelection(), UIThemeManager::instance(), loadSupportedSearchPlugins(), m_pluginManager, m_storeDialogSize, m_ui, PLUGIN_ID, SearchPluginManager::pluginInstallationFailed(), pluginInstallationFailed(), SearchPluginManager::pluginInstalled(), pluginInstalled(), SearchPluginManager::pluginUpdated(), pluginUpdated(), SearchPluginManager::pluginUpdateFailed(), pluginUpdateFailed(), Utils::Gui::resize(), and togglePluginState().

Here is the call graph for this function:

◆ ~PluginSelectDialog()

PluginSelectDialog::~PluginSelectDialog ( )
override

Definition at line 102 of file pluginselectdialog.cpp.

103 {
104  m_storeDialogSize = size();
105  delete m_ui;
106 }

References m_storeDialogSize, and m_ui.

Member Function Documentation

◆ addNewPlugin()

void PluginSelectDialog::addNewPlugin ( const QString &  pluginName)
private

Definition at line 294 of file pluginselectdialog.cpp.

295 {
296  auto *item = new QTreeWidgetItem(m_ui->pluginsTree);
297  PluginInfo *plugin = m_pluginManager->pluginInfo(pluginName);
298  item->setText(PLUGIN_NAME, plugin->fullName);
299  item->setText(PLUGIN_URL, plugin->url);
300  item->setText(PLUGIN_ID, plugin->name);
301  if (plugin->enabled)
302  {
303  item->setText(PLUGIN_STATE, tr("Yes"));
304  setRowColor(m_ui->pluginsTree->indexOfTopLevelItem(item), "green");
305  }
306  else
307  {
308  item->setText(PLUGIN_STATE, tr("No"));
309  setRowColor(m_ui->pluginsTree->indexOfTopLevelItem(item), "red");
310  }
311  // Handle icon
312  if (QFile::exists(plugin->iconPath))
313  {
314  // Good, we already have the icon
315  item->setData(PLUGIN_NAME, Qt::DecorationRole, QIcon(plugin->iconPath));
316  }
317  else
318  {
319  // Icon is missing, we must download it
320  using namespace Net;
321  DownloadManager::instance()->download(
322  DownloadRequest(plugin->url + "/favicon.ico").saveToFile(true)
324  }
325  item->setText(PLUGIN_VERSION, plugin->version);
326 }
void setRowColor(int row, const QString &color)
void iconDownloadFinished(const Net::DownloadResult &result)
PluginInfo * pluginInfo(const QString &name) const
Definition: session.h:86
@ PLUGIN_URL
@ PLUGIN_VERSION
@ PLUGIN_NAME
@ PLUGIN_STATE
PluginVersion version

References PluginInfo::enabled, PluginInfo::fullName, iconDownloadFinished(), PluginInfo::iconPath, m_pluginManager, m_ui, PluginInfo::name, PLUGIN_ID, PLUGIN_NAME, PLUGIN_STATE, PLUGIN_URL, PLUGIN_VERSION, SearchPluginManager::pluginInfo(), Net::DownloadRequest::saveToFile(), setRowColor(), PluginInfo::url, and PluginInfo::version.

Referenced by loadSupportedSearchPlugins(), and pluginInstalled().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ askForLocalPlugin

void PluginSelectDialog::askForLocalPlugin ( )
privateslot

Definition at line 388 of file pluginselectdialog.cpp.

389 {
390  const QStringList pathsList = QFileDialog::getOpenFileNames(
391  nullptr, tr("Select search plugins"), QDir::homePath(),
392  tr("qBittorrent search plugin") + QLatin1String(" (*.py)")
393  );
394  for (const QString &path : pathsList)
395  {
396  startAsyncOp();
398  }
399 }
void installPlugin(const QString &source)

References SearchPluginManager::installPlugin(), m_pluginManager, and startAsyncOp().

Referenced by on_installButton_clicked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ askForPluginUrl

void PluginSelectDialog::askForPluginUrl ( )
privateslot

Definition at line 360 of file pluginselectdialog.cpp.

361 {
362  bool ok = false;
363  QString clipTxt = qApp->clipboard()->text();
364  QString defaultUrl = "http://";
365  if (Net::DownloadManager::hasSupportedScheme(clipTxt) && clipTxt.endsWith(".py"))
366  defaultUrl = clipTxt;
367  QString url = AutoExpandableDialog::getText(
368  this, tr("New search engine plugin URL"),
369  tr("URL:"), QLineEdit::Normal, defaultUrl, &ok
370  );
371 
372  while (ok && !url.isEmpty() && !url.endsWith(".py"))
373  {
374  QMessageBox::warning(this, tr("Invalid link"), tr("The link doesn't seem to point to a search engine plugin."));
376  this, tr("New search engine plugin URL"),
377  tr("URL:"), QLineEdit::Normal, url, &ok
378  );
379  }
380 
381  if (ok && !url.isEmpty())
382  {
383  startAsyncOp();
385  }
386 }
static QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode=QLineEdit::Normal, const QString &text={}, bool *ok=nullptr, bool excludeExtension=false, Qt::InputMethodHints inputMethodHints=Qt::ImhNone)
static bool hasSupportedScheme(const QString &url)

References AutoExpandableDialog::getText(), Net::DownloadManager::hasSupportedScheme(), SearchPluginManager::installPlugin(), m_pluginManager, and startAsyncOp().

Referenced by on_installButton_clicked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkForUpdatesFailed

void PluginSelectDialog::checkForUpdatesFailed ( const QString &  reason)
privateslot

Definition at line 468 of file pluginselectdialog.cpp.

469 {
470  finishAsyncOp();
471  QMessageBox::warning(this, tr("Search plugin update"), tr("Sorry, couldn't check for plugin updates. %1").arg(reason));
472 }

References finishAsyncOp().

Referenced by PluginSelectDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkForUpdatesFinished

void PluginSelectDialog::checkForUpdatesFinished ( const QHash< QString, PluginVersion > &  updateInfo)
privateslot

Definition at line 451 of file pluginselectdialog.cpp.

452 {
453  finishAsyncOp();
454  if (updateInfo.isEmpty())
455  {
456  QMessageBox::information(this, tr("Search plugin update"), tr("All your plugins are already up to date."));
457  return;
458  }
459 
460  for (auto i = updateInfo.cbegin(); i != updateInfo.cend(); ++i)
461  {
462  startAsyncOp();
464  m_pluginManager->updatePlugin(i.key());
465  }
466 }
void updatePlugin(const QString &name)

References finishAsyncOp(), m_pendingUpdates, m_pluginManager, startAsyncOp(), and SearchPluginManager::updatePlugin().

Referenced by PluginSelectDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ displayContextMenu

void PluginSelectDialog::displayContextMenu ( const QPoint &  )
privateslot

Definition at line 177 of file pluginselectdialog.cpp.

178 {
179  // Enable/disable pause/start action given the DL state
180  const QList<QTreeWidgetItem *> items = m_ui->pluginsTree->selectedItems();
181  if (items.isEmpty()) return;
182 
183  QMenu *myContextMenu = new QMenu(this);
184  myContextMenu->setAttribute(Qt::WA_DeleteOnClose);
185 
186  const QString firstID = items.first()->text(PLUGIN_ID);
187  m_ui->actionEnable->setChecked(m_pluginManager->pluginInfo(firstID)->enabled);
188  myContextMenu->addAction(m_ui->actionEnable);
189  myContextMenu->addSeparator();
190  myContextMenu->addAction(m_ui->actionUninstall);
191 
192  myContextMenu->popup(QCursor::pos());
193 }

References PluginInfo::enabled, m_pluginManager, m_ui, PLUGIN_ID, and SearchPluginManager::pluginInfo().

Referenced by PluginSelectDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dragEnterEvent()

void PluginSelectDialog::dragEnterEvent ( QDragEnterEvent *  event)
overrideprotected

Definition at line 142 of file pluginselectdialog.cpp.

143 {
144  for (const QString &mime : asConst(event->mimeData()->formats()))
145  {
146  qDebug("mimeData: %s", qUtf8Printable(mime));
147  }
148 
149  if (event->mimeData()->hasFormat(QLatin1String("text/plain")) || event->mimeData()->hasFormat(QLatin1String("text/uri-list")))
150  {
151  event->acceptProposedAction();
152  }
153 }
constexpr std::add_const_t< T > & asConst(T &t) noexcept
Definition: global.h:42

References asConst().

Here is the call graph for this function:

◆ dropEvent()

void PluginSelectDialog::dropEvent ( QDropEvent *  event)
overrideprotected

Definition at line 108 of file pluginselectdialog.cpp.

109 {
110  event->acceptProposedAction();
111 
112  QStringList files;
113  if (event->mimeData()->hasUrls())
114  {
115  for (const QUrl &url : asConst(event->mimeData()->urls()))
116  {
117  if (!url.isEmpty())
118  {
119  if (url.scheme().compare("file", Qt::CaseInsensitive) == 0)
120  files << url.toLocalFile();
121  else
122  files << url.toString();
123  }
124  }
125  }
126  else
127  {
128  files = event->mimeData()->text().split('\n');
129  }
130 
131  if (files.isEmpty()) return;
132 
133  for (const QString &file : asConst(files))
134  {
135  qDebug("dropped %s", qUtf8Printable(file));
136  startAsyncOp();
138  }
139 }
flag icons free of to any person obtaining a copy of this software and associated documentation files(the "Software")
file(GLOB QBT_TS_FILES "${qBittorrent_SOURCE_DIR}/src/lang/*.ts") set_source_files_properties($
Definition: CMakeLists.txt:5

References asConst(), file(), files(), SearchPluginManager::installPlugin(), m_pluginManager, and startAsyncOp().

Here is the call graph for this function:

◆ enableSelection

void PluginSelectDialog::enableSelection ( bool  enable)
privateslot

Definition at line 228 of file pluginselectdialog.cpp.

229 {
230  for (QTreeWidgetItem *item : asConst(m_ui->pluginsTree->selectedItems()))
231  {
232  int index = m_ui->pluginsTree->indexOfTopLevelItem(item);
233  Q_ASSERT(index != -1);
234  QString id = item->text(PLUGIN_ID);
235  m_pluginManager->enablePlugin(id, enable);
236  if (enable)
237  {
238  item->setText(PLUGIN_STATE, tr("Yes"));
239  setRowColor(index, "green");
240  }
241  else
242  {
243  item->setText(PLUGIN_STATE, tr("No"));
244  setRowColor(index, "red");
245  }
246  }
247 }
void enablePlugin(const QString &name, bool enabled=true)

References asConst(), SearchPluginManager::enablePlugin(), m_pluginManager, m_ui, PLUGIN_ID, PLUGIN_STATE, and setRowColor().

Referenced by PluginSelectDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findItemsWithUrl()

QVector< QTreeWidgetItem * > PluginSelectDialog::findItemsWithUrl ( const QString &  url)

Definition at line 259 of file pluginselectdialog.cpp.

260 {
261  QVector<QTreeWidgetItem*> res;
262  res.reserve(m_ui->pluginsTree->topLevelItemCount());
263 
264  for (int i = 0; i < m_ui->pluginsTree->topLevelItemCount(); ++i)
265  {
266  QTreeWidgetItem *item = m_ui->pluginsTree->topLevelItem(i);
267  if (url.startsWith(item->text(PLUGIN_URL), Qt::CaseInsensitive))
268  res << item;
269  }
270 
271  return res;
272 }

References m_ui, and PLUGIN_URL.

Referenced by iconDownloadFinished().

Here is the caller graph for this function:

◆ findItemWithID()

QTreeWidgetItem * PluginSelectDialog::findItemWithID ( const QString &  id)

Definition at line 274 of file pluginselectdialog.cpp.

275 {
276  for (int i = 0; i < m_ui->pluginsTree->topLevelItemCount(); ++i)
277  {
278  QTreeWidgetItem *item = m_ui->pluginsTree->topLevelItem(i);
279  if (id == item->text(PLUGIN_ID))
280  return item;
281  }
282 
283  return nullptr;
284 }

References m_ui, and PLUGIN_ID.

Referenced by pluginUpdated().

Here is the caller graph for this function:

◆ finishAsyncOp()

void PluginSelectDialog::finishAsyncOp ( )
private

Definition at line 335 of file pluginselectdialog.cpp.

336 {
337  --m_asyncOps;
338  if (m_asyncOps == 0)
339  setCursor(QCursor(Qt::ArrowCursor));
340 }

References m_asyncOps.

Referenced by checkForUpdatesFailed(), checkForUpdatesFinished(), pluginInstallationFailed(), pluginInstalled(), pluginUpdated(), and pluginUpdateFailed().

Here is the caller graph for this function:

◆ finishPluginUpdate()

void PluginSelectDialog::finishPluginUpdate ( )
private

Definition at line 342 of file pluginselectdialog.cpp.

343 {
345  if ((m_pendingUpdates == 0) && !m_updatedPlugins.isEmpty())
346  {
347  m_updatedPlugins.sort(Qt::CaseInsensitive);
348  QMessageBox::information(this, tr("Search plugin update"), tr("Plugins installed or updated: %1").arg(m_updatedPlugins.join(", ")));
349  m_updatedPlugins.clear();
350  }
351 }
QStringList m_updatedPlugins

References m_pendingUpdates, and m_updatedPlugins.

Referenced by pluginInstallationFailed(), pluginInstalled(), pluginUpdated(), and pluginUpdateFailed().

Here is the caller graph for this function:

◆ iconDownloadFinished

void PluginSelectDialog::iconDownloadFinished ( const Net::DownloadResult result)
privateslot

Definition at line 401 of file pluginselectdialog.cpp.

402 {
403  if (result.status != Net::DownloadStatus::Success)
404  {
405  qDebug("Could not download favicon: %s, reason: %s", qUtf8Printable(result.url), qUtf8Printable(result.errorString));
406  return;
407  }
408 
409  const QString filePath = Utils::Fs::toUniformPath(result.filePath);
410 
411  // Icon downloaded
412  QIcon icon(filePath);
413  // Detect a non-decodable icon
414  QList<QSize> sizes = icon.availableSizes();
415  bool invalid = (sizes.isEmpty() || icon.pixmap(sizes.first()).isNull());
416  if (!invalid)
417  {
418  for (QTreeWidgetItem *item : asConst(findItemsWithUrl(result.url)))
419  {
420  QString id = item->text(PLUGIN_ID);
421  PluginInfo *plugin = m_pluginManager->pluginInfo(id);
422  if (!plugin) continue;
423 
424  QString iconPath = QString("%1/%2.%3")
426  , id
427  , result.url.endsWith(".ico", Qt::CaseInsensitive) ? "ico" : "png");
428  if (QFile::copy(filePath, iconPath))
429  {
430  // This 2nd check is necessary. Some favicons (eg from piratebay)
431  // decode fine without an ext, but fail to do so when appending the ext
432  // from the url. Probably a Qt bug.
433  QIcon iconWithExt(iconPath);
434  QList<QSize> sizesExt = iconWithExt.availableSizes();
435  bool invalidExt = (sizesExt.isEmpty() || iconWithExt.pixmap(sizesExt.first()).isNull());
436  if (invalidExt)
437  {
438  Utils::Fs::forceRemove(iconPath);
439  continue;
440  }
441 
442  item->setData(PLUGIN_NAME, Qt::DecorationRole, iconWithExt);
444  }
445  }
446  }
447  // Delete tmp file
448  Utils::Fs::forceRemove(filePath);
449 }
QVector< QTreeWidgetItem * > findItemsWithUrl(const QString &url)
static void updateIconPath(PluginInfo *const plugin)
static QString pluginsLocation()
flag icons free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to copy
QString toUniformPath(const QString &path)
Definition: fs.cpp:69
bool forceRemove(const QString &filePath)
Definition: fs.cpp:173
DownloadStatus status

References asConst(), copy, Net::DownloadResult::errorString, Net::DownloadResult::filePath, findItemsWithUrl(), Utils::Fs::forceRemove(), m_pluginManager, PLUGIN_ID, PLUGIN_NAME, SearchPluginManager::pluginInfo(), SearchPluginManager::pluginsLocation(), Net::DownloadResult::status, Net::Success, Utils::Fs::toUniformPath(), SearchPluginManager::updateIconPath(), and Net::DownloadResult::url.

Referenced by addNewPlugin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadSupportedSearchPlugins()

void PluginSelectDialog::loadSupportedSearchPlugins ( )
private

Definition at line 286 of file pluginselectdialog.cpp.

287 {
288  // Some clean up first
289  m_ui->pluginsTree->clear();
290  for (const QString &name : asConst(m_pluginManager->allPlugins()))
291  addNewPlugin(name);
292 }
void addNewPlugin(const QString &pluginName)
QStringList allPlugins() const

References addNewPlugin(), SearchPluginManager::allPlugins(), asConst(), m_pluginManager, and m_ui.

Referenced by PluginSelectDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_actionUninstall_triggered

void PluginSelectDialog::on_actionUninstall_triggered ( )
privateslot

Definition at line 200 of file pluginselectdialog.cpp.

201 {
202  bool error = false;
203  for (QTreeWidgetItem *item : asConst(m_ui->pluginsTree->selectedItems()))
204  {
205  int index = m_ui->pluginsTree->indexOfTopLevelItem(item);
206  Q_ASSERT(index != -1);
207  QString id = item->text(PLUGIN_ID);
209  {
210  delete item;
211  }
212  else
213  {
214  error = true;
215  // Disable it instead
216  m_pluginManager->enablePlugin(id, false);
217  item->setText(PLUGIN_STATE, tr("No"));
218  setRowColor(index, "red");
219  }
220  }
221 
222  if (error)
223  QMessageBox::warning(this, tr("Uninstall warning"), tr("Some plugins could not be uninstalled because they are included in qBittorrent. Only the ones you added yourself can be uninstalled.\nThose plugins were disabled."));
224  else
225  QMessageBox::information(this, tr("Uninstall success"), tr("All selected plugins were uninstalled successfully"));
226 }
bool uninstallPlugin(const QString &name)

References asConst(), SearchPluginManager::enablePlugin(), m_pluginManager, m_ui, PLUGIN_ID, PLUGIN_STATE, setRowColor(), and SearchPluginManager::uninstallPlugin().

Here is the call graph for this function:

◆ on_closeButton_clicked

void PluginSelectDialog::on_closeButton_clicked ( )
privateslot

Definition at line 195 of file pluginselectdialog.cpp.

196 {
197  close();
198 }

◆ on_installButton_clicked

void PluginSelectDialog::on_installButton_clicked ( )
privateslot

◆ on_updateButton_clicked

void PluginSelectDialog::on_updateButton_clicked ( )
privateslot

Definition at line 155 of file pluginselectdialog.cpp.

156 {
157  startAsyncOp();
159 }

References SearchPluginManager::checkForUpdates(), m_pluginManager, and startAsyncOp().

Here is the call graph for this function:

◆ pluginInstallationFailed

void PluginSelectDialog::pluginInstallationFailed ( const QString &  name,
const QString &  reason 
)
privateslot

Definition at line 482 of file pluginselectdialog.cpp.

483 {
484  finishAsyncOp();
485  QMessageBox::information(this, tr("Search plugin install")
486  , tr("Couldn't install \"%1\" search engine plugin. %2").arg(name, reason));
488 }

References finishAsyncOp(), and finishPluginUpdate().

Referenced by PluginSelectDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pluginInstalled

void PluginSelectDialog::pluginInstalled ( const QString &  name)
privateslot

Definition at line 474 of file pluginselectdialog.cpp.

475 {
476  addNewPlugin(name);
477  finishAsyncOp();
478  m_updatedPlugins.append(name);
480 }

References addNewPlugin(), finishAsyncOp(), finishPluginUpdate(), and m_updatedPlugins.

Referenced by PluginSelectDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pluginUpdated

void PluginSelectDialog::pluginUpdated ( const QString &  name)
privateslot

Definition at line 490 of file pluginselectdialog.cpp.

491 {
492  finishAsyncOp();
494  QTreeWidgetItem *item = findItemWithID(name);
495  item->setText(PLUGIN_VERSION, version);
496  m_updatedPlugins.append(name);
498 }
QTreeWidgetItem * findItemWithID(const QString &id)

References findItemWithID(), finishAsyncOp(), finishPluginUpdate(), m_pluginManager, m_updatedPlugins, PLUGIN_VERSION, SearchPluginManager::pluginInfo(), and PluginInfo::version.

Referenced by PluginSelectDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pluginUpdateFailed

void PluginSelectDialog::pluginUpdateFailed ( const QString &  name,
const QString &  reason 
)
privateslot

Definition at line 500 of file pluginselectdialog.cpp.

501 {
502  finishAsyncOp();
503  QMessageBox::information(this, tr("Search plugin update")
504  , tr("Couldn't update \"%1\" search engine plugin. %2").arg(name, reason));
506 }

References finishAsyncOp(), and finishPluginUpdate().

Referenced by PluginSelectDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRowColor

void PluginSelectDialog::setRowColor ( int  row,
const QString &  color 
)
privateslot

Definition at line 250 of file pluginselectdialog.cpp.

251 {
252  QTreeWidgetItem *item = m_ui->pluginsTree->topLevelItem(row);
253  for (int i = 0; i < m_ui->pluginsTree->columnCount(); ++i)
254  {
255  item->setData(i, Qt::ForegroundRole, QColor(color));
256  }
257 }

References m_ui.

Referenced by addNewPlugin(), enableSelection(), on_actionUninstall_triggered(), and togglePluginState().

Here is the caller graph for this function:

◆ startAsyncOp()

void PluginSelectDialog::startAsyncOp ( )
private

Definition at line 328 of file pluginselectdialog.cpp.

329 {
330  ++m_asyncOps;
331  if (m_asyncOps == 1)
332  setCursor(QCursor(Qt::WaitCursor));
333 }

References m_asyncOps.

Referenced by askForLocalPlugin(), askForPluginUrl(), checkForUpdatesFinished(), dropEvent(), and on_updateButton_clicked().

Here is the caller graph for this function:

◆ togglePluginState

void PluginSelectDialog::togglePluginState ( QTreeWidgetItem *  item,
int   
)
privateslot

Definition at line 161 of file pluginselectdialog.cpp.

162 {
163  PluginInfo *plugin = m_pluginManager->pluginInfo(item->text(PLUGIN_ID));
164  m_pluginManager->enablePlugin(plugin->name, !plugin->enabled);
165  if (plugin->enabled)
166  {
167  item->setText(PLUGIN_STATE, tr("Yes"));
168  setRowColor(m_ui->pluginsTree->indexOfTopLevelItem(item), "green");
169  }
170  else
171  {
172  item->setText(PLUGIN_STATE, tr("No"));
173  setRowColor(m_ui->pluginsTree->indexOfTopLevelItem(item), "red");
174  }
175 }

References PluginInfo::enabled, SearchPluginManager::enablePlugin(), m_pluginManager, m_ui, PluginInfo::name, PLUGIN_ID, PLUGIN_STATE, SearchPluginManager::pluginInfo(), and setRowColor().

Referenced by PluginSelectDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_asyncOps

int PluginSelectDialog::m_asyncOps = 0
private

Definition at line 98 of file pluginselectdialog.h.

Referenced by finishAsyncOp(), and startAsyncOp().

◆ m_pendingUpdates

int PluginSelectDialog::m_pendingUpdates = 0
private

Definition at line 99 of file pluginselectdialog.h.

Referenced by checkForUpdatesFinished(), and finishPluginUpdate().

◆ m_pluginManager

◆ m_storeDialogSize

SettingValue<QSize> PluginSelectDialog::m_storeDialogSize
private

Definition at line 95 of file pluginselectdialog.h.

Referenced by PluginSelectDialog(), and ~PluginSelectDialog().

◆ m_ui

◆ m_updatedPlugins

QStringList PluginSelectDialog::m_updatedPlugins
private

Definition at line 97 of file pluginselectdialog.h.

Referenced by finishPluginUpdate(), pluginInstalled(), and pluginUpdated().


The documentation for this class was generated from the following files: