~ubuntu-sdk-team/qtcreator-plugin-remotelinux/trunk

« back to all changes in this revision

Viewing changes to src/qnx/bardescriptoreditorgeneralwidget.cpp

  • Committer: CI bot
  • Author(s): Benjamin Zeller
  • Date: 2014-06-16 10:28:43 UTC
  • mfrom: (4.2.4 remotelinux)
  • Revision ID: ps-jenkins@lists.canonical.com-20140616102843-8juvmjvzwlzsboyw
Migrating to Qt5.3 and QtC 3.1 

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    m_ui->chrome->addItem(tr("Standard"), QLatin1String("standard"));
52
52
    m_ui->chrome->addItem(tr("None"), QLatin1String("none"));
53
53
 
54
 
    connect(m_ui->orientation, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
55
 
    connect(m_ui->chrome, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
56
 
    connect(m_ui->transparentMainWindow, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
57
 
    connect(m_ui->applicationArguments, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
 
54
    addSignalMapping(BarDescriptorDocument::aspectRatio, m_ui->orientation, SIGNAL(currentIndexChanged(int)));
 
55
    addSignalMapping(BarDescriptorDocument::systemChrome, m_ui->chrome, SIGNAL(currentIndexChanged(int)));
 
56
    addSignalMapping(BarDescriptorDocument::transparent, m_ui->transparentMainWindow, SIGNAL(toggled(bool)));
 
57
    addSignalMapping(BarDescriptorDocument::arg, m_ui->applicationArguments, SIGNAL(textChanged(QString)));
58
58
}
59
59
 
60
60
BarDescriptorEditorGeneralWidget::~BarDescriptorEditorGeneralWidget()
62
62
    delete m_ui;
63
63
}
64
64
 
65
 
void BarDescriptorEditorGeneralWidget::clear()
66
 
{
67
 
    setComboBoxBlocked(m_ui->orientation, m_ui->orientation->findData(QLatin1String("")));
68
 
    setComboBoxBlocked(m_ui->chrome, m_ui->chrome->findData(QLatin1String("none")));
69
 
    setCheckBoxBlocked(m_ui->transparentMainWindow, false);
70
 
    setLineEditBlocked(m_ui->applicationArguments, QString());
71
 
}
72
 
 
73
 
QString BarDescriptorEditorGeneralWidget::orientation() const
74
 
{
75
 
    return m_ui->orientation->itemData(m_ui->orientation->currentIndex()).toString();
76
 
}
77
 
 
78
 
void BarDescriptorEditorGeneralWidget::setOrientation(const QString &orientation)
79
 
{
80
 
    int index = m_ui->orientation->findData(orientation);
81
 
    QTC_ASSERT(index >= 0, return);
82
 
 
83
 
    setComboBoxBlocked(m_ui->orientation, index);
84
 
}
85
 
 
86
 
QString BarDescriptorEditorGeneralWidget::chrome() const
87
 
{
88
 
    return m_ui->chrome->itemData(m_ui->chrome->currentIndex()).toString();
89
 
}
90
 
 
91
 
void BarDescriptorEditorGeneralWidget::setChrome(const QString &chrome)
92
 
{
93
 
    int index = m_ui->chrome->findData(chrome);
94
 
    QTC_ASSERT(index >= 0, return);
95
 
 
96
 
    setComboBoxBlocked(m_ui->chrome, index);
97
 
}
98
 
 
99
 
bool BarDescriptorEditorGeneralWidget::transparent() const
100
 
{
101
 
    return m_ui->transparentMainWindow->isChecked();
102
 
}
103
 
 
104
 
void BarDescriptorEditorGeneralWidget::setTransparent(bool transparent)
105
 
{
106
 
    setCheckBoxBlocked(m_ui->transparentMainWindow, transparent);
107
 
}
108
 
 
109
 
void BarDescriptorEditorGeneralWidget::appendApplicationArgument(const QString &argument)
110
 
{
111
 
    QString completeArguments = m_ui->applicationArguments->text();
112
 
    if (!completeArguments.isEmpty())
113
 
        completeArguments.append(QLatin1Char(' '));
114
 
    completeArguments.append(argument);
115
 
 
116
 
    setLineEditBlocked(m_ui->applicationArguments, completeArguments);
117
 
}
118
 
 
119
 
QStringList BarDescriptorEditorGeneralWidget::applicationArguments() const
120
 
{
121
 
    // TODO: Should probably handle "argument with spaces within quotes"
122
 
    return m_ui->applicationArguments->text().split(QLatin1Char(' '));
 
65
void BarDescriptorEditorGeneralWidget::updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value)
 
66
{
 
67
    if (tag == BarDescriptorDocument::aspectRatio) {
 
68
        m_ui->orientation->setCurrentIndex(m_ui->orientation->findData(value));
 
69
    } else if (tag == BarDescriptorDocument::autoOrients) {
 
70
        if (value.toString() == QLatin1String("true")) {
 
71
            blockSignalMapping(BarDescriptorDocument::aspectRatio);
 
72
            m_ui->orientation->setCurrentIndex(m_ui->orientation->findData(QLatin1String("auto-orient")));
 
73
            unblockSignalMapping(BarDescriptorDocument::aspectRatio);
 
74
        }
 
75
    } else if (tag == BarDescriptorDocument::arg) {
 
76
        m_ui->applicationArguments->setText(value.toStringList().join(QLatin1String(" ")));
 
77
    } else {
 
78
        BarDescriptorEditorAbstractPanelWidget::updateWidgetValue(tag, value);
 
79
    }
 
80
}
 
81
 
 
82
void BarDescriptorEditorGeneralWidget::emitChanged(BarDescriptorDocument::Tag tag)
 
83
{
 
84
    if (tag == BarDescriptorDocument::aspectRatio) {
 
85
        QString value = m_ui->orientation->itemData(m_ui->orientation->currentIndex()).toString();
 
86
        if (value == QLatin1String("auto-orient")) {
 
87
            emit changed(BarDescriptorDocument::aspectRatio, QLatin1String(""));
 
88
            emit changed(BarDescriptorDocument::autoOrients, QLatin1String("true"));
 
89
            return;
 
90
        } else if (!value.isEmpty()) {
 
91
            emit changed(BarDescriptorDocument::aspectRatio, value);
 
92
            emit changed(BarDescriptorDocument::autoOrients, QLatin1String("false"));
 
93
        } else {
 
94
            emit changed(BarDescriptorDocument::aspectRatio, value);
 
95
            emit changed(BarDescriptorDocument::autoOrients, QLatin1String(""));
 
96
        }
 
97
    } else if (tag == BarDescriptorDocument::arg) {
 
98
        emit changed(tag, m_ui->applicationArguments->text().split(QLatin1Char(' ')));
 
99
    } else {
 
100
        BarDescriptorEditorAbstractPanelWidget::emitChanged(tag);
 
101
    }
123
102
}