- 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 <random> // std::default_random_engine
|
||||
|
||||
ImageSelector::ImageSelector(std::unique_ptr<PathTraverser>& pathTraverser, char aspect):
|
||||
pathTraverser(pathTraverser), _aspect(aspect)
|
||||
ImageSelector::ImageSelector(std::unique_ptr<PathTraverser>& pathTraverser, char aspectIn):
|
||||
pathTraverser(pathTraverser), aspect(aspectIn)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ bool ImageSelector::imageValidForAspect(const std::string &fileName)
|
||||
std::swap(imageWidth,imageHeight);
|
||||
}
|
||||
|
||||
switch(_aspect)
|
||||
switch(aspect)
|
||||
{
|
||||
case 'a':
|
||||
// allow all
|
||||
@@ -118,7 +118,7 @@ std::string RandomImageSelector::getNextImage()
|
||||
|
||||
unsigned int RandomImageSelector::selectRandom(const QStringList& images) const
|
||||
{
|
||||
if(_debugMode)
|
||||
if(debugMode)
|
||||
{
|
||||
std::cout << "images: " << images.size() << std::endl;
|
||||
}
|
||||
|
||||
@@ -11,17 +11,17 @@ class PathTraverser;
|
||||
class ImageSelector
|
||||
{
|
||||
public:
|
||||
ImageSelector(std::unique_ptr<PathTraverser>& pathTraverser, char aspect);
|
||||
ImageSelector(std::unique_ptr<PathTraverser>& pathTraverser, char aspectIn);
|
||||
virtual ~ImageSelector();
|
||||
virtual std::string getNextImage() = 0;
|
||||
void setDebugMode(bool debugMode) { _debugMode = debugMode;}
|
||||
void setDebugMode(bool debugModeIn) { debugMode = debugModeIn;}
|
||||
|
||||
protected:
|
||||
int getImageRotation(const std::string &fileName);
|
||||
bool imageValidForAspect(const std::string &fileName);
|
||||
std::unique_ptr<PathTraverser>& pathTraverser;
|
||||
char _aspect;
|
||||
bool _debugMode = false;
|
||||
char aspect;
|
||||
bool debugMode = false;
|
||||
};
|
||||
|
||||
class RandomImageSelector : public ImageSelector
|
||||
|
||||
@@ -109,7 +109,7 @@ void MainWindow::updateImage(bool immediately)
|
||||
}
|
||||
|
||||
QPixmap p( currentImage.c_str() );
|
||||
if(_debugMode)
|
||||
if(debugMode)
|
||||
{
|
||||
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->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);
|
||||
if (_debugMode)
|
||||
if (debugMode)
|
||||
{
|
||||
// draw a thumbnail version of the source image in the bottom left, to check for cropping issues
|
||||
QPainter pt(&background);
|
||||
@@ -184,14 +184,14 @@ void MainWindow::setOverlay(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)
|
||||
{
|
||||
if (scaled.width() < width() || _aspect == 'l') {
|
||||
if (scaled.width() < width()) {
|
||||
QPixmap background = blur(originalSize.scaledToWidth(width(), Qt::SmoothTransformation));
|
||||
QRect rect(0, (background.height() - height())/2, width(), height());
|
||||
return background.copy(rect);
|
||||
@@ -212,15 +212,15 @@ QPixmap MainWindow::getRotatedPixmap(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
|
||||
QPixmap pTemp = p.scaledToHeight(height(), Qt::SmoothTransformation);
|
||||
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
|
||||
QPixmap pTemp = p.scaledToWidth(width(), Qt::SmoothTransformation);
|
||||
|
||||
@@ -25,18 +25,18 @@ public:
|
||||
void setBackgroundOpacity(unsigned int opacity);
|
||||
void warn(std::string text);
|
||||
void setOverlay(Overlay* overlay);
|
||||
void setAspect(char aspect);
|
||||
void setDebugMode(bool debugMode) {_debugMode = debugMode;}
|
||||
void setFitAspectAxisToWindow(bool fitAspectAxisToWindow) { _fitAspectAxisToWindow = fitAspectAxisToWindow; }
|
||||
void setAspect(char aspectIn);
|
||||
void setDebugMode(bool debugModeIn) {debugMode = debugModeIn;}
|
||||
void setFitAspectAxisToWindow(bool fitAspectAxisToWindowIn) { fitAspectAxisToWindow = fitAspectAxisToWindowIn; }
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
std::string currentImage;
|
||||
unsigned int blurRadius = 20;
|
||||
unsigned int backgroundOpacity = 150;
|
||||
char _aspect = 'a';
|
||||
bool _debugMode = false;
|
||||
bool _fitAspectAxisToWindow = false;
|
||||
char aspect = 'a';
|
||||
bool debugMode = false;
|
||||
bool fitAspectAxisToWindow = false;
|
||||
|
||||
Overlay* overlay;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ void Overlay::parseInput() {
|
||||
|
||||
QString Overlay::getTemplate(QStringList components){
|
||||
if (components.size()>3) {
|
||||
if(_debugMode)
|
||||
if(debugMode)
|
||||
{
|
||||
std::cout << "template: " << components[3].toStdString() << std::endl;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ QString Overlay::getTemplate(QStringList components){
|
||||
|
||||
int Overlay::getMargin(QStringList components){
|
||||
if (components.size()>1) {
|
||||
if(_debugMode)
|
||||
if(debugMode)
|
||||
{
|
||||
std::cout << "margin: " << components[1].toStdString() << std::endl;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ int Overlay::getMargin(QStringList components){
|
||||
|
||||
int Overlay::getFontsize(QStringList components){
|
||||
if (components.size()>2) {
|
||||
if(_debugMode)
|
||||
if(debugMode)
|
||||
{
|
||||
std::cout << "fontsize: " << components[2].toStdString() << std::endl;
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class Overlay
|
||||
int getMarginBottomRight();
|
||||
int getFontsizeBottomRight();
|
||||
|
||||
void setDebugMode(const bool debugMode) { _debugMode = debugMode; }
|
||||
void setDebugMode(const bool debugModeIn) { debugMode = debugModeIn; }
|
||||
|
||||
private:
|
||||
const std::string overlayInput;
|
||||
int margin;
|
||||
int fontsize;
|
||||
bool _debugMode = false;
|
||||
bool debugMode = false;
|
||||
|
||||
QString topLeftTemplate;
|
||||
QString topRightTemplate;
|
||||
|
||||
Reference in New Issue
Block a user