Fix the command line options when another instance is running
This commit is contained in:
parent
c5ff9edc40
commit
f5cd85c6de
|
@ -301,11 +301,11 @@ QByteArray CommandlineOptions::Serialize() const {
|
||||||
s << *this;
|
s << *this;
|
||||||
buf.close();
|
buf.close();
|
||||||
|
|
||||||
return buf.data();
|
return buf.data().toBase64();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandlineOptions::Load(const QByteArray& serialized) {
|
void CommandlineOptions::Load(const QByteArray& serialized) {
|
||||||
QByteArray copy(serialized);
|
QByteArray copy = QByteArray::fromBase64(serialized);
|
||||||
QBuffer buf(©);
|
QBuffer buf(©);
|
||||||
buf.open(QIODevice::ReadOnly);
|
buf.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ class CommandlineOptions {
|
||||||
friend QDataStream& operator>>(QDataStream& s, CommandlineOptions& a);
|
friend QDataStream& operator>>(QDataStream& s, CommandlineOptions& a);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CommandlineOptions(int argc = 0, char* *argv = nullptr);
|
explicit CommandlineOptions(int argc = 0, char** argv = nullptr);
|
||||||
|
|
||||||
static const char* kHelpText;
|
static const char* kHelpText;
|
||||||
static const char* kVersionText;
|
static const char* kVersionText;
|
||||||
|
|
|
@ -111,7 +111,6 @@ namespace {
|
||||||
|
|
||||||
void LoadTranslation(const QString& prefix, const QString& path,
|
void LoadTranslation(const QString& prefix, const QString& path,
|
||||||
const QString& language) {
|
const QString& language) {
|
||||||
|
|
||||||
QTranslator* t = new PoTranslator;
|
QTranslator* t = new PoTranslator;
|
||||||
if (t->load(prefix + "_" + language, path))
|
if (t->load(prefix + "_" + language, path))
|
||||||
QCoreApplication::installTranslator(t);
|
QCoreApplication::installTranslator(t);
|
||||||
|
@ -349,7 +348,8 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
a.setQuitOnLastWindowClosed(false);
|
a.setQuitOnLastWindowClosed(false);
|
||||||
// Do this check again because another instance might have started by now
|
// Do this check again because another instance might have started by now
|
||||||
if (a.isRunning() && a.sendMessage(options.Serialize(), 5000)) {
|
if (a.isRunning() &&
|
||||||
|
a.sendMessage(QString::fromLatin1(options.Serialize()), 5000)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,8 +390,8 @@ int main(int argc, char* argv[]) {
|
||||||
// Add root CA cert for SoundCloud, whose certificate is missing on OS X.
|
// Add root CA cert for SoundCloud, whose certificate is missing on OS X.
|
||||||
QSslSocket::addDefaultCaCertificates(
|
QSslSocket::addDefaultCaCertificates(
|
||||||
QSslCertificate::fromPath(":/soundcloud-ca.pem", QSsl::Pem));
|
QSslCertificate::fromPath(":/soundcloud-ca.pem", QSsl::Pem));
|
||||||
QSslSocket::addDefaultCaCertificates(
|
QSslSocket::addDefaultCaCertificates(QSslCertificate::fromPath(
|
||||||
QSslCertificate::fromPath(":/Equifax_Secure_Certificate_Authority.pem", QSsl::Pem));
|
":/Equifax_Secure_Certificate_Authority.pem", QSsl::Pem));
|
||||||
|
|
||||||
// Has the user forced a different language?
|
// Has the user forced a different language?
|
||||||
QString override_language = options.language();
|
QString override_language = options.language();
|
||||||
|
|
|
@ -2045,15 +2045,9 @@ void MainWindow::PlaylistEditFinished(const QModelIndex& index) {
|
||||||
if (index == playlist_menu_index_) SelectionSetValue();
|
if (index == playlist_menu_index_) SelectionSetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::CommandlineOptionsReceived(
|
void MainWindow::CommandlineOptionsReceived(const QString& string_options) {
|
||||||
const QString& serialized_options) {
|
|
||||||
if (serialized_options == "wake up!") {
|
|
||||||
// Old versions of Clementine sent this - just ignore it
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandlineOptions options;
|
CommandlineOptions options;
|
||||||
options.Load(serialized_options.toLatin1());
|
options.Load(string_options.toLatin1());
|
||||||
|
|
||||||
if (options.is_empty()) {
|
if (options.is_empty()) {
|
||||||
show();
|
show();
|
||||||
|
|
|
@ -240,7 +240,7 @@ signals:
|
||||||
void AddCDTracks();
|
void AddCDTracks();
|
||||||
void AddPodcast();
|
void AddPodcast();
|
||||||
|
|
||||||
void CommandlineOptionsReceived(const QString &serialized_options);
|
void CommandlineOptionsReceived(const QString& string_options);
|
||||||
|
|
||||||
void CheckForUpdates();
|
void CheckForUpdates();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue