79
86
connect(pb_refresh, SIGNAL(clicked()), this, SLOT(doRefresh()));
87
connect(pb_refresh, SIGNAL(clicked()), this, SLOT(updateStatus()));
80
88
connect(te_desc, SIGNAL(textChanged()), this, SLOT(textChanged()));
89
connect(pb_open, SIGNAL(clicked()), this, SLOT(selectPhoto()));
90
connect(pb_clear, SIGNAL(clicked()), this, SLOT(clearPhoto()));
82
92
if(d->type == Self) {
83
93
connect(pb_submit, SIGNAL(clicked()), this, SLOT(doSubmit()));
97
d->te_status = new PsiTextView(tabwidget);
98
d->te_status->setReadOnly(true);
99
d->te_status->setTextFormat(RichText);
100
tabwidget->addTab(d->te_status, tr("Status"));
86
104
pb_submit->hide();
107
ly_photo->setSpacing(0);
87
108
setReadOnly(true);
206
227
le_title->setText( i.title() );
207
228
le_role->setText( i.role() );
208
229
te_desc->setText( i.desc() );
231
if ( !i.photo().isEmpty() ) {
232
//printf("There is a picture...\n");
233
d->photo = i.photo();
210
239
setEdited(false);
242
void InfoDlg::updatePhoto()
244
int max_width = label_photo->width() - 20; // FIXME: Ugly magic number
245
int max_height = label_photo->height() - 20; // FIXME: Ugly magic number
247
QImage img(d->photo);
249
if (img.width() > max_width || img.height() > max_height) {
250
img_scaled = img.smoothScale(max_width, max_height,QImage::ScaleMin);
255
label_photo->setPixmap(QPixmap(img_scaled));
213
258
void InfoDlg::fieldsEnable(bool x)
215
260
le_fullname->setEnabled(x);
420
472
d->te_edited = true;
476
* Opens a file browser dialog, and if selected, calls the setPreviewPhoto with the consecuent path.
477
* \see setPreviewPhoto(const QString& path)
479
void InfoDlg::selectPhoto()
482
if(option.lastPath.isEmpty())
483
option.lastPath = QDir::homeDirPath();
484
QString str = QFileDialog::getOpenFileName(option.lastPath, tr("Images (*.png *.xpm *.jpg *.PNG *.XPM *.JPG)"), this, 0, tr("Choose a file"));
488
QMessageBox::information(this, tr("Error"), tr("The file specified does not exist."));
491
option.lastPath = fi.dirPath();
492
//printf(QDir::convertSeparators(fi.filePath()));
494
// put the image in the preview box
495
setPreviewPhoto(str);
503
* Loads the image from the requested URL, and inserts the resized image into the preview box.
504
* \param path image file to load
506
void InfoDlg::setPreviewPhoto(const QString& path)
508
QFile photo_file(path);
509
if (!photo_file.open(IO_ReadOnly))
512
QByteArray photo_data = photo_file.readAll();
513
QImage photo_image(photo_data);
514
if(!photo_image.isNull()) {
515
d->photo = photo_data;
522
* Clears the preview image box and marks the te_edited signal in the private.
524
void InfoDlg::clearPhoto()
526
// this will cause the pixmap disappear
527
label_photo->setText(tr("Picture not\navailable"));
528
d->photo = QByteArray();
530
// the picture changed, so notify there are some changes done
535
* Updates the status info of the contact
537
void InfoDlg::updateStatus()
542
UserListItem *u = d->pa->find(d->jid);
544
d->te_status->setText(u->makeDesc());
547
d->te_status->clear();