ui fixes
This commit is contained in:
parent
65698b9502
commit
f36c16191b
5 changed files with 70 additions and 27 deletions
BIN
client/images/background_connected.png
Normal file
BIN
client/images/background_connected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 63 KiB |
|
@ -36,5 +36,6 @@
|
|||
<file>server_scripts/remove_openvpn_server.sh</file>
|
||||
<file>server_scripts/setup_openvpn_server.sh</file>
|
||||
<file>server_scripts/template.ovpn</file>
|
||||
<file>images/background_connected.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -21,9 +21,15 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
m_vpnConnection(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->widget_tittlebar->installEventFilter(this);
|
||||
|
||||
setWindowFlags(Qt:: ToolTip | Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
|
||||
ui->stackedWidget_main->setSpeed(200);
|
||||
ui->stackedWidget_main->setAnimation(QEasingCurve::Linear);
|
||||
|
||||
// Post initialization
|
||||
ui->widget_tittlebar->hide();
|
||||
|
||||
if (m_settings->haveAuthData()) {
|
||||
goToPage(Page::Vpn);
|
||||
|
@ -78,7 +84,37 @@ MainWindow::~MainWindow()
|
|||
|
||||
void MainWindow::goToPage(Page page)
|
||||
{
|
||||
ui->stackedWidget_main->setCurrentIndex(static_cast<int>(page));
|
||||
ui->stackedWidget_main->slideInIdx(static_cast<int>(page));
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (obj == ui->widget_tittlebar) {
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
|
||||
if (!mouseEvent)
|
||||
return false;
|
||||
|
||||
if(event->type() == QEvent::MouseButtonPress) {
|
||||
offset = mouseEvent->pos();
|
||||
canMove = true;
|
||||
}
|
||||
|
||||
if(event->type() == QEvent::MouseButtonRelease) {
|
||||
canMove = false;
|
||||
}
|
||||
|
||||
if (event->type() == QEvent::MouseMove) {
|
||||
if(canMove && (mouseEvent->buttons() & Qt::LeftButton)) {
|
||||
move(mapToParent(mouseEvent->pos() - offset));
|
||||
}
|
||||
|
||||
event->ignore();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return QMainWindow::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||
|
@ -108,8 +144,19 @@ void MainWindow::onPushButtonNewServerConnectWithNewData(bool clicked)
|
|||
m_settings->setPassword(ui->lineEdit_new_server_password->text());
|
||||
m_settings->save();
|
||||
|
||||
//goToPage(Page::Vpn);
|
||||
|
||||
if (requestOvpnConfig(m_settings->serverName(), m_settings->login(), m_settings->password())) {
|
||||
goToPage(Page::Vpn);
|
||||
|
||||
ui->pushButton_connect->setDown(true);
|
||||
|
||||
if (!m_vpnConnection->connectToVpn()) {
|
||||
ui->pushButton_connect->setChecked(false);
|
||||
QMessageBox::critical(this, APPLICATION_NAME, m_vpnConnection->lastError());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,3 +278,8 @@ bool MainWindow::requestOvpnConfig(const QString& hostName, const QString& userN
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_close_clicked()
|
||||
{
|
||||
qApp->exit();
|
||||
}
|
||||
|
|
|
@ -37,8 +37,9 @@ private slots:
|
|||
void onPushButtonNewServerSetup(bool clicked);
|
||||
void onPushButtonSettingsClicked(bool clicked);
|
||||
|
||||
void on_pushButton_close_clicked();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
bool requestOvpnConfig(const QString& hostName, const QString& userName, const QString& password, int port = 22, int timeout = 30);
|
||||
|
||||
private:
|
||||
|
@ -47,6 +48,11 @@ private:
|
|||
Ui::MainWindow *ui;
|
||||
VpnConnection* m_vpnConnection;
|
||||
Settings* m_settings;
|
||||
|
||||
bool canMove = false;
|
||||
QPoint offset;
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -231,9 +231,7 @@ image-position: right;
|
|||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">
|
||||
|
||||
QPushButton {
|
||||
<string notr="true">QPushButton {
|
||||
image-position: right;
|
||||
image: url(:/images/close.png);
|
||||
|
||||
|
@ -381,7 +379,6 @@ border-radius: 4px;</string>
|
|||
|
||||
/* grey */
|
||||
border: 1px solid #A7A7A7;
|
||||
box-sizing: border-box;
|
||||
color: #333333;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -593,7 +590,6 @@ color: #333333;</string>
|
|||
|
||||
/* grey */
|
||||
border: 1px solid #A7A7A7;
|
||||
box-sizing: border-box;
|
||||
color: #333333;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -614,11 +610,10 @@ color: #333333;</string>
|
|||
|
||||
/* grey */
|
||||
border: 1px solid #A7A7A7;
|
||||
box-sizing: border-box;
|
||||
color: #333333;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>root</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_new_server_password">
|
||||
|
@ -635,7 +630,6 @@ color: #333333;</string>
|
|||
|
||||
/* grey */
|
||||
border: 1px solid #A7A7A7;
|
||||
box-sizing: border-box;
|
||||
color: #333333;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -684,9 +678,9 @@ border-radius: 4px;
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>120</y>
|
||||
<y>115</y>
|
||||
<width>281</width>
|
||||
<height>16</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
|
@ -695,10 +689,6 @@ font-style: normal;
|
|||
font-weight: normal;
|
||||
font-size: 16px;
|
||||
line-height: 20px;
|
||||
|
||||
/* or 125% */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
|
||||
/* акцент */
|
||||
|
@ -805,14 +795,14 @@ QPushButton:hover {
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>380</width>
|
||||
<height>200</height>
|
||||
<height>325</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">image: url(:/images/tray/active.png);</string>
|
||||
<string notr="true">border-image: url(:/images/background_connected.png);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
|
@ -955,7 +945,7 @@ line-height: 21px;
|
|||
</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add site</string>
|
||||
<string>+ Add site</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_settings">
|
||||
|
@ -1282,7 +1272,7 @@ color: #181922;</string>
|
|||
|
||||
/* grey */
|
||||
border: 1px solid #A7A7A7;
|
||||
box-sizing: border-box;</string>
|
||||
</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
|
@ -1431,9 +1421,6 @@ font-style: normal;
|
|||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
line-height: 25px;
|
||||
/* identical to box height, or 125% */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
Text-align:left;
|
||||
padding-left: 30px;
|
||||
|
||||
|
@ -1480,9 +1467,6 @@ font-style: normal;
|
|||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
line-height: 25px;
|
||||
/* identical to box height, or 125% */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
Text-align:left;
|
||||
padding-left: 30px;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue