Exemple #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);
}
Exemple #2
0
void DBConfigDialog::initInterface()
{
    QGroupBox * group = new QGroupBox(conv("Параметры"));
    group->setStyle(new QPlastiqueStyle);
    {
        int port;
        QString name, host;
        QString user, password;

        if (!Settings::readConfig(name, host, port, user, password))
            emit information(new Exception(conv("Ошибка чтения настроек подключения к базе"), 103));

        QFormLayout * fLayout =  new QFormLayout;
        edtDatabaseName = new QLineEdit(name);
        fLayout->addRow(conv("Название"), edtDatabaseName);
        edtDatabaseHost = new QLineEdit(host);
        QHBoxLayout * hLayout = new QHBoxLayout;
        hLayout->addWidget(edtDatabaseHost);
        hLayout->addWidget(new QLabel(conv("Порт")));
        edtDatabasePort = new QSpinBox;
        edtDatabasePort->setRange(1, 65535);
        edtDatabasePort->setValue(port);
        hLayout->addWidget(edtDatabasePort);
        fLayout->addRow(conv("Адрес"), hLayout);
        edtDatabaseUser = new QLineEdit(user);
        fLayout->addRow(conv("Пользователь"), edtDatabaseUser);
        edtDatabasePassword = new QLineEdit(password);
        edtDatabasePassword->setEchoMode(QLineEdit::Password);
        fLayout->addRow(conv("Пароль"), edtDatabasePassword);
        hLayout = new QHBoxLayout;
        chkConnectionState = new QCheckBox;
        chkConnectionState->setFixedSize(QSize(20, 20));
        chkConnectionState->setStyleSheet("QCheckBox::indicator:unchecked { image: url(:/images/unchecked) }"
                                          "QCheckBox::indicator:checked { image: url(:/images/checked) }");

        lblConnectionState = new BlinkLabel(conv("Не подключен"));
        lblConnectionState->setFixedWidth(120);
        lblConnectionState->setMargin(10);
        lblConnectionState->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
        btnCheckConnection = new QPushButton(conv("Проверка"));
        btnCheckConnection->setFixedWidth(100);
        hLayout->addStretch();
        hLayout->addWidget(chkConnectionState);
        hLayout->addWidget(lblConnectionState);
        hLayout->addWidget(btnCheckConnection);
        fLayout->addRow(hLayout);
        group->setLayout(fLayout);
    }

    QVBoxLayout * vLayout = new QVBoxLayout;
    vLayout->addWidget(group);

    btnApply = new QPushButton(conv("Применить"));
    btnApply->setFixedWidth(100);
    btnExit = new QPushButton(conv("Выход"));
    btnExit->setFixedWidth(100);
    QHBoxLayout * hLayout = new QHBoxLayout;
    hLayout->addStretch();
    hLayout->addWidget(btnApply);
    hLayout->addWidget(btnExit);

    vLayout->addLayout(hLayout);
    setLayout(vLayout);
}