1 
2 #include "codecproblems.h"
3 
4 #include <KLocale>
5 #include <KIcon>
6 #include <QLayout>
7 #include <QLabel>
8 #include <QScrollArea>
9 
10 
CodecProblems(Mode mode,const QList<Problem> & problemList,QWidget * parent,Qt::WFlags f)11 CodecProblems::CodecProblems( Mode mode, const QList<Problem>& problemList, QWidget* parent, Qt::WFlags f )
12     : KDialog( parent, f )
13 {
14     setCaption( i18n("Solutions for backend problems") );
15     setWindowIcon( KIcon("help-about") );
16     setButtons( KDialog::Close );
17     setButtonFocus( KDialog::Close );
18 
19     QWidget *widget = new QWidget( this );
20     setMainWidget( widget );
21     QVBoxLayout *box = new QVBoxLayout( widget );
22 
23     QString message;
24     if( mode == Debug )
25     {
26         if( problemList.isEmpty() )
27         {
28             message = i18n("soundKonverter couldn't find any missing packages.\nIf you are missing some file formats you might need to install an additional plugin via the package manager of your distribution.");
29         }
30         else
31         {
32             message = i18n("Some of the installed plugins aren't working.\nPossible solutions are listed below.");
33         }
34     }
35     else if( mode == Decode )
36     {
37         message = i18n("Some files can't be decoded.\nPossible solutions are listed below.");
38     }
39     else if( mode == ReplayGain )
40     {
41         message = i18n("Replay Gain isn't supported for some files.\nPossible solutions are listed below.");
42     }
43     else if( mode == AudioCd )
44     {
45         if( problemList.isEmpty() )
46         {
47             message = i18n("Ripping audio CDs is not supported by any installed plugin.\nPlease have a look at your distributions package manager in order to get a cd ripper plugin for soundKonverter.");
48         }
49         else
50         {
51             message = i18n("Ripping audio CDs is currently not supported because of missing backends.\nPossible solutions are listed below.");
52         }
53     }
54     QLabel *messageLabel = new QLabel( message, this );
55     box->addWidget( messageLabel );
56 
57     if( !problemList.isEmpty() )
58     {
59         QStringList messageList;
60         for( int i=0; i<problemList.count(); i++ )
61         {
62             const QString codecName = problemList.at(i).codecName;
63             if( codecName != "wav" )
64             {
65                 if( problemList.at(i).affectedFiles.isEmpty() )
66                 {
67                     messageList += "<b>" + i18n("Possible solutions for %1", codecName) + "</b>:\n" + problemList.at(i).solutions.join("\n<b>"+i18nc("like in either or","or")+"</b>\n");
68                 }
69                 else
70                 {
71                     messageList += "<b>" + i18n("Possible solutions for %1", codecName) + "</b>:\n" + problemList.at(i).solutions.join("\n<b>"+i18nc("like in either or","or")+"</b>\n") + "\n\n" + i18n("Affected files:") + "\n" + problemList.at(i).affectedFiles.join("\n");
72                 }
73             }
74         }
75         QLabel *solutionsLabel = new QLabel( messageList.join("\n\n").replace("\n","<br>"), this );
76         solutionsLabel->setMargin( 8 );
77         solutionsLabel->setWordWrap( true );
78         solutionsLabel->setTextInteractionFlags( Qt::TextSelectableByMouse );
79 
80         QScrollArea *solutionsScrollArea = new QScrollArea();
81         solutionsScrollArea->setWidget( solutionsLabel );
82         box->addWidget( solutionsScrollArea );
83     }
84 }
85 
~CodecProblems()86 CodecProblems::~CodecProblems()
87 {}
88 
89