~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/plugins/extensions/imagesize/dlg_imagesize.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include <math.h>
25
25
 
 
26
#include <multilock_button.h>
 
27
 
26
28
#include <klocale.h>
27
29
#include <kis_debug.h>
28
30
 
48
50
    m_aspectRatio = m_width / m_height;
49
51
 
50
52
    m_page = new WdgImageSize(this);
 
53
 
51
54
    m_page->layout()->setMargin(0);
52
55
    Q_CHECK_PTR(m_page);
53
56
    m_page->setObjectName("image_size");
54
57
 
55
58
    m_page->intPixelWidth->setValue(width);
 
59
    m_page->intPixelWidth->setFocus();
56
60
    m_page->intPixelHeight->setValue(height);
57
61
 
58
62
    m_page->cmbFilterType->setIDList(KisFilterStrategyRegistry::instance()->listKeys());
63
67
 
64
68
    m_page->doubleResolution->setValue(72.0 * resolution);
65
69
 
66
 
    m_page->cmbInteractor->addItem(i18n("Size in Pixels"));
67
 
    m_page->cmbInteractor->addItem(i18n("Print Size"));
 
70
    m_page->lock_pixel->nominateSiblings(m_page->lock_resolution, m_page->lock_print);
 
71
    m_page->lock_print->nominateSiblings(m_page->lock_pixel, m_page->lock_resolution);
 
72
    m_page->lock_resolution->nominateSiblings(m_page->lock_pixel, m_page->lock_print);
 
73
    m_page->lock_resolution->lock();
68
74
 
69
75
    slotAspectChanged(true);
70
76
 
77
83
    setMainWidget(m_page);
78
84
    resize(m_page->sizeHint());
79
85
 
80
 
    connect(m_page->chkAffectResolution, SIGNAL(toggled(bool)),
81
 
            this, SLOT(slotProtectChanged()));
82
 
 
83
86
    connect(m_page->aspectPixels, SIGNAL(keepAspectRatioChanged(bool)),
84
87
            this, SLOT(slotAspectChanged(bool)));
85
88
 
86
89
    connect(m_page->aspectPhysical, SIGNAL(keepAspectRatioChanged(bool)),
87
90
            this, SLOT(slotAspectChanged(bool)));
88
91
 
