~thomas-moenicke/phablet-extras/maliit-plugins-fix-1199150

« back to all changes in this revision

Viewing changes to maliit-keyboard/lib/models/styleattributes.cpp

branch to get the new maliit-keyboard.

Approved by Bill Filler, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
#include "styleattributes.h"
33
33
 
 
34
#include <QtGui/QGuiApplication>
 
35
#include <QtGui/QScreen>
 
36
 
34
37
//! \class StyleAttributes
35
38
//! This class allows to query style attributes, such as image names and font
36
39
//! sizes. Styling attributes are read from INI files.
469
472
//! @returns Value of "${style}\${orientation}\key-area-width".
470
473
qreal StyleAttributes::keyAreaWidth(Logic::LayoutHelper::Orientation orientation) const
471
474
{
472
 
    return lookup(m_store, orientation,
 
475
    QVariant result(lookup(m_store, orientation,
473
476
                  m_style_name.toLocal8Bit(),
474
 
                  QByteArray("key-area-width")).toReal();
 
477
                  QByteArray("key-area-width")));
 
478
 
 
479
    qreal resultAsReal = 0.0; // ToDo should be cached
 
480
 
 
481
    if(result.toString().contains("%")) {
 
482
        resultAsReal =
 
483
                  0.01
 
484
                * result.toString().remove('%').toDouble()
 
485
                * QGuiApplication::primaryScreen()->size().width();
 
486
    } else {
 
487
        resultAsReal = result.toReal();
 
488
    }
 
489
 
 
490
    return resultAsReal;
475
491
}
476
492
 
477
493
 
575
591
    return m_store->value("sound/keyboard-hide").toByteArray();
576
592
}
577
593
 
 
594
qreal StyleAttributes::keyboardTotalHeight(Logic::LayoutHelper::Orientation orientation) const
 
595
{
 
596
    return lookup(m_store, orientation,
 
597
                  m_style_name.toLocal8Bit(),
 
598
                  QByteArray("keyboard-total-height")).toReal();
 
599
}
 
600
 
 
601
qreal StyleAttributes::keyboardVisibleHeight(Logic::LayoutHelper::Orientation orientation) const
 
602
{
 
603
    return lookup(m_store, orientation,
 
604
                  m_style_name.toLocal8Bit(),
 
605
                  QByteArray("keyboard-visible-height")).toReal();
 
606
}
 
607
 
 
608
qreal StyleAttributes::topMargin(Logic::LayoutHelper::Orientation orientation) const
 
609
{
 
610
    return lookup(m_store, orientation,
 
611
                  m_style_name.toLocal8Bit(),
 
612
                  QByteArray("keyboard-top-margin")).toReal();
 
613
}
 
614
 
578
615
} // namespace MaliitKeyboard