Diffstat (limited to 'kaddressbook/imagewidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/imagewidget.cpp | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index 49d456b..48370e3 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp | |||
@@ -86,100 +86,96 @@ ImageWidget::ImageWidget( QWidget *parent, const char *name ) | |||
86 | boxLayout->setRowStretch( 2, 1 ); | 86 | boxLayout->setRowStretch( 2, 1 ); |
87 | 87 | ||
88 | mLogoLabel = new QLabel( logoBox ); | 88 | mLogoLabel = new QLabel( logoBox ); |
89 | mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); | 89 | mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); |
90 | mLogoLabel->setScaledContents( true ); | 90 | mLogoLabel->setScaledContents( true ); |
91 | mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 91 | mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
92 | boxLayout->addMultiCellWidget( mLogoLabel, 0, 2, 0, 0 ); | 92 | boxLayout->addMultiCellWidget( mLogoLabel, 0, 2, 0, 0 ); |
93 | 93 | ||
94 | mLogoUrl = new KURLRequester( logoBox ); | 94 | mLogoUrl = new KURLRequester( logoBox ); |
95 | #ifndef KAB_EMBEDDED | 95 | #ifndef KAB_EMBEDDED |
96 | mLogoUrl->setFilter( KImageIO::pattern() ); | 96 | mLogoUrl->setFilter( KImageIO::pattern() ); |
97 | #else //KAB_EMBEDDED | 97 | #else //KAB_EMBEDDED |
98 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); | 98 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); |
99 | #endif //KAB_EMBEDDED | 99 | #endif //KAB_EMBEDDED |
100 | boxLayout->addWidget( mLogoUrl, 0, 1 ); | 100 | boxLayout->addWidget( mLogoUrl, 0, 1 ); |
101 | 101 | ||
102 | mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox ); | 102 | mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox ); |
103 | mUseLogoUrl->setEnabled( false ); | 103 | mUseLogoUrl->setEnabled( false ); |
104 | boxLayout->addWidget( mUseLogoUrl, 1, 1 ); | 104 | boxLayout->addWidget( mUseLogoUrl, 1, 1 ); |
105 | 105 | ||
106 | topLayout->addWidget( logoBox, 1, 0 ); | 106 | topLayout->addWidget( logoBox, 1, 0 ); |
107 | 107 | ||
108 | connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), | 108 | connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), |
109 | SIGNAL( changed() ) ); | 109 | SIGNAL( changed() ) ); |
110 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 110 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
111 | SLOT( loadPhoto() ) ); | 111 | SLOT( loadPhoto() ) ); |
112 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 112 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
113 | SIGNAL( changed() ) ); | 113 | SIGNAL( changed() ) ); |
114 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 114 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
115 | SLOT( updateGUI() ) ); | 115 | SLOT( updateGUI() ) ); |
116 | connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), | 116 | connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), |
117 | SIGNAL( changed() ) ); | 117 | SIGNAL( changed() ) ); |
118 | 118 | ||
119 | connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), | 119 | connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), |
120 | SIGNAL( changed() ) ); | 120 | SIGNAL( changed() ) ); |
121 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 121 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
122 | SLOT( loadLogo() ) ); | 122 | SLOT( loadLogo() ) ); |
123 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 123 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
124 | SIGNAL( changed() ) ); | 124 | SIGNAL( changed() ) ); |
125 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 125 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
126 | SLOT( updateGUI() ) ); | 126 | SLOT( updateGUI() ) ); |
127 | connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), | 127 | connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), |
128 | SIGNAL( changed() ) ); | 128 | SIGNAL( changed() ) ); |
129 | 129 | ||
130 | #ifndef KAB_EMBEDDED | 130 | #ifndef KAB_EMBEDDED |
131 | KAcceleratorManager::manage( this ); | 131 | KAcceleratorManager::manage( this ); |
132 | #endif //KAB_EMBEDDED | 132 | #endif //KAB_EMBEDDED |
133 | 133 | ||
134 | #ifndef DESKTOP_VERSION | ||
135 | mUsePhotoUrl->setChecked( true ); | ||
136 | mUseLogoUrl->setChecked( true ); | ||
137 | #endif | ||
138 | } | 134 | } |
139 | 135 | ||
140 | ImageWidget::~ImageWidget() | 136 | ImageWidget::~ImageWidget() |
141 | { | 137 | { |
142 | } | 138 | } |
143 | 139 | ||
144 | void ImageWidget::setPhoto( const KABC::Picture &photo ) | 140 | void ImageWidget::setPhoto( const KABC::Picture &photo ) |
145 | { | 141 | { |
146 | bool blocked = signalsBlocked(); | 142 | bool blocked = signalsBlocked(); |
147 | blockSignals( true ); | 143 | blockSignals( true ); |
148 | 144 | ||
149 | if ( photo.isIntern() ) { | 145 | if ( photo.isIntern() ) { |
150 | //US | 146 | //US |
151 | //US mPhotoLabel->setPixmap( photo.data() ); | 147 | //US mPhotoLabel->setPixmap( photo.data() ); |
152 | if (photo.data().isNull() != true) | 148 | if (photo.data().isNull() != true) |
153 | { | 149 | { |
154 | QPixmap pm; | 150 | QPixmap pm; |
155 | pm.convertFromImage(photo.data()); | 151 | pm.convertFromImage(photo.data()); |
156 | 152 | ||
157 | mPhotoLabel->setPixmap( pm ); | 153 | mPhotoLabel->setPixmap( pm ); |
158 | } | 154 | } |
159 | 155 | ||
160 | mUsePhotoUrl->setChecked( false ); | 156 | mUsePhotoUrl->setChecked( false ); |
161 | } else { | 157 | } else { |
162 | mPhotoUrl->setURL( photo.url() ); | 158 | mPhotoUrl->setURL( photo.url() ); |
163 | if ( !photo.url().isEmpty() ) | 159 | if ( !photo.url().isEmpty() ) |
164 | mUsePhotoUrl->setChecked( true ); | 160 | mUsePhotoUrl->setChecked( true ); |
165 | loadPhoto(); | 161 | loadPhoto(); |
166 | } | 162 | } |
167 | 163 | ||
168 | blockSignals( blocked ); | 164 | blockSignals( blocked ); |
169 | } | 165 | } |
170 | 166 | ||
171 | KABC::Picture ImageWidget::photo() const | 167 | KABC::Picture ImageWidget::photo() const |
172 | { | 168 | { |
173 | KABC::Picture photo; | 169 | KABC::Picture photo; |
174 | 170 | ||
175 | if ( mUsePhotoUrl->isChecked() ) | 171 | if ( mUsePhotoUrl->isChecked() ) |
176 | photo.setUrl( mPhotoUrl->url() ); | 172 | photo.setUrl( mPhotoUrl->url() ); |
177 | else { | 173 | else { |
178 | QPixmap *px = mPhotoLabel->pixmap(); | 174 | QPixmap *px = mPhotoLabel->pixmap(); |
179 | if ( px ) { | 175 | if ( px ) { |
180 | #ifndef KAB_EMBEDDED | 176 | #ifndef KAB_EMBEDDED |
181 | if ( px->height() > px->width() ) | 177 | if ( px->height() > px->width() ) |
182 | photo.setData( px->convertToImage().scaleHeight( 140 ) ); | 178 | photo.setData( px->convertToImage().scaleHeight( 140 ) ); |
183 | else | 179 | else |
184 | photo.setData( px->convertToImage().scaleWidth( 100 ) ); | 180 | photo.setData( px->convertToImage().scaleWidth( 100 ) ); |
185 | #else //KAB_EMBEDDED | 181 | #else //KAB_EMBEDDED |
@@ -215,85 +211,84 @@ void ImageWidget::setLogo( const KABC::Picture &logo ) | |||
215 | if ( !logo.url().isEmpty() ) | 211 | if ( !logo.url().isEmpty() ) |
216 | mUseLogoUrl->setChecked( true ); | 212 | mUseLogoUrl->setChecked( true ); |
217 | loadLogo(); | 213 | loadLogo(); |
218 | } | 214 | } |
219 | 215 | ||
220 | blockSignals( blocked ); | 216 | blockSignals( blocked ); |
221 | } | 217 | } |
222 | 218 | ||
223 | KABC::Picture ImageWidget::logo() const | 219 | KABC::Picture ImageWidget::logo() const |
224 | { | 220 | { |
225 | KABC::Picture logo; | 221 | KABC::Picture logo; |
226 | 222 | ||
227 | if ( mUseLogoUrl->isChecked() ) | 223 | if ( mUseLogoUrl->isChecked() ) |
228 | logo.setUrl( mLogoUrl->url() ); | 224 | logo.setUrl( mLogoUrl->url() ); |
229 | else { | 225 | else { |
230 | QPixmap *px = mLogoLabel->pixmap(); | 226 | QPixmap *px = mLogoLabel->pixmap(); |
231 | if ( px ) { | 227 | if ( px ) { |
232 | #ifndef KAB_EMBEDDED | 228 | #ifndef KAB_EMBEDDED |
233 | if ( px->height() > px->width() ) | 229 | if ( px->height() > px->width() ) |
234 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); | 230 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); |
235 | else | 231 | else |
236 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); | 232 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); |
237 | #else //KAB_EMBEDDED | 233 | #else //KAB_EMBEDDED |
238 | logo.setData( px->convertToImage() ); | 234 | logo.setData( px->convertToImage() ); |
239 | #endif //KAB_EMBEDDED | 235 | #endif //KAB_EMBEDDED |
240 | 236 | ||
241 | logo.setType( "PNG" ); | 237 | logo.setType( "PNG" ); |
242 | 238 | ||
243 | } | 239 | } |
244 | } | 240 | } |
245 | 241 | ||
246 | return logo; | 242 | return logo; |
247 | } | 243 | } |
248 | 244 | ||
249 | void ImageWidget::loadPhoto() | 245 | void ImageWidget::loadPhoto() |
250 | { | 246 | { |
251 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); | 247 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); |
252 | } | 248 | } |
253 | 249 | ||
254 | void ImageWidget::loadLogo() | 250 | void ImageWidget::loadLogo() |
255 | { | 251 | { |
256 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); | 252 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); |
257 | } | 253 | } |
258 | 254 | ||
259 | void ImageWidget::updateGUI() | 255 | void ImageWidget::updateGUI() |
260 | { | 256 | { |
261 | KURLRequester *ptr = (KURLRequester*)sender(); | 257 | KURLRequester *ptr = (KURLRequester*)sender(); |
262 | 258 | ||
263 | #ifdef DESKTOP_VERSION | 259 | |
264 | if ( ptr == mPhotoUrl ) | 260 | if ( ptr == mPhotoUrl ) |
265 | mUsePhotoUrl->setEnabled( true ); | 261 | mUsePhotoUrl->setEnabled( true ); |
266 | else if ( ptr == mLogoUrl ) | 262 | else if ( ptr == mLogoUrl ) |
267 | mUseLogoUrl->setEnabled( true ); | 263 | mUseLogoUrl->setEnabled( true ); |
268 | #endif | ||
269 | } | 264 | } |
270 | 265 | ||
271 | QPixmap ImageWidget::loadPixmap( const KURL &url ) | 266 | QPixmap ImageWidget::loadPixmap( const KURL &url ) |
272 | { | 267 | { |
273 | QString tempFile; | 268 | QString tempFile; |
274 | QPixmap pixmap; | 269 | QPixmap pixmap; |
275 | 270 | ||
276 | if ( url.isEmpty() ) | 271 | if ( url.isEmpty() ) |
277 | return pixmap; | 272 | return pixmap; |
278 | 273 | ||
279 | if ( url.isLocalFile() ) | 274 | if ( url.isLocalFile() ) |
280 | pixmap = QPixmap( url.path() ); | 275 | pixmap = QPixmap( url.path() ); |
281 | else | 276 | else |
282 | { | 277 | { |
283 | #ifndef KAB_EMBEDDED | 278 | #ifndef KAB_EMBEDDED |
284 | if ( KIO::NetAccess::download( url, tempFile ) ) { | 279 | if ( KIO::NetAccess::download( url, tempFile ) ) { |
285 | pixmap = QPixmap( tempFile ); | 280 | pixmap = QPixmap( tempFile ); |
286 | KIO::NetAccess::removeTempFile( tempFile ); | 281 | KIO::NetAccess::removeTempFile( tempFile ); |
287 | } | 282 | } |
288 | #else //KAB_EMBEDDED | 283 | #else //KAB_EMBEDDED |
289 | qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); | 284 | qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); |
290 | #endif //KAB_EMBEDDED | 285 | #endif //KAB_EMBEDDED |
291 | 286 | ||
292 | } | 287 | } |
293 | 288 | ||
294 | return pixmap; | 289 | return pixmap; |
295 | } | 290 | } |
296 | 291 | ||
297 | #ifndef KAB_EMBEDDED | 292 | #ifndef KAB_EMBEDDED |
298 | #include "imagewidget.moc" | 293 | #include "imagewidget.moc" |
299 | #endif //KAB_EMBEDDED | 294 | #endif //KAB_EMBEDDED |