added text edit dialog to text effect
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#include "texteditdialog.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
TextEditDialog::TextEditDialog(QWidget *parent, const QString &s) :
|
||||
QDialog(parent)
|
||||
{
|
||||
setWindowTitle("Edit Text");
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
setLayout(layout);
|
||||
|
||||
textEdit = new QPlainTextEdit();
|
||||
textEdit->setPlainText(s);
|
||||
layout->addWidget(textEdit);
|
||||
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
layout->addWidget(buttons);
|
||||
connect(buttons, SIGNAL(accepted()), this, SLOT(save()));
|
||||
connect(buttons, SIGNAL(rejected()), this, SLOT(cancel()));
|
||||
}
|
||||
|
||||
const QString& TextEditDialog::get_string() {
|
||||
return result_str;
|
||||
}
|
||||
|
||||
void TextEditDialog::save() {
|
||||
result_str = textEdit->toPlainText();
|
||||
accept();
|
||||
}
|
||||
|
||||
void TextEditDialog::cancel() {
|
||||
reject();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef TEXTEDITDIALOG_H
|
||||
#define TEXTEDITDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QPlainTextEdit;
|
||||
|
||||
class TextEditDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TextEditDialog(QWidget* parent = 0, const QString& s = 0);
|
||||
const QString& get_string();
|
||||
private slots:
|
||||
void save();
|
||||
void cancel();
|
||||
private:
|
||||
QString result_str;
|
||||
QPlainTextEdit* textEdit;
|
||||
};
|
||||
|
||||
#endif // TEXTEDITDIALOG_H
|
||||
Reference in New Issue
Block a user