Пример #1
0
void ParameterWidget::addParam()
{
  XComboBox *xcomboBox = new XComboBox(_filterGroup);
  QToolButton *toolButton = new QToolButton(_filterGroup);
  QLineEdit *lineEdit = new QLineEdit(_filterGroup);
  QGridLayout *gridLayout = new QGridLayout();
  QVBoxLayout *xcomboLayout = new QVBoxLayout();
  QHBoxLayout *widgetLayout1 = new QHBoxLayout();
  QVBoxLayout *widgetLayout2 = new QVBoxLayout();
  QVBoxLayout *buttonLayout = new QVBoxLayout();

  int nextRow = _filtersLayout->rowCount();
  QString currRow = QString().setNum(nextRow);

  // Set up objects
  gridLayout->setObjectName("topLayout" + currRow);

  xcomboLayout->setObjectName("xcomboLayout" + currRow);
  xcomboLayout->setContentsMargins(0, 0, 0, 0);

  xcomboBox->setObjectName("xcomboBox" + currRow);
  xcomboBox->addItem("", currRow + ":" + "2");

  widgetLayout1->setObjectName("widgetLayout1" + currRow);

  widgetLayout2->setObjectName("widgetLayout2" + currRow);
  widgetLayout2->setContentsMargins(0, 0, 0, 0);

  lineEdit->setObjectName("widget" + currRow);
  lineEdit->setDisabled(true);

  buttonLayout->setObjectName("buttonLayout" + currRow);
  buttonLayout->setContentsMargins(0, 0, 0, 0);

  toolButton->setObjectName("button" + currRow);
  toolButton->setText(tr("-"));

  //grab the items provided by other widgets to populate xcombobox with
  QMapIterator<QString, QPair<QString, ParameterWidgetTypes> > i(_types);
  while (i.hasNext())
  {
    i.next();
    QPair<QString, ParameterWidgetTypes> tempPair = i.value();
    QString value = QString().setNum(nextRow) + ":" + QString().setNum(tempPair.second);
    if ( _usedTypes.isEmpty() || !containsUsedType(i.key()) )
      xcomboBox->addItem(i.key(), value );
  }

  xcomboLayout->addWidget(xcomboBox);
  xcomboLayout->addItem(new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Expanding));

  // Place the default line edit/button combo
  widgetLayout1->addWidget(lineEdit);
  widgetLayout1->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed));

  widgetLayout2->addLayout(widgetLayout1);
  widgetLayout2->addItem(new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Expanding));

  gridLayout->addLayout(widgetLayout2, 0, 0, 1, 1);

  // Place Button
  buttonLayout->addWidget(toolButton);
  buttonLayout->addItem(new QSpacerItem(10, 0, QSizePolicy::Fixed, QSizePolicy::Expanding));

  gridLayout->addLayout(buttonLayout, 0, 1, 1, 1);

  _filtersLayout->addLayout(gridLayout, nextRow, 1, 1, 1);
  _filtersLayout->addLayout(xcomboLayout, nextRow, 0, 1, 1);

  // Hook up connections
  connect(toolButton, SIGNAL(clicked()), _filterSignalMapper, SLOT(map()));
  connect(toolButton, SIGNAL(clicked()), gridLayout, SLOT( deleteLater() ) );
  connect(toolButton, SIGNAL(clicked()), xcomboBox, SLOT( deleteLater() ) );
  connect(toolButton, SIGNAL(clicked()), lineEdit, SLOT( deleteLater() ) );
  connect(toolButton, SIGNAL(clicked()), toolButton, SLOT( deleteLater() ) );
  connect(xcomboBox, SIGNAL(currentIndexChanged(int)), this, SLOT( changeFilterObject(int)) );
  connect(lineEdit, SIGNAL(editingFinished()), this, SLOT( storeFilterValue() ) );

  _filterSignalMapper->setMapping(toolButton, nextRow);

  _addFilterRow->setDisabled(true);
}
Пример #2
0
AccountWidget::AccountWidget( QWidget* parent )
    : QWidget( parent )
    , TomahawkUtils::DpiScaler( this )
{
    QHBoxLayout *mainLayout = new QHBoxLayout();
    TomahawkUtils::unmarginLayout( mainLayout );
    setLayout( mainLayout );
    setContentsMargins( 0, scaledY( 8 ), 0, scaledY( 8 ) );

    m_imageLabel = new QLabel( this );
    mainLayout->addWidget( m_imageLabel );
    mainLayout->setSpacing( scaledX( 4 ) );

    QGridLayout* vLayout = new QGridLayout();
    vLayout->setSpacing( 8 );
    mainLayout->addLayout( vLayout );

    QFrame* idContainer = new QFrame( this );
    idContainer->setAttribute( Qt::WA_TranslucentBackground, false );
    vLayout->addWidget( idContainer, 0, 0 );

    QHBoxLayout* idContLayout = new QHBoxLayout();
    idContainer->setLayout( idContLayout );
    idContainer->setContentsMargins( 0, 0, 0, 0 );
    idContLayout->setMargin( 2 );

    m_idLabel = new ElidedLabel( idContainer );
    m_idLabel->setElideMode( Qt::ElideRight );
    m_idLabel->setContentsMargins( 3, 0, 3, 0 );
    m_idLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
    m_idLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
    idContLayout->addWidget( m_idLabel );

    m_spinnerWidget = new QWidget( idContainer );
    QSize spinnerSize = 16 > TomahawkUtils::defaultFontHeight()  ?
                            QSize( 16, 16 ) :
                            QSize( TomahawkUtils::defaultFontHeight(),
                                   TomahawkUtils::defaultFontHeight() );
    m_spinnerWidget->setFixedSize( spinnerSize );
    idContLayout->addWidget( m_spinnerWidget );
    m_spinnerWidget->setContentsMargins( 0, 1, 0, 0 );
    m_spinner = new AnimatedSpinner( m_spinnerWidget->size() - QSize( 2, 2 ), m_spinnerWidget );

    idContainer->setStyleSheet( QString( "QFrame {"
                                "border: 1px solid #e9e9e9;"
                                "border-radius: %1px;"
                                "background: #e9e9e9;"
                                "}" ).arg( idContainer->sizeHint().height() / 2 + 1 ) );
    idContainer->setMinimumHeight( spinnerSize.height() + 6 /*margins*/ );

    m_statusToggle = new SlideSwitchButton( this );
    m_statusToggle->setContentsMargins( 0, 0, 0, 0 );
    m_statusToggle->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
    m_statusToggle->setFixedSize( m_statusToggle->sizeHint() );
    QHBoxLayout *statusToggleLayout = new QHBoxLayout();
    vLayout->addLayout( statusToggleLayout, 0, 1, 1, 1 );
    statusToggleLayout->addStretch();
    statusToggleLayout->addWidget( m_statusToggle );

    m_inviteContainer = new QFrame( this );
    m_inviteContainer->setObjectName( "inviteContainer" );
    vLayout->addWidget( m_inviteContainer, 1, 0 );
    m_inviteContainer->setStyleSheet( QString( "QWidget { background: white; } QFrame#%1 { border: 1px solid %2; }" ).arg( m_inviteContainer->objectName() ).arg( TomahawkStyle::BORDER_LINE.name() ) );
    m_inviteContainer->setMinimumWidth( m_inviteContainer->logicalDpiX() * 2 );
    m_inviteContainer->setContentsMargins( 1, 1, 1, 2 );
    m_inviteContainer->setAttribute( Qt::WA_TranslucentBackground, false );

    QHBoxLayout* containerLayout = new QHBoxLayout();
    m_inviteContainer->setLayout( containerLayout );
    TomahawkUtils::unmarginLayout( containerLayout );
    containerLayout->setContentsMargins( 1, 1, 0, 0 );

    m_addAccountIcon = new QLabel( m_inviteContainer );
    m_addAccountIcon->setContentsMargins( 1, 0, 0, 0 );
    m_addAccountIcon->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::AddContact, TomahawkUtils::Original, QSize( 16, 16 ) ) );
    m_addAccountIcon->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding );
    m_addAccountIcon->setAlignment( Qt::AlignCenter );
    containerLayout->addWidget( m_addAccountIcon );

    m_inviteEdit = new QLineEdit( m_inviteContainer );
    m_inviteEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    containerLayout->addWidget( m_inviteEdit );
    m_inviteEdit->setFrame( false );

    m_inviteButton = new QPushButton( this );
    m_inviteButton->setMinimumWidth( m_inviteButton->logicalDpiX() * 0.8 );
    m_inviteButton->setText( AccountWidget::tr( "Invite" ) );
    m_inviteButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred );
    vLayout->addWidget( m_inviteButton, 1, 1 );
    vLayout->setColumnStretch( 0, 1 );

#ifdef Q_OS_MAC
    layout()->setContentsMargins( 0, 0, 0, 0 );
#endif

    setInviteWidgetsEnabled( false );
}
Пример #3
0
void CalendarWidget::createGeneralOptionsGroupBox()
{
    generalOptionsGroupBox = new QGroupBox(tr("General Options"));

    firstDayCombo = new QComboBox;
    firstDayCombo->addItem(tr("Monday"), Qt::Monday);
    firstDayCombo->addItem(tr("Tuesday"), Qt::Tuesday);
    firstDayCombo->addItem(tr("Wednesday"), Qt::Wednesday);
    firstDayCombo->addItem(tr("Thursday"), Qt::Thursday);
    firstDayCombo->addItem(tr("Friday"), Qt::Friday);
    firstDayCombo->addItem(tr("Saturday"), Qt::Saturday);
    firstDayCombo->addItem(tr("Sunday"), Qt::Sunday);

    firstDayLabel = new QLabel(tr("Wee&k starts on:"));
    firstDayLabel->setBuddy(firstDayCombo);

    selectionModeCombo = new QComboBox;
    selectionModeCombo->addItem(tr("Single selection"),
                                QCalendarWidget::SingleSelection);
    selectionModeCombo->addItem(tr("None"), QCalendarWidget::NoSelection);

    selectionModeLabel = new QLabel(tr("&Selection mode:"));
    selectionModeLabel->setBuddy(selectionModeCombo);

    gridCheckBox = new QCheckBox(tr("&Grid"));
    gridCheckBox->setChecked(calendar->isGridVisible());

    navigationCheckBox = new QCheckBox(tr("&Navigation bar"));
    navigationCheckBox->setChecked(true);

    horizontalHeaderCombo = new QComboBox;
    horizontalHeaderCombo->addItem(tr("Single letter day names"),
                                   QCalendarWidget::SingleLetterDayNames);
    horizontalHeaderCombo->addItem(tr("Short day names"),
                                   QCalendarWidget::ShortDayNames);
    horizontalHeaderCombo->addItem(tr("None"),
                                   QCalendarWidget::NoHorizontalHeader);
    horizontalHeaderCombo->setCurrentIndex(1);

    horizontalHeaderLabel = new QLabel(tr("&Horizontal header:"));
    horizontalHeaderLabel->setBuddy(horizontalHeaderCombo);

    verticalHeaderCombo = new QComboBox;
    verticalHeaderCombo->addItem(tr("ISO week numbers"),
                                 QCalendarWidget::ISOWeekNumbers);
    verticalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoVerticalHeader);

    verticalHeaderLabel = new QLabel(tr("&Vertical header:"));
    verticalHeaderLabel->setBuddy(verticalHeaderCombo);

    connect(firstDayCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(firstDayChanged(int)));
    connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(selectionModeChanged(int)));
    connect(gridCheckBox, SIGNAL(toggled(bool)),
            calendar, SLOT(setGridVisible(bool)));
    connect(navigationCheckBox, SIGNAL(toggled(bool)),
            calendar, SLOT(setNavigationBarVisible(bool)));
    connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(horizontalHeaderChanged(int)));
    connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(verticalHeaderChanged(int)));

    QHBoxLayout *checkBoxLayout = new QHBoxLayout;
    checkBoxLayout->addWidget(gridCheckBox);
    checkBoxLayout->addStretch();
    checkBoxLayout->addWidget(navigationCheckBox);

    QGridLayout *outerLayout = new QGridLayout;
    outerLayout->addWidget(firstDayLabel, 0, 0);
    outerLayout->addWidget(firstDayCombo, 0, 1);
    outerLayout->addWidget(selectionModeLabel, 1, 0);
    outerLayout->addWidget(selectionModeCombo, 1, 1);
    outerLayout->addLayout(checkBoxLayout, 2, 0, 1, 2);
    outerLayout->addWidget(horizontalHeaderLabel, 3, 0);
    outerLayout->addWidget(horizontalHeaderCombo, 3, 1);
    outerLayout->addWidget(verticalHeaderLabel, 4, 0);
    outerLayout->addWidget(verticalHeaderCombo, 4, 1);
    generalOptionsGroupBox->setLayout(outerLayout);

    firstDayChanged(firstDayCombo->currentIndex());
    selectionModeChanged(selectionModeCombo->currentIndex());
    horizontalHeaderChanged(horizontalHeaderCombo->currentIndex());
    verticalHeaderChanged(verticalHeaderCombo->currentIndex());
}
Пример #4
0
//! [0]
WidgetGallery::WidgetGallery(QWidget *parent)
    : QDialog(parent)
{
    originalPalette = QApplication::palette();

    styleComboBox = new QComboBox;
    styleComboBox->addItem("NorwegianWood");
    styleComboBox->addItems(QStyleFactory::keys());

    styleLabel = new QLabel(tr("&Style:"));
    styleLabel->setBuddy(styleComboBox);

    useStylePaletteCheckBox = new QCheckBox(tr("&Use style's standard palette"));
    useStylePaletteCheckBox->setChecked(true);

    disableWidgetsCheckBox = new QCheckBox(tr("&Disable widgets"));

    createTopLeftGroupBox();
    createTopRightGroupBox();
    createBottomLeftTabWidget();
    createBottomRightGroupBox();
    createProgressBar();
//! [0]

//! [1]
    connect(styleComboBox, SIGNAL(activated(QString)),
//! [1] //! [2]
            this, SLOT(changeStyle(QString)));
    connect(useStylePaletteCheckBox, SIGNAL(toggled(bool)),
            this, SLOT(changePalette()));
    connect(disableWidgetsCheckBox, SIGNAL(toggled(bool)),
            topLeftGroupBox, SLOT(setDisabled(bool)));
    connect(disableWidgetsCheckBox, SIGNAL(toggled(bool)),
            topRightGroupBox, SLOT(setDisabled(bool)));
    connect(disableWidgetsCheckBox, SIGNAL(toggled(bool)),
            bottomLeftTabWidget, SLOT(setDisabled(bool)));
    connect(disableWidgetsCheckBox, SIGNAL(toggled(bool)),
            bottomRightGroupBox, SLOT(setDisabled(bool)));
//! [2]

//! [3]
    QHBoxLayout *topLayout = new QHBoxLayout;
//! [3] //! [4]
    topLayout->addWidget(styleLabel);
    topLayout->addWidget(styleComboBox);
    topLayout->addStretch(1);
    topLayout->addWidget(useStylePaletteCheckBox);
    topLayout->addWidget(disableWidgetsCheckBox);

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addLayout(topLayout, 0, 0, 1, 2);
    mainLayout->addWidget(topLeftGroupBox, 1, 0);
    mainLayout->addWidget(topRightGroupBox, 1, 1);
    mainLayout->addWidget(bottomLeftTabWidget, 2, 0);
    mainLayout->addWidget(bottomRightGroupBox, 2, 1);
    mainLayout->addWidget(progressBar, 3, 0, 1, 2);
    mainLayout->setRowStretch(1, 1);
    mainLayout->setRowStretch(2, 1);
    mainLayout->setColumnStretch(0, 1);
    mainLayout->setColumnStretch(1, 1);
    setLayout(mainLayout);

    setWindowTitle(tr("Styles"));
    changeStyle("NorwegianWood");
}
Пример #5
0
//Constructors:
ActiveLearningDialog::ActiveLearningDialog(/*std::string validate,*/std::vector<QImage> snapshot, 
										   vtkSmartPointer<vtkTable> table,int classval,std::vector<int> rowvals,
										   int num_classes,QWidget *parent)
