~ubuntu-branches/ubuntu/quantal/kscd/quantal-proposed

« back to all changes in this revision

Viewing changes to gui/randombutton.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-06-14 17:35:46 UTC
  • Revision ID: package-import@ubuntu.com-20120614173546-0t4dq1zkvl62ebpd
Tags: upstream-4.8.90+repack
Import upstream version 4.8.90+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Kscd - A simple cd player for the KDE Project
 
3
 *
 
4
 * Copyright (c) 1997 Bernd Johannes wuebben@math.cornell.edu
 
5
 * Copyright (c) 2002-2003 Aaron J. Seigo <aseigo@kde.org>
 
6
 * Copyright (c) 2004 Alexander Kern <alex.kern@gmx.de>
 
7
 * Copyright (c) 2003-2006 Richard Lärkäng <nouseforaname@home.se>
 
8
 *
 
9
 * --------------
 
10
 * ISI KsCD Team :
 
11
 * --------------
 
12
 * Stanislas KRZYWDA <stanislas.krzywda@gmail.com>
 
13
 * Sovanramy Var <mastasushi@gmail.com>
 
14
 * Bouchikhi Mohamed-Amine <bouchikhi.amine@gmail.com>
 
15
 * Gastellu Sylvain<sylvain.gastellu@gmail.com>
 
16
 * -----------------------------------------------------------------------------
 
17
 *
 
18
 * This program is free software; you can redistribute it and/or modify
 
19
 * it under the terms of the GNU General Public License as published by
 
20
 * the Free Software Foundation; either version 2, or (at your option)
 
21
 * any later version.
 
22
 *
 
23
 * This program is distributed in the hope that it will be useful,
 
24
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
26
 * GNU General Public License for more details.
 
27
 *
 
28
 * You should have received a copy of the GNU General Public License
 
29
 * along with this program; if not, write to the Free Software
 
30
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
31
 *
 
32
 */
 
33
#include "randombutton.h"
 
34
#include <KLocale>
 
35
 
 
36
RandomButton::RandomButton(QWidget * parent):KscdWidget(I18N_NOOP(QLatin1String( "random" )),parent)
 
37
{
 
38
}
 
39
 
 
40
RandomButton::~RandomButton()
 
41
{
 
42
}
 
43
 
 
44
void RandomButton::mousePressEvent(QMouseEvent *event)
 
45
{
 
46
        if(m_bounds->contains(event->pos()+(m_bounds->boundingRect()).topLeft()))
 
47
        {
 
48
                event->accept();
 
49
                m_state = QLatin1String( "pressed" );
 
50
                if(m_name== QLatin1String( "random" ))
 
51
                {
 
52
                        m_id = m_name + QLatin1Char( '_' ) + m_state;
 
53
                        emit(needRepaint());
 
54
                }
 
55
                else
 
56
                {
 
57
                        event->ignore();
 
58
                }
 
59
        }
 
60
        else
 
61
        {
 
62
                event->ignore();
 
63
        }
 
64
}
 
65
 
 
66
void RandomButton::mouseReleaseEvent(QMouseEvent *event)
 
67
{
 
68
        if(m_bounds->contains(event->pos()+(m_bounds->boundingRect()).topLeft()))
 
69
        {
 
70
                event->accept();
 
71
                m_state = QLatin1String( "over" );
 
72
                if(m_name==QLatin1String( "random" ))
 
73
                {
 
74
                        kDebug() << "1" ;
 
75
                        m_name = QLatin1String( "p_random" );
 
76
                }
 
77
                else
 
78
                {
 
79
                        kDebug() << "2" ;
 
80
                        m_name = QLatin1String( "random" );
 
81
                }
 
82
                kDebug() << m_name ;
 
83
                m_id = m_name + QLatin1Char( '_' ) + m_state;
 
84
                emit(buttonClicked(m_name));
 
85
        }
 
86
        else
 
87
        {
 
88
                event->ignore();
 
89
        }
 
90
}
 
91
 
 
92
void RandomButton::enterEvent (QEvent * event )
 
93
{
 
94
        if(m_name == QLatin1String( "p_random" ))
 
95
        {
 
96
                event->ignore();
 
97
        }
 
98
        else
 
99
        {
 
100
                event->accept();
 
101
                m_state = QLatin1String( "over" );
 
102
                m_id = m_name + QLatin1Char( '_' ) + m_state;
 
103
                emit(needRepaint());
 
104
                setToolTip( i18n( qPrintable( m_name ) ) );
 
105
        }
 
106
}
 
107
 
 
108
void RandomButton::leaveEvent (QEvent * event )
 
109
{
 
110
        if(m_name == QLatin1String( "p_random" ))
 
111
        {
 
112
                event->ignore();
 
113
        }
 
114
        else
 
115
        {
 
116
                event->accept();
 
117
                m_state = QLatin1String( "default" );
 
118
                m_id = m_name + QLatin1Char( '_' ) + m_state;
 
119
                emit(needRepaint());
 
120
        }
 
121
}