summaryrefslogtreecommitdiff
path: root/noncore/settings/appearance2/editScheme.cpp
authorsandman <sandman>2002-09-24 23:53:23 (UTC)
committer sandman <sandman>2002-09-24 23:53:23 (UTC)
commit5ae62a1def1d21c4827560607b208033d6054ed0 (patch) (unidiff)
tree445b34a539ec9f377d36ba9fb1587c72dafa46b0 /noncore/settings/appearance2/editScheme.cpp
parenta390040768072b4b2b931ec0bcdaaa55daae0b4c (diff)
downloadopie-5ae62a1def1d21c4827560607b208033d6054ed0.zip
opie-5ae62a1def1d21c4827560607b208033d6054ed0.tar.gz
opie-5ae62a1def1d21c4827560607b208033d6054ed0.tar.bz2
- updated all copyright headers
- use new OColorButton - rearranged editScheme a bit
Diffstat (limited to 'noncore/settings/appearance2/editScheme.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/appearance2/editScheme.cpp116
1 files changed, 51 insertions, 65 deletions
diff --git a/noncore/settings/appearance2/editScheme.cpp b/noncore/settings/appearance2/editScheme.cpp
index 4f2ac2c..8cb0f1c 100644
--- a/noncore/settings/appearance2/editScheme.cpp
+++ b/noncore/settings/appearance2/editScheme.cpp
@@ -1,25 +1,34 @@
1/********************************************************************** 1/*
2** EditScheme 2               =. This file is part of the OPIE Project
3** 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4** Dialog for editing color scheme 4           .>+-=
5** 5 _;:,     .>    :=|. This library is free software; you can
6** Copyright (C) 2002, Dan Williams 6.> <`_,   >  .   <= redistribute it and/or modify it under
7** williamsdr@acm.org 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8** http://draknor.net 8.="- .-=="i,     .._ License as published by the Free Software
9** 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10** This file may be distributed and/or modified under the terms of the 10     ._= =}       : or (at your option) any later version.
11** GNU General Public License version 2 as published by the Free Software 11    .%`+i>       _;_.
12** Foundation and appearing in the file LICENSE.GPL included in the 12    .i_,=:_.      -<s. This library is distributed in the hope that
13** packaging of this file. 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14** 14    : ..    .:,     . . . without even the implied warranty of
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17** 17..}^=.=       =       ; Library General Public License for more
18**********************************************************************/ 18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
19 28
20#include "editScheme.h" 29#include "editScheme.h"
21 30
22#include "opie/colorpopupmenu.h" 31#include <opie/ocolorbutton.h>
23 32
24#include <qaction.h> 33#include <qaction.h>
25#include <qlabel.h> 34#include <qlabel.h>
@@ -28,60 +37,37 @@
28#include <qscrollview.h> 37#include <qscrollview.h>
29#include <qtoolbutton.h> 38#include <qtoolbutton.h>
30 39
31EditScheme::EditScheme( QWidget* parent, const char* name, bool modal, WFlags fl, 40EditScheme::EditScheme ( int cnt, const QString *labels, QColor *colors, QWidget* parent, const char* name, bool modal, WFlags fl )
32 int max, QString *list, QString *colors ) 41 : QDialog ( parent, name, modal, fl )
33 : QDialog( parent, name, modal, fl )
34{ 42{
35 setCaption( tr( "Edit scheme" ) ); 43 setCaption ( tr( "Edit scheme" ) );
36 QGridLayout* layout = new QGridLayout( this ); 44 QGridLayout *layout = new QGridLayout ( this, 0, 0, 4, 4 );
37 layout->setSpacing( 4 );
38 layout->setMargin( 4 );
39
40 45
41 maxCount = max; 46 m_count = cnt;
42 colorList = colors; 47 m_buttons = new OColorButton * [cnt];
43 surfaceList = list; 48 m_colors = colors;
44 colorButtons = new QToolButton * [max]; 49
45 int i; 50 for ( int i = 0; i < cnt; i++ )
46 QLabel* label;
47 ColorPopupMenu* colorPopupMenu;
48 for ( i = 0; i < max; i++ )
49 { 51 {
50// colorList[i] = colors[i]; 52 QLabel *l = new QLabel ( labels [i], this );
51// surfaceList[i] = list[i]; 53 layout-> addWidget ( l, i, 0 );
52 label = new QLabel( tr( surfaceList[i] ), this ); 54
53 layout->addWidget( label, i, 0 ); 55 m_buttons [i] = new OColorButton ( this );
54 colorButtons[i] = new QToolButton( this, list[i] ); 56 m_buttons [i]-> setColor ( colors [i] );
55 colorButtons[i]->setPalette( QPalette( QColor( colors[i] ) ) ); 57 layout-> addWidget ( m_buttons [i], i, 1 );
56 layout->addWidget( colorButtons[i], i, 1 );
57
58 colorPopupMenu = new ColorPopupMenu( colors[i], 0, list[i] );
59 colorButtons[i]->setPopup( colorPopupMenu );
60 colorButtons[i]->setPopupDelay( 0 );
61 connect( colorPopupMenu, SIGNAL( colorSelected( const QColor& ) ), this, SLOT( changeColor( const QColor& ) ) );
62 } 58 }
63} 59}
64 60
65EditScheme::~EditScheme() 61EditScheme::~EditScheme ( )
66{ 62{
67 delete [] colorButtons; 63 delete [] m_buttons;
68} 64}
69 65
70void EditScheme::changeColor( const QColor& color ) 66void EditScheme::accept ( )
71{ 67{
72 QString name( sender()->name() ); 68 for ( int i = 0; i < m_count; i++ )
73 int i; 69 m_colors [i] = m_buttons [i]-> color ( );
74 70
75 for ( i = 0; i < maxCount; i++ ) 71 QDialog::accept ( );
76 {
77 if ( name == colorButtons[i]->name() )
78 {
79 break;
80 }
81 }
82 if ( i < maxCount && name == colorButtons[i]->name() )
83 {
84 colorList[i] = color.name();
85 colorButtons[i]->setPalette( QPalette( QColor( colorList[i] ) ) );
86 }
87} 72}
73