-
Notifications
You must be signed in to change notification settings - Fork 0
/
modify_text.cpp
80 lines (75 loc) · 2.13 KB
/
modify_text.cpp
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "modify_text.h"
#include "ui_modify_text.h"
Modify_text::Modify_text(QWidget *parent, QCPAxis *axis, QFont &x, QFont &y, QString &xlab, QString &ylab) :
QDialog(parent), //axis_local(axis),
ui(new Ui::Modify_text)
{
ui->setupUi(this);
mode=0;
axis_local=axis;
xlabel_font=&x;
ylabel_font=&y;
xlabel=&xlab;
ylabel=&ylab;
#ifdef Q_OS_MAC
ui->label->setFont(QFont("Arial",14));
#endif
}
Modify_text::Modify_text(QWidget *parent, QCPTextElement* &title):
QDialog (parent), ui(new Ui::Modify_text)
{
ui->setupUi(this);
title_local=title;
mode=1;
#ifdef Q_OS_MAC
ui->label->setFont(QFont("Arial",14));
#endif
}
Modify_text::~Modify_text()
{
delete ui;
}
void Modify_text::on_font_clicked(){
hide();
bool ok{};
if (mode==0){
QFont font = QFontDialog::getFont(&ok, axis_local->labelFont(), this, "PLIS - Choose Font");
if (ok){
if (axis_local->axisType()==QCPAxis::atBottom)
*xlabel_font=font;
else if(axis_local->axisType()==QCPAxis::atLeft)
*ylabel_font=font;
}
}
else if(mode==1){
QFont font = QFontDialog::getFont(&ok, title_local->font() , this, "PLIS - Choose Font");
if (ok){
title_local->setFont(font);
}
}
}
void Modify_text::on_label_text_clicked()
{
hide();
bool ok{};
if(mode==0){
QString label = QInputDialog::getText(this, "PLIS", "New axis label:", QLineEdit::Normal, axis_local->label(), &ok);
if (ok && label!="")
{
if (axis_local->axisType()==QCPAxis::atBottom)
*xlabel=label;
else if(axis_local->axisType()==QCPAxis::atLeft)
*ylabel=label;
}
}
else if(mode==1){
QString newTitle = QInputDialog::getText(this, "PLIS", "New plot title:", QLineEdit::Normal, title_local->text(), &ok);
if (ok && newTitle!="")
title_local->setText(newTitle);
}
}
void Modify_text::on_both_clicked()
{
on_font_clicked();
on_label_text_clicked();
}