コード例 #1
0
ファイル: kfontaction.cpp プロジェクト: crayonink/calligra-2
/*
 * Maintenance note: Keep in sync with QFontComboBox::setCurrentFont()
 */
void KFontAction::setFont( const QString &family )
{
    qDebug() << "KFontAction::setFont(" << family << ")";

    // Suppress triggered(QString) signal and prevent recursive call to ourself.
    d->settingFont++;

    foreach(QWidget *w, createdWidgets())
    {
        QFontComboBox *cb = qobject_cast<QFontComboBox *>(w);
        qDebug() << "\tw=" << w << "cb=" << cb;

        if(!cb) continue;

        cb->setCurrentFont(QFont(family.toLower()));
        qDebug() << "\t\tw spit back=" << cb->currentFont().family();
    }
コード例 #2
0
ファイル: kfontaction.cpp プロジェクト: crayonink/calligra-2
QWidget* KFontAction::createWidget(QWidget* parent)
{
    qDebug() << "KFontAction::createWidget()";
#ifdef __GNUC__
#warning FIXME: items need to be converted
#endif
    // This is the visual element on the screen.  This method overrides
    // the KSelectAction one, preventing KSelectAction from creating its
    // regular KComboBox.
    QFontComboBox *cb = new QFontComboBox( parent );
    cb->setFontFilters(d->fontFilters);

    qDebug() << "\tset=" << font();
    // Do this before connecting the signal so that nothing will fire.
    cb->setCurrentFont( QFont( font().toLower() ) );
    qDebug() << "\tspit back=" << cb->currentFont().family();

    connect( cb, SIGNAL(currentFontChanged(QFont)), SLOT(_k_slotFontChanged(QFont)) );
    cb->setMinimumWidth( cb->sizeHint().width() );
    return cb;
}
コード例 #3
0
ファイル: MainWindow.cpp プロジェクト: robcaldecott/jupiter
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    createStatusBar();

    // Recent files
    for (int i = 0; i < MaxRecentFiles; ++i)
    {
	recentFileActions[i] = new QAction(this);
	recentFileActions[i]->setVisible(false);
	connect(recentFileActions[i], SIGNAL(triggered()), this, SLOT(openRecentFile()));
	ui->menuFile->insertAction(ui->actionExit, recentFileActions[i]);
    }
    recentFilesSeparator = ui->menuFile->insertSeparator(ui->actionExit);

    printer = new QPrinter;
    printer->setFullPage(true);
    printer->setPaperSize(QPrinter::Letter);
    printer->setPageMargins(.5, .5, .5, .5, QPrinter::Inch);

    report = new Report(printer, this);
    view = new ReportView(report, this);

    preview = new QPrintPreviewWidget(printer, this);
    setCentralWidget(preview);
    preview->fitToWidth();

    QFontComboBox* fontComboBox = new QFontComboBox;
    fontComboBox->setFontFilters(QFontComboBox::MonospacedFonts | QFontComboBox::ScalableFonts);
    fontComboBox->setCurrentFont(report->font().family());
    ui->fontToolBar->insertWidget(ui->actionBold, fontComboBox);
    connect(fontComboBox, SIGNAL(currentFontChanged(QFont)), report, SLOT(setFont(QFont)));

    pageNumberComboBox = new QComboBox;
    ui->viewToolBar->insertWidget(ui->actionNextPage, pageNumberComboBox);
    connect(pageNumberComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentPageChanged(int)));

    const qreal zoomFactors[] = { 12.5, 25, 50, 100, 125, 150, 200, 400, 800 };
    zoomComboBox = new QComboBox;
    for (unsigned int i = 0; i < sizeof(zoomFactors) / sizeof(*zoomFactors); ++i)
    {
	zoomComboBox->addItem(QString("%1%").arg(zoomFactors[i]));
    }
    zoomComboBox->setCurrentIndex(-1);
    ui->viewToolBar->insertWidget(ui->actionZoomOut, zoomComboBox);
    connect(zoomComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(zoomChanged(QString)));

    QActionGroup* orientationGroup = new QActionGroup(this);
    orientationGroup->addAction(ui->actionPortrait);
    orientationGroup->addAction(ui->actionLandscape);
    orientationChanged(report->orientation());

    QActionGroup* heightGroup = new QActionGroup(this);
    heightGroup->addAction(ui->action6LPI);
    heightGroup->addAction(ui->action8LPI);
    heightGroup->addAction(ui->action9LPI);
    heightGroup->setDisabled(ui->actionStretchFont->isEnabled());
    connect(ui->actionStretchFont, SIGNAL(toggled(bool)), heightGroup, SLOT(setDisabled(bool)));

    QActionGroup* widthGroup = new QActionGroup(this);
    widthGroup->addAction(ui->actionDefaultWidth);
    widthGroup->addAction(ui->action10CPI);
    widthGroup->addAction(ui->action12CPI);
    widthGroup->addAction(ui->action17CPI);
    widthGroup->setDisabled(ui->actionStretchFont->isEnabled());
    connect(ui->actionStretchFont, SIGNAL(toggled(bool)), widthGroup, SLOT(setDisabled(bool)));

    QActionGroup* pageGroup = new QActionGroup(this);
    pageGroup->addAction(ui->actionSinglePage);
    pageGroup->addAction(ui->actionFacingPages);
    pageGroup->addAction(ui->actionAllPages);
    ui->actionSinglePage->setChecked(preview->viewMode() == QPrintPreviewWidget::SinglePageView);
    ui->actionFacingPages->setChecked(preview->viewMode() == QPrintPreviewWidget::FacingPagesView);
    ui->actionAllPages->setChecked(preview->viewMode() == QPrintPreviewWidget::AllPagesView);

    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()));
    connect(ui->actionOpenURL, SIGNAL(triggered()), this, SLOT(openUrl()));
    connect(ui->actionReload, SIGNAL(triggered()), this, SLOT(reload()));
    connect(ui->actionSaveAsPDF, SIGNAL(triggered()), this, SLOT(saveAsPdf()));
    connect(ui->actionPrint, SIGNAL(triggered()), this, SLOT(print()));
    connect(ui->actionPageSetup, SIGNAL(triggered()), this, SLOT(pageSetup()));
    connect(ui->actionEmail, SIGNAL(triggered()), this, SLOT(email()));
    connect(ui->actionCopy, SIGNAL(triggered()), this, SLOT(copy()));
    connect(ui->actionStretchFont, SIGNAL(toggled(bool)), report, SLOT(setStretchFont(bool)));
    connect(report, SIGNAL(stretchFontChanged(bool)), ui->actionStretchFont, SLOT(setChecked(bool)));
    connect(ui->actionBold, SIGNAL(toggled(bool)), report, SLOT(setBold(bool)));
    connect(ui->actionStripes, SIGNAL(toggled(bool)), report, SLOT(setStripes(bool)));
    connect(ui->actionStripeColor, SIGNAL(triggered()), this, SLOT(stripeColor()));
    connect(ui->actionColor, SIGNAL(triggered()), this, SLOT(fontColor()));
    connect(ui->action6LPI, SIGNAL(triggered()), this, SLOT(height6Lpi()));
    connect(ui->action8LPI, SIGNAL(triggered()), this, SLOT(height8Lpi()));
    connect(ui->action9LPI, SIGNAL(triggered()), this, SLOT(height9Lpi()));
    connect(ui->actionDefaultWidth, SIGNAL(toggled(bool)), this, SLOT(widthDefault()));
    connect(ui->action10CPI, SIGNAL(triggered()), this, SLOT(width10Cpi()));
    connect(ui->action12CPI, SIGNAL(triggered()), this, SLOT(width12Cpi()));
    connect(ui->action17CPI, SIGNAL(triggered()), this, SLOT(width17Cpi()));
    connect(ui->actionFirstPage, SIGNAL(triggered()), this, SLOT(firstPage()));
    connect(ui->actionPreviousPage, SIGNAL(triggered()), this, SLOT(previousPage()));
    connect(ui->actionNextPage, SIGNAL(triggered()), this, SLOT(nextPage()));
    connect(ui->actionLastPage, SIGNAL(triggered()), this, SLOT(lastPage()));
    connect(ui->actionFitWidth, SIGNAL(triggered()), preview, SLOT(fitToWidth()));
    connect(ui->actionFitHeight, SIGNAL(triggered()), preview, SLOT(fitInView()));
    connect(ui->actionPortrait, SIGNAL(triggered()), preview, SLOT(setPortraitOrientation()));
    connect(ui->actionLandscape, SIGNAL(triggered()), preview, SLOT(setLandscapeOrientation()));
    connect(ui->actionActualSize, SIGNAL(triggered()), this, SLOT(actualSize()));
    connect(ui->actionZoomIn, SIGNAL(triggered()), preview, SLOT(zoomIn()));
    connect(ui->actionZoomOut, SIGNAL(triggered()), preview, SLOT(zoomOut()));
    connect(ui->actionSinglePage, SIGNAL(triggered()), preview, SLOT(setSinglePageViewMode()));
    connect(ui->actionFacingPages, SIGNAL(triggered()), preview, SLOT(setFacingPagesViewMode()));
    connect(ui->actionAllPages, SIGNAL(triggered()), preview, SLOT(setAllPagesViewMode()));
    connect(ui->actionMainToolbar, SIGNAL(triggered(bool)), this, SLOT(toggleMainToolbar(bool)));
    connect(ui->actionViewToolbar, SIGNAL(triggered(bool)), this, SLOT(toggleViewToolbar(bool)));
    connect(ui->actionFontToolbar, SIGNAL(triggered(bool)), this, SLOT(toggleFontToolbar(bool)));
    connect(ui->actionStatusBar, SIGNAL(triggered(bool)), this, SLOT(toggleStatusBar(bool)));
    connect(ui->menuToolbars, SIGNAL(aboutToShow()), this, SLOT(updateToolbarMenu()));
    connect(ui->menuView, SIGNAL(aboutToShow()), this, SLOT(updateToolbarMenu()));
    connect(preview, SIGNAL(previewChanged()), this, SLOT(previewChanged()));

    connect(preview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(paint(QPrinter*)));
    connect(report, SIGNAL(loaded()), preview, SLOT(updatePreview()));
    connect(report, SIGNAL(changed()), preview, SLOT(updatePreview()));
    connect(report, SIGNAL(loaded()), this, SLOT(documentLoaded()));
    connect(report, SIGNAL(orientationChanged(QPrinter::Orientation)), this, SLOT(orientationChanged(QPrinter::Orientation)));
    connect(report, SIGNAL(lpiChanged(int)), this, SLOT(lpiChanged(int)));
    connect(report, SIGNAL(cpiChanged(int)), this, SLOT(cpiChanged(int)));
    connect(report, SIGNAL(boldChanged(bool)), ui->actionBold, SLOT(setChecked(bool)));
    connect(report, SIGNAL(fontChanged(QFont)), fontComboBox, SLOT(setCurrentFont(QFont)));

    QSettings settings;
    restoreGeometry(settings.value("geometry").toByteArray());
    restoreState(settings.value("state").toByteArray());
    recentFiles = settings.value("recentFiles").toStringList();
    currentFolder = settings.value("currentFolder").toString();
    ui->statusBar->setVisible(settings.value("statusBar", true).toBool());

    updateRecentFileActions();

    zoomTimer = new QTimer(this);
    connect(zoomTimer, SIGNAL(timeout()), this, SLOT(updateZoom()));
    connect(preview, SIGNAL(previewChanged()), this, SLOT(updateZoom()));
    zoomTimer->start(1000);
}
コード例 #4
0
SimpleFontDialog::SimpleFontDialog(const QFont& initial, QWidget* parent)
    : QDialog(parent)
{
    QFontComboBox* fontComboBox = new QFontComboBox(this);
    fontComboBox->setCurrentFont(initial);
    font = initial;

    QVBoxLayout* familyLayout = new QVBoxLayout();
    familyLayout->addWidget(new QLabel(tr("Family")));
    familyLayout->addWidget(fontComboBox);

    QList<int> sizes = QFontDatabase::standardSizes();

    QComboBox* sizeComboBox = new QComboBox(this);
    sizeComboBox->setEditable(true);

    QIntValidator* sizeValidator = new QIntValidator(1, 512, this);
    sizeComboBox->setValidator(sizeValidator);

    int currentSizeIndex = 0;
    QFontInfo fontInfo(initial);
    bool currentFontInserted = false;

    for (int i = 0; i < sizes.size(); i++)
    {
        int size = sizes[i];

        // If the current font size is a non-standard size, then insert
        // it in the appropriate place in the sorted list of fonts.
        //
        if ((fontInfo.pointSize() < size) && !currentFontInserted)
        {
            currentSizeIndex = i;
            sizeComboBox->addItem(QString("%1").arg(fontInfo.pointSize()), fontInfo.pointSize());
            currentFontInserted = true;
        }
        // Else current font size is in the standard font sizes list.  Set
        // the index in the combo box to its position in the list.
        //
        else
        {
            if (fontInfo.pointSize() == size)
            {
                currentSizeIndex = i;
                currentFontInserted = true;
            }
        }

        sizeComboBox->addItem(QString("%1").arg(size), size);
    }

    if (!currentFontInserted)
    {
        sizeComboBox->addItem(QString("%1").arg(fontInfo.pointSize()), fontInfo.pointSize());
        currentSizeIndex = sizeComboBox->count() - 1;
    }

    sizeComboBox->setCurrentIndex(currentSizeIndex);

    QVBoxLayout* sizeLayout = new QVBoxLayout();
    sizeLayout->addWidget(new QLabel(tr("Size")));
    sizeLayout->addWidget(sizeComboBox);

    fontPreview = new QLineEdit(tr("AaBbCcXxYyZz"), this);
    fontPreview->setFont(initial);

    QVBoxLayout* previewLayout = new QVBoxLayout();
    previewLayout->addWidget(new QLabel(tr("Preview")));
    previewLayout->addWidget(fontPreview);

    QDialogButtonBox* buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
    buttonBox->addButton(QDialogButtonBox::Ok);
    buttonBox->addButton(QDialogButtonBox::Cancel);

    QGridLayout* layout = new QGridLayout();
    layout->addItem(familyLayout, 0, 0);
    layout->addItem(sizeLayout, 0, 1);
    layout->addItem(previewLayout, 1, 0, 1, 2, Qt::AlignCenter);
    layout->addWidget(buttonBox, 2, 0, 1, 2);

    setLayout(layout);

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    connect(fontComboBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(onFontFamilyChanged(const QFont&)));
    connect(sizeComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(onFontSizeChanged(const QString&)));
    connect(sizeComboBox, SIGNAL(editTextChanged(QString)), this, SLOT(onFontSizeChanged(const QString&)));
}
コード例 #5
0
int main(int argc, char **argv)
{
    //! [0]
    QApplication app(argc, argv);
    Q3DScatter *graph = new Q3DScatter();
    QWidget *container = QWidget::createWindowContainer(graph);
    //! [0]

    if (!graph->hasContext()) {
        QMessageBox msgBox;
        msgBox.setText("Couldn't initialize the OpenGL context.");
        msgBox.exec();
        return -1;
    }

    QSize screenSize = graph->screen()->size();
    container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.5));
    container->setMaximumSize(screenSize);
    container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    container->setFocusPolicy(Qt::StrongFocus);

    //! [1]
    QWidget *widget = new QWidget;
    QHBoxLayout *hLayout = new QHBoxLayout(widget);
    QVBoxLayout *vLayout = new QVBoxLayout();
    hLayout->addWidget(container, 1);
    hLayout->addLayout(vLayout);
    //! [1]

    widget->setWindowTitle(QStringLiteral("A Cosine Wave"));

    //! [4]
    QComboBox *themeList = new QComboBox(widget);
    themeList->addItem(QStringLiteral("Qt"));
    themeList->addItem(QStringLiteral("Primary Colors"));
    themeList->addItem(QStringLiteral("Digia"));
    themeList->addItem(QStringLiteral("Stone Moss"));
    themeList->addItem(QStringLiteral("Army Blue"));
    themeList->addItem(QStringLiteral("Retro"));
    themeList->addItem(QStringLiteral("Ebony"));
    themeList->addItem(QStringLiteral("Isabelle"));
    themeList->setCurrentIndex(6);

    QPushButton *labelButton = new QPushButton(widget);
    labelButton->setText(QStringLiteral("Change label style"));

    QCheckBox *smoothCheckBox = new QCheckBox(widget);
    smoothCheckBox->setText(QStringLiteral("Smooth dots"));
    smoothCheckBox->setChecked(true);

    QComboBox *itemStyleList = new QComboBox(widget);
    itemStyleList->addItem(QStringLiteral("Sphere"), int(QAbstract3DSeries::MeshSphere));
    itemStyleList->addItem(QStringLiteral("Cube"), int(QAbstract3DSeries::MeshCube));
    itemStyleList->addItem(QStringLiteral("Minimal"), int(QAbstract3DSeries::MeshMinimal));
    itemStyleList->addItem(QStringLiteral("Point"), int(QAbstract3DSeries::MeshPoint));
    itemStyleList->setCurrentIndex(0);

    QPushButton *cameraButton = new QPushButton(widget);
    cameraButton->setText(QStringLiteral("Change camera preset"));

    QPushButton *itemCountButton = new QPushButton(widget);
    itemCountButton->setText(QStringLiteral("Toggle item count"));

    QCheckBox *backgroundCheckBox = new QCheckBox(widget);
    backgroundCheckBox->setText(QStringLiteral("Show background"));
    backgroundCheckBox->setChecked(true);

    QCheckBox *gridCheckBox = new QCheckBox(widget);
    gridCheckBox->setText(QStringLiteral("Show grid"));
    gridCheckBox->setChecked(true);

    QComboBox *shadowQuality = new QComboBox(widget);
    shadowQuality->addItem(QStringLiteral("None"));
    shadowQuality->addItem(QStringLiteral("Low"));
    shadowQuality->addItem(QStringLiteral("Medium"));
    shadowQuality->addItem(QStringLiteral("High"));
    shadowQuality->addItem(QStringLiteral("Low Soft"));
    shadowQuality->addItem(QStringLiteral("Medium Soft"));
    shadowQuality->addItem(QStringLiteral("High Soft"));
    shadowQuality->setCurrentIndex(4);

    QFontComboBox *fontList = new QFontComboBox(widget);
    fontList->setCurrentFont(QFont("Arial"));
    //! [4]

    //! [5]
    vLayout->addWidget(labelButton, 0, Qt::AlignTop);
    vLayout->addWidget(cameraButton, 0, Qt::AlignTop);
    vLayout->addWidget(itemCountButton, 0, Qt::AlignTop);
    vLayout->addWidget(backgroundCheckBox);
    vLayout->addWidget(gridCheckBox);
    vLayout->addWidget(smoothCheckBox, 0, Qt::AlignTop);
    vLayout->addWidget(new QLabel(QStringLiteral("Change dot style")));
    vLayout->addWidget(itemStyleList);
    vLayout->addWidget(new QLabel(QStringLiteral("Change theme")));
    vLayout->addWidget(themeList);
    vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality")));
    vLayout->addWidget(shadowQuality);
    vLayout->addWidget(new QLabel(QStringLiteral("Change font")));
    vLayout->addWidget(fontList, 1, Qt::AlignTop);
    //! [5]

    //! [2]
    ScatterDataModifier *modifier = new ScatterDataModifier(graph);
    //! [2]

    //! [6]
    QObject::connect(cameraButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::changePresetCamera);
    QObject::connect(labelButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::changeLabelStyle);
    QObject::connect(itemCountButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::toggleItemCount);

    QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setBackgroundEnabled);
    QObject::connect(gridCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setGridEnabled);
    QObject::connect(smoothCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setSmoothDots);

    QObject::connect(modifier, &ScatterDataModifier::backgroundEnabledChanged,
                     backgroundCheckBox, &QCheckBox::setChecked);
    QObject::connect(modifier, &ScatterDataModifier::gridEnabledChanged,
                     gridCheckBox, &QCheckBox::setChecked);
    QObject::connect(itemStyleList, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeStyle(int)));

    QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeTheme(int)));

    QObject::connect(shadowQuality, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeShadowQuality(int)));

    QObject::connect(modifier, &ScatterDataModifier::shadowQualityChanged, shadowQuality,
                     &QComboBox::setCurrentIndex);
    QObject::connect(graph, &Q3DScatter::shadowQualityChanged, modifier,
                     &ScatterDataModifier::shadowQualityUpdatedByVisual);

    QObject::connect(fontList, &QFontComboBox::currentFontChanged, modifier,
                     &ScatterDataModifier::changeFont);

    QObject::connect(modifier, &ScatterDataModifier::fontChanged, fontList,
                     &QFontComboBox::setCurrentFont);
    //! [6]

    //! [3]
    widget->show();
    return app.exec();
    //! [3]
}
コード例 #6
0
void PropertiesEditorItem::prepareWidget()
{
    QWidget *editor = 0;

    if (mProperty.type() == QVariant::BitArray) {

    } else if (mProperty.type() == QVariant::Bitmap) {

    } else if (mProperty.type() == QVariant::Bool) {
        QCheckBox *checkBox = new QCheckBox(parent());
        checkBox->setText(QString());
        checkBox->setChecked(mProperty.read(mObject.data()).toBool());
        editor = qobject_cast< QWidget* >(checkBox);
        connect(checkBox, SIGNAL(toggled(bool)), SLOT(slotCheckBoxToggled()));

    } else if (mProperty.type() == QVariant::Brush) {

    } else if (mProperty.type() == QVariant::ByteArray) {

    } else if (mProperty.type() == QVariant::Char) {

    } else if (mProperty.type() == QVariant::Color) {
        QPushButton *button = new QPushButton(parent());
        button->setText(mProperty.read(mObject.data()).value<QColor>().name());
        connect(button, SIGNAL(clicked(bool)), SLOT(slotOpenColorEditor()));
        editor = qobject_cast< QWidget* >(button);

    } else if (mProperty.type() == QVariant::Cursor) {

    } else if (mProperty.type() == QVariant::Date) {

    } else if (mProperty.type() == QVariant::DateTime) {

    } else if (mProperty.type() == QVariant::Double) {
        QDoubleSpinBox *spinBox = new QDoubleSpinBox(parent());
        spinBox->setMaximum(LONG_MAX);
        spinBox->setMinimum(LONG_MIN);
        spinBox->setSingleStep(0.01);
        spinBox->setValue(mProperty.read(mObject.data()).toDouble());
        editor = qobject_cast< QWidget* >(spinBox);
        connect(spinBox, SIGNAL(valueChanged(double)), SLOT(slotDoubleSpinBoxValueChanged()));

    } else if (mProperty.type() == QVariant::EasingCurve) {
        QPushButton *button = new QPushButton(parent());
        QEasingCurve curve = mProperty.read(mObject.data()).toEasingCurve();
        button->setText(curve.staticMetaObject.enumerator(0).valueToKey(curve.type()));
        connect(button, SIGNAL(clicked(bool)), SLOT(slotOpenEasingCurveEditor()));
        editor = qobject_cast< QWidget* >(button);

    } else if (mProperty.type() == QVariant::Font) {
        QFontComboBox *comboBox = new QFontComboBox(parent());
        comboBox->setCurrentFont(mProperty.read(mObject.data()).value<QFont>());
        editor = qobject_cast< QWidget* >(comboBox);
        connect(comboBox, SIGNAL(currentFontChanged(QFont)), SLOT(slotFontComboChanged()));

    } else if (mProperty.type() == QVariant::Hash) {

    } else if (mProperty.type() == QVariant::Icon) {

    } else if (mProperty.type() == QVariant::Image) {

    } else if (mProperty.type() == QVariant::Int) {
        QSpinBox *spinBox = new QSpinBox(parent());
        spinBox->setMinimum(INT_MIN);
        spinBox->setMaximum(INT_MAX);
        spinBox->setValue(mProperty.read(mObject.data()).toInt());
        editor = qobject_cast< QWidget* >(spinBox);
        connect(spinBox, SIGNAL(valueChanged(int)), SLOT(slotSpinBoxValueChanged()));

    } else if (mProperty.type() == QVariant::KeySequence) {

    } else if (mProperty.type() == QVariant::Line) {

    } else if (mProperty.type() == QVariant::LineF) {

    } else if (mProperty.type() == QVariant::List) {

    } else if (mProperty.type() == QVariant::Locale) {

    } else if (mProperty.type() == QVariant::LongLong) {
        QDoubleSpinBox *spinBox = new QDoubleSpinBox(parent());
        spinBox->setSingleStep(1.0);
        spinBox->setDecimals(0);
        spinBox->setMaximum(LONG_MAX);
        spinBox->setMinimum(LONG_MIN);
        spinBox->setValue(mProperty.read(mObject.data()).toLongLong());
        editor = qobject_cast< QWidget* >(spinBox);
        connect(spinBox, SIGNAL(valueChanged(int)), SLOT(slotDoubleSpinBoxValueChanged()));

    } else if (mProperty.type() == QVariant::Map) {

    } else if (mProperty.type() == QVariant::Matrix) {

    } else if (mProperty.type() == QVariant::Matrix4x4) {

    } else if (mProperty.type() == QVariant::Palette) {

    } else if (mProperty.type() == QVariant::Pen) {

    } else if (mProperty.type() == QVariant::Pixmap) {

    } else if (mProperty.type() == QVariant::Point) {

    } else if (mProperty.type() == QVariant::PointF) {

    } else if (mProperty.type() == QVariant::Polygon) {

    } else if (mProperty.type() == QVariant::Quaternion) {

    } else if (mProperty.type() == QVariant::Rect) {

    } else if (mProperty.type() == QVariant::RectF) {

    } else if (mProperty.type() == QVariant::RegExp) {

    } else if (mProperty.type() == QVariant::Region) {

    } else if (mProperty.type() == QVariant::Size) {

    } else if (mProperty.type() == QVariant::SizeF) {

    } else if (mProperty.type() == QVariant::SizePolicy) {

    } else if (mProperty.type() == QVariant::String) {
        QLineEdit *lineEdit = new QLineEdit(parent());
        lineEdit->setText(mProperty.read(mObject.data()).toString());
        editor = qobject_cast< QWidget* >(lineEdit);
        connect(lineEdit, SIGNAL(textChanged(QString)), SLOT(slotLineEditChanged()));

    } else if (mProperty.type() == QVariant::StringList) {

    } else if (mProperty.type() == QVariant::TextFormat) {

    } else if (mProperty.type() == QVariant::TextLength) {

    } else if (mProperty.type() == QVariant::Time) {

    } else if (mProperty.type() == QVariant::Transform) {

    } else if (mProperty.type() == QVariant::UInt) {
        QSpinBox *spinBox = new QSpinBox(parent());
        spinBox->setMaximum(UINT_MAX);
        spinBox->setMinimum(0);
        spinBox->setValue(mProperty.read(mObject.data()).toUInt());
        editor = qobject_cast< QWidget* >(spinBox);
        connect(spinBox, SIGNAL(valueChanged(int)), SLOT(slotSpinBoxValueChanged()));

    } else if (mProperty.type() == QVariant::ULongLong) {
        QDoubleSpinBox *spinBox = new QDoubleSpinBox(parent());
        spinBox->setSingleStep(1.0);
        spinBox->setDecimals(0);
        spinBox->setMinimum(0);
        spinBox->setMaximum(ULONG_MAX);
        spinBox->setValue(mProperty.read(mObject.data()).toULongLong());
        editor = qobject_cast< QWidget* >(spinBox);
        connect(spinBox, SIGNAL(valueChanged(int)), SLOT(slotDoubleSpinBoxValueChanged()));

    } else if (mProperty.type() == QVariant::Url) {
        QPushButton *button = new QPushButton(parent());
        QUrl url = mProperty.read(mObject.data()).toUrl();
        setButtonUrl(button, url);
        editor = qobject_cast< QWidget* >(button);
        connect(button, SIGNAL(clicked(bool)), SLOT(slotUrlButtonClicked()));

    } else if (mProperty.type() == QVariant::UserType) {

    } else if (mProperty.type() == QVariant::Vector2D) {

    } else if (mProperty.type() == QVariant::Vector3D) {

    } else if (mProperty.type() == QVariant::Vector4D) {

    }

    mWidget = editor;
}
コード例 #7
0
void PropertiesEditorItem::slotPropertyValueChanged()
{
    if (mProperty.type() == QVariant::BitArray) {

    } else if (mProperty.type() == QVariant::Bitmap) {

    } else if (mProperty.type() == QVariant::Bool) {
        QCheckBox *checkBox = qobject_cast<QCheckBox*>(mWidget.data());
        checkBox->setChecked(mProperty.read(mObject.data()).toBool());

    } else if (mProperty.type() == QVariant::Brush) {

    } else if (mProperty.type() == QVariant::ByteArray) {

    } else if (mProperty.type() == QVariant::Char) {

    } else if (mProperty.type() == QVariant::Color) {

    } else if (mProperty.type() == QVariant::Cursor) {

    } else if (mProperty.type() == QVariant::Date) {

    } else if (mProperty.type() == QVariant::DateTime) {

    } else if (mProperty.type() == QVariant::Double) {
        QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(mWidget.data());
        spinBox->setValue(mProperty.read(mObject.data()).toDouble());

    } else if (mProperty.type() == QVariant::EasingCurve) {
        QPushButton *button = qobject_cast<QPushButton*>(mWidget.data());
        QEasingCurve curve = mProperty.read(mObject.data()).toEasingCurve();
        button->setText(curve.staticMetaObject.enumerator(0).valueToKey(curve.type()));

    } else if (mProperty.type() == QVariant::Font) {
        QFontComboBox *comboBox = qobject_cast<QFontComboBox*>(mWidget.data());
        comboBox->setCurrentFont(mProperty.read(mObject.data()).value<QFont>());

    } else if (mProperty.type() == QVariant::Hash) {

    } else if (mProperty.type() == QVariant::Icon) {

    } else if (mProperty.type() == QVariant::Image) {

    } else if (mProperty.type() == QVariant::Int) {
        QSpinBox *spinBox = qobject_cast<QSpinBox*>(mWidget.data());
        spinBox->setValue(mProperty.read(mObject.data()).toInt());

    } else if (mProperty.type() == QVariant::KeySequence) {

    } else if (mProperty.type() == QVariant::Line) {

    } else if (mProperty.type() == QVariant::LineF) {

    } else if (mProperty.type() == QVariant::List) {

    } else if (mProperty.type() == QVariant::Locale) {

    } else if (mProperty.type() == QVariant::LongLong) {
        QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(mWidget.data());
        spinBox->setValue(mProperty.read(mObject.data()).toLongLong());

    } else if (mProperty.type() == QVariant::Map) {

    } else if (mProperty.type() == QVariant::Matrix) {

    } else if (mProperty.type() == QVariant::Matrix4x4) {

    } else if (mProperty.type() == QVariant::Palette) {

    } else if (mProperty.type() == QVariant::Pen) {

    } else if (mProperty.type() == QVariant::Pixmap) {

    } else if (mProperty.type() == QVariant::Point) {

    } else if (mProperty.type() == QVariant::PointF) {

    } else if (mProperty.type() == QVariant::Polygon) {

    } else if (mProperty.type() == QVariant::Quaternion) {

    } else if (mProperty.type() == QVariant::Rect) {

    } else if (mProperty.type() == QVariant::RectF) {

    } else if (mProperty.type() == QVariant::RegExp) {

    } else if (mProperty.type() == QVariant::Region) {

    } else if (mProperty.type() == QVariant::Size) {

    } else if (mProperty.type() == QVariant::SizeF) {

    } else if (mProperty.type() == QVariant::SizePolicy) {

    } else if (mProperty.type() == QVariant::String) {
        QLineEdit *lineEdit = qobject_cast<QLineEdit*>(mWidget.data());
        lineEdit->setText(mProperty.read(mObject.data()).toString());

    } else if (mProperty.type() == QVariant::StringList) {

    } else if (mProperty.type() == QVariant::TextFormat) {

    } else if (mProperty.type() == QVariant::TextLength) {

    } else if (mProperty.type() == QVariant::Time) {

    } else if (mProperty.type() == QVariant::Transform) {

    } else if (mProperty.type() == QVariant::UInt) {
        QSpinBox *spinBox = qobject_cast<QSpinBox*>(mWidget.data());
        spinBox->setValue(mProperty.read(mObject.data()).toUInt());

    } else if (mProperty.type() == QVariant::ULongLong) {
        QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(mWidget.data());
        spinBox->setValue(mProperty.read(mObject.data()).toULongLong());

    } else if (mProperty.type() == QVariant::Url) {
        QPushButton *button = qobject_cast<QPushButton*>(mWidget.data());
        QUrl url = mProperty.read(mObject.data()).toUrl();
        setButtonUrl(button, url);

    } else if (mProperty.type() == QVariant::UserType) {

    } else if (mProperty.type() == QVariant::Vector2D) {

    } else if (mProperty.type() == QVariant::Vector3D) {

    } else if (mProperty.type() == QVariant::Vector4D) {

    }
}