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 #2
0
void Preferences::setColourPalette(QtColorPicker &p)
{
	const int numColours = 8;
	const int numShades = 5;
	struct { QColor c; char *n; int f; } colours[] =
	{
		QColor(240,100,0),		"orange",		115,
		QColor("darkred"),		"red",			125,
		QColor("darkolivegreen"),"olivegreen",	125,
		QColor("darkblue"),		"blue",			125,
		QColor("forestgreen"),	"forestgreen",	125,
		QColor("saddlebrown"),	"saddlebrown",	120,
		QColor(50,110,175),		"steelblue",	115,
		QColor(148,44,196),		"orchid",		115,
	};

	p.setPopupShape(Shape_FixedCols);
	p.setPopupRowsOrCols(numShades+1);

	for(int i = 0; i < numColours; i++)
	{
		QColor c(colours[i].c); // copy so can create lighter versions
		QString nm = QString("%1\n%2").arg(colours[i].n).arg(c.name().toUpper());
		p.insertColor(c, nm);

		for(int j = 0; j < numShades; j++)
		{
			c = c.lighter(colours[i].f);
			QString nm = QString("%1\n%2").arg(colours[i].n).arg(c.name().toUpper());
			p.insertColor(c, nm);
		}
	}

    p.insertColor(QColor("black"), tr("black"));			// 0
    p.insertColor(QColor("dimgrey"), tr("dimgrey"));		// 105
    p.insertColor(QColor("gray"), tr("gray"));				// 128
    p.insertColor(QColor("silver"), tr("silver"));			// 192
    p.insertColor(QColor("lightgrey"), tr("lightgrey"));	// 211
    p.insertColor(QColor("white"), tr("white"));			// 255

}
Beispiel #3
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;
        }
    }
}
Beispiel #4
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QtColorPicker window;
    window.insertColor(QColor("white"), "White");
    window.insertColor(QColor("black"), "Black");
    window.insertColor(QColor("green"), "Green");
    window.insertColor(QColor("darkGreen"), "Dark green");
    window.insertColor(QColor("blue"), "Blue");
    window.insertColor(QColor("darkBlue"), "Dark blue");
    window.insertColor(QColor("cyan"), "Cyan");
    window.insertColor(QColor("darkCyan"), "Dark cyan");
    window.insertColor(QColor("magenta"), "Magenta");
    window.insertColor(QColor("darkMagenta"), "Dark magenta");
    window.insertColor(QColor("yellow"), "Yellow");
    window.insertColor(QColor("grey"), "Grey");

    window.show();

    return app.exec();
}
Beispiel #5
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);
}