root/trunk/qt4-gui/src/widgets/colorbutton.cpp

Revision 6081, 1.6 kB (checked in by flynd, 9 months ago)

Changed widget/colorbutton to use KColorButton when building for kde.

Line 
1/*
2 * This file is part of Licq, an instant messaging client for UNIX.
3 * Copyright (C) 2006 Licq developers
4 *
5 * Licq is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * Licq is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with Licq; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19
20#include "colorbutton.h"
21
22#ifndef USE_KDE
23#include <QColorDialog>
24#endif
25
26using namespace LicqQtGui;
27
28ColorButton::ColorButton(QWidget* parent)
29  : COLORBUTTON_BASE(parent)
30{
31#ifndef USE_KDE
32  setFixedSize(40, 20);
33  connect(this, SIGNAL(clicked()), SLOT(selectColor()));
34#endif
35}
36
37QString ColorButton::colorName() const
38{
39  return color().name();
40}
41
42#ifndef USE_KDE
43QColor ColorButton::color() const
44{
45  return palette().color(backgroundRole());
46}
47
48void ColorButton::selectColor()
49{
50  QColor color = QColorDialog::getColor(palette().color(backgroundRole()), this);
51  if (color.isValid())
52    setColor(color);
53}
54
55void ColorButton::setColor(const QColor& color)
56{
57  QPalette pal(palette());
58  pal.setColor(backgroundRole(), color);
59  setPalette(pal);
60  emit changed(color);
61}
62#endif
Note: See TracBrowser for help on using the browser.