コード例 #1
0
StrokeDocker::StrokeDocker()
    : d( new Private() )
{
    setWindowTitle( i18n( "Stroke Properties" ) );

    QWidget *mainWidget = new QWidget( this );
    QGridLayout *mainLayout = new QGridLayout( mainWidget );

    QLabel * styleLabel = new QLabel( i18n( "Style:" ), mainWidget );
    mainLayout->addWidget( styleLabel, 0, 0 );
    d->lineStyle = new KoLineStyleSelector( mainWidget );
    mainLayout->addWidget( d->lineStyle, 0, 1, 1, 3 );

    connect( d->lineStyle, SIGNAL(currentIndexChanged( int ) ), this, SLOT( styleChanged() ) );

    QLabel* widthLabel = new QLabel( i18n ( "Width:" ), mainWidget );
    mainLayout->addWidget( widthLabel, 1, 0 );
    // set min/max/step and value in points, then set actual unit
    d->setLineWidth = new KoUnitDoubleSpinBox( mainWidget );
    d->setLineWidth->setMinMaxStep( 0.0, 1000.0, 0.5 );
    d->setLineWidth->setDecimals( 2 );
    d->setLineWidth->setUnit( KoUnit(KoUnit::Point) );
    d->setLineWidth->setToolTip( i18n( "Set line width of actual selection" ) );
    mainLayout->addWidget( d->setLineWidth, 1, 1, 1, 3 );
    connect( d->setLineWidth, SIGNAL( valueChangedPt( qreal ) ), this, SLOT( widthChanged() ) );

    QLabel* capLabel = new QLabel( i18n ( "Cap:" ), mainWidget );
    mainLayout->addWidget( capLabel, 2, 0 );
    d->capGroup = new QButtonGroup( mainWidget );
    d->capGroup->setExclusive( true );
    d->capGroup->setExclusive( true );

    QRadioButton *button = 0;

    button = new QRadioButton( mainWidget );
    button->setIcon( SmallIcon( "cap_butt" ) );
    button->setCheckable( true );
    button->setToolTip( i18n( "Butt cap" ) );
    d->capGroup->addButton( button, Qt::FlatCap );
    mainLayout->addWidget( button, 2, 1 );

    button = new QRadioButton( mainWidget );
    button->setIcon( SmallIcon( "cap_round" ) );
    button->setCheckable( true );
    button->setToolTip( i18n( "Round cap" ) );
    d->capGroup->addButton( button, Qt::RoundCap );
    mainLayout->addWidget( button, 2, 2 );

    button = new QRadioButton( mainWidget );
    button->setIcon( SmallIcon( "cap_square" ) );
    button->setCheckable( true );
    button->setToolTip( i18n( "Square cap" ) );
    d->capGroup->addButton( button, Qt::SquareCap );
    mainLayout->addWidget( button, 2, 3 );

    connect( d->capGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( slotCapChanged( int ) ) );

    QLabel* joinLabel = new QLabel( i18n ( "Join:" ), mainWidget );
    mainLayout->addWidget( joinLabel, 3, 0 );

    d->joinGroup = new QButtonGroup( mainWidget );
    d->joinGroup->setExclusive( true );

    button = new QRadioButton( mainWidget );
    button->setIcon( SmallIcon( "join_miter" ) );
    button->setCheckable( true );
    button->setToolTip( i18n( "Miter join" ) );
    d->joinGroup->addButton( button, Qt::MiterJoin );
    mainLayout->addWidget( button, 3, 1 );

    button = new QRadioButton( mainWidget );
    button->setIcon( SmallIcon( "join_round" ) );
    button->setCheckable( true );
    button->setToolTip( i18n( "Round join" ) );
    d->joinGroup->addButton( button, Qt::RoundJoin );
    mainLayout->addWidget( button, 3, 2 );

    button = new QRadioButton( mainWidget );
    button->setIcon( SmallIcon( "join_bevel" ) );
    button->setCheckable( true );
    button->setToolTip( i18n( "Bevel join" ) );
    d->joinGroup->addButton( button, Qt::BevelJoin );
    mainLayout->addWidget( button, 3, 3 );

    connect( d->joinGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( slotJoinChanged( int ) ) );

    QLabel* miterLabel = new QLabel( i18n ( "Miter limit:" ), mainWidget );
    mainLayout->addWidget( miterLabel, 4, 0 );
    // set min/max/step and value in points, then set actual unit
    d->miterLimit = new KoUnitDoubleSpinBox( mainWidget );
    d->miterLimit->setMinMaxStep( 0.0, 1000.0, 0.5 );
    d->miterLimit->setDecimals( 2 );
    d->miterLimit->setUnit( KoUnit(KoUnit::Point) );
    d->miterLimit->setToolTip( i18n( "Set miter limit" ) );
    mainLayout->addWidget( d->miterLimit, 4, 1, 1, 3 );
    connect( d->miterLimit, SIGNAL( valueChangedPt( qreal ) ), this, SLOT( miterLimitChanged() ) );

    mainLayout->setRowStretch( 5, 1 );
    mainLayout->setColumnStretch( 1, 1 );
    mainLayout->setColumnStretch( 2, 1 );
    mainLayout->setColumnStretch( 3, 1 );

    setWidget( mainWidget );

    updateControls();
}
コード例 #2
0
ファイル: new_game_tab.cpp プロジェクト: gottcode/tetzle
NewGameTab::NewGameTab(const QStringList& files, QDialog* parent)
	: QWidget(parent)
{
	// Add image filter
	m_image_tags = new TagManager(this);
	connect(m_image_tags, &TagManager::filterChanged, this, &NewGameTab::filterImages);
	connect(m_image_tags, &TagManager::tagsChanged, this, &NewGameTab::updateTagsStrings);

	// Add image selector
	m_images = new ToolBarList(this);
	m_images->setViewMode(QListView::IconMode);
	m_images->setIconSize(QSize(74, 74));
	m_images->setMinimumSize(460 + m_images->verticalScrollBar()->sizeHint().width(), 230);
	m_images->setItemDelegate(new ThumbnailDelegate(m_images));
	connect(m_images, &ToolBarList::currentItemChanged, this, &NewGameTab::imageSelected);
	connect(m_images, &ToolBarList::itemActivated, this, &NewGameTab::editImageProperties);

	// Add image actions
	QAction* add_action = new QAction(m_images->fetchIcon("list-add"), tr("Add Image"), this);
	m_images->addToolBarAction(add_action);
	connect(add_action, &QAction::triggered, this, &NewGameTab::addImageClicked);

	m_remove_action = new QAction(m_images->fetchIcon("list-remove"), tr("Remove Image"), this);
	m_images->addToolBarAction(m_remove_action);
	connect(m_remove_action, &QAction::triggered, this, &NewGameTab::removeImage);

	m_tag_action = new QAction(m_images->fetchIcon("image-x-generic"), tr("Image Properties"), this);
	m_images->addToolBarAction(m_tag_action);
	connect(m_tag_action, &QAction::triggered, this, &NewGameTab::editImageProperties);

	// Add image splitter
	m_image_contents = new QSplitter(this);
	m_image_contents->addWidget(m_image_tags);
	m_image_contents->addWidget(m_images);
	m_image_contents->setStretchFactor(0, 0);
	m_image_contents->setStretchFactor(1, 1);
	m_image_contents->setSizes(QList<int>() << 130 << m_images->minimumWidth());

	// Add pieces slider
	m_slider = new QSlider(Qt::Horizontal, this);
	m_slider->setRange(1, 1);
	connect(m_slider, &QSlider::valueChanged, this, &NewGameTab::pieceCountChanged);

	m_count = new QLabel(this);
	m_count->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
	m_count->setMinimumWidth(m_count->fontMetrics().boundingRect(tr("%L1 pieces").arg(9999)).width());

	// Add buttons
	QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
	connect(buttons, &QDialogButtonBox::accepted, this, &NewGameTab::accept);
	connect(buttons, &QDialogButtonBox::rejected, parent, &QDialog::reject);

	m_accept_button = buttons->button(QDialogButtonBox::Ok);
	m_accept_button->setEnabled(false);

	// Arrange widgets
	QGridLayout* layout = new QGridLayout(this);
	layout->setColumnStretch(1, 1);
	layout->setRowStretch(0, 1);
	layout->addWidget(m_image_contents, 0, 0, 1, 2);
	layout->setRowMinimumHeight(1, 12);
	layout->addWidget(m_count, 2, 0);
	layout->addWidget(m_slider, 2, 1);
	layout->setRowMinimumHeight(3, 12);
	layout->addWidget(buttons, 4, 0, 1, 2);

	// Load images
	QSettings details(Path::image("details"), QSettings::IniFormat);
	QListWidgetItem* item = 0;
	for (const QString& image : QDir(Path::images(), "*.*").entryList(QDir::Files, QDir::Time | QDir::Reversed)) {
		item = createItem(image, details);
	}
	m_images->sortItems();

	// Load values
	QSettings settings;
	item = m_images->item(0);
	QString image = settings.value("NewGame/Image").toString();
	if (!image.isEmpty()) {
		for (int i = m_images->count() - 1; i >= 0; --i) {
			item = m_images->item(i);
			if (item->data(ImageRole) == image) {
				break;
			}
		}
	}
	m_images->setCurrentItem(item);
	m_slider->setValue(settings.value("NewGame/Pieces", 2).toInt());
	pieceCountChanged(m_slider->value());

	// Add new images
	addImages(files);

	// Resize contents
	m_image_contents->restoreState(settings.value("NewGame/SplitterSizes").toByteArray());
}
コード例 #3
0
medReformatViewer::medReformatViewer(medAbstractView * view,QWidget * parent): medAbstractView(parent)
{
    int * imageDims;
    vtkImageView3D * view3d;
    if (!view)
        return;

    inputData = static_cast<medAbstractLayeredView*>(view)->layerData(0);

    view3d = static_cast<medVtkViewBackend*>(view->backend())->view3D;

    vtkViewData = vtkSmartPointer<vtkImageData>::New();
    vtkViewData->DeepCopy(view3d->GetInput());
    imageDims = vtkViewData->GetDimensions();

    viewBody = new QWidget(parent);
    for (int i = 0; i < 3; i++)
    {
        riw[i] = vtkSmartPointer<vtkResliceImageViewer>::New();
        frames[i] = new QVTKFrame(viewBody);
        views[i] = frames[i]->getView();
        views[i]->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Minimum );
        if (i==0)
            frames[i]->setStyleSheet("* {border : 1px solid #FF0000;}");
        else if (i==1)
            frames[i]->setStyleSheet("* {border : 1px solid #00FF00;}");
        else if (i==2)
            frames[i]->setStyleSheet("* {border : 1px solid #0000FF;}");
        views[i]->installEventFilter(this);
    }
    frames[3] = new QVTKFrame(viewBody);
    views[3] = frames[3]->getView();
    views[3]->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Minimum );
    QGridLayout * gridLayout = new QGridLayout(parent);
    gridLayout->addWidget(frames[2],0,0);
    gridLayout->addWidget(frames[3],0,1);
    gridLayout->addWidget(frames[1],1,0);
    gridLayout->addWidget(frames[0],1,1);

    gridLayout->setColumnStretch ( 0, 0 );
    gridLayout->setColumnStretch ( 1, 0 );
    gridLayout->setRowStretch ( 0, 0 );
    gridLayout->setRowStretch ( 1, 0 );

    viewBody->setLayout(gridLayout);
    
    views[0]->SetRenderWindow(riw[0]->GetRenderWindow()); 
    riw[0]->SetupInteractor(views[0]->GetRenderWindow()->GetInteractor());


    views[1]->SetRenderWindow(riw[1]->GetRenderWindow());
    riw[1]->SetupInteractor(views[1]->GetRenderWindow()->GetInteractor());

    views[2]->SetRenderWindow(riw[2]->GetRenderWindow());
    riw[2]->SetupInteractor(views[2]->GetRenderWindow()->GetInteractor());

    for (int i = 0; i < 3; i++)
    {
        // make them all share the same reslice cursor object.

        vtkResliceCursorLineRepresentation *rep = vtkResliceCursorLineRepresentation::SafeDownCast(
                    riw[i]->GetResliceCursorWidget()->GetRepresentation());
        riw[i]->SetResliceCursor(riw[2]->GetResliceCursor());

        rep->GetResliceCursorActor()->GetCursorAlgorithm()->SetReslicePlaneNormal(i);

        riw[i]->SetInput(vtkViewData); 
        riw[i]->SetSliceOrientation(i);
        riw[i]->SetResliceModeToOblique();
    }

    vtkViewData->GetSpacing(outputSpacing);

    vtkSmartPointer<vtkCellPicker> picker = vtkSmartPointer<vtkCellPicker>::New();
    picker->SetTolerance(0.005);

    vtkSmartPointer<vtkProperty> ipwProp = vtkSmartPointer<vtkProperty>::New();

    vtkSmartPointer< vtkRenderer > ren = vtkSmartPointer< vtkRenderer >::New();

    views[3]->GetRenderWindow()->AddRenderer(ren);
    vtkRenderWindowInteractor *iren = views[3]->GetInteractor();


    for (int i = 0; i < 3; i++)
    {
        planeWidget[i] = vtkSmartPointer<vtkImagePlaneWidget>::New();
        planeWidget[i]->SetInteractor( iren );
        planeWidget[i]->SetPicker(picker);
        planeWidget[i]->RestrictPlaneToVolumeOn();
        double color[3] = {0, 0, 0};
        color[i] = 1;
        planeWidget[i]->GetPlaneProperty()->SetColor(color);

        color[0] /= 4.0;
        color[1] /= 4.0;
        color[2] /= 4.0;
        riw[i]->GetRenderer()->SetBackground( 0,0,0 );

        planeWidget[i]->SetTexturePlaneProperty(ipwProp);
        planeWidget[i]->TextureInterpolateOff();
        planeWidget[i]->SetResliceInterpolateToLinear();
        planeWidget[i]->SetInput(vtkViewData);
        planeWidget[i]->SetPlaneOrientation(i);
        planeWidget[i]->SetSliceIndex(imageDims[i]/2);
        planeWidget[i]->DisplayTextOn();
        planeWidget[i]->SetDefaultRenderer(ren);
        planeWidget[i]->On();
        planeWidget[i]->InteractionOn();
    }

    vtkSmartPointer<medResliceCursorCallback> cbk = vtkSmartPointer<medResliceCursorCallback>::New();
    cbk->reformatViewer = this;

    for (int i = 0; i < 3; i++)
    {
        riw[i]->GetResliceCursorWidget()->AddObserver(vtkResliceCursorWidget::ResliceAxesChangedEvent, cbk);
        riw[i]->GetResliceCursorWidget()->AddObserver(vtkResliceCursorWidget::WindowLevelEvent, cbk);
        riw[i]->GetResliceCursorWidget()->AddObserver(vtkResliceCursorWidget::ResliceThicknessChangedEvent, cbk);
        riw[i]->GetResliceCursorWidget()->AddObserver(vtkResliceCursorWidget::ResetCursorEvent, cbk);
        riw[i]->GetInteractorStyle()->AddObserver(vtkCommand::WindowLevelEvent, cbk);
        riw[i]->GetInteractorStyle()->AddObserver(vtkCommand::MouseMoveEvent, cbk);

        // Make them all share the same color map.
        riw[i]->SetLookupTable(riw[2]->GetLookupTable());
        riw[i]->SetColorLevel(view3d->GetColorLevel());
        riw[i]->SetColorWindow(view3d->GetColorWindow());

        planeWidget[i]->GetColorMap()->SetLookupTable(riw[2]->GetLookupTable());
        planeWidget[i]->SetColorMap(riw[i]->GetResliceCursorWidget()->GetResliceCursorRepresentation()->GetColorMap());

    }

    resetViews();
    applyRadiologicalConvention();
    updatePlaneNormals();

    planeWidget[0]->GetCurrentRenderer()->ResetCamera();
    planeWidget[0]->GetCurrentRenderer()->GetActiveCamera()->Azimuth(180);
    planeWidget[0]->GetCurrentRenderer()->GetActiveCamera()->Roll(180);

    views[0]->show();
    views[1]->show();
    views[2]->show();

    selectedView = 2;

    this->initialiseNavigators();
}
コード例 #4
0
void JabberAddAccountWidget::createGui(bool showButtons)
{
  	QVBoxLayout *mainLayout = new QVBoxLayout(this);

	QWidget *formWidget = new QWidget(this);
	mainLayout->addWidget(formWidget);

	QFormLayout *layout = new QFormLayout(formWidget);

	QWidget *jidWidget = new QWidget(this);
	QGridLayout *jidLayout = new QGridLayout(jidWidget);
	jidLayout->setSpacing(0);
	jidLayout->setMargin(0);
	jidLayout->setColumnStretch(0, 2);
	jidLayout->setColumnStretch(2, 2);

	Username = new QLineEdit(this);
	connect(Username, SIGNAL(textEdited(QString)), this, SLOT(dataChanged()));
	jidLayout->addWidget(Username);

	AtLabel = new QLabel("@", this);
	jidLayout->addWidget(AtLabel, 0, 1);

	Domain = new QComboBox();
	Domain->setEditable(true);
	if (!Factory->allowChangeServer())
	{
		Domain->setVisible(false);
		AtLabel->setVisible(false);

		QString toolTip = Factory->whatIsMyUsername();
		if (!toolTip.isEmpty())
		{
			QLabel *whatIsMyUsernameLabel = new QLabel(tr("<a href='#'>What is my username?</a>"), this);
			whatIsMyUsernameLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
			jidLayout->addWidget(whatIsMyUsernameLabel, 0, 2, Qt::AlignRight);

			connect(whatIsMyUsernameLabel, SIGNAL(linkActivated(QString)), this, SLOT(showWhatIsMyUsername()));
		}
	}
	else
	{
		connect(Domain, SIGNAL(currentIndexChanged(QString)), this, SLOT(dataChanged()));
		connect(Domain, SIGNAL(editTextChanged(QString)), this, SLOT(dataChanged()));
	}
	jidLayout->addWidget(Domain, 0, 2);

	layout->addRow(tr("Username") + ':', jidWidget);

	AccountPassword = new QLineEdit(this);
	connect(AccountPassword, SIGNAL(textEdited(QString)), this, SLOT(dataChanged()));
	AccountPassword->setEchoMode(QLineEdit::Password);
	layout->addRow(tr("Password") + ':', AccountPassword);

	RememberPassword = new QCheckBox(tr("Remember Password"), this);
	layout->addRow(0, RememberPassword);

	Identity = new IdentitiesComboBox(this);
	connect(Identity, SIGNAL(currentIndexChanged(int)), this, SLOT(dataChanged()));
	layout->addRow(tr("Account Identity") + ':', Identity);

	QLabel *infoLabel = new QLabel(tr("<font size='-1'><i>Select or enter the identity that will be associated with this account.</i></font>"), this);
	infoLabel->setWordWrap(true);
	infoLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
	infoLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
	layout->addRow(0, infoLabel);

	mainLayout->addStretch(100);

	QDialogButtonBox *buttons = new QDialogButtonBox(Qt::Horizontal, this);
	mainLayout->addWidget(buttons);

	AddAccountButton = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogApplyButton), tr("Add Account"), this);
	QPushButton *cancelButton = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogCancelButton), tr("Cancel"), this);

	buttons->addButton(AddAccountButton, QDialogButtonBox::AcceptRole);
	buttons->addButton(cancelButton, QDialogButtonBox::DestructiveRole);

	connect(AddAccountButton, SIGNAL(clicked(bool)), this, SLOT(apply()));
	connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(cancel()));

	if (!showButtons)
		buttons->hide();
}
コード例 #5
0
ファイル: color_dialog.cpp プロジェクト: FEK10/mapper
ColorDialog::ColorDialog(const Map& map, const MapColor& source_color, QWidget* parent, Qt::WindowFlags f)
: QDialog(parent, f),
  map(map),
  source_color(source_color),
  color(source_color),
  color_modified(false),
  react_to_changes(true)
{
	setWindowTitle(tr("Edit map color"));
	setSizeGripEnabled(true);
	
	color_preview_label = new QLabel();
	mc_name_edit = new QLineEdit();
	
	prof_color_layout = new QGridLayout();
	int col = 0;
	prof_color_layout->setColumnStretch(col, 1);
	prof_color_layout->setColumnStretch(col+1, 3);
	
	int row = 0;
	prof_color_layout->addWidget(Util::Headline::create("Spot color printing"), row, col, 1, 2);
	
	QButtonGroup* spot_color_options = new QButtonGroup(this);
	
	++row;
	full_tone_option = new QRadioButton(tr("Defines a spot color:"));
	spot_color_options->addButton(full_tone_option, MapColor::SpotColor);
	prof_color_layout->addWidget(full_tone_option, row, col, 1, 2);
	
	++row;
	sc_name_edit = new QLineEdit();
	prof_color_layout->addWidget(sc_name_edit, row, col, 1, 2);
	
	++row;
	composition_option = new QRadioButton(tr("Mixture of spot colors (screens and overprint):"));
	spot_color_options->addButton(composition_option, MapColor::CustomColor);
	prof_color_layout->addWidget(composition_option, row, col, 1, 2);
	
	int num_components = 0 /*color.getComponents().size()*/; // FIXME: cleanup
	components_row0 = row+1;
	components_col0 = col;
	component_colors.resize(num_components+1);
	component_halftone.resize(num_components+1);
	for (int i = 0; i <= num_components; i++)
	{
		++row;
		component_colors[i] = new ColorDropDown(&map, &color, true);
		component_colors[i]->removeColor(&source_color);
		prof_color_layout->addWidget(component_colors[i], row, col);
		component_halftone[i] = Util::SpinBox::create(1, 0.0, 100.0, tr("%"), 10.0);
		prof_color_layout->addWidget(component_halftone[i], row, col+1);
	}
	
	++row;
	knockout_option = new QCheckBox(tr("Knockout: erases lower colors"));
	prof_color_layout->addWidget(knockout_option, row, col, 1, 2);
	knockout_option->setEnabled(false);
	
	row = 0, col += 2;
	prof_color_layout->setColumnStretch(col, 1);
	
	const int spacing = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
	prof_color_layout->addItem(new QSpacerItem(3*spacing, spacing), row, col, 7, 1);
	
	row = 0, col +=1;
	prof_color_layout->setColumnStretch(col, 1);
	prof_color_layout->setColumnStretch(col+1, 3);
	prof_color_layout->addWidget(Util::Headline::create("CMYK"), row, col, 1, 2);
	
	QButtonGroup* cmyk_color_options = new QButtonGroup(this);
	
	++row;
	cmyk_spot_color_option = new QRadioButton(tr("Calculate from spot colors"));
	cmyk_color_options->addButton(cmyk_spot_color_option, MapColor::SpotColor);
	prof_color_layout->addWidget(cmyk_spot_color_option, row, col, 1, 2);
	
	++row;
	evaluate_rgb_option = new QRadioButton(tr("Calculate from RGB color"));
	cmyk_color_options->addButton(evaluate_rgb_option, MapColor::RgbColor);
	prof_color_layout->addWidget(evaluate_rgb_option, row, col, 1, 2);
	
	++row;
	custom_cmyk_option = new QRadioButton(tr("Custom process color:"));
	cmyk_color_options->addButton(custom_cmyk_option, MapColor::CustomColor);
	prof_color_layout->addWidget(custom_cmyk_option, row, col, 1, 2);
	
	++row;
	c_edit = Util::SpinBox::create(1, 0.0, 100.0, tr("%"), 10.0);
	prof_color_layout->addWidget(new QLabel(tr("Cyan")), row, col);
	prof_color_layout->addWidget(c_edit, row, col+1);
	
	++row;
	m_edit = Util::SpinBox::create(1, 0.0, 100.0, tr("%"), 10.0);
	prof_color_layout->addWidget(new QLabel(tr("Magenta")), row, col);
	prof_color_layout->addWidget(m_edit, row, col+1);
	
	++row;
	y_edit = Util::SpinBox::create(1, 0.0, 100.0, tr("%"), 10.0);
	prof_color_layout->addWidget(new QLabel(tr("Yellow")), row, col);
	prof_color_layout->addWidget(y_edit, row, col+1);
	
	++row;
	k_edit = Util::SpinBox::create(1, 0.0, 100.0, tr("%"), 10.0);
	prof_color_layout->addWidget(new QLabel(tr("Black")), row, col);
	prof_color_layout->addWidget(k_edit, row, col+1);
	
	++row;
	stretch_row0 = row;
	stretch_col0 = col;
	stretch = new QWidget();
	prof_color_layout->addWidget(stretch, row, col);
	prof_color_layout->setRowStretch(row, 1);
	
	QWidget* prof_color_widget = new QWidget();
	prof_color_widget->setLayout(prof_color_layout);
	prof_color_widget->setObjectName(QString::fromLatin1("professional"));
	
	
	QGridLayout* desktop_layout = new QGridLayout();
	col = 0;
	desktop_layout->setColumnStretch(col, 1);
	desktop_layout->setColumnStretch(col+1, 3);
	
	row = 0;
	desktop_layout->addWidget(Util::Headline::create("RGB"), row, col, 1, 2);
	
	QButtonGroup* rgb_color_options = new QButtonGroup(this);
	
	++row;
	rgb_spot_color_option = new QRadioButton(tr("Calculate from spot colors"));
	rgb_color_options->addButton(rgb_spot_color_option, MapColor::SpotColor);
	desktop_layout->addWidget(rgb_spot_color_option, row, col, 1, 2);
	
	++row;
	evaluate_cmyk_option = new QRadioButton(tr("Calculate from CMYK color"));
	rgb_color_options->addButton(evaluate_cmyk_option, MapColor::CmykColor);
	desktop_layout->addWidget(evaluate_cmyk_option, row, col, 1, 2);
	
	++row;
	custom_rgb_option = new QRadioButton(tr("Custom RGB color:"));
	rgb_color_options->addButton(custom_rgb_option, MapColor::CustomColor);
	desktop_layout->addWidget(custom_rgb_option, row, col, 1, 2);
	
	++row;
	r_edit = Util::SpinBox::create(1, 0.0, 255.0, {}, 5);
	desktop_layout->addWidget(new QLabel(tr("Red")), row, col);
	desktop_layout->addWidget(r_edit, row, col+1);
	
	++row;
	g_edit = Util::SpinBox::create(1, 0.0, 255.0, {}, 5);
	desktop_layout->addWidget(new QLabel(tr("Green")), row, col);
	desktop_layout->addWidget(g_edit, row, col+1);
	
	++row;
	b_edit = Util::SpinBox::create(1, 0.0, 255.0, {}, 5);
	desktop_layout->addWidget(new QLabel(tr("Blue")), row, col);
	desktop_layout->addWidget(b_edit, row, col+1);
	
	++row;
	html_edit = new QLineEdit();
	desktop_layout->addWidget(new QLabel(tr("#RRGGBB")), row, col);
	desktop_layout->addWidget(html_edit, row, col+1);
	
	++row;
	desktop_layout->addWidget(new QWidget(), row, col);
	desktop_layout->setRowStretch(row, 1);
	
	row = 0, col += 2;
	desktop_layout->setColumnStretch(col, 7);
	
	desktop_layout->addItem(new QSpacerItem(3*spacing, spacing), row, col, 7, 1);
	
	QWidget* desktop_color_widget = new QWidget();
	desktop_color_widget->setLayout(desktop_layout);
	desktop_color_widget->setObjectName(QString::fromLatin1("desktop"));
	
	
	properties_widget = new QTabWidget();
	properties_widget->addTab(desktop_color_widget, tr("Desktop"));
	properties_widget->addTab(prof_color_widget, tr("Professional printing"));
	
	QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok | QDialogButtonBox::Reset | QDialogButtonBox::Help);
	ok_button = button_box->button(QDialogButtonBox::Ok);
	reset_button = button_box->button(QDialogButtonBox::Reset);
	connect(button_box, SIGNAL(rejected()), this, SLOT(reject()));
	connect(button_box, SIGNAL(accepted()), this, SLOT(accept()));
	connect(reset_button, SIGNAL(clicked(bool)), this, SLOT(reset()));
	connect(button_box->button(QDialogButtonBox::Help), SIGNAL(clicked(bool)), this, SLOT(showHelp()));
	
	QGridLayout* layout = new QGridLayout();
	layout->addWidget(color_preview_label, 0, 0);
	layout->addWidget(mc_name_edit, 0, 1);
	layout->addWidget(properties_widget, 1, 0, 1, 2);
	layout->addWidget(button_box, 2, 0, 1, 2);
	layout->setColumnStretch(1, 1);
	setLayout(layout);
	
	updateWidgets();
	updateButtons();
	
	connect(mc_name_edit, SIGNAL(textChanged(QString)), this, SLOT(mapColorNameChanged()));
	
	connect(spot_color_options, SIGNAL(buttonClicked(int)), this, SLOT(spotColorTypeChanged(int)));
	connect(sc_name_edit, SIGNAL(textChanged(QString)), this, SLOT(spotColorNameChanged()));
	for (int i = 0; i < (int)component_colors.size(); i++)
	{
		connect(component_colors[i], SIGNAL(currentIndexChanged(int)), this, SLOT(spotColorCompositionChanged()));
		connect(component_halftone[i], SIGNAL(valueChanged(double)), this, SLOT(spotColorCompositionChanged()));
	}
	connect(knockout_option, SIGNAL(clicked(bool)), this, SLOT(knockoutChanged()));
	
	connect(cmyk_color_options, SIGNAL(buttonClicked(int)), this, SLOT(cmykColorTypeChanged(int)));
	connect(c_edit, SIGNAL(valueChanged(double)), this, SLOT(cmykValueChanged()));
	connect(m_edit, SIGNAL(valueChanged(double)), this, SLOT(cmykValueChanged()));
	connect(y_edit, SIGNAL(valueChanged(double)), this, SLOT(cmykValueChanged()));
	connect(k_edit, SIGNAL(valueChanged(double)), this, SLOT(cmykValueChanged()));
	
	connect(rgb_color_options, SIGNAL(buttonClicked(int)), this, SLOT(rgbColorTypeChanged(int)));
	connect(r_edit, SIGNAL(valueChanged(double)), this, SLOT(rgbValueChanged()));
	connect(g_edit, SIGNAL(valueChanged(double)), this, SLOT(rgbValueChanged()));
	connect(b_edit, SIGNAL(valueChanged(double)), this, SLOT(rgbValueChanged()));
	
	QSettings settings;
	settings.beginGroup(QString::fromLatin1("ColorDialog"));
	QString default_view = settings.value(QString::fromLatin1("view")).toString();
	settings.endGroup();
	properties_widget->setCurrentWidget(properties_widget->findChild<QWidget*>(default_view));
}
コード例 #6
0
ファイル: qfontdialog.cpp プロジェクト: MarianMMX/MarianMMX
void QFontDialogPrivate::init()
{
    Q_Q(QFontDialog);

    q->setSizeGripEnabled(true);
    q->setWindowTitle(QFontDialog::tr("Select Font"));

    // grid
    familyEdit = new QLineEdit(q);
    familyEdit->setReadOnly(true);
    familyList = new QFontListView(q);
    familyEdit->setFocusProxy(familyList);

    familyAccel = new QLabel(q);
#ifndef QT_NO_SHORTCUT
    familyAccel->setBuddy(familyList);
#endif
    familyAccel->setIndent(2);

    styleEdit = new QLineEdit(q);
    styleEdit->setReadOnly(true);
    styleList = new QFontListView(q);
    styleEdit->setFocusProxy(styleList);

    styleAccel = new QLabel(q);
#ifndef QT_NO_SHORTCUT
    styleAccel->setBuddy(styleList);
#endif
    styleAccel->setIndent(2);

    sizeEdit = new QLineEdit(q);
    sizeEdit->setFocusPolicy(Qt::ClickFocus);
    QIntValidator *validator = new QIntValidator(1, 512, q);
    sizeEdit->setValidator(validator);
    sizeList = new QFontListView(q);

    sizeAccel = new QLabel(q);
#ifndef QT_NO_SHORTCUT
    sizeAccel->setBuddy(sizeEdit);
#endif
    sizeAccel->setIndent(2);

    // effects box
    effects = new QGroupBox(q);
    QVBoxLayout *vbox = new QVBoxLayout(effects);
    strikeout = new QCheckBox(effects);
    vbox->addWidget(strikeout);
    underline = new QCheckBox(effects);
    vbox->addWidget(underline);

    sample = new QGroupBox(q);
    QHBoxLayout *hbox = new QHBoxLayout(sample);
    sampleEdit = new QLineEdit(sample);
    sampleEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
    sampleEdit->setAlignment(Qt::AlignCenter);
    // Note that the sample text is *not* translated with tr(), as the
    // characters used depend on the charset encoding.
    sampleEdit->setText(QLatin1String("AaBbYyZz"));
    hbox->addWidget(sampleEdit);

    writingSystemCombo = new QComboBox(q);

    writingSystemAccel = new QLabel(q);
#ifndef QT_NO_SHORTCUT
    writingSystemAccel->setBuddy(writingSystemCombo);
#endif
    writingSystemAccel->setIndent(2);

    size = 0;
    smoothScalable = false;

    QObject::connect(writingSystemCombo, SIGNAL(activated(int)), q, SLOT(_q_writingSystemHighlighted(int)));
    QObject::connect(familyList, SIGNAL(highlighted(int)), q, SLOT(_q_familyHighlighted(int)));
    QObject::connect(styleList, SIGNAL(highlighted(int)), q, SLOT(_q_styleHighlighted(int)));
    QObject::connect(sizeList, SIGNAL(highlighted(int)), q, SLOT(_q_sizeHighlighted(int)));
    QObject::connect(sizeEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_sizeChanged(QString)));

    QObject::connect(strikeout, SIGNAL(clicked()), q, SLOT(_q_updateSample()));
    QObject::connect(underline, SIGNAL(clicked()), q, SLOT(_q_updateSample()));

    for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) {
        QFontDatabase::WritingSystem ws = QFontDatabase::WritingSystem(i);
        QString writingSystemName = QFontDatabase::writingSystemName(ws);
        if (writingSystemName.isEmpty())
            break;
        writingSystemCombo->addItem(writingSystemName);
    }

    updateFamilies();
    if (familyList->count() != 0) {
        familyList->setCurrentItem(0);
        sizeList->setCurrentItem(0);
    }

    // grid layout
    QGridLayout *mainGrid = new QGridLayout(q);

    int spacing = mainGrid->spacing();
    if (spacing >= 0) {     // uniform spacing
       mainGrid->setSpacing(0);

       mainGrid->setColumnMinimumWidth(1, spacing);
       mainGrid->setColumnMinimumWidth(3, spacing);

       int margin = 0;
       mainGrid->getContentsMargins(0, 0, 0, &margin);

       mainGrid->setRowMinimumHeight(3, margin);
       mainGrid->setRowMinimumHeight(6, 2);
       mainGrid->setRowMinimumHeight(8, margin);
    }

    mainGrid->addWidget(familyAccel, 0, 0);
    mainGrid->addWidget(familyEdit, 1, 0);
    mainGrid->addWidget(familyList, 2, 0);

    mainGrid->addWidget(styleAccel, 0, 2);
    mainGrid->addWidget(styleEdit, 1, 2);
    mainGrid->addWidget(styleList, 2, 2);

    mainGrid->addWidget(sizeAccel, 0, 4);
    mainGrid->addWidget(sizeEdit, 1, 4);
    mainGrid->addWidget(sizeList, 2, 4);

    mainGrid->setColumnStretch(0, 38);
    mainGrid->setColumnStretch(2, 24);
    mainGrid->setColumnStretch(4, 10);

    mainGrid->addWidget(effects, 4, 0);

    mainGrid->addWidget(sample, 4, 2, 4, 3);

    mainGrid->addWidget(writingSystemAccel, 5, 0);
    mainGrid->addWidget(writingSystemCombo, 7, 0);

    buttonBox = new QDialogButtonBox(q);
    mainGrid->addWidget(buttonBox, 9, 0, 1, 5);

    QPushButton *button
            = static_cast<QPushButton *>(buttonBox->addButton(QDialogButtonBox::Ok));
    QObject::connect(buttonBox, SIGNAL(accepted()), q, SLOT(accept()));
    button->setDefault(true);

    buttonBox->addButton(QDialogButtonBox::Cancel);
    QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject()));

