~ubuntu-branches/ubuntu/utopic/psi/utopic

« back to all changes in this revision

Viewing changes to src/infodlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-08-28 18:46:52 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080828184652-iiik12dl91nq7cdi
Tags: 0.12-2
Uploading to unstable (Closes: Bug#494352)

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
#include "iconwidget.h"
44
44
#include "contactview.h"
45
45
#include "psirichtext.h"
46
 
 
 
46
#include "psioptions.h"
 
47
#include "fileutil.h"
47
48
 
48
49
using namespace XMPP;
49
50
                
69
70
        : QDialog(parent)
70
71
{
71
72
        setAttribute(Qt::WA_DeleteOnClose);
72
 
        if ( option.brushedMetal )
 
73
        if ( PsiOptions::instance()->getOption("options.ui.mac.use-brushed-metal-windows").toBool() )
73
74
                setAttribute(Qt::WA_MacMetalStyle);
74
75
        ui_.setupUi(this);
75
76
        d = new Private;
165
166
 
166
167
void InfoDlg::jt_finished()
167
168
{
 
169
        d->jt = 0;
 
170
        JT_VCard* jtVCard = static_cast<JT_VCard*> (sender());
 
171
 
168
172
        d->busy->stop();
169
173
        ui_.pb_refresh->setEnabled(true);
170
174
        ui_.pb_submit->setEnabled(true);
171
175
        ui_.pb_close->setEnabled(true);
172
176
        fieldsEnable(true);
173
177
 
174
 
        if(d->jt->success()) {
 
178
        if(jtVCard->success()) {
175
179
                if(d->actionType == 0) {
176
 
                        d->vcard = d->jt->vcard();
 
180
                        d->vcard = jtVCard->vcard();
177
181
                        setData(d->vcard);
178
182
                }
179
183
                else if(d->actionType == 1) {
180
 
                        d->vcard = d->jt->vcard();
 
184
                        d->vcard = jtVCard->vcard();
181
185
                        if ( d->cacheVCard )
182
186
                                VCardFactory::instance()->setVCard(d->jid, d->vcard);
183
187
                        setData(d->vcard);
198
202
                        if(d->type == Self)
199
203
                                QMessageBox::critical(this, tr("Error"), tr("Unable to retrieve your account information.  Perhaps you haven't entered any yet."));
200
204
                        else
201
 
                                QMessageBox::critical(this, tr("Error"), tr("Unable to retrieve information about this contact.\nReason: %1").arg(d->jt->statusString()));
 
205
                                QMessageBox::critical(this, tr("Error"), tr("Unable to retrieve information about this contact.\nReason: %1").arg(jtVCard->statusString()));
202
206
                }
203
207
                else {
204
 
                        QMessageBox::critical(this, tr("Error"), tr("Unable to publish your account information.\nReason: %1").arg(d->jt->statusString()));
 
208
                        QMessageBox::critical(this, tr("Error"), tr("Unable to publish your account information.\nReason: %1").arg(jtVCard->statusString()));
205
209
                }
206
210
        }
207
 
 
208
 
        d->jt = 0;
209
211
}
210
212
 
211
213
void InfoDlg::setData(const VCard &i)
407
409
        d->actionType = 1;
408
410
        d->busy->start();
409
411
 
410
 
        d->jt = new JT_VCard(d->pa->client()->rootTask());
411
 
        connect(d->jt, SIGNAL(finished()), SLOT(jt_finished()));
412
 
        d->jt->set(submit_vcard);
413
 
        d->jt->go(true);
 
412
        VCardFactory::instance()->setVCard(d->pa, submit_vcard, this, SLOT(jt_finished()));
414
413
}
415
414
 
416
415
VCard InfoDlg::makeVCard()
497
496
*/
498
497
void InfoDlg::selectPhoto()
499
498
{
500
 
        while(1) {
501
 
                if(option.lastPath.isEmpty())
502
 
                        option.lastPath = QDir::homeDirPath();
503
 
                QString str = QFileDialog::getOpenFileName(this, tr("Choose a file"), option.lastPath, tr("Images (*.png *.xpm *.jpg *.PNG *.XPM *.JPG)"));
504
 
                if(!str.isEmpty()) {
505
 
                        QFileInfo fi(str);
506
 
                        if(!fi.exists()) {
507
 
                                QMessageBox::information(this, tr("Error"), tr("The file specified does not exist."));
508
 
                                continue;
509
 
                        }
510
 
                        option.lastPath = fi.dirPath();
511
 
                        //printf(QDir::convertSeparators(fi.filePath()));
512
 
                        
513
 
                        // put the image in the preview box
514
 
                        setPreviewPhoto(str);
515
 
                }
516
 
                break;
 
499
        QString str = FileUtil::getImageFileName(this);
 
500
        if (!str.isEmpty()) {
 
501
                setPreviewPhoto(str);
517
502
        }
518
 
        
519
503
}
520
504
 
521
505
/**