: QDialog(parent)
{
	this->setWindowTitle(tr("Validation Window: Validate Classifier Performance"));
	//this->setModal(true);
	this->setModal(false);

	rejectFlag = false;
	
	queries = rowvals;
	num_of_classes = num_classes;

	query_label.resize(rowvals.size());
	buttongroup.resize(rowvals.size());

	//Master Layout
	QGridLayout * layout = new QGridLayout;
	
	QHBoxLayout *topRow = new QHBoxLayout;
	std::vector<int>::iterator it; 
	
	//set font    
	QFont font;
	font.setPointSize(15);
	font.setBold(true);
	
	QString x = "All these samples have been classified as class  "+QString::number(classval);
	QLabel *ClassLabel = new QLabel(x, this);
	ClassLabel->setFont(font);
	layout->addWidget(ClassLabel,0,0);


	//Shows 5 samples at a time
	for(int i=0;i<snapshot.size();++i)
	{
		std::vector<QHBoxLayout *> rows  = Validation_Sample_Details(snapshot[i],table,classval,rowvals[i],i,num_classes);
		//layout->addLayout(rows[0],2*i+1,0,0);
		//layout->addLayout(rows[1],2*i+2,0,0);
		layout->addLayout(rows[0],i+1,0,0);
		layout->addLayout(rows[1],i+1,1,0);
	}

	//Done Button
	QPushButton *doneButton = new QPushButton("Done");
	connect(doneButton, SIGNAL(clicked()), this, SLOT(finished()));
	doneButton->setDefault(false);
	doneButton->setAutoDefault(false);


	//Cancel Button
	QPushButton *cancelButton = new QPushButton("Cancel");
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(rejectAction()));
	cancelButton->setDefault(false);
	cancelButton->setAutoDefault(false);

	//next Button
	QPushButton *nextButton = new QPushButton("Next");
	connect(nextButton, SIGNAL(clicked()), this, SLOT(nextquery()));
	nextButton->setDefault(false);
	nextButton->setAutoDefault(true);

	//Top-row of the window 
	QHBoxLayout *finalRow = new QHBoxLayout;
	finalRow->addWidget(nextButton,0,0);
	finalRow->addWidget(doneButton,0,0);
	finalRow->addWidget(cancelButton,0,0);

	layout->addLayout(finalRow,14,0,0);
	this->setLayout(layout);

	for(int i =0 ; i<query_label.size() ; ++i)
	{
		query_label[i].second = classval;// Used to check if no radiobutton was selected for any sample
	}

	//QLabel *channelLabel = new QLabel("Please ensure all the relevant channels which might affect classification are ON ", this);	
	this->resize(1200,1200);

}
Пример #6
0
KKeyChooser::KKeyChooser( QDict<KKeyEntry> *aKeyDict, QWidget *parent )
    : QWidget( parent )
{
	
	bKeyIntercept = FALSE;
	kbMode = NoKey;
	
	aKeyIt = new QDictIterator<KKeyEntry> ( *aKeyDict );
	
	// TOP LAYOUT MANAGER
	
	// The following layout is used for the dialog
	// 		LIST LABELS LAYOUT
	//		SPLIT LIST BOX WIDGET
	//		CHOOSE KEY GROUP BOX WIDGET
	//		BUTTONS LAYOUT
	// Items are added to topLayout as they are created.
	
	QBoxLayout *topLayout = new QVBoxLayout( this, 0, 10 ); 
	
	// CREATE LIST LABELS
	
	QGridLayout *stackLayout = new QGridLayout( 2, 2, 2);
	topLayout->addLayout( stackLayout, 50 );
	
	stackLayout->setRowStretch(1,10);

	keyLabel = new QLabel(this);
	stackLayout->addWidget(keyLabel, 0, 1);
	keyLabel->setText( i18n("Current key") );
	keyLabel->setFixedHeight( keyLabel->sizeHint().height() );
	
	// CREATE SPLIT LIST BOX
	
	// Copy all currentKeyCodes to configKeyCodes
	// and fill up the split list box with the action/key pairs.
	
	wList = new KSplitList( this );
	stackLayout->addMultiCellWidget( wList, 1, 1, 0, 1 );
	
	actLabel = new QLabel( wList, i18n("&Action"), this );
	stackLayout->addWidget( actLabel, 0, 0 );
	actLabel->setFixedHeight( actLabel->sizeHint().height() );
	
	wList->setAutoUpdate(FALSE);
	wList->setFocus();
	
	aIt = aKeyIt;
	aIt->toFirst();
	while ( aIt->current() ) {
		aIt->current()->aConfigKeyCode = aIt->current()->aCurrentKeyCode;
		
		KSplitListItem *sli = new KSplitListItem(
		 	item( aIt->current()->aConfigKeyCode, aIt->currentKey() )
		);
		
		connect( wList, SIGNAL( newWidth( int ) ),
				 sli, SLOT( setWidth( int ) ) );
		wList->insertItem( sli );
		
		++ ( *aIt );
	}

	if ( wList->count() == 0 ) wList->setEnabled( FALSE );
	//connect( wList, SIGNAL( selected( int ) ), SLOT( toChange( int ) ) );
	connect( wList, SIGNAL( highlighted( int ) ), SLOT( updateAction( int ) ) );
	
	// CREATE CHOOSE KEY GROUP
	
	fCArea = new QGroupBox( this );
	topLayout->addWidget( fCArea, 1 );
	
	fCArea->setTitle( i18n("Choose a key for the selected action") );
	fCArea->setFrameStyle( QFrame::Box | QFrame::Sunken );
	
	// CHOOSE KEY GROUP LAYOUT MANAGER
	
	QGridLayout *grid = new QGridLayout( fCArea, 6, 4, 5 );
	
	grid->setRowStretch(0,10);
	grid->setRowStretch(1,10);
	grid->setRowStretch(2,10);
	grid->setRowStretch(3,10);
	grid->setRowStretch(4,10);
	grid->setRowStretch(5,10);

	grid->setColStretch(0,0);
	grid->setColStretch(1,10);
	grid->setColStretch(2,90);
	grid->setColStretch(3,0);
	
	grid->addRowSpacing(0,15);
	grid->addRowSpacing(5,1);
	
	
	kbGroup = new QButtonGroup( fCArea );
    kbGroup->hide();
    kbGroup->setExclusive( true );
	
	QRadioButton *rb = new QRadioButton( i18n("&No key"), fCArea );
    rb->adjustSize();
    rb->setFixedHeight( rb->height() );
    rb->setMinimumWidth( rb->width() );
    kbGroup->insert( rb, NoKey );
	
	grid->addMultiCellWidget( rb, 1, 1, 1, 2 );
	
	rb = new QRadioButton( i18n("&Default key"), fCArea );
    rb->adjustSize();
    rb->setFixedHeight( rb->height() );
    rb->setMinimumWidth( rb->width() );
    kbGroup->insert( rb, DefaultKey );
	
	grid->addMultiCellWidget( rb, 2, 2, 1, 2 );
	
	rb = new QRadioButton( i18n("&Custom key"), fCArea );
    rb->adjustSize();
    rb->setFixedHeight( rb->height() );
    rb->setMinimumWidth( rb->width() );
    kbGroup->insert( rb, CustomKey );
	
	connect( kbGroup, SIGNAL( clicked( int ) ), SLOT( keyMode( int ) ) );
	
	grid->addMultiCellWidget( rb, 3, 3, 1, 2 );
	
	QBoxLayout *pushLayout = new QHBoxLayout( 2 );
	grid->addLayout( pushLayout, 4, 2 );
	
	cShift = new QCheckBox( fCArea );
	cShift->setText( "SHIFT" );
	cShift->setEnabled( FALSE );
	connect( cShift, SIGNAL( clicked() ), SLOT( shiftClicked() ) );
	
	cCtrl = new QCheckBox( fCArea );
	cCtrl->setText( "CTRL" );
	cCtrl->setEnabled( FALSE );
	connect( cCtrl, SIGNAL( clicked() ), SLOT( ctrlClicked() ) );
	
	cAlt = new QCheckBox( fCArea );
	cAlt->setText( "ALT" );
	cAlt->setEnabled( FALSE );
	connect( cAlt, SIGNAL( clicked() ), SLOT( altClicked() ) );
	
	bChange = new KKeyButton("key", fCArea);
	bChange->setEnabled( FALSE );
	connect( bChange, SIGNAL( clicked() ), SLOT( changeKey() ) );
	
	// Set height of checkboxes to basic key button height.
	// Basic key button height = push button height.
	cAlt->adjustSize();
	cAlt->setFixedHeight( bChange->sizeHint().height() );
	cAlt->setMinimumWidth( cAlt->width() );
	cShift->adjustSize();
	cShift->setFixedHeight( bChange->sizeHint().height() );
	cShift->setMinimumWidth( cShift->width() );
	cCtrl->adjustSize();
	cCtrl->setFixedHeight( bChange->sizeHint().height() );
	cCtrl->setMinimumWidth( cCtrl->width() );
	fCArea->setMinimumHeight( bChange->sizeHint().height() + 20 +
		3*rb->height() + 4*10);
	
	// Add widgets to the geometry manager
	
	pushLayout->addWidget( cShift );
	pushLayout->addSpacing( 8 );
	pushLayout->addWidget( cCtrl );
	pushLayout->addSpacing( 8 );
	pushLayout->addWidget( cAlt );
	pushLayout->addSpacing( 18 );
	pushLayout->addWidget( bChange );
	pushLayout->addStretch( 10 );
	
	lNotConfig = new QLabel(fCArea);
	lNotConfig->resize(0,0);
	lNotConfig->setFont( QFont("Helvetica", 14, QFont::Bold) );
	lNotConfig->setAlignment( AlignCenter );
	lNotConfig->setFrameStyle( QFrame::Panel | QFrame::Sunken );
	if ( wList->count()==0 )
		lNotConfig->setText(i18n("No keys defined"));
	else {
		lNotConfig->setText(i18n("Not configurable"));
		lNotConfig->hide();
	}
	lNotConfig->hide();

	lInfo = new QLabel(fCArea);
	resize(0,0);
	lInfo->setAlignment( AlignCenter );
	lInfo->setEnabled( FALSE );
	lInfo->hide();
	
	wList->setAutoUpdate(TRUE);
	wList->update();
	
	globalDict = new QDict<int> ( 37, false );
	globalDict->setAutoDelete( true );
	readGlobalKeys();
	
	topLayout->activate();
}
Пример #7
0
//! [1]
Window::Window()
{
    QPainterPath rectPath;
    rectPath.moveTo(20.0, 30.0);
    rectPath.lineTo(80.0, 30.0);
    rectPath.lineTo(80.0, 70.0);
    rectPath.lineTo(20.0, 70.0);
    rectPath.closeSubpath();
//! [1]

//! [2]
    QPainterPath roundRectPath;
    roundRectPath.moveTo(80.0, 35.0);
    roundRectPath.arcTo(70.0, 30.0, 10.0, 10.0, 0.0, 90.0);
    roundRectPath.lineTo(25.0, 30.0);
    roundRectPath.arcTo(20.0, 30.0, 10.0, 10.0, 90.0, 90.0);
    roundRectPath.lineTo(20.0, 65.0);
    roundRectPath.arcTo(20.0, 60.0, 10.0, 10.0, 180.0, 90.0);
    roundRectPath.lineTo(75.0, 70.0);
    roundRectPath.arcTo(70.0, 60.0, 10.0, 10.0, 270.0, 90.0);
    roundRectPath.closeSubpath();
//! [2]

//! [3]
    QPainterPath ellipsePath;
    ellipsePath.moveTo(80.0, 50.0);
    ellipsePath.arcTo(20.0, 30.0, 60.0, 40.0, 0.0, 360.0);
//! [3]

//! [4]
    QPainterPath piePath;
    piePath.moveTo(50.0, 50.0);
    piePath.arcTo(20.0, 30.0, 60.0, 40.0, 60.0, 240.0);
    piePath.closeSubpath();
//! [4]

//! [5]
    QPainterPath polygonPath;
    polygonPath.moveTo(10.0, 80.0);
    polygonPath.lineTo(20.0, 10.0);
    polygonPath.lineTo(80.0, 30.0);
    polygonPath.lineTo(90.0, 70.0);
    polygonPath.closeSubpath();
//! [5]

//! [6]
    QPainterPath groupPath;
    groupPath.moveTo(60.0, 40.0);
    groupPath.arcTo(20.0, 20.0, 40.0, 40.0, 0.0, 360.0);
    groupPath.moveTo(40.0, 40.0);
    groupPath.lineTo(40.0, 80.0);
    groupPath.lineTo(80.0, 80.0);
    groupPath.lineTo(80.0, 40.0);
    groupPath.closeSubpath();
//! [6]

//! [7]
    QPainterPath textPath;
    QFont timesFont("Times", 50);
    timesFont.setStyleStrategy(QFont::ForceOutline);
    textPath.addText(10, 70, timesFont, tr("Qt"));
//! [7]

//! [8]
    QPainterPath bezierPath;
    bezierPath.moveTo(20, 30);
    bezierPath.cubicTo(80, 0, 50, 50, 80, 80);
//! [8]

//! [9]
    QPainterPath starPath;
    starPath.moveTo(90, 50);
    for (int i = 1; i < 5; ++i) {
        starPath.lineTo(50 + 40 * cos(0.8 * i * Pi),
                        50 + 40 * sin(0.8 * i * Pi));
    }
    starPath.closeSubpath();
//! [9]

//! [10]
#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR)
    renderAreas.push_back(new RenderArea(rectPath));
    renderAreas.push_back(new RenderArea(roundRectPath));
    renderAreas.push_back(new RenderArea(ellipsePath));
    renderAreas.push_back(new RenderArea(piePath));
    renderAreas.push_back(new RenderArea(polygonPath));
    renderAreas.push_back(new RenderArea(groupPath));
#endif
    renderAreas.push_back(new RenderArea(textPath));
    renderAreas.push_back(new RenderArea(bezierPath));
    renderAreas.push_back(new RenderArea(starPath));
//! [10]

//! [11]
    fillRuleComboBox = new QComboBox;
    fillRuleComboBox->addItem(tr("Odd Even"), Qt::OddEvenFill);
    fillRuleComboBox->addItem(tr("Winding"), Qt::WindingFill);

    fillRuleLabel = new QLabel(tr("Fill &Rule:"));
    fillRuleLabel->setBuddy(fillRuleComboBox);
//! [11]

//! [12]
    fillColor1ComboBox = new QComboBox;
    populateWithColors(fillColor1ComboBox);
    fillColor1ComboBox->setCurrentIndex(
        fillColor1ComboBox->findText("mediumslateblue"));

    fillColor2ComboBox = new QComboBox;
    populateWithColors(fillColor2ComboBox);
    fillColor2ComboBox->setCurrentIndex(
        fillColor2ComboBox->findText("cornsilk"));

    fillGradientLabel = new QLabel(tr("&Fill Gradient:"));
    fillGradientLabel->setBuddy(fillColor1ComboBox);

    fillToLabel = new QLabel(tr("to"));
    fillToLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    penWidthSpinBox = new QSpinBox;
    penWidthSpinBox->setRange(0, 20);

    penWidthLabel = new QLabel(tr("&Pen Width:"));
    penWidthLabel->setBuddy(penWidthSpinBox);

    penColorComboBox = new QComboBox;
    populateWithColors(penColorComboBox);
    penColorComboBox->setCurrentIndex(
        penColorComboBox->findText("darkslateblue"));

    penColorLabel = new QLabel(tr("Pen &Color:"));
    penColorLabel->setBuddy(penColorComboBox);

    rotationAngleSpinBox = new QSpinBox;
    rotationAngleSpinBox->setRange(0, 359);
    rotationAngleSpinBox->setWrapping(true);
    rotationAngleSpinBox->setSuffix("\xB0");

    rotationAngleLabel = new QLabel(tr("&Rotation Angle:"));
    rotationAngleLabel->setBuddy(rotationAngleSpinBox);
//! [12]

//! [16]
    connect(fillRuleComboBox, SIGNAL(activated(int)),
            this, SLOT(fillRuleChanged()));
    connect(fillColor1ComboBox, SIGNAL(activated(int)),
            this, SLOT(fillGradientChanged()));
    connect(fillColor2ComboBox, SIGNAL(activated(int)),
            this, SLOT(fillGradientChanged()));
    connect(penColorComboBox, SIGNAL(activated(int)),
            this, SLOT(penColorChanged()));

    for(QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); it++) {
        connect(penWidthSpinBox, SIGNAL(valueChanged(int)),
                *it, SLOT(setPenWidth(int)));
        connect(rotationAngleSpinBox, SIGNAL(valueChanged(int)),
                *it, SLOT(setRotationAngle(int)));
    }

//! [16] //! [17]
    QGridLayout *topLayout = new QGridLayout;
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
    topLayout->setSizeConstraint(QLayout::SetNoConstraint);
#endif

    int i=0;
    for(QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); it++, i++)
        topLayout->addWidget(*it, i / 3, i % 3);

    QGridLayout *mainLayout = new QGridLayout;
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
    mainLayout->setSizeConstraint(QLayout::SetNoConstraint);
#endif
    mainLayout->addLayout(topLayout, 0, 0, 1, 4);
    mainLayout->addWidget(fillRuleLabel, 1, 0);
    mainLayout->addWidget(fillRuleComboBox, 1, 1, 1, 3);
    mainLayout->addWidget(fillGradientLabel, 2, 0);
    mainLayout->addWidget(fillColor1ComboBox, 2, 1);
    mainLayout->addWidget(fillToLabel, 2, 2);
    mainLayout->addWidget(fillColor2ComboBox, 2, 3);
    mainLayout->addWidget(penWidthLabel, 3, 0);
    mainLayout->addWidget(penWidthSpinBox, 3, 1, 1, 3);
    mainLayout->addWidget(penColorLabel, 4, 0);
    mainLayout->addWidget(penColorComboBox, 4, 1, 1, 3);
#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR)
    mainLayout->addWidget(rotationAngleLabel, 5, 0);
    mainLayout->addWidget(rotationAngleSpinBox, 5, 1, 1, 3);
#endif
    setLayout(mainLayout);
//! [17]

//! [18]
    fillRuleChanged();
    fillGradientChanged();
    penColorChanged();
    penWidthSpinBox->setValue(2);

    setWindowTitle(tr("Painter Paths"));
}
Пример #8
0
ThemeDialog::ThemeDialog(Theme& theme, QWidget* parent)
	: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint),
	m_theme(theme)
{
	setWindowTitle(tr("Edit Theme"));
	setWindowModality(Qt::WindowModal);

	// Create name edit
	m_name = new QLineEdit(this);
	m_name->setText(m_theme.name());
	connect(m_name, SIGNAL(textChanged(QString)), this, SLOT(checkNameAvailable()));

	QHBoxLayout* name_layout = new QHBoxLayout;
	name_layout->setMargin(0);
	name_layout->addWidget(new QLabel(tr("Name:"), this));
	name_layout->addWidget(m_name);


	// Create scrollarea
	QWidget* contents = new QWidget(this);

	QScrollArea* scroll = new QScrollArea(this);
	scroll->setWidget(contents);
	scroll->setWidgetResizable(true);


	// Create text group
	QGroupBox* text_group = new QGroupBox(tr("Text"), contents);

	m_text_color = new ColorButton(text_group);
	m_text_color->setColor(m_theme.textColor());
	connect(m_text_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview()));

	m_font_names = new FontComboBox(text_group);
	m_font_names->setEditable(false);
	m_font_names->setCurrentFont(m_theme.textFont());
	connect(m_font_names, SIGNAL(activated(int)), this, SLOT(fontChanged()));
	connect(m_font_names, SIGNAL(activated(int)), this, SLOT(renderPreview()));

	m_font_sizes = new QComboBox(text_group);
	m_font_sizes->setEditable(true);
	m_font_sizes->setMinimumContentsLength(3);
	connect(m_font_sizes, SIGNAL(editTextChanged(QString)), this, SLOT(renderPreview()));
	fontChanged();

	m_misspelled_color = new ColorButton(text_group);
	m_misspelled_color->setColor(m_theme.misspelledColor());
	connect(m_misspelled_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview()));

	QHBoxLayout* font_layout = new QHBoxLayout;
	font_layout->addWidget(m_font_names);
	font_layout->addWidget(m_font_sizes);

	QFormLayout* text_layout = new QFormLayout(text_group);
	text_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	text_layout->addRow(tr("Color:"), m_text_color);
	text_layout->addRow(tr("Font:"), font_layout);
	text_layout->addRow(tr("Misspelled:"), m_misspelled_color);


	// Create background group
	QGroupBox* background_group = new QGroupBox(tr("Window Background"), contents);

	m_background_color = new ColorButton(background_group);
	m_background_color->setColor(m_theme.backgroundColor());
	connect(m_background_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview()));

	m_background_image = new ImageButton(background_group);
	m_background_image->setImage(m_theme.backgroundImage(), m_theme.backgroundPath());
	connect(m_background_image, SIGNAL(changed(QString)), this, SLOT(imageChanged()));

	m_clear_image = new QPushButton(tr("Remove"), background_group);
	connect(m_clear_image, SIGNAL(clicked()), m_background_image, SLOT(unsetImage()));

	m_background_type = new QComboBox(background_group);
	m_background_type->addItems(QStringList() << tr("No Image") << tr("Tiled") << tr("Centered") << tr("Stretched") << tr("Scaled") << tr("Zoomed"));
	m_background_type->setCurrentIndex(m_theme.backgroundType());
	connect(m_background_type, SIGNAL(activated(int)), this, SLOT(renderPreview()));

	QVBoxLayout* image_layout = new QVBoxLayout;
	image_layout->setSpacing(0);
	image_layout->setMargin(0);
	image_layout->addWidget(m_background_image);
	image_layout->addWidget(m_clear_image);

	QFormLayout* background_layout = new QFormLayout(background_group);
	background_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	background_layout->addRow(tr("Color:"), m_background_color);
	background_layout->addRow(tr("Image:"), image_layout);
	background_layout->addRow(tr("Type:"), m_background_type);


	// Create foreground group
	QGroupBox* foreground_group = new QGroupBox(tr("Text Background"), contents);

	m_foreground_color = new ColorButton(foreground_group);
	m_foreground_color->setColor(m_theme.foregroundColor());
	connect(m_foreground_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview()));

	m_foreground_opacity = new QSpinBox(foreground_group);
	m_foreground_opacity->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_foreground_opacity->setSuffix(QLocale().percent());
	m_foreground_opacity->setRange(theme.foregroundOpacity().minimumValue(), theme.foregroundOpacity().maximumValue());
	m_foreground_opacity->setValue(m_theme.foregroundOpacity());
	connect(m_foreground_opacity, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	m_foreground_position = new QComboBox(foreground_group);
	m_foreground_position->addItems(QStringList() << tr("Left") << tr("Centered") << tr("Right") << tr("Stretched"));
	m_foreground_position->setCurrentIndex(m_theme.foregroundPosition());
	connect(m_foreground_position, SIGNAL(currentIndexChanged(int)), this, SLOT(positionChanged(int)));

	m_foreground_width = new QSpinBox(foreground_group);
	m_foreground_width->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_foreground_width->setSuffix(tr(" pixels"));
	m_foreground_width->setRange(theme.foregroundWidth().minimumValue(), theme.foregroundWidth().maximumValue());
	m_foreground_width->setValue(m_theme.foregroundWidth());
	m_foreground_width->setEnabled(m_theme.foregroundPosition() != 3);
	connect(m_foreground_width, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	QFormLayout* foreground_layout = new QFormLayout(foreground_group);
	foreground_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	foreground_layout->addRow(tr("Color:"), m_foreground_color);
	foreground_layout->addRow(tr("Opacity:"), m_foreground_opacity);
	foreground_layout->addRow(tr("Position:"), m_foreground_position);
	foreground_layout->addRow(tr("Width:"), m_foreground_width);


	// Create rounding group
	m_round_corners = new QGroupBox(tr("Round Text Background Corners"), contents);
	m_round_corners->setCheckable(true);
	m_round_corners->setChecked(m_theme.roundCornersEnabled());
	connect(m_round_corners, SIGNAL(clicked()), this, SLOT(renderPreview()));

	m_corner_radius = new QSpinBox(m_round_corners);
	m_corner_radius->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_corner_radius->setSuffix(tr(" pixels"));
	m_corner_radius->setRange(theme.cornerRadius().minimumValue(), theme.cornerRadius().maximumValue());
	m_corner_radius->setValue(m_theme.cornerRadius());
	connect(m_corner_radius, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	QFormLayout* corner_layout = new QFormLayout(m_round_corners);
	corner_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	corner_layout->addRow(tr("Radius:"), m_corner_radius);


	// Create blur group
	m_blur = new QGroupBox(tr("Blur Text Background"), contents);
	m_blur->setCheckable(true);
	m_blur->setChecked(m_theme.blurEnabled());
	connect(m_blur, SIGNAL(clicked()), this, SLOT(renderPreview()));

	m_blur_radius = new QSpinBox(m_blur);
	m_blur_radius->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_blur_radius->setSuffix(tr(" pixels"));
	m_blur_radius->setRange(theme.blurRadius().minimumValue(), theme.blurRadius().maximumValue());
	m_blur_radius->setValue(m_theme.blurRadius());
	connect(m_blur_radius, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	QFormLayout* blur_layout = new QFormLayout(m_blur);
	blur_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	blur_layout->addRow(tr("Radius:"), m_blur_radius);


	// Create shadow group
	m_shadow = new QGroupBox(tr("Text Background Drop Shadow"), contents);
	m_shadow->setCheckable(true);
	m_shadow->setChecked(m_theme.shadowEnabled());
	connect(m_shadow, SIGNAL(clicked()), this, SLOT(renderPreview()));

	m_shadow_color = new ColorButton(m_shadow);
	m_shadow_color->setColor(m_theme.shadowColor());
	connect(m_shadow_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview()));

	m_shadow_radius = new QSpinBox(m_shadow);
	m_shadow_radius->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_shadow_radius->setSuffix(tr(" pixels"));
	m_shadow_radius->setRange(theme.shadowRadius().minimumValue(), theme.shadowRadius().maximumValue());
	m_shadow_radius->setValue(m_theme.shadowRadius());
	connect(m_shadow_radius, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	m_shadow_offset = new QSpinBox(m_shadow);
	m_shadow_offset->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_shadow_offset->setSuffix(tr(" pixels"));
	m_shadow_offset->setRange(theme.shadowOffset().minimumValue(), theme.shadowOffset().maximumValue());
	m_shadow_offset->setValue(m_theme.shadowOffset());
	connect(m_shadow_offset, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	QFormLayout* shadow_layout = new QFormLayout(m_shadow);
	shadow_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	shadow_layout->addRow(tr("Color:"), m_shadow_color);
	shadow_layout->addRow(tr("Radius:"), m_shadow_radius);
	shadow_layout->addRow(tr("Vertical Offset:"), m_shadow_offset);


	// Create margins group
	QGroupBox* margins_group = new QGroupBox(tr("Margins"), contents);

	m_foreground_margin = new QSpinBox(margins_group);
	m_foreground_margin->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_foreground_margin->setSuffix(tr(" pixels"));
	m_foreground_margin->setRange(theme.foregroundMargin().minimumValue(), theme.foregroundMargin().maximumValue());
	m_foreground_margin->setValue(m_theme.foregroundMargin());
	connect(m_foreground_margin, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	m_foreground_padding = new QSpinBox(margins_group);
	m_foreground_padding->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_foreground_padding->setSuffix(tr(" pixels"));
	m_foreground_padding->setRange(theme.foregroundPadding().minimumValue(), theme.foregroundPadding().maximumValue());
	m_foreground_padding->setValue(m_theme.foregroundPadding());
	connect(m_foreground_padding, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	QFormLayout* margins_layout = new QFormLayout(margins_group);
	margins_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	margins_layout->addRow(tr("Window:"), m_foreground_margin);
	margins_layout->addRow(tr("Page:"), m_foreground_padding);


	// Create line spacing group
	QGroupBox* line_spacing = new QGroupBox(tr("Line Spacing"), contents);

	m_line_spacing_type = new QComboBox(line_spacing);
	m_line_spacing_type->setEditable(false);
	m_line_spacing_type->addItems(QStringList() << tr("Single") << tr("1.5 Lines") << tr("Double") << tr("Proportional"));
	m_line_spacing_type->setCurrentIndex(3);

	m_line_spacing = new QSpinBox(line_spacing);
	m_line_spacing->setSuffix(QLocale().percent());
	m_line_spacing->setRange(theme.lineSpacing().minimumValue(), theme.lineSpacing().maximumValue());
	m_line_spacing->setValue(m_theme.lineSpacing());
	m_line_spacing->setEnabled(false);

	switch (m_theme.lineSpacing()) {
	case 100: m_line_spacing_type->setCurrentIndex(0); break;
	case 150: m_line_spacing_type->setCurrentIndex(1); break;
	case 200: m_line_spacing_type->setCurrentIndex(2); break;
	default: m_line_spacing->setEnabled(true); break;
	}
	connect(m_line_spacing_type, SIGNAL(currentIndexChanged(int)), this, SLOT(lineSpacingChanged(int)));
	connect(m_line_spacing_type, SIGNAL(currentIndexChanged(int)), this, SLOT(renderPreview()));
	connect(m_line_spacing, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	QFormLayout* line_spacing_layout = new QFormLayout(line_spacing);
	line_spacing_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	line_spacing_layout->addRow(tr("Type:"), m_line_spacing_type);
	line_spacing_layout->addRow(tr("Height:"), m_line_spacing);


	// Create paragraph spacing group
	QGroupBox* paragraph_spacing = new QGroupBox(tr("Paragraph Spacing"), contents);

	m_tab_width = new QSpinBox(paragraph_spacing);
	m_tab_width->setSuffix(tr(" pixels"));
	m_tab_width->setRange(theme.tabWidth().minimumValue(), theme.tabWidth().maximumValue());
	m_tab_width->setValue(m_theme.tabWidth());
	connect(m_tab_width, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	m_spacing_above_paragraph = new QSpinBox(paragraph_spacing);
	m_spacing_above_paragraph->setSuffix(tr(" pixels"));
	m_spacing_above_paragraph->setRange(theme.spacingAboveParagraph().minimumValue(), theme.spacingAboveParagraph().maximumValue());
	m_spacing_above_paragraph->setValue(m_theme.spacingAboveParagraph());
	connect(m_spacing_above_paragraph, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	m_spacing_below_paragraph = new QSpinBox(paragraph_spacing);
	m_spacing_below_paragraph->setSuffix(tr(" pixels"));
	m_spacing_below_paragraph->setRange(theme.spacingBelowParagraph().minimumValue(), theme.spacingBelowParagraph().maximumValue());
	m_spacing_below_paragraph->setValue(m_theme.spacingBelowParagraph());
	connect(m_spacing_below_paragraph, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	m_indent_first_line = new QCheckBox(tr("Indent first line"), paragraph_spacing);
	m_indent_first_line->setChecked(m_theme.indentFirstLine());
	connect(m_indent_first_line, SIGNAL(toggled(bool)), this, SLOT(renderPreview()));

	QFormLayout* paragraph_spacing_layout = new QFormLayout(paragraph_spacing);
	paragraph_spacing_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	paragraph_spacing_layout->addRow(tr("Tab Width:"), m_tab_width);
	paragraph_spacing_layout->addRow(tr("Above:"), m_spacing_above_paragraph);
	paragraph_spacing_layout->addRow(tr("Below:"), m_spacing_below_paragraph);
	paragraph_spacing_layout->addRow("", m_indent_first_line);


	// Create preview
	m_preview_text = new QTextEdit;
	m_preview_text->setFrameStyle(QFrame::NoFrame);
	m_preview_text->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	m_preview_text->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	QFile file(":/lorem.txt");
	if (file.open(QFile::ReadOnly)) {
		m_preview_text->setPlainText(QString::fromLatin1(file.readAll()));
		file.close();
	}

	m_preview = new QLabel(this);
	m_preview->setAlignment(Qt::AlignCenter);
	m_preview->setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);

	QPixmap pixmap(480, 270);
	pixmap.fill(palette().window().color());
	m_preview->setPixmap(pixmap);

	m_theme_renderer = new ThemeRenderer(this);
	connect(m_theme_renderer, SIGNAL(rendered(QImage,QRect,Theme)), this, SLOT(renderPreview(QImage,QRect,Theme)));
	renderPreview();


	// Lay out dialog
	QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
	m_ok = buttons->button(QDialogButtonBox::Ok);
	connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
	connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));

	QVBoxLayout* groups_layout = new QVBoxLayout(contents);
	groups_layout->addWidget(text_group);
	groups_layout->addWidget(background_group);
	groups_layout->addWidget(foreground_group);
	groups_layout->addWidget(m_round_corners);
	groups_layout->addWidget(m_blur);
	groups_layout->addWidget(m_shadow);
	groups_layout->addWidget(margins_group);
	groups_layout->addWidget(line_spacing);
	groups_layout->addWidget(paragraph_spacing);

	QGridLayout* layout = new QGridLayout(this);
	layout->setColumnStretch(0, 1);
	layout->setRowStretch(1, 1);
	layout->setRowMinimumHeight(2, layout->margin());
	layout->addLayout(name_layout, 0, 0, 1, 2);
	layout->addWidget(scroll, 1, 0, 1, 1);
	layout->addWidget(m_preview, 1, 1, 1, 1, Qt::AlignCenter);
	layout->addWidget(buttons, 3, 0, 1, 2);

	resize(QSettings().value("ThemeDialog/Size", sizeHint()).toSize());
}
Пример #9
0
void SearchResultWidget::setupUi(QMainWindow* qmw, const QString &iconThemePath)
{
    searchResultWidget = new QDockWidget(qmw);
    searchResultWidget->setObjectName(QString::fromUtf8("searchResultWidget_new"));//object name for created instance, it renames to 'searchResultWidget_old'
    //searchResultWidget->setLayoutDirection(Qt::RightToLeft);
    searchResultWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
    searchResultWidget->setAttribute(Qt::WA_DeleteOnClose, true);

    searchResultWidget->setStyleSheet("QDockWidget::title { background: transparent; text-align: left; padding: 0 10 0 10;}"
                                      "QDockWidget::close-button, QDockWidget::float-button { background: transparent;}");

    QGridLayout* searchGridLayout = new QGridLayout(searchResultContents);
    searchGridLayout->setSpacing(6);
    searchGridLayout->setContentsMargins(11, 11, 11, 11);
    searchGridLayout->setObjectName(QString::fromUtf8("searchGridLayout"));
    QHBoxLayout* horizontalLayout = new QHBoxLayout();
    horizontalLayout->setSpacing(6);
    horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
    QGridLayout* searchTableGridLayout = new QGridLayout();
    searchTableGridLayout->setSpacing(6);
    searchTableGridLayout->setObjectName(QString::fromUtf8("searchTableGridLayout"));

    //create filter lable and lineEdit and layout
    QHBoxLayout* filterHorizontalLayout = new QHBoxLayout();
    filterHorizontalLayout->setSpacing(6);
    filterHorizontalLayout->setObjectName(QString::fromUtf8("filterHorizontalLayout"));

    QLabel* filterLabel = new QLabel(searchResultContents);
    filterLabel->setObjectName(QString::fromUtf8("filterLabel"));
    filterLabel->setText(tr("Filter:"));
    filterHorizontalLayout->addWidget(filterLabel, 0, Qt::AlignRight | Qt::AlignCenter);

    QString clearIconPath = iconThemePath + "/clear-left.png";
    if (searchResultContents->layoutDirection() == Qt::RightToLeft) {
        clearIconPath = iconThemePath + "/clear-right.png";
    }
    filterLineEdit = new QSearchLineEdit(searchResultContents, clearIconPath, iconThemePath + "/filter.png");
    filterLineEdit->setObjectName(QString::fromUtf8("filterLineEdit"));
#if QT_VERSION >= 0x040700
    filterLineEdit->setPlaceholderText(tr("Filter"));
#endif
    connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterResults(QString)));
    filterHorizontalLayout->addWidget(filterLineEdit);
    QSpacerItem* filterHorizSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    filterHorizontalLayout->addItem(filterHorizSpacer);

    pageLabel = new QLabel(searchResultContents);
    pageLabel->setObjectName(QString::fromUtf8("pageLabel"));
//  filterHorizontalLayout->addWidget(pageLabel, 0, Qt::AlignRight|Qt::AlignCenter);

    //searchTableGridLayout->addLayout(filterHorizontalLayout, 1, 0, 1, 1);

    //create QTableWidget
    searchTable = new QTableWidget(searchResultContents);
    searchTable->setObjectName(QString::fromUtf8("searchTable"));
    searchTable->setColumnCount(3);
    searchTable->setLayoutDirection(Qt::RightToLeft);
    searchTable->setAlternatingRowColors(true);
    searchTable->setSelectionMode(QAbstractItemView::NoSelection /*SingleSelection*/);
    searchTable->setSelectionBehavior(QAbstractItemView::SelectRows);
    searchTable->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
    searchTable->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
    searchTable->verticalHeader()->setVisible(false);
    //searchTable->horizontalHeader()->setVisible(false);
    searchTable->horizontalHeader()->setHighlightSections(false);
    searchTable->horizontalHeader()->setStretchLastSection(true);
    connect(searchTable, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(currentRowColumnChanged(int,int,int,int)));

    //install delagate on third column
    SaagharItemDelegate* searchDelegate = new SaagharItemDelegate(searchTable, searchTable->style(), phrase);
    searchTable->setItemDelegateForColumn(2, searchDelegate);
    connect(this, SIGNAL(searchFiltered(QString)), searchDelegate, SLOT(keywordChanged(QString)));

    //searchTable->setItemDelegateForColumn(2, new SaagharItemDelegate(searchTable, searchTable->style(), phrase));

    searchTableGridLayout->addWidget(searchTable, 0, 0, 1, 1);

//  QVBoxLayout *searchNavVerticalLayout = new QVBoxLayout();
//  searchNavVerticalLayout->setSpacing(6);
//  searchNavVerticalLayout->setObjectName(QString::fromUtf8("searchNavVerticalLayout"));

    searchNextPage = new QToolButton(searchResultContents);
    searchNextPage->setObjectName(QString::fromUtf8("searchNextPage"));
    searchNextPage->setStyleSheet("QToolButton { border: none; padding: 0px; }");

    actSearchNextPage = new QAction(searchResultContents);
    searchNextPage->setDefaultAction(actSearchNextPage);

    connect(searchNextPage, SIGNAL(triggered(QAction*)), this, SLOT(searchPageNavigationClicked(QAction*)));

    searchNextPage->setEnabled(false);
    searchNextPage->hide();

    //searchNavVerticalLayout->addWidget(searchNextPage);

    searchPreviousPage = new QToolButton(searchResultContents);
    searchPreviousPage->setObjectName(QString::fromUtf8("searchPreviousPage"));
    searchPreviousPage->setStyleSheet("QToolButton { border: none; padding: 0px; }");

    actSearchPreviousPage = new QAction(searchResultContents);
    searchPreviousPage->setDefaultAction(actSearchPreviousPage);

    if (qmw->layoutDirection() == Qt::LeftToRight) {
        actSearchPreviousPage->setIcon(QIcon(iconThemePath + "/previous.png"));
        actSearchNextPage->setIcon(QIcon(iconThemePath + "/next.png"));
    }
    else {
        actSearchPreviousPage->setIcon(QIcon(iconThemePath + "/next.png"));
        actSearchNextPage->setIcon(QIcon(iconThemePath + "/previous.png"));
    }

    connect(searchPreviousPage, SIGNAL(triggered(QAction*)), this, SLOT(searchPageNavigationClicked(QAction*)));

    searchPreviousPage->setEnabled(false);
    searchPreviousPage->hide();

//  searchNavVerticalLayout->addWidget(searchPreviousPage);

    //QSpacerItem *searchNavVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);

    //searchNavVerticalLayout->addItem(searchNavVerticalSpacer);

//  if (moreThanOnePage)
//      horizontalLayout->addLayout(searchNavVerticalLayout);

    filterHorizontalLayout->addWidget(searchPreviousPage);
    filterHorizontalLayout->addWidget(searchNextPage);
    filterHorizontalLayout->addWidget(pageLabel, 0, Qt::AlignRight | Qt::AlignCenter);
    searchTableGridLayout->addLayout(filterHorizontalLayout, 1, 0, 1, 1);

    horizontalLayout->addLayout(searchTableGridLayout);

    searchGridLayout->addLayout(horizontalLayout, 0, 0, 1, 1);

    /****************************/
    QDockWidget* tmpDockWidget = 0;
    QObjectList mainWindowChildren = qmw->children();
    for (int i = 0; i < mainWindowChildren.size(); ++i) {
        tmpDockWidget = qobject_cast<QDockWidget*>(mainWindowChildren.at(i));
        if (tmpDockWidget) {
            if (mainWindowChildren.at(i)->objectName() == "searchResultWidget_old") {
                break;
            }
        }
    }

    /****************************************/
    searchResultWidget->setWidget(searchResultContents);

    qmw->addDockWidget(Qt::BottomDockWidgetArea, searchResultWidget);

    if (tmpDockWidget && tmpDockWidget->objectName() == "searchResultWidget_old") { //there is another search results dock-widget present
        qmw->tabifyDockWidget(tmpDockWidget, searchResultWidget);
    }


    searchResultWidget->setObjectName("searchResultWidget_old");

    searchResultWidget->show();
    searchResultWidget->raise();
}
Пример #10
0
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
  ModelPanel(parent, model, generalSettings, firmware),
  initialized(false)
#if defined(PHONON)
  ,
  phononCurrent(-1),
  clickObject(NULL),
  clickOutput(NULL)
#endif
{
  QGridLayout * gridLayout = new QGridLayout(this);

  addLabel(gridLayout, tr("Switch"), 1);
  addLabel(gridLayout, tr("Action"), 2);
  addLabel(gridLayout, tr("Parameters"), 3);
  addLabel(gridLayout, tr("Enable"), 4, true );
  addEmptyLabel(gridLayout, 5 );

  lock = true;
  int num_fsw = firmware->getCapability(CustomFunctions);

  if (!firmware->getCapability(VoicesAsNumbers)) {
    tracksSet = getFilesSet(getSoundsPath(generalSettings), QStringList() << "*.wav" << "*.WAV", firmware->getCapability(VoicesMaxLength));
    for (int i=0; i<num_fsw; i++) {
      if (model.funcSw[i].func==FuncPlayPrompt || model.funcSw[i].func==FuncBackgroundMusic) {
        QString temp = model.funcSw[i].paramarm;
        if (!temp.isEmpty()) {
          tracksSet.insert(temp);
        }
      }
    }
    qDebug() << tracksSet;
  }

  if (IS_TARANIS(firmware->getBoard())) {
    scriptsSet = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS", QStringList() << "*.lua", firmware->getCapability(VoicesMaxLength));
    for (int i=0; i<num_fsw; i++) {
      if (model.funcSw[i].func==FuncPlayScript) {
        QString temp = model.funcSw[i].paramarm;
        if (!temp.isEmpty()) {
          scriptsSet.insert(temp);
        }
      }
    }
    qDebug() << scriptsSet;
  }

  CompanionIcon playIcon("play.png");

  for (int i=0; i<num_fsw; i++) {
    // The label
    QLabel * label = new QLabel(this);
    label->setContextMenuPolicy(Qt::CustomContextMenu);
    label->setMouseTracking(true);
    label->setProperty("index", i);
    label->setText(tr("SF%1").arg(i+1));
    label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
    connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint)));
    gridLayout->addWidget(label, i+1, 0);

    // The switch
    fswtchSwtch[i] = new QComboBox(this);
    fswtchSwtch[i]->setProperty("index", i);
    fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
    connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
    gridLayout->addWidget(fswtchSwtch[i], i+1, 1);

    // The function
    fswtchFunc[i] = new QComboBox(this);
    fswtchFunc[i]->setProperty("index", i);
    connect(fswtchFunc[i], SIGNAL(currentIndexChanged(int)), this, SLOT(functionEdited()));
    gridLayout->addWidget(fswtchFunc[i], i+1, 2);

    QHBoxLayout *paramLayout = new QHBoxLayout();
    gridLayout->addLayout(paramLayout, i+1, 3);

    fswtchGVmode[i] = new QComboBox(this);
    fswtchGVmode[i]->setProperty("index", i);
    connect(fswtchGVmode[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
    paramLayout->addWidget(fswtchGVmode[i]);

    fswtchParamGV[i] = new QCheckBox(this);
    fswtchParamGV[i]->setProperty("index", i);
    fswtchParamGV[i]->setText("GV");
    fswtchParamGV[i]->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
    connect(fswtchParamGV[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
    paramLayout->addWidget(fswtchParamGV[i]);

    fswtchParam[i] = new QDoubleSpinBox(this);
    fswtchParam[i]->setProperty("index", i);
    fswtchParam[i]->setAccelerated(true);
    fswtchParam[i]->setDecimals(0);
    connect(fswtchParam[i], SIGNAL(editingFinished()), this, SLOT(customFunctionEdited()));
    paramLayout->addWidget(fswtchParam[i]);

    fswtchParamTime[i] = new QTimeEdit(this);
    fswtchParamTime[i]->setProperty("index", i);
    fswtchParamTime[i]->setAccelerated(true);
    fswtchParamTime[i]->setDisplayFormat("hh:mm:ss");
    connect(fswtchParamTime[i], SIGNAL(editingFinished()), this, SLOT(customFunctionEdited()));
    paramLayout->addWidget(fswtchParamTime[i]);

    fswtchParamT[i] = new QComboBox(this);
    fswtchParamT[i]->setProperty("index", i);
    paramLayout->addWidget(fswtchParamT[i]);
    connect(fswtchParamT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));

    fswtchParamArmT[i] = new QComboBox(this);
    fswtchParamArmT[i]->setProperty("index", i);
    fswtchParamArmT[i]->setEditable(true);
    paramLayout->addWidget(fswtchParamArmT[i]);

    connect(fswtchParamArmT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
    connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited()));

    fswtchBLcolor[i] = new QSlider(this);
    fswtchBLcolor[i]->setProperty("index", i);
    fswtchBLcolor[i]->setMinimum(0);
    fswtchBLcolor[i]->setMaximum(100);
    fswtchBLcolor[i]->setSingleStep(1);
    fswtchBLcolor[i]->setOrientation(Qt::Horizontal);
    paramLayout->addWidget(fswtchBLcolor[i]);
    connect(fswtchBLcolor[i], SIGNAL(sliderReleased()), this, SLOT(customFunctionEdited()));

#ifdef PHONON
    playBT[i] = new QPushButton(this);
    playBT[i]->setProperty("index", i);
    playBT[i]->setIcon(playIcon);
    paramLayout->addWidget(playBT[i]);
    connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic()));
#endif

    QHBoxLayout *repeatLayout = new QHBoxLayout();
    gridLayout->addLayout(repeatLayout, i+1, 4);
    fswtchRepeat[i] = new RepeatComboBox(this, model.funcSw[i].repeatParam);
    repeatLayout->addWidget(fswtchRepeat[i], i+1);
    connect(fswtchRepeat[i], SIGNAL(modified()), this, SLOT(onChildModified()));

    fswtchEnable[i] = new QCheckBox(this);
    fswtchEnable[i]->setProperty("index", i);
    fswtchEnable[i]->setText(tr("ON"));
    fswtchEnable[i]->setFixedWidth( 80 );
    repeatLayout->addWidget(fswtchEnable[i], i+1);
    connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
  }

  // Push rows upward
  addDoubleSpring(gridLayout, 5, num_fsw+1);

  disableMouseScrolling();

  lock = false;
}
Пример #11
0
LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
  ModelPanel(parent, model, generalSettings, firmware),
  selectedSwitch(0)
{
  QGridLayout * gridLayout = new QGridLayout(this);

  int col = 1;
  addLabel(gridLayout, tr("Function"), col++);
  addLabel(gridLayout, tr("V1"), col++);
  addLabel(gridLayout, tr("V2"), col++);
  addLabel(gridLayout, tr("AND Switch"), col++);
  if (firmware->getCapability(LogicalSwitchesExt)) {
    addLabel(gridLayout, tr("Duration"), col++);
    addLabel(gridLayout, tr("Delay"), col++);
  }

  lock = true;
  for (int i=0; i<firmware->getCapability(LogicalSwitches); i++) {
    // The label
    QLabel * label = new QLabel(this);
    label->setProperty("index", i);
    label->setText(tr("L%1").arg(i+1));
    label->setContextMenuPolicy(Qt::CustomContextMenu);
    label->setMouseTracking(true);
    label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
    connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint)));
    gridLayout->addWidget(label, i+1, 0);

    // The function
    csw[i] = new QComboBox(this);
    csw[i]->setProperty("index", i);
    connect(csw[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
    gridLayout->addWidget(csw[i], i+1, 1);

    // V1
    cswitchSource1[i] = new QComboBox(this);
    cswitchSource1[i]->setProperty("index",i);
    connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v1Edited(int)));
    gridLayout->addWidget(cswitchSource1[i], i+1, 2);
    cswitchSource1[i]->setVisible(false);
    cswitchValue[i] = new QDoubleSpinBox(this);
    cswitchValue[i]->setMaximum(125);
    cswitchValue[i]->setMinimum(-125);
    cswitchValue[i]->setAccelerated(true);
    cswitchValue[i]->setDecimals(0);
    cswitchValue[i]->setProperty("index", i);
    connect(cswitchValue[i], SIGNAL(valueChanged(double)), this, SLOT(edited()));
    gridLayout->addWidget(cswitchValue[i], i+1, 2);
    cswitchValue[i]->setVisible(false);

    // V2
    QHBoxLayout *v2Layout = new QHBoxLayout();
    cswitchSource2[i] = new QComboBox(this);
    cswitchSource2[i]->setProperty("index", i);
    connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v2Edited(int)));
    v2Layout->addWidget(cswitchSource2[i]);
    cswitchSource2[i]->setVisible(false);
    cswitchOffset[i] = new QDoubleSpinBox(this);
    cswitchOffset[i]->setProperty("index",i);
    cswitchOffset[i]->setMaximum(125);
    cswitchOffset[i]->setMinimum(-125);
    cswitchOffset[i]->setAccelerated(true);
    cswitchOffset[i]->setDecimals(0);
    connect(cswitchOffset[i], SIGNAL(valueChanged(double)), this, SLOT(edited()));
    cswitchOffset[i]->setVisible(false);
    v2Layout->addWidget(cswitchOffset[i]);
    cswitchOffset2[i] = new QDoubleSpinBox(this);
    cswitchOffset2[i]->setProperty("index",i);
    cswitchOffset2[i]->setMaximum(125);
    cswitchOffset2[i]->setMinimum(-125);
    cswitchOffset2[i]->setAccelerated(true);
    cswitchOffset2[i]->setDecimals(0);
    connect(cswitchOffset2[i], SIGNAL(valueChanged(double)), this, SLOT(edited()));
    cswitchOffset2[i]->setVisible(false);
    v2Layout->addWidget(cswitchOffset2[i]);
    cswitchTOffset[i] = new QTimeEdit(this);
    cswitchTOffset[i]->setProperty("index",i);
    cswitchTOffset[i]->setAccelerated(true);
    connect(cswitchTOffset[i],SIGNAL(editingFinished()),this,SLOT(edited()));
    v2Layout->addWidget(cswitchTOffset[i]);
    cswitchTOffset[i]->setVisible(false);
    gridLayout->addLayout(v2Layout, i+1, 3);

    // AND
    cswitchAnd[i] = new QComboBox(this);
    cswitchAnd[i]->setProperty("index", i);
    connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int)));
    gridLayout->addWidget(cswitchAnd[i], i+1, 4);

    if (firmware->getCapability(LogicalSwitchesExt)) {
      // Duration
      cswitchDuration[i] = new QDoubleSpinBox(this);
      cswitchDuration[i]->setProperty("index", i);
      cswitchDuration[i]->setSingleStep(0.1);
      cswitchDuration[i]->setMaximum(25);
      cswitchDuration[i]->setMinimum(0);
      cswitchDuration[i]->setAccelerated(true);
      cswitchDuration[i]->setDecimals(1);
      connect(cswitchDuration[i], SIGNAL(valueChanged(double)), this, SLOT(durationEdited(double)));
      gridLayout->addWidget(cswitchDuration[i], i+1, 5);

      // Delay
      cswitchDelay[i] = new QDoubleSpinBox(this);
      cswitchDelay[i]->setProperty("index", i);
      cswitchDelay[i]->setSingleStep(0.1);
      cswitchDelay[i]->setMaximum(25);
      cswitchDelay[i]->setMinimum(0);
      cswitchDelay[i]->setAccelerated(true);
      cswitchDelay[i]->setDecimals(1);
      connect(cswitchDelay[i], SIGNAL(valueChanged(double)), this, SLOT(delayEdited(double)));
      gridLayout->addWidget(cswitchDelay[i], i+1, 6);
    }
  }
Пример #12
0
MyWidget::MyWidget( QWidget *parent, const char *name )
: QWidget( parent, name )
{
	setCaption("Color Codes");

  // icons are handled differently on OSX
#ifndef __APPLE__
  setIcon(QPixmap(":/bitmaps/big.qucs.xpm"));
#endif

	 // --------  create menubar  -------------------
  QAction *fileExit = new QAction(tr("E&xit"), this);
  fileExit->setShortcut(Qt::CTRL+Qt::Key_Q);
  connect(fileExit, SIGNAL(activated()), qApp, SLOT(quit()));

  QMenu *fileMenu = new QMenu(tr("&File"));
  fileMenu->addAction(fileExit);

  QAction *help = new QAction(tr("Help..."), this);
  help->setShortcut(Qt::Key_F1);
  connect(help, SIGNAL(activated()), this, SLOT(slotHelpIntro()));

  QAction *about = new QAction(tr("&About ResistorCodes..."), this);
  connect(about, SIGNAL(activated()), this, SLOT(slotHelpAbout()));

  QAction *aboutQt = new QAction(tr("&About Qt..."), this);
  connect(aboutQt, SIGNAL(activated()), this, SLOT(slotHelpAboutQt()));

  QMenu *helpMenu = new QMenu(tr("&Help"));
  helpMenu->addAction(help);
  helpMenu->addAction(about);
  helpMenu->addSeparator();
  helpMenu->addAction(aboutQt);

  QMenuBar *menuBar = new QMenuBar(this);
	menuBar->addMenu(fileMenu);
	menuBar->insertSeparator();
	menuBar->addMenu(helpMenu);

	res= new QResistor();
	//--------------------resistance displayin ui ---------------------------------//
	resBox = new MyResistanceBox (this);

	connect(res, SIGNAL(valueModified(QResistor*)),resBox,SLOT(update(QResistor*)));
	//-------------------color displaying ui---------------------------------------------//
	colorBox = new MyColorBox(this);

	connect(res, SIGNAL(valueModified(QResistor*)),colorBox,SLOT(update(QResistor*)));

	//-------------------paste the configuration to clipboard--------------------------------------------//
	connect(res, SIGNAL(valueModified(QResistor*)),this,SLOT(slotConfiguration()));
	//-------------------switching buttons ui--------------------------------------//
  QPushButton *calcColor = new QPushButton(QPixmap(":/bitmaps/next.png")," To Colors", this, "calcColor" );
	connect(calcColor, SIGNAL(clicked()),this,SLOT(setResistanceValue()));

	QPushButton *calcResistance = new QPushButton(QPixmap(":/bitmaps/previous.png")," To Resistance", this, "calcResistance" );
	connect(calcResistance, SIGNAL(clicked()),this,SLOT(setColorValue()));

	QPushButton *quit = new QPushButton( "Quit", this, "quit" );
	connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) );

  QHBoxLayout *buttonBox = new QHBoxLayout;
  buttonBox->addWidget(calcColor);
  buttonBox->addWidget(calcResistance);
  buttonBox->addWidget(quit);

	//--------------------packing all of them together---------------------------------------//
  QGridLayout *grid = new QGridLayout(this);
  grid->setMargin(10);

#ifndef __APPLE__
    QWidget *Space = new QWidget(this);   // reserve space for menubar
    Space->setFixedSize(1, menuBar->height());
    grid->addWidget(Space, 0,0);
#endif

	grid->addWidget( resBox, 1, 0 );
	grid->addLayout( buttonBox, 2, 0 );
	grid->addWidget( colorBox, 3, 0 );

}
void PathStrokeControls::layoutForSmallScreens()
{
    createCommonControls(this);

    m_capGroup->layout()->setMargin(0);
    m_joinGroup->layout()->setMargin(0);
    m_styleGroup->layout()->setMargin(0);
    m_pathModeGroup->layout()->setMargin(0);

    QPushButton* okBtn = new QPushButton(tr("OK"), this);
    okBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    okBtn->setMinimumSize(100,okBtn->minimumSize().height());

    QPushButton* quitBtn = new QPushButton(tr("Quit"), this);
    quitBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    quitBtn->setMinimumSize(100, okBtn->minimumSize().height());

    QLabel *penWidthLabel = new QLabel(tr(" Width:"));
    QSlider *penWidth = new QSlider(Qt::Horizontal, this);
    penWidth->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    penWidth->setRange(0, 500);

#ifdef QT_OPENGL_SUPPORT
    QPushButton *enableOpenGLButton = new QPushButton(this);
    enableOpenGLButton->setText(tr("Use OpenGL"));
    enableOpenGLButton->setCheckable(true);
    enableOpenGLButton->setChecked(m_renderer->usesOpenGL());
    if (!QGLFormat::hasOpenGL())
        enableOpenGLButton->hide();
#endif

    // Layouts:
    QHBoxLayout *penWidthLayout = new QHBoxLayout(0);
    penWidthLayout->addWidget(penWidthLabel, 0, Qt::AlignRight);
    penWidthLayout->addWidget(penWidth);

    QVBoxLayout *leftLayout = new QVBoxLayout(0);
    leftLayout->addWidget(m_capGroup);
    leftLayout->addWidget(m_joinGroup);
#ifdef QT_OPENGL_SUPPORT
    leftLayout->addWidget(enableOpenGLButton);
#endif
    leftLayout->addLayout(penWidthLayout);

    QVBoxLayout *rightLayout = new QVBoxLayout(0);
    rightLayout->addWidget(m_styleGroup);
    rightLayout->addWidget(m_pathModeGroup);

    QGridLayout *mainLayout = new QGridLayout(this);
    mainLayout->setMargin(0);

    // Add spacers around the form items so we don't look stupid at higher resolutions
    mainLayout->addItem(new QSpacerItem(0,0), 0, 0, 1, 4);
    mainLayout->addItem(new QSpacerItem(0,0), 1, 0, 2, 1);
    mainLayout->addItem(new QSpacerItem(0,0), 1, 3, 2, 1);
    mainLayout->addItem(new QSpacerItem(0,0), 3, 0, 1, 4);

    mainLayout->addLayout(leftLayout, 1, 1);
    mainLayout->addLayout(rightLayout, 1, 2);
    mainLayout->addWidget(quitBtn, 2, 1, Qt::AlignHCenter | Qt::AlignTop);
    mainLayout->addWidget(okBtn, 2, 2, Qt::AlignHCenter | Qt::AlignTop);

#ifdef QT_OPENGL_SUPPORT
    connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool)));
#endif

    connect(penWidth, SIGNAL(valueChanged(int)), m_renderer, SLOT(setPenWidth(int)));
    connect(quitBtn, SIGNAL(clicked()), this, SLOT(emitQuitSignal()));
    connect(okBtn, SIGNAL(clicked()), this, SLOT(emitOkSignal()));

    m_renderer->setAnimation(true);
    penWidth->setValue(50);
}
Пример #14
0
/* 
 * Sets up the GUI. It's a bit messy. These are the important things to remember:
 *   1. The parameter/state block created by DefaultGUIModel is HIDDEN. 
 *   2. The Unload button is hidden, Pause is renamed 'Auto', and Modify is renamed 'Set DAQ'
 *   3. All GUI changes are connected to their respective text boxes in the hidden block
 *   4. 'Set DAQ' updates the values of inner variables with GUI choices linked to the text boxes
 * 
 * Okay, here we go!
 */
void AMAmp::customizeGUI(void) {
	QGridLayout *customLayout = DefaultGUIModel::getLayout();
	
	customLayout->itemAtPosition(1,0)->widget()->setVisible(false);
	DefaultGUIModel::pauseButton->setVisible(false);
	DefaultGUIModel::modifyButton->setText("Set DAQ");
	DefaultGUIModel::unloadButton->setVisible(false);

	// create input spinboxes
	QGroupBox *ioGroupBox = new QGroupBox("Channels");
	QGridLayout *ioGroupLayout = new QGridLayout;
	ioGroupBox->setLayout(ioGroupLayout);

	QLabel *inputBoxLabel = new QLabel("Input");
	inputBox = new AMAmpSpinBox; // this is the QSpinBox wrapper made earlier
	inputBox->setRange(0,100);
	ioGroupLayout->addWidget(inputBoxLabel, 0, 0);
	ioGroupLayout->addWidget(inputBox, 0, 1);

	QLabel *outputBoxLabel = new QLabel("Output");
	outputBox = new AMAmpSpinBox;
	outputBox->setRange(0,100);
	ioGroupLayout->addWidget(outputBoxLabel, 1, 0);
	ioGroupLayout->addWidget(outputBox, 1, 1);

	// create amp mode groupbox
	QGroupBox *ampModeGroupBox = new QGroupBox("Amp Mode");
	QGridLayout *ampModeGroupLayout = new QGridLayout;
	ampModeGroupBox->setLayout(ampModeGroupLayout);

	QGridLayout *offsetLayout = new QGridLayout;
	offsetLayout->setColumnStretch(0, 1);
	QLabel *aiOffsetLabel = new QLabel("AI Offset:");
	offsetLayout->addWidget(aiOffsetLabel, 0, 0);
	aiOffsetEdit = new AMAmpLineEdit();
	aiOffsetEdit->setMaximumWidth(aiOffsetEdit->minimumSizeHint().width()*3);
	aiOffsetEdit->setValidator( new QDoubleValidator(aiOffsetEdit) );
	offsetLayout->addWidget(aiOffsetEdit, 0, 1);
	aiOffsetUnits = new QLabel("1 V/V");
	offsetLayout->addWidget(aiOffsetUnits, 0, 2, Qt::AlignCenter);
	
	QLabel *aoOffsetLabel = new QLabel("AO Offset:");
	offsetLayout->addWidget(aoOffsetLabel, 1, 0);
	aoOffsetEdit = new AMAmpLineEdit();
	aoOffsetEdit->setMaximumWidth(aoOffsetEdit->minimumSizeHint().width()*3);
	aoOffsetEdit->setValidator( new QDoubleValidator(aoOffsetEdit) );
	offsetLayout->addWidget(aoOffsetEdit, 1, 1);
	aoOffsetUnits = new QLabel("---");
	offsetLayout->addWidget(aoOffsetUnits, 1, 2, Qt::AlignCenter);

	findZeroButton = new QPushButton("Zero AI/AO Channels");
	findZeroButton->setToolTip("Find offset that will make output from specified channel = 0");
	offsetLayout->addWidget(findZeroButton, 2, 0, 1, 3);

	ampModeGroupLayout->addLayout(offsetLayout, 0, 0);

	//add little bit of space betwen offsets and buttons
	ampModeGroupLayout->addItem( new QSpacerItem(0, 10, QSizePolicy::Expanding, QSizePolicy::Minimum), 2, 0);

	// add probe gain combobox
	QGridLayout *probeGainLayout = new QGridLayout;
	QLabel *probeGainLabel = new QLabel("Probe Gain:");
	probeGainComboBox = new AMAmpComboBox;
	probeGainComboBox->insertItem(0, QString::fromUtf8("Low (10 MΩ)"));
	probeGainComboBox->insertItem(1, QString::fromUtf8("High (10 GΩ)"));
	probeGainLayout->addWidget(probeGainLabel, 0, 0);
	probeGainLayout->addWidget(probeGainComboBox, 0, 1);
	ampModeGroupLayout->addLayout(probeGainLayout, 3, 0);

	//add little bit of space betwen offsets and buttons
	ampModeGroupLayout->addItem( new QSpacerItem(0, 10, QSizePolicy::Expanding, QSizePolicy::Minimum), 4, 0);

	// make the buttons
	ampButtonGroup = new QButtonGroup;
	vclampButton = new QRadioButton("VClamp");
	ampButtonGroup->addButton(vclampButton, 1);
	izeroButton = new QRadioButton("I = 0");
	ampButtonGroup->addButton(izeroButton, 2);
	iclampButton = new QRadioButton("IClamp");
	ampButtonGroup->addButton(iclampButton, 3);
	vcompButton = new QRadioButton("VComp");
	ampButtonGroup->addButton(vcompButton, 4);
	vtestButton = new QRadioButton("VTest");
	ampButtonGroup->addButton(vtestButton, 5);
	iresistButton = new QRadioButton("IResist");
	ampButtonGroup->addButton(iresistButton, 6);
	ifollowButton = new QRadioButton("IFollow");
	ampButtonGroup->addButton(ifollowButton, 7);

	QGridLayout *ampButtonGroupLayout = new QGridLayout;
	ampButtonGroupLayout->addWidget(vclampButton, 0, 0);
	ampButtonGroupLayout->addWidget(izeroButton, 0, 1);
	ampButtonGroupLayout->addWidget(iclampButton, 1, 0);
	ampButtonGroupLayout->addWidget(vcompButton, 1, 1);
	ampButtonGroupLayout->addWidget(vtestButton, 2, 0);
	ampButtonGroupLayout->addWidget(iresistButton, 2, 1);
	ampButtonGroupLayout->addWidget(ifollowButton, 3, 0);

	ampModeGroupLayout->addLayout(ampButtonGroupLayout, 5, 0);

	// add widgets to custom layout
	customLayout->addWidget(ioGroupBox, 0, 0);
	customLayout->addWidget(ampModeGroupBox, 2, 0);
	setLayout(customLayout);

	checkZeroCalc = new QTimer(this);

	// connect the widgets to the signals
	QObject::connect(ampButtonGroup, SIGNAL(buttonPressed(int)), this, SLOT(updateMode(int)));
	QObject::connect(ampButtonGroup, SIGNAL(buttonPressed(int)), this, SLOT(updateOffset(int)));
	QObject::connect(inputBox, SIGNAL(valueChanged(int)), this, SLOT(updateInputChannel(int)));
	QObject::connect(outputBox, SIGNAL(valueChanged(int)), this, SLOT(updateOutputChannel(int)));
	QObject::connect(aiOffsetEdit, SIGNAL(textEdited(const QString &)), this, SLOT(setAIOffset(const QString &)));
	QObject::connect(aoOffsetEdit, SIGNAL(textEdited(const QString &)), this, SLOT(setAOOffset(const QString &)));
	QObject::connect(findZeroButton, SIGNAL(clicked(void)), this, SLOT(findZeroOffset(void)));
	QObject::connect(checkZeroCalc, SIGNAL(timeout(void)), this, SLOT(calculateOffset(void)));
	QObject::connect(probeGainComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setProbeGain(int)));
}
Пример #15
0
PeopleDefinitionInspectorView::PeopleDefinitionInspectorView(bool isIP, 
                                                             const openstudio::model::Model& model,
                                                             QWidget * parent)
  : ModelObjectInspectorView(model, true, parent)
{
  m_isIP = isIP;

  //QWidget* hiddenWidget = new QWidget();
  //this->stackedWidget()->insertWidget(0, hiddenWidget);

  QWidget* visibleWidget = new QWidget();
  this->stackedWidget()->addWidget(visibleWidget);

  //this->stackedWidget()->setCurrentIndex(0);

  QGridLayout* mainGridLayout = new QGridLayout();
  mainGridLayout->setContentsMargins(7,7,7,7);
  mainGridLayout->setSpacing(14);
  visibleWidget->setLayout(mainGridLayout);

  // name
  QVBoxLayout* vLayout = new QVBoxLayout();

  QLabel* label = new QLabel("Name: ");
  label->setObjectName("H2");
  vLayout->addWidget(label);

  m_nameEdit = new OSLineEdit2();
  vLayout->addWidget(m_nameEdit);

  mainGridLayout->addLayout(vLayout,0,0,1,3, Qt::AlignTop);

  // number of people, people per area, and area per person
  vLayout = new QVBoxLayout();

  label = new QLabel("Number of People: ");
  label->setObjectName("H2");
  vLayout->addWidget(label);

  bool isConnected = false;

  m_numberofPeopleEdit = new OSDoubleEdit2();
  vLayout->addWidget(m_numberofPeopleEdit);

  mainGridLayout->addLayout(vLayout,1,0, Qt::AlignTop|Qt::AlignLeft);

  vLayout = new QVBoxLayout();

  label = new QLabel("People per Space Floor Area: ");
  label->setObjectName("H2");
  vLayout->addWidget(label);

  m_peopleperSpaceFloorAreaEdit = new OSQuantityEdit2("people/m^2", "people/m^2", "people/ft^2", m_isIP);
  isConnected = connect(this, SIGNAL(toggleUnitsClicked(bool)), m_peopleperSpaceFloorAreaEdit, SLOT(onUnitSystemChange(bool)));
  OS_ASSERT(isConnected);
  vLayout->addWidget(m_peopleperSpaceFloorAreaEdit);

  mainGridLayout->addLayout(vLayout,1,1, Qt::AlignTop|Qt::AlignLeft);

  vLayout = new QVBoxLayout();

  label = new QLabel("Space Floor Area per Person: ");
  label->setObjectName("H2");
  vLayout->addWidget(label);

  m_spaceFloorAreaperPersonEdit = new OSQuantityEdit2("m^2/person", "m^2/person", "ft^2/person", m_isIP);
  isConnected = connect(this, SIGNAL(toggleUnitsClicked(bool)), m_spaceFloorAreaperPersonEdit, SLOT(onUnitSystemChange(bool)));
  OS_ASSERT(isConnected);
  vLayout->addWidget(m_spaceFloorAreaperPersonEdit);

  mainGridLayout->addLayout(vLayout,1,2, Qt::AlignTop|Qt::AlignLeft);

  // fraction radiance, sensible heat fraction, carbon dioxide rate
  vLayout = new QVBoxLayout();

  label = new QLabel("Fraction Radiant: ");
  label->setObjectName("H2");
  vLayout->addWidget(label);

  m_fractionRadiantEdit = new OSDoubleEdit2();
  vLayout->addWidget(m_fractionRadiantEdit);

  mainGridLayout->addLayout(vLayout,2,0, Qt::AlignTop|Qt::AlignLeft);

  vLayout = new QVBoxLayout();

  label = new QLabel("Sensible Heat Fraction Radiant: ");
  label->setObjectName("H2");
  vLayout->addWidget(label);

  m_sensibleHeatFractionEdit = new OSDoubleEdit2();
  vLayout->addWidget(m_sensibleHeatFractionEdit);

  mainGridLayout->addLayout(vLayout,2,1, Qt::AlignTop|Qt::AlignLeft);

  vLayout = new QVBoxLayout();

  label = new QLabel("Carbon Dioxide Generation Rate: ");
  label->setObjectName("H2");
  vLayout->addWidget(label);

  m_carbonDioxideGenerationRateEdit = new OSQuantityEdit2("m^3/s*W", "L/s*W", "ft^3*hr/min*Btu", m_isIP);
  isConnected = connect(this, SIGNAL(toggleUnitsClicked(bool)), m_carbonDioxideGenerationRateEdit, SLOT(onUnitSystemChange(bool)));
  OS_ASSERT(isConnected);
  vLayout->addWidget(m_carbonDioxideGenerationRateEdit);

  mainGridLayout->addLayout(vLayout,2,2, Qt::AlignTop|Qt::AlignLeft);

  mainGridLayout->setColumnMinimumWidth(0, 80);
  mainGridLayout->setColumnMinimumWidth(1, 80);
  mainGridLayout->setColumnMinimumWidth(2, 80);
  mainGridLayout->setColumnStretch(3,1);
  mainGridLayout->setRowMinimumHeight(0, 30);
  mainGridLayout->setRowMinimumHeight(1, 30);
  mainGridLayout->setRowMinimumHeight(2, 30);
  mainGridLayout->setRowStretch(3,1);
}
OptionsServerPage::OptionsServerPage(DVRServerRepository *serverRepository, QWidget *parent)
    : OptionsDialogPage(parent), m_serverRepository(serverRepository)
{
    Q_ASSERT(m_serverRepository);

    QBoxLayout *mainLayout = new QVBoxLayout(this);
    QBoxLayout *topLayout = new QHBoxLayout;
    mainLayout->addLayout(topLayout);

    /* Servers list */
    m_serversView = new QTreeView;

    m_model = new DVRServersModel(serverRepository, false, m_serversView);
    m_proxyModel = new DVRServersProxyModel(m_model);
    m_proxyModel->setDynamicSortFilter(true);
    m_proxyModel->setSourceModel(m_model);
    m_proxyModel->sort(0);

    m_serversView->setModel(m_proxyModel);

    m_serversView->header()->setHighlightSections(false);
    m_serversView->header()->setResizeMode(QHeaderView::ResizeToContents);
    m_serversView->header()->setResizeMode(0, QHeaderView::Stretch);
    m_serversView->header()->setStretchLastSection(false);
    m_serversView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    m_serversView->setMinimumSize(480, 150);
    m_serversView->setSelectionBehavior(QAbstractItemView::SelectRows);
    m_serversView->setSelectionMode(QAbstractItemView::SingleSelection);
    m_serversView->setItemsExpandable(false);
    m_serversView->setRootIsDecorated(false);
    topLayout->addWidget(m_serversView);

    connect(m_serversView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
            SLOT(currentServerChanged(QModelIndex,QModelIndex)));

    /* Editing area */
    QGridLayout *editsLayout = new QGridLayout;
    mainLayout->addLayout(editsLayout);

    QLabel *label = new QLabel(tr("Name:"));
    editsLayout->addWidget(label, 0, 0, Qt::AlignRight);

    m_nameEdit = new QLineEdit;
    editsLayout->addWidget(m_nameEdit, 0, 1);

    label = new QLabel(tr("Hostname:"));
    editsLayout->addWidget(label, 1, 0, Qt::AlignRight);

    QBoxLayout *hnLayout = new QBoxLayout(QBoxLayout::LeftToRight);
    m_hostnameEdit = new QLineEdit;
    hnLayout->addWidget(m_hostnameEdit);

    m_portEdit = new QLineEdit;
    m_portEdit->setValidator(new QIntValidator(1, 65535, m_portEdit));
    m_portEdit->setFixedWidth(50);
    hnLayout->addWidget(m_portEdit);

    m_portChecker = new WebRtpPortCheckerWidget;
    hnLayout->addWidget(m_portChecker);

    editsLayout->addLayout(hnLayout, 1, 1);

    label = new QLabel(tr("Connection Type:"));
    editsLayout->addWidget(label, 2, 0, Qt::AlignRight);

    m_connectionType = new QComboBox;
    m_connectionType->addItem(tr("RTSP"));
    m_connectionType->addItem(tr("MJPEG"));
    editsLayout->addWidget(m_connectionType, 2, 1);

    label = new QLabel(tr("Username:"******"Password:"******"Connect Automatically"));
    m_autoConnect->setChecked(true);
    editsLayout->addWidget(m_autoConnect, 3, 1, 1, 1);

    /* Errors */
    m_connectionStatus = new QLabel;
    m_connectionStatus->setAlignment(Qt::AlignCenter);
    //m_connectionStatus->setContentsMargins(4, 4, 4, 4);
    m_connectionStatus->setVisible(false);
    mainLayout->addWidget(m_connectionStatus);

    /* Buttons */
    QFrame *line = new QFrame;
    line->setFrameStyle(QFrame::HLine | QFrame::Sunken);
    mainLayout->addWidget(line);

    QBoxLayout *btnLayout = new QHBoxLayout;
    mainLayout->addLayout(btnLayout);

    QPushButton *newBtn = new QPushButton(tr("Add Server"));
    newBtn->setAutoDefault(false);
    connect(newBtn, SIGNAL(clicked()), SLOT(addNewServer()));
    btnLayout->addWidget(newBtn);

    QPushButton *delBtn = new QPushButton(tr("Delete"));
    delBtn->setAutoDefault(false);
    connect(delBtn, SIGNAL(clicked()), SLOT(deleteServer()));
    btnLayout->addWidget(delBtn);

    btnLayout->addStretch();
    QPushButton *applyBtn = new QPushButton(tr("Apply"));
    applyBtn->setAutoDefault(false);
    connect(applyBtn, SIGNAL(clicked()), SLOT(saveChanges()));
    btnLayout->addWidget(applyBtn);

    connect(m_hostnameEdit, SIGNAL(editingFinished()), this, SLOT(checkServer()));
    connect(m_portEdit, SIGNAL(editingFinished()), this, SLOT(checkServer()));
}
//! [10]
void Window::createGeneralOptionsGroupBox()
{
    generalOptionsGroupBox = new QGroupBox(tr("General Options"));

    localeCombo = new QComboBox;
    int curLocaleIndex = -1;
    int index = 0;
    for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) {
        QLocale::Language lang = static_cast<QLocale::Language>(_lang);
        QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang);
        for (int i = 0; i < countries.count(); ++i) {
            QLocale::Country country = countries.at(i);
            QString label = QLocale::languageToString(lang);
            label += QLatin1Char('/');
            label += QLocale::countryToString(country);
            QLocale locale(lang, country);
            if (this->locale().language() == lang && this->locale().country() == country)
                curLocaleIndex = index;
            localeCombo->addItem(label, locale);
            ++index;
        }
    }
    if (curLocaleIndex != -1)
        localeCombo->setCurrentIndex(curLocaleIndex);
    localeLabel = new QLabel(tr("&Locale"));
    localeLabel->setBuddy(localeCombo);

    firstDayCombo = new QComboBox;
    firstDayCombo->addItem(tr("Sunday"), Qt::Sunday);
    firstDayCombo->addItem(tr("Monday"), Qt::Monday);
    firstDayCombo->addItem(tr("Tuesday"), Qt::Tuesday);
    firstDayCombo->addItem(tr("Wednesday"), Qt::Wednesday);
    firstDayCombo->addItem(tr("Thursday"), Qt::Thursday);
    firstDayCombo->addItem(tr("Friday"), Qt::Friday);
    firstDayCombo->addItem(tr("Saturday"), Qt::Saturday);

    firstDayLabel = new QLabel(tr("Wee&k starts on:"));
    firstDayLabel->setBuddy(firstDayCombo);
//! [10]

    selectionModeCombo = new QComboBox;
    selectionModeCombo->addItem(tr("Single selection"),
                                QCalendarWidget::SingleSelection);
    selectionModeCombo->addItem(tr("None"), QCalendarWidget::NoSelection);

    selectionModeLabel = new QLabel(tr("&Selection mode:"));
    selectionModeLabel->setBuddy(selectionModeCombo);

    gridCheckBox = new QCheckBox(tr("&Grid"));
    gridCheckBox->setChecked(calendar->isGridVisible());

    navigationCheckBox = new QCheckBox(tr("&Navigation bar"));
    navigationCheckBox->setChecked(true);

    horizontalHeaderCombo = new QComboBox;
    horizontalHeaderCombo->addItem(tr("Single letter day names"),
                                   QCalendarWidget::SingleLetterDayNames);
    horizontalHeaderCombo->addItem(tr("Short day names"),
                                   QCalendarWidget::ShortDayNames);
    horizontalHeaderCombo->addItem(tr("None"),
                                   QCalendarWidget::NoHorizontalHeader);
    horizontalHeaderCombo->setCurrentIndex(1);

    horizontalHeaderLabel = new QLabel(tr("&Horizontal header:"));
    horizontalHeaderLabel->setBuddy(horizontalHeaderCombo);

    verticalHeaderCombo = new QComboBox;
    verticalHeaderCombo->addItem(tr("ISO week numbers"),
                                 QCalendarWidget::ISOWeekNumbers);
    verticalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoVerticalHeader);

    verticalHeaderLabel = new QLabel(tr("&Vertical header:"));
    verticalHeaderLabel->setBuddy(verticalHeaderCombo);

//! [11]
    connect(localeCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(localeChanged(int)));
    connect(firstDayCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(firstDayChanged(int)));
    connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(selectionModeChanged(int)));
    connect(gridCheckBox, SIGNAL(toggled(bool)),
            calendar, SLOT(setGridVisible(bool)));
    connect(navigationCheckBox, SIGNAL(toggled(bool)),
            calendar, SLOT(setNavigationBarVisible(bool)));
    connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(horizontalHeaderChanged(int)));
    connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(verticalHeaderChanged(int)));
//! [11]

    QHBoxLayout *checkBoxLayout = new QHBoxLayout;
    checkBoxLayout->addWidget(gridCheckBox);
    checkBoxLayout->addStretch();
    checkBoxLayout->addWidget(navigationCheckBox);

    QGridLayout *outerLayout = new QGridLayout;
    outerLayout->addWidget(localeLabel, 0, 0);
    outerLayout->addWidget(localeCombo, 0, 1);
    outerLayout->addWidget(firstDayLabel, 1, 0);
    outerLayout->addWidget(firstDayCombo, 1, 1);
    outerLayout->addWidget(selectionModeLabel, 2, 0);
    outerLayout->addWidget(selectionModeCombo, 2, 1);
    outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2);
    outerLayout->addWidget(horizontalHeaderLabel, 4, 0);
    outerLayout->addWidget(horizontalHeaderCombo, 4, 1);
    outerLayout->addWidget(verticalHeaderLabel, 5, 0);
    outerLayout->addWidget(verticalHeaderCombo, 5, 1);
    generalOptionsGroupBox->setLayout(outerLayout);

//! [12]
    firstDayChanged(firstDayCombo->currentIndex());
    selectionModeChanged(selectionModeCombo->currentIndex());
    horizontalHeaderChanged(horizontalHeaderCombo->currentIndex());
    verticalHeaderChanged(verticalHeaderCombo->currentIndex());
}
Пример #18
0
void ParameterGroup::setFixedSize(bool pFixed)
{
  if (pFixed == _fixed)
    return;
  
  if (layout())
    delete layout();
    
  if (_selectedGroup->layout())
    delete _selectedGroup->layout();
      
  if (_patternGroup->layout())
    delete _patternGroup->layout();
  
  if (pFixed)
  {
    setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
    QHBoxLayout * hLayout = new QHBoxLayout(_selectedGroup);
    hLayout->setSpacing(5);
    hLayout->setMargin(0);
    hLayout->addWidget(_selected);
    hLayout->addWidget(_items);
    _selectedGroup->setLayout(hLayout);

    hLayout = new QHBoxLayout(_patternGroup);
    hLayout->setSpacing(5);
    hLayout->setMargin(0);
    hLayout->addWidget(_usePattern);
    hLayout->addWidget(_pattern);
    _patternGroup->setLayout(hLayout);

    QVBoxLayout * vLayout = new QVBoxLayout(this);
    vLayout->setSpacing(0);
    vLayout->setMargin(5);
    vLayout->addWidget(_all);
    vLayout->addWidget(_selectedGroup);
    vLayout->addWidget(_patternGroup);
    setLayout(vLayout);
  }
  else
  {
    setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
    QGridLayout * gridLayout = new QGridLayout(this);
    QGridLayout * gridLayout1 = new QGridLayout();
  #if defined Q_OS_MAC
    gridLayout1->setRowMinimumHeight(0,24);
  #endif
    
    gridLayout1->addWidget(_all, 0, 0, 1, 2);
    
    gridLayout1->addWidget(_selected, 1, 0, 1, 1);

    QHBoxLayout * hboxLayout = new QHBoxLayout();
    hboxLayout->setSpacing(5);
    hboxLayout->addWidget(_items);
    QSpacerItem * spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    hboxLayout->addItem(spacerItem);
    gridLayout1->addLayout(hboxLayout, 1, 1, 1, 1);

    gridLayout1->addWidget(_usePattern, 2, 0, 1, 1);

    QHBoxLayout * hboxLayout1 = new QHBoxLayout();
    hboxLayout1->setSpacing(5);
    hboxLayout1->addWidget(_pattern);
    QSpacerItem * spacerItem1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    hboxLayout1->addItem(spacerItem1);
    gridLayout1->addLayout(hboxLayout1, 2, 1, 1, 1);
    
    QVBoxLayout * vboxLayout1 = new QVBoxLayout();
    vboxLayout1->setSpacing(5);
    vboxLayout1->addLayout(gridLayout1);
    QSpacerItem * spacerItem2 = new QSpacerItem(20, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
    vboxLayout1->addItem(spacerItem2);

    gridLayout->addLayout(vboxLayout1, 0, 0, 1, 1);
  }
  _buttonGroup->addButton(_all);
  _buttonGroup->addButton(_selected);
  _buttonGroup->addButton(_usePattern);
  _fixed = pFixed;
}
Пример #19
0
MetadataWidget::MetadataWidget(QWidget* parent) :
   QWidget(parent),
   mpMetadata(NULL)
{
   // Metadata
   QLabel* pMetadataLabel = new QLabel("Metadata:", this);

   mpMetadataModel = new DynamicObjectItemModel(this, NULL);
   mpMetadataSortingModel = new QSortFilterProxyModel(this);
   mpMetadataSortingModel->setSortCaseSensitivity(Qt::CaseInsensitive);
   mpMetadataSortingModel->setSourceModel(mpMetadataModel);

   mpMetadataTree = new QTreeView(this);
   mpMetadataTree->setSelectionMode(QAbstractItemView::SingleSelection);
   mpMetadataTree->setRootIsDecorated(true);
   mpMetadataTree->setSortingEnabled(true);
   mpMetadataTree->sortByColumn(0, Qt::AscendingOrder);
   mpMetadataTree->setUniformRowHeights(true);
   mpMetadataTree->setModel(mpMetadataSortingModel);
   mpMetadataTree->setSelectionBehavior(QAbstractItemView::SelectRows);
   mpMetadataTree->setAllColumnsShowFocus(true);
   mpMetadataTree->setContextMenuPolicy(Qt::ActionsContextMenu);
   QAction* pCopyIdAction = new QAction("Copy item ID to clipboard", mpMetadataTree);
   mpMetadataTree->addAction(pCopyIdAction);
   QAction* pCopyValueAction = new QAction("Copy item value to clipboard", mpMetadataTree);
   mpMetadataTree->addAction(pCopyValueAction);

   QHeaderView* pHeader = mpMetadataTree->header();
   if (pHeader != NULL)
   {
      pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
      pHeader->setSortIndicatorShown(true);
      pHeader->resizeSection(1, 200); // Set the default Value column width
   }

   // Filter
   mpFilterCheck = new QCheckBox("Filter:", this);
   mpFilterCombo = new QComboBox(this);
   mpFilterCombo->setEditable(false);

   // Buttons
   mpCreateFilterButton = new QToolButton(this);
   mpCreateFilterButton->setIcon(QIcon(":/icons/CreateFilter"));
   mpCreateFilterButton->setToolTip("Create Filter");
   mpCreateFilterButton->setAutoRaise(true);

   mpEditFilterButton = new QToolButton(this);
   mpEditFilterButton->setIcon(QIcon(":/icons/EditFilter"));
   mpEditFilterButton->setToolTip("Edit Filter");
   mpEditFilterButton->setAutoRaise(true);

   mpDeleteFilterButton = new QToolButton(this);
   mpDeleteFilterButton->setIcon(QIcon(":/icons/DeleteFilter"));
   mpDeleteFilterButton->setToolTip("Delete Filter");
   mpDeleteFilterButton->setAutoRaise(true);

   mpModifyButton = new QToolButton(this);
   mpModifyButton->setIcon(QIcon(":/icons/ModifyMetadata"));
   mpModifyButton->setToolTip("Modify Values");
   mpModifyButton->setAutoRaise(true);

   mpAddChildButton = new QToolButton(this);
   mpAddChildButton->setIcon(QIcon(":/icons/AddMetadataChild"));
   mpAddChildButton->setToolTip("Add Child");
   mpAddChildButton->setAutoRaise(true);

   mpAddSiblingButton = new QToolButton(this);
   mpAddSiblingButton->setIcon(QIcon(":/icons/AddMetadataSibling"));
   mpAddSiblingButton->setToolTip("Add Sibling");
   mpAddSiblingButton->setAutoRaise(true);

   mpEditButton = new QToolButton(this);
   mpEditButton->setIcon(QIcon(":/icons/EditMetadataValue"));
   mpEditButton->setToolTip("Edit");
   mpEditButton->setAutoRaise(true);

   mpDeleteButton = new QToolButton(this);
   mpDeleteButton->setIcon(QIcon(":/icons/DeleteMetadataValue"));
   mpDeleteButton->setToolTip("Delete");
   mpDeleteButton->setAutoRaise(true);

   mpClearButton = new QToolButton(this);
   mpClearButton->setIcon(QIcon(":/icons/ClearMetadata"));
   mpClearButton->setToolTip("Clear");
   mpClearButton->setAutoRaise(true);

   // Layout
   QHBoxLayout* pButtonLayout = new QHBoxLayout();
   pButtonLayout->setMargin(0);
   pButtonLayout->setSpacing(0);
   pButtonLayout->addWidget(mpCreateFilterButton);
   pButtonLayout->addWidget(mpEditFilterButton);
   pButtonLayout->addWidget(mpDeleteFilterButton);
   pButtonLayout->addSpacing(15);
   pButtonLayout->addStretch();
   pButtonLayout->addWidget(mpModifyButton);
   pButtonLayout->addSpacing(15);
   pButtonLayout->addWidget(mpAddChildButton);
   pButtonLayout->addWidget(mpAddSiblingButton);
   pButtonLayout->addWidget(mpEditButton);
   pButtonLayout->addWidget(mpDeleteButton);
   pButtonLayout->addWidget(mpClearButton);

   QGridLayout* pGrid = new QGridLayout(this);
   pGrid->setMargin(0);
   pGrid->setSpacing(5);
   pGrid->addWidget(pMetadataLabel, 0, 0, 1, 2);
   pGrid->addWidget(mpMetadataTree, 1, 0, 1, 2);
   pGrid->addWidget(mpFilterCheck, 2, 0);
   pGrid->addWidget(mpFilterCombo, 2, 1);
   pGrid->addLayout(pButtonLayout, 3, 0, 1, 2);
   pGrid->setRowStretch(1, 10);
   pGrid->setColumnStretch(1, 10);

   Service<DesktopServices> pDesktop;
   bool editWarning = pDesktop->getSuppressibleMsgDlgState(getEditWarningDialogId());

   // Initialization
   mpFilterCombo->setEnabled(false);
   mpCreateFilterButton->setEnabled(false);
   mpEditFilterButton->setEnabled(false);
   mpDeleteFilterButton->setEnabled(false);
   mpModifyButton->setEnabled(!editWarning);
   mpAddChildButton->setEnabled(editWarning);
   mpAddSiblingButton->setEnabled(false);
   mpEditButton->setEnabled(false);
   mpDeleteButton->setEnabled(false);
   mpClearButton->setEnabled(editWarning);

   // Connections
   if (editWarning == true)
   {
      VERIFYNR(connect(mpMetadataTree->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)),
         this, SLOT(currentChanged(const QModelIndex&, const QModelIndex&))));
      VERIFYNR(connect(mpMetadataTree, SIGNAL(doubleClicked(const QModelIndex&)), this,
         SLOT(editSelectedValue(const QModelIndex&))));
   }
