// CppTypeHierarchyWidget
CppTypeHierarchyWidget::CppTypeHierarchyWidget(Core::IEditor *editor) :
    QWidget(0),
    m_cppEditor(0),
    m_treeView(0),
    m_model(0),
    m_delegate(0)
{
    QVBoxLayout *layout = new QVBoxLayout;
    layout->setMargin(0);
    layout->setSpacing(0);

    if (CPPEditor *cppEditor = qobject_cast<CPPEditor *>(editor)) {
        m_cppEditor = static_cast<CPPEditorWidget *>(cppEditor->widget());

        m_model = new QStandardItemModel;
        m_treeView = new Utils::NavigationTreeView;
        m_delegate = new AnnotatedItemDelegate;
        m_delegate->setDelimiter(QLatin1String(" "));
        m_delegate->setAnnotationRole(AnnotationRole);
        m_treeView->setModel(m_model);
        m_treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
        m_treeView->setItemDelegate(m_delegate);
        layout->addWidget(m_treeView);

        connect(m_treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(onItemClicked(QModelIndex)));
        connect(CppPlugin::instance(), SIGNAL(typeHierarchyRequested()), this, SLOT(perform()));
    } else {
        QLabel *label = new QLabel(tr("No type hierarchy available"), this);
        label->setAlignment(Qt::AlignCenter);
        label->setAutoFillBackground(true);
        label->setBackgroundRole(QPalette::Base);
        layout->addWidget(label);
    }
    setLayout(layout);
}
void FilterItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	QAbstractItemView *view = qobject_cast<QAbstractItemView*>(parent());
	QLabel *label;

	if (view->indexWidget(index) == 0)
	{
		label = new QLabel();

		label->installEventFilter(filter);
		label->setAutoFillBackground(true);
		label->setFocusPolicy(Qt::TabFocus);
		label->setText(index.data().toString());
		view->setIndexWidget(index, label);
	}

	label = (QLabel*)view->indexWidget(index);

	if (option.state & QStyle::State_Selected)
		if (option.state & QStyle::State_HasFocus)
			label->setBackgroundRole(QPalette::Highlight);
		else
			label->setBackgroundRole(QPalette::Window);
	else
		label->setBackgroundRole(QPalette::Base);
}
FlashableWidget::FlashableWidget(int width, int height, QWidget *parent):
    QWidget(parent) ,vLabels_(), width_(width), height_(height),
    vActiveLabels_(), inactiveLabelPalette(), activeLabelPalette(),
    backgroundPalette(), currentHalve(0), selectedHalveWidth(0),
    selectedHalveHeight(0), firstHalveWidth(0), firstHalveHeight(0),
    secondHalveWidth(0), secondHalveHeight(0)
{
    grid = new QGridLayout;

    QFont f("Helvetica", 20);
    for(int row = 0; row < height_; ++row)
    {
        for(int column = 0; column < width_; ++column)
        {
            QLabel *label = new QLabel();
            label->setFont(f);
            label->setScaledContents(true);
            label->setFrameShape(QFrame::Box);
            label->setLineWidth(3);
            label->setAlignment(Qt::AlignCenter);
            label->setPalette(inactiveLabelPalette);
            label->setAutoFillBackground(true);
            grid->addWidget(label, row, column);
            vLabels_.push_back(label);
        }
    }

    setLayout(grid);

    oneByOneIndex_ = 0;
}
void OBSPropertiesView::AddColor(obs_property_t *prop, QFormLayout *layout,
		QLabel *&label)
{
	QPushButton *button     = new QPushButton;
	QLabel      *colorLabel = new QLabel;
	const char  *name       = obs_property_name(prop);
	long long   val         = obs_data_get_int(settings, name);
	QColor      color       = color_from_int(val);

	button->setText(QTStr("Basic.PropertiesWindow.SelectColor"));

	colorLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel);
	colorLabel->setText(color.name(QColor::HexArgb));
	colorLabel->setPalette(QPalette(color));
	colorLabel->setAutoFillBackground(true);
	colorLabel->setAlignment(Qt::AlignCenter);

	QHBoxLayout *subLayout = new QHBoxLayout;
	subLayout->setContentsMargins(0, 0, 0, 0);

	subLayout->addWidget(colorLabel);
	subLayout->addWidget(button);

	WidgetInfo *info = new WidgetInfo(this, prop, colorLabel);
	connect(button, SIGNAL(clicked()), info, SLOT(ControlChanged()));
	children.emplace_back(info);

	label = new QLabel(QT_UTF8(obs_property_description(prop)));
	layout->addRow(label, subLayout);
}
DialWindow::DialWindow(MainWindow *mainWindow) :
    GcWindow(mainWindow), mainWindow(mainWindow), average(1), isNewLap(false)
{
    rolling.resize(150); // enough for 30 seconds at 5hz

    setContentsMargins(0,0,0,0);
    setInstanceName("Dial");

    QWidget *c = new QWidget;
    QVBoxLayout *cl = new QVBoxLayout(c);
    setControls(c);

    // setup the controls
    QFormLayout *controlsLayout = new QFormLayout();
    controlsLayout->setSpacing(0);
    controlsLayout->setContentsMargins(5,5,5,5);
    cl->addLayout(controlsLayout);

    // data series selection
    QLabel *seriesLabel = new QLabel(tr("Data Series"), this);
    seriesLabel->setAutoFillBackground(true);
    seriesSelector = new QComboBox(this);
    foreach (RealtimeData::DataSeries x, RealtimeData::listDataSeries()) {
        seriesSelector->addItem(RealtimeData::seriesName(x), static_cast<int>(x));
    }
void TimeAnalysisWidget::updateLegend()
{
    std::vector<std::string> &labels = _selectedScalar->labels();

    // removinb previous legend
    QFormLayout *layout = (QFormLayout *)_ui->legendGroupBox->layout();
    QLayoutItem *child;
    while (layout->count()!=0 && (child = layout->takeAt(0)) != 0) {
        child->widget()->deleteLater();
        delete child;
    }

    for (unsigned i=0; i<labels.size(); ++i) {
        QLabel *colorLabel = new QLabel;
        colorLabel->setAutoFillBackground(true);
        colorLabel->setMinimumSize(70, 15);
        QPalette palette = colorLabel->palette();

        float denom = _selectedScalar->max() - _selectedScalar->min();
        float normalizedValue = ( i - _selectedScalar->min() ) / ( denom == 0 ? 1.f : denom );

        palette.setColor(colorLabel->backgroundRole(), _ui->projectionWidget->colorScale()->getColor(normalizedValue));
        colorLabel->setPalette(palette);

        layout->addRow(new QLabel(labels[i].c_str()), colorLabel);
    }

    repaint();
}
Exemple #7
0
void MorePage::initializeWidget()
{
    //导航栏
    QString strTitle = tr("更多...");
    navigationBar = new NavigationBar(this);
    navigationBar->setTitleText(strTitle);

    QHBoxLayout* pHLTop = new QHBoxLayout();
    pHLTop->addWidget(navigationBar);
    pHLTop->setSpacing(0);
    pHLTop->setMargin(0);
    this->setTopbarLayout(pHLTop);


    //个人信息
    QLabel* themeWidget = new QLabel;
    QPixmap pixmap = QPixmap(ImagePath::MOREPAGE_THEME);
    pixmap.setDevicePixelRatio(2);
    themeWidget->setAutoFillBackground(true);
    themeWidget->setFixedHeight(this->screenHeight()*0.25);
    themeWidget->setFixedWidth(this->screenWidth());
    themeWidget->setPixmap(pixmap);
    themeWidget->setScaledContents(true);

    btnPersonalInfo = new QToolButton;
    btnPersonalInfo->setFixedWidth(this->screenWidth());
    btnPersonalInfo->setFixedHeight(this->screenHeight()*0.15);
    btnPersonalInfo->setIconSize(QSize(btnPersonalInfo->height()*0.7, btnPersonalInfo->height()*0.7));
    btnPersonalInfo->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    btnPersonalInfo->setStyleSheet("font:16px; color:white;background-color:rgba(0,0,0,0)");
    connect(btnPersonalInfo, SIGNAL(clicked()), SLOT(on_btnPersonal_clicked()));

    QVBoxLayout* themeLayout = new QVBoxLayout;
    themeLayout->addWidget(btnPersonalInfo);
    themeLayout->setMargin(0);
    themeWidget->setLayout(themeLayout);

    //设置
    btnSetting = new GroupButton;
    btnSetting->setStyleSheet(SheetStyle::GROUPBUTTON_BOTTOMBORDER);
    QPixmap settingPixmap(ImagePath::SETTING);
    this->setGroupButton(btnSetting, settingPixmap, tr("设置"));
    connect(btnSetting, SIGNAL(clicked()), SLOT(on_btnSetting_clicked()));

    QVBoxLayout* vblTotalLayout = new QVBoxLayout;
    vblTotalLayout->addWidget(themeWidget);
    vblTotalLayout->addSpacing(this->screenHeight()*0.026);
    vblTotalLayout->addWidget(btnSetting);
    vblTotalLayout->setAlignment(Qt::AlignTop);
    vblTotalLayout->setMargin(0);
    vblTotalLayout->setSpacing(0);
    this->setBodyPartLayout(vblTotalLayout);

    //屏幕触摸滚动设置
    this->setBodyScreenHeight(this->scrollAreaHasBottomBarHeight());
    this->installScrollViewportArea();
    this->loadLocalData(curAccountID);
}
QLabel * addLabel(QHBoxLayout * hboxLayout, QPixmap * pixmap) {
	QLabel * label = new QLabel();
	label->setObjectName("iconLabel");
	label->setAutoFillBackground(true);
	label->setPixmap(*pixmap);
	label->setFixedSize(pixmap->size());
	hboxLayout->addWidget(label);
	hboxLayout->addSpacing(IconSpace);

	return label;
}
Exemple #9
0
QWidget* MenuTitleItem::createWidget(QWidget *parent)
{
  QLabel* l = new QLabel(s, parent);
  l->setAlignment(Qt::AlignCenter);
  l->setAutoFillBackground(true);
  //QPalette palette;
  //palette.setColor(label->backgroundRole(), c);
  //l->setPalette(palette);
  l->setBackgroundRole(QPalette::Dark);
  return l;
}
 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                       const QModelIndex &index) const
 {
     Q_UNUSED(option);
     QLabel *label = new QLabel(parent);
     label->setAutoFillBackground(true);
     label->setTextInteractionFlags(Qt::TextSelectableByMouse
         | Qt::LinksAccessibleByMouse);
     label->setText(index.data().toString());
     return label;
 }
