Skip to content

Commit 0500ff3

Browse files
committed
showtextdlg: extract same UI rendering to renderDialog()
1 parent f4e74ab commit 0500ff3

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/showtextdlg.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,19 @@
2525
// FIXME: combine to common init function
2626
ShowTextDlg::ShowTextDlg(const QString &fname, bool rich, QWidget *parent) : QDialog(parent)
2727
{
28-
setAttribute(Qt::WA_DeleteOnClose);
29-
ui_.setupUi(this);
30-
3128
QString text = FileUtil::readFileText(fname);
32-
ui_.textEdit->setAcceptRichText(rich);
33-
ui_.textEdit->setText(text);
34-
if (rich) {
35-
ui_.textEdit->setTextInteractionFlags(Qt::TextBrowserInteraction);
36-
}
37-
38-
resize(560, 384);
29+
renderDialog(text, rich);
3930
}
4031

4132
ShowTextDlg::ShowTextDlg(const QString &text, bool nonfile, bool rich, QWidget *parent) : QDialog(parent)
4233
{
4334
Q_UNUSED(nonfile);
4435

36+
renderDialog(text, rich);
37+
}
38+
39+
void ShowTextDlg::renderDialog(const QString &text, bool rich)
40+
{
4541
setAttribute(Qt::WA_DeleteOnClose);
4642
ui_.setupUi(this);
4743

src/showtextdlg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ShowTextDlg : public QDialog {
3131
ShowTextDlg(const QString &text, bool nonfile, bool rich, QWidget *parent);
3232
private:
3333
Ui::ShowTextDlg ui_;
34+
void renderDialog(const QString &text, bool rich);
3435
};
3536

3637
#endif // CS_SHOWTEXTDLG_H

0 commit comments

Comments
 (0)