#if defined(Q_OS_WINCE)
    q->resize(180, 120);
#else
    q->resize(500, 360);
#endif // Q_OS_WINCE

    sizeEdit->installEventFilter(q);
    familyList->installEventFilter(q);
    styleList->installEventFilter(q);
    sizeList->installEventFilter(q);

    familyList->setFocus();
    retranslateStrings();
    sampleEdit->setObjectName(QLatin1String("qt_fontDialog_sampleEdit"));
}
コード例 #7
0
void AlarmTimeWidget::init(Mode mode, const QString& title)
{
	static const QString recurText = i18nc("@info/plain",
	                                       "If a recurrence is configured, the start date/time will be adjusted "
	                                       "to the first recurrence on or after the entered date/time."); 
	static const QString tzText = i18nc("@info/plain",
	                                    "This uses KAlarm's default time zone, set in the Configuration dialog.");

	QWidget* topWidget;
	if (title.isEmpty())
		topWidget = this;
	else
	{
		QBoxLayout* layout = new QVBoxLayout(this);
		layout->setMargin(0);
		layout->setSpacing(0);
		topWidget = new QGroupBox(title, this);
		layout->addWidget(topWidget);
	}
	mDeferring = mode & DEFER_TIME;
	mButtonGroup = new ButtonGroup(this);
	connect(mButtonGroup, SIGNAL(buttonSet(QAbstractButton*)), SLOT(slotButtonSet(QAbstractButton*)));
	QVBoxLayout* topLayout = new QVBoxLayout(topWidget);
	topLayout->setSpacing(KDialog::spacingHint());
	topLayout->setMargin(title.isEmpty() ? 0 : KDialog::marginHint());

	// At time radio button/label
	mAtTimeRadio = new RadioButton((mDeferring ? i18nc("@option:radio", "Defer to date/time:") : i18nc("@option:radio", "At date/time:")), topWidget);
	mAtTimeRadio->setFixedSize(mAtTimeRadio->sizeHint());
	mAtTimeRadio->setWhatsThis(mDeferring ? i18nc("@info:whatsthis", "Reschedule the alarm to the specified date and time.")
	                                      : i18nc("@info:whatsthis", "Specify the date, or date and time, to schedule the alarm."));
	mButtonGroup->addButton(mAtTimeRadio);

	// Date edit box
	mDateEdit = new DateEdit(topWidget);
	connect(mDateEdit, SIGNAL(dateEntered(const QDate&)), SLOT(dateTimeChanged()));
	mDateEdit->setWhatsThis(i18nc("@info:whatsthis",
	      "<para>Enter the date to schedule the alarm.</para>"
	      "<para>%1</para>", (mDeferring ? tzText : recurText)));
	mAtTimeRadio->setFocusWidget(mDateEdit);

	// Time edit box and Any time checkbox
	KHBox* timeBox = new KHBox(topWidget);
	timeBox->setSpacing(2*KDialog::spacingHint());
	mTimeEdit = new TimeEdit(timeBox);
	mTimeEdit->setFixedSize(mTimeEdit->sizeHint());
	connect(mTimeEdit, SIGNAL(valueChanged(int)), SLOT(dateTimeChanged()));
	mTimeEdit->setWhatsThis(i18nc("@info:whatsthis",
	      "<para>Enter the time to schedule the alarm.</para>"
	      "<para>%1</para>"
	      "<para>%2</para>", (mDeferring ? tzText : recurText), TimeSpinBox::shiftWhatsThis()));

	mAnyTime = -1;    // current status is uninitialised
	if (mode == DEFER_TIME)
	{
		mAnyTimeAllowed = false;
		mAnyTimeCheckBox = 0;
	}
	else
	{
		mAnyTimeAllowed = true;
		mAnyTimeCheckBox = new CheckBox(i18nc("@option:check", "Any time"), timeBox);
		mAnyTimeCheckBox->setFixedSize(mAnyTimeCheckBox->sizeHint());
		connect(mAnyTimeCheckBox, SIGNAL(toggled(bool)), SLOT(slotAnyTimeToggled(bool)));
		mAnyTimeCheckBox->setWhatsThis(i18nc("@info:whatsthis",
		      "Check to specify only a date (without a time) for the alarm. The alarm will trigger at the first opportunity on the selected date."));
	}

	// 'Time from now' radio button/label
	mAfterTimeRadio = new RadioButton((mDeferring ? i18nc("@option:radio", "Defer for time interval:") : i18nc("@option:radio", "Time from now:")), topWidget);
	mAfterTimeRadio->setFixedSize(mAfterTimeRadio->sizeHint());
	mAfterTimeRadio->setWhatsThis(mDeferring ? i18nc("@info:whatsthis", "Reschedule the alarm for the specified time interval after now.")
	                                         : i18nc("@info:whatsthis", "Schedule the alarm after the specified time interval from now."));
	mButtonGroup->addButton(mAfterTimeRadio);

	// Delay time spin box
	mDelayTimeEdit = new TimeSpinBox(1, maxDelayTime, topWidget);
	mDelayTimeEdit->setValue(1439);
	mDelayTimeEdit->setFixedSize(mDelayTimeEdit->sizeHint());
	connect(mDelayTimeEdit, SIGNAL(valueChanged(int)), SLOT(delayTimeChanged(int)));
	mDelayTimeEdit->setWhatsThis(mDeferring ? i18nc("@info:whatsthis", "<para>%1</para><para>%2</para>", i18n_TimeAfterPeriod(), TimeSpinBox::shiftWhatsThis())
	                                        : i18nc("@info:whatsthis", "<para>%1</para><para>%2</para><para>%3</para>", i18n_TimeAfterPeriod(), recurText, TimeSpinBox::shiftWhatsThis()));
	mAfterTimeRadio->setFocusWidget(mDelayTimeEdit);

	// Set up the layout, either narrow or wide
	QGridLayout* grid = new QGridLayout();
	grid->setMargin(0);
	topLayout->addLayout(grid);
	if (mDeferring)
	{
		grid->addWidget(mAtTimeRadio, 0, 0);
		grid->addWidget(mDateEdit, 0, 1, Qt::AlignLeft);
		grid->addWidget(timeBox, 1, 1, Qt::AlignLeft);
		grid->setColumnStretch(2, 1);
		topLayout->addStretch();
		QHBoxLayout* layout = new QHBoxLayout();
		topLayout->addLayout(layout);
		layout->addWidget(mAfterTimeRadio);
		layout->addWidget(mDelayTimeEdit);
		layout->addStretch();
	}
	else
	{
		grid->addWidget(mAtTimeRadio, 0, 0, Qt::AlignLeft);
		grid->addWidget(mDateEdit, 0, 1, Qt::AlignLeft);
		grid->addWidget(timeBox, 0, 2, Qt::AlignLeft);
		grid->setRowStretch(1, 1);
		grid->addWidget(mAfterTimeRadio, 2, 0, Qt::AlignLeft);
		grid->addWidget(mDelayTimeEdit, 2, 1, Qt::AlignLeft);

		// Time zone selection push button
		mTimeZoneButton = new PushButton(i18nc("@action:button", "Time Zone..."), topWidget);
		connect(mTimeZoneButton, SIGNAL(clicked()), SLOT(showTimeZoneSelector()));
		mTimeZoneButton->setWhatsThis(i18nc("@info:whatsthis",
		      "Choose a time zone for this alarm which is different from the default time zone set in KAlarm's configuration dialog."));
		grid->addWidget(mTimeZoneButton, 2, 2, 1, 2, Qt::AlignRight);

		grid->setColumnStretch(2, 1);
		topLayout->addStretch();

		QHBoxLayout* layout = new QHBoxLayout();
		topLayout->addLayout(layout);
		layout->setSpacing(2*KDialog::spacingHint());

		// Time zone selector
		mTimeZoneBox = new KHBox(topWidget);   // this is to control the QWhatsThis text display area
		mTimeZoneBox->setMargin(0);
		mTimeZoneBox->setSpacing(KDialog::spacingHint());
		QLabel* label = new QLabel(i18nc("@label:listbox", "Time zone:"), mTimeZoneBox);
		mTimeZone = new TimeZoneCombo(mTimeZoneBox);
		mTimeZone->setMaxVisibleItems(15);
		connect(mTimeZone, SIGNAL(activated(int)), SLOT(slotTimeZoneChanged()));
		mTimeZoneBox->setWhatsThis(i18nc("@info:whatsthis", "Select the time zone to use for this alarm."));
		label->setBuddy(mTimeZone);
		layout->addWidget(mTimeZoneBox);

		// Time zone checkbox
		mNoTimeZone = new CheckBox(i18nc("@option:check", "Ignore time zone"), topWidget);
		connect(mNoTimeZone, SIGNAL(toggled(bool)), SLOT(slotTimeZoneToggled(bool)));
		mNoTimeZone->setWhatsThis(i18nc("@info:whatsthis",
		                                "<para>Check to use the local computer time, ignoring time zones.</para>"
		                                "<para>You are recommended not to use this option if the alarm has a "
		                                "recurrence specified in hours/minutes. If you do, the alarm may "
		                                "occur at unexpected times after daylight saving time shifts.</para>"));
		layout->addWidget(mNoTimeZone);
		layout->addStretch();

		// Initially show only the time zone button, not time zone selector
		mTimeZoneBox->hide();
		mNoTimeZone->hide();
	}

	// Initialise the radio button statuses
	mAtTimeRadio->setChecked(true);
	slotButtonSet(mAtTimeRadio);

	// Timeout every minute to update alarm time fields.
	MinuteTimer::connect(this, SLOT(updateTimes()));
}