Exemple #11
0
//! [4]
QLabel *IconPreviewArea::createPixmapLabel()
{
    QLabel *label = new QLabel;
    label->setEnabled(false);
    label->setAlignment(Qt::AlignCenter);
    label->setFrameShape(QFrame::Box);
    label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    label->setBackgroundRole(QPalette::Base);
    label->setAutoFillBackground(true);
    label->setMinimumSize(132, 132);
    return label;
}
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);
}
Exemple #13
0
/** Add the optional message in a light yellow box to the layout
 *
 * @param mainLay :: layout
 */
void AlgorithmDialog::addOptionalMessage(QVBoxLayout *mainLay) {
  QLabel *inputMessage = new QLabel(this);
  inputMessage->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  QPalette pal = inputMessage->palette();
  pal.setColor(inputMessage->backgroundRole(),
               QColor(255, 255, 224)); // Light yellow
  pal.setColor(inputMessage->foregroundRole(), Qt::black);
  inputMessage->setPalette(pal);
  inputMessage->setAutoFillBackground(true);
  inputMessage->setWordWrap(true);
  inputMessage->setAlignment(Qt::AlignJustify);
  inputMessage->setMargin(3);
  inputMessage->setText(getOptionalMessage());
  QHBoxLayout *msgArea = new QHBoxLayout;
  msgArea->addWidget(inputMessage);
  mainLay->addLayout(msgArea, 0);
}
Exemple #14
0
TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings, FirmwareInterface * firmware):
    ModelPanel(parent, model, generalSettings, firmware),
    ui(new Ui::TelemetryCustomScreen),
    screen(screen)
{
    ui->setupUi(this);

    for (int l=0; l<4; l++) {
        for (int c=0; c<firmware->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
            fieldsCB[l][c] = new QComboBox(this);
            fieldsCB[l][c]->setProperty("index", c + (l<<8));
            ui->screenNumsLayout->addWidget(fieldsCB[l][c], l, c, 1, 1);
            connect(fieldsCB[l][c], SIGNAL(currentIndexChanged(int)), this, SLOT(customFieldChanged(int)));
        }
    }

    for (int l=0; l<4; l++) {
        barsCB[l] = new QComboBox(this);
        barsCB[l]->setProperty("index", l);
        connect(barsCB[l], SIGNAL(currentIndexChanged(int)), this, SLOT(barSourceChanged(int)));
        ui->screenBarsLayout->addWidget(barsCB[l], l, 0, 1, 1);

        minSB[l] = new QDoubleSpinBox(this);
        minSB[l]->setProperty("index", l);
        connect(minSB[l], SIGNAL(valueChanged(double)), this, SLOT(barMinChanged(double)));
        ui->screenBarsLayout->addWidget(minSB[l], l, 1, 1, 1);

        QLabel * label = new QLabel(this);
        label->setAutoFillBackground(false);
        label->setStyleSheet(QString::fromUtf8("Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),)\n"""));
        label->setFrameShape(QFrame::Panel);
        label->setFrameShadow(QFrame::Raised);
        label->setAlignment(Qt::AlignCenter);
        ui->screenBarsLayout->addWidget(label, l, 2, 1, 1);

        maxSB[l] = new QDoubleSpinBox(this);
        maxSB[l]->setProperty("index", l);
        connect(maxSB[l], SIGNAL(valueChanged(double)), this, SLOT(barMaxChanged(double)));
        ui->screenBarsLayout->addWidget(maxSB[l], l, 3, 1, 1);
    }

    disableMouseScrolling();

    update();
}
Exemple #15
0
    AlignmentView(Gui::Document* pcDocument, QWidget* parent, QGLWidget* shareWidget=0, Qt::WindowFlags wflags=0)
        : AbstractSplitView(pcDocument, parent, wflags)
    {
        QSplitter* mainSplitter=0;
        mainSplitter = new QSplitter(Qt::Horizontal, this);
        _viewer.push_back(new View3DInventorViewer(mainSplitter, shareWidget));
        _viewer.back()->setDocument(pcDocument);
        _viewer.push_back(new View3DInventorViewer(mainSplitter, shareWidget));
        _viewer.back()->setDocument(pcDocument);

        QFrame* vbox = new QFrame(this);
        QVBoxLayout* layout = new QVBoxLayout();
        layout->setMargin(0);
        layout->setSpacing(0);
        vbox->setLayout(layout);

        myLabel = new QLabel(this);
        myLabel->setAutoFillBackground(true);
        QPalette pal = myLabel->palette();
        pal.setColor(QPalette::Window, Qt::darkGray);
        pal.setColor(QPalette::WindowText, Qt::white);
        myLabel->setPalette(pal);
        mainSplitter->setPalette(pal);
        myLabel->setAlignment(Qt::AlignCenter);
        myLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
        QFont font = myLabel->font();
        font.setPointSize(14);
        myLabel->setFont(font);
        layout->addWidget(myLabel);
        layout->addWidget(mainSplitter);

        vbox->show();
        setCentralWidget(vbox);

        // apply the user settings
        setupSettings();

        static_cast<SoGroup*>(getViewer(0)->getSoRenderManager()->getSceneGraph())->
            addChild(setupHeadUpDisplay(tr("Movable object")));
        static_cast<SoGroup*>(getViewer(1)->getSoRenderManager()->getSceneGraph())->
            addChild(setupHeadUpDisplay(tr("Fixed object")));
    }
