all thing is Ok

This commit is contained in:
Am-teamdev
2026-05-12 12:51:49 +03:30
parent 0dfb5d3415
commit 3669f7e2dc
12 changed files with 620 additions and 270 deletions
+227
View File
@@ -0,0 +1,227 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>517</width>
<height>171</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">/* پس‌زمینه اصلی: مشکی عمیق */
QWidget {
background-color: #0d1117; /* مشکی-سورمه‌ای بسیار تاریک */
color: #e6edf3; /* سفید مایل به آبی برای خوانایی */
font-family: &quot;Segoe UI&quot;, Tahoma, Arial;
font-size: 14px;
}
/* فیلدهای ورودی */
QLineEdit, QTextEdit, QSpinBox, QComboBox {
background-color: #161b22; /* خاکستری بسیار تیره برای فیلدها */
color: #ffffff;
border: 2px solid #21262d; /* حاشیه محو در حالت عادی */
border-radius: 8px;
padding: 8px 12px;
selection-background-color: #00e5ff; /* سایان نئونی برای متن انتخاب شده */
selection-color: #000000;
}
/* حالت فوکوس (درخشش نئونی) */
QLineEdit:focus, QTextEdit:focus, QSpinBox:focus, QComboBox:focus {
border: 2px solid #00e5ff; /* نئون درخشان */
background-color: #0d1117;
}
/* دکمه‌ها: استایل Outline (خالی با حاشیه رنگی) */
QPushButton {
background-color: transparent;
color: #00e5ff; /* متن نئونی */
font-weight: bold;
font-size: 15px;
border: 2px solid #00e5ff; /* حاشیه نئونی */
border-radius: 8px;
padding: 10px 20px;
}
/* وقتی ماوس روی دکمه می‌رود: دکمه پُر می‌شود */
QPushButton:hover {
background-color: #00e5ff;
color: #0d1117; /* رنگ متن برعکس می‌شود (مشکی) */
border: 2px solid #00e5ff;
}
QPushButton:pressed {
background-color: #00b3cc;
border: 2px solid #00b3cc;
color: #0d1117;
}
/* طراحی تب‌ها */
QTabBar::tab {
background-color: #161b22;
color: #8b949e;
padding: 10px 20px;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
margin-right: 2px;
border: 1px solid #21262d;
border-bottom: none;
}
QTabBar::tab:selected {
background-color: #00e5ff;
color: #0d1117;
font-weight: bold;
border: 1px solid #00e5ff;
}
QTabBar::tab:hover:!selected {
background-color: #21262d;
color: #e6edf3;
}
/* SpinBox و فلش‌ها */
QSpinBox {
padding-right: 28px;
}
QSpinBox::up-button, QSpinBox::down-button {
width: 22px;
height: 16px;
border: none;
background-color: transparent;
}
QSpinBox::up-button:hover, QSpinBox::down-button:hover {
background-color: rgba(0, 229, 255, 0.2); /* هاله نئونی روی دکمه‌های کوچک */
}
QSpinBox::up-arrow {
image: url(&quot;data:image/svg+xml,%3Csvg%20fill='%2300e5ff'%20height='10'%20width='10'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M7%2014l5-5%205%205z'/%3E%3C/svg%3E&quot;);
}
QSpinBox::down-arrow {
image: url(&quot;data:image/svg+xml,%3Csvg%20fill='%2300e5ff'%20height='10'%20width='10'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M7%2010l5%205%205-5z'/%3E%3C/svg%3E&quot;);
}
</string>
</property>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>6</x>
<y>6</y>
<width>152</width>
<height>55</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>key</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="key_box">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>164</x>
<y>120</y>
<width>206</width>
<height>45</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>6</x>
<y>67</y>
<width>511</width>
<height>47</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>path save file :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="path_save_in"/>
</item>
<item>
<widget class="QPushButton" name="open_svae_bt">
<property name="text">
<string>open</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+107 -227
View File
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>736</width>
<width>867</width>
<height>846</height>
</rect>
</property>
@@ -29,129 +29,125 @@
<iconset theme="preferences-system-network"/>
</property>
<property name="styleSheet">
<string notr="true">/* تنظیمات کلی و پس‌زمینه اصلی */
<string notr="true">/* پس‌زمینه اصلی: مشکی عمیق */
QWidget {
background-color: #222831; /* خاکستری-سورمه‌ای بسیار تیره */
color: #EEEEEE; /* سفید مات برای خوانایی بالا */
background-color: #0d1117; /* مشکی-سورمه‌ای بسیار تاریک */
color: #e6edf3; /* سفید مایل به آبی برای خوانایی */
font-family: &quot;Segoe UI&quot;, Tahoma, Arial;
font-size: 14px;
}
/* فیلدهای ورودی متن و اعداد */
/* فیلدهای ورودی */
QLineEdit, QTextEdit, QSpinBox, QComboBox {
background-color: #393E46; /* پس‌زمینه فیلدها */
color: #EEEEEE;
border: 2px solid #393E46; /* حاشیه نامرئی در حالت عادی */
border-radius: 8px; /* گوشه‌های گرد و مدرن */
padding: 6px 10px;
selection-background-color: #00ADB5; /* رنگ پس‌زمینه متنی که انتخاب (Select) می‌شود */
}
/* حالت فوکوس (وقتی کاربر روی فیلد کلیک می‌کند) */
QLineEdit:focus, QTextEdit:focus, QSpinBox:focus, QComboBox:focus {
border: 2px solid #00ADB5; /* روشن شدن حاشیه با رنگ فیروزه‌ای */
background-color: #2D323A;
}
/* دکمه‌های اصلی */
QPushButton {
background-color: #00ADB5; /* فیروزه‌ای شیک و مدرن */
background-color: #161b22; /* خاکستری بسیار تیره برای فیلدها */
color: #ffffff;
border: 2px solid #21262d; /* حاشیه محو در حالت عادی */
border-radius: 8px;
padding: 8px 12px;
selection-background-color: #00e5ff; /* سایان نئونی برای متن انتخاب شده */
selection-color: #000000;
}
/* حالت فوکوس (درخشش نئونی) */
QLineEdit:focus, QTextEdit:focus, QSpinBox:focus, QComboBox:focus {
border: 2px solid #00e5ff; /* نئون درخشان */
background-color: #0d1117;
}
/* دکمه‌ها: استایل Outline (خالی با حاشیه رنگی) */
QPushButton {
background-color: transparent;
color: #00e5ff; /* متن نئونی */
font-weight: bold;
font-size: 15px;
border: none;
border-radius: 8px; /* گوشه‌های کاملا گرد */
border: 2px solid #00e5ff; /* حاشیه نئونی */
border-radius: 8px;
padding: 10px 20px;
}
/* وقتی ماوس روی دکمه می‌رود (Hover) */
/* وقتی ماوس روی دکمه می‌رود: دکمه پُر می‌شود */
QPushButton:hover {
background-color: #008f96; /* فیروزه‌ای تیره‌تر */
background-color: #00e5ff;
color: #0d1117; /* رنگ متن برعکس می‌شود (مشکی) */
border: 2px solid #00e5ff;
}
/* وقتی دکمه کلیک می‌شود */
QPushButton:pressed {
background-color: #00737a;
background-color: #00b3cc;
border: 2px solid #00b3cc;
color: #0d1117;
}
/* طراحی تب‌ها (اگر در برنامه دارید) */
/* طراحی تب‌ها */
QTabBar::tab {
background-color: #393E46;
color: #AAAAAA;
background-color: #161b22;
color: #8b949e;
padding: 10px 20px;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
margin-right: 2px;
border: 1px solid #21262d;
border-bottom: none;
}
/* تبِ انتخاب شده */
QTabBar::tab:selected {
background-color: #00ADB5;
color: #ffffff;
background-color: #00e5ff;
color: #0d1117;
font-weight: bold;
border: 1px solid #00e5ff;
}
/* وقتی ماوس روی تب‌های دیگر می‌رود */
QTabBar::tab:hover:!selected {
background-color: #4A5059;
color: #EEEEEE;
background-color: #21262d;
color: #e6edf3;
}
QPushButton:focus {
outline: none; /* پاک کردن مستطیل دور تمرکز */
border: 2px solid #00ADB5; /* حفظ حاشیه آبی فیروزه ای */
background-color: #2D323A;
}
/* SpinBox اصلی */
/* SpinBox و فلش‌ها */
QSpinBox {
background-color: #393E46;
padding-right: 28px;
}
QSpinBox::up-button, QSpinBox::down-button {
width: 22px;
height: 16px;
border: none;
background-color: transparent;
}
QSpinBox::up-button:hover, QSpinBox::down-button:hover {
background-color: rgba(0, 229, 255, 0.2); /* هاله نئونی روی دکمه‌های کوچک */
}
QSpinBox::up-arrow {
image: url(&quot;data:image/svg+xml,%3Csvg%20fill='%2300e5ff'%20height='10'%20width='10'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M7%2014l5-5%205%205z'/%3E%3C/svg%3E&quot;);
}
QSpinBox::down-arrow {
image: url(&quot;data:image/svg+xml,%3Csvg%20fill='%2300e5ff'%20height='10'%20width='10'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M7%2010l5%205%205-5z'/%3E%3C/svg%3E&quot;);
}
QMenuBar {
background-color: #222831;
color: #EEEEEE;
border: 2px solid #393E46;
border-radius: 8px;
padding: 6px 10px;
padding-right: 28px; /* جا برای دکمه‌های بالا/پایین */
min-width: 10px;
}
/* دکمه‌های بالا و پایین */
QSpinBox::up-button {
subcontrol-origin: padding;
subcontrol-position: top right;
width: 22px;
height: 16px;
border: none;
border-top-right-radius: 8px;
background-color: transparent;
QMenuBar::item {
spacing: 8px;
padding: 6px 12px;
background: transparent;
border-radius: 6px;
}
QSpinBox::down-button {
subcontrol-origin: padding;
subcontrol-position: bottom right;
width: 22px;
height: 16px;
border: none;
border-bottom-right-radius: 8px;
background-color: transparent;
QMenuBar::item:selected {
background: #00ADB5;
}
/* هاور دکمه‌های spinbox */
QSpinBox::up-button:hover,
QSpinBox::down-button:hover {
QMenu {
background-color: #393E46;
color: white;
border: 1px solid #555;
}
QMenu::item:selected {
background-color: #00ADB5;
}
/* فلش بالا */
QSpinBox::up-arrow {
image: url(&quot;data:image/svg+xml,%3Csvg%20fill='%23EEEEEE'%20height='10'%20width='10'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M7%2014l5-5%205%205z'/%3E%3C/svg%3E&quot;);
width: 10px;
height: 10px;
}
/* فلش پایین */
QSpinBox::down-arrow {
image: url(&quot;data:image/svg+xml,%3Csvg%20fill='%23EEEEEE'%20height='10'%20width='10'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M7%2010l5%205%205-5z'/%3E%3C/svg%3E&quot;);
width: 10px;
height: 10px;
}</string>
</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
@@ -360,12 +356,12 @@ QSpinBox::down-arrow {
</font>
</property>
<property name="text">
<string>path bin :</string>
<string>path file :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="path_bin_en">
<widget class="QLineEdit" name="path_file_en">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -381,7 +377,7 @@ QSpinBox::down-arrow {
</widget>
</item>
<item>
<widget class="QPushButton" name="open_bin_en">
<widget class="QPushButton" name="open_file_en">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -408,58 +404,6 @@ QSpinBox::down-arrow {
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Segoe UI</family>
<pointsize>-1</pointsize>
</font>
</property>
<property name="text">
<string>key :</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="key_box_en">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
@@ -508,12 +452,12 @@ QSpinBox::down-arrow {
</font>
</property>
<property name="text">
<string>path bin :</string>
<string>path file:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="path_bin_de">
<widget class="QLineEdit" name="path_file_de">
<property name="font">
<font>
<family>Segoe UI</family>
@@ -523,7 +467,7 @@ QSpinBox::down-arrow {
</widget>
</item>
<item>
<widget class="QPushButton" name="open_bin_de">
<widget class="QPushButton" name="open_file_de">
<property name="text">
<string>open</string>
</property>
@@ -531,92 +475,6 @@ QSpinBox::down-arrow {
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<family>Segoe UI</family>
<pointsize>-1</pointsize>
</font>
</property>
<property name="text">
<string>path txt :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="path_txt_de">
<property name="font">
<font>
<family>Segoe UI</family>
<pointsize>-1</pointsize>
</font>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="open_txt_de">
<property name="text">
<string>open</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Segoe UI</family>
<pointsize>-1</pointsize>
</font>
</property>
<property name="text">
<string>key :</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="key_box_de">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
@@ -670,6 +528,16 @@ QSpinBox::down-arrow {
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Segoe UI','Tahoma','Arial'; font-size:14px; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;amir&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</widget>
</item>
@@ -700,12 +568,24 @@ QSpinBox::down-arrow {
<rect>
<x>0</x>
<y>0</y>
<width>736</width>
<width>867</width>
<height>32</height>
</rect>
</property>
<widget class="QMenu" name="menusetting">
<property name="title">
<string>setting</string>
</property>
<addaction name="config_bar"/>
</widget>
<addaction name="menusetting"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="config_bar">
<property name="text">
<string>config</string>
</property>
</action>
</widget>
<resources/>
<connections/>
Binary file not shown.
Binary file not shown.
Binary file not shown.
+63 -20
View File
@@ -1,28 +1,71 @@
import json
from PyQt6.QtWidgets import QFileDialog
class EdCoding:
def __init__(self, key):
self.key = key
def ende(self, data):
@staticmethod
def ende(data, key_str) -> tuple:
"""
:param data: type just dict and string
:param data:
:return tuple (encoded || decoded, status):
"""
try:
key = int(key_str)
text = data
encoded = ''
if isinstance(data, dict):
text = json.dumps(data, ensure_ascii=False, indent=4)
if isinstance(text, str):
encoded = ''.join(
chr(ord(c) ^ key) for c in text
)
return encoded, True
encoded_bytes = bytearray()
for b in text:
encoded_bytes.append(b ^ key)
return encoded_bytes, True
except Exception as e:
return e, False
@staticmethod
def read_file(path, type_open='rb'):
"""
:param path:
:return tuple (file, status):
"""
try:
with open(path, type_open) as f:
file = f.read()
return file, True
except Exception as e:
return e, False
@staticmethod
def save_file(path, text, type_open='w'):
"""
:param path:
:return:
"""
text = data
if isinstance(data, dict):
text = json.dumps(data, ensure_ascii=False)
encoded = ''.join(
chr(ord(c) ^ self.key) for c in text
)
return encoded
def read_file(self):
pass
try:
with open(path, type_open) as f:
f.write(text)
return True, True
except Exception as e:
return e, False
@staticmethod
def open_file_dialog_with_suffix(parent) -> str:
"""
open file dialog with suffix
:param self: parent widget
:return viod:
"""
filter_str = "BIN and TXT Files (*.bin *.txt)"
filename, _ = QFileDialog.getOpenFileName(parent, "select file", "", filter_str)
return filename
coding = EdCoding(12)
en = coding.ende({'key': 'value'})
de = coding.ende(en)
print(en, de, sep='\n')
# coding = EdCoding(12)
# file = coding.read_file('/home/amdev/Projects/network_procsses/test/test_read.txt')
# print(file)
# encoding, status = coding.ende(file[0])
# decoding, status_decoding = coding.ende(encoding)
# print(encoding, status)
# print(decoding, status_decoding)
+1
View File
@@ -0,0 +1 @@
{"Url": "kldfjlkadjijfds", "Port": 8888, "Username": "adfsdfasdf", "Password": "asdfadfasdfd"}
+2 -3
View File
@@ -1,4 +1,3 @@
import ed_coding
from main_gui import *
from PyQt6.QtWidgets import QApplication
from PyQt6.QtCore import QTimer
@@ -6,7 +5,8 @@ import sys
if __name__ == "__main__":
app = QApplication(sys.argv)
QApplication.setOrganizationName("Atrix")
QApplication.setApplicationName("AMDEV")
# نمایش صفحه اول (Splash Screen)
splash = SplashScreen()
splash.show()
@@ -19,7 +19,6 @@ if __name__ == "__main__":
splash.close()
main_window.show()
QTimer.singleShot(3000, show_main_window)
sys.exit(app.exec())
+168 -15
View File
@@ -1,50 +1,204 @@
from PyQt6.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout, QMainWindow, QProgressBar
from PyQt6.QtCore import Qt, QTimer, QPropertyAnimation, QEasingCurve
from PyQt6.QtGui import QFont
from PyQt6.QtWidgets import QWidget, QLabel, QVBoxLayout, QMainWindow, QLineEdit, QDialog, QMessageBox, QFileDialog
from PyQt6.QtCore import Qt, QPropertyAnimation, QEasingCurve
from PyQt6.QtGui import QFont, QIcon, QAction
from PyQt6 import uic
from PyQt6.QtSvgWidgets import QSvgWidget
from setting_gui import SettingsDialog
from PyQt6.QtCore import QSettings
from ed_coding import EdCoding
class MainWindow(QMainWindow):
def __init__(self):
self.gui_base_path = '../GUI/'
super().__init__()
uic.loadUi("../GUI/gui.ui", self)
uic.loadUi(self.gui_base_path + "gui.ui", self)
self.pass_in.setEchoMode(QLineEdit.EchoMode.Password)
self.icon_show = QIcon(self.gui_base_path + 'xsi-eye-symbolic.svg')
self.icon_hide = QIcon(self.gui_base_path + 'image-red-eye.svg')
self.toggle_password_action = QAction(self.icon_show, "Show/Hide Password", self)
self.toggle_password_action.triggered.connect(self.toggle_password_visibility)
self.pass_in.addAction(self.toggle_password_action, QLineEdit.ActionPosition.TrailingPosition)
self.config_bar.triggered.connect(self.open_settings)
self.reset_bt.clicked.connect(self.logs.clear)
self.open_file_en.clicked.connect(self.open_file_encoding)
self.open_file_de.clicked.connect(self.open_file_decoding)
self.encoding_bt.clicked.connect(self.encoding)
self.decoding_bt.clicked.connect(self.decoding)
# setting
self.key = 0
self.path_save = ''
self.apply_settings()
if self.key == 0 or self.path_save == '':
QMessageBox.warning(self, "Warning", "Please cheng config.")
def toggle_password_visibility(self):
"""
cheng status password input (hidden/normal)
:return:
"""
if self.pass_in.echoMode() == QLineEdit.EchoMode.Password:
self.pass_in.setEchoMode(QLineEdit.EchoMode.Normal)
self.toggle_password_action.setIcon(self.icon_hide)
else:
self.pass_in.setEchoMode(QLineEdit.EchoMode.Password)
self.toggle_password_action.setIcon(self.icon_show)
def open_settings(self):
"""
open settings dialog
:return:
"""
dialog = SettingsDialog(self)
result = dialog.exec()
if result == QDialog.DialogCode.Accepted:
QMessageBox.information(self, "successfully", "Setting saved successfully")
self.apply_settings()
def apply_settings(self):
"""
apply settings dialog
:return:
"""
settings = QSettings()
self.key = settings.value("key_ende", 0, type=int)
self.path_save = settings.value("path_save", 'encoding.txt', type=str)
# def open_file_dialog_with_suffix(self) -> str:
# """
# open file dialog with suffix
# :param self: parent widget
# :return viod:
# """
# filter_str = "BIN and TXT Files (*.bin *.txt)"
# filename, _ = QFileDialog.getOpenFileName(self, "select file", "", filter_str)
# return filename
def open_file_decoding(self):
self.path_file_de.setText(EdCoding.open_file_dialog_with_suffix(self))
def open_file_encoding(self):
self.path_file_en.setText(EdCoding.open_file_dialog_with_suffix(self))
def decoding(self):
self.logs.clear()
if self.path_file_de.text() != '':
#
file, status = EdCoding.read_file(self.path_file_de.text(), type_open='r')
if status:
self.logs.append('read file : Ok')
else:
self.logs.append(str(file))
return None
#
decoding_data, status = EdCoding.ende(file, self.key)
if status:
self.logs.append('decoding info : Ok')
self.logs.append(f'data : \n{decoding_data}') if self.path_file_de.text()[
-4:] == '.txt' else EdCoding.save_file(
self.path_save + 'decoding.bin', decoding_data, 'wb')
else:
self.logs.append(str(decoding_data))
return None
#
else:
self.logs.append('ERROR: Pleas open file!')
def encoding(self):
self.logs.clear()
#
dict_info = {
'Url': self.url_in.text(),
'Port': self.prot_box.value(),
'Username': self.user_in.text(),
'Password': self.pass_in.text(),
}
for key, values in list(dict_info.items()):
if values == '':
dict_info.pop(key)
if self.path_file_en.text() == '' and len(dict_info) < 2: # txt
self.logs.append("ERROR: Please fill the inputs")
return None
#
if self.path_file_en.text() != '': # bin
#
info, status = EdCoding.read_file(self.path_file_en.text())
if status:
self.logs.append('read file : Ok')
else:
self.logs.append(str(info))
return None
#
encoding_info, status = EdCoding.ende(info, self.key)
if status:
self.logs.append('encoding info : Ok')
else:
self.logs.append(str(encoding_info))
return None
#
error, status = EdCoding.save_file(self.path_save + 'encoding.bin', encoding_info, 'wb')
if status:
self.logs.append('save bin file: Ok')
else:
self.logs.append(str(error))
return None
#
if len(dict_info) >= 2:
#
encoding_info, status = EdCoding.ende(dict_info, self.key)
if status:
self.logs.append('encoding info: Ok')
else:
self.logs.append(str(encoding_info))
return None
#
error, status = EdCoding.save_file(self.path_save + 'encoding.txt', encoding_info)
if status:
self.logs.append('save file : Ok')
else:
self.logs.append(str(error))
return None
#
class SplashScreen(QWidget):
def __init__(self):
super().__init__()
# --- تنظیمات ظاهری پنجره ---
self.setFixedSize(400, 300)
self.setWindowFlags(Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowStaysOnTopHint)
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
# --- چیدمان و ویجت‌ها ---
layout = QVBoxLayout(self)
layout.setContentsMargins(20, 20, 20, 20)
self.setLayout(layout)
# --- ویجت برای نمایش SVG ---
# استفاده از QSvgWidget بهترین راه برای نمایش فایل SVG است
self.svg_widget = QSvgWidget('../GUI/network-vpn.svg', self)
self.svg_widget.setFixedSize(150, 150) # اندازه آیکون را تنظیم کنید
# --- متن زیر آیکون ---
self.title_label = QLabel("Security Network", self)
self.title_label.setFont(QFont("Segoe UI", 20, QFont.Weight.Bold))
self.loading_label = QLabel("Welcome.", self)
self.loading_label.setFont(QFont("Segoe UI", 10))
# افزودن ویجت‌ها به چیدمان و وسط‌چین کردن آن‌ها
layout.addStretch() # فضای خالی در بالا
layout.addStretch()
layout.addWidget(self.svg_widget, alignment=Qt.AlignmentFlag.AlignCenter)
layout.addWidget(self.title_label, alignment=Qt.AlignmentFlag.AlignCenter)
layout.addWidget(self.loading_label, alignment=Qt.AlignmentFlag.AlignCenter)
layout.addStretch() # فضای خالی در پایین
layout.addStretch()
# --- استایل‌دهی (تم دارک) ---
self.setStyleSheet("""
QWidget {
background-color: #0d1117; /* پس‌زمینه مشکی-سورمه‌ای */
@@ -53,9 +207,8 @@ class SplashScreen(QWidget):
}
""")
# --- انیمیشن محو شدن (Fade-in) ---
self.animation = QPropertyAnimation(self, b"windowOpacity")
self.animation.setDuration(1000) # ۱ ثانیه
self.animation.setDuration(1000)
self.animation.setStartValue(0.0)
self.animation.setEndValue(1.0)
self.animation.setEasingCurve(QEasingCurve.Type.InOutQuad)
+45
View File
@@ -0,0 +1,45 @@
from PyQt6.QtWidgets import QDialog, QFileDialog
from PyQt6.QtCore import QSettings
from PyQt6 import uic
from ed_coding import EdCoding
class SettingsDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
uic.loadUi("../GUI/config.ui", self)
self.load_settings()
self.open_svae_bt.clicked.connect(self.select_folder)
def load_settings(self):
"""
set settings
:return void:
"""
settings = QSettings()
key = settings.value("key_ende", 0, type=int)
self.key_box.setValue(key)
path_save = settings.value("path_save", 'encoding.txt', type=str)
self.path_save_in.setText(path_save)
def accept(self):
"""
accept settings
:return void:
"""
settings = QSettings()
settings.setValue("key_ende", self.key_box.value())
settings.setValue("path_save", self.path_save_in.text())
settings.sync()
super().accept()
def select_folder(self):
folder = QFileDialog.getExistingDirectory(
self,
"Select Folder"
)
if folder:
self.path_save_in.setText(folder + '/')
+6 -5
View File
@@ -1,5 +1,6 @@
import json
d = {"key": "value",
'key2': 'value2',
'key3': 'value3'}
print(json.dumps(d, indent=4))
b = bytearray()
print(b.append(10))
print(b.append(20))
print(b.append(80))
print(b)
+1
View File
@@ -0,0 +1 @@
amir abas is very good in typing