- 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
|
||||
|
||||
```
|
||||
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)
|
||||
@@ -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)
|
||||
* `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.
|
||||
* `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
|
||||
* `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
|
||||
* `--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.
|
||||
* It defines overlays for all four edges in the order `top-left;top-right;bottom-left;bottom-right`
|
||||
* All edges overlays are separated by `;`
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
struct Config {
|
||||
public:
|
||||
unsigned int rotationSeconds = 30;
|
||||
unsigned int transitionTime = 1;
|
||||
int blurRadius = -1;
|
||||
int backgroundOpacity = -1;
|
||||
ImageDisplayOptions baseDisplayOptions;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <memory>
|
||||
|
||||
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[]) {
|
||||
@@ -34,7 +34,7 @@ bool parseCommandLine(AppConfig &appConfig, int argc, char *argv[]) {
|
||||
{"overlay-color", required_argument, 0, 'h'},
|
||||
};
|
||||
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) {
|
||||
case 0:
|
||||
/* If this option set a flag, do nothing else now. */
|
||||
@@ -61,6 +61,9 @@ bool parseCommandLine(AppConfig &appConfig, int argc, char *argv[]) {
|
||||
case 't':
|
||||
appConfig.rotationSeconds = atoi(optarg);
|
||||
break;
|
||||
case 'T':
|
||||
appConfig.transitionTime =atoi(optarg);
|
||||
break;
|
||||
case 'b':
|
||||
appConfig.blurRadius = atoi(optarg);
|
||||
break;
|
||||
@@ -129,6 +132,8 @@ void ConfigureWindowFromSettings(MainWindow &w, const AppConfig &appConfig)
|
||||
w.setBackgroundOpacity(appConfig.backgroundOpacity);
|
||||
}
|
||||
|
||||
w.setTransitionTime(appConfig.transitionTime);
|
||||
|
||||
if (!appConfig.overlayHexRGB.isEmpty())
|
||||
{
|
||||
QRegularExpression hexRGBMatcher("^#([0-9A-Fa-f]{3}){1,2}$");
|
||||
|
||||
@@ -120,7 +120,8 @@ bool MainWindow::event(QEvent* event)
|
||||
void MainWindow::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
QMainWindow::resizeEvent(event);
|
||||
updateImage(true);
|
||||
this->findChild<QLabel*>("image")->clear();
|
||||
updateImage();
|
||||
}
|
||||
|
||||
void MainWindow::checkWindowSize()
|
||||
@@ -133,7 +134,7 @@ void MainWindow::checkWindowSize()
|
||||
{
|
||||
Log("Resizing Window", screenSize.width(), "," , screenSize.height() );
|
||||
setFixedSize(screenSize);
|
||||
updateImage(true);
|
||||
updateImage();
|
||||
}
|
||||
|
||||
if (imageAspectMatchesMonitor)
|
||||
@@ -166,7 +167,7 @@ void MainWindow::setImage(const ImageDetails &imageDetails)
|
||||
{
|
||||
pendingReply->abort();
|
||||
}
|
||||
updateImage(false);
|
||||
updateImage();
|
||||
}
|
||||
|
||||
void MainWindow::fileDownloaded(QNetworkReply* netReply)
|
||||
@@ -179,12 +180,12 @@ void MainWindow::fileDownloaded(QNetworkReply* netReply)
|
||||
{
|
||||
downloadedData = netReply->readAll();
|
||||
netReply->deleteLater();
|
||||
updateImage(false);
|
||||
updateImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateImage(bool immediately)
|
||||
void MainWindow::updateImage()
|
||||
{
|
||||
checkWindowSize();
|
||||
if (currentImage.filename == "")
|
||||
@@ -203,7 +204,7 @@ void MainWindow::updateImage(bool immediately)
|
||||
|
||||
QLabel *label = this->findChild<QLabel*>("image");
|
||||
const QPixmap* oldImage = label->pixmap();
|
||||
if (oldImage != NULL && !immediately)
|
||||
if (oldImage != NULL && transitionSeconds > 0)
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setBrush(QPalette::Background, *oldImage);
|
||||
@@ -256,13 +257,13 @@ void MainWindow::updateImage(bool immediately)
|
||||
|
||||
label->setPixmap(background);
|
||||
|
||||
if (oldImage != NULL && !immediately)
|
||||
if (oldImage != NULL && transitionSeconds > 0)
|
||||
{
|
||||
auto effect = new QGraphicsOpacityEffect(label);
|
||||
effect->setOpacity(0.0);
|
||||
label->setGraphicsEffect(effect);
|
||||
QPropertyAnimation* animation = new QPropertyAnimation(effect, "opacity");
|
||||
animation->setDuration(1000);
|
||||
animation->setDuration(transitionSeconds*1000);
|
||||
animation->setStartValue(0);
|
||||
animation->setEndValue(1);
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
@@ -393,6 +394,11 @@ void MainWindow::setOverlayHexRGB(QString overlayHexRGB)
|
||||
this->overlayHexRGB = overlayHexRGB;
|
||||
}
|
||||
|
||||
void MainWindow::setTransitionTime(unsigned int transitionSeconds)
|
||||
{
|
||||
this->transitionSeconds = transitionSeconds;
|
||||
}
|
||||
|
||||
void MainWindow::warn(std::string text)
|
||||
{
|
||||
QLabel *label = this->findChild<QLabel*>("image");
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
void setImage(const ImageDetails &imageDetails);
|
||||
void setBlurRadius(unsigned int blurRadius);
|
||||
void setBackgroundOpacity(unsigned int opacity);
|
||||
void setTransitionTime(unsigned int transitionSeconds);
|
||||
void warn(std::string text);
|
||||
void setOverlay(std::unique_ptr<Overlay> &overlay);
|
||||
void setBaseOptions(const ImageDisplayOptions &baseOptionsIn);
|
||||
@@ -52,13 +53,14 @@ private:
|
||||
QNetworkReply *pendingReply = nullptr;
|
||||
QSize lastScreenSize = {0,0};
|
||||
QString overlayHexRGB = "#FFFF";
|
||||
unsigned int transitionSeconds = 1;
|
||||
|
||||
std::unique_ptr<Overlay> overlay;
|
||||
ImageSwitcher *switcher = nullptr;
|
||||
|
||||
void drawText(QPixmap& image, int margin, int fontsize, QString text, int alignment);
|
||||
|
||||
void updateImage(bool immediately);
|
||||
void updateImage();
|
||||
int getImageRotation();
|
||||
|
||||
QPixmap getBlurredBackground(const QPixmap& originalSize, const QPixmap& scaled);
|
||||
|
||||
Reference in New Issue
Block a user