-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from SatoshiShimada/dev
New layout
- Loading branch information
Showing
22 changed files
with
1,511 additions
and
720 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "aspect_ratio_pixmap_label.h" | ||
|
||
AspectRatioPixmapLabel::AspectRatioPixmapLabel(QWidget *parent) : QLabel(parent) | ||
{ | ||
constexpr int minimum_width = 740; | ||
constexpr int minimum_height = 540; | ||
this->setMinimumSize(minimum_width, minimum_height); | ||
setScaledContents(false); | ||
} | ||
|
||
void AspectRatioPixmapLabel::setPixmap(const QPixmap &p) | ||
{ | ||
pix = p; | ||
QLabel::setPixmap(scaledPixmap()); | ||
} | ||
|
||
int AspectRatioPixmapLabel::heightForWidth(int width) const | ||
{ | ||
if(this->height()) | ||
return pix.isNull(); | ||
else | ||
return (static_cast<qreal>(pix.height()) * width) / pix.width(); | ||
} | ||
|
||
QSize AspectRatioPixmapLabel::sizeHint() const | ||
{ | ||
int w = this->width(); | ||
return QSize(w, heightForWidth(w)); | ||
} | ||
|
||
QPixmap AspectRatioPixmapLabel::scaledPixmap() const | ||
{ | ||
return pix.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); | ||
} | ||
|
||
void AspectRatioPixmapLabel::resizeEvent(QResizeEvent *e) | ||
{ | ||
if(!pix.isNull()) | ||
QLabel::setPixmap(scaledPixmap()); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef ASPECT_RATIO_PIXMAP_LABEL_H | ||
#define ASPECT_RATIO_PIXMAP_LABEL_H | ||
|
||
#include <QtGui> | ||
#include <QtCore> | ||
#include <QApplication> | ||
#include <QLabel> | ||
#include <QPixmap> | ||
#include <QResizeEvent> | ||
|
||
class AspectRatioPixmapLabel : public QLabel | ||
{ | ||
Q_OBJECT | ||
public: | ||
AspectRatioPixmapLabel(QWidget *parent = 0); | ||
virtual int heightForWidth(int width) const; | ||
virtual QSize sizeHint() const; | ||
QPixmap scaledPixmap() const; | ||
public slots: | ||
void setPixmap(const QPixmap &); | ||
void resizeEvent(QResizeEvent *); | ||
private: | ||
QPixmap pix; | ||
}; | ||
|
||
#endif // ASPECT_RATIO_PIXMAP_LABEL_H | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.