1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2025-01-29 16:49:27 +01:00

Use QCoreApplication::applicationName() directly

This commit is contained in:
Jonas Kvinge 2025-01-06 00:38:51 +01:00
parent cbce9f7191
commit 69d38879d2
8 changed files with 13 additions and 29 deletions

View File

@ -152,7 +152,7 @@ int main(int argc, char *argv[]) {
// Only start a core application now, so we can check if there's another instance without requiring an X server.
// This MUST be done before parsing the commandline options so QTextCodec gets the right system locale for filenames.
QCoreApplication core_app(argc, argv);
KDSingleApplication single_app(QCoreApplication::applicationName(), KDSingleApplication::Option::IncludeUsernameInSocketName);
KDSingleApplication single_app(QCoreApplication::applicationName().toLower(), KDSingleApplication::Option::IncludeUsernameInSocketName);
// Parse commandline options - need to do this before starting the full QApplication, so it works without an X server
if (!options.Parse()) return 1;
logging::SetLevels(options.log_levels());
@ -189,7 +189,7 @@ int main(int argc, char *argv[]) {
QGuiApplication::setQuitOnLastWindowClosed(false);
QApplication a(argc, argv);
KDSingleApplication single_app(QCoreApplication::applicationName(), KDSingleApplication::Option::IncludeUsernameInSocketName);
KDSingleApplication single_app(QCoreApplication::applicationName().toLower(), KDSingleApplication::Option::IncludeUsernameInSocketName);
if (!single_app.isPrimaryInstance()) {
if (options.is_empty()) {
qLog(Info) << "Strawberry is already running - activating existing window (2)";

View File

@ -106,8 +106,7 @@ Mpris2::Mpris2(const SharedPtr<Player> player,
: QObject(parent),
player_(player),
playlist_manager_(playlist_manager),
current_albumcover_loader_(current_albumcover_loader),
app_name_(QCoreApplication::applicationName()) {
current_albumcover_loader_(current_albumcover_loader) {
new Mpris2Root(this);
new Mpris2TrackList(this);
@ -135,8 +134,6 @@ Mpris2::Mpris2(const SharedPtr<Player> player,
QObject::connect(&*playlist_manager_, &PlaylistManager::PlaylistChanged, this, &Mpris2::PlaylistChangedSlot);
QObject::connect(&*playlist_manager_, &PlaylistManager::CurrentChanged, this, &Mpris2::PlaylistCollectionChanged);
app_name_[0] = app_name_[0].toUpper();
QStringList data_dirs = QString::fromUtf8(qgetenv("XDG_DATA_DIRS")).split(u':');
if (!data_dirs.contains("/usr/local/share"_L1)) {
@ -238,7 +235,7 @@ bool Mpris2::CanRaise() const { return true; }
bool Mpris2::HasTrackList() const { return true; }
QString Mpris2::Identity() const { return app_name_; }
QString Mpris2::Identity() const { return QCoreApplication::applicationName(); }
QString Mpris2::DesktopEntryAbsolutePath() const {

View File

@ -242,7 +242,6 @@ class Mpris2 : public QObject {
const SharedPtr<PlaylistManager> playlist_manager_;
const SharedPtr<CurrentAlbumCoverLoader> current_albumcover_loader_;
QString app_name_;
QString desktopfilepath_;
QVariantMap last_metadata_;

View File

@ -48,7 +48,6 @@ OSDBase::OSDBase(const SharedPtr<SystemTrayIcon> tray_icon, QObject *parent)
: QObject(parent),
tray_icon_(tray_icon),
pretty_popup_(new OSDPretty(OSDPretty::Mode::Popup)),
app_name_(QCoreApplication::applicationName()),
timeout_msec_(5000),
type_(OSDSettings::Type::Native),
show_on_volume_change_(false),
@ -59,11 +58,7 @@ OSDBase::OSDBase(const SharedPtr<SystemTrayIcon> tray_icon, QObject *parent)
use_custom_text_(false),
force_show_next_(false),
ignore_next_stopped_(false),
playing_(false) {
app_name_[0] = app_name_[0].toUpper();
}
playing_(false) {}
OSDBase::~OSDBase() {
delete pretty_popup_;
@ -264,7 +259,7 @@ void OSDBase::Stopped() {
}
void OSDBase::StopAfterToggle(const bool stop) {
ShowMessage(app_name_, tr("Stop playing after track: %1").arg(stop ? tr("On") : tr("Off")));
ShowMessage(QCoreApplication::applicationName(), tr("Stop playing after track: %1").arg(stop ? tr("On") : tr("Off")));
}
void OSDBase::PlaylistFinished() {
@ -272,7 +267,7 @@ void OSDBase::PlaylistFinished() {
// We get a PlaylistFinished followed by a Stopped from the player
ignore_next_stopped_ = true;
ShowMessage(app_name_, tr("Playlist finished"));
ShowMessage(QCoreApplication::applicationName(), tr("Playlist finished"));
}
@ -290,7 +285,7 @@ void OSDBase::VolumeChanged(const uint value) {
}
#endif
ShowMessage(app_name_, message);
ShowMessage(QCoreApplication::applicationName(), message);
}
@ -346,7 +341,7 @@ void OSDBase::ShuffleModeChanged(const PlaylistSequence::ShuffleMode mode) {
case PlaylistSequence::ShuffleMode::InsideAlbum: current_mode = tr("Shuffle tracks in this album"); break;
case PlaylistSequence::ShuffleMode::Albums: current_mode = tr("Shuffle albums"); break;
}
ShowMessage(app_name_, current_mode);
ShowMessage(QCoreApplication::applicationName(), current_mode);
}
}
@ -363,7 +358,7 @@ void OSDBase::RepeatModeChanged(const PlaylistSequence::RepeatMode mode) {
case PlaylistSequence::RepeatMode::OneByOne: current_mode = tr("Stop after every track"); break;
case PlaylistSequence::RepeatMode::Intro: current_mode = tr("Intro tracks"); break;
}
ShowMessage(app_name_, current_mode);
ShowMessage(QCoreApplication::applicationName(), current_mode);
}
}

View File

@ -53,8 +53,6 @@ class OSDBase : public QObject {
virtual bool SupportsNativeNotifications();
virtual bool SupportsTrayPopups();
QString app_name() { return app_name_; }
public Q_SLOTS:
void ReloadSettings();
@ -88,7 +86,6 @@ class OSDBase : public QObject {
const SharedPtr<SystemTrayIcon> tray_icon_;
OSDPretty *pretty_popup_;
QString app_name_;
int timeout_msec_;
OSDSettings::Type type_;
bool show_on_volume_change_;

View File

@ -170,7 +170,7 @@ void OSDDBus::ShowMessageNative(const QString &summary, const QString &message,
id = notification_id_;
}
QDBusPendingReply<uint> reply = interface_->Notify(app_name(), id, icon, summary_stripped, message, QStringList(), hints, timeout_msec());
QDBusPendingReply<uint> reply = interface_->Notify(QCoreApplication::applicationName(), id, icon, summary_stripped, message, QStringList(), hints, timeout_msec());
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &OSDDBus::CallFinished);

View File

@ -39,7 +39,6 @@ using namespace Qt::Literals::StringLiterals;
SystemTrayIcon::SystemTrayIcon(QObject *parent)
: QSystemTrayIcon(parent),
menu_(new QMenu),
app_name_(QCoreApplication::applicationName()),
pixmap_playing_(u":/pictures/tiny-play.png"_s),
pixmap_paused_(u":/pictures/tiny-pause.png"_s),
action_play_pause_(nullptr),
@ -51,8 +50,6 @@ SystemTrayIcon::SystemTrayIcon(QObject *parent)
trayicon_progress_(false),
song_progress_(0) {
app_name_[0] = app_name_[0].toUpper();
const QIcon icon = IconLoader::Load(u"strawberry"_s);
const QIcon icon_grey = IconLoader::Load(u"strawberry-grey"_s);
pixmap_normal_ = icon.pixmap(48, QIcon::Normal);
@ -66,7 +63,7 @@ SystemTrayIcon::SystemTrayIcon(QObject *parent)
if (isSystemTrayAvailable()) {
available_ = true;
setIcon(icon);
setToolTip(app_name_);
setToolTip(QCoreApplication::applicationName());
}
QObject::connect(this, &QSystemTrayIcon::activated, this, &SystemTrayIcon::Clicked);
@ -198,7 +195,7 @@ void SystemTrayIcon::SetNowPlaying(const Song &song, const QUrl &url) {
}
void SystemTrayIcon::ClearNowPlaying() {
if (available_) setToolTip(app_name_);
if (available_) setToolTip(QCoreApplication::applicationName());
}
void SystemTrayIcon::LoveVisibilityChanged(const bool value) {

View File

@ -82,7 +82,6 @@ class SystemTrayIcon : public QSystemTrayIcon {
private:
QMenu *menu_;
QString app_name_;
QPixmap pixmap_normal_;
QPixmap pixmap_grey_;
QPixmap pixmap_playing_;