예제 #1
0
파일: strip.cpp 프로젝트: songo/muse
Strip::Strip(QWidget* parent, MusECore::Track* t, bool hasHandle)
   : QFrame(parent)
      {
      setMouseTracking(true);
      
      _curGridRow = 0;
      _userWidth = 0;
      autoType = 0;
      _visible = true;
      dragOn=false;
      setAttribute(Qt::WA_DeleteOnClose);
      iR            = 0;
      oR            = 0;
      
      ///setBackgroundRole(QPalette::Mid);
      setFrameStyle(Panel | Raised);
      setLineWidth(2);
      
      track    = t;
      meter[0] = 0;
      meter[1] = 0;
      setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding));
      
      grid = new QGridLayout();
      grid->setContentsMargins(0, 0, 0, 0);
      grid->setSpacing(0);
      
      _handle = 0;
      if(hasHandle)
      {
        _handle = new ExpanderHandle();
        connect(_handle, SIGNAL(moved(int)), SLOT(changeUserWidth(int)));
        QHBoxLayout* hlayout = new QHBoxLayout(this);
        hlayout->setContentsMargins(0, 0, 0, 0);
        hlayout->setSpacing(0);
        hlayout->addLayout(grid);
        hlayout->addWidget(_handle);
      }
      else
      {
        setLayout(grid);
      }
        
      //---------------------------------------------
      //    label
      //---------------------------------------------

      //label = new QLabel(this);
      // NOTE: This was required, otherwise the strip labels have no colour in the mixer only - track info OK !
      // Not sure why...
      label = new QLabel(this);
      label->setObjectName(track->cname());
      label->setTextFormat(Qt::PlainText);
      
      // Unfortunately for the mixer labels, QLabel doesn't support the BreakAnywhere flag.
      // Changed by Tim. p3.3.9
      //label->setAlignment(AlignCenter);
      //label->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
      // MusE-2 Tested: TextWrapAnywhere actually works, but in fact it takes precedence 
      //  over word wrap, so I found it is not really desirable. Maybe with a user setting...
      //label->setAlignment(Qt::AlignCenter | Qt::TextWordWrap | Qt::TextWrapAnywhere);
      // changed by Orcan: We can't use Qt::TextWordWrap in alignment in Qt4.
      label->setAlignment(Qt::AlignCenter);
      label->setWordWrap(true);
      label->setAutoFillBackground(true);
      label->setLineWidth(2);
      label->setFrameStyle(Sunken | StyledPanel);
      
      label->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
      
      setLabelText();
      setLabelFont();
      
      grid->addWidget(label, _curGridRow++, 0, 1, 3); // REMOVE Tim. Trackinfo. Changed. TEST
      }
