Add cpp files for classes with only header files

This commit is contained in:
Jonas Kvinge
2024-08-12 00:48:16 +02:00
parent 1ebcd61a75
commit f624b7a331
19 changed files with 317 additions and 47 deletions

44
src/core/mimedata.cpp Normal file
View File

@@ -0,0 +1,44 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <QString>
#include "mimedata.h"
MimeData::MimeData(const bool clear, const bool play_now, const bool enqueue, const bool enqueue_next_now, const bool open_in_new_playlist, QObject *parent)
: override_user_settings_(false),
clear_first_(clear),
play_now_(play_now),
enqueue_now_(enqueue),
enqueue_next_now_(enqueue_next_now),
open_in_new_playlist_(open_in_new_playlist),
name_for_new_playlist_(QString()),
from_doubleclick_(false) {
Q_UNUSED(parent);
}
QString MimeData::get_name_for_new_playlist() const {
return name_for_new_playlist_.isEmpty() ? tr("Playlist") : name_for_new_playlist_;
}

View File

@@ -2,6 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,9 +22,6 @@
#ifndef MIMEDATA_H
#define MIMEDATA_H
#include "config.h"
#include <QObject>
#include <QMimeData>
#include <QString>
@@ -31,15 +29,7 @@ class MimeData : public QMimeData {
Q_OBJECT
public:
explicit MimeData(const bool clear = false, const bool play_now = false, const bool enqueue = false, const bool enqueue_next_now = false, const bool open_in_new_playlist = false, QObject* = nullptr)
: override_user_settings_(false),
clear_first_(clear),
play_now_(play_now),
enqueue_now_(enqueue),
enqueue_next_now_(enqueue_next_now),
open_in_new_playlist_(open_in_new_playlist),
name_for_new_playlist_(QString()),
from_doubleclick_(false) {}
explicit MimeData(const bool clear = false, const bool play_now = false, const bool enqueue = false, const bool enqueue_next_now = false, const bool open_in_new_playlist = false, QObject *parent = nullptr);
// If this is set then MainWindow will not touch any of the other flags.
bool override_user_settings_;
@@ -69,9 +59,7 @@ class MimeData : public QMimeData {
// Returns a pretty name for a playlist containing songs described by this MimeData object.
// By pretty name we mean the value of 'name_for_new_playlist_' or generic "Playlist" string if the 'name_for_new_playlist_' attribute is empty.
QString get_name_for_new_playlist() {
return name_for_new_playlist_.isEmpty() ? tr("Playlist") : name_for_new_playlist_;
}
QString get_name_for_new_playlist() const;
};
#endif // MIMEDATA_H

34
src/core/potranslator.cpp Normal file
View File

@@ -0,0 +1,34 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <QString>
#include "potranslator.h"
PoTranslator::PoTranslator(QObject *parent) : QTranslator(parent) {}
QString PoTranslator::translate(const char *context, const char *source_text, const char *disambiguation, const int n) const {
QString ret = QTranslator::translate(context, source_text, disambiguation, n);
if (!ret.isEmpty()) return ret;
return QTranslator::translate(nullptr, source_text, disambiguation, n);
}

View File

@@ -2,6 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,6 +23,7 @@
#define POTRANSLATOR_H
#include <QTranslator>
#include <QString>
// We convert from .po files to .qm files, which loses context information.
// This translator tries loading strings with an empty context if it can't find any others.
@@ -30,12 +32,8 @@ class PoTranslator : public QTranslator {
Q_OBJECT
public:
PoTranslator(QObject *parent = nullptr) : QTranslator(parent) {}
QString translate(const char *context, const char *source_text, const char *disambiguation = nullptr, int n = -1) const override {
QString ret = QTranslator::translate(context, source_text, disambiguation, n);
if (!ret.isEmpty()) return ret;
return QTranslator::translate(nullptr, source_text, disambiguation, n);
}
explicit PoTranslator(QObject *parent = nullptr);
QString translate(const char *context, const char *source_text, const char *disambiguation = nullptr, int n = -1) const override;
};
#endif // POTRANSLATOR_H