Diffstat (limited to 'kaddressbook/imagewidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/imagewidget.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index 9ee4eac..1e9743c 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp | |||
@@ -8,156 +8,155 @@ | |||
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <kabc/picture.h> | 24 | #include <kabc/picture.h> |
25 | 25 | ||
26 | #ifndef KAB_EMBEDDED | 26 | #ifndef KAB_EMBEDDED |
27 | #include <kaccelmanager.h> | 27 | #include <kaccelmanager.h> |
28 | #include <kio/netaccess.h> | 28 | #include <kio/netaccess.h> |
29 | #include <kimageio.h> | 29 | #include <kimageio.h> |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kdialog.h> | 33 | #include <kdialog.h> |
34 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kurlrequester.h> | 36 | #include <kurlrequester.h> |
37 | #include <kurl.h> | 37 | #include <kurl.h> |
38 | 38 | ||
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qgroupbox.h> | 40 | #include <qgroupbox.h> |
41 | #include <qlabel.h> | 41 | #include <qlabel.h> |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <qpixmap.h> | 43 | #include <qpixmap.h> |
44 | #include <qpushbutton.h> | 44 | #include <qpushbutton.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | 46 | ||
47 | #include "imagewidget.h" | 47 | #include "imagewidget.h" |
48 | 48 | ||
49 | ImageWidget::ImageWidget( QWidget *parent, const char *name ) | 49 | ImageWidget::ImageWidget( QWidget *parent, const char *name ) |
50 | : QWidget( parent, name ) | 50 | : QWidget( parent, name ) |
51 | { | 51 | { |
52 | QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(), | 52 | QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(), |
53 | KDialog::spacingHint() ); | 53 | KDialog::spacingHint() ); |
54 | 54 | ||
55 | QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this ); | 55 | QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this ); |
56 | QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 4, 2, | 56 | QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2, |
57 | KDialog::spacingHint() ); | 57 | KDialog::spacingHint() ); |
58 | boxLayout->setRowStretch( 2, 1 ); | 58 | boxLayout->setRowStretch( 2, 1 ); |
59 | 59 | ||
60 | mPhotoLabel = new QLabel( photoBox ); | 60 | mPhotoLabel = new QLabel( photoBox ); |
61 | int fac = 9; | 61 | int fac = 9; |
62 | if ( QApplication::desktop()->width() > 320 ) | 62 | if ( QApplication::desktop()->width() > 320 ) |
63 | fac = 6; | 63 | fac = 6; |
64 | mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac ); | 64 | mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac ); |
65 | mPhotoLabel->setScaledContents( true ); | 65 | mPhotoLabel->setScaledContents( true ); |
66 | mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 66 | mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
67 | boxLayout->addMultiCellWidget( mPhotoLabel, 0, 3, 0, 0 ); | 67 | boxLayout->addMultiCellWidget( mPhotoLabel, 0, 3, 0, 0 ); |
68 | 68 | ||
69 | mPhotoUrl = new KURLRequester( photoBox ); | 69 | mPhotoUrl = new KURLRequester( photoBox ); |
70 | #ifndef KAB_EMBEDDED | 70 | #ifndef KAB_EMBEDDED |
71 | mPhotoUrl->setFilter( KImageIO::pattern() ); | 71 | mPhotoUrl->setFilter( KImageIO::pattern() ); |
72 | #else //KAB_EMBEDDED | 72 | #else //KAB_EMBEDDED |
73 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???"); | 73 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???"); |
74 | #endif //KAB_EMBEDDED | 74 | #endif //KAB_EMBEDDED |
75 | 75 | ||
76 | 76 | ||
77 | boxLayout->addWidget( mPhotoUrl, 0, 1 ); | 77 | boxLayout->addWidget( mPhotoUrl, 0, 1 ); |
78 | 78 | QHBox *hb1 = new QHBox ( photoBox ); | |
79 | mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), photoBox ); | 79 | mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), hb1 ); |
80 | mUsePhotoUrl->setEnabled( false ); | 80 | mUsePhotoUrl->setEnabled( false ); |
81 | boxLayout->addWidget( mUsePhotoUrl, 1, 1 ); | 81 | boxLayout->addWidget( hb1, 1, 1 ); |
82 | 82 | ||
83 | QPushButton * pb = new QPushButton( i18n( "Remove" ), photoBox ); | 83 | QPushButton * pb = new QPushButton( i18n( "Remove" ), hb1 ); |
84 | connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) ); | 84 | connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) ); |
85 | boxLayout->addWidget( pb, 2, 1 ); | 85 | boxLayout->addWidget( new QLabel( photoBox ), 2, 1 ); |
86 | boxLayout->addWidget( new QLabel( photoBox ), 3, 1 ); | ||
87 | 86 | ||
88 | topLayout->addWidget( photoBox, 0, 0 ); | 87 | topLayout->addWidget( photoBox, 0, 0 ); |
89 | 88 | ||
90 | QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this ); | 89 | QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this ); |
91 | boxLayout = new QGridLayout( logoBox->layout(), 4, 2, KDialog::spacingHint() ); | 90 | boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() ); |
92 | boxLayout->setRowStretch( 2, 1 ); | 91 | boxLayout->setRowStretch( 2, 1 ); |
93 | 92 | ||
94 | mLogoLabel = new QLabel( logoBox ); | 93 | mLogoLabel = new QLabel( logoBox ); |
95 | mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); | 94 | mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); |
96 | mLogoLabel->setScaledContents( true ); | 95 | mLogoLabel->setScaledContents( true ); |
97 | mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 96 | mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
98 | boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 ); | 97 | boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 ); |
99 | 98 | ||
100 | mLogoUrl = new KURLRequester( logoBox ); | 99 | mLogoUrl = new KURLRequester( logoBox ); |
101 | #ifndef KAB_EMBEDDED | 100 | #ifndef KAB_EMBEDDED |
102 | mLogoUrl->setFilter( KImageIO::pattern() ); | 101 | mLogoUrl->setFilter( KImageIO::pattern() ); |
103 | #else //KAB_EMBEDDED | 102 | #else //KAB_EMBEDDED |
104 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); | 103 | //US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); |
105 | #endif //KAB_EMBEDDED | 104 | #endif //KAB_EMBEDDED |
106 | boxLayout->addWidget( mLogoUrl, 0, 1 ); | 105 | boxLayout->addWidget( mLogoUrl, 0, 1 ); |
107 | 106 | ||
108 | mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox ); | 107 | QHBox *hb2 = new QHBox ( logoBox ); |
108 | mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), hb2 ); | ||
109 | mUseLogoUrl->setEnabled( false ); | 109 | mUseLogoUrl->setEnabled( false ); |
110 | boxLayout->addWidget( mUseLogoUrl, 1, 1 ); | 110 | boxLayout->addWidget( hb2, 1, 1 ); |
111 | 111 | ||
112 | pb = new QPushButton( i18n( "Remove" ), logoBox ); | 112 | pb = new QPushButton( i18n( "Remove" ), hb2 ); |
113 | connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) ); | 113 | connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) ); |
114 | boxLayout->addWidget( pb, 2, 1 ); | 114 | boxLayout->addWidget( new QLabel( logoBox ), 2, 1 ); |
115 | boxLayout->addWidget( new QLabel( logoBox ), 3, 1 ); | ||
116 | topLayout->addWidget( logoBox, 1, 0 ); | 115 | topLayout->addWidget( logoBox, 1, 0 ); |
117 | 116 | ||
118 | connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), | 117 | connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), |
119 | SIGNAL( changed() ) ); | 118 | SIGNAL( changed() ) ); |
120 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 119 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
121 | SLOT( loadPhoto() ) ); | 120 | SLOT( loadPhoto() ) ); |
122 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 121 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
123 | SIGNAL( changed() ) ); | 122 | SIGNAL( changed() ) ); |
124 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 123 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
125 | SLOT( updateGUI() ) ); | 124 | SLOT( updateGUI() ) ); |
126 | connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), | 125 | connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), |
127 | SIGNAL( changed() ) ); | 126 | SIGNAL( changed() ) ); |
128 | 127 | ||
129 | connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), | 128 | connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), |
130 | SIGNAL( changed() ) ); | 129 | SIGNAL( changed() ) ); |
131 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 130 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
132 | SLOT( loadLogo() ) ); | 131 | SLOT( loadLogo() ) ); |
133 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 132 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
134 | SIGNAL( changed() ) ); | 133 | SIGNAL( changed() ) ); |
135 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 134 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
136 | SLOT( updateGUI() ) ); | 135 | SLOT( updateGUI() ) ); |
137 | connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), | 136 | connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), |
138 | SIGNAL( changed() ) ); | 137 | SIGNAL( changed() ) ); |
139 | 138 | ||
140 | #ifndef KAB_EMBEDDED | 139 | #ifndef KAB_EMBEDDED |
141 | KAcceleratorManager::manage( this ); | 140 | KAcceleratorManager::manage( this ); |
142 | #endif //KAB_EMBEDDED | 141 | #endif //KAB_EMBEDDED |
143 | 142 | ||
144 | } | 143 | } |
145 | 144 | ||
146 | ImageWidget::~ImageWidget() | 145 | ImageWidget::~ImageWidget() |
147 | { | 146 | { |
148 | } | 147 | } |
149 | 148 | ||
150 | void ImageWidget::setPhoto( const KABC::Picture &photo ) | 149 | void ImageWidget::setPhoto( const KABC::Picture &photo ) |
151 | { | 150 | { |
152 | bool blocked = signalsBlocked(); | 151 | bool blocked = signalsBlocked(); |
153 | blockSignals( true ); | 152 | blockSignals( true ); |
154 | 153 | ||
155 | if ( photo.isIntern() ) { | 154 | if ( photo.isIntern() ) { |
156 | //US | 155 | //US |
157 | //US mPhotoLabel->setPixmap( photo.data() ); | 156 | //US mPhotoLabel->setPixmap( photo.data() ); |
158 | if (photo.data().isNull() != true) | 157 | if (photo.data().isNull() != true) |
159 | { | 158 | { |
160 | QPixmap pm; | 159 | QPixmap pm; |
161 | pm.convertFromImage(photo.data()); | 160 | pm.convertFromImage(photo.data()); |
162 | 161 | ||
163 | mPhotoLabel->setPixmap( pm ); | 162 | mPhotoLabel->setPixmap( pm ); |