UI: add drop shadow to mainwindow labels
This commit is contained in:
		
							
								
								
									
										1
									
								
								main.cpp
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								main.cpp
									
									
									
									
									
								
							@ -21,7 +21,6 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
    if (translator.load(QLocale(), QLatin1String("pineapple-music"), QLatin1String("_"), QLatin1String(":/i18n"))) {
 | 
					    if (translator.load(QLocale(), QLatin1String("pineapple-music"), QLatin1String("_"), QLatin1String(":/i18n"))) {
 | 
				
			||||||
        a.installTranslator(&translator);
 | 
					        a.installTranslator(&translator);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    a.installTranslator(&translator);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // parse commandline arguments
 | 
					    // parse commandline arguments
 | 
				
			||||||
    QCommandLineParser parser;
 | 
					    QCommandLineParser parser;
 | 
				
			||||||
 | 
				
			|||||||
@ -33,6 +33,7 @@
 | 
				
			|||||||
#include <QMessageBox>
 | 
					#include <QMessageBox>
 | 
				
			||||||
#include <QStringBuilder>
 | 
					#include <QStringBuilder>
 | 
				
			||||||
#include <QSettings>
 | 
					#include <QSettings>
 | 
				
			||||||
 | 
					#include <QGraphicsDropShadowEffect>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
constexpr QSize miniSize(490, 160);
 | 
					constexpr QSize miniSize(490, 160);
 | 
				
			||||||
constexpr QSize fullSize(490, 420);
 | 
					constexpr QSize fullSize(490, 420);
 | 
				
			||||||
@ -61,6 +62,11 @@ MainWindow::MainWindow(QWidget *parent)
 | 
				
			|||||||
    ui->actionOpen->setShortcut(QKeySequence::Open);
 | 
					    ui->actionOpen->setShortcut(QKeySequence::Open);
 | 
				
			||||||
    addAction(ui->actionOpen);
 | 
					    addAction(ui->actionOpen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ui->titleLabel->setGraphicsEffect(createLabelShadowEffect());
 | 
				
			||||||
 | 
					    ui->propLabel->setGraphicsEffect(createLabelShadowEffect());
 | 
				
			||||||
 | 
					    ui->nowTimeLabel->setGraphicsEffect(createLabelShadowEffect());
 | 
				
			||||||
 | 
					    ui->totalTimeLabel->setGraphicsEffect(createLabelShadowEffect());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint);
 | 
					    setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint);
 | 
				
			||||||
    setAttribute(Qt::WA_TranslucentBackground, true);
 | 
					    setAttribute(Qt::WA_TranslucentBackground, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -668,3 +674,12 @@ void MainWindow::on_actionHelp_triggered()
 | 
				
			|||||||
    infoBox.exec();
 | 
					    infoBox.exec();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QGraphicsDropShadowEffect *MainWindow::createLabelShadowEffect()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    QGraphicsDropShadowEffect * effect = new QGraphicsDropShadowEffect(this);
 | 
				
			||||||
 | 
					    effect->setBlurRadius(3);
 | 
				
			||||||
 | 
					    effect->setColor(QColor(0, 0, 0, 180));
 | 
				
			||||||
 | 
					    effect->setOffset(1, 1);
 | 
				
			||||||
 | 
					    return effect;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -15,6 +15,7 @@ class QMediaDevices;
 | 
				
			|||||||
class QMediaPlayer;
 | 
					class QMediaPlayer;
 | 
				
			||||||
class QAudioOutput;
 | 
					class QAudioOutput;
 | 
				
			||||||
class QPropertyAnimation;
 | 
					class QPropertyAnimation;
 | 
				
			||||||
 | 
					class QGraphicsDropShadowEffect;
 | 
				
			||||||
QT_END_NAMESPACE
 | 
					QT_END_NAMESPACE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class FFTSpectrum;
 | 
					class FFTSpectrum;
 | 
				
			||||||
@ -83,6 +84,8 @@ signals:
 | 
				
			|||||||
    void playbackModeChanged(enum PlaybackMode mode);
 | 
					    void playbackModeChanged(enum PlaybackMode mode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
 | 
					    QGraphicsDropShadowEffect * createLabelShadowEffect();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool m_clickedOnWindow = false;
 | 
					    bool m_clickedOnWindow = false;
 | 
				
			||||||
    bool m_playbackSliderPressed = false;
 | 
					    bool m_playbackSliderPressed = false;
 | 
				
			||||||
    QLinearGradient m_bgLinearGradient;
 | 
					    QLinearGradient m_bgLinearGradient;
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user