예제 #2
0
/** The constructor for a single set of widgets containing parameters for the labeling and format of an axis.
*  @param app :: the containing application window
*  @param graph :: the graph the dialog is settign the options for
*  @param mappedaxis :: the QwtPlot::axis value that corresponds to this axis
*  @param parent :: the QWidget that acts as this widget's parent in the hierachy
*/
AxisDetails::AxisDetails(ApplicationWindow* app, Graph* graph, int mappedaxis, QWidget *parent) : QWidget(parent)
{
  m_app = app;
  m_graph = graph;
  m_tablesList = m_app->tableNames();
  m_mappedaxis = mappedaxis;
  m_initialised = false;
  QHBoxLayout * topLayout = new QHBoxLayout();

  m_chkShowAxis = new QCheckBox(tr("Show"));
  topLayout->addWidget(m_chkShowAxis);

  m_grpTitle = new QGroupBox(tr("Title"));
  topLayout->addWidget(m_grpTitle);

  QVBoxLayout *titleBoxLayout = new QVBoxLayout(m_grpTitle);
  titleBoxLayout->setSpacing(2);

  m_txtTitle = new QTextEdit();
  m_txtTitle->setTextFormat(Qt::PlainText);
  QFontMetrics metrics(this->font());
  m_txtTitle->setMaximumHeight(3 * metrics.height());
  titleBoxLayout->addWidget(m_txtTitle);

  QHBoxLayout *hl = new QHBoxLayout();
  hl->setMargin(0);
  hl->setSpacing(2);
  m_btnLabelFont = new QPushButton(tr("&Font"));
  hl->addWidget(m_btnLabelFont);

  m_formatButtons = new TextFormatButtons(m_txtTitle, TextFormatButtons::AxisLabel);
  hl->addWidget(m_formatButtons);
  hl->addStretch();

  m_txtTitle->setMaximumWidth(m_btnLabelFont->width() + m_formatButtons->width());
  titleBoxLayout->addLayout(hl);

  QHBoxLayout * bottomLayout = new QHBoxLayout();

  m_grpAxisDisplay = new QGroupBox(QString());
  bottomLayout->addWidget(m_grpAxisDisplay);
  QGridLayout * leftBoxLayout = new QGridLayout(m_grpAxisDisplay);

  leftBoxLayout->addWidget(new QLabel(tr("Type")), 0, 0);

  m_cmbAxisType = new QComboBox();
  m_cmbAxisType->addItem(tr("Numeric"));
  m_cmbAxisType->addItem(tr("Text from table"));
  m_cmbAxisType->addItem(tr("Day of the week"));
  m_cmbAxisType->addItem(tr("Month"));
  m_cmbAxisType->addItem(tr("Time"));
  m_cmbAxisType->addItem(tr("Date"));
  m_cmbAxisType->addItem(tr("Column Headings"));
  leftBoxLayout->addWidget(m_cmbAxisType, 0, 1);

  leftBoxLayout->addWidget(new QLabel(tr("Font")), 1, 0);

  m_btnAxesFont = new QPushButton();
  m_btnAxesFont->setText(tr("Axis &Font"));
  leftBoxLayout->addWidget(m_btnAxesFont, 1, 1);

  leftBoxLayout->addWidget(new QLabel(tr("Color")), 2, 0);
  m_cbtnAxisColor = new ColorButton();
  leftBoxLayout->addWidget(m_cbtnAxisColor, 2, 1);

  leftBoxLayout->addWidget(new QLabel(tr("Major Ticks")), 3, 0);

  m_cmbMajorTicksType = new QComboBox();
  m_cmbMajorTicksType->addItem(tr("None"));
  m_cmbMajorTicksType->addItem(tr("Out"));
  m_cmbMajorTicksType->addItem(tr("In & Out"));
  m_cmbMajorTicksType->addItem(tr("In"));
  leftBoxLayout->addWidget(m_cmbMajorTicksType, 3, 1);

  leftBoxLayout->addWidget(new QLabel(tr("Minor Ticks")), 4, 0);

  m_cmbMinorTicksType = new QComboBox();
  m_cmbMinorTicksType->addItem(tr("None"));
  m_cmbMinorTicksType->addItem(tr("Out"));
  m_cmbMinorTicksType->addItem(tr("In & Out"));
  m_cmbMinorTicksType->addItem(tr("In"));
  leftBoxLayout->addWidget(m_cmbMinorTicksType, 4, 1);

  leftBoxLayout->addWidget(new QLabel(tr("Stand-off")), 5, 0);
  m_spnBaseline = new QSpinBox();
  m_spnBaseline->setRange(0, 1000);
  leftBoxLayout->addWidget(m_spnBaseline);

  m_grpShowLabels = new QGroupBox(tr("Show Labels"));
  m_grpShowLabels->setCheckable(true);
  m_grpShowLabels->setChecked(true);

  bottomLayout->addWidget(m_grpShowLabels);
  QGridLayout *rightBoxLayout = new QGridLayout(m_grpShowLabels);

  m_lblColumn = new QLabel(tr("Column"));
  rightBoxLayout->addWidget(m_lblColumn, 0, 0);

  m_cmbColName = new QComboBox();
  rightBoxLayout->addWidget(m_cmbColName, 0, 1);

  m_lblTable = new QLabel(tr("Table"));
  rightBoxLayout->addWidget(m_lblTable, 1, 0);

  m_cmbTableName = new QComboBox();
  m_cmbTableName->insertStringList(m_tablesList);
  m_cmbColName->insertStringList(m_app->columnsList(Table::All));
  rightBoxLayout->addWidget(m_cmbTableName, 1, 1);

  m_lblFormat = new QLabel(tr("Format"));
  rightBoxLayout->addWidget(m_lblFormat, 2, 0);

  m_cmbFormat = new QComboBox();
  m_cmbFormat->setDuplicatesEnabled(false);
  rightBoxLayout->addWidget(m_cmbFormat, 2, 1);

  m_lblPrecision = new QLabel(tr("Precision"));
  rightBoxLayout->addWidget(m_lblPrecision, 3, 0);
  m_spnPrecision = new QSpinBox();
  m_spnPrecision->setRange(0, 10);
  rightBoxLayout->addWidget(m_spnPrecision, 3, 1);

  rightBoxLayout->addWidget(new QLabel(tr("Angle")), 4, 0);

  m_spnAngle = new QSpinBox();
  m_spnAngle->setRange(-90, 90);
  m_spnAngle->setSingleStep(5);
  rightBoxLayout->addWidget(m_spnAngle, 4, 1);

  rightBoxLayout->addWidget(new QLabel(tr("Color")), 5, 0);
  m_cbtnAxisNumColor = new ColorButton();
  rightBoxLayout->addWidget(m_cbtnAxisNumColor, 5, 1);

  m_chkShowFormula = new QCheckBox(tr("For&mula"));
  rightBoxLayout->addWidget(m_chkShowFormula, 6, 0);

  m_txtFormula = new QTextEdit();
  m_txtFormula->setTextFormat(Qt::PlainText);
  m_txtFormula->setMaximumHeight(3 * metrics.height());
  //m_txtFormula->hide();
  rightBoxLayout->addWidget(m_txtFormula, 6, 1);
  rightBoxLayout->setRowStretch(7, 1);

  QVBoxLayout * rightLayout = new QVBoxLayout(this);
  rightLayout->addLayout(topLayout);
  rightLayout->addLayout(bottomLayout);
  rightLayout->addStretch(1);

  connect(m_chkShowFormula, SIGNAL(clicked()), this, SLOT(enableFormulaBox()));
  connect(m_cmbAxisType, SIGNAL(activated(int)), this, SLOT(setAxisFormatOptions(int)));

  connect(m_grpShowLabels, SIGNAL(clicked(bool)), this,  SLOT(showAxis()));
  connect(m_chkShowAxis, SIGNAL(clicked()), this, SLOT(showAxis()));
  connect(m_cmbFormat, SIGNAL(activated(int)), this,  SLOT(showAxis()));

  connect(m_btnAxesFont, SIGNAL(clicked()), this, SLOT(setScaleFont()));
  connect(m_btnLabelFont, SIGNAL(clicked()), this, SLOT(setLabelFont()));

  initWidgets();
}