forked from BGmot/BGShellBB10
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysettingswindow.cpp
126 lines (110 loc) · 3.78 KB
/
mysettingswindow.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
* Copyright (C) 2013 BGmot <[email protected]>
*/
#include <QtGui/QPalette>
#include <QtGui/QLabel>
#include <QtCore/QSettings>
#include "qtermwidget.h"
#include "mymainwindow.h"
#include "mysettingswindow.h"
extern CMyMainWindow *mainWindow;
CMySettingsWindow::CMySettingsWindow(QWidget *parent) :
QWidget(parent)
{
setWindowModality(Qt::ApplicationModal);
}
int CMySettingsWindow::Init(){
QRect r = QApplication::desktop()->screenGeometry(0);
int nWidth = r.width();
int nHeight = nWidth;
this->setGeometry(0, 0, nWidth, nHeight);
QBrush brush1(QColor(76, 76, 76, 255));
brush1.setStyle(Qt::SolidPattern);
QPalette palette;
palette.setBrush(QPalette::Active, QPalette::Window, brush1);
this->setAutoFillBackground(true);
QGroupBox *gb = new QGroupBox(tr("Settings"), this);
gb->setGeometry(10, 2, this->width()-20, this->height()-20);
gb->setAlignment(Qt::AlignHCenter);
gb->setFlat(false);
// HTTP Proxy block
QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins(20, 10, 20, 20);
QLabel *lblProxy = new QLabel(tr("You might need to use HTTP Proxy for SSH connections if you installed the app in Work perimeter or you are behind restrictive firewall"
" but have HTTP proxy allowing CONNECT method and this proxy's IP/port configured in your smartphone's Settings"));
lblProxy->setWordWrap(true);
lblProxy->setAlignment(Qt::AlignHCenter);
layout->addWidget(lblProxy);
cbxProxyOn = new QCheckBox(tr(" Use HTTP Proxy"));
QSettings settings;
int nProxyOn = settings.value("HttpProxyOn").toInt();
if (nProxyOn)
cbxProxyOn->setChecked(true);
else
cbxProxyOn->setChecked(false);
layout->addWidget(cbxProxyOn);
// Font size block
QGroupBox *gb1 = new QGroupBox(tr("Terminal Font Size"), this);
gb1->setAlignment(Qt::AlignHCenter);
gb1->setFlat(false);
QHBoxLayout *hlayout = new QHBoxLayout;
gb1->setLayout(hlayout);
QRadioButton *rbtnSmall = new QRadioButton(tr("Small"));
QRadioButton *rbtnNorm = new QRadioButton(tr("Norm"));
QRadioButton *rbtnLarge = new QRadioButton(tr("Large"));
QRadioButton *rbtnXLarge = new QRadioButton(tr("XLarge"));
switch (mainWindow->nFontSize){
case 20:
rbtnSmall->setChecked(true);
break;
case 22:
rbtnNorm->setChecked(true);
break;
case 24:
rbtnLarge->setChecked(true);
break;
case 26:
rbtnXLarge->setChecked(true);
break;
default:
rbtnNorm->setChecked(true);
break;
}
btngrFontSize = new QButtonGroup();
btngrFontSize->addButton(rbtnSmall);
btngrFontSize->addButton(rbtnNorm);
btngrFontSize->addButton(rbtnLarge);
btngrFontSize->addButton(rbtnXLarge);
QObject::connect(btngrFontSize, SIGNAL(buttonPressed(QAbstractButton *)), this, SLOT(on_FontSizeChanged(QAbstractButton *)));
hlayout->addWidget(rbtnSmall);
hlayout->addWidget(rbtnNorm);
hlayout->addWidget(rbtnLarge);
hlayout->addWidget(rbtnXLarge);
layout->addWidget(gb1);
QLabel *lblHint = new QLabel(tr("\nHint: Swipe down again to hide this dialog"));
layout->addWidget(lblHint);
gb->setLayout(layout);
return 0;
}
extern QTermWidget *console;
void CMySettingsWindow::on_FontSizeChanged(QAbstractButton *button){
QString btn = button->text();
int nSize = 22;
if (!btn.compare(QString("Small"))){
nSize = 20;
}else if (!btn.compare(QString("Norm"))){
nSize = 22;
}else if (!btn.compare(QString("Large"))){
nSize = 24;
}else if (!btn.compare(QString("XLarge"))){
nSize = 26;
}
mainWindow->nFontSize = nSize;
QSettings settings;
settings.setValue("FontSize", nSize);
QFont newfont = QFont(QString("Courier New"), 6);
newfont.setPixelSize(nSize);
newfont.setStyle(QFont::StyleNormal);
newfont.setWeight(QFont::Normal);
console->setTerminalFont(newfont);
}