- Remove "_" prefix on members
- Remove aspect check getBlurredBackground as it is not needed
This commit is contained in:
@@ -12,8 +12,8 @@
|
|||||||
#include <algorithm> // std::shuffle
|
#include <algorithm> // std::shuffle
|
||||||
#include <random> // std::default_random_engine
|
#include <random> // std::default_random_engine
|
||||||
|
|
||||||
ImageSelector::ImageSelector(std::unique_ptr<PathTraverser>& pathTraverser, char aspect):
|
ImageSelector::ImageSelector(std::unique_ptr<PathTraverser>& pathTraverser, char aspectIn):
|
||||||
pathTraverser(pathTraverser), _aspect(aspect)
|
pathTraverser(pathTraverser), aspect(aspectIn)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ bool ImageSelector::imageValidForAspect(const std::string &fileName)
|
|||||||
std::swap(imageWidth,imageHeight);
|
std::swap(imageWidth,imageHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(_aspect)
|
switch(aspect)
|
||||||
{
|
{
|
||||||
case 'a':
|
case 'a':
|
||||||
// allow all
|
// allow all
|
||||||
@@ -118,7 +118,7 @@ std::string RandomImageSelector::getNextImage()
|
|||||||
|
|
||||||
unsigned int RandomImageSelector::selectRandom(const QStringList& images) const
|
unsigned int RandomImageSelector::selectRandom(const QStringList& images) const
|
||||||
{
|
{
|
||||||
if(_debugMode)
|
if(debugMode)
|
||||||
{
|
{
|
||||||
std::cout << "images: " << images.size() << std::endl;
|
std::cout << "images: " << images.size() << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,17 +11,17 @@ class PathTraverser;
|
|||||||
class ImageSelector
|
class ImageSelector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ImageSelector(std::unique_ptr<PathTraverser>& pathTraverser, char aspect);
|
ImageSelector(std::unique_ptr<PathTraverser>& pathTraverser, char aspectIn);
|
||||||
virtual ~ImageSelector();
|
virtual ~ImageSelector();
|
||||||
virtual std::string getNextImage() = 0;
|
virtual std::string getNextImage() = 0;
|
||||||
void setDebugMode(bool debugMode) { _debugMode = debugMode;}
|
void setDebugMode(bool debugModeIn) { debugMode = debugModeIn;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int getImageRotation(const std::string &fileName);
|
int getImageRotation(const std::string &fileName);
|
||||||
bool imageValidForAspect(const std::string &fileName);
|
bool imageValidForAspect(const std::string &fileName);
|
||||||
std::unique_ptr<PathTraverser>& pathTraverser;
|
std::unique_ptr<PathTraverser>& pathTraverser;
|
||||||
char _aspect;
|
char aspect;
|
||||||
bool _debugMode = false;
|
bool debugMode = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RandomImageSelector : public ImageSelector
|
class RandomImageSelector : public ImageSelector
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ void MainWindow::updateImage(bool immediately)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPixmap p( currentImage.c_str() );
|
QPixmap p( currentImage.c_str() );
|
||||||
if(_debugMode)
|
if(debugMode)
|
||||||
{
|
{
|
||||||
std::cout << "size:" << p.width() << "x" << p.height() << std::endl;
|
std::cout << "size:" << p.width() << "x" << p.height() << std::endl;
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ void MainWindow::updateImage(bool immediately)
|
|||||||
drawText(background, overlay->getMarginTopRight(), overlay->getFontsizeTopRight(), overlay->getRenderedTopRight(currentImage).c_str(), Qt::AlignTop|Qt::AlignRight);
|
drawText(background, overlay->getMarginTopRight(), overlay->getFontsizeTopRight(), overlay->getRenderedTopRight(currentImage).c_str(), Qt::AlignTop|Qt::AlignRight);
|
||||||
drawText(background, overlay->getMarginBottomLeft(), overlay->getFontsizeBottomLeft(), overlay->getRenderedBottomLeft(currentImage).c_str(), Qt::AlignBottom|Qt::AlignLeft);
|
drawText(background, overlay->getMarginBottomLeft(), overlay->getFontsizeBottomLeft(), overlay->getRenderedBottomLeft(currentImage).c_str(), Qt::AlignBottom|Qt::AlignLeft);
|
||||||
drawText(background, overlay->getMarginBottomRight(), overlay->getFontsizeBottomRight(), overlay->getRenderedBottomRight(currentImage).c_str(), Qt::AlignBottom|Qt::AlignRight);
|
drawText(background, overlay->getMarginBottomRight(), overlay->getFontsizeBottomRight(), overlay->getRenderedBottomRight(currentImage).c_str(), Qt::AlignBottom|Qt::AlignRight);
|
||||||
if (_debugMode)
|
if (debugMode)
|
||||||
{
|
{
|
||||||
// draw a thumbnail version of the source image in the bottom left, to check for cropping issues
|
// draw a thumbnail version of the source image in the bottom left, to check for cropping issues
|
||||||
QPainter pt(&background);
|
QPainter pt(&background);
|
||||||
@@ -184,14 +184,14 @@ void MainWindow::setOverlay(Overlay* o)
|
|||||||
overlay = o;
|
overlay = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setAspect(char aspect)
|
void MainWindow::setAspect(char aspectIn)
|
||||||
{
|
{
|
||||||
_aspect = aspect;
|
aspect = aspectIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap MainWindow::getBlurredBackground(const QPixmap& originalSize, const QPixmap& scaled)
|
QPixmap MainWindow::getBlurredBackground(const QPixmap& originalSize, const QPixmap& scaled)
|
||||||
{
|
{
|
||||||
if (scaled.width() < width() || _aspect == 'l') {
|
if (scaled.width() < width()) {
|
||||||
QPixmap background = blur(originalSize.scaledToWidth(width(), Qt::SmoothTransformation));
|
QPixmap background = blur(originalSize.scaledToWidth(width(), Qt::SmoothTransformation));
|
||||||
QRect rect(0, (background.height() - height())/2, width(), height());
|
QRect rect(0, (background.height() - height())/2, width(), height());
|
||||||
return background.copy(rect);
|
return background.copy(rect);
|
||||||
@@ -212,15 +212,15 @@ QPixmap MainWindow::getRotatedPixmap(const QPixmap& p)
|
|||||||
|
|
||||||
QPixmap MainWindow::getScaledPixmap(const QPixmap& p)
|
QPixmap MainWindow::getScaledPixmap(const QPixmap& p)
|
||||||
{
|
{
|
||||||
if (_fitAspectAxisToWindow)
|
if (fitAspectAxisToWindow)
|
||||||
{
|
{
|
||||||
if ( _aspect == 'p')
|
if ( aspect == 'p')
|
||||||
{
|
{
|
||||||
// potrait mode, make height of image fit screen and crop top/bottom
|
// potrait mode, make height of image fit screen and crop top/bottom
|
||||||
QPixmap pTemp = p.scaledToHeight(height(), Qt::SmoothTransformation);
|
QPixmap pTemp = p.scaledToHeight(height(), Qt::SmoothTransformation);
|
||||||
return pTemp.copy(0,0,width(),height());
|
return pTemp.copy(0,0,width(),height());
|
||||||
}
|
}
|
||||||
else if ( _aspect == 'l')
|
else if ( aspect == 'l')
|
||||||
{
|
{
|
||||||
// landscape mode, make width of image fit screen and crop top/bottom
|
// landscape mode, make width of image fit screen and crop top/bottom
|
||||||
QPixmap pTemp = p.scaledToWidth(width(), Qt::SmoothTransformation);
|
QPixmap pTemp = p.scaledToWidth(width(), Qt::SmoothTransformation);
|
||||||
|
|||||||
@@ -25,18 +25,18 @@ public:
|
|||||||
void setBackgroundOpacity(unsigned int opacity);
|
void setBackgroundOpacity(unsigned int opacity);
|
||||||
void warn(std::string text);
|
void warn(std::string text);
|
||||||
void setOverlay(Overlay* overlay);
|
void setOverlay(Overlay* overlay);
|
||||||
void setAspect(char aspect);
|
void setAspect(char aspectIn);
|
||||||
void setDebugMode(bool debugMode) {_debugMode = debugMode;}
|
void setDebugMode(bool debugModeIn) {debugMode = debugModeIn;}
|
||||||
void setFitAspectAxisToWindow(bool fitAspectAxisToWindow) { _fitAspectAxisToWindow = fitAspectAxisToWindow; }
|
void setFitAspectAxisToWindow(bool fitAspectAxisToWindowIn) { fitAspectAxisToWindow = fitAspectAxisToWindowIn; }
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
|
||||||
std::string currentImage;
|
std::string currentImage;
|
||||||
unsigned int blurRadius = 20;
|
unsigned int blurRadius = 20;
|
||||||
unsigned int backgroundOpacity = 150;
|
unsigned int backgroundOpacity = 150;
|
||||||
char _aspect = 'a';
|
char aspect = 'a';
|
||||||
bool _debugMode = false;
|
bool debugMode = false;
|
||||||
bool _fitAspectAxisToWindow = false;
|
bool fitAspectAxisToWindow = false;
|
||||||
|
|
||||||
Overlay* overlay;
|
Overlay* overlay;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ void Overlay::parseInput() {
|
|||||||
|
|
||||||
QString Overlay::getTemplate(QStringList components){
|
QString Overlay::getTemplate(QStringList components){
|
||||||
if (components.size()>3) {
|
if (components.size()>3) {
|
||||||
if(_debugMode)
|
if(debugMode)
|
||||||
{
|
{
|
||||||
std::cout << "template: " << components[3].toStdString() << std::endl;
|
std::cout << "template: " << components[3].toStdString() << std::endl;
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ QString Overlay::getTemplate(QStringList components){
|
|||||||
|
|
||||||
int Overlay::getMargin(QStringList components){
|
int Overlay::getMargin(QStringList components){
|
||||||
if (components.size()>1) {
|
if (components.size()>1) {
|
||||||
if(_debugMode)
|
if(debugMode)
|
||||||
{
|
{
|
||||||
std::cout << "margin: " << components[1].toStdString() << std::endl;
|
std::cout << "margin: " << components[1].toStdString() << std::endl;
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ int Overlay::getMargin(QStringList components){
|
|||||||
|
|
||||||
int Overlay::getFontsize(QStringList components){
|
int Overlay::getFontsize(QStringList components){
|
||||||
if (components.size()>2) {
|
if (components.size()>2) {
|
||||||
if(_debugMode)
|
if(debugMode)
|
||||||
{
|
{
|
||||||
std::cout << "fontsize: " << components[2].toStdString() << std::endl;
|
std::cout << "fontsize: " << components[2].toStdString() << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ class Overlay
|
|||||||
int getMarginBottomRight();
|
int getMarginBottomRight();
|
||||||
int getFontsizeBottomRight();
|
int getFontsizeBottomRight();
|
||||||
|
|
||||||
void setDebugMode(const bool debugMode) { _debugMode = debugMode; }
|
void setDebugMode(const bool debugModeIn) { debugMode = debugModeIn; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string overlayInput;
|
const std::string overlayInput;
|
||||||
int margin;
|
int margin;
|
||||||
int fontsize;
|
int fontsize;
|
||||||
bool _debugMode = false;
|
bool debugMode = false;
|
||||||
|
|
||||||
QString topLeftTemplate;
|
QString topLeftTemplate;
|
||||||
QString topRightTemplate;
|
QString topRightTemplate;
|
||||||
|
|||||||
Reference in New Issue
Block a user