Mercurial > minori
comparison src/gui/widgets/poster.cc @ 348:6b0768158dcd
text: redesign almost every widget
i.e. Paragraph is now a QLabel, etc etc, some things will probably
break, idc
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Tue, 25 Jun 2024 11:19:54 -0400 |
| parents | b1f625b0227c |
| children | ea3a74ed2ef9 |
comparison
equal
deleted
inserted
replaced
| 347:a0aa8c8c4307 | 348:6b0768158dcd |
|---|---|
| 14 #include <QMessageBox> | 14 #include <QMessageBox> |
| 15 #include <QPixmap> | 15 #include <QPixmap> |
| 16 #include <QThread> | 16 #include <QThread> |
| 17 #include <QUrl> | 17 #include <QUrl> |
| 18 | 18 |
| 19 #include <iostream> | |
| 20 | |
| 19 Poster::Poster(QWidget* parent) : QFrame(parent) { | 21 Poster::Poster(QWidget* parent) : QFrame(parent) { |
| 20 QHBoxLayout* layout = new QHBoxLayout(this); | 22 QHBoxLayout* layout = new QHBoxLayout(this); |
| 21 layout->setContentsMargins(1, 1, 1, 1); | 23 layout->setContentsMargins(1, 1, 1, 1); |
| 22 | 24 |
| 23 setCursor(Qt::PointingHandCursor); | 25 setCursor(Qt::PointingHandCursor); |
| 24 setFixedSize(150, 225); | 26 setFixedSize(150, 225); // FIXME need to kill this |
| 25 setFrameShape(QFrame::Box); | 27 setFrameShape(QFrame::Box); |
| 26 setFrameShadow(QFrame::Plain); | 28 setFrameShadow(QFrame::Plain); |
| 27 | 29 |
| 28 label_.setAlignment(Qt::AlignCenter); | 30 label_.setAlignment(Qt::AlignCenter); |
| 29 layout->addWidget(&label_); | 31 layout->addWidget(&label_); |
| 99 if (pixmap.isNull()) | 101 if (pixmap.isNull()) |
| 100 return; | 102 return; |
| 101 label_.setPixmap(pixmap.scaled(label_.size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation)); | 103 label_.setPixmap(pixmap.scaled(label_.size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation)); |
| 102 } | 104 } |
| 103 | 105 |
| 106 bool Poster::hasHeightForWidth(void) const { | |
| 107 return true; | |
| 108 } | |
| 109 | |
| 110 int Poster::heightForWidth(int w) const { | |
| 111 return static_cast<int>(static_cast<double>(w) * 225 / 150); | |
| 112 } | |
| 113 | |
| 104 void Poster::resizeEvent(QResizeEvent*) { | 114 void Poster::resizeEvent(QResizeEvent*) { |
| 105 RenderToLabel(); | 115 RenderToLabel(); |
| 106 } | 116 } |
| 117 | |
| 118 QSize Poster::minimumSizeHint() const { | |
| 119 return QSize(120, heightForWidth(120)); | |
| 120 } | |
| 121 | |
| 122 QSize Poster::sizeHint() const { | |
| 123 return QSize(150, heightForWidth(150)); | |
| 124 } |