Exemple #16
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);
}
Exemple #17
0
JMoonTool::JMoonTool(QWidget *parent)
        : KDialog( parent )
{
    ksw = (KStars*)parent;
    QFrame *page = new QFrame(this);
    setMainWidget( page );
    setCaption( i18n("Jupiter Moons Tool") );
    setButtons( KDialog::Close );
    setModal( false );

    QVBoxLayout *vlay = new QVBoxLayout( page );
    vlay->setMargin( 0 );
    vlay->setSpacing( 0 );

    colJp = QColor(Qt::white);
    colIo = QColor(Qt::red);
    colEu = QColor(Qt::yellow);
    colGn = QColor(Qt::cyan);
    colCa = QColor(Qt::green);

    QLabel *labIo = new QLabel( i18n("Io"), page );
    QLabel *labEu = new QLabel( i18n("Europa"), page );
    QLabel *labGn = new QLabel( i18n("Ganymede"), page );
    QLabel *labCa = new QLabel( i18n("Callisto"), page );

    labIo->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    labEu->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    labGn->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    labCa->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    labIo->setAlignment( Qt::AlignHCenter );
    labEu->setAlignment( Qt::AlignHCenter );
    labGn->setAlignment( Qt::AlignHCenter );
    labCa->setAlignment( Qt::AlignHCenter );

    QPalette p = palette();
    p.setColor( QPalette::Window, Qt::black );
    p.setColor( QPalette::WindowText, colIo );
    labIo->setPalette( p );
    p.setColor( QPalette::WindowText, colEu );
    labEu->setPalette( p );
    p.setColor( QPalette::WindowText, colGn );
    labGn->setPalette( p );
    p.setColor( QPalette::WindowText, colCa );
    labCa->setPalette( p );
    labIo->setAutoFillBackground( true );
    labEu->setAutoFillBackground( true );
    labGn->setAutoFillBackground( true );
    labCa->setAutoFillBackground( true );

    QGridLayout *glay = new QGridLayout();
    glay->addWidget( labIo, 0, 0 );
    glay->addWidget( labEu, 1, 0 );
    glay->addWidget( labGn, 0, 1 );
    glay->addWidget( labCa, 1, 1 );

    pw = new KPlotWidget( page );
    pw->setShowGrid( false );
    pw->setAntialiasing( true );
    pw->setLimits( -12.0, 12.0, -11.0, 11.0 );
    pw->axis(KPlotWidget::BottomAxis)->setLabel( i18n( "offset from Jupiter (arcmin)" ) );
    pw->axis(KPlotWidget::LeftAxis)->setLabel( i18n( "time since now (days)" ) );
    vlay->addLayout( glay );
    vlay->addWidget( pw );
    resize( 350, 600 );

    initPlotObjects();
    update();
}
void MainWindow::refresh()
{
    sortedValues->setVisible(false);
    if (tree.size() >= 1) {
        deleteKeyButton->setVisible(true);
        searchButton->setVisible(true);
    } else {
        deleteKeyButton->setVisible(false);
        searchButton->setVisible(false);
    }
    if (tree.size() >= 2) sortButton->setVisible(true);
    else sortButton->setVisible(false);

    delete treeWidget;
    treeWidget = nullptr;
    treeWidget = new QWidget();

    QHBoxLayout *treeLayout = new QHBoxLayout();
    treeLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);

    tree.inOrder();
    std::vector<int> values = tree.getInorderVector();
    std::vector<int> heights = tree.getHeights();

    for (int i = 0; i < (int)values.size(); i++) {
        QVBoxLayout *vl = new QVBoxLayout();
        QLabel *ql = new QLabel(QString::fromStdString(std::to_string(values[i])));

        vl->addWidget(ql);
        vl->setAlignment(Qt::AlignTop);
        vl->setSpacing(0);

        QPalette pal = ql->palette();
        int cval = (heights[i] * 10) % 125;
        pal.setColor(QPalette::Window, QColor(50+cval, 120+cval, 100+(cval *1.01), 128));

        if(heights[i]-1 == 0) {
            pal.setColor(QPalette::Window, QColor(200,200,50,128));
        }
        if(found && values[i] == foundVal) {
            pal.setColor(QPalette::Window, QColor(150,122, 200, 128));
            found = false;
        }
        ql->setAutoFillBackground(true);
        ql->setPalette(pal);
        ql->setFixedHeight(20);

        for (int j = 0; j < heights[i]-1; j++) {
            QLabel *littlel = new QLabel(" ");
            vl->addWidget(littlel);
            littlel->setAutoFillBackground(true);
            littlel->setPalette(pal);
            littlel->setFixedHeight(20);
        }

        QFont f;
        f.setPointSize(17);
        f.setBold(true);
        ql->setFont(f);


        treeLayout->addLayout(vl);
    }
    treeWidget->setLayout(treeLayout);
    mainLayout->addWidget(treeWidget);
    mainLayout->addWidget(sortButton);
}
Exemple #19
0
void PlayersPopup::updateFromServer(const Server& server)
{
    setUpdatesEnabled(false);

    ui->svlabel_GameMode->setText(server.GameModeString);
    // time
    if (server.TimeLimit > 0)
    {
        ui->svlabel_Time->setText(QString("%1/%2").arg(QString::number(server.TimeLimit-server.TimeLeft),
                                                       QString::number(server.TimeLimit)));
    }
    else
    {
        ui->svlabel_Time->setText("unlimited");
    }
    // frags
    QString frgType = server.getPointsName();
    if (frgType == "Frags" || frgType == "Points" || frgType == "Wins")
    {
        ui->svlabel_PointsName->setText(frgType+":");
        int limit = 0;
        if (frgType == "Frags") limit = server.FragLimit;
        else if (frgType == "Points") limit = server.PointLimit;
        else if (frgType == "Wins") limit = server.WinLimit;
        if (limit > 0)
        {
            // find top point team or player
            int topPts = 0;
            if (!server.Teams.isEmpty())
            {
                topPts = -32768;
                for (int i = 0; i < server.Teams.size(); i++)
                {
                    //qDebug("%s = %d", server.Teams[i].NameClean.toUtf8().data(), server.Teams[i].Points);
                    if (server.Teams[i].Points > topPts)
                        topPts = server.Teams[i].Points;
                }
            }
            else
            {
                topPts = -32768;
                for (int i = 0; i < server.Players.size(); i++)
                {
                    if (server.Players[i].Points > topPts)
                        topPts = server.Players[i].Points;
                }
            }
            ui->svlabel_Points->setText(QString("%1/%2").arg(QString::number(topPts),
                                                             QString::number(limit)));
        }
        else
        {
            ui->svlabel_Points->setText("unlimited");
        }
    }
    else // simulating IDE behavior. although IMO in this case we should just hide the points counter.
    {
        ui->svlabel_PointsName->setText("Frags:");
        ui->svlabel_Points->setText("unlimited");
    }
    // players
    int canjoin = server.MaxPlayers-server.PlayerCount;
    // sometimes canjoin can be negative.  for example when an admin forces their join into a nospec server.
    // let's keep it negative to amuse users  ;)
    QString ptext = QString("%1/%2").arg(QString::number(server.PlayerCount+server.BotCount),
                                         QString::number(server.MaxClients));
    if (canjoin != 0)
        ptext += QString(" (")+QString::number(canjoin)+QString(" can join)");
    ui->svlabel_Players->setText(ptext);
    // teams
    // first, remove all old labels
    for (int i = 0; i < teams.size(); i++)
        delete teams[i];
    teams.clear();

    for (int i = 0; i < server.Teams.size(); i++)
    {
        QLabel* teamlabel = new QLabel(ui->frame_2);
        teamlabel->setText(QString("%1: %2").arg(server.Teams[i].NameClean, QString::number(server.Teams[i].Points)));
        QFont nf = teamlabel->font();
        nf.setBold(true);
        teamlabel->setFont(nf);
        // now adjust label background
        QPalette np = teamlabel->palette();
        QColor lbg = server.Teams[i].Color;
        np.setColor(QPalette::Background, lbg);
        float luminance = 0.299*lbg.redF() + 0.587*lbg.greenF() + 0.114*lbg.blueF();
        if (luminance > 0.5)
            np.setColor(QPalette::WindowText, QColor(0, 0, 0, 255));
        else np.setColor(QPalette::WindowText, QColor(255, 255, 255, 255));
        teamlabel->setPalette(np);
        teamlabel->setAutoFillBackground(true);
        teamlabel->setMargin(2);
        ui->svlayout_teams->addWidget(teamlabel);
        teams.append(teamlabel);
    }

    ui->svlayout_teams->activate();

    setUpdatesEnabled(true);
}
/****************************************************************************
**
** Copyright (C) 2016
**
** This file is generated by the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

#include <QComboBox>
#include <QStringListModel>
#include <QLabel>
#include <QHBoxLayout>
#include <QGroupBox>
#include <QLineEdit>
#include "tb_transformationwidget.h"

namespace Magus
{
    //****************************************************************************/
    TransformationWidget::TransformationWidget(QWidget* parent) : QWidget(parent)
    {
        selectionChanged = false;
        mPrecision = 2;
        mPosition = QVector3D(0, 0, 0);
        mRotation = QVector3D(0, 0, 0);
        mScale = QVector3D(0, 0, 0);
        mTransformation = POSITION;
        QHBoxLayout* transformationLayout = new QHBoxLayout;
        QHBoxLayout* xLayout = new QHBoxLayout;
        QHBoxLayout* yLayout = new QHBoxLayout;
        QHBoxLayout* zLayout = new QHBoxLayout;

        // Combobox
        QStringList list;
        list << QString("Position") << QString("Rotation") << QString("Scale");
        mModel = new QStringListModel(list);
        mTransformationCombobox = new QComboBox(parent);
        mTransformationCombobox->setModel(mModel);
        mTransformationCombobox->setMaxVisibleItems(3);

        // X, Y, Z
        QString s;
        QLabel* xLabel = new QLabel(QString("<b>X</b>"));
        xLabel->setMaximumWidth(24);
        xLabel->setAutoFillBackground(true);
        xLabel->setStyleSheet("QLabel {background-color : rgb(255, 0, 0); margin-left: 0px; margin-right: 0px; spacing: 0px;}");
        QRegExp regularExpression("[+-]?([0-9]+\\.([0-9]+)?|\\.[0-9]+)([eE][+-]?[0-9]+)?"); // floating point
        QRegExpValidator* validator = new QRegExpValidator(regularExpression);
        mXedit = new QLineEdit;
        mXedit->setValidator(validator);
        s = QVariant(mPosition.x()).toString();
        s = s.left(getLeftStringIndex(s));
        mXedit->setText(s);
        mXedit->setStyleSheet("QLineEdit {margin-right: 0px; margin-left: 5px; width: 32px; spacing: 0px;}");

        QLabel* yLabel = new QLabel(QString("<b>Y</b>"));
        yLabel->setMaximumWidth(24);
        yLabel->setAutoFillBackground(true);
        yLabel->setStyleSheet("QLabel {background-color : rgb(0, 255, 0); margin-left: 0px; margin-right: 0px;}");
        mYedit = new QLineEdit;
        mYedit->setValidator(validator);
        s = QVariant(mPosition.y()).toString();
        s = s.left(getLeftStringIndex(s));
        mYedit->setText(s);
        mYedit->setStyleSheet("QLineEdit {margin-right: 0px; margin-left: 0px; width: 32px; spacing: 0px;}");

        QLabel* zLabel = new QLabel(QString("<b>Z</b>"));
        zLabel->setMaximumWidth(24);
        zLabel->setAutoFillBackground(true);
        zLabel->setStyleSheet("QLabel {background-color : rgb(100, 100, 255); margin-left: 0px; margin-right: 0px;}");
        mZedit = new QLineEdit;
        mZedit->setValidator(validator);
        s = QVariant(mPosition.z()).toString();
        s = s.left(getLeftStringIndex(s));
        mZedit->setText(s);
        mZedit->setStyleSheet("QLineEdit {margin-right: 0px; margin-left: 0px; width: 32px; spacing: 0px;}");

        // Layout
        transformationLayout->addWidget(mTransformationCombobox);
        xLayout->addWidget(xLabel, 0, Qt::AlignRight);
        xLayout->addWidget(mXedit, 100, Qt::AlignLeft);
        yLayout->addWidget(yLabel, 0, Qt::AlignRight);
        yLayout->addWidget(mYedit, 0, Qt::AlignLeft);
        zLayout->addWidget(zLabel, 0, Qt::AlignRight);
        zLayout->addWidget(mZedit, 0, Qt::AlignLeft);
        transformationLayout->addLayout(xLayout);
        transformationLayout->addLayout(yLayout);
        transformationLayout->addLayout(zLayout);
        setLayout(transformationLayout);
        connect(mTransformationCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
        connect(mXedit, SIGNAL(textEdited(const QString &)), this, SLOT(handleXchanged(const QString &)));
        connect(mYedit, SIGNAL(textEdited(const QString &)), this, SLOT(handleYchanged(const QString &)));
        connect(mZedit, SIGNAL(textEdited(const QString &)), this, SLOT(handleZchanged(const QString &)));
    }
QWidget *MemcheckErrorDelegate::createDetailsWidget(const QModelIndex &errorIndex, QWidget *parent) const
{
    QWidget *widget = new QWidget(parent);
    QVBoxLayout *layout = new QVBoxLayout;
    // code + white-space:pre so the padding (see below) works properly
    // don't include frameName here as it should wrap if required and pre-line is not supported
    // by Qt yet it seems
    const QString displayTextTemplate = QString("<code style='white-space:pre'>%1:</code> %2");

    QString relativeTo = relativeToPath();

    const Error error = errorIndex.data(ErrorListModel::ErrorRole).value<Error>();

    QLabel *errorLabel = new QLabel();
    errorLabel->setWordWrap(true);
    errorLabel->setContentsMargins(0, 0, 0, 0);
    errorLabel->setMargin(0);
    errorLabel->setIndent(0);
    QPalette p = errorLabel->palette();
    QColor lc = p.color(QPalette::Text);
    QString linkStyle = QString("style=\"color:rgba(%1, %2, %3, %4);\"")
                            .arg(lc.red()).arg(lc.green()).arg(lc.blue()).arg(int(0.7 * 255));
    p.setBrush(QPalette::Text, p.highlightedText());
    errorLabel->setPalette(p);
    errorLabel->setText(QString("%1&nbsp;&nbsp;<span %4>%2</span>")
                            .arg(error.what(), errorLocation(errorIndex, error, true, linkStyle),
                                 linkStyle));
    connect(errorLabel, SIGNAL(linkActivated(QString)), SLOT(openLinkInEditor(QString)));
    layout->addWidget(errorLabel);

    const QVector<Stack> stacks = error.stacks();
    for (int i = 0; i < stacks.count(); ++i) {
        const Stack &stack = stacks.at(i);
        // auxwhat for additional stacks
        if (i > 0) {
            QLabel *stackLabel = new QLabel(stack.auxWhat());
            stackLabel->setWordWrap(true);
            stackLabel->setContentsMargins(0, 0, 0, 0);
            stackLabel->setMargin(0);
            stackLabel->setIndent(0);
            QPalette p = stackLabel->palette();
            p.setBrush(QPalette::Text, p.highlightedText());
            stackLabel->setPalette(p);
            layout->addWidget(stackLabel);
        }
        int frameNr = 1;
        foreach (const Frame &frame, stack.frames()) {
            QString frameName = makeFrameName(frame, relativeTo);
            QTC_ASSERT(!frameName.isEmpty(), qt_noop());

            QLabel *frameLabel = new QLabel(widget);
            frameLabel->setAutoFillBackground(true);
            if (frameNr % 2 == 0) {
                // alternating rows
                QPalette p = frameLabel->palette();
                p.setBrush(QPalette::Base, p.alternateBase());
                frameLabel->setPalette(p);
            }
            frameLabel->setFont(QFont("monospace"));
            connect(frameLabel, SIGNAL(linkActivated(QString)), SLOT(openLinkInEditor(QString)));
            // pad frameNr to 2 chars since only 50 frames max are supported by valgrind
            const QString displayText = displayTextTemplate
                                            .arg(frameNr++, 2).arg(frameName);
            frameLabel->setText(displayText);

            frameLabel->setToolTip(Valgrind::XmlProtocol::toolTipForFrame(frame));
            frameLabel->setWordWrap(true);
            frameLabel->setContentsMargins(0, 0, 0, 0);
            frameLabel->setMargin(0);
            frameLabel->setIndent(10);
            layout->addWidget(frameLabel);
        }
    }

    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);
    widget->setLayout(layout);
    return widget;
}
BinCalcWidget::BinCalcWidget(QWidget *parent)
    : QWidget(parent)
    , m_value( 0 )
{
    setAutoFillBackground( true );
    setPalette( Qt::green );

    QLabel *label = new QLabel;
    label->setAutoFillBackground( true );
    label->setPalette( Qt::yellow );
    label->setAlignment( Qt::AlignRight );

    QLineEdit *lineEdit = new QLineEdit;
    lineEdit->setReadOnly( true );
    lineEdit->setAlignment( Qt::AlignRight );

//    QPushButton *button0 = new QPushButton( "0", this );
//    QPushButton *button1 = new QPushButton( "1", this );
    QPushButton *button0 = new QPushButton( "0" );
    QPushButton *button1 = new QPushButton( "1" );

    QPushButton *buttonAdd = new QPushButton( "+" );
    QPushButton *buttonSub = new QPushButton( "-" );
    QPushButton *buttonMul = new QPushButton( "*" );
    QPushButton *buttonDiv = new QPushButton( "/" );

    QPushButton *buttonEqual = new QPushButton( "=" );
    QPushButton *buttonClear = new QPushButton( "C" );

//    button1->move(100, 50);

//    button0->show();
//    button1->show();

    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget( button0 );
    layout->addWidget( button1 );

    QHBoxLayout *operatorLayout = new QHBoxLayout;
    operatorLayout->addWidget( buttonAdd );
    operatorLayout->addWidget( buttonSub );
    operatorLayout->addWidget( buttonMul );
    operatorLayout->addWidget( buttonDiv );

    QHBoxLayout *commandLayout = new QHBoxLayout;
    commandLayout->addWidget( buttonEqual );
    commandLayout->addWidget( buttonClear );

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget( label );
    mainLayout->addWidget( lineEdit );
    mainLayout->addLayout( layout );
    mainLayout->addLayout( operatorLayout );
    mainLayout->addLayout( commandLayout );

    setLayout( mainLayout );

    connect( button0, SIGNAL(clicked(bool)),
             this, SLOT(numberButtonClicked()) );
    connect( button1, SIGNAL(clicked(bool)),
             this, SLOT(numberButtonClicked()) );

    connect( buttonAdd, SIGNAL(clicked(bool)),
             this, SLOT(operatorButtonClicked()) );
    connect( buttonSub, SIGNAL(clicked(bool)),
             this, SLOT(operatorButtonClicked()) );
    connect( buttonMul, SIGNAL(clicked(bool)),
             this, SLOT(operatorButtonClicked()) );
    connect( buttonDiv, SIGNAL(clicked(bool)),
             this, SLOT(operatorButtonClicked()) );

    connect( buttonEqual, SIGNAL(clicked(bool)),
             this, SLOT(equalButtonClicked()) );
    connect( buttonClear, SIGNAL(clicked(bool)),
             this, SLOT(clearButtonClicked()) );
}
Exemple #23
0
////------------ Private Methods ----------------
void mtsPIDQtWidget::setupUi(void)
{
    QFont font;
    font.setBold(true);
    font.setPointSize(12);

    const double maximum = 30000;

    QGridLayout * gridLayout = new QGridLayout();
    gridLayout->setSpacing(1);

    int row = 0;
    QLabel * currentPosLabel = new QLabel("Current position (deg)");
    currentPosLabel->setAlignment(Qt::AlignRight);
    gridLayout->addWidget(currentPosLabel, row, 0);
    QVRCurrentPositionWidget = new vctQtWidgetDynamicVectorDoubleRead();
    QVRCurrentPositionWidget->SetPrecision(3);
    gridLayout->addWidget(QVRCurrentPositionWidget, row, 1);
    row++;

    QLabel * desiredPosLabel = new QLabel("Desired position (deg)");
    desiredPosLabel->setAlignment(Qt::AlignRight);
    gridLayout->addWidget(desiredPosLabel, row, 0);
    QVWDesiredPositionWidget = new vctQtWidgetDynamicVectorDoubleWrite(vctQtWidgetDynamicVectorDoubleWrite::SPINBOX_WIDGET);
    QVWDesiredPositionWidget->SetStep(0.1);
    QVWDesiredPositionWidget->SetRange(-360.0, 360.0);
    gridLayout->addWidget(QVWDesiredPositionWidget, row, 1);
    row++;

    QLabel * currentEffortLabel = new QLabel("Current effort (Nm)");
    currentEffortLabel->setAlignment(Qt::AlignRight);
    gridLayout->addWidget(currentEffortLabel, row, 0);
    QVRCurrentEffortWidget = new vctQtWidgetDynamicVectorDoubleRead();
    QVRCurrentEffortWidget->SetPrecision(3);
    gridLayout->addWidget(QVRCurrentEffortWidget, row, 1);
    row++;

    QLabel * desiredEffortLabel = new QLabel("Desired effort (Nm)");
    desiredEffortLabel->setAlignment(Qt::AlignRight);
    gridLayout->addWidget(desiredEffortLabel, row, 0);
    QVWDesiredEffortWidget = new vctQtWidgetDynamicVectorDoubleRead();
    QVWDesiredEffortWidget->SetPrecision(3);
    gridLayout->addWidget(QVWDesiredEffortWidget, row, 1);
    row++;

    QLabel * pLabel = new QLabel("PGain");
    pLabel->setAlignment(Qt::AlignRight);
    gridLayout->addWidget(pLabel);
    QVWPGainWidget = new vctQtWidgetDynamicVectorDoubleWrite(vctQtWidgetDynamicVectorDoubleWrite::SPINBOX_WIDGET);
    QVWPGainWidget->SetStep(0.01);
    QVWPGainWidget->SetPrecision(3);
    QVWPGainWidget->SetRange(-maximum, maximum);
    gridLayout->addWidget(QVWPGainWidget, row, 1);
    row++;

    QLabel * dLabel = new QLabel("DGain");
    dLabel->setAlignment(Qt::AlignRight);
    gridLayout->addWidget(dLabel);
    QVWDGainWidget = new vctQtWidgetDynamicVectorDoubleWrite(vctQtWidgetDynamicVectorDoubleWrite::SPINBOX_WIDGET);
    QVWDGainWidget->SetStep(0.01);
    QVWDGainWidget->SetPrecision(3);
    QVWDGainWidget->SetRange(-maximum, maximum);
    gridLayout->addWidget(QVWDGainWidget, row, 1);
    row++;

    QLabel * iLabel = new QLabel("IGain");
    iLabel->setAlignment(Qt::AlignRight);
    gridLayout->addWidget(iLabel);
    QVWIGainWidget = new vctQtWidgetDynamicVectorDoubleWrite(vctQtWidgetDynamicVectorDoubleWrite::SPINBOX_WIDGET);
    QVWIGainWidget->SetStep(0.001);
    QVWIGainWidget->SetPrecision(5);
    QVWIGainWidget->SetRange(-maximum, maximum);
    gridLayout->addWidget(QVWIGainWidget, row, 1);
    row++;

    // plot
    QHBoxLayout * plotLayout = new QHBoxLayout;
    // plot control
    QVBoxLayout * plotButtonsLayout = new QVBoxLayout;
    // - pick axis to display
    QLabel * plotIndexLabel = new QLabel("Index");
    plotButtonsLayout->addWidget(plotIndexLabel);
    QSBPlotIndex = new QSpinBox();
    QSBPlotIndex->setRange(0, NumberOfAxis);
    plotButtonsLayout->addWidget(QSBPlotIndex);
    // legend
    QLabel * label;
    QPalette palette;
    palette.setColor(QPalette::Window, Qt::black);
    label = new QLabel("Current position");
    label->setAutoFillBackground(true);
    palette.setColor(QPalette::WindowText, Qt::red);
    label->setPalette(palette);
    plotButtonsLayout->addWidget(label);
    label = new QLabel("Desired position");
    label->setAutoFillBackground(true);
    palette.setColor(QPalette::WindowText, Qt::green);
    label->setPalette(palette);
    plotButtonsLayout->addWidget(label);
    label = new QLabel("Current velocity");
    label->setAutoFillBackground(true);
    palette.setColor(QPalette::WindowText, Qt::gray);
    label->setPalette(palette);
    plotButtonsLayout->addWidget(label);
    label = new QLabel("Current effort");
    label->setAutoFillBackground(true);
    palette.setColor(QPalette::WindowText, Qt::cyan);
    label->setPalette(palette);
    plotButtonsLayout->addWidget(label);
    label = new QLabel("Desired effort");
    label->setAutoFillBackground(true);
    palette.setColor(QPalette::WindowText, Qt::white);
    label->setPalette(palette);
    plotButtonsLayout->addWidget(label);
    plotButtonsLayout->addStretch();
    plotLayout->addLayout(plotButtonsLayout);
    // plotting area
    QVPlot = new vctPlot2DOpenGLQtWidget();
    vctPlot2DBase::Scale * scalePosition = QVPlot->AddScale("positions");
    CurrentPositionSignal = scalePosition->AddSignal("current");
    CurrentPositionSignal->SetColor(vctDouble3(1.0, 0.0, 0.0));
    DesiredPositionSignal = scalePosition->AddSignal("desired");
    DesiredPositionSignal->SetColor(vctDouble3(0.0, 1.0, 0.0));
    vctPlot2DBase::Scale * scaleVelocity = QVPlot->AddScale("velocities");
    CurrentVelocitySignal = scaleVelocity->AddSignal("current");
    CurrentVelocitySignal->SetColor(vctDouble3(0.5, 0.5, 0.5));
    vctPlot2DBase::Scale * scaleEffort = QVPlot->AddScale("efforts");
    CurrentEffortSignal = scaleEffort->AddSignal("-current");
    CurrentEffortSignal->SetColor(vctDouble3(0.0, 1.0, 1.0));
    DesiredEffortSignal = scaleEffort->AddSignal("-desired");
    DesiredEffortSignal->SetColor(vctDouble3(1.0, 1.0, 1.0));
    QVPlot->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
    plotLayout->addWidget(QVPlot);

    // control
    QCBEnableDirectControl = new QCheckBox("Direct control");
    QCBEnablePID = new QCheckBox("Enable PID");
    QCBEnableTorqueMode = new QCheckBox("Enable torque mode");
    QPBMaintainPosition = new QPushButton("Maintain position");
    QPBZeroPosition = new QPushButton("Zero position");
    QPBResetPIDGain = new QPushButton("Reset PID gains");
    QHBoxLayout * controlLayout = new QHBoxLayout;
    controlLayout->addWidget(QCBEnableDirectControl);
    controlLayout->addWidget(QCBEnablePID);
    controlLayout->addWidget(QCBEnableTorqueMode);
    controlLayout->addWidget(QPBMaintainPosition);
    controlLayout->addWidget(QPBZeroPosition);
    controlLayout->addWidget(QPBResetPIDGain);
    controlLayout->addStretch();
    QGroupBox * controlGroupBox = new QGroupBox("Control");
    controlGroupBox->setLayout(controlLayout);

    connect(QCBEnableDirectControl, SIGNAL(toggled(bool)), this, SLOT(SlotEnableDirectControl(bool)));
    connect(QCBEnablePID, SIGNAL(clicked(bool)), this, SLOT(SlotEnablePID(bool)));
    connect(this, SIGNAL(SignalEnablePID(bool)), this, SLOT(SlotEnableEventHandler(bool)));
    connect(QCBEnableTorqueMode, SIGNAL(toggled(bool)), this, SLOT(SlotEnableTorqueMode(bool)));
    connect(QPBMaintainPosition, SIGNAL(clicked()), this, SLOT(SlotMaintainPosition()));
    connect(QPBZeroPosition, SIGNAL(clicked()), this, SLOT(SlotZeroPosition()));
    connect(QPBResetPIDGain, SIGNAL(clicked()), this, SLOT(SlotResetPIDGain()));
    connect(QSBPlotIndex, SIGNAL(valueChanged(int)), this, SLOT(SlotPlotIndex(int)));

    // main layout
    QVBoxLayout * mainLayout = new QVBoxLayout;
    mainLayout->addLayout(gridLayout);
    mainLayout->addLayout(plotLayout);
    mainLayout->addWidget(controlGroupBox);

    setLayout(mainLayout);

    setWindowTitle(this->GetName().c_str());
    setMinimumWidth(750);
    resize(sizeHint());

    // connect signals & slots
    connect(QVWDesiredPositionWidget, SIGNAL(valueChanged()), this, SLOT(SlotPositionChanged()));
    connect(QVWPGainWidget, SIGNAL(valueChanged()), this, SLOT(SlotPGainChanged()));
    connect(QVWDGainWidget, SIGNAL(valueChanged()), this, SLOT(SlotDGainChanged()));
    connect(QVWIGainWidget, SIGNAL(valueChanged()), this, SLOT(SlotIGainChanged()));

    // set initial values
    QCBEnableDirectControl->setChecked(DirectControl);
    SlotEnableDirectControl(DirectControl);
}
ChartBar::ChartBar(Context *context) : QWidget(context->mainWindow), context(context)
{
    // left / right scroller icon
    static QIcon leftIcon = iconFromPNG(":images/mac/left.png");
    static QIcon rightIcon = iconFromPNG(":images/mac/right.png");

    setContentsMargins(0,0,0,0);

    // main layout
    QHBoxLayout *mlayout = new QHBoxLayout(this);
    mlayout->setSpacing(0);
    mlayout->setContentsMargins(0,0,0,0);

    // buttonBar Widget
    buttonBar = new ButtonBar(this);
    buttonBar->setFixedHeight(23);
    buttonBar->setContentsMargins(0,0,0,0);

    QHBoxLayout *vlayout = new QHBoxLayout(buttonBar); 
    vlayout->setSpacing(0);
    vlayout->setContentsMargins(0,0,0,0);

    layout = new QHBoxLayout;
    layout->setSpacing(2);
    layout->setContentsMargins(0,0,0,0);
    vlayout->addLayout(layout);
    vlayout->addStretch();

    // scrollarea
    scrollArea = new QScrollArea(this);
    scrollArea->setAutoFillBackground(false);
    scrollArea->setWidgetResizable(true);
    scrollArea->setFrameStyle(QFrame::NoFrame);
    scrollArea->setContentsMargins(0,0,0,0);
    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scrollArea->setWidget(buttonBar);
    // scroll area turns it on .. we turn it off!
    buttonBar->setAutoFillBackground(false);

    // scroller buttons
    left = new QToolButton(this);
    left->setStyleSheet("QToolButton { border: none; padding: 0px; }");
    left->setAutoFillBackground(false);
    left->setFixedSize(20,20);
    left->setIcon(leftIcon);
    left->setIconSize(QSize(20,20));
    left->setFocusPolicy(Qt::NoFocus);
    mlayout->addWidget(left);
    connect(left, SIGNAL(clicked()), this, SLOT(scrollLeft()));

    // menu bar in the middle of the buttons
    mlayout->addWidget(scrollArea);

    right = new QToolButton(this);
    right->setStyleSheet("QToolButton { border: none; padding: 0px; }");
    right->setAutoFillBackground(false);
    right->setFixedSize(20,20);
    right->setIcon(rightIcon);
    right->setIconSize(QSize(20,20));
    right->setFocusPolicy(Qt::NoFocus);
    mlayout->addWidget(right);
    connect(right, SIGNAL(clicked()), this, SLOT(scrollRight()));

    // spacer to make the menuButton on the right
    QLabel *spacer = new QLabel("", this);
    spacer->setAutoFillBackground(false);
    spacer->setFixedHeight(20);
    spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
    mlayout->addWidget(spacer);

    menuButton = new QToolButton(this);
    menuButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
    menuButton->setAutoFillBackground(false);
    menuButton->setFixedSize(20,20);
    menuButton->setIcon(iconFromPNG(":images/sidebar/extra.png"));
    menuButton->setIconSize(QSize(10,10));
    menuButton->setFocusPolicy(Qt::NoFocus);
    mlayout->addWidget(menuButton);
    //connect(p, SIGNAL(clicked()), action, SLOT(trigger()));

    QFontMetrics fs(buttonFont);
#ifdef Q_OS_MAC
    setFixedHeight(fs.height()+7);
    scrollArea->setFixedHeight(fs.height()+7);
    buttonBar->setFixedHeight(fs.height()+7);
#else
    setFixedHeight(fs.height()+4);
    scrollArea->setFixedHeight(fs.height()+4);
    buttonBar->setFixedHeight(fs.height()+4);
#endif

    signalMapper = new QSignalMapper(this); // maps each option
    connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(clicked(int)));

    barMenu = new QMenu("Add");
    chartMenu = barMenu->addMenu(tr("Add Chart"));

    // menu
    connect(menuButton, SIGNAL(clicked()), this, SLOT(menuPopup()));
    connect(chartMenu, SIGNAL(aboutToShow()), this, SLOT(setChartMenu()));
    connect(chartMenu, SIGNAL(triggered(QAction*)), context->mainWindow, SLOT(addChart(QAction*)));

    // trap resize / mouse events
    installEventFilter(this);

    // appearance update
    connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32)));
}
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();
}
Exemple #26
0
NoteWidget::NoteWidget(QString title, QString text, QWidget *parent)
    : QWidget(parent)
{
	ui.setupUi(this);
	setBackgroundImage();
	this->setContentsMargins(0,0,0,0);
	
	/* create the GUI objects */
	backButton = new ButtonLabel(QPixmap(":/icons/backButton.png"), QPixmap(":/icons/backButtonPushed.png"), this);
	connect(backButton, SIGNAL(released()), this, SLOT(close()));
	quitButton = new ButtonLabel(QPixmap(":/icons/quitButton.png"), QPixmap(":/icons/quitButtonPushed.png"), this);
	connect(quitButton, SIGNAL(released()), QApplication::instance(), SLOT(quit()));
	patientIcon = new QLabel(this);
	patientIcon->setPixmap(QPixmap(":/icons/patientIcon.png"));
	
	/* initialize the footer object */
	footer = new ChangePatientFooter(this);
	
    QLabel *headerText = new QLabel(this);
    headerText->setStyleSheet("font-family: arial; font-weight: bold; font-size: 18px;");
    headerText->setText("<font color=\"#622181\">Paziente</font><font color=\"#9C9E9F\"> / </font><font color=\"#0B72B5\">Immagini</font>");
        
	QHBoxLayout *headerLayout = new QHBoxLayout();
	headerLayout->setContentsMargins(13, 13, 13, 0);
	headerLayout->addWidget(patientIcon);
	headerLayout->addSpacing(3);
	headerLayout->addWidget(headerText);
	headerLayout->setAlignment(headerText, Qt::AlignVCenter);
	headerLayout->addStretch();	
	headerLayout->addWidget(quitButton);
	
	QLabel *titleLabel = new QLabel("<font color=\"black\">Soggetto<br/></font> <font color=\"white\" >"+ title +"</font>", this);
	titleLabel->setMinimumHeight(100);
	titleLabel->setAutoFillBackground(true);
	titleLabel->setFont(QFont("helvetica"));
	titleLabel->setAlignment(Qt::AlignVCenter);
	QPalette titlePal(titleLabel->palette());
	titlePal.setColor(QPalette::Background, QColor(190,10,38));
	titleLabel->setPalette(titlePal);
	
	QLabel *note = new QLabel(text, this);
	note->setFont(QFont("helvetica"));
	QPalette notePal(note->palette());
	notePal.setColor(QPalette::Text, Qt::black);
	note->setPalette(notePal);
	note->setWordWrap(true);
	note->setAlignment(Qt::AlignJustify);
	note->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	
	QScrollArea *scrollArea = new QScrollArea();
	scrollArea->setWidgetResizable(true);
	scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	scrollArea->setWidget(note);
	scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	
	QVBoxLayout *mainLayout = new QVBoxLayout();
	mainLayout->addLayout(headerLayout);
	mainLayout->addWidget(titleLabel);
	
	QHBoxLayout *backHLayout = new QHBoxLayout();
	backHLayout->setContentsMargins(15, 0,0,0);
	backHLayout->addWidget(backButton);
	
	QHBoxLayout *scrollLayout = new QHBoxLayout();
	scrollLayout->addWidget(scrollArea);
	scrollLayout->setAlignment(scrollArea, Qt::AlignVCenter);
	mainLayout->addLayout(scrollLayout);
	mainLayout->addStretch(3);
	mainLayout->addLayout(backHLayout);
	mainLayout->addStretch(1);
	mainLayout->addWidget(footer);
			
	setLayout(mainLayout);
}
QWidget*
PartitionViewStep::createSummaryWidget() const
{
    QWidget* widget = new QWidget;
    QVBoxLayout* mainLayout = new QVBoxLayout;
    widget->setLayout( mainLayout );
    mainLayout->setMargin( 0 );

    ChoicePage::Choice choice = m_choicePage->currentChoice();

    QFormLayout* formLayout = new QFormLayout( widget );
    const int MARGIN = CalamaresUtils::defaultFontHeight() / 2;
    formLayout->setContentsMargins( MARGIN, 0, MARGIN, MARGIN );
    mainLayout->addLayout( formLayout );

    QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo();
    if ( list.length() > 1 ) // There are changes on more than one disk
    {
        //NOTE: all of this should only happen when Manual partitioning is active.
        //      Any other choice should result in a list.length() == 1.
        QLabel* modeLabel = new QLabel;
        formLayout->addRow( modeLabel );
        QString modeText;
        switch ( choice )
        {
        case ChoicePage::Alongside:
            modeText = tr( "Install %1 <strong>alongside</strong> another operating system." )
                       .arg( Calamares::Branding::instance()->
                             string( Calamares::Branding::ShortVersionedName ) );
            break;
        case ChoicePage::Erase:
            modeText = tr( "<strong>Erase</strong> disk and install %1." )
                       .arg( Calamares::Branding::instance()->
                             string( Calamares::Branding::ShortVersionedName ) );
            break;
        case ChoicePage::Replace:
            modeText = tr( "<strong>Replace</strong> a partition with %1." )
                       .arg( Calamares::Branding::instance()->
                             string( Calamares::Branding::ShortVersionedName ) );
            break;
        default:
            modeText = tr( "<strong>Manual</strong> partitioning." );
        }
        modeLabel->setText( modeText );
    }
    for ( const auto& info : list )
    {
        QLabel* diskInfoLabel = new QLabel;
        if ( list.length() == 1 ) // this is the only disk preview
        {
            QString modeText;
            switch ( choice )
            {
            case ChoicePage::Alongside:
                modeText = tr( "Install %1 <strong>alongside</strong> another operating system on disk <strong>%2</strong> (%3)." )
                           .arg( Calamares::Branding::instance()->
                                 string( Calamares::Branding::ShortVersionedName ) )
                           .arg( info.deviceNode )
                           .arg( info.deviceName );
                break;
            case ChoicePage::Erase:
                modeText = tr( "<strong>Erase</strong> disk <strong>%2</strong> (%3) and install %1." )
                           .arg( Calamares::Branding::instance()->
                                 string( Calamares::Branding::ShortVersionedName ) )
                           .arg( info.deviceNode )
                           .arg( info.deviceName );
                break;
            case ChoicePage::Replace:
                modeText = tr( "<strong>Replace</strong> a partition on disk <strong>%2</strong> (%3) with %1." )
                           .arg( Calamares::Branding::instance()->
                                 string( Calamares::Branding::ShortVersionedName ) )
                           .arg( info.deviceNode )
                           .arg( info.deviceName );
                break;
            default:
                modeText = tr( "<strong>Manual</strong> partitioning on disk <strong>%1</strong> (%2)." )
                           .arg( info.deviceNode )
                           .arg( info.deviceName );
            }
            diskInfoLabel->setText( modeText );
        }
        else // multiple disk previews!
        {
            diskInfoLabel->setText( tr( "Disk <strong>%1</strong> (%2)" )
                                        .arg( info.deviceNode )
                                        .arg( info.deviceName ) );
        }
        formLayout->addRow( diskInfoLabel );

        PartitionBarsView* preview;
        PartitionLabelsView* previewLabels;
        QVBoxLayout* field;

        preview = new PartitionBarsView;
        previewLabels = new PartitionLabelsView;
        preview->setModel( info.partitionModelBefore );
        previewLabels->setModel( info.partitionModelBefore );
        info.partitionModelBefore->setParent( widget );
        field = new QVBoxLayout;
        CalamaresUtils::unmarginLayout( field );
        field->setSpacing( 6 );
        field->addWidget( preview );
        field->addWidget( previewLabels );
        formLayout->addRow( tr( "Current state:" ), field );

        preview = new PartitionBarsView;
        previewLabels = new PartitionLabelsView;
        preview->setModel( info.partitionModelAfter );
        previewLabels->setModel( info.partitionModelAfter );
        info.partitionModelAfter->setParent( widget );
        field = new QVBoxLayout;
        CalamaresUtils::unmarginLayout( field );
        field->setSpacing( 6 );
        field->addWidget( preview );
        field->addWidget( previewLabels );
        formLayout->addRow( tr( "Your changes:" ), field );
    }
    QStringList jobsLines;
    foreach ( const Calamares::job_ptr& job, jobs() )
    {
        if ( !job->prettyDescription().isEmpty() )
        jobsLines.append( job->prettyDescription() );
    }
    if ( !jobsLines.isEmpty() )
    {
        QLabel* jobsLabel = new QLabel( widget );
        mainLayout->addWidget( jobsLabel );
        jobsLabel->setText( jobsLines.join( "<br/>" ) );
        int m = CalamaresUtils::defaultFontHeight() / 2;
        jobsLabel->setMargin( CalamaresUtils::defaultFontHeight() / 2 );
        QPalette pal;
        pal.setColor( QPalette::Background, pal.background().color().lighter( 108 ) );
        jobsLabel->setAutoFillBackground( true );
        jobsLabel->setPalette( pal );
    }
    return widget;
}