Example #1
0
FindDialog::FindDialog(EditorPane *parent, bool replace, bool hasSelection)
   : QDialog(parent), m_parent(parent), m_searching(false), m_modifiable(true)
{
   QStyle *style = new QCleanlooksStyle();
   setFont(QFont("arial", 10));
   const QFont font("arial", 9);
   
   // assure EditorPane is notified upon invocation of find/replace
//   connect(this, SIGNAL(accepted()), m_parent, SLOT(findDialogInvoked()));
   
   setWindowTitle(tr("Find"));
   QGridLayout *mainLayout = new QGridLayout();
   QVBoxLayout *layout = new QVBoxLayout();
   
   // Find section
   QGroupBox *box = new QGroupBox(tr("Find"), this);
   box->setStyle(style);
   QLabel *label = new QLabel(tr("Text to find:"), this);
   m_lineEdit = new QLineEdit(this);
   connect(m_lineEdit, SIGNAL(returnPressed()), this, SLOT(accept()));
   
   m_regularExpression = new QCheckBox(tr("Regular e&xpression"), this);
   m_regularExpression->setStyle(style);
   m_regularExpression->setFont(font);
   
   layout->addWidget(label);
   layout->addWidget(m_lineEdit);
   layout->addWidget(m_regularExpression);
   layout->addStretch(1);
   box->setLayout(layout);
   
   mainLayout->addWidget(box, 0, 0, 1, 3);
   
   // Replace section
   m_replaceWidget = new ReplaceWidget(this, style);
   m_replaceWidget->setChecked(replace);
   connect(m_replaceWidget, SIGNAL(toggled(bool)), this, SLOT(updateReplace(bool)));
   mainLayout->addWidget(m_replaceWidget, 1, 0, 1, 3);
   
   // Options section
   QGridLayout *l = new QGridLayout();
   box = new QGroupBox(tr("Options"), this);
   box->setStyle(style);
   QCheckBox *b = new QCheckBox(tr("C&ase sensitive"), this);
   m_caseSensitive = b;
   b->setStyle(style);
   b->setFont(font);
   l->addWidget(b, 0, 0);
   b = new QCheckBox(tr("&Whole words only"), this);
   m_wholeWordsOnly = b;
   b->setStyle(style);
   b->setFont(font);
   l->addWidget(b, 1, 0);
   l->setColumnMinimumWidth(0, b->sizeHint().width() + 10); // hack cause this layout manager apparently has trouble w/ multiple styles
   b = new QCheckBox(tr("From c&ursor"), this);
   m_fromCursor = b;
   b->setStyle(style);
   b->setFont(font);
   l->addWidget(b, 2, 0);
   b = new QCheckBox(tr("Find &backwards"), this);
   m_findBackwards = b;
   b->setStyle(style);
   b->setFont(font);
   l->addWidget(b, 0, 1);
   b = new QCheckBox(tr("&Search selection"), this);
   m_searchSelection = b;
   b->setStyle(style);
   b->setFont(font);
   b->setEnabled(hasSelection);
   l->setColumnMinimumWidth(1, b->sizeHint().width() + 10); // hack cause this layout manager apparently has trouble w/ multiple styles
   connect(m_parent, SIGNAL(copyAvailabile(bool)), b, SLOT(setEnabled(bool)));
   
   l->addWidget(b, 1, 1);
/*   b = new QCheckBox(tr("&Prompt on replace"), this);
   m_promptOnReplace = b;
   b->setStyle(style);
   b->setEnabled(replace);
   connect(m_replaceWidget, SIGNAL(toggled(bool)), b, SLOT(setEnabled(bool)));
   l->addWidget(b, 2, 1);*/
   
   box->setLayout(l);
   mainLayout->addWidget(box, 2, 0, 1, 3);
   
   // Bottom buttons (invoke, cancel, replaceAll)
   m_invoked = new QPushButton((replace ? "&Replace" : "&Find"));
   m_invoked->setAutoDefault(true);
   m_invoked->setStyle(style);
   connect(m_invoked, SIGNAL(clicked()), this, SLOT(accept()));
   mainLayout->addWidget(m_invoked, 3, 0);//, Qt::AlignRight);
   
   m_cancel = new QPushButton("&Cancel");
   m_cancel->setAutoDefault(false);
   m_cancel->setStyle(style);
   connect(m_cancel, SIGNAL(clicked()), this, SLOT(reject()));
   mainLayout->addWidget(m_cancel, 3, 2);//, Qt::AlignRight);
   
   m_replaceAll = new QPushButton("Replace &All");
   m_replaceAll->setAutoDefault(false);
   m_replaceAll->setStyle(style);
   connect(m_replaceAll, SIGNAL(clicked()), this, SLOT(replaceAll()));
   mainLayout->addWidget(m_replaceAll, 3, 1);
 
   mainLayout->setSizeConstraint(QLayout::SetFixedSize);

   updateReplace(replace);
   setLayout(mainLayout);
   setModal(false);
}
Example #2
0
void VPiano::initExtraControllers()
{
    QWidget *w = NULL;
    QCheckBox *chkbox = NULL;
    Knob *knob = NULL;
    QSpinBox *spin = NULL;
    QSlider *slider = NULL;
    QToolButton *button = NULL;
    foreach(const QString& s, m_extraControls) {
        QString lbl;
        int control = 0;
        int type = 0;
        int minValue = 0;
        int maxValue = 127;
        int defValue = 0;
        int value = 0;
        int size = 100;
        QString fileName;
        ExtraControl::decodeString( s, lbl, control, type,
                                    minValue, maxValue, defValue,
                                    size, fileName );
        if (m_ctlState[m_channel].contains(control))
            value = m_ctlState[m_channel][control];
        else
            value = defValue;
        switch(type) {
        case 0:
            chkbox = new QCheckBox(this);
            if (dlgPreferences()->getStyledWidgets()) {
                chkbox->setStyle(m_dialStyle);
            }
            chkbox->setProperty(MIDICTLONVALUE, maxValue);
            chkbox->setProperty(MIDICTLOFFVALUE, minValue);
            chkbox->setChecked(bool(value));
            connect(chkbox, SIGNAL(clicked(bool)), SLOT(slotControlClicked(bool)));
            w = chkbox;
            break;
        case 1:
            knob = new Knob(this);
            knob->setFixedSize(32, 32);
            knob->setStyle(dlgPreferences()->getStyledWidgets()? m_dialStyle : NULL);
            knob->setMinimum(minValue);
            knob->setMaximum(maxValue);
            knob->setValue(value);
            knob->setToolTip(QString::number(value));
            knob->setDefaultValue(defValue);
            knob->setDialMode(Knob::LinearMode);
            connect(knob, SIGNAL(sliderMoved(int)), SLOT(slotExtraController(int)));
            w = knob;
            break;
        case 2:
            spin = new QSpinBox(this);
            spin->setMinimum(minValue);
            spin->setMaximum(maxValue);
            spin->setValue(value);
            connect(spin, SIGNAL(valueChanged(int)), SLOT(slotExtraController(int)));
            w = spin;
            break;
        case 3:
            slider = new QSlider(this);
            slider->setOrientation(Qt::Horizontal);
            slider->setFixedWidth(size);
            slider->setMinimum(minValue);
            slider->setMaximum(maxValue);
            slider->setToolTip(QString::number(value));
            slider->setValue(value);
            connect(slider, SIGNAL(sliderMoved(int)), SLOT(slotExtraController(int)));
            w = slider;
            break;
        case 4:
            button = new QToolButton(this);
            button->setText(lbl);
            button->setProperty(MIDICTLONVALUE, maxValue);
            button->setProperty(MIDICTLOFFVALUE, minValue);
            connect(button, SIGNAL(clicked(bool)), SLOT(slotControlClicked(bool)));
            w = button;
            break;
        case 5:
            control = 255;
            button = new QToolButton(this);
            button->setText(lbl);
            button->setProperty(SYSEXFILENAME, fileName);
            button->setProperty(SYSEXFILEDATA, readSysexDataFile(fileName));
            connect(button, SIGNAL(clicked(bool)), SLOT(slotControlClicked(bool)));
            w = button;
            break;
        default:
            w = NULL;
        }
        if (w != NULL) {
            if (!lbl.isEmpty() && type < 4) {
                QLabel *qlbl = new QLabel(lbl, this);
                qlbl->setMargin(TOOLBARLABELMARGIN);
                ui.toolBarExtra->addWidget(qlbl);
                //connect(qlbl, SIGNAL(destroyed(QObject*)), SLOT(slotDebugDestroyed(QObject*)));
            }
            w->setProperty(MIDICTLNUMBER, control);
            w->setFocusPolicy(Qt::NoFocus);
            ui.toolBarExtra->addWidget(w);
            //connect(w, SIGNAL(destroyed(QObject*)), SLOT(slotDebugDestroyed(QObject*)));
        }
    }