qtgradienteditor.cpp

来自「奇趣公司比较新的qt/emd版本」· C++ 代码 · 共 444 行 · 第 1/2 页

CPP
444
字号
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the Qt Designer of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************//*TRANSLATOR qdesigner_internal::QtGradientEditor*/#include "qtgradienteditor.h"#include "ui_qtgradienteditor.h"#include "qdebug.h"using namespace qdesigner_internal;namespace qdesigner_internal {class QtGradientEditorPrivate{    QtGradientEditor *q_ptr;    Q_DECLARE_PUBLIC(QtGradientEditor)public:    void slotGradientStopsChanged(const QGradientStops &stops);    void slotTypeChanged(int type);    void slotSpreadChanged(int spread);    void slotStartLinearXChanged();    void slotStartLinearYChanged();    void slotEndLinearXChanged();    void slotEndLinearYChanged();    void slotCentralRadialXChanged();    void slotCentralRadialYChanged();    void slotFocalRadialXChanged();    void slotFocalRadialYChanged();    void slotRadiusRadialChanged();    void slotCentralConicalXChanged();    void slotCentralConicalYChanged();    void slotAngleConicalChanged();    void startLinearChanged(const QPointF &point);    void endLinearChanged(const QPointF &point);    void centralRadialChanged(const QPointF &point);    void focalRadialChanged(const QPointF &point);    void radiusRadialChanged(qreal radius);    void centralConicalChanged(const QPointF &point);    void angleConicalChanged(qreal angle);    Ui::QtGradientEditor m_ui;};}void QtGradientEditorPrivate::slotGradientStopsChanged(const QGradientStops &stops){    m_ui.gradientWidget->setGradientStops(stops);    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotTypeChanged(int type){    if (type == 0) {        m_ui.stackedWidget->setCurrentWidget(m_ui.linearPage);        m_ui.gradientWidget->setGradientType(QGradient::LinearGradient);    } else if (type == 1) {        m_ui.stackedWidget->setCurrentWidget(m_ui.radialPage);        m_ui.gradientWidget->setGradientType(QGradient::RadialGradient);    } else if (type == 2) {        m_ui.stackedWidget->setCurrentWidget(m_ui.conicalPage);        m_ui.gradientWidget->setGradientType(QGradient::ConicalGradient);    }    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotSpreadChanged(int spread){    if (spread == 0) {        m_ui.gradientWidget->setGradientSpread(QGradient::PadSpread);    } else if (spread == 1) {        m_ui.gradientWidget->setGradientSpread(QGradient::RepeatSpread);    } else if (spread == 2) {        m_ui.gradientWidget->setGradientSpread(QGradient::ReflectSpread);    }    m_ui.spreadLinearComboBox->setCurrentIndex(spread);    m_ui.spreadRadialComboBox->setCurrentIndex(spread);    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotStartLinearXChanged(){    QPointF point = m_ui.gradientWidget->startLinear();    point.setX(m_ui.startLinearXSpinBox->value());    m_ui.gradientWidget->setStartLinear(point);    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotStartLinearYChanged(){    QPointF point = m_ui.gradientWidget->startLinear();    point.setY(m_ui.startLinearYSpinBox->value());    m_ui.gradientWidget->setStartLinear(point);    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotEndLinearXChanged(){    QPointF point = m_ui.gradientWidget->endLinear();    point.setX(m_ui.endLinearXSpinBox->value());    m_ui.gradientWidget->setEndLinear(point);    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotEndLinearYChanged(){    QPointF point = m_ui.gradientWidget->endLinear();    point.setY(m_ui.endLinearYSpinBox->value());    m_ui.gradientWidget->setEndLinear(point);    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotCentralRadialXChanged(){    QPointF point = m_ui.gradientWidget->centralRadial();    point.setX(m_ui.centralRadialXSpinBox->value());    m_ui.gradientWidget->setCentralRadial(point);    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotCentralRadialYChanged(){    QPointF point = m_ui.gradientWidget->centralRadial();    point.setY(m_ui.centralRadialYSpinBox->value());    m_ui.gradientWidget->setCentralRadial(point);    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotFocalRadialXChanged(){    QPointF point = m_ui.gradientWidget->focalRadial();    point.setX(m_ui.focalRadialXSpinBox->value());    m_ui.gradientWidget->setFocalRadial(point);    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotFocalRadialYChanged(){    QPointF point = m_ui.gradientWidget->focalRadial();    point.setY(m_ui.focalRadialYSpinBox->value());    m_ui.gradientWidget->setFocalRadial(point);    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotRadiusRadialChanged(){    m_ui.gradientWidget->setRadiusRadial(m_ui.radiusRadialSpinBox->value());    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotCentralConicalXChanged(){    QPointF point = m_ui.gradientWidget->centralConical();    point.setX(m_ui.centralConicalXSpinBox->value());    m_ui.gradientWidget->setCentralConical(point);    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotCentralConicalYChanged(){    QPointF point = m_ui.gradientWidget->centralConical();    point.setY(m_ui.centralConicalYSpinBox->value());    m_ui.gradientWidget->setCentralConical(point);    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::slotAngleConicalChanged(){    m_ui.gradientWidget->setAngleConical(m_ui.angleConicalSpinBox->value());    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::startLinearChanged(const QPointF &point){    m_ui.startLinearXSpinBox->setValue(point.x());    m_ui.startLinearYSpinBox->setValue(point.y());    emit q_ptr->gradientChanged(q_ptr->gradient());}void QtGradientEditorPrivate::endLinearChanged(const QPointF &point){    m_ui.endLinearXSpinBox->setValue(point.x());    m_ui.endLinearYSpinBox->setValue(point.y());    emit q_ptr->gradientChanged(q_ptr->gradient());

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?