summaryrefslogtreecommitdiffstats
path: root/kipi-plugins/ipodexport/ipodheader.cpp
blob: 9fbf092074d4ace7fd155b3c6c5f869d8f3b5bd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/***************************************************************************
 * copyright            : (C) 2006 Seb Ruiz <me@sebruiz.net>               *
 **************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#include "ipodheader.h"
#include "ipodexportdialog.h"

#include "klocale.h"
#include "kpushbutton.h"

#include "tqlabel.h"
#include "tqlayout.h"

using namespace IpodExport;

IpodHeader::IpodHeader( TQWidget *parent, const char *name, WFlags f )
    : TQFrame( parent, name, f )
{
    TQVBoxLayout *tqlayout = new TQVBoxLayout( this, 10/*margin*/, 5/*spacing*/ );

    tqsetSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Minimum );

    m_messageLabel = new TQLabel( TQString(), this );
    m_messageLabel->tqsetSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Minimum );

    TQHBoxLayout *buttonLayout = new TQHBoxLayout;
    m_button = new KPushButton( this );
    m_button->hide();

    buttonLayout->addStretch( 1 );
    buttonLayout->addWidget( m_button );
    buttonLayout->addStretch( 1 );

    tqlayout->addWidget( m_messageLabel );
    tqlayout->addLayout( buttonLayout );
}

void IpodHeader::setViewType( ViewType view )
{
    m_viewType = view;

    switch( view )
    {
        case NoIpod:
            setNoIpod();
            break;

        case IncompatibleIpod:
            setIncompatibleIpod();
            break;

        case ValidIpod:
            setValidIpod();
            break;

        default:
            break;
    }
}

void IpodHeader::setNoIpod()
{
    m_messageLabel->setText( i18n("<p align=\"center\"><b>No iPod was detected</b></p>" ) );

    setPaletteBackgroundColor( TQColor(147,18,18) );
    m_messageLabel->setPaletteBackgroundColor( TQColor(147,18,18) );
    m_messageLabel->setPaletteForegroundColor( TQt::white );

    m_button->setText( i18n( "Refresh" ) );
    m_button->show();

    m_button->disconnect();
    connect( m_button, TQT_SIGNAL( clicked() ), TQT_SIGNAL( refreshDevices() ) );
}

void IpodHeader::setIncompatibleIpod()
{
    const TQString modelType = UploadDialog::instance()->ipodModel();

    m_messageLabel->setText( i18n("<p align=\"center\"><b>Your iPod (%1) does not seem to support artwork.</b></p>" ).tqarg( modelType ) );

    setPaletteBackgroundColor( TQColor(225,150,0) );
    m_messageLabel->setPaletteBackgroundColor( TQColor(225,150,0)  );
    m_messageLabel->setPaletteForegroundColor( TQt::white );

    m_button->setText( i18n( "Set iPod Model" ) );
//     m_button->show();
    m_button->hide(); // FIXME its not implemented!

    m_button->disconnect();
    connect( m_button, TQT_SIGNAL( clicked() ), TQT_SIGNAL( updateSysInfo() ) );
}


void IpodHeader::setValidIpod()
{
    const TQString modelType  = UploadDialog::instance()->ipodModel();
    const TQString mountPoint = UploadDialog::instance()->mountPoint();

    if( !mountPoint.isEmpty() )
    {
        m_messageLabel->setText( i18n("<p align=\"center\"><b>iPod %1 detected at: %2</b></p>" )
                                 .tqarg( modelType, mountPoint ) );
    }
    else
    {
        m_messageLabel->setText( i18n("<p align=\"center\"><b>iPod %1 detected</b></p>" )
                                .tqarg( modelType ) );
    }
    setPaletteBackgroundColor( TQColor(0,98,0) );
    m_messageLabel->setPaletteBackgroundColor( TQColor(0,98,0) );
    m_messageLabel->setPaletteForegroundColor( TQt::white );

    m_button->hide();
}