PageRenderTime 51ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/llibs/plugins/panache/desktop/Search/Search.cpp

https://gitlab.com/logram/corrections_magellan
C++ | 81 lines | 42 code | 12 blank | 27 comment | 0 complexity | 5a3ef976405fb40128709448bb645fa5 MD5 | raw file
  1. /*
  2. * Search.cpp
  3. * This file is part of Logram
  4. *
  5. * Copyright (C) 2008 - Florent Revest <florent.revest666@gmail.com>
  6. *
  7. * Logram is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Logram is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with Logram; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor,
  20. * Boston, MA 02110-1301 USA
  21. */
  22. #include "Search.h"
  23. void SearchPlugin::load()
  24. {
  25. }
  26. void SearchPlugin::linkParent(QWidget *parent)
  27. {
  28. mparent = parent;
  29. //Initialisation des widgets
  30. espace = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  31. espace2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  32. google = new QPushButton();
  33. google->setIcon(QIcon(":/logo.png"));
  34. google->setIconSize(QSize(276, 110));
  35. google->setFlat(true);
  36. barreDeRecherche = new QLineEdit();
  37. rechercher = new QPushButton(tr("Rechercher"));
  38. //Initialisation des layouts
  39. layout = new QGridLayout();
  40. layout->addWidget(google, 0, 0, 1, 3);
  41. layout->addWidget(barreDeRecherche, 1, 0, 1, 3);
  42. layout->addItem(espace, 2, 0, 1, 1);
  43. layout->addWidget(rechercher, 2, 1, 1, 1);
  44. layout->addItem(espace2, 2, 2, 1, 1);
  45. //Initialisation de la languette
  46. mparent->resize(390, 230);
  47. mparent->setLayout(layout);
  48. //Connexion des signaux à leurs slots
  49. connect(google, SIGNAL(clicked()), this, SLOT(ouvrirGoogle()));
  50. connect(rechercher, SIGNAL(clicked()), this, SLOT(chercher()));
  51. }
  52. void SearchPlugin::unlinkParent()
  53. {
  54. //Rien à faire
  55. return;
  56. }
  57. void SearchPlugin::chercher()
  58. {
  59. QString motARechercher = barreDeRecherche->text();
  60. motARechercher.replace(QString(" "), QString("+")); //remplace les espaces par des +
  61. QString adresse = "http://www.google.fr/search?hl=fr&q=" + motARechercher + "&btnG=Recherche+Google&meta=&aq=f&oq=";
  62. QDesktopServices::openUrl(QUrl(adresse));
  63. }
  64. void SearchPlugin::ouvrirGoogle()
  65. {
  66. QDesktopServices::openUrl(QUrl("http://www.google.fr"));
  67. }
  68. //export du plugin.
  69. Q_EXPORT_PLUGIN2(dummy, SearchPlugin)