- merge from main
This commit is contained in:
@@ -18,7 +18,7 @@ This project is maintained by myself during my spare time. If you like and use i
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
slide [-t rotation_seconds] [-a aspect] [-o background_opacity(0..255)] [-b blur_radius] [-p image_folder|-i imageFile,...] [-r] [-O overlay_string] [-v] [--verbose] [--stretch] [-c path_to_config_json]
|
slide [-t rotation_seconds] [-T transition_seconds] [-h/--overlay-color overlay_color(#rrggbb)] [-a aspect] [-o background_opacity(0..255)] [-b blur_radius] [-p image_folder|-i imageFile,...] [-r] [-O overlay_string] [-v] [--verbose] [--stretch] [-c path_to_config_json]
|
||||||
```
|
```
|
||||||
|
|
||||||
* `image_folder`: where to search for images (.jpg files)
|
* `image_folder`: where to search for images (.jpg files)
|
||||||
@@ -30,10 +30,13 @@ slide [-t rotation_seconds] [-a aspect] [-o background_opacity(0..255)] [-b blur
|
|||||||
* `-S` for sorted rotation (files ordered by name, first images then subfolders)
|
* `-S` for sorted rotation (files ordered by name, first images then subfolders)
|
||||||
* `rotation_seconds(default=30)`: time until next random image is chosen from the given folder
|
* `rotation_seconds(default=30)`: time until next random image is chosen from the given folder
|
||||||
* `aspect(default=a)`: the required aspect ratio of the picture to display. Valid values are 'a' (all), 'l' (landscape), 'p' (portrait) and 'm' (monitor). Monitor will match the aspect ratio of the display we are running on.
|
* `aspect(default=a)`: the required aspect ratio of the picture to display. Valid values are 'a' (all), 'l' (landscape), 'p' (portrait) and 'm' (monitor). Monitor will match the aspect ratio of the display we are running on.
|
||||||
|
* `transition_seconds(default=1)`: time of image transition animation. Default is 1 second, and transition animation will be disabled if the value is set to 0
|
||||||
|
* `aspect(default=a)`: the required aspect ratio of the picture to display. Valid values are 'a' (all), 'l' (landscape) and 'p' (portrait)
|
||||||
* `background_opacity(default=150)`: opacity of the background filling image between 0 (black background) and 255
|
* `background_opacity(default=150)`: opacity of the background filling image between 0 (black background) and 255
|
||||||
* `blur_radius(default=20)`: blur radius of the background filling image
|
* `blur_radius(default=20)`: blur radius of the background filling image
|
||||||
* `-v` or `--verbose`: Verbose debug output when running, plus a thumbnail of the original image in the bottom left of the screen
|
* `-v` or `--verbose`: Verbose debug output when running, plus a thumbnail of the original image in the bottom left of the screen
|
||||||
* `--stretch`: When in aspect mode 'l','p' or 'm' crop the image rather than leaving a blurred background. For example, in landscape mode this will make images as wide as the screen and crop the top and bottom to fit.
|
* `--stretch`: When in aspect mode 'l','p' or 'm' crop the image rather than leaving a blurred background. For example, in landscape mode this will make images as wide as the screen and crop the top and bottom to fit.
|
||||||
|
* `-h` or `--overlay-color` the color of the overlay text, in the form of 3 or 6 digits hex rgb string prefixed by `#`, for example `#00FF00` or `#0F0` for color 🟢
|
||||||
* `-O` is used to create a overlay string.
|
* `-O` is used to create a overlay string.
|
||||||
* It defines overlays for all four edges in the order `top-left;top-right;bottom-left;bottom-right`
|
* It defines overlays for all four edges in the order `top-left;top-right;bottom-left;bottom-right`
|
||||||
* All edges overlays are separated by `;`
|
* All edges overlays are separated by `;`
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
struct Config {
|
struct Config {
|
||||||
public:
|
public:
|
||||||
unsigned int rotationSeconds = 30;
|
unsigned int rotationSeconds = 30;
|
||||||
|
unsigned int transitionTime = 1;
|
||||||
int blurRadius = -1;
|
int blurRadius = -1;
|
||||||
int backgroundOpacity = -1;
|
int backgroundOpacity = -1;
|
||||||
ImageDisplayOptions baseDisplayOptions;
|
ImageDisplayOptions baseDisplayOptions;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
void usage(std::string programName) {
|
void usage(std::string programName) {
|
||||||
std::cerr << "Usage: " << programName << " [-t rotation_seconds] [-a aspect('l','p','a', 'm')] [-o background_opacity(0..255)] [-b blur_radius] -p image_folder [-r] [-s] [-v] [--verbose] [--stretch] [-c config_file_path]" << std::endl;
|
std::cerr << "Usage: " << programName << " [-t rotation_seconds] [-T transition_seconds] [-h/--overlay-color #rrggbb] [-a aspect('l','p','a', 'm')] [-o background_opacity(0..255)] [-b blur_radius] -p image_folder [-r] [-s] [-S] [-v] [--verbose] [--stretch] [-c config_file_path]" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parseCommandLine(AppConfig &appConfig, int argc, char *argv[]) {
|
bool parseCommandLine(AppConfig &appConfig, int argc, char *argv[]) {
|
||||||
@@ -34,7 +34,7 @@ bool parseCommandLine(AppConfig &appConfig, int argc, char *argv[]) {
|
|||||||
{"overlay-color", required_argument, 0, 'h'},
|
{"overlay-color", required_argument, 0, 'h'},
|
||||||
};
|
};
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
while ((opt = getopt_long(argc, argv, "b:p:t:o:O:a:i:c:h:rsSv", long_options, &option_index)) != -1) {
|
while ((opt = getopt_long(argc, argv, "b:p:t:T:o:O:a:i:c:h:rsSv", long_options, &option_index)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 0:
|
case 0:
|
||||||
/* If this option set a flag, do nothing else now. */
|
/* If this option set a flag, do nothing else now. */
|
||||||
@@ -61,6 +61,9 @@ bool parseCommandLine(AppConfig &appConfig, int argc, char *argv[]) {
|
|||||||
case 't':
|
case 't':
|
||||||
appConfig.rotationSeconds = atoi(optarg);
|
appConfig.rotationSeconds = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'T':
|
||||||
|
appConfig.transitionTime =atoi(optarg);
|
||||||
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
appConfig.blurRadius = atoi(optarg);
|
appConfig.blurRadius = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
@@ -129,6 +132,8 @@ void ConfigureWindowFromSettings(MainWindow &w, const AppConfig &appConfig)
|
|||||||
w.setBackgroundOpacity(appConfig.backgroundOpacity);
|
w.setBackgroundOpacity(appConfig.backgroundOpacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.setTransitionTime(appConfig.transitionTime);
|
||||||
|
|
||||||
if (!appConfig.overlayHexRGB.isEmpty())
|
if (!appConfig.overlayHexRGB.isEmpty())
|
||||||
{
|
{
|
||||||
QRegularExpression hexRGBMatcher("^#([0-9A-Fa-f]{3}){1,2}$");
|
QRegularExpression hexRGBMatcher("^#([0-9A-Fa-f]{3}){1,2}$");
|
||||||
|
|||||||
@@ -120,7 +120,8 @@ bool MainWindow::event(QEvent* event)
|
|||||||
void MainWindow::resizeEvent(QResizeEvent* event)
|
void MainWindow::resizeEvent(QResizeEvent* event)
|
||||||
{
|
{
|
||||||
QMainWindow::resizeEvent(event);
|
QMainWindow::resizeEvent(event);
|
||||||
updateImage(true);
|
this->findChild<QLabel*>("image")->clear();
|
||||||
|
updateImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::checkWindowSize()
|
void MainWindow::checkWindowSize()
|
||||||
@@ -133,7 +134,7 @@ void MainWindow::checkWindowSize()
|
|||||||
{
|
{
|
||||||
Log("Resizing Window", screenSize.width(), "," , screenSize.height() );
|
Log("Resizing Window", screenSize.width(), "," , screenSize.height() );
|
||||||
setFixedSize(screenSize);
|
setFixedSize(screenSize);
|
||||||
updateImage(true);
|
updateImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imageAspectMatchesMonitor)
|
if (imageAspectMatchesMonitor)
|
||||||
@@ -166,7 +167,7 @@ void MainWindow::setImage(const ImageDetails &imageDetails)
|
|||||||
{
|
{
|
||||||
pendingReply->abort();
|
pendingReply->abort();
|
||||||
}
|
}
|
||||||
updateImage(false);
|
updateImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::fileDownloaded(QNetworkReply* netReply)
|
void MainWindow::fileDownloaded(QNetworkReply* netReply)
|
||||||
@@ -179,12 +180,12 @@ void MainWindow::fileDownloaded(QNetworkReply* netReply)
|
|||||||
{
|
{
|
||||||
downloadedData = netReply->readAll();
|
downloadedData = netReply->readAll();
|
||||||
netReply->deleteLater();
|
netReply->deleteLater();
|
||||||
updateImage(false);
|
updateImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateImage(bool immediately)
|
void MainWindow::updateImage()
|
||||||
{
|
{
|
||||||
checkWindowSize();
|
checkWindowSize();
|
||||||
if (currentImage.filename == "")
|
if (currentImage.filename == "")
|
||||||
@@ -203,7 +204,7 @@ void MainWindow::updateImage(bool immediately)
|
|||||||
|
|
||||||
QLabel *label = this->findChild<QLabel*>("image");
|
QLabel *label = this->findChild<QLabel*>("image");
|
||||||
const QPixmap* oldImage = label->pixmap();
|
const QPixmap* oldImage = label->pixmap();
|
||||||
if (oldImage != NULL && !immediately)
|
if (oldImage != NULL && transitionSeconds > 0)
|
||||||
{
|
{
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
palette.setBrush(QPalette::Background, *oldImage);
|
palette.setBrush(QPalette::Background, *oldImage);
|
||||||
@@ -256,13 +257,13 @@ void MainWindow::updateImage(bool immediately)
|
|||||||
|
|
||||||
label->setPixmap(background);
|
label->setPixmap(background);
|
||||||
|
|
||||||
if (oldImage != NULL && !immediately)
|
if (oldImage != NULL && transitionSeconds > 0)
|
||||||
{
|
{
|
||||||
auto effect = new QGraphicsOpacityEffect(label);
|
auto effect = new QGraphicsOpacityEffect(label);
|
||||||
effect->setOpacity(0.0);
|
effect->setOpacity(0.0);
|
||||||
label->setGraphicsEffect(effect);
|
label->setGraphicsEffect(effect);
|
||||||
QPropertyAnimation* animation = new QPropertyAnimation(effect, "opacity");
|
QPropertyAnimation* animation = new QPropertyAnimation(effect, "opacity");
|
||||||
animation->setDuration(1000);
|
animation->setDuration(transitionSeconds*1000);
|
||||||
animation->setStartValue(0);
|
animation->setStartValue(0);
|
||||||
animation->setEndValue(1);
|
animation->setEndValue(1);
|
||||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||||
@@ -393,6 +394,11 @@ void MainWindow::setOverlayHexRGB(QString overlayHexRGB)
|
|||||||
this->overlayHexRGB = overlayHexRGB;
|
this->overlayHexRGB = overlayHexRGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::setTransitionTime(unsigned int transitionSeconds)
|
||||||
|
{
|
||||||
|
this->transitionSeconds = transitionSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::warn(std::string text)
|
void MainWindow::warn(std::string text)
|
||||||
{
|
{
|
||||||
QLabel *label = this->findChild<QLabel*>("image");
|
QLabel *label = this->findChild<QLabel*>("image");
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public:
|
|||||||
void setImage(const ImageDetails &imageDetails);
|
void setImage(const ImageDetails &imageDetails);
|
||||||
void setBlurRadius(unsigned int blurRadius);
|
void setBlurRadius(unsigned int blurRadius);
|
||||||
void setBackgroundOpacity(unsigned int opacity);
|
void setBackgroundOpacity(unsigned int opacity);
|
||||||
|
void setTransitionTime(unsigned int transitionSeconds);
|
||||||
void warn(std::string text);
|
void warn(std::string text);
|
||||||
void setOverlay(std::unique_ptr<Overlay> &overlay);
|
void setOverlay(std::unique_ptr<Overlay> &overlay);
|
||||||
void setBaseOptions(const ImageDisplayOptions &baseOptionsIn);
|
void setBaseOptions(const ImageDisplayOptions &baseOptionsIn);
|
||||||
@@ -52,13 +53,14 @@ private:
|
|||||||
QNetworkReply *pendingReply = nullptr;
|
QNetworkReply *pendingReply = nullptr;
|
||||||
QSize lastScreenSize = {0,0};
|
QSize lastScreenSize = {0,0};
|
||||||
QString overlayHexRGB = "#FFFF";
|
QString overlayHexRGB = "#FFFF";
|
||||||
|
unsigned int transitionSeconds = 1;
|
||||||
|
|
||||||
std::unique_ptr<Overlay> overlay;
|
std::unique_ptr<Overlay> overlay;
|
||||||
ImageSwitcher *switcher = nullptr;
|
ImageSwitcher *switcher = nullptr;
|
||||||
|
|
||||||
void drawText(QPixmap& image, int margin, int fontsize, QString text, int alignment);
|
void drawText(QPixmap& image, int margin, int fontsize, QString text, int alignment);
|
||||||
|
|
||||||
void updateImage(bool immediately);
|
void updateImage();
|
||||||
int getImageRotation();
|
int getImageRotation();
|
||||||
|
|
||||||
QPixmap getBlurredBackground(const QPixmap& originalSize, const QPixmap& scaled);
|
QPixmap getBlurredBackground(const QPixmap& originalSize, const QPixmap& scaled);
|
||||||
|
|||||||
Reference in New Issue
Block a user