aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm-dev/ScrollDialog.h
blob: eefe62f491672c35cba55afd1ce44a9cd76c8e52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//===========================================
//  Lumina-DE source code
//  Copyright (c) 2014, Ken Moore
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
//  This is the dialog for showing a lot of text in a scrollable format (instead of QMessageBox)
//===========================================
#ifndef _LUMINA_FILE_MANAGER_SCROLL_DIALOG_H
#define _LUMINA_FILE_MANAGER_SCROLL_DIALOG_H

#include <QDialog>
#include <QVBoxLayout>
#include <QTextEdit>
#include <QDialogButtonBox>

class ScrollDialog : public QDialog{
	Q_OBJECT
	
private:
	QDialogButtonBox *buttons;
	QTextEdit *label;
	QVBoxLayout *layout1;

public:
	ScrollDialog(QWidget *parent = 0) : QDialog(parent){
	  //Create the widgets
	  buttons = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, this);
	  label = new QTextEdit(this);
	    label->setReadOnly(true);
	    label->setWordWrapMode(QTextOption::NoWrap);
	  layout1 = new QVBoxLayout(this);
	  //Put them in the dialog
	  layout1->addWidget(label);
	  layout1->addWidget(buttons);
	  this->setLayout(layout1);
	  //Connect signals/slots
	  connect(buttons, SIGNAL(accepted()), this, SLOT(accept()) );
	  connect(buttons, SIGNAL(rejected()), this, SLOT(reject()) );
	  //Set a useful size/position
	  this->resize(400,200);
	  if(parent!=0){
	    QPoint ctr = parent->mapToGlobal(parent->geometry().center());
	    this->move( ctr.x()-(this->width()/2), ctr.y()-(this->height()/2) );
	  }
	}
	~ScrollDialog(){}

	void setText(QString txt){
	  label->setPlainText(txt);
	  //this->resize( label->fontMetrics().width(txt.section("\n",0,0))+30, this->height());
	}

};
#endif
bgstack15