This repository has been archived by the owner on May 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmysettingswindow.cpp
126 lines (102 loc) · 3.87 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);
lblFontSample = new QLabel(tr("Sample 123"), this);
lblFontSample->setObjectName(tr("lblFontSample"));
QFont fontSample = QFont(QString("Courier New"), 6);
fontSample.setPixelSize(mainWindow->nFontSize);
fontSample.setStyle(QFont::StyleNormal);
fontSample.setWeight(QFont::Normal);
lblFontSample->setFont(fontSample);
this->setObjectName(tr("wdgSettingsWindow"));
QComboBox *cbFontSize = new QComboBox(gb1);
cbFontSize->setObjectName(tr("cbFontSize"));
cbFontSize->setMaxVisibleItems(9);
for(int i=18; i < 52; i += 4){
cbFontSize->addItem(QString::number(i));
if (i == mainWindow->nFontSize)
cbFontSize->setCurrentIndex(cbFontSize->count()-1); // Current Font size
}
hlayout->addWidget(lblFontSample);
hlayout->addWidget(cbFontSize);
layout->addWidget(gb1);
btnClose = new QToolButton(this);
btnClose->setObjectName(QString::fromUtf8("btnClose"));
btnClose->setText(QString("Close"));
btnClose->setMinimumWidth(nWidth/2);
layout->addWidget(btnClose);
layout->setAlignment(btnClose, Qt::AlignHCenter);
gb->setLayout(layout);
QMetaObject::connectSlotsByName(this);
return 0;
}
extern QTermWidget *console;
void CMySettingsWindow::on_cbFontSize_currentIndexChanged(const QString & text){
// User selected something from drop-down list
int nSize = text.toInt();
mainWindow->nFontSize = nSize;
// Save new settings
QSettings settings;
settings.setValue("FontSize", nSize);
// Create new Font
QFont newfont = QFont(QString("Courier New"), 6);
newfont.setPixelSize(nSize);
newfont.setStyle(QFont::StyleNormal);
newfont.setWeight(QFont::Normal);
// Apply new Font/size to Sample Text
lblFontSample->setFont(newfont);
// Apply new Font/size to console
console->setTerminalFont(newfont);
}
void CMySettingsWindow::on_btnClose_clicked(){
QEvent* event= new QEvent(QEvent::PlatformPanel);
QApplication::sendEvent(this->parent(), event);
}