summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/colorpopupmenu.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/libopie/colorpopupmenu.cpp b/libopie/colorpopupmenu.cpp
index dac10e9..5a8d77e 100644
--- a/libopie/colorpopupmenu.cpp
+++ b/libopie/colorpopupmenu.cpp
@@ -44,127 +44,130 @@ OColorPanelButton::OColorPanelButton( const QColor& color, QWidget* parent, cons
44 44
45 setFixedSize( 16, 16 ); 45 setFixedSize( 16, 16 );
46 setActive( FALSE ); 46 setActive( FALSE );
47} 47}
48 48
49OColorPanelButton::~OColorPanelButton() 49OColorPanelButton::~OColorPanelButton()
50{ 50{
51} 51}
52 52
53void OColorPanelButton::setActive( bool active ) 53void OColorPanelButton::setActive( bool active )
54{ 54{
55 m_active = active; 55 m_active = active;
56 56
57 if ( m_active ) { 57 if ( m_active ) {
58 setFrameStyle( Panel | Sunken ); 58 setFrameStyle( Panel | Sunken );
59 } else { 59 } else {
60 setFrameStyle( NoFrame ); 60 setFrameStyle( NoFrame );
61 } 61 }
62} 62}
63 63
64void OColorPanelButton::enterEvent( QEvent* ) 64void OColorPanelButton::enterEvent( QEvent* )
65{ 65{
66 if ( !m_active ) { 66 if ( !m_active ) {
67 setFrameStyle( Panel | Sunken ); 67 setFrameStyle( Panel | Sunken );
68 } 68 }
69} 69}
70 70
71void OColorPanelButton::leaveEvent( QEvent* ) 71void OColorPanelButton::leaveEvent( QEvent* )
72{ 72{
73 if ( !m_active ) { 73 if ( !m_active ) {
74 setFrameStyle( NoFrame ); 74 setFrameStyle( NoFrame );
75 } 75 }
76} 76}
77 77
78void OColorPanelButton::paintEvent( QPaintEvent* e ) 78void OColorPanelButton::paintEvent( QPaintEvent* e )
79{ 79{
80 QFrame::paintEvent( e ); 80 QFrame::paintEvent( e );
81 81
82 QPainter painter; 82 QPainter painter;
83 painter.begin( this ); 83 painter.begin( this );
84 painter.fillRect( 2, 2, 12, 12, m_color ); 84 painter.fillRect( 2, 2, 12, 12, m_color );
85 painter.setPen( Qt::black ); 85 painter.setPen( Qt::black );
86 painter.drawRect( 2, 2, 12, 12 ); 86 painter.drawRect( 2, 2, 12, 12 );
87 painter.end(); 87 painter.end();
88} 88}
89 89
90void OColorPanelButton::mouseReleaseEvent( QMouseEvent* ) 90void OColorPanelButton::mouseReleaseEvent( QMouseEvent* )
91{ 91{
92 emit selected( m_color ); 92 emit selected( m_color );
93} 93}
94 94
95OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name ) 95OColorPopupMenu::OColorPopupMenu( const QColor& color, QWidget* parent, const char* name )
96 : QPopupMenu( parent, name ) 96 : QPopupMenu( parent, name )
97{ 97{
98 m_color = color; 98 m_color = color;
99 99
100 colorPanel = new QWidget( this ); 100 colorPanel = new QWidget( this );
101 101
102 colorLayout = new QGridLayout(colorPanel, 5, 6); 102 colorLayout = new QGridLayout(colorPanel, 5, 6);
103 103
104 addColor(QColor(255, 255, 255), 0, 1); 104 addColor(QColor(255, 255, 255), 0, 1);
105 addColor(QColor(192, 192, 192), 0, 2); 105 addColor(QColor(192, 192, 192), 0, 2);
106 addColor(QColor(128, 128, 128), 0, 3); 106 addColor(QColor(128, 128, 128), 0, 3);
107 addColor(QColor(64, 64, 64), 0, 4); 107 addColor(QColor(64, 64, 64), 0, 4);
108 addColor(QColor(0, 0, 0), 0, 5); 108 addColor(QColor(0, 0, 0), 0, 5);
109 109
110 addColor(QColor(255, 0, 0), 1, 0); 110 addColor(QColor(255, 0, 0), 1, 0);
111 addColor(QColor(255, 128, 0), 1, 1); 111 addColor(QColor(255, 128, 0), 1, 1);
112 addColor(QColor(255, 255, 0), 1, 2); 112 addColor(QColor(255, 255, 0), 1, 2);
113 addColor(QColor(128, 255, 0), 1, 3); 113 addColor(QColor(128, 255, 0), 1, 3);
114 addColor(QColor(0, 255, 0), 1, 4); 114 addColor(QColor(0, 255, 0), 1, 4);
115 addColor(QColor(0, 255, 128), 1, 5); 115 addColor(QColor(0, 255, 128), 1, 5);
116 116
117 addColor(QColor(128, 0, 0), 2, 0); 117 addColor(QColor(128, 0, 0), 2, 0);
118 addColor(QColor(128, 64, 0), 2, 1); 118 addColor(QColor(128, 64, 0), 2, 1);
119 addColor(QColor(128, 128, 0), 2, 2); 119 addColor(QColor(128, 128, 0), 2, 2);
120 addColor(QColor(64, 128, 0), 2, 3); 120 addColor(QColor(64, 128, 0), 2, 3);
121 addColor(QColor(0, 128, 0), 2, 4); 121 addColor(QColor(0, 128, 0), 2, 4);
122 addColor(QColor(0, 128, 64), 2, 5); 122 addColor(QColor(0, 128, 64), 2, 5);
123 123
124 addColor(QColor(0, 255, 255), 3, 0); 124 addColor(QColor(0, 255, 255), 3, 0);
125 addColor(QColor(0, 128, 255), 3, 1); 125 addColor(QColor(0, 128, 255), 3, 1);
126 addColor(QColor(0, 0, 255), 3, 2); 126 addColor(QColor(0, 0, 255), 3, 2);
127 addColor(QColor(128, 0, 255), 3, 3); 127 addColor(QColor(128, 0, 255), 3, 3);
128 addColor(QColor(255, 0, 255), 3, 4); 128 addColor(QColor(255, 0, 255), 3, 4);
129 addColor(QColor(255, 0, 128), 3, 5); 129 addColor(QColor(255, 0, 128), 3, 5);
130 130
131 addColor(QColor(0, 128, 128), 4, 0); 131 addColor(QColor(0, 128, 128), 4, 0);
132 addColor(QColor(0, 64, 128), 4, 1); 132 addColor(QColor(0, 64, 128), 4, 1);
133 addColor(QColor(0, 0, 128), 4, 2); 133 addColor(QColor(0, 0, 128), 4, 2);
134 addColor(QColor(64, 0, 128), 4, 3); 134 addColor(QColor(64, 0, 128), 4, 3);
135 addColor(QColor(128, 0, 128), 4, 4); 135 addColor(QColor(128, 0, 128), 4, 4);
136 addColor(QColor(128, 0, 64), 4, 5); 136 addColor(QColor(128, 0, 64), 4, 5);
137 137
138 insertItem( colorPanel ); 138 insertItem( colorPanel );
139 insertSeparator(); 139 insertSeparator();
140 insertItem(tr("More"),this,SLOT( moreColorClicked()));
141 /*
140 QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" ); 142 QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" );
141 connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) ); 143 connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) );
142 chooseColorAction->addTo( this ); 144 chooseColorAction->addTo( this );
145 */
143 activateItemAt( 0 ); 146 activateItemAt( 0 );
144} 147}
145 148
146OColorPopupMenu::~OColorPopupMenu() 149OColorPopupMenu::~OColorPopupMenu()
147{ 150{
148} 151}
149 152
150void OColorPopupMenu::addColor( const QColor& color, int row, int col ) 153void OColorPopupMenu::addColor( const QColor& color, int row, int col )
151{ 154{
152 OColorPanelButton* panelButton = new OColorPanelButton( color, colorPanel ); 155 OColorPanelButton* panelButton = new OColorPanelButton( color, colorPanel );
153 connect( panelButton, SIGNAL( selected( const QColor& ) ), this, SLOT( buttonSelected( const QColor& ) ) ); 156 connect( panelButton, SIGNAL( selected( const QColor& ) ), this, SLOT( buttonSelected( const QColor& ) ) );
154 colorLayout->addWidget( panelButton, row, col ); 157 colorLayout->addWidget( panelButton, row, col );
155} 158}
156 159
157void OColorPopupMenu::buttonSelected( const QColor& color ) 160void OColorPopupMenu::buttonSelected( const QColor& color )
158{ 161{
159 m_color = color; 162 m_color = color;
160 emit colorSelected( color ); 163 emit colorSelected( color );
161 hide(); 164 hide();
162} 165}
163 166
164void OColorPopupMenu::moreColorClicked() 167void OColorPopupMenu::moreColorClicked()
165{ 168{
166 QColor color = OColorDialog::getColor( m_color ); 169 QColor color = OColorDialog::getColor( m_color );
167 m_color = color; 170 m_color = color;
168 emit colorSelected( color ); 171 emit colorSelected( color );
169 hide(); 172 hide();
170} 173}