diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 781c297b1..547bbb0f5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -184,6 +184,7 @@ set(SOURCES dialogs/userpassdialog.cpp dialogs/deleteconfirmationdialog.cpp dialogs/lastfmimportdialog.cpp + dialogs/snapdialog.cpp widgets/autoexpandingtreeview.cpp widgets/busyindicator.cpp @@ -399,6 +400,7 @@ set(HEADERS dialogs/userpassdialog.h dialogs/deleteconfirmationdialog.h dialogs/lastfmimportdialog.h + dialogs/snapdialog.h widgets/autoexpandingtreeview.h widgets/busyindicator.h @@ -513,6 +515,7 @@ set(UI dialogs/addstreamdialog.ui dialogs/userpassdialog.ui dialogs/lastfmimportdialog.ui + dialogs/snapdialog.ui widgets/trackslider.ui widgets/fileview.ui diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 0d8c3d83b..b47f10c42 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -104,6 +104,7 @@ #include "dialogs/addstreamdialog.h" #include "dialogs/deleteconfirmationdialog.h" #include "dialogs/lastfmimportdialog.h" +#include "dialogs/snapdialog.h" #include "organize/organizedialog.h" #include "widgets/fancytabwidget.h" #include "widgets/playingwidget.h" @@ -986,6 +987,18 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd } #endif +#ifdef Q_OS_LINUX + if (!Utilities::GetEnv("SNAP").isEmpty() && !Utilities::GetEnv("SNAP_NAME").isEmpty()) { + s.beginGroup(kSettingsGroup); + if (!s.value("ignore_snap", false).toBool()) { + SnapDialog *snap_dialog = new SnapDialog(); + snap_dialog->setAttribute(Qt::WA_DeleteOnClose); + snap_dialog->show(); + } + s.endGroup(); + } +#endif + qLog(Debug) << "Started" << QThread::currentThread(); initialized_ = true; diff --git a/src/dialogs/snapdialog.cpp b/src/dialogs/snapdialog.cpp new file mode 100644 index 000000000..19d328002 --- /dev/null +++ b/src/dialogs/snapdialog.cpp @@ -0,0 +1,87 @@ +/* + * Strawberry Music Player + * Copyright 2020, Jonas Kvinge + * + * 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 . + * + */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "snapdialog.h" +#include "ui_snapdialog.h" + +#include "core/mainwindow.h" + +SnapDialog::SnapDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_SnapDialog) { + + ui_->setupUi(this); + setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint); + setWindowTitle(tr("Strawberry is running as a Snap")); + + QString text; + text += QString("

"); + text += tr("It is detected that Strawberry is running as a Snap"); + text += QString("

"); + + text += QString("

"); + text += tr("Strawberry is slower, and has restrictions when running as a Snap. Accessing the root filesystem (/) will not work. There also might be other restrictions such as accessing certain devices or network shares."); + text += QString("

"); + + text += QString("

"); + text += QString("Strawberry is available natively in the official package repositories for Fedora, openSUSE, Mageia, Arch, Manjaro, MX Linux and most other popular Linux distributions."); + text += QString("

"); + + text += QString("

"); + text += tr("For Ubuntu there is an official PPA repository available at %1.").arg(QString("https://launchpad.net/~jonaski/+archive/ubuntu/strawberry").arg(palette().text().color().name())); + text += QString("

"); + + text += QString("

"); + text += tr("Official releases are available for Debian and Ubuntu which also work on most of their derivatives. See %1 for more information.").arg(QString("https://www.strawberrymusicplayer.org/").arg(palette().text().color().name())); + text += QString("

"); + + text += QString("

"); + text += tr("For a better experience please consider the other options above."); + text += QString("

"); + + text += QString("

"); + + ui_->label_text->setText(text); + ui_->label_text->adjustSize(); + + ui_->buttonBox->button(QDialogButtonBox::Ok)->setShortcut(QKeySequence::Close); + + connect(ui_->checkbox_do_not_show_message_again, SIGNAL(toggled(bool)), SLOT(DoNotShowMessageAgain())); + +} + +SnapDialog::~SnapDialog() { delete ui_; } + +void SnapDialog::DoNotShowMessageAgain() { + + QSettings s; + s.beginGroup(MainWindow::kSettingsGroup); + s.setValue("ignore_snap", ui_->checkbox_do_not_show_message_again->isChecked()); + s.endGroup(); + +} diff --git a/src/dialogs/snapdialog.h b/src/dialogs/snapdialog.h new file mode 100644 index 000000000..6632c15f0 --- /dev/null +++ b/src/dialogs/snapdialog.h @@ -0,0 +1,41 @@ +/* + * Strawberry Music Player + * Copyright 2020, Jonas Kvinge + * + * 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 . + * + */ + +#ifndef SNAPDIALOG_H +#define SNAPDIALOG_H + +#include + +class Ui_SnapDialog; + +class SnapDialog : public QDialog { + Q_OBJECT + + public: + explicit SnapDialog(QWidget *parent = nullptr); + ~SnapDialog() override; + + private slots: + void DoNotShowMessageAgain(); + + private: + Ui_SnapDialog *ui_; +}; + +#endif // SNAPDIALOG_H diff --git a/src/dialogs/snapdialog.ui b/src/dialogs/snapdialog.ui new file mode 100644 index 000000000..db0065f51 --- /dev/null +++ b/src/dialogs/snapdialog.ui @@ -0,0 +1,160 @@ + + + SnapDialog + + + + 0 + 0 + 600 + 300 + + + + Qt::StrongFocus + + + Strawberry is running as a snap + + + + :/icons/64x64/strawberry.png:/icons/64x64/strawberry.png + + + + QLayout::SetMinimumSize + + + + + QLayout::SetMinimumSize + + + + + + + + + + :/icons/64x64/dialog-warning.png + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + QLayout::SetMinimumSize + + + + + + 0 + 0 + + + + + + + true + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Do not show this message again. + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + + + + + + + + buttonBox + accepted() + SnapDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + SnapDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +