Пример #1
0
KWMailMergeVariableInsertDia::KWMailMergeVariableInsertDia( QWidget *parent, KWMailMergeDataBase *db )
  : KDialogBase( Plain, i18n( "Mail Merge - Variable Name" ),
                 Ok | Cancel, Ok, parent, "", true )
{
  m_db=db;
  QWidget *page = plainPage();

  QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() );
  layout->setAutoAdd( true );

  QLabel *l = new QLabel( i18n( "Name:" ), page );
  l->setMaximumHeight( l->sizeHint().height() );
  names = new QListBox( page );

  QMap< QString, QString >::ConstIterator it = db->getRecordEntries().begin();
  for ( ; it != db->getRecordEntries().end(); ++it )
    names->insertItem( m_db->version() ?it.data():it.key(), -1 );

  setInitialSize( QSize( 350, 400 ) );
  connect( names, SIGNAL( selectionChanged() ),
           this, SLOT( slotSelectionChanged() ) );
  connect( names, SIGNAL( doubleClicked( QListBoxItem* ) ),
           this, SLOT( slotOk() ) );

  setFocus();
  enableButtonOK( names->currentItem() != -1 );
}
Пример #2
0
void MessageWidget::showTagLabels()
{
	clearTagLabels();

	if (currMsgId.empty()) {
		return;
	}

	MsgTagInfo tagInfo;
	rsMail->getMessageTag(currMsgId, tagInfo);

	if (tagInfo.tagIds.empty() == false) {
		ui.tagsLabel->setVisible(true);

		MsgTagType Tags;
		rsMail->getMessageTagTypes(Tags);

		std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
		for (std::list<uint32_t>::iterator tagId = tagInfo.tagIds.begin(); tagId != tagInfo.tagIds.end(); ++tagId) {
			Tag = Tags.types.find(*tagId);
			if (Tag != Tags.types.end()) {
				QLabel *tagLabel = new QLabel(TagDefs::name(Tag->first, Tag->second.first), this);
				tagLabel->setMaximumHeight(16);
				tagLabel->setStyleSheet(TagDefs::labelStyleSheet(Tag->second.second));
				tagLabels.push_back(tagLabel);
				ui.tagLayout->addWidget(tagLabel);
				ui.tagLayout->addSpacing(3);
			}
		}
		ui.tagLayout->addStretch();
	} else {
		ui.tagsLabel->setVisible(false);
	}
}
Пример #3
0
void MainWindow ::retrievElements(QDomElement root, QString tag, QString att)
{
    QDomNodeList nodes = root.elementsByTagName(tag);

    QGridLayout *layout = new QGridLayout (this);


    qDebug() << "# nodes = " << nodes.count();
    for(int i = 0; i < nodes.count(); i++)
    {
        QDomNode elm = nodes.at(i);
        if(elm.isElement())
        {
            QDomElement e = elm.toElement();
            QStringList allAttrs = att.split("+");
            for(int k=0;k<allAttrs.length();k++)
            {
                qDebug() << e.attribute(allAttrs[k]);
                QLabel *l = new QLabel(this);
                l->setText(e.attribute(allAttrs[k]));
                l->setStyleSheet("QLabel {color : blue; }");
                QFont f( "Arial", 10, QFont::Bold);
                l->setGeometry(0,0,500,60);
                l->setFont(f);
                l->setMaximumHeight(50);
                layout->addWidget(l,i,k);

            }
        }
    }
    show();
}
Пример #4
0
void LyricWidget::setLyric(const QLyricList &lyric) {
    if (animWidget) delete animWidget;
    animWidget = new QWidget(this);
    animWidget->raise();
    ui->border->raise();
    QRect geo = this->geometry();
    animWidget->setMinimumWidth(geo.width());
    animWidget->setMaximumWidth(geo.width());
    animWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    QVBoxLayout *vbox = new QVBoxLayout(animWidget);
    vbox->setMargin(0);
    vbox->setSpacing(0);
    vbox->setContentsMargins(0, 0, 0, 0);
    animWidget->setLayout(vbox);

    labels.clear();
    curInd = 0;
    this->lyric = lyric;
    firstShowing = false;

    int widgetWidth = this->geometry().width();
    int accuHeight = 0;
    for (const QLyric& lyr : lyric) {
        QLabel *label = new QLabel(animWidget);
        QFont font("文泉驿微米黑", 11);
        font.setStyleStrategy(QFont::PreferAntialias);
        label->setFont(font);
        label->setText(QString("<font color='grey'>") +
                        lyr.lyric + QString("</font>"));
        label->setMaximumWidth(widgetWidth);
        label->setMaximumWidth(widgetWidth);
        label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        label->setWordWrap(true);
        labels.append(label);
        QRect fsize = label->fontMetrics().boundingRect(label->text());
        int height = (widgetWidth + fsize.width()) / widgetWidth * fsize.height() + 15;
        heights.append(height);
        label->setMinimumHeight(height);
        label->setMaximumHeight(height);
        accuHeight += height;

        animWidget->layout()->addWidget(label);
    }

    if (heights.size() > 0) {
        animWidget->setGeometry(0, this->geometry().height() / 2 + heights[0],
                                this->geometry().width(), accuHeight);
    }
    animWidget->show();
    ui->border->setText("");
}
Пример #5
0
void DetailWindow::blankKeyLabel(){
  deleteKeyLabels();
  QLabel* dummyLabel = new QLabel();
  QPalette pal = dummyLabel->palette();
  pal.setColor(backgroundRole(), Qt::black);
  dummyLabel->setPalette(pal);
  dummyLabel->setAutoFillBackground(true);
  dummyLabel->setMinimumHeight(20);
  dummyLabel->setMaximumHeight(30);
  dummyLabel->setToolTip(wrapToolTip(tr("Drag an audio file onto the window.")));
  ui->horizontalLayout_keyLabels->addWidget(dummyLabel);
  keyLabels.push_back(dummyLabel);
}
Пример #6
0
XmlWindow::XmlWindow(QWidget *parent) : QWidget(parent){

    QFont font;
    font.setFamily("Courier");
    font.setFixedPitch(true);
    font.setPointSize(11);
    font.setBold(true);

    setNulls();

    //Used to avoid loading simulation again when this caused the initial change
    during_update_of_schema = false;

    textEdit = new CodeEditor(this);
    textEdit->setFont(font);
    textEdit->setWordWrapMode( QTextOption::NoWrap );


    QLabel *aa = new QLabel(this);
    aa->setText("");
    aa->setMinimumHeight(37);
    aa->setMaximumHeight(37);
    toolBar = new QToolBar("File/edit", aa);//addToolBar(tr("File"));

    layout = new QVBoxLayout(this);
    layout->setContentsMargins(QMargins(0,0,0,0));
    layout->addWidget(aa);
    layout->addWidget(textEdit);
    this->setLayout(layout);

    highlighter = new XMLHighlighter(textEdit->document());

    createActions();
    createMenus();
    createToolBars();
    createStatusBar();

    readSettings();

    connect(textEdit->document(), SIGNAL(contentsChanged()),
            this, SLOT(documentWasModified()));

    setCurrentFile("");
    //setUnifiedTitleAndToolBarOnMac(true);
}
Пример #7
0
DateTimeDialog::DateTimeDialog(QWidget *parent) :
        QDialog(parent)
{
    QPalette pal = this->palette();
    pal.setColor(QPalette::Window, "#D0D0E7");

    setPalette(pal);

    setWindowTitle(QString::fromLocal8Bit("Změna času fotografií"));
    setLayout(new QVBoxLayout);

    QGroupBox *gBox = new QGroupBox;
    gBox->setLayout(new QVBoxLayout);
    rAll = new QRadioButton(tr("All pictures"));
    rAll->setChecked(true);
    rSelected = new QRadioButton(tr("Selected pictures"));
    gBox->setContentsMargins(QMargins(0,0,0,0));
    gBox->layout()->addWidget(rAll);
    gBox->layout()->addWidget(rSelected);

    QLabel *l = new QLabel;
    l->setAutoFillBackground(true);
    l->setBackgroundRole(QPalette::Light);
    l->setMaximumHeight(1);

    QDialogButtonBox *buttonBox = new QDialogButtonBox;//(QDialogButtonBox::Apply & QDialogButtonBox::Cancel);
    buttonBox->addButton(QDialogButtonBox::Cancel);
    buttonBox->addButton(QDialogButtonBox::Ok); //Apply

    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));


    this->layout()->addWidget(gBox);
    this->layout()->addWidget(l);
    this->layout()->addWidget(buttonBox);
}
Пример #8
0
// ---- initSettings ----------------------------------------------------------
QWidget *Configuration::initSettings(Cfg &cfg)
{
    QWidget *control = new QWidget( _mainWidget );

    QFontMetrics fm = fontMetrics();
	int fh = fm.height();

    QVBoxLayout *vb = new QVBoxLayout( control );

	QScrollView *sv = new QScrollView( control );
	vb->addWidget( sv, 0, 0 );
	sv->setResizePolicy( QScrollView::AutoOneFit );
	sv->setFrameStyle( QFrame::NoFrame );

	QWidget *container = new QWidget( sv->viewport() );
	sv->addChild( container );

	QGridLayout *layout = new QGridLayout( container );
	layout->setSpacing( 4 );
	layout->setMargin( 4 );

	QLabel *label = new QLabel( tr( "Enter currency symbol:" ), container );
	QWhatsThis::add( label, tr( "Enter your local currency symbol here." ) );
	label->setMaximumHeight( fh + 3 );
	layout->addWidget( label, 0, 0 );

	symbolEdit = new QLineEdit( cfg.getCurrencySymbol(), container );
	QWhatsThis::add( symbolEdit, tr( "Enter your local currency symbol here." ) );
	symbolEdit->setMaximumHeight( fh + 5 );
	symbolEdit->setFocus();
    layout->addWidget( symbolEdit, 0, 1 );

	lockCB = new QCheckBox( tr( "Show whether checkbook is password\nprotected" ), container );
	QWhatsThis::add( lockCB, tr( "Click here to select whether or not the main window will display that the checkbook is protected with a password." ) );
	lockCB->setChecked( cfg.getShowLocks() );
	layout->addMultiCellWidget( lockCB, 1, 1, 0, 1 );

	balCB = new QCheckBox( tr( "Show checkbook balances" ), container );
	QWhatsThis::add( balCB, tr( "Click here to select whether or not the main window will display the current balance for each checkbook." ) );
	balCB->setMaximumHeight( fh + 5 );
	balCB->setChecked( cfg.getShowBalances() );
	layout->addMultiCellWidget( balCB, 2, 2, 0, 1 );

    openLastBookCB = new QCheckBox( tr("Open last checkbook" ), container );
    QWhatsThis::add( openLastBookCB, tr("Click here to select whether the last open checkbook will be opened at startup.") );
    openLastBookCB->setMaximumHeight(fh+5);
    openLastBookCB->setChecked( cfg.isOpenLastBook() );
    layout->addMultiCellWidget( openLastBookCB, 3, 3, 0, 1 );

    lastTabCB = new QCheckBox( tr("Show last checkbook tab" ), container );
    QWhatsThis::add( lastTabCB, tr("Click here to select whether the last tab in a checkbook should be displayed.") );
    lastTabCB->setMaximumHeight(fh+5);
    lastTabCB->setChecked( cfg.isShowLastTab() );
    layout->addMultiCellWidget( lastTabCB, 4, 4, 0, 1 );

    savePayees = new QCheckBox( tr("Save new description as payee"), container );
    QWhatsThis::add( savePayees, tr("Click here to save new descriptions in the list of payess.") );
    savePayees->setMaximumHeight(fh+5);
    savePayees->setChecked( cfg.getSavePayees() );
    layout->addMultiCellWidget( savePayees, 5, 5, 0, 1 );

	smallFontCB = new QCheckBox( tr( "Use smaller font for list" ), container );
	QWhatsThis::add( smallFontCB, tr( "Click here to select smaller font for transactions." ) );
	smallFontCB->setChecked( cfg.getUseSmallFont() );
	layout->addMultiCellWidget( smallFontCB, 6, 6, 0, 1 );

    return(control);
}
Пример #9
0
MintingView::MintingView(QWidget *parent) :
    QWidget(parent), model(0), mintingView(0)
{
    QHBoxLayout *hlayout = new QHBoxLayout();
    hlayout->setContentsMargins(0,0,0,0);

    QString legendBoxStyle = "background-color: rgb(%1,%2,%3); border: 1px solid black;";

    QLabel *youngColor = new QLabel(" ");
    youngColor->setMaximumHeight(15);
    youngColor->setMaximumWidth(10);
    youngColor->setStyleSheet(legendBoxStyle.arg(COLOR_MINT_YOUNG.red()).arg(COLOR_MINT_YOUNG.green()).arg(COLOR_MINT_YOUNG.blue()));
    QLabel *youngLegend = new QLabel(tr("transaction is too young"));
    youngLegend->setContentsMargins(5,0,15,0);

    QLabel *matureColor = new QLabel(" ");
    matureColor->setMaximumHeight(15);
    matureColor->setMaximumWidth(10);
    matureColor->setStyleSheet(legendBoxStyle.arg(COLOR_MINT_MATURE.red()).arg(COLOR_MINT_MATURE.green()).arg(COLOR_MINT_MATURE.blue()));
    QLabel *matureLegend = new QLabel(tr("transaction is mature"));
    matureLegend->setContentsMargins(5,0,15,0);

    QLabel *oldColor = new QLabel(" ");
    oldColor->setMaximumHeight(15);
    oldColor->setMaximumWidth(10);
    oldColor->setStyleSheet(legendBoxStyle.arg(COLOR_MINT_OLD.red()).arg(COLOR_MINT_OLD.green()).arg(COLOR_MINT_OLD.blue()));
    QLabel *oldLegend = new QLabel(tr("transaction has reached maximum probability"));
    oldLegend->setContentsMargins(5,0,15,0);

    QHBoxLayout *legendLayout = new QHBoxLayout();
    legendLayout->setContentsMargins(10,10,0,0);
    legendLayout->addWidget(youngColor);
    legendLayout->addWidget(youngLegend);
    legendLayout->addWidget(matureColor);
    legendLayout->addWidget(matureLegend);
    legendLayout->addWidget(oldColor);
    legendLayout->addWidget(oldLegend);
    legendLayout->insertStretch(-1);
	
	QLabel *label1 = new QLabel(this);
	label1->setText("Staking Estimations");
	label1->setAlignment(Qt::AlignLeft);
	QFont font( "Arial", 16, QFont::Bold);
	label1->setFont(font);
	label1->setFixedWidth(250);
	
	QLabel *mintingLabel = new QLabel(tr("Check the arrow icon below for more staking information. *BETA*"));

    QLabel *mintingLabel2 = new QLabel(tr(" [Display staking probability within]: "));
    mintingCombo = new QComboBox();
    mintingCombo->addItem(tr("10 min"), Minting10min);
    mintingCombo->addItem(tr("24 hours"), Minting1day);
    mintingCombo->addItem(tr("7 days"), Minting7days);
    mintingCombo->addItem(tr("30 days"), Minting30days);
    mintingCombo->addItem(tr("60 days"), Minting60days);
    mintingCombo->addItem(tr("90 days"), Minting90days);
    mintingCombo->setFixedWidth(120);

    hlayout->insertStretch(0);
    hlayout->addWidget(mintingLabel);
	hlayout->addWidget(mintingLabel2);
    hlayout->addWidget(mintingCombo);

    QVBoxLayout *vlayout = new QVBoxLayout(this);
    vlayout->setContentsMargins(0,0,0,0);
    vlayout->setSpacing(0);

    QTableView *view = new QTableView(this);
    vlayout->addLayout(hlayout);
    vlayout->addWidget(view);
    vlayout->addLayout(legendLayout);

    vlayout->setSpacing(0);
    int width = view->verticalScrollBar()->sizeHint().width();
    // Cover scroll bar width with spacing
#ifdef Q_WS_MAC
    hlayout->addSpacing(width+2);
#else
    hlayout->addSpacing(width);
#endif
    // Always show scroll bar
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    view->setTabKeyNavigation(false);
    view->setContextMenuPolicy(Qt::CustomContextMenu);

    mintingView = view;

    connect(mintingCombo, SIGNAL(activated(int)), this, SLOT(chooseMintingInterval(int)));

    // Actions
    QAction *copyTxIDAction = new QAction(tr("Copy transaction ID of input"), this);
    QAction *copyAddressAction = new QAction(tr("Copy address of input"), this);
    QAction *showHideAddressAction = new QAction(tr("Show/hide 'Address' column"), this);
    QAction *showHideTxIDAction = new QAction(tr("Show/hide 'Transaction' column"), this);

    contextMenu = new QMenu();
    contextMenu->addAction(copyAddressAction);
    contextMenu->addAction(copyTxIDAction);
    contextMenu->addAction(showHideAddressAction);
    contextMenu->addAction(showHideTxIDAction);

    connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress()));
    connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID()));
    connect(showHideAddressAction, SIGNAL(triggered()), this, SLOT(showHideAddress()));
    connect(showHideTxIDAction, SIGNAL(triggered()), this, SLOT(showHideTxID()));

    connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
}
Пример #10
0
tSonarTestDigital::tSonarTestDigital( tHAL& hal, tSonarMaster& SonarMaster, tSonarClient& SonarClient,
                                      tSonarSettings& SonarSettings,  QWidget* p ) :
    tTestModule( p, "Sonar Test, Digital" )
    , m_HAL( hal )
    , m_SonarMaster( SonarMaster )
    , m_SonarClient( SonarClient )
    , m_SonarSettings( SonarSettings )
{
    m_Depth = 0.0f;
    m_Temp = 0.0f;
    m_WaterSpeed = 0.0f;
    m_Voltage = 0.0f;
    m_DepthValid = false;
    m_TempValid = false;
    m_WaterSpeedValid = false;
    m_VoltageValid = false;

    m_pLayout = new QGridLayout();

    m_pDigitalDepth = new QLineEdit( QString( "----" ) );
    m_pTemp1 = new QLineEdit( QString( "----" ) );
    m_pWaterSpeed = new QLineEdit( QString( "----" ) );
    m_pVoltage = new QLineEdit( QString( "----" ) );
    m_pDigitalDepth->setFocusPolicy( Qt::NoFocus );
    m_pTemp1->setFocusPolicy( Qt::NoFocus );
    m_pWaterSpeed->setFocusPolicy( Qt::NoFocus );
    m_pVoltage->setFocusPolicy( Qt::NoFocus );

    QString toggleBtnStr = m_HAL.PlatformId() == ePlatformStingray2 ? "Power" : "Down Arrow";
    QLabel* pLabelInstructions = new QLabel( QString( "Enter to start test\n" + toggleBtnStr + " to toggle temperature" ) );
    long fontheight = QFontMetrics( pLabelInstructions->font() ).height();
    pLabelInstructions->setMaximumHeight( fontheight * 4 );

    QLabel* pLabelDigitalDepth = new QLabel( QString( "Digital Depth (49ft to 51ft)" ) );
    m_pLabelTemp1 = new QLabel( QString( "Temp 1 (9 F to 11 F)" ) );
    //    QLabel* pLabelTemp2 = new QLabel(QString("Temp 2:"));
    QLabel* pLabelWaterSpeed = new QLabel( QString( "Water speed (59mph to 61mph)" ) );
    QLabel* pLabelVoltage = new QLabel( QString( "Voltage (12.85V to 14.15V)" ) );

    //
    m_pLayout->addWidget( pLabelInstructions, 0, 0 );

    m_pLayout->addWidget( pLabelDigitalDepth, 1, 0 );
    m_pLayout->addWidget( m_pDigitalDepth, 1, 1 );

    m_pLayout->addWidget( m_pLabelTemp1, 3, 0 );
    m_pLayout->addWidget( m_pTemp1, 3, 1 );

    m_pLayout->addWidget( pLabelWaterSpeed, 5, 0 );
    m_pLayout->addWidget( m_pWaterSpeed, 5, 1 );

    m_pLayout->addWidget( pLabelVoltage, 7, 0 );
    m_pLayout->addWidget( m_pVoltage, 7, 1 );

    setLayout( m_pLayout );

    Connect( &m_SonarClient, SIGNAL( NewDepth( float, bool, float, bool ) ), this, SLOT( NewDepth( float, bool, float, bool ) ) );

#if defined(_WIN32)  //Only turn this on for debugging, not on a real unit
    Connect( &m_SonarSettings, SIGNAL( NewTemperature( float, bool, bool, SonarCommon::eWaterTemperatureInstance ) ), this, SLOT( NewTemperature( float, bool ) ) );
    Connect( &m_SonarSettings, SIGNAL( NewSpeed( float, bool, bool ) ), this, SLOT( NewSpeed( float, bool ) ) );
#endif

    Connect( &m_SonarMaster, SIGNAL( NewTemperature( float, bool, SonarCommon::eWaterTemperatureInstance ) ), this, SLOT( NewTemperature( float, bool ) ) );
    Connect( &m_SonarMaster, SIGNAL( NewSpeed( float, bool ) ), this, SLOT( NewSpeed( float, bool ) ) );

    m_ShowError = false;

    m_TimerCount = 0;

    m_TempTestIndex = 0;

    startTimer( 100 );
}
QWidget* ExtensionDialog::CreateWidget( extension_widget_t *p_widget )
{
    QLabel *label = NULL;
    QPushButton *button = NULL;
    QTextBrowser *textArea = NULL;
    QLineEdit *textInput = NULL;
    QCheckBox *checkBox = NULL;
    QComboBox *comboBox = NULL;
    QListWidget *list = NULL;
    SpinningIcon *spinIcon = NULL;
    struct /*extension_widget_t::*/extension_widget_value_t *p_value = NULL;			// sunqueen modify

    assert( p_widget->p_sys_intf == NULL );

    switch( p_widget->type )
    {
        case EXTENSION_WIDGET_LABEL:
            label = new QLabel( qfu( p_widget->psz_text ), this );
            p_widget->p_sys_intf = label;
            label->setTextFormat( Qt::RichText );
            label->setOpenExternalLinks( true );
            return label;

        case EXTENSION_WIDGET_BUTTON:
            button = new QPushButton( qfu( p_widget->psz_text ), this );
            clickMapper->setMapping( button, new WidgetMapper( p_widget ) );
            CONNECT( button, clicked(), clickMapper, map() );
            p_widget->p_sys_intf = button;
            return button;

        case EXTENSION_WIDGET_IMAGE:
            label = new QLabel( this );
            label->setPixmap( QPixmap( qfu( p_widget->psz_text ) ) );
            if( p_widget->i_width > 0 )
                label->setMaximumWidth( p_widget->i_width );
            if( p_widget->i_height > 0 )
                label->setMaximumHeight( p_widget->i_height );
            label->setScaledContents( true );
            p_widget->p_sys_intf = label;
            return label;

        case EXTENSION_WIDGET_HTML:
            textArea = new QTextBrowser( this );
            textArea->setOpenExternalLinks( true );
            textArea->setHtml( qfu( p_widget->psz_text ) );
            p_widget->p_sys_intf = textArea;
            return textArea;

        case EXTENSION_WIDGET_TEXT_FIELD:
            textInput = new QLineEdit( this );
            textInput->setText( qfu( p_widget->psz_text ) );
            textInput->setReadOnly( false );
            textInput->setEchoMode( QLineEdit::Normal );
            inputMapper->setMapping( textInput, new WidgetMapper( p_widget ) );
            /// @note: maybe it would be wiser to use textEdited here?
            CONNECT( textInput, textChanged(const QString &),
                     inputMapper, map() );
            p_widget->p_sys_intf = textInput;
            return textInput;

        case EXTENSION_WIDGET_PASSWORD:
            textInput = new QLineEdit( this );
            textInput->setText( qfu( p_widget->psz_text ) );
            textInput->setReadOnly( false );
            textInput->setEchoMode( QLineEdit::Password );
            inputMapper->setMapping( textInput, new WidgetMapper( p_widget ) );
            /// @note: maybe it would be wiser to use textEdited here?
            CONNECT( textInput, textChanged(const QString &),
                     inputMapper, map() );
            p_widget->p_sys_intf = textInput;
            return textInput;

        case EXTENSION_WIDGET_CHECK_BOX:
            checkBox = new QCheckBox( this );
            checkBox->setText( qfu( p_widget->psz_text ) );
            checkBox->setChecked( p_widget->b_checked );
            clickMapper->setMapping( checkBox, new WidgetMapper( p_widget ) );
            CONNECT( checkBox, stateChanged( int ), clickMapper, map() );
            p_widget->p_sys_intf = checkBox;
            return checkBox;

        case EXTENSION_WIDGET_DROPDOWN:
            comboBox = new QComboBox( this );
            comboBox->setEditable( false );
            for( p_value = p_widget->p_values;
                 p_value != NULL;
                 p_value = p_value->p_next )
            {
                comboBox->addItem( qfu( p_value->psz_text ), p_value->i_id );
            }
            /* Set current item */
            if( p_widget->psz_text )
            {
                int idx = comboBox->findText( qfu( p_widget->psz_text ) );
                if( idx >= 0 )
                    comboBox->setCurrentIndex( idx );
            }
            selectMapper->setMapping( comboBox, new WidgetMapper( p_widget ) );
            CONNECT( comboBox, currentIndexChanged( const QString& ),
                     selectMapper, map() );
            return comboBox;

        case EXTENSION_WIDGET_LIST:
            list = new QListWidget( this );
            list->setSelectionMode( QAbstractItemView::ExtendedSelection );
            for( p_value = p_widget->p_values;
                 p_value != NULL;
                 p_value = p_value->p_next )
            {
                QListWidgetItem *item =
                    new QListWidgetItem( qfu( p_value->psz_text ) );
                item->setData( Qt::UserRole, p_value->i_id );
                list->addItem( item );
            }
            selectMapper->setMapping( list, new WidgetMapper( p_widget ) );
            CONNECT( list, itemSelectionChanged(),
                     selectMapper, map() );
            return list;

        case EXTENSION_WIDGET_SPIN_ICON:
            spinIcon = new SpinningIcon( this );
            spinIcon->play( p_widget->i_spin_loops );
            p_widget->p_sys_intf = spinIcon;
            return spinIcon;

        default:
            msg_Err( p_intf, "Widget type %d unknown", p_widget->type );
            return NULL;
    }
}
Пример #12
0
Info::Info(QWidget *parent)
    : QWidget(parent)
{
    QString problemFormulation, about;
    problemFormulation =
        QString("A number N of spies have a number N of\n")+
        QString("parts of the key, which is an ordered\n")+
        QString("set of numbers: spy №1 has the first\n")+
        QString("element of the set, spy №2 has the\n")+
        QString("second, etc. These spies can answer\n")+
        QString("questions like, \"Do you know the key?\"\n")+
        QString("or \"Does №k know the key? \", the\n")+
        QString("answer to which can only be \"yes\" or\n")+
        QString("\"no\".\n\n")+
        QString("Input of the program includes a set\n")+
        QString("of keys, among which is the desired\n")+
        QString("key. The program must ask questions\n")+
        QString("to spies (specifying the type of the\n")+
        QString("question and the spy who was asked)\n")+
        QString("to as long as one of the spies will\n")+
        QString("not be able to name the key.");

    about =
        QString("This application is developed by Ugarov\n")+
        QString("Anton as an alternative exam in discrete\n")+
        QString("mathematics. The program is developed\n")+
        QString("using Qt.\n\n")+
        QString("Email: [email protected]\n\n")+
        QString("2016 ETU \"LETI\"");

    QString *tipTexts = new QString[N_TIPS];
    tipTexts[0] =
        QString("First of all, You need to enter keys\n")+
        QString("into the right input box, one per\n")+
        QString("line. The key is to consist of the\n")+
        QString("natural numbers. Numbers less than\n")+
        QString("or equal to zero and the other\n")+
        QString("characters will be ignored. The keys\n")+
        QString("must be the same length. The extra\n")+
        QString("part will be ignored. You need to\n")+
        QString("enter a valid key in the first line.\n")+
        QString("An example of a correct entry can be\n")+
        QString("seen in the input box.");

    tipTexts[1] =
        QString("Then just click on the start button!\n")+
        QString("After that the program will compute\n")+
        QString("questions and answers and display them\n")+
        QString("in the left output box.");

    tipTexts[2] =
        QString("If you click on the fields with question\n")+
        QString("then you will be able to see the\n")+
        QString("consequences of response.\n");

    QPixmap *images = new QPixmap[N_TIPS];
    images[0].load(":/img/tip1.png");
    images[1].load(":/img/tip2.png");
    images[2].load(":/img/tip3.png");

    QLabel *aboutName = new QLabel("About");
    aboutName->setAlignment(Qt::AlignHCenter);
    aboutName->setMaximumHeight(30);
    aboutName->setStyleSheet("font-size: 20px;");
    about_ = new QLabel;
    about_->setText(about);

    QLabel *problemFormulationName = new QLabel("Formulation of the problem");
    problemFormulationName->setAlignment(Qt::AlignHCenter);
    problemFormulationName->setMaximumHeight(30);
    problemFormulationName->setStyleSheet("font-size: 20px");
    problemFormulation_ = new QLabel;
    problemFormulation_->setText(problemFormulation);

    QFrame *horizontalLine = new QFrame;
    horizontalLine->setFrameShape(QFrame::HLine);
    horizontalLine->setFrameShadow(QFrame::Sunken);

    leftLayout_ = new QVBoxLayout;
    leftLayout_->addWidget(problemFormulationName);
    leftLayout_->addWidget(problemFormulation_);
    leftLayout_->addWidget(horizontalLine);
    leftLayout_->addWidget(aboutName);
    leftLayout_->addWidget(about_);
    leftLayout_->setAlignment(Qt::AlignTop);

    QLabel *tipsName = new QLabel("Tips");
    tipsName->setAlignment(Qt::AlignHCenter);
    tipsName->setMaximumHeight(30);
    tipsName->setStyleSheet("font-size: 20px");
    tipsLayout_ = new QVBoxLayout;
    tipsLayout_->addWidget(tipsName);
    tips_ = new QHBoxLayout*[N_TIPS];
    tipLabels_ = new QLabel*[N_TIPS];
    tipImages_ = new QLabel*[N_TIPS];
    for(int i = 0; i < N_TIPS; i++)
    {
        tipLabels_[i] = new QLabel;
        tipLabels_[i]->setText(tipTexts[i]);
        tipLabels_[i]->setAlignment(Qt::AlignVCenter);

        tipImages_[i] = new QLabel;
        tipImages_[i]->setPixmap(images[i]);

        tips_[i] = new QHBoxLayout;
        if(i%2 == 0)
        {
            tips_[i]->addWidget(tipLabels_[i]);
            tips_[i]->addWidget(tipImages_[i]);
        }
        else
        {
            tips_[i]->addWidget(tipImages_[i]);
            tips_[i]->addWidget(tipLabels_[i]);
        }
        tipsLayout_->addLayout(tips_[i]);
    }

    QFrame* verticalLine = new QFrame;
    verticalLine->setFrameShape(QFrame::VLine);
    verticalLine->setFrameShadow(QFrame::Sunken);

    mainLayout_ = new QHBoxLayout;
    mainLayout_->addLayout(leftLayout_);
    mainLayout_->addWidget(verticalLine);
    mainLayout_->addLayout(tipsLayout_);

    setStyleSheet("background-color : white;");
    setLayout(mainLayout_);
    setWindowIcon(QIcon(":/img/logo.png"));
    setWindowTitle("Information");
    setMaximumHeight(300);
    setMaximumWidth(500);
}
Пример #13
0
  QWidget* AutoRotateTool::settingsWidget() {
    if(!m_settingsWidget) {
      m_settingsWidget = new QWidget;

      // Label and slider to set x axis rotation
      QLabel* labelX = new QLabel(tr("x rotation:"));
      labelX->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
      labelX->setMaximumHeight(15);
      m_sliderX = new QSlider(m_settingsWidget);
      m_sliderX->setOrientation(Qt::Horizontal);
      m_sliderX->setTickPosition(QSlider::TicksAbove);
      m_sliderX->setToolTip(tr("x rotation"));
      m_sliderX->setTickInterval(m_maxRotation);
      m_sliderX->setPageStep(5);
      m_sliderX->setRange(-m_maxRotation, m_maxRotation);
      m_sliderX->setValue(0);
      QHBoxLayout* xLayout = new QHBoxLayout;
      xLayout->addWidget(labelX);
      xLayout->addWidget(m_sliderX);

      // Label and slider to set y axis rotation
      QLabel* labelY = new QLabel(tr("y rotation:"));
      labelY->setMaximumHeight(15);
      m_sliderY = new QSlider(m_settingsWidget);
      m_sliderY->setOrientation(Qt::Horizontal);
      m_sliderY->setTickPosition(QSlider::TicksAbove);
      m_sliderY->setToolTip(tr("y rotation"));
      m_sliderY->setTickInterval(m_maxRotation);
      m_sliderY->setPageStep(5);
      m_sliderY->setRange(-m_maxRotation, m_maxRotation);
      m_sliderY->setValue(0);
      QHBoxLayout* yLayout = new QHBoxLayout;
      yLayout->addWidget(labelY);
      yLayout->addWidget(m_sliderY);

      // Label and slider to set z axis rotation
      QLabel* labelZ = new QLabel(tr("z rotation:"));
      labelZ->setMaximumHeight(15);
      m_sliderZ = new QSlider(m_settingsWidget);
      m_sliderZ->setOrientation(Qt::Horizontal);
      m_sliderZ->setTickPosition(QSlider::TicksAbove);
      m_sliderZ->setToolTip(tr("z rotation"));
      m_sliderZ->setTickInterval(m_maxRotation);
      m_sliderZ->setPageStep(5);
      m_sliderZ->setRange(-m_maxRotation, m_maxRotation);
      m_sliderZ->setValue(0);
      QHBoxLayout* zLayout = new QHBoxLayout;
      zLayout->addWidget(labelZ);
      zLayout->addWidget(m_sliderZ);

      // Push buttons to start/stop and to reset
      m_buttonStartStop = new QPushButton(tr("Start"), m_settingsWidget);
      QPushButton* buttonReset = new QPushButton(tr("Reset"), m_settingsWidget);
      QHBoxLayout* buttonLayout = new QHBoxLayout();
      buttonLayout->addWidget(m_buttonStartStop);
      buttonLayout->addWidget(buttonReset);

      QVBoxLayout* layout = new QVBoxLayout();
      layout->addLayout(xLayout);
      layout->addLayout(yLayout);
      layout->addLayout(zLayout);
      layout->addLayout(buttonLayout);
      layout->addStretch(1);
      m_settingsWidget->setLayout(layout);

      // Connect the sliders with the slots
      connect(m_sliderX, SIGNAL(valueChanged(int)),
          this, SLOT(setXRotation(int)));

      connect(m_sliderY, SIGNAL(valueChanged(int)),
          this, SLOT(setYRotation(int)));

      connect(m_sliderZ, SIGNAL(valueChanged(int)),
          this, SLOT(setZRotation(int)));

      // Connect the start/stop button
      connect(m_buttonStartStop, SIGNAL(clicked()),
          this, SLOT(toggleTimer()));

      // Connect the reset button to the reset slot
      connect(buttonReset, SIGNAL(clicked()),
          this, SLOT(resetRotations()));
      // Connect the reset signal to the sliders
      connect(this, SIGNAL(resetRotation(int)),
          m_sliderX, SLOT(setValue(int)));
      connect(this, SIGNAL(resetRotation(int)),
          m_sliderY, SLOT(setValue(int)));
      connect(this, SIGNAL(resetRotation(int)),
          m_sliderZ, SLOT(setValue(int)));

      connect(m_settingsWidget, SIGNAL(destroyed()),
          this, SLOT(settingsWidgetDestroyed()));
    }
Пример #14
0
DeferredShading::DeferredShading(QWidget *parent, Qt::WFlags flags)
	: QMainWindow(parent, flags)
{
	ui.setupUi(this);

	// Layouts
	QHBoxLayout *mainLayout = new QHBoxLayout;
    QVBoxLayout *secondLayout = new QVBoxLayout;
	QHBoxLayout *thirdLayout = new QHBoxLayout;

	// Menus
	// File
	QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
	QAction *loadModelAct = new QAction(tr("&Load Model"), this);
	fileMenu->addAction(loadModelAct);
	// Render
	QMenu *renderMenu = menuBar()->addMenu(tr("&Render"));
	QAction *forwardRenderAct = new QAction(tr("&Forward"), this);
	QAction *forwardBlendRenderAct = new QAction(tr("&Forward(Blend)"), this);
	QAction *deferredRenderAct = new QAction(tr("&Deferred"), this);
	QAction *forwardPlusRenderAct = new QAction(tr("&Forward+"), this);
	QAction *forwardPlusCudaRenderAct = new QAction(tr("&Forward+(CUDA)"), this);
	QAction *positionRenderAct = new QAction(tr("&Position"), this);
	QAction *diffuseRenderAct = new QAction(tr("&Diffuse"), this);
	QAction *normalRenderAct = new QAction(tr("&Normal"), this);
	QAction *allRenderAct = new QAction(tr("&All"), this);
	QAction *depthRenderAct = new QAction(tr("&Depth"), this);
	QAction *gridRenderAct = new QAction(tr("&Lighting Grid"), this);
	renderMenu->addAction(forwardRenderAct);
	renderMenu->addAction(forwardBlendRenderAct);
	renderMenu->addAction(deferredRenderAct);
	renderMenu->addAction(forwardPlusRenderAct);
	renderMenu->addAction(forwardPlusCudaRenderAct);
	renderMenu->addSeparator();
	renderMenu->addAction(positionRenderAct);
	renderMenu->addAction(diffuseRenderAct);
	renderMenu->addAction(normalRenderAct);
	renderMenu->addAction(allRenderAct);
	renderMenu->addSeparator();
	renderMenu->addAction(depthRenderAct);
	renderMenu->addAction(gridRenderAct);

	// Validators
	QDoubleValidator *_doubleValidator = new QDoubleValidator(0.01,10.0,2);
	_doubleValidator->setNotation(QDoubleValidator::StandardNotation);
	QDoubleValidator *doubleValidator = new QDoubleValidator(0.01,10000.0,2);
	doubleValidator->setNotation(QDoubleValidator::StandardNotation);

	QIntValidator *intValidator = new QIntValidator(0,N_MAX_LIGHTS);
	QIntValidator *intValidator2 = new QIntValidator(0,4096);

	// Separators
	QFrame *line = new QFrame();
	line->setFrameShape(QFrame::VLine);
	QFrame *line2 = new QFrame();
	line2->setFrameShape(QFrame::VLine);
	QFrame *line3 = new QFrame();
	line3->setFrameShape(QFrame::VLine);
	QFrame *line4 = new QFrame();
	line4->setFrameShape(QFrame::VLine);

	// Camera Sensitivity
	QLabel *sensibilityLabel = new QLabel();
	sensibilityLabel->setText("Sensitivity: ");

	QLineEdit *cameraSensitivityIn = new QLineEdit();
	cameraSensitivityIn->setValidator(doubleValidator);
	cameraSensitivityIn->setText("0.1");

	// Camera Speed
	QLabel *speedLabel = new QLabel();
	speedLabel->setText("Speed: ");

	QLineEdit *cameraSpeedIn = new QLineEdit();
	cameraSpeedIn->setValidator(doubleValidator);
	cameraSpeedIn->setText("1.0");

	// Threshold (deferred only)
	QLabel *thresholdLabel = new QLabel();
	thresholdLabel->setText("Threshold: ");

	QLineEdit *thresholdIn = new QLineEdit();
	thresholdIn->setValidator(intValidator2);
	thresholdIn->setText("256");

	// Billboards
	//QLabel *billboardsLabel = new QLabel();
	//billboardsLabel->setText("Billboards: ");

	QCheckBox *billboardsCheckBox = new QCheckBox("Billboards:");
	billboardsCheckBox->setLayoutDirection(Qt::RightToLeft);
	billboardsCheckBox->setChecked(false);

	// Light bounding box scale
	QLabel *lightBBScaleLabel = new QLabel();
	lightBBScaleLabel->setText(" Bb scale: ");

	QLineEdit *lighBBScaleIn = new QLineEdit();
	lighBBScaleIn->setValidator(doubleValidator);
	lighBBScaleIn->setText("1.0");

	// Attenuation
	QLabel *attenuationLabel = new QLabel();
	attenuationLabel->setText("Attenuation: ");

	QLineEdit *constantAttIn = new QLineEdit();
	constantAttIn->setValidator(doubleValidator);
	constantAttIn->setText("1.0");

	QLineEdit *linearAttIn = new QLineEdit();
	linearAttIn->setValidator(doubleValidator);
	linearAttIn->setText("60.0");

	QLineEdit *expAttIn = new QLineEdit();
	expAttIn->setValidator(doubleValidator);
	expAttIn->setText("0.0");

	// Light intensity
	QLabel *lightIntesityLabel = new QLabel();
	lightIntesityLabel->setText("Intensity: ");

	QLineEdit *lighIntensityIn = new QLineEdit();
	lighIntensityIn->setValidator(doubleValidator);
	lighIntensityIn->setText("1.0");

	// Number of lights
	QLabel *nLightsLabel = new QLabel();
	nLightsLabel->setText("N: ");
	std::stringstream sstm;
	sstm << INITIAL_LIGHTS;
	std::string s = sstm.str();
	// QString::fromStdString desnt work on release
#ifdef NDEBUG
	nLights = "20";
#else
	nLights = QString::fromStdString(s);
#endif
	
	QLineEdit *nLightsIn = new QLineEdit();
	nLightsIn->setValidator(intValidator);
	nLightsIn->setText(nLights);

	QPushButton *genLightsButton = new QPushButton("Gen. Lights");

	// Render Mode
	QLabel *renderModeLabel = new QLabel();
	renderModeLabel->setText("Forward");
	renderModeLabel->setAlignment(Qt::AlignRight);

	// FPS
	QLabel *fpsLabelNum = new QLabel();
	fpsLabelNum->setNum(0);
	fpsLabelNum->setAlignment(Qt::AlignRight);
	fpsLabelNum->setMaximumHeight(20);

	QLabel *fpsLabel = new QLabel();
	fpsLabel->setText("FPS: ");
	fpsLabel->setAlignment(Qt::AlignRight);

	// GLWidget
    GLWidget *glWidget = new GLWidget;

	// Connect signals-slots
	connect(loadModelAct,SIGNAL(triggered()), this, SLOT(loadModelDia()));
	connect(this,SIGNAL(modelPathChange(std::string)), glWidget, SLOT(loadModel(std::string)));
	connect(forwardRenderAct,SIGNAL(triggered()), glWidget, SLOT(setForwardRenderMode()));
	connect(forwardBlendRenderAct,SIGNAL(triggered()), glWidget, SLOT(setForwardBlendRenderMode()));
	connect(forwardPlusRenderAct,SIGNAL(triggered()), glWidget, SLOT(setForwardPlusRenderMode()));
	connect(forwardPlusCudaRenderAct,SIGNAL(triggered()), glWidget, SLOT(setForwardPlusCudaRenderMode()));
	connect(deferredRenderAct,SIGNAL(triggered()), glWidget, SLOT(setDeferredRenderMode()));
	connect(positionRenderAct,SIGNAL(triggered()), glWidget, SLOT(setPositionRenderMode()));
	connect(diffuseRenderAct,SIGNAL(triggered()), glWidget, SLOT(setDiffuseRenderMode())); 
	connect(normalRenderAct,SIGNAL(triggered()), glWidget, SLOT(setNormalRenderMode()));
	connect(allRenderAct,SIGNAL(triggered()), glWidget, SLOT(setAllRenderMode()));
	connect(depthRenderAct,SIGNAL(triggered()), glWidget, SLOT(setDepthRenderMode()));
	connect(gridRenderAct,SIGNAL(triggered()), glWidget, SLOT(setForwardDebugRenderMode()));
	connect(this,SIGNAL(keyPressed(int)), glWidget, SLOT(addKey(int)));
	connect(this,SIGNAL(keyReleased(int)), glWidget, SLOT(removeKey(int)));
	connect(cameraSensitivityIn,SIGNAL(textChanged(QString)),glWidget,SLOT(modifyCameraSensitivity(QString)));
	connect(cameraSpeedIn,SIGNAL(textChanged(QString)),glWidget,SLOT(modifyCameraSpeed(QString)));
	connect(glWidget, SIGNAL(updateFPSSignal(int)), fpsLabelNum, SLOT(setNum(int)));
	connect(nLightsIn,SIGNAL(textChanged(QString)),this,SLOT(modifyNLights(QString)));
	connect(genLightsButton, SIGNAL(clicked()), this, SLOT(genLights()));
	connect(this, SIGNAL(glGenLights(int)), glWidget, SLOT(genLightning(int)));
	connect(billboardsCheckBox, SIGNAL(stateChanged(int)), glWidget, SLOT(enableBillboards(int)));
	connect(lighBBScaleIn, SIGNAL(textChanged(QString)), glWidget, SLOT(modifyBoundingBoxScale(QString)));
	connect(lighIntensityIn, SIGNAL(textChanged(QString)), glWidget, SLOT(modifyMaxIntensity(QString)));
	connect(glWidget, SIGNAL(updateLightIntensityIn(QString)), lighIntensityIn, SLOT(setText(QString)));
	connect(glWidget, SIGNAL(updateRenderMode(QString)), renderModeLabel, SLOT(setText(QString)));
	connect(thresholdIn, SIGNAL(textChanged(QString)), glWidget, SLOT(modifyThreshold(QString)));
	connect(constantAttIn, SIGNAL(textChanged(QString)), glWidget, SLOT(modifyConstantAttenuation(QString)));
	connect(linearAttIn, SIGNAL(textChanged(QString)), glWidget, SLOT(modifyLinearAttenuation(QString)));
	connect(expAttIn, SIGNAL(textChanged(QString)), glWidget, SLOT(modifyExpAttenuation(QString)));

	// Set layout content
    mainLayout->addWidget(glWidget);

	thirdLayout->addWidget(sensibilityLabel);
	thirdLayout->addWidget(cameraSensitivityIn);
	thirdLayout->addWidget(speedLabel);
	thirdLayout->addWidget(cameraSpeedIn);
	thirdLayout->addWidget(line);
	thirdLayout->addWidget(thresholdLabel);
	thirdLayout->addWidget(thresholdIn);
	thirdLayout->addWidget(line2);
	thirdLayout->addWidget(billboardsCheckBox);
	thirdLayout->addWidget(lightBBScaleLabel);
	thirdLayout->addWidget(lighBBScaleIn);
	thirdLayout->addWidget(attenuationLabel);
	thirdLayout->addWidget(constantAttIn);
	thirdLayout->addWidget(linearAttIn);
	thirdLayout->addWidget(expAttIn);
	thirdLayout->addWidget(lightIntesityLabel);
	thirdLayout->addWidget(lighIntensityIn);
	thirdLayout->addWidget(nLightsLabel);
	thirdLayout->addWidget(nLightsIn);
	thirdLayout->addWidget(genLightsButton);
	thirdLayout->addWidget(line3);
	thirdLayout->addWidget(renderModeLabel);
	thirdLayout->addWidget(line4);
	thirdLayout->addWidget(fpsLabel);
	thirdLayout->addWidget(fpsLabelNum);

	secondLayout->addLayout(thirdLayout);
    secondLayout->addLayout(mainLayout);

	cameraSpeedIn->setFocus();

    setWindowTitle("Deferred Shading");
    ui.centralWidget->setLayout(secondLayout);
	setMinimumSize(1024,576);
}
Пример #15
0
void DetailWindow::analysisFinished(){
  QString error = analysisWatcher.result().errorMessage;
  if(error != ""){
    say(error);
    cleanUpAfterRun();
    return;
  }
  // Title bar
  TagLibMetadata md(filePath);
  QString shortName = md.getTitle();
  if(shortName == "")
    shortName = filePath.mid(filePath.lastIndexOf("/") + 1);
  this->setWindowTitle(GuiStrings::getInstance()->appName() + GuiStrings::getInstance()->delim() + tr("Detailed Analysis") + GuiStrings::getInstance()->delim() + shortName);
  // full chromagram
  chromagramImage = imageFromChromagram(analysisWatcher.result().core.fullChromagram);
  ui->chromagramLabel->setPixmap(QPixmap::fromImage(chromagramImage));
  ui->chromagramLabel->setMinimumHeight(analysisWatcher.result().core.fullChromagram.getBins()+2);
  ui->chromagramLabel->setMinimumWidth(analysisWatcher.result().core.fullChromagram.getHops()+2);
  // one octave chromagram
  miniChromagramImage = imageFromChromagram(analysisWatcher.result().core.oneOctaveChromagram);
  ui->miniChromagramLabel->setPixmap(QPixmap::fromImage(miniChromagramImage));
  //: A tooltip on the Detail window
  ui->miniChromagramLabel->setToolTip(wrapToolTip(tr("This is the same chromagram data, reduced to a single octave.")));
  // harmonic change signal
  int rateOfChangePrecision = 100;
  int size = (signed)analysisWatcher.result().core.harmonicChangeSignal.size();
  harmonicChangeImage = QImage(size*chromaScaleH,rateOfChangePrecision,QImage::Format_Indexed8);
  prefs.setImageColours(harmonicChangeImage,ui->chromaColourCombo->currentIndex());
  for(int h=0; h<size; h++){
    int value = analysisWatcher.result().core.harmonicChangeSignal[h] * rateOfChangePrecision;
    for(int y=0; y<rateOfChangePrecision; y++)
      for(int x=0; x<chromaScaleH; x++)
        harmonicChangeImage.setPixel(h*chromaScaleH+x, y, (rateOfChangePrecision - y > value ? 0 : 50));
  }
  ui->harmonicChangeLabel->setPixmap(QPixmap::fromImage(harmonicChangeImage));
  // Tooltip
  if(prefs.getSegmentation() == 'n'){
    //: A tooltip on the Detail window
    ui->harmonicChangeLabel->setToolTip(wrapToolTip(tr("You are not using segmentation, so there is no harmonic change data to display.")));
  }else if(prefs.getSegmentation() == 'a'){
    //: A tooltip on the Detail window
    ui->harmonicChangeLabel->setToolTip(wrapToolTip(tr("You are using arbitrary segmentation, so there is no harmonic change data to display.")));
  }else{
    //: A tooltip on the Detail window
    ui->harmonicChangeLabel->setToolTip(wrapToolTip(tr("This is the level of harmonic change detected in the chromagram over time. Peaks in this signal are used to segment the chromagram.")));
  }
  // Key estimates
  deleteKeyLabels();
  int lastChange = -1; // enable correct stretch policy for first segment
  for(int h = 0; h < (signed)analysisWatcher.result().core.segments.size(); h++){
    QLabel* newLabel = new QLabel(prefs.getKeyCode(analysisWatcher.result().core.segments[h].key));
    newLabel->setAlignment(Qt::AlignCenter);
    QPalette pal = newLabel->palette();
    pal.setColor(backgroundRole(), prefs.getKeyColour(analysisWatcher.result().core.segments[h].key));
    newLabel->setPalette(pal);
    newLabel->setFrameStyle(1);
    newLabel->setAutoFillBackground(true);
    newLabel->setMinimumHeight(20);
    newLabel->setMaximumHeight(30);
    if(prefs.getSegmentation() == 'n'){
      //: A tooltip on the Detail window
      newLabel->setToolTip(wrapToolTip(tr("This row shows the key estimate for the unsegmented chromagram.")));
    }else if(prefs.getSegmentation() == 'a'){
      //: A tooltip on the Detail window
      newLabel->setToolTip(wrapToolTip(tr("This row shows the key estimates for the arbitrary segments.")));
    }else{
      //: A tooltip on the Detail window
      newLabel->setToolTip(wrapToolTip(tr("This row shows the key estimates for the segments between peak harmonic changes.")));
    }
    ui->horizontalLayout_keyLabels->addWidget(newLabel, h - lastChange);
    keyLabels.push_back(newLabel);
    lastChange = h;
  }
  //: Text in the Batch window status bar; includes a key code at %1
  say(tr("Key estimate: %1").arg(prefs.getKeyCode(analysisWatcher.result().core.globalKeyEstimate)));
  cleanUpAfterRun();
}
void MesoscopicDataPlotView::initUI() {
    // density
    densityPlot_ = new QCustomPlot();
    densityPlot_->setInteractions(QCustomPlot::iRangeDrag|QCustomPlot::iRangeZoom);
    densityPlot_->setRangeDrag(Qt::Horizontal|Qt::Vertical);
    densityPlot_->setRangeZoom(Qt::Horizontal|Qt::Vertical);
    densityPlot_->legend->setVisible(true);

    densityPlot_->addGraph();
    densityPlot_->graph(0)->setName("Mesoscopic Density");
    densityPlot_->xAxis->setLabel("time slice");
    densityPlot_->yAxis->setLabel("cars/km");
    densityPlot_->yAxis->setRange(0, preferenceManager_->getMesoscopicDensityPlotScale());
    densityPlot_->replot();

    densityTracer_ = new QCPItemTracer(densityPlot_);
    densityTracer_->setStyle(QCPItemTracer::tsCrosshair);
    densityTracer_->setGraph(densityPlot_->graph(0));
    densityTracer_->setVisible(true);

    // flow
    flowPlot_ = new QCustomPlot();
    flowPlot_->setInteractions(QCustomPlot::iRangeDrag|QCustomPlot::iRangeZoom);
    flowPlot_->setRangeDrag(Qt::Horizontal|Qt::Vertical);
    flowPlot_->setRangeZoom(Qt::Horizontal|Qt::Vertical);
    flowPlot_->legend->setVisible(true);

    flowPlot_->addGraph();
    flowPlot_->graph(0)->setName("Mesoscopic Flow");
    flowPlot_->xAxis->setLabel("time slice");
    flowPlot_->yAxis->setLabel("cars/sec-meter");
    flowPlot_->yAxis->setRange(0, preferenceManager_->getMesoscopicFlowPlotScale());

    flowPlot_->replot();

    flowTracer_ = new QCPItemTracer(flowPlot_);
    flowTracer_->setStyle(QCPItemTracer::tsCrosshair);
    flowTracer_->setGraph(flowPlot_->graph(0));
    flowTracer_->setVisible(true);

    // speed
    speedPlot_ = new QCustomPlot();
    speedPlot_->setInteractions(QCustomPlot::iRangeDrag|QCustomPlot::iRangeZoom);
    speedPlot_->setRangeDrag(Qt::Horizontal|Qt::Vertical);
    speedPlot_->setRangeZoom(Qt::Horizontal|Qt::Vertical);
    speedPlot_->legend->setVisible(true);

    speedPlot_->addGraph();
    speedPlot_->graph(0)->setName("Mesoscopic Speed");
    speedPlot_->xAxis->setLabel("time slice");
    speedPlot_->yAxis->setLabel("meters/sec");
    speedPlot_->yAxis->setRange(0, preferenceManager_->getMesoscopicSpeedPlotScale());

    speedTracer_ = new QCPItemTracer(speedPlot_);
    speedTracer_->setStyle(QCPItemTracer::tsCrosshair);
    speedTracer_->setGraph(speedPlot_->graph(0));
    speedTracer_->setVisible(true);

    densityPlot_->xAxis->setRange(0, 100);
    flowPlot_->xAxis->setRange(0, 100);
    speedPlot_->xAxis->setRange(0, 100);

    // layout
    QLabel *title = new QLabel();
    title->setText("MESOSCOPIC PLOT VIEW");
    title->setMaximumHeight(10);
    closeBut_ = new QPushButton();
    closeBut_->setText("Close");
    closeBut_->setMaximumWidth(100);
    QHBoxLayout *titleBar = new QHBoxLayout();
    titleBar->addWidget(title);
    titleBar->addWidget(closeBut_);
    QVBoxLayout *plotsContainer = new QVBoxLayout();
    plotsContainer->addLayout(titleBar);
    plotsContainer->addWidget(densityPlot_);
    plotsContainer->addWidget(flowPlot_);
    plotsContainer->addWidget(speedPlot_);
    this->setLayout(plotsContainer);

    connect(closeBut_, SIGNAL(clicked()), this, SIGNAL(announceClose()));
}
Пример #17
0
MintingView::MintingView(QWidget *parent) :
    QWidget(parent), model(0), mintingView(0)
{
    QHBoxLayout *hlayout = new QHBoxLayout();
    hlayout->setContentsMargins(0,0,0,0);

    QString legendBoxStyle = "background-color: rgb(%1,%2,%3); border: 1px solid black;";

    QLabel *youngColor = new QLabel(" ");
    youngColor->setMaximumHeight(15);
    youngColor->setMaximumWidth(10);
    youngColor->setStyleSheet(legendBoxStyle.arg(COLOR_MINT_YOUNG.red()).arg(COLOR_MINT_YOUNG.green()).arg(COLOR_MINT_YOUNG.blue()));
    QLabel *youngLegend = new QLabel(tr("transaction is too young"));
    youngLegend->setContentsMargins(5,0,15,0);

    QLabel *matureColor = new QLabel(" ");
    matureColor->setMaximumHeight(15);
    matureColor->setMaximumWidth(10);
    matureColor->setStyleSheet(legendBoxStyle.arg(COLOR_MINT_MATURE.red()).arg(COLOR_MINT_MATURE.green()).arg(COLOR_MINT_MATURE.blue()));
    QLabel *matureLegend = new QLabel(tr("transaction is mature"));
    matureLegend->setContentsMargins(5,0,15,0);

    QLabel *oldColor = new QLabel(" ");
    oldColor->setMaximumHeight(15);
    oldColor->setMaximumWidth(10);
    oldColor->setStyleSheet(legendBoxStyle.arg(COLOR_MINT_OLD.red()).arg(COLOR_MINT_OLD.green()).arg(COLOR_MINT_OLD.blue()));
    QLabel *oldLegend = new QLabel(tr("transaction  has reached maximum probability"));
    oldLegend->setContentsMargins(5,0,15,0);

    QHBoxLayout *legendLayout = new QHBoxLayout();
    legendLayout->setContentsMargins(10,10,0,0);
    legendLayout->addWidget(youngColor);
    legendLayout->addWidget(youngLegend);
    legendLayout->addWidget(matureColor);
    legendLayout->addWidget(matureLegend);
    legendLayout->addWidget(oldColor);
    legendLayout->addWidget(oldLegend);
    legendLayout->insertStretch(-1);

    QLabel *mintingLabel = new QLabel(tr("Display minting probability within : "));
    mintingCombo = new QComboBox();
    mintingCombo->addItem(tr("10 min"), Minting10min);
    mintingCombo->addItem(tr("24 hours"), Minting1day);
    mintingCombo->addItem(tr("30 days"), Minting30days);
    mintingCombo->addItem(tr("90 days"), Minting90days);
    mintingCombo->setFixedWidth(120);


    hlayout->insertStretch(0);
    hlayout->addWidget(mintingLabel);
    hlayout->addWidget(mintingCombo);

    QVBoxLayout *vlayout = new QVBoxLayout(this);
    vlayout->setContentsMargins(0,0,0,0);
    vlayout->setSpacing(0);

    QTableView *view = new QTableView(this);
    vlayout->addLayout(hlayout);
    vlayout->addWidget(view);
    vlayout->addLayout(legendLayout);

    vlayout->setSpacing(0);
    int width = view->verticalScrollBar()->sizeHint().width();
    // Cover scroll bar width with spacing
#ifdef Q_WS_MAC
    hlayout->addSpacing(width+2);
#else
    hlayout->addSpacing(width);
#endif
    // Always show scroll bar
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    view->setTabKeyNavigation(false);
    view->setContextMenuPolicy(Qt::CustomContextMenu);

    mintingView = view;

    connect(mintingCombo, SIGNAL(activated(int)), this, SLOT(chooseMintingInterval(int)));

}