BioXASXASScanConfigurationEditor::BioXASXASScanConfigurationEditor(BioXASXASScanConfiguration *configuration, QWidget *parent) :
	BioXASXASScanConfigurationView(parent)
{
	// Create scan name editor.

	QLabel *namePrompt = new QLabel("Name: ");

	nameLineEdit_ = new QLineEdit();

	// Create scan energy editor.

	QLabel *energyPrompt = new QLabel("Energy: ");

	energySpinBox_ = new QDoubleSpinBox();
	energySpinBox_->setSuffix(" eV");
	energySpinBox_->setMinimum(0);
	energySpinBox_->setMaximum(30000);

	edgeEditor_ = new BioXASXASScanConfigurationEdgeEditor(0);

	// Create scan regions editor.

	regionsEditor_ = new BioXASXASScanConfigurationRegionsEditor(0);

	// Create scan detectors editor.

	scientificDetectorsView_ = new AMGenericStepScanConfigurationDetectorsView(0, BioXASBeamline::bioXAS()->exposedScientificDetectors());

	QVBoxLayout *scientificDetectorsWidgetLayout = new QVBoxLayout();
	scientificDetectorsWidgetLayout->addWidget(scientificDetectorsView_);
	scientificDetectorsWidgetLayout->addStretch();

	QWidget *scientificDetectorsWidget = new QWidget();
	scientificDetectorsWidget->setLayout(scientificDetectorsWidgetLayout);

	allDetectorsView_ = new AMGenericStepScanConfigurationDetectorsView(0, BioXASBeamline::bioXAS()->defaultXASScanDetectorOptions());

	QVBoxLayout *allDetectorsWidgetLayout = new QVBoxLayout();
	allDetectorsWidgetLayout->addWidget(allDetectorsView_);
	allDetectorsWidgetLayout->addStretch();

	QWidget *allDetectorsWidget = new QWidget();
	allDetectorsWidget->setLayout(allDetectorsWidgetLayout);

	QTabWidget *detectorsViews = new QTabWidget();
	detectorsViews->addTab(scientificDetectorsWidget, "Scientific");
	detectorsViews->addTab(allDetectorsWidget, "All");

	exportSpectraCheckBox_ = new QCheckBox("Export spectra");

	collectICRsCheckBox_ = new QCheckBox("Collect ICRs");

	// Create and set main layouts

	QHBoxLayout *edgeEditorLayout = new QHBoxLayout();
	edgeEditorLayout->addStretch();
	edgeEditorLayout->addWidget(edgeEditor_);

	QGridLayout *propertiesLayout = new QGridLayout();
	propertiesLayout->addWidget(namePrompt, 0, 0, 1, 1, Qt::AlignRight);
	propertiesLayout->addWidget(nameLineEdit_, 0, 1);
	propertiesLayout->addWidget(energyPrompt, 1, 0, 1, 1, Qt::AlignRight);
	propertiesLayout->addWidget(energySpinBox_, 1, 1);
	propertiesLayout->addLayout(edgeEditorLayout, 1, 2);

	QVBoxLayout *scanBoxLayout = new QVBoxLayout();
	scanBoxLayout->addLayout(propertiesLayout);
	scanBoxLayout->addWidget(regionsEditor_);

	QGroupBox *scanBox = new QGroupBox("Scan");
	scanBox->setLayout(scanBoxLayout);

	QVBoxLayout *detectorBoxLayout = new QVBoxLayout();
	detectorBoxLayout->addWidget(detectorsViews);
	detectorBoxLayout->addWidget(exportSpectraCheckBox_);
	detectorBoxLayout->addWidget(collectICRsCheckBox_);
	detectorBoxLayout->addStretch();

	QGroupBox *detectorBox = new QGroupBox("Detectors");
	detectorBox->setLayout(detectorBoxLayout);

	QHBoxLayout *layout = new QHBoxLayout();
	layout->addWidget(scanBox);
	layout->addWidget(detectorBox);

	setLayout(layout);

	// Make connections.

	connect( nameLineEdit_, SIGNAL(textChanged(QString)), this, SLOT(updateConfigurationName()) );
	connect( energySpinBox_, SIGNAL(valueChanged(double)), this, SLOT(updateConfigurationEnergy()) );
	connect( exportSpectraCheckBox_, SIGNAL(clicked(bool)), this, SLOT(updateConfigurationExportSpectraPreference()) );
	connect( collectICRsCheckBox_, SIGNAL(clicked(bool)), this, SLOT(updateConfigurationCollectICRsPreference()) );

	// Current settings.

	setConfiguration(configuration);
}
Пример #21
0
View::View (MainWindow * mw, const QString & name, QWidget * parent)
	: m_mainWindow(mw)
	, QFrame(parent)
{
	setFrameStyle(Sunken | StyledPanel);
	m_frameSpinBox = new QSpinBox;
	m_graphicsView = new MyGraphicsView(*m_frameSpinBox);
	m_graphicsView->setRenderHint(QPainter::Antialiasing, false);
	m_graphicsView->setDragMode(QGraphicsView::RubberBandDrag);
	m_graphicsView->setOptimizationFlags(QGraphicsView::DontSavePainterState);
	m_graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);

	int size = style()->pixelMetric(QStyle::PM_ToolBarIconSize);
	QSize iconSize(size, size);

	QToolButton * zoomInIcon = new QToolButton;
	zoomInIcon->setAutoRepeat(true);
	zoomInIcon->setAutoRepeatInterval(33);
	zoomInIcon->setAutoRepeatDelay(0);
	zoomInIcon->setIcon(QPixmap(":/zoomin.png"));
	zoomInIcon->setIconSize(iconSize);
	QToolButton * zoomOutIcon = new QToolButton;
	zoomOutIcon->setAutoRepeat(true);
	zoomOutIcon->setAutoRepeatInterval(33);
	zoomOutIcon->setAutoRepeatDelay(0);
	zoomOutIcon->setIcon(QPixmap(":/zoomout.png"));
	zoomOutIcon->setIconSize(iconSize);
	m_zoomSlider = new QSlider;
	m_zoomSlider->setMinimum(0);
	m_zoomSlider->setMaximum(500);
	m_zoomSlider->setValue(250);
	m_zoomSlider->setTickPosition(QSlider::TicksRight);

	// Zoom slider layout
	QVBoxLayout *zoomSliderLayout = new QVBoxLayout;
	zoomSliderLayout->addWidget(zoomInIcon);
	zoomSliderLayout->addWidget(m_zoomSlider);
	zoomSliderLayout->addWidget(zoomOutIcon);

	m_resetButton = new QToolButton;
	m_resetButton->setText(tr("0"));
	m_resetButton->setEnabled(false);

	// Label layout
	QHBoxLayout *labelLayout = new QHBoxLayout;
	m_label = new QLabel(name);
	m_antialiasButton = new QToolButton;
	m_antialiasButton->setText(tr("Antialiasing"));
	m_antialiasButton->setCheckable(true);
	m_antialiasButton->setChecked(false);
	m_openGlButton = new QToolButton;
	m_openGlButton->setText(tr("OpenGL"));
	m_openGlButton->setCheckable(true);
#ifndef QT_NO_OPENGL
	m_openGlButton->setEnabled(QGLFormat::hasOpenGL());
#else
	m_openGlButton->setEnabled(false);
