UI: add drop shadow to mainwindow labels

This commit is contained in:
Gary Wang 2024-11-16 20:38:48 +08:00
parent 5d609cdace
commit af8e61c124
No known key found for this signature in database
GPG Key ID: 5D30A4F15EA78760
3 changed files with 18 additions and 1 deletions

View File

@ -21,7 +21,6 @@ int main(int argc, char *argv[])
if (translator.load(QLocale(), QLatin1String("pineapple-music"), QLatin1String("_"), QLatin1String(":/i18n"))) {
a.installTranslator(&translator);
}
a.installTranslator(&translator);
// parse commandline arguments
QCommandLineParser parser;

View File

@ -33,6 +33,7 @@
#include <QMessageBox>
#include <QStringBuilder>
#include <QSettings>
#include <QGraphicsDropShadowEffect>
constexpr QSize miniSize(490, 160);
constexpr QSize fullSize(490, 420);
@ -61,6 +62,11 @@ MainWindow::MainWindow(QWidget *parent)
ui->actionOpen->setShortcut(QKeySequence::Open);
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);
setAttribute(Qt::WA_TranslucentBackground, true);
@ -668,3 +674,12 @@ void MainWindow::on_actionHelp_triggered()
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;
}

View File

@ -15,6 +15,7 @@ class QMediaDevices;
class QMediaPlayer;
class QAudioOutput;
class QPropertyAnimation;
class QGraphicsDropShadowEffect;
QT_END_NAMESPACE
class FFTSpectrum;
@ -83,6 +84,8 @@ signals:
void playbackModeChanged(enum PlaybackMode mode);
private:
QGraphicsDropShadowEffect * createLabelShadowEffect();
bool m_clickedOnWindow = false;
bool m_playbackSliderPressed = false;
QLinearGradient m_bgLinearGradient;