Diffstat (limited to 'noncore/settings/appearance2/editScheme.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/appearance2/editScheme.cpp | 104 |
1 files changed, 45 insertions, 59 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,24 +1,33 @@ | |||
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> |
@@ -29,35 +38,22 @@ | |||
29 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
30 | 39 | ||
31 | EditScheme::EditScheme( QWidget* parent, const char* name, bool modal, WFlags fl, | 40 | EditScheme::EditScheme ( int cnt, const QString *labels, QColor *colors, QWidget* parent, const char* name, bool modal, WFlags fl ) |
32 | int max, QString *list, QString *colors ) | ||
33 | : QDialog( parent, name, modal, fl ) | 41 | : 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 | 45 | ||
46 | m_count = cnt; | ||
47 | m_buttons = new OColorButton * [cnt]; | ||
48 | m_colors = colors; | ||
40 | 49 | ||
41 | maxCount = max; | 50 | for ( int i = 0; i < cnt; i++ ) |
42 | colorList = colors; | ||
43 | surfaceList = list; | ||
44 | colorButtons = new QToolButton * [max]; | ||
45 | int 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 ); | ||
53 | layout->addWidget( label, i, 0 ); | ||
54 | colorButtons[i] = new QToolButton( this, list[i] ); | ||
55 | colorButtons[i]->setPalette( QPalette( QColor( colors[i] ) ) ); | ||
56 | layout->addWidget( colorButtons[i], i, 1 ); | ||
57 | 54 | ||
58 | colorPopupMenu = new ColorPopupMenu( colors[i], 0, list[i] ); | 55 | m_buttons [i] = new OColorButton ( this ); |
59 | colorButtons[i]->setPopup( colorPopupMenu ); | 56 | m_buttons [i]-> setColor ( colors [i] ); |
60 | colorButtons[i]->setPopupDelay( 0 ); | 57 | layout-> addWidget ( m_buttons [i], i, 1 ); |
61 | connect( colorPopupMenu, SIGNAL( colorSelected( const QColor& ) ), this, SLOT( changeColor( const QColor& ) ) ); | ||
62 | } | 58 | } |
63 | } | 59 | } |
@@ -65,23 +61,13 @@ EditScheme::EditScheme( QWidget* parent, const char* name, bool modal, WFlags f | |||
65 | EditScheme::~EditScheme() | 61 | EditScheme::~EditScheme() |
66 | { | 62 | { |
67 | delete [] colorButtons; | 63 | delete [] m_buttons; |
68 | } | 64 | } |
69 | 65 | ||
70 | void EditScheme::changeColor( const QColor& color ) | 66 | void 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 | |||