#endif

	labelLayout->addWidget(m_label);
	labelLayout->addStretch();
	labelLayout->addWidget(m_antialiasButton);
	labelLayout->addWidget(m_openGlButton);

	QGridLayout *topLayout = new QGridLayout;
	topLayout->addLayout(labelLayout, 0, 0);
	topLayout->addWidget(m_graphicsView, 1, 0);
	topLayout->addLayout(zoomSliderLayout, 1, 1);

	QSlider * m_heightSlider = new QSlider;
	m_heightSlider->setMinimum(0);
	m_heightSlider->setMaximum(400);
	m_heightSlider->setValue(g_heightValue);
	topLayout->addWidget(m_heightSlider, 1, 2);
	//m_heightSlider->setTickPosition(QSlider::TicksRight);
	//
	m_frameSpinBox->setMinimum(0);
	m_frameSpinBox->setValue(0);

	int const max = m_mainWindow->getProfileInfo(0).m_frames.size();
	m_frameSpinBox->setMaximum(max);
	topLayout->addWidget(m_frameSpinBox, 0, 1);

	topLayout->addWidget(m_resetButton, 2, 1);
	setLayout(topLayout);

	connect(m_resetButton, SIGNAL(clicked()), this, SLOT(resetView()));
	connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setupMatrix()));
	connect(m_graphicsView->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(setResetButtonEnabled()));
	connect(m_graphicsView->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(setResetButtonEnabled()));
	connect(m_antialiasButton, SIGNAL(toggled(bool)), this, SLOT(toggleAntialiasing()));
	connect(m_openGlButton, SIGNAL(toggled(bool)), this, SLOT(toggleOpenGL()));
	connect(zoomInIcon, SIGNAL(clicked()), this, SLOT(zoomIn()));
	connect(zoomOutIcon, SIGNAL(clicked()), this, SLOT(zoomOut()));

	connect(m_heightSlider, SIGNAL(valueChanged(int)), this, SLOT(changeHeight(int)));

	setupMatrix();
}
Пример #22
0
AddressBook::AddressBook(QWidget *parent)
    : QWidget(parent)
{
    QLabel *nameLabel = new QLabel(tr("Name:"));
    nameLine = new QLineEdit;
    nameLine->setReadOnly(true);

    QLabel *addressLabel = new QLabel(tr("Address:"));
    addressText = new QTextEdit;
    addressText->setReadOnly(true);

    addButton = new QPushButton(tr("&Add"));

    editButton = new QPushButton(tr("&Edit"));
    editButton->setEnabled(false);
    removeButton = new QPushButton(tr("&Remove"));
    removeButton->setEnabled(false);
//! [instantiating findButton]
    findButton = new QPushButton(tr("&Find"));
    findButton->setEnabled(false);
//! [instantiating findButton]
    submitButton = new QPushButton(tr("&Submit"));
    submitButton->hide();
    cancelButton = new QPushButton(tr("&Cancel"));
    cancelButton->hide();

    nextButton = new QPushButton(tr("&Next"));
    nextButton->setEnabled(false);
    previousButton = new QPushButton(tr("&Previous"));
    previousButton->setEnabled(false);

//! [instantiating FindDialog]
    dialog = new FindDialog;
//! [instantiating FindDialog]

    connect(addButton, SIGNAL(clicked()), this, SLOT(addContact()));
    connect(submitButton, SIGNAL(clicked()), this, SLOT(submitContact()));
    connect(editButton, SIGNAL(clicked()), this, SLOT(editContact()));
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
    connect(removeButton, SIGNAL(clicked()), this, SLOT(removeContact()));
//! [signals and slots for find]    
    connect(findButton, SIGNAL(clicked()), this, SLOT(findContact()));
//! [signals and slots for find]        
    connect(nextButton, SIGNAL(clicked()), this, SLOT(next()));
    connect(previousButton, SIGNAL(clicked()), this, SLOT(previous()));
    
    QVBoxLayout *buttonLayout1 = new QVBoxLayout;
    buttonLayout1->addWidget(addButton);
    buttonLayout1->addWidget(editButton);
    buttonLayout1->addWidget(removeButton);
//! [adding findButton to layout]        
    buttonLayout1->addWidget(findButton);
//! [adding findButton to layout]            
    buttonLayout1->addWidget(submitButton);
    buttonLayout1->addWidget(cancelButton);
    buttonLayout1->addStretch();

    QHBoxLayout *buttonLayout2 = new QHBoxLayout;
    buttonLayout2->addWidget(previousButton);
    buttonLayout2->addWidget(nextButton);

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(nameLabel, 0, 0);
    mainLayout->addWidget(nameLine, 0, 1);
    mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
    mainLayout->addWidget(addressText, 1, 1);
    mainLayout->addLayout(buttonLayout1, 1, 2);
    mainLayout->addLayout(buttonLayout2, 2, 1);

    setLayout(mainLayout);
    setWindowTitle(tr("Simple Address Book"));
}
Пример #23
0
//Constructors:
ActiveLearningDialog::ActiveLearningDialog(std::vector<QImage> snapshot, vtkSmartPointer<vtkTable> table,int num_classes,std::vector<int> active_query,std::vector<int>top_feats,QWidget *parent)
: QDialog(parent)
{
	rejectFlag = false;
	queries = active_query;
	num_of_classes = num_classes;
	query_label.resize(snapshot.size());
	buttongroup.resize(snapshot.size());

	this->setWindowTitle(tr("Active Learning Window: Specify Class"));
	this->setModal(false);
	//Master Layout
	QGridLayout * layout = new QGridLayout;


	for(int i=0;i<snapshot.size();++i)
	{
	std::vector<QHBoxLayout *> rows  = Sample_Details(snapshot[i],table,num_classes,active_query[i],top_feats,i);
	layout->addLayout(rows[0],2*i,0,0);
	layout->addLayout(rows[1],2*i+1,0,0);
	}
	
	//Sample_Details(snapshot,table,num_classes,active_query,top_feats);
	////QLabel *channelLabel = new QLabel("Please ensure all the relevant channels which might affect classification are ON ", this);	
	////Master Layout
	//layout->addLayout(topRow,2,0,0);
	//layout->addLayout(botRow,3,0,0);


	//Done Button
	QPushButton *doneButton = new QPushButton("Done");
	connect(doneButton, SIGNAL(clicked()), this, SLOT(StartClassification()));
	doneButton->setDefault(false);
	doneButton->setAutoDefault(false);


	QPushButton *nextButton = new QPushButton("Next");
	connect(nextButton, SIGNAL(clicked()), this, SLOT(Retrain()));
	nextButton->setDefault(false);
	nextButton->setAutoDefault(true);


	//Cancel Button
	QPushButton *cancelButton = new QPushButton("Cancel");
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
	cancelButton->setDefault(false);
	cancelButton->setAutoDefault(false);

	//Top-row of the window 
	QHBoxLayout *finalRow = new QHBoxLayout;
	finalRow->addWidget(nextButton,0,0);
	finalRow->addWidget(doneButton,0,0);
	finalRow->addWidget(cancelButton,0,0);

	layout->addLayout(finalRow,2*snapshot.size()+2,0,0);
	this->setLayout(layout);
	
	
	for(int i =0 ; i<query_label.size() ; ++i)
	{
		query_label[i].second = -1;// Used to check if no radiobutton was selected for any sample
	}

	//QLabel *channelLabel = new QLabel("Please ensure all the relevant channels which might affect classification are ON ", this);	
	this->resize(300,300);
}
Пример #24
0
AddressBook::AddressBook(QWidget *parent)
    : QWidget(parent)
{
    QLabel *nameLabel = new QLabel(tr("Name:"));
    nameLine = new QLineEdit;
    nameLine->setReadOnly(true);

    QLabel *addressLabel = new QLabel(tr("Address:"));
    addressText = new QTextEdit;
    addressText->setReadOnly(true);

    addButton = new QPushButton(tr("&Add"));

    editButton = new QPushButton(tr("&Edit"));
    editButton->setEnabled(false);
    removeButton = new QPushButton(tr("&Remove"));
    removeButton->setEnabled(false);
    findButton = new QPushButton(tr("&Find"));
    findButton->setEnabled(false);
    submitButton = new QPushButton(tr("&Submit"));
    submitButton->hide();
    cancelButton = new QPushButton(tr("&Cancel"));
    cancelButton->hide();

    nextButton = new QPushButton(tr("&Next"));
    nextButton->setEnabled(false);
    previousButton = new QPushButton(tr("&Previous"));
    previousButton->setEnabled(false);

    loadButton = new QPushButton(tr("&Load..."));
//! [tooltip 1]
    loadButton->setToolTip(tr("Load contacts from a file"));
//! [tooltip 1]
    saveButton = new QPushButton(tr("&Save..."));
//! [tooltip 2]
    saveButton->setToolTip(tr("Save contacts to a file"));
//! [tooltip 2]
    saveButton->setEnabled(false);

    dialog = new FindDialog(this);

    connect(addButton, SIGNAL(clicked()), this, SLOT(addContact()));
    connect(submitButton, SIGNAL(clicked()), this, SLOT(submitContact()));
    connect(editButton, SIGNAL(clicked()), this, SLOT(editContact()));
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
    connect(removeButton, SIGNAL(clicked()), this, SLOT(removeContact()));
    connect(findButton, SIGNAL(clicked()), this, SLOT(findContact()));
    connect(nextButton, SIGNAL(clicked()), this, SLOT(next()));
    connect(previousButton, SIGNAL(clicked()), this, SLOT(previous()));
    connect(loadButton, SIGNAL(clicked()), this, SLOT(loadFromFile()));
    connect(saveButton, SIGNAL(clicked()), this, SLOT(saveToFile()));

    QVBoxLayout *buttonLayout1 = new QVBoxLayout;
    buttonLayout1->addWidget(addButton);
    buttonLayout1->addWidget(editButton);
    buttonLayout1->addWidget(removeButton);
    buttonLayout1->addWidget(findButton);
    buttonLayout1->addWidget(submitButton);
    buttonLayout1->addWidget(cancelButton);
    buttonLayout1->addWidget(loadButton);
    buttonLayout1->addWidget(saveButton);
    buttonLayout1->addStretch();

    QHBoxLayout *buttonLayout2 = new QHBoxLayout;
    buttonLayout2->addWidget(previousButton);
    buttonLayout2->addWidget(nextButton);

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(nameLabel, 0, 0);
    mainLayout->addWidget(nameLine, 0, 1);
    mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
    mainLayout->addWidget(addressText, 1, 1);
    mainLayout->addLayout(buttonLayout1, 1, 2);
    mainLayout->addLayout(buttonLayout2, 2, 1);

    setLayout(mainLayout);
    setWindowTitle(tr("Simple Address Book"));
}
Пример #25
0
void QGridLayoutProto::addLayout(QLayout *layout, int row, int column, int columnSpan, Qt::Alignment a)
{
  QGridLayout *item = qscriptvalue_cast<QGridLayout*>(thisObject());
  if (item)
    item->addLayout(layout, row, column, columnSpan, a);
}
Пример #26
0
void ServiceBrowser::initWidgets()
{
    showAllServicesItem = new QListWidgetItem(tr("(All registered services)"));

    servicesListWidget = new QListWidget;
    interfacesListWidget = new QListWidget;
    interfacesListWidget->addItem(tr("(Select a service)"));
    attributesListWidget = new QListWidget;
    attributesListWidget->addItem(tr("(Select an interface implementation)"));

    connect(servicesListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
            this, SLOT(reloadInterfaceImplementationsList()));

    connect(interfacesListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
            this, SLOT(currentInterfaceImplChanged(QListWidgetItem*,QListWidgetItem*)));

    defaultInterfaceButton = new QPushButton(tr("Set as default implementation"));
    defaultInterfaceButton->setEnabled(false);
    connect(defaultInterfaceButton, SIGNAL(clicked()),
            this, SLOT(setDefaultInterfaceImplementation()));

    selectedImplRadioButton = new QRadioButton(tr("Selected interface implementation"));
    defaultImplRadioButton = new QRadioButton(tr("Default implementation"));
    selectedImplRadioButton->setChecked(true);

    QButtonGroup *radioButtons = new QButtonGroup(this);
    radioButtons->addButton(selectedImplRadioButton);
    radioButtons->addButton(defaultImplRadioButton);
    connect(radioButtons, SIGNAL(buttonClicked(QAbstractButton*)),
            this, SLOT(reloadAttributesList()));

    QGroupBox *servicesGroup = new QGroupBox(tr("Show services for:"));
    QVBoxLayout *servicesLayout = new QVBoxLayout;
    servicesLayout->addWidget(servicesListWidget);
    servicesGroup->setLayout(servicesLayout);

    interfacesGroup = new QGroupBox(tr("Interface implementations"));
    QVBoxLayout *interfacesLayout = new QVBoxLayout;
    interfacesLayout->addWidget(interfacesListWidget);
    interfacesLayout->addWidget(defaultInterfaceButton);
    interfacesGroup->setLayout(interfacesLayout);

    attributesGroup = new QGroupBox(tr("Invokable attributes"));
    QVBoxLayout *attributesLayout = new QVBoxLayout;
    attributesLayout->addWidget(attributesListWidget);
#if !defined(Q_WS_MAEMO_5)
    // No space on the screen to show following title in Maemo
    attributesLayout->addWidget(new QLabel(tr("Show attributes for:")));
#endif
    attributesLayout->addWidget(selectedImplRadioButton);
    attributesLayout->addWidget(defaultImplRadioButton);
    attributesGroup->setLayout(attributesLayout);

#if defined(Q_WS_MAEMO_5)
    // Maemo 5 style doesn't take group box titles into account.
    int spacingHack = QFontMetrics(QFont()).height();
    interfacesLayout->setContentsMargins(0, spacingHack, 0, 0);
    attributesLayout->setContentsMargins(0, spacingHack, 0, 0);
    servicesLayout->setContentsMargins(0, spacingHack, 0, 0);
#endif
#if defined(MEEGO_EDITION_HARMATTAN)
    QGridLayout *layout = new QGridLayout;
    layout->addWidget(servicesGroup, 0, 0);
    layout->addWidget(attributesGroup, 0, 1, 2, 1);
    layout->addWidget(interfacesGroup, 1, 0);
#else
    QVBoxLayout *layout = new QVBoxLayout;    
    QStackedLayout *stackedLayout = new QStackedLayout;
    stackedLayout->addWidget(servicesGroup);
    stackedLayout->addWidget(interfacesGroup);
    stackedLayout->addWidget(attributesGroup);
    
    QComboBox *pageComboBox = new QComboBox;
    pageComboBox->addItem(tr("Services"));
    pageComboBox->addItem(tr("Interfaces"));
    pageComboBox->addItem(tr("Attributes"));
    connect(pageComboBox, SIGNAL(activated(int)),
            stackedLayout, SLOT(setCurrentIndex(int)));
    
    layout->addWidget(pageComboBox);
    layout->addLayout(stackedLayout);
#endif

    setLayout(layout);
}
Пример #27
0
ObjrefWidget::ObjrefWidget(InterfaceDescriptor_ptr iface,
        QWidget * parent) :
    QWidget(parent), m_model(NULL)
{
    setInterface(iface);

    QGridLayout * mainLayout = new QGridLayout;
    QHBoxLayout * layout = new QHBoxLayout;

    m_selector = new QComboBox;
    QLabel * label = new QLabel("Select source");
    mainLayout->addWidget(label, 0, 0);
    label->setMaximumWidth(150);
    mainLayout->addWidget(m_selector, 0, 1);

    m_stack = new QStackedWidget;
    layout->addWidget(m_stack);

    QPushButton * updateBtn = new QPushButton("Update");
    mainLayout->addWidget(updateBtn, 0, 2);

    updateBtn->setMaximumWidth(90);

    m_status = new qt::Status;
    mainLayout->addWidget(m_status, 0, 3);

    {
        // IOR
        m_selector->addItem("IOR");
        m_ior = new QTextEdit;
        m_ior->setAcceptRichText(false);
        m_stack->addWidget(m_ior);

        // NameService query
        m_selector->addItem("Name service query");
        m_resolve_str = new QTextEdit;
        m_stack->addWidget(m_resolve_str);

        // Well-known objects
        m_selector->addItem("Well-known object");
        QWidget * w = new QWidget;
        QVBoxLayout * l = new QVBoxLayout;
        m_object_selector = new QComboBox;
        l->addWidget(m_object_selector);
        w->setLayout(l);
        m_stack->addWidget(w);
    }
    mainLayout->addLayout(layout, 1, 0, 1, 4);

    setLayout(mainLayout);

    connect(m_selector, SIGNAL(currentIndexChanged(int)),
            m_stack, SLOT(setCurrentIndex(int)));

    connect(m_selector, SIGNAL(currentIndexChanged(int)),
            this, SLOT(valueChanged()));

    connect(m_object_selector, SIGNAL(currentIndexChanged(int)),
            this, SLOT(valueChanged()));

    connect(m_ior, SIGNAL(textChanged()), this, 
            SLOT(valueChanged()));

    connect(m_resolve_str, SIGNAL(textChanged()), this, 
            SLOT(valueChanged()));

    connect(updateBtn, SIGNAL(clicked()), this, 
            SLOT(valueChanged()));

    connect(this, SIGNAL(resolve(Objref_ptr)),
            Application::currentApplication()->nameServiceManager(),
            SLOT(resolve(Objref_ptr)));

    // Default model
    QAbstractItemModel * model = qt::getDefaultInstanceModel();
    if (model)
    {
        setModel(model);
    }

    setMaximumHeight(100);
}
Пример #28
0
//=============================================================================
// GUI
//=============================================================================
QFrame *DialogProxy::createFrameGui(QWidget *parent)
{
    QFrame * frm = new QFrame(parent);
//    QFrame * ftmp;
    QLabel * label;
    QGridLayout  *lay = new QGridLayout(frm);
	lay->setContentsMargins (0,0,0,0);
    int lig=0;
    //-------------------------------------------
	// Proxy or not proxy
    //-------------------------------------------
    QButtonGroup *grp = new QButtonGroup(frm);
    btDontUseProxy    = new QRadioButton(tr("Direct connection to internet"), frm);
    grp->addButton(btDontUseProxy);
    btUseProxy     = new QRadioButton(tr("Connection with a proxy"), frm);
    grp->addButton(btUseProxy);
    QHBoxLayout  *ltmp = new QHBoxLayout ();
	ltmp->addWidget (btDontUseProxy);
	ltmp->addWidget (btUseProxy);
    lig ++;
    lay->addLayout (ltmp, lig,0,   1, 2);	
    //-------------------------
    lig ++;
    label = new QLabel (tr("Proxy type: "), frm);
	listProxyLabels.push_back (label);
    lay->addWidget (label,    lig,0, Qt::AlignRight);
	cbProxyType = new QComboBox (frm);
	cbProxyType->addItem (tr("System default proxy"), (int) QNetworkProxy::DefaultProxy);
	cbProxyType->addItem (tr("HTTP proxy"), (int) QNetworkProxy::HttpProxy);
	cbProxyType->addItem (tr("SOCKS5 proxy"), (int) QNetworkProxy::Socks5Proxy);
    lay->addWidget (cbProxyType, lig,1, Qt::AlignLeft);

    int pval = Util::getSetting ("httpProxyType", QNetworkProxy::HttpProxy).toInt();
    int ind = cbProxyType->findData (pval);
    cbProxyType->setCurrentIndex (ind);
    //-------------------------
    lig ++;
    label = new QLabel(tr("Proxy server: "), frm);
	listProxyLabels.push_back (label);
    lay->addWidget( label,    lig,0, Qt::AlignRight);
    lineProxyHostname = new QLineEdit(frm);
    lineProxyHostname->setFixedWidth(320);
    lay->addWidget( lineProxyHostname, lig,1, Qt::AlignLeft);
    //-------------------------
    lig ++;
    label = new QLabel(tr("Port number :"), frm);
	listProxyLabels.push_back (label);
    lay->addWidget( label,    lig,0, Qt::AlignRight);
    lineProxyPort = new QLineEdit(frm);
    lineProxyPort->setFixedWidth(60);
    
    lineProxyPort->setValidator(new QIntValidator(0,65536, this));
    lay->addWidget( lineProxyPort, lig,1, Qt::AlignLeft);
    //-------------------------
    lig ++;
    label = new QLabel(tr("User * :"), frm);
	listProxyLabels.push_back (label);
    lay->addWidget( label,    lig,0, Qt::AlignRight);
    lineProxyUserName = new QLineEdit(frm);
    lineProxyUserName->setFixedWidth(320);
    lay->addWidget( lineProxyUserName, lig,1, Qt::AlignLeft);
    lig ++;
    label = new QLabel(tr("Password * :"), frm);
	listProxyLabels.push_back (label);
    lay->addWidget( label,    lig,0, Qt::AlignRight);
    lineProxyUserPassword = new QLineEdit(frm);
    lineProxyUserPassword->setFixedWidth(320);
    lineProxyUserPassword->setEchoMode(QLineEdit::Password);
    lay->addWidget( lineProxyUserPassword, lig,1, Qt::AlignLeft);
    lig ++;
    label = new QLabel(tr("(* if needed)"), frm);
	listProxyLabels.push_back (label);
    lay->addWidget( label,    lig,0, 1,2, Qt::AlignLeft);
	
    //-------------------------------------------
	// Strict HTTP Connection or standard
    //-------------------------------------------
//    lig ++;
//    ftmp = new QFrame(frm); ftmp->setFrameShape(QFrame::HLine); lay->addWidget( ftmp, lig,0, 1, -1);
//    //-------------------------
//    QButtonGroup *grp2 = new QButtonGroup (frm);
//	btStandardDownload = new QRadioButton (tr("Standard download"));
//    grp2->addButton (btStandardDownload);
//	btStrictHttpDownload = new QRadioButton (tr("Strict HTTP download"));
//    grp2->addButton (btStrictHttpDownload);
//    ltmp = new QHBoxLayout ();
//	ltmp->addWidget (btStandardDownload);
//	ltmp->addWidget (btStrictHttpDownload);
//    lig ++;
//    lay->addLayout (ltmp, lig,0,   1, 2);
//    //-------------------------
//    lig ++;
//    label = new QLabel(tr("Forum login :"******"Forum password :"******"You must have a valid account on www.zygrib.org forum."), frm);
//	listDownloadLabels.push_back (label);
//    lay->addWidget( label,    lig,0, 1,2, Qt::AlignLeft);
	
    return frm;
}
Пример #29
0
void CalendarWidget::createTextFormatsGroupBox()
{
    textFormatsGroupBox = new QGroupBox(tr("Text Formats"));

    weekdayColorCombo = createColorComboBox();
    weekdayColorCombo->setCurrentIndex(
            weekdayColorCombo->findText(tr("Black")));

    weekdayColorLabel = new QLabel(tr("&Weekday color:"));
    weekdayColorLabel->setBuddy(weekdayColorCombo);

    weekendColorCombo = createColorComboBox();
    weekendColorCombo->setCurrentIndex(
            weekendColorCombo->findText(tr("Red")));

    weekendColorLabel = new QLabel(tr("Week&end color:"));
    weekendColorLabel->setBuddy(weekendColorCombo);

    headerTextFormatCombo = new QComboBox;
    headerTextFormatCombo->addItem(tr("Bold"));
    headerTextFormatCombo->addItem(tr("Italic"));
    headerTextFormatCombo->addItem(tr("Plain"));

    headerTextFormatLabel = new QLabel(tr("&Header text:"));
    headerTextFormatLabel->setBuddy(headerTextFormatCombo);

    firstFridayCheckBox = new QCheckBox(tr("&First Friday in blue"));

    mayFirstCheckBox = new QCheckBox(tr("May &1 in red"));

    connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(weekdayFormatChanged()));
    connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(weekendFormatChanged()));
    connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(QString)),
            this, SLOT(reformatHeaders()));
    connect(firstFridayCheckBox, SIGNAL(toggled(bool)),
            this, SLOT(reformatCalendarPage()));
    connect(mayFirstCheckBox, SIGNAL(toggled(bool)),
            this, SLOT(reformatCalendarPage()));

    QHBoxLayout *checkBoxLayout = new QHBoxLayout;
    checkBoxLayout->addWidget(firstFridayCheckBox);
    checkBoxLayout->addStretch();
    checkBoxLayout->addWidget(mayFirstCheckBox);

    QGridLayout *outerLayout = new QGridLayout;
    outerLayout->addWidget(weekdayColorLabel, 0, 0);
    outerLayout->addWidget(weekdayColorCombo, 0, 1);
    outerLayout->addWidget(weekendColorLabel, 1, 0);
    outerLayout->addWidget(weekendColorCombo, 1, 1);
    outerLayout->addWidget(headerTextFormatLabel, 2, 0);
    outerLayout->addWidget(headerTextFormatCombo, 2, 1);
    outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2);
    textFormatsGroupBox->setLayout(outerLayout);

    weekdayFormatChanged();
    weekendFormatChanged();
    reformatHeaders();
    reformatCalendarPage();
}
Пример #30
0
    SshTunnelTab::SshTunnelTab(ConnectionSettings *settings) :
        _settings(settings)
    {
        SshSettings *info = settings->sshSettings();
        _sshSupport = new QCheckBox("Use SSH tunnel");
        _sshSupport->setStyleSheet("margin-bottom: 7px");
        _sshSupport->setChecked(info->enabled());

        _askForPassword = new QCheckBox(askPasswordText);
        _askForPassword->setChecked(info->askPassword());
        VERIFY(connect(_askForPassword, SIGNAL(stateChanged(int)), this, SLOT(askForPasswordStateChanged(int))));

        _sshHostName = new QLineEdit(QtUtils::toQString(info->host()));
        _userName = new QLineEdit(QtUtils::toQString(info->userName()));

        _sshPort = new QLineEdit(QString::number(info->port()));
        _sshPort->setFixedWidth(40);
        QRegExp rx("\\d+"); //(0-65554)
        _sshPort->setValidator(new QRegExpValidator(rx, this));        

        _security = new QComboBox();
        _security->addItems(QStringList() << "Password" << "Private Key");
        VERIFY(connect(_security, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(securityChange(const QString&))));

        _passwordBox = new QLineEdit(QtUtils::toQString(info->userPassword()));
        _passwordBox->setEchoMode(QLineEdit::Password);
        _passwordEchoModeButton = new QPushButton;
        VERIFY(connect(_passwordEchoModeButton, SIGNAL(clicked()), this, SLOT(togglePasswordEchoMode())));
        togglePasswordEchoMode();

        _privateKeyBox = new QLineEdit(QtUtils::toQString(info->privateKeyFile()));
        
        _passphraseBox = new QLineEdit(QtUtils::toQString(info->passphrase()));
        _passphraseBox->setEchoMode(QLineEdit::Password);
        _passphraseEchoModeButton = new QPushButton;
        VERIFY(connect(_passphraseEchoModeButton, SIGNAL(clicked()), this, SLOT(togglePassphraseEchoMode())));
        togglePassphraseEchoMode();

        _passwordLabel = new QLabel("User Password:"******"Private key:");
        _sshPassphraseLabel = new QLabel("Passphrase:");
        _sshAddressLabel = new QLabel("SSH Address:");
        _sshUserNameLabel = new QLabel("SSH User Name:");
        _sshAuthMethodLabel = new QLabel("SSH Auth Method:");

/*
// Commented because of this:
// https://github.com/paralect/robomongo/issues/391

#ifdef Q_OS_WIN
        QRegExp pathx("([a-zA-Z]:)?([\\\\/][a-zA-Z0-9_.-]+)+[\\\\/]?");
#else
        QRegExp pathx("^\\/?([\\d\\w\\.]+)(/([\\d\\w\\.]+))*\\/?$");
#endif // Q_OS_WIN
        _publicKeyBox->setValidator(new QRegExpValidator(pathx, this));
        _privateKeyBox->setValidator(new QRegExpValidator(pathx, this));
*/

        QHBoxLayout *hostAndPasswordLayout = new QHBoxLayout;
        hostAndPasswordLayout->addWidget(_sshHostName);
        hostAndPasswordLayout->addWidget(new QLabel(":"));
        hostAndPasswordLayout->addWidget(_sshPort);

        QGridLayout *connectionLayout = new QGridLayout;
        connectionLayout->setAlignment(Qt::AlignTop);
        connectionLayout->setColumnStretch(1, 1);
        connectionLayout->setColumnMinimumWidth(0, _passwordLabel->sizeHint().width() + 5);

        connectionLayout->addWidget(_sshAddressLabel ,             1, 0);
        connectionLayout->addLayout(hostAndPasswordLayout,         1, 1, 1, 2);

        connectionLayout->addWidget(_sshUserNameLabel,             2, 0);
        connectionLayout->addWidget(_userName,                     2, 1, 1, 2);

        connectionLayout->addWidget(_sshAuthMethodLabel,           4, 0);
        connectionLayout->addWidget(_security,                     4, 1, 1, 2);

        connectionLayout->addWidget(_passwordLabel,                5, 0);
        connectionLayout->addWidget(_passwordBox,                  5, 1);
        connectionLayout->addWidget(_passwordEchoModeButton,       5, 2);

        _selectPrivateFileButton = new QPushButton("...");
        _selectPrivateFileButton->setMaximumWidth(50);

        connectionLayout->addWidget(_sshPrivateKeyLabel,           7, 0);
        connectionLayout->addWidget(_privateKeyBox,                7, 1);
        connectionLayout->addWidget(_selectPrivateFileButton,      7, 2);

        connectionLayout->addWidget(_sshPassphraseLabel,           8, 0);
        connectionLayout->addWidget(_passphraseBox,                8, 1);
        connectionLayout->addWidget(_passphraseEchoModeButton,     8, 2);
        connectionLayout->addWidget(_askForPassword,               9, 1, 1, 2);

        QVBoxLayout *mainLayout = new QVBoxLayout;
        mainLayout->addWidget(_sshSupport);
        mainLayout->addLayout(connectionLayout);
        setLayout(mainLayout);

        if (info->authMethod() == "publickey") {
            utils::setCurrentText(_security, "Private Key");
        } else {
            utils::setCurrentText(_security, "Password");
        }

        securityChange(_security->currentText());
        VERIFY(connect(_selectPrivateFileButton, SIGNAL(clicked()), this, SLOT(setPrivateFile())));

        sshSupportStateChange(_sshSupport->checkState());
        VERIFY(connect(_sshSupport, SIGNAL(stateChanged(int)), this, SLOT(sshSupportStateChange(int))));

        _sshHostName->setFocus();

#ifdef Q_OS_MAC
        _passwordEchoModeButton->setMaximumWidth(_selectPrivateFileButton->width());
        _passphraseEchoModeButton->setMaximumWidth(_selectPrivateFileButton->width());
#else
        _passwordEchoModeButton->setMinimumWidth(_selectPrivateFileButton->width());
        _passphraseEchoModeButton->setMinimumWidth(_selectPrivateFileButton->width());
#endif
        // Attempt to fix the issue for Windows High DPI button height is slightly taller than other widgets 
#ifdef Q_OS_WIN
        _passwordEchoModeButton->setMaximumHeight(HighDpiContants::WIN_HIGH_DPI_BUTTON_HEIGHT);
        _passphraseEchoModeButton->setMaximumHeight(HighDpiContants::WIN_HIGH_DPI_BUTTON_HEIGHT);
        _selectPrivateFileButton->setMaximumHeight(HighDpiContants::WIN_HIGH_DPI_BUTTON_HEIGHT);
#endif

    }