/YACReaderLibrary/comic_vine/scraper_scroll_label.cpp

https://github.com/YACReader/yacreader · C++ · 52 lines · 44 code · 8 blank · 0 comment · 0 complexity · 3e292f37a5f3c4808a0744a34e42cd1f MD5 · raw file

  1. #include "scraper_scroll_label.h"
  2. #include <QLabel>
  3. #include <QDesktopServices>
  4. #include <QUrl>
  5. ScraperScrollLabel::ScraperScrollLabel(QWidget *parent)
  6. : QScrollArea(parent)
  7. {
  8. textLabel = new QLabel(this);
  9. textLabel->setStyleSheet("QLabel {background-color: #2B2B2B; color:white; font-size:12px; font-family:Arial; }");
  10. textLabel->setWordWrap(true);
  11. textLabel->setMinimumSize(168, 12);
  12. setWidget(textLabel);
  13. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  14. setStyleSheet(
  15. "QScrollArea {background-color:#2B2B2B; border:none;}"
  16. "QScrollBar:vertical { border: none; background: #2B2B2B; width: 3px; margin: 0; }"
  17. "QScrollBar:horizontal { border: none; background: #2B2B2B; height: 3px; margin: 0; }"
  18. "QScrollBar::handle:vertical { background: #DDDDDD; width: 7px; min-height: 20px; }"
  19. "QScrollBar::handle:horizontal { background: #DDDDDD; width: 7px; min-height: 20px; }"
  20. "QScrollBar::add-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
  21. "QScrollBar::sub-line:vertical { border: none; background: #404040; height: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
  22. "QScrollBar::add-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 0 3px 0;}"
  23. "QScrollBar::sub-line:horizontal { border: none; background: #404040; width: 10px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 0 3px 0;}"
  24. "QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
  25. "QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
  26. "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical, QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {background: none; }");
  27. connect(textLabel, SIGNAL(linkActivated(QString)), this, SLOT(openLink(QString)));
  28. }
  29. void ScraperScrollLabel::setAltText(const QString &text)
  30. {
  31. textLabel->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
  32. textLabel->setText(text);
  33. textLabel->adjustSize();
  34. }
  35. void ScraperScrollLabel::setText(const QString &text)
  36. {
  37. textLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
  38. textLabel->setText(text);
  39. textLabel->adjustSize();
  40. }
  41. void ScraperScrollLabel::openLink(const QString &link)
  42. {
  43. QDesktopServices::openUrl(QUrl("http://www.comicvine.com" + link));
  44. }