Beispiel #1
0
void Workbench::activated()
{
    if (!initialized) {
        QList<QToolBar*> bars = Gui::getMainWindow()->findChildren<QToolBar*>(QString::fromLatin1("Spreadsheet"));

        if (bars.size() == 1) {
            QToolBar * bar = bars[0];
            QtColorPicker * foregroundColor;
            QtColorPicker * backgroundColor;
            QPalette palette = Gui::getMainWindow()->palette();

            QList<QtColorPicker*> fgList = Gui::getMainWindow()->findChildren<QtColorPicker*>(QString::fromLatin1("Spreadsheet_ForegroundColor"));
            if (fgList.size() > 0)
                foregroundColor = fgList[0];
            else {
                foregroundColor = new QtColorPicker();
                foregroundColor->setObjectName(QString::fromLatin1("Spreadsheet_ForegroundColor"));
                foregroundColor->setStandardColors();
                foregroundColor->setCurrentColor(palette.color(QPalette::Foreground));
                QObject::connect(foregroundColor, SIGNAL(colorSet(QColor)), workbenchHelper.get(), SLOT(setForegroundColor(QColor)));
            }
            bar->addWidget(foregroundColor);

            QList<QtColorPicker*> bgList = Gui::getMainWindow()->findChildren<QtColorPicker*>(QString::fromLatin1("Spreadsheet_BackgroundColor"));
            if (bgList.size() > 0)
                backgroundColor = bgList[0];
            else {
                backgroundColor = new QtColorPicker();
                backgroundColor->setObjectName(QString::fromLatin1("Spreadsheet_BackgroundColor"));
                backgroundColor->setStandardColors();
                backgroundColor->setCurrentColor(palette.color(QPalette::Base));
                QObject::connect(backgroundColor, SIGNAL(colorSet(QColor)), workbenchHelper.get(), SLOT(setBackgroundColor(QColor)));
            }
            bar->addWidget(backgroundColor);

            initialized = false;
        }
    }
}
void XletSwitchBoard::mouseReleaseEvent(QMouseEvent *)
{
    // qDebug() << Q_FUNC_INFO;
    if (m_trace_box) {
        QRect rect = QRect(m_first_corner, m_second_corner).normalized();

        QRect gridRect = m_layout->getGridRect(rect);
        if ((gridRect.top() != gridRect.bottom()) &&
           (gridRect.right() != gridRect.left())) {
            QString name;
            QDialog dialog;
            dialog.setWindowTitle(tr("New group"));
            QVBoxLayout *layout = new QVBoxLayout(&dialog);
            layout->addWidget(new QLabel(tr("Please enter a name for the new group"), &dialog));
            QLineEdit *lineedit = new QLineEdit(&dialog);
            layout->addWidget(lineedit);
            layout->addWidget(new QLabel(tr("Please choose a color for the new group"), &dialog));
            QtColorPicker *colorpicker = new QtColorPicker(&dialog);
            colorpicker->setStandardColors();
            colorpicker->setCurrentColor(QColor(63, 63, 255));
            layout->addWidget(colorpicker);
            QDialogButtonBox *buttonbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
                                                               Qt::Horizontal, &dialog);
            layout->addWidget(buttonbox);
            connect(buttonbox, SIGNAL(accepted()),
                    &dialog, SLOT(accept()) );
            connect(buttonbox, SIGNAL(rejected()),
                    &dialog, SLOT(reject()) );
            dialog.exec();
            if (dialog.result() == QDialog::Accepted)
                name = lineedit->text();
            if (!name.isEmpty()) {
                Group *group = new Group(this);
                group->setRect(gridRect);
                group->setName(name);
                group->setColor(colorpicker->currentColor());
                m_group_list.append(group);
                saveGroups();
            }
        }
        m_trace_box = false;
        update();
    }
    if (m_group_to_resize) {
        unsetCursor();
        m_group_to_resize = NULL;
    }
}
Beispiel #3
0
void CoreWindow::createToolBar()
{ 
	//inicializacia comboboxu typov vyberu
	nodeTypeComboBox = new QComboBox();
	nodeTypeComboBox->insertItems(0,(QStringList() << "All" << "Node" << "Edge"));
	nodeTypeComboBox->setFocusPolicy(Qt::NoFocus);	
	connect(nodeTypeComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(nodeTypeComboBoxChanged(int)));

	toolBar = new QToolBar("Tools",this);

	QFrame * frame = createHorizontalFrame();
	
	frame->layout()->addWidget(noSelect);
	frame->layout()->addWidget(singleSelect);
	toolBar->addWidget(frame);
	
	frame = createHorizontalFrame();
	toolBar->addWidget(frame);
	frame->layout()->addWidget(multiSelect);
	frame->layout()->addWidget(center);

	toolBar->addWidget(nodeTypeComboBox);
	toolBar->addSeparator();

	frame = createHorizontalFrame();

	toolBar->addWidget(frame);
	frame->layout()->addWidget(addMeta);
	frame->layout()->addWidget(removeMeta);

	frame = createHorizontalFrame();

	toolBar->addWidget(frame);
	frame->layout()->addWidget(fix);
	frame->layout()->addWidget(unFix);

	frame = createHorizontalFrame();

	toolBar->addWidget(frame);
	frame->layout()->addWidget(merge);
	frame->layout()->addWidget(separate);

	toolBar->addWidget(label);
	toolBar->addSeparator();
	toolBar->addWidget(play);
	toolBar->addSeparator();
	toolBar->addWidget(add_Edge);
	toolBar->addWidget(add_Node);
	toolBar->addWidget(remove_all);
	toolBar->addWidget(applyColor);
	
	//inicializacia colorpickera
	QtColorPicker * colorPicker = new QtColorPicker();
	colorPicker->setStandardColors();
	connect(colorPicker,SIGNAL(colorChanged(const QColor &)),this,SLOT(colorPickerChanged(const QColor &)));
	toolBar->addWidget(colorPicker);	
	toolBar->addSeparator();
	
	// layout restrictions
	frame = createHorizontalFrame();
	toolBar->addWidget(frame);
	frame->layout()->addWidget(b_SetRestriction_SphereSurface);
	frame->layout()->addWidget(b_SetRestriction_Sphere);

	frame = createHorizontalFrame();
	toolBar->addWidget(frame);
	frame->layout()->addWidget(b_SetRestriction_Plane);
	frame->layout()->addWidget(b_UnsetRestriction);

	toolBar->addSeparator();

	//inicializacia slideru
	slider = new QSlider(Qt::Vertical,this);
	slider->setTickPosition(QSlider::TicksAbove);
	slider->setTickInterval(5);
	slider->setValue(5);
	slider->setFocusPolicy(Qt::NoFocus);	
	connect(slider,SIGNAL(valueChanged(int)),this,SLOT(sliderValueChanged(int)));
	
	frame = createHorizontalFrame();
	frame->setMaximumHeight(100);
	frame->layout()->setAlignment(Qt::AlignHCenter);
	toolBar->addWidget(frame);
	frame->layout()->addWidget(slider);


	addToolBar(Qt::LeftToolBarArea,toolBar);
	toolBar->setMovable(false);
}