89
 
    connect(m_page->cmbInteractor, SIGNAL(currentIndexChanged(int)),
 
92
    connect(m_page->lock_pixel, SIGNAL(lockStateChanged(bool)),
 
93
            this, SLOT(slotProtectChanged()));
 
94
 
 
95
    connect(m_page->lock_print, SIGNAL(lockStateChanged(bool)),
 
96
            this, SLOT(slotProtectChanged()));
 
97
 
 
98
    connect(m_page->lock_resolution, SIGNAL(lockStateChanged(bool)),
90
99
            this, SLOT(slotProtectChanged()));
91
100
 
92
101
    connect(m_page->intPixelWidth, SIGNAL(valueChanged(int)),
122
131
    connect(m_page->cmbHeightUnit, SIGNAL(currentIndexChanged(int)),
123
132
            this, SLOT(slotHeightUnitChanged(int)));
124
133
 
 
134
    connect(m_page->doubleResolution, SIGNAL(valueChanged(double)),
 
135
            this, SLOT(slotResolutionChanged(double)));
 
136
 
125
137
    slotProtectChanged();
126
138
 
127
139
#ifdef __GNUC__
173
185
{
174
186
    blockAll();
175
187
 
176
 
    if (!m_page->chkAffectResolution->isChecked()) {
 
188
    if (m_page->lock_resolution->isLocked()) { // !m_page->chkAffectResolution->isChecked()) {
177
189
        m_width = 72 * w / m_page->doubleResolution->value();
178
190
 
179
191
        KoUnit unit = KoUnit((KoUnit::Unit)m_page->cmbWidthUnit->currentIndex());
207
219
{
208
220
    blockAll();
209
221
 
210
 
    if (!m_page->chkAffectResolution->isChecked()) {
 
222
    if (m_page->lock_resolution->isLocked()) { // !m_page->chkAffectResolution->isChecked()) {
211
223
        m_height = 72 * h / m_page->doubleResolution->value();
212
224
 
213
225
        KoUnit unit = KoUnit((KoUnit::Unit)m_page->cmbHeightUnit->currentIndex());
278
290
    KoUnit unit = KoUnit((KoUnit::Unit)m_page->cmbWidthUnit->currentIndex());
279
291
    m_width = unit.fromUserValue(w);
280
292
 
281
 
    if (!m_page->chkAffectResolution->isChecked()) {
 
293
    if (m_page->lock_resolution->isLocked()) { // !m_page->chkAffectResolution->isChecked()) {
282
294
        m_page->intPixelWidth->setValue(int(0.5 + m_width*m_page->doubleResolution->value() / 72.0));
 
295
        m_page->doublePercentageWidth->setValue(100.0 * m_page->intPixelWidth->value() / m_origW);
283
296
    } else {
284
297
        m_page->doubleResolution->setValue(72*m_page->intPixelWidth->value() / m_width);
285
298
        // since we only have one resolution parameter we need to recalculate the physical height
296
309
        m_page->doublePhysicalHeight->setValue(unit.toUserValue(m_height));
297
310
 
298
311
        m_page->intPixelHeight->setValue(int(0.5 + m_height * m_page->doubleResolution->value() / 72.0));
 
312
        m_page->doublePercentageHeight->setValue(100.0 * m_page->intPixelHeight->value() / m_origH);
299
313
    }
300
314
 
301
315
    // recalculate aspect ratio
311
325
    KoUnit unit = KoUnit((KoUnit::Unit)m_page->cmbHeightUnit->currentIndex());
312
326
    m_height = unit.fromUserValue(h);
313
327
 
314
 
    if (!m_page->chkAffectResolution->isChecked()) {
 
328
    if (m_page->lock_resolution->isLocked()) { // !m_page->chkAffectResolution->isChecked()) {
315
329
        m_page->intPixelHeight->setValue(int(0.5 + m_height*m_page->doubleResolution->value() / 72.0));
 
330
        m_page->doublePercentageHeight->setValue(100.0 * m_page->intPixelHeight->value() / m_origH);
316
331
    } else {
317
332
        m_page->doubleResolution->setValue(72*m_page->intPixelHeight->value() / m_height);
318
333
 
330
345
        m_page->doublePhysicalWidth->setValue(unit.toUserValue(m_width));
331
346
 
332
347
        m_page->intPixelWidth->setValue(int(0.5 + m_width * m_page->doubleResolution->value() / 72.0));
 
348
        m_page->doublePercentageWidth->setValue(100.0 * m_page->intPixelWidth->value() / m_origW);
333
349
    }
334
350
 
335
351
    // recalculate aspect ratio
359
375
    unblockAll();
360
376
}
361
377
 
 
378
void DlgImageSize::slotResolutionChanged(double r)
 
379
{
 
380
    Q_UNUSED(r);
 
381
    blockAll();
 
382
 
 
383
    if (m_page->lock_print->isLocked()) {
 
384
        m_page->intPixelHeight->setValue(int(0.5 + m_height*m_page->doubleResolution->value() / 72.0));
 
385
        m_page->doublePercentageHeight->setValue(100.0 * m_page->intPixelHeight->value() / m_origH);
 
386
        m_page->intPixelWidth->setValue(int(0.5 + m_width*m_page->doubleResolution->value() / 72.0));
 
387
        m_page->doublePercentageWidth->setValue(100.0 * m_page->intPixelWidth->value() / m_origW);
 
388
    } else {
 
389
        m_width = 72 * m_page->intPixelWidth->value() / m_page->doubleResolution->value();
 
390
        m_height = 72 * m_page->intPixelHeight->value() / m_page->doubleResolution->value();
 
391
 
 
392
        KoUnit unit = KoUnit((KoUnit::Unit)m_page->cmbWidthUnit->currentIndex());
 
393
        m_page->doublePhysicalWidth->setValue(unit.toUserValue(m_width));
 
394
        m_page->doublePhysicalHeight->setValue(unit.toUserValue(m_height));
 
395
    }
 
396
 
 
397
    unblockAll();
 
398
}
 
399
 
362
400
void DlgImageSize::slotProtectChanged()
363
401
{
364
 
    if (m_page->chkAffectResolution->isChecked()) {
365
 
        m_page->intPixelWidth->setEnabled(m_page->cmbInteractor->currentIndex() == 0);
366
 
        m_page->intPixelHeight->setEnabled(m_page->cmbInteractor->currentIndex() == 0);
367
 
        m_page->doublePhysicalWidth->setEnabled(m_page->cmbInteractor->currentIndex() == 1);
368
 
        m_page->doublePhysicalHeight->setEnabled(m_page->cmbInteractor->currentIndex() == 1);
369
 
        m_page->doubleResolution->setEnabled(true);
370
 
        m_page->cmbInteractor->setEnabled(true);
371
 
        m_page->labelInteractor->setEnabled(true);
372
 
    } else {
373
 
        m_page->intPixelWidth->setEnabled(true);
374
 
        m_page->intPixelHeight->setEnabled(true);
375
 
        m_page->doublePhysicalWidth->setEnabled(true);
376
 
        m_page->doublePhysicalHeight->setEnabled(true);
377
 
        m_page->doubleResolution->setEnabled(false);
378
 
        m_page->cmbInteractor->setEnabled(false);
379
 
        m_page->labelInteractor->setEnabled(false);
380
 
    }
 
402
    m_page->labelWidth->setEnabled(!m_page->lock_pixel->isLocked());
 
403
    m_page->intPixelWidth->setEnabled(!m_page->lock_pixel->isLocked());
 
404
    m_page->cmbWidthPixelUnit->setEnabled(!m_page->lock_pixel->isLocked());
 
405
    m_page->labelHeight->setEnabled(!m_page->lock_pixel->isLocked());
 
406
    m_page->intPixelHeight->setEnabled(!m_page->lock_pixel->isLocked());
 
407
    m_page->cmbHeightPixelUnit->setEnabled(!m_page->lock_pixel->isLocked());
 
408
    m_page->doublePercentageWidth->setEnabled(!m_page->lock_pixel->isLocked());
 
409
    m_page->doublePercentageHeight->setEnabled(!m_page->lock_pixel->isLocked());
 
410
    m_page->labelFilter->setEnabled(!m_page->lock_pixel->isLocked());
 
411
    m_page->cmbFilterType->setEnabled(!m_page->lock_pixel->isLocked());
 
412
    m_page->aspectPixels->setEnabled(!m_page->lock_pixel->isLocked());
 
413
    m_page->labelPhysicalWidth->setEnabled(!m_page->lock_print->isLocked());
 
414
    m_page->doublePhysicalWidth->setEnabled(!m_page->lock_print->isLocked());
 
415
    m_page->cmbWidthUnit->setEnabled(!m_page->lock_print->isLocked());
 
416
    m_page->labelPhysicalHeight->setEnabled(!m_page->lock_print->isLocked());
 
417
    m_page->doublePhysicalHeight->setEnabled(!m_page->lock_print->isLocked());
 
418
    m_page->cmbHeightUnit->setEnabled(!m_page->lock_print->isLocked());
 
419
    m_page->aspectPhysical->setEnabled(!m_page->lock_pixel->isLocked());
 
420
    m_page->labelResolution->setEnabled(!m_page->lock_resolution->isLocked());
 
421
    m_page->doubleResolution->setEnabled(!m_page->lock_resolution->isLocked());
 
422
    m_page->labelResolutionUnit->setEnabled(!m_page->lock_resolution->isLocked());
381
423
}
382
424
 
383
425
void DlgImageSize::slotAspectChanged(bool keep)