You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kaffeine/kaffeine/src/player-parts/libmpv-part/libmpv_errordlg.cpp

114 lines
3.7 KiB

/*
* Kaffeine libmpv part
* Copyright (C) 2023 Mavridis Philippe <mavridisf@gmail.com>
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
// TQt
#include <tqhbox.h>
#include <tqlabel.h>
// TDE
#include <kiconloader.h>
#include <tdeglobal.h>
#include <tdelocale.h>
// Part
#include "libmpv_part.h"
#include "libmpv_errordlg.h"
/******************************/
/***** Error Dialog *****/
/******************************/
MpvErrorDlg::MpvErrorDlg(MpvPart *part)
: KDialogBase(0, 0, true, i18n("Error"),
KDialogBase::User1 | KDialogBase::User2 | KDialogBase::User3,
KDialogBase::User1, false,
KGuiItem(i18n("Ignore"), "media-playback-start", i18n("Ignore error and continue playback")),
KGuiItem(i18n("Stop"), "media-playback-stop", i18n("Stop playback")),
KGuiItem(i18n("View Log"), "text-x-log", i18n("Pause playback and view event log"))),
m_part(part)
{
Q_ASSERT(m_part);
TQHBox *hbox = makeHBoxMainWidget();
TQLabel *errorPix = new TQLabel(hbox);
errorPix->setPixmap(TDEGlobal::iconLoader()->loadIcon("messagebox_warning",
TDEIcon::NoGroup, TDEIcon::SizeMedium, TDEIcon::DefaultState));
TQLabel *errorMsg = new TQLabel(i18n("An error has occurred, but Kaffeine can continue playing the current file.\n"
"You can view the event log to check for details."), hbox);
errorMsg->setAlignment(TQt::AlignLeft | TQt::AlignTop);
m_part->slotPause(true);
}
MpvErrorDlg::~MpvErrorDlg() {
}
/*** Ignore error and continue playback ***/
void MpvErrorDlg::slotUser1() {
m_part->slotPlay();
accept();
}
/*** Stop playback ***/
void MpvErrorDlg::slotUser2() {
m_part->slotStop();
accept();
}
/*** Pause playback and view event log ***/
void MpvErrorDlg::slotUser3() {
m_part->slotViewLog();
accept();
}
/******************************/
/***** Fatal Error Dialog *****/
/******************************/
MpvFatalErrorDlg::MpvFatalErrorDlg(MpvPart *part)
: KDialogBase(0, 0, true, i18n("Fatal Error"),
KDialogBase::User1 | KDialogBase::User2,
KDialogBase::User1, false,
KGuiItem(i18n("Stop"), "media-playback-stop", i18n("Stop playback")),
KGuiItem(i18n("View Log"), "text-x-log", i18n("Stop playback and view event log"))),
m_part(part)
{
TQHBox *hbox = makeHBoxMainWidget();
TQLabel *errorPix = new TQLabel(hbox);
errorPix->setPixmap(TDEGlobal::iconLoader()->loadIcon("messagebox_critical",
TDEIcon::NoGroup, TDEIcon::SizeMedium, TDEIcon::DefaultState));
TQLabel *errorMsg = new TQLabel(i18n("A fatal error has occurred and Kaffeine cannot continue playback."), hbox);
errorMsg->setAlignment(TQt::AlignLeft | TQt::AlignTop);
m_part->slotStop();
}
MpvFatalErrorDlg::~MpvFatalErrorDlg() {
}
/*** Stop playback ***/
void MpvFatalErrorDlg::slotUser1() {
accept(); // already stopped
}
/*** Stop playback and view event log ***/
void MpvFatalErrorDlg::slotUser2() {
m_part->slotViewLog();
accept(); // already stopped
}