[Psi-Devel] Fwd: Psi Jabber Client - FS#531: Add 'Save as' context menu for vcard photo

Hal Rottenberg hal at halr9000.com
Sat Feb 9 11:58:37 PST 2008


FYI


---------- Forwarded message ----------
From: Psi Jabber Client <flyspray at psi-im.org>
Date: Feb 9, 2008 2:07 PM
Subject: Psi Jabber Client - FS#531: Add 'Save as' context menu for  vcard photo
To: hal at halr9000.com


THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

The following task has a new comment added:

FS#531 - Add 'Save as' context menu for vcard photo
User who did this - zet (zet)

----------
for example, patch from dion (
http://bombus-im.org/zet/psi/patches/psi-vcard-save.diff ):

<code>
Index: trunk/src/infodlg.cpp
===================================================================
--- trunk.orig/src/infodlg.cpp  2007-11-22 20:25:31.000000000 +0200
+++ trunk/src/infodlg.cpp       2007-11-22 20:26:08.000000000 +0200
@@ -95,6 +95,7 @@
        connect(ui_.pb_refresh, SIGNAL(clicked()), this, SLOT(updateStatus()));
        connect(ui_.te_desc, SIGNAL(textChanged()), this, SLOT(textChanged()));
        connect(ui_.pb_open, SIGNAL(clicked()), this, SLOT(selectPhoto()));
+       connect(ui_.pb_save, SIGNAL(clicked()), this, SLOT(savePhoto()));
        connect(ui_.pb_clear, SIGNAL(clicked()), this, SLOT(clearPhoto()));
        connect(ui_.pb_close, SIGNAL(clicked()), this, SLOT(close()));

@@ -273,6 +274,7 @@
                img_scaled = img;
        }
        ui_.label_photo->setPixmap(QPixmap(img_scaled));
+       ui_.pb_save->show();
 }

 void InfoDlg::fieldsEnable(bool x)
@@ -517,6 +519,26 @@
 }

 /**
+ * Opens a file browser dialog, and if selected, save photo from vcard
+*/
+void InfoDlg::savePhoto()
+{
+       if (!d->photo.isEmpty()) {
+               if
(PsiOptions::instance()->getOption("options.ui.last-used-open-path").toString().isEmpty())
+
PsiOptions::instance()->getOption("options.ui.last-used-open-path").toString()
= QDir::homeDirPath();
+               QString str=QFileDialog::getSaveFileName(this,
tr("Save photo"),
PsiOptions::instance()->getOption("options.ui.last-used-open-path").toString(),
tr("Images (*.png *.xpm *.jpg *.PNG *.XPM *.JPG"));
+               if (!str.isEmpty())
+               {
+                       QFileInfo fi(str);
+
PsiOptions::instance()->getOption("options.ui.last-used-open-path").toString()=fi.dirPath();
+                       // Convert imge if required
+                       QImage img(d->photo);
+                       img.save(str);
+               }
+       }
+}
+
+/**
  * Loads the image from the requested URL, and inserts the resized
image into the preview box.
  * \param path image file to load
 */
@@ -546,6 +568,7 @@

        // the picture changed, so notify there are some changes done
        d->te_edited = true;
+       ui_.pb_save->hide();
 }

 /**
Index: trunk/src/infodlg.h
===================================================================
--- trunk.orig/src/infodlg.h    2007-11-22 20:25:11.000000000 +0200
+++ trunk/src/infodlg.h 2007-11-22 20:26:08.000000000 +0200
@@ -63,6 +63,7 @@
        void doSubmit();
        void textChanged();
        void selectPhoto();
+       void savePhoto();
        void clearPhoto();

 private:
Index: trunk/src/info.ui
===================================================================
--- trunk.orig/src/info.ui      2007-11-22 20:25:11.000000000 +0200
+++ trunk/src/info.ui   2007-11-22 20:26:08.000000000 +0200
@@ -160,6 +160,30 @@
             </widget>
            </item>
            <item>
+            <widget class="QPushButton" name="pb_save" >
+             <property name="sizePolicy" >
+              <sizepolicy>
+               <hsizetype>1</hsizetype>
+               <vsizetype>0</vsizetype>
+               <horstretch>0</horstretch>
+               <verstretch>0</verstretch>
+              </sizepolicy>
+             </property>
+             <property name="text" >
+              <string>&amp;Save...</string>
+             </property>
+             <property name="shortcut" >
+              <string>Alt+S</string>
+             </property>
+             <property name="autoDefault" >
+              <bool>false</bool>
+             </property>
+             <property name="flat" >
+              <bool>false</bool>
+             </property>
+            </widget>
+           </item>
+           <item>
             <widget class="QPushButton" name="pb_clear" >
              <property name="sizePolicy" >
               <sizepolicy>
@@ -503,6 +527,7 @@
   <tabstop>le_homepage</tabstop>
   <tabstop>le_email</tabstop>
   <tabstop>pb_open</tabstop>
+  <tabstop>pb_save</tabstop>
   <tabstop>pb_clear</tabstop>
   <tabstop>pb_submit</tabstop>
   <tabstop>pb_refresh</tabstop>
</code>
----------

More information can be found at the following URL:
http://flyspray.psi-im.org/task/531#comment800


You are receiving this message because you have requested it from the
Flyspray bugtracking system.  If you did not expect this message or
don't want to receive mails in future, you can change your
notification settings at the URL shown above.



-- 
Blog: http://halr9000.com
Webmaster, Psi (http://psi-im.org)
Co-host, PowerScripting Podcast (http://powerscripting.net)


More information about the Psi-Devel mailing list