Ejemplo n.º 1
0
UpdateDialog::UpdateDialog(QWidget *parent, const QString& releaseNotes, const QString& latestVersion, const QUrl& downloadURL) :
    QDialog(parent),
    _latestVersion(latestVersion),
    _downloadUrl(downloadURL)
{
    Ui::Dialog dialogUI;
    dialogUI.setupUi(this);
    
    QString updateRequired = QString("You are currently running build %1, the latest build released is %2."
                                     "\n\nPlease download and install the most recent release to access the latest features and bug fixes.")
                                      .arg(Application::getInstance()->applicationVersion(), latestVersion);
    
    setAttribute(Qt::WA_DeleteOnClose);
    
    QPushButton* downloadButton = findChild<QPushButton*>("downloadButton");
    QPushButton* skipButton = findChild<QPushButton*>("skipButton");
    QPushButton* closeButton = findChild<QPushButton*>("closeButton");
    QLabel* updateContent = findChild<QLabel*>("updateContent");
    
    updateContent->setText(updateRequired);
    
    connect(downloadButton, SIGNAL(released()), this, SLOT(handleDownload()));
    connect(skipButton, SIGNAL(released()), this, SLOT(handleSkip()));
    connect(closeButton, SIGNAL(released()), this, SLOT(close()));
    
    QMetaObject::invokeMethod(this, "show", Qt::QueuedConnection);
}
Ejemplo n.º 2
0
/* Find/Replace dialog */
TextFindDialog::TextFindDialog(QPlasmaTextDoc* parent, bool replace)
              : QDialog(parent)
{
    s_findSettings.current = this;
    fDocument = parent;
    setAttribute(Qt::WA_DeleteOnClose);
    if (replace) {
        setWindowTitle(tr("Replace..."));
        setWindowIcon(qStdIcon("edit-find-replace"));
    } else {
        setWindowTitle(tr("Find..."));
        setWindowIcon(qStdIcon("edit-find"));
    }

    fFindText = new QLineEdit(s_findSettings.text, this);
    if (replace)
        fNewText = new QLineEdit(s_findSettings.newText, this);
    else
        fNewText = NULL;
    fCaseSensitive = new QCheckBox(tr("&Case sensitive"), this);
    fRegEx = new QCheckBox(tr("&Regular expression search"), this);
    fWholeWord = new QCheckBox(tr("Match &whole word"), this);
    fReverse = new QCheckBox(tr("Search &up"), this);
    fFindText->selectAll();
    fCaseSensitive->setChecked(s_findSettings.cs);
    fRegEx->setChecked(s_findSettings.regex);
    fWholeWord->setChecked(s_findSettings.wo);
    fReverse->setChecked(s_findSettings.reverse);

    QWidget* buttonPanel = new QWidget(this);
    QPushButton* btnFind = new QPushButton(replace ? tr("&Replace") : tr("&Find"), buttonPanel);
    QPushButton* btnReplaceAll = NULL;
    if (replace) {
        btnReplaceAll = new QPushButton(tr("Replace &All"), buttonPanel);
        fBtnSkip = new QPushButton(tr("&Skip"), buttonPanel);
        fBtnSkip->setEnabled(false);
    }
    QPushButton* btnCancel = new QPushButton(tr("&Cancel"), buttonPanel);

    QGridLayout* buttonLayout = new QGridLayout(buttonPanel);
    buttonLayout->setContentsMargins(0, 0, 0, 0);
    buttonLayout->setVerticalSpacing(4);
    int idx = 0;
    buttonLayout->addWidget(btnFind, idx++, 0);
    if (replace) {
        buttonLayout->addWidget(btnReplaceAll, idx++, 0);
        buttonLayout->addWidget(fBtnSkip, idx++, 0);
    }
    buttonLayout->addWidget(btnCancel, idx++, 0);
    buttonLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), idx, 0);

    QGridLayout* layout = new QGridLayout(this);
    layout->setContentsMargins(8, 8, 8, 8);
    layout->setVerticalSpacing(4);
    layout->setHorizontalSpacing(8);
    idx = 0;
    layout->addWidget(new QLabel(tr("Search string:"), this), idx, 0);
    layout->addWidget(fFindText, idx++, 1);
    if (replace) {
        layout->addWidget(new QLabel(tr("Replace with:"), this), idx, 0);
        layout->addWidget(fNewText, idx++, 1);
    }
    layout->addItem(new QSpacerItem(0, 16, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum), idx++, 0, 1, 2);
    layout->addWidget(fCaseSensitive, idx++, 1);
    layout->addWidget(fRegEx, idx++, 1);
    layout->addWidget(fWholeWord, idx++, 1);
    layout->addWidget(fReverse, idx++, 1);
    layout->addWidget(buttonPanel, 0, 2, idx, 1);

    connect(btnFind, SIGNAL(clicked()), this, SLOT(handleFind()));
    connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
    if (replace) {
        connect(btnReplaceAll, SIGNAL(clicked()), this, SLOT(handleReplaceAll()));
        connect(fBtnSkip, SIGNAL(clicked()), this, SLOT(handleSkip()));
    }

    resize(sizeHint().width() * 1.5, sizeHint().height());
}