add option for read and config app
This commit is contained in:
parent
299528fa97
commit
0d4fecd578
|
@ -1,5 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
# from PyQt5.QtCore import QSettings
|
# from PyQt5.QtCore import QSettings
|
||||||
from PySide6.QtCore import QSettings
|
from PySide6.QtCore import QSettings
|
||||||
|
|
||||||
|
@ -13,7 +13,8 @@ class Params(object):
|
||||||
def __init__(self, file_):
|
def __init__(self, file_):
|
||||||
self.file = file_
|
self.file = file_
|
||||||
|
|
||||||
dirx = os.path.abspath(os.path.join(__file__, '..', '..'))
|
current_path = os.path.abspath(__file__)
|
||||||
|
dirx = os.path.abspath(os.path.join(current_path, '..', '..', '..'))
|
||||||
|
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
homex = 'HOME'
|
homex = 'HOME'
|
||||||
|
@ -25,15 +26,16 @@ class Params(object):
|
||||||
HOME_DIR = os.getenv(homex)
|
HOME_DIR = os.getenv(homex)
|
||||||
default_dir = os.path.join(HOME_DIR, dirconfig)
|
default_dir = os.path.join(HOME_DIR, dirconfig)
|
||||||
|
|
||||||
if os.path.exists(default_dir):
|
if not os.path.exists(default_dir):
|
||||||
config_file = os.path.join(default_dir, self.file)
|
os.makedirs(default_dir)
|
||||||
else:
|
|
||||||
config_file = os.path.join(dirx, self.file)
|
self.config_file = os.path.join(default_dir, self.file)
|
||||||
|
|
||||||
if not os.path.exists(config_file):
|
if not os.path.exists(self.config_file):
|
||||||
config_file = self.file
|
config_file_path = os.path.join(dirx, self.file)
|
||||||
|
shutil.copy2(config_file_path, self.config_file)
|
||||||
|
|
||||||
settings = QSettings(config_file, QSettings.IniFormat)
|
settings = QSettings(self.config_file, QSettings.IniFormat)
|
||||||
self.params = {
|
self.params = {
|
||||||
"server": "localhost",
|
"server": "localhost",
|
||||||
"port": "8010",
|
"port": "8010",
|
||||||
|
|
|
@ -4,7 +4,6 @@ import sys
|
||||||
import os
|
import os
|
||||||
import gettext
|
import gettext
|
||||||
import logging
|
import logging
|
||||||
import time
|
|
||||||
import ssl
|
import ssl
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from PySide6.QtWidgets import QDialog
|
from PySide6.QtWidgets import QDialog
|
||||||
|
@ -14,6 +13,7 @@ from http.client import HTTPConnection, HTTPSConnection
|
||||||
import orjson as json
|
import orjson as json
|
||||||
from app.threads import VerifyConn
|
from app.threads import VerifyConn
|
||||||
from app.commons.config import Params
|
from app.commons.config import Params
|
||||||
|
from app.commons.dialogs import ConfigEditDialog
|
||||||
from app.commons.ui_login import Ui_Login
|
from app.commons.ui_login import Ui_Login
|
||||||
from logger_config import logger
|
from logger_config import logger
|
||||||
context_http = ssl._create_unverified_context()
|
context_http = ssl._create_unverified_context()
|
||||||
|
@ -145,6 +145,19 @@ class Login(QDialog):
|
||||||
|
|
||||||
def error_message(self):
|
def error_message(self):
|
||||||
self.ui.label_error.show()
|
self.ui.label_error.show()
|
||||||
|
|
||||||
|
def open_config_file(self):
|
||||||
|
config_file_path = "/home/psk/.tryton/config_pos.ini" # Reemplaza con tu ruta real
|
||||||
|
dialog = ConfigEditDialog(config_file_path)
|
||||||
|
dialog.exec_()
|
||||||
|
|
||||||
|
def show_about(self):
|
||||||
|
# Aquí debes implementar la lógica para mostrar el diálogo de configuración
|
||||||
|
# Puedes crear una nueva ventana de configuración o un cuadro de diálogo modal.
|
||||||
|
# Por ejemplo:
|
||||||
|
print('pasa a mos')
|
||||||
|
# config_dialog = ConfigDialog(self)
|
||||||
|
# config_dialog.exec_()
|
||||||
|
|
||||||
|
|
||||||
def xconnection(mode, user, password, host, database, port):
|
def xconnection(mode, user, password, host, database, port):
|
||||||
|
|
|
@ -9,7 +9,7 @@ from collections import OrderedDict
|
||||||
# from PyQt5.QtCore import Qt, pyqtSlot, QModelIndex
|
# from PyQt5.QtCore import Qt, pyqtSlot, QModelIndex
|
||||||
from PySide6.QtWidgets import (
|
from PySide6.QtWidgets import (
|
||||||
QDialog, QAbstractItemView, QVBoxLayout, QHBoxLayout, QLabel, QWidget,
|
QDialog, QAbstractItemView, QVBoxLayout, QHBoxLayout, QLabel, QWidget,
|
||||||
QTreeView, QLineEdit, QTableView, QCompleter
|
QTreeView, QLineEdit, QTableView, QCompleter, QPushButton, QTextEdit
|
||||||
)
|
)
|
||||||
from PySide6.QtGui import QStandardItem, QStandardItemModel, QPixmap, QGuiApplication
|
from PySide6.QtGui import QStandardItem, QStandardItemModel, QPixmap, QGuiApplication
|
||||||
from PySide6.QtCore import Qt, Slot, QModelIndex
|
from PySide6.QtCore import Qt, Slot, QModelIndex
|
||||||
|
@ -18,7 +18,7 @@ from .qt_models import get_simple_model
|
||||||
from .forms import GridForm
|
from .forms import GridForm
|
||||||
from .buttons import ActionButton
|
from .buttons import ActionButton
|
||||||
|
|
||||||
__all__ = ['QuickDialog', 'SearchDialog', 'HelpDialog', 'FactoryIcons']
|
__all__ = ['QuickDialog', 'SearchDialog', 'HelpDialog', 'FactoryIcons', 'ConfigEditDialog']
|
||||||
|
|
||||||
current_dir = os.path.dirname(__file__)
|
current_dir = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
@ -381,3 +381,44 @@ class FactoryIcons(object):
|
||||||
_icon_label.setAlignment(Qt.AlignCenter | Qt.AlignCenter)
|
_icon_label.setAlignment(Qt.AlignCenter | Qt.AlignCenter)
|
||||||
_icon_label.setPixmap(_qpixmap_icon.scaledToHeight(48))
|
_icon_label.setPixmap(_qpixmap_icon.scaledToHeight(48))
|
||||||
self.icons[name] = _icon_label
|
self.icons[name] = _icon_label
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigEditDialog(QDialog):
|
||||||
|
def __init__(self, config_file_path):
|
||||||
|
super(ConfigEditDialog, self).__init__()
|
||||||
|
|
||||||
|
self.setWindowTitle("Editar Configuración")
|
||||||
|
width, height = get_screen()
|
||||||
|
self.setGeometry(100, 100, int(width*0.8), int(height*0.8))
|
||||||
|
|
||||||
|
self.config_file_path = config_file_path
|
||||||
|
|
||||||
|
self.layout = QVBoxLayout()
|
||||||
|
|
||||||
|
self.text_edit = QTextEdit(self)
|
||||||
|
self.layout.addWidget(self.text_edit)
|
||||||
|
|
||||||
|
self.save_button = QPushButton("Guardar")
|
||||||
|
self.save_button.clicked.connect(self.save_config)
|
||||||
|
self.layout.addWidget(self.save_button)
|
||||||
|
|
||||||
|
self.load_config()
|
||||||
|
|
||||||
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
|
def load_config(self):
|
||||||
|
try:
|
||||||
|
with open(self.config_file_path, 'r') as file:
|
||||||
|
config_text = file.read()
|
||||||
|
self.text_edit.setPlainText(config_text)
|
||||||
|
except FileNotFoundError:
|
||||||
|
self.text_edit.setPlainText("Archivo de configuración no encontrado.")
|
||||||
|
|
||||||
|
def save_config(self):
|
||||||
|
config_text = self.text_edit.toPlainText()
|
||||||
|
try:
|
||||||
|
with open(self.config_file_path, 'w') as file:
|
||||||
|
file.write(config_text)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error al guardar el archivo de configuración: {str(e)}")
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from PySide6.QtCore import (QSize, Qt, QRect)
|
||||||
from PySide6.QtGui import (QFont, QIcon, QPixmap)
|
from PySide6.QtGui import (QFont, QIcon, QPixmap)
|
||||||
from PySide6.QtWidgets import (QGridLayout, QGroupBox, QLabel,
|
from PySide6.QtWidgets import (QGridLayout, QGroupBox, QLabel,
|
||||||
QLayout, QPushButton, QLineEdit, QVBoxLayout, QWidget,
|
QLayout, QPushButton, QLineEdit, QVBoxLayout, QWidget,
|
||||||
QHBoxLayout)
|
QHBoxLayout, QMenuBar)
|
||||||
|
|
||||||
from ..version import __version__
|
from ..version import __version__
|
||||||
from ..tools import get_screen
|
from ..tools import get_screen
|
||||||
|
@ -45,6 +45,7 @@ class Ui_Login(object):
|
||||||
MainWindow.setWindowIcon(icon)
|
MainWindow.setWindowIcon(icon)
|
||||||
MainWindow.setWindowOpacity(1.0)
|
MainWindow.setWindowOpacity(1.0)
|
||||||
MainWindow.setStyleSheet(STYLE)
|
MainWindow.setStyleSheet(STYLE)
|
||||||
|
MainWindow.setWindowTitle("Login presik pos")
|
||||||
# MainWindow.setStyleSheet(u"margin:0;background-color: rgb(246, 245, 244);")
|
# MainWindow.setStyleSheet(u"margin:0;background-color: rgb(246, 245, 244);")
|
||||||
self.centralwidget = QWidget(MainWindow)
|
self.centralwidget = QWidget(MainWindow)
|
||||||
self.centralwidget.setObjectName(u"centralwidget")
|
self.centralwidget.setObjectName(u"centralwidget")
|
||||||
|
@ -255,3 +256,16 @@ class Ui_Login(object):
|
||||||
self.pushButtonOk.clicked.connect(MainWindow.accept)
|
self.pushButtonOk.clicked.connect(MainWindow.accept)
|
||||||
self.pushButtonCancel.clicked.connect(MainWindow.reject)
|
self.pushButtonCancel.clicked.connect(MainWindow.reject)
|
||||||
self.field_password.editingFinished.connect(MainWindow.accept)
|
self.field_password.editingFinished.connect(MainWindow.accept)
|
||||||
|
|
||||||
|
menubar = QMenuBar(self.centralwidget)
|
||||||
|
file_menu = menubar.addMenu("Opciones")
|
||||||
|
|
||||||
|
action_config = file_menu.addAction("Configuracion")
|
||||||
|
action_about = file_menu.addAction("Acerca de")
|
||||||
|
|
||||||
|
# Connect the action to a slot or function for handling the action
|
||||||
|
action_config.triggered.connect(MainWindow.open_config_file)
|
||||||
|
action_about.triggered.connect(MainWindow.show_about)
|
||||||
|
|
||||||
|
self.gridLayout_2.setMenuBar(menubar)
|
||||||
|
|
||||||
|
|
|
@ -2107,11 +2107,11 @@ class AppWindow(FrontWindow):
|
||||||
('payment_term', '=', self.default_payment_term['id']),
|
('payment_term', '=', self.default_payment_term['id']),
|
||||||
('payment_term', '=', None),
|
('payment_term', '=', None),
|
||||||
],
|
],
|
||||||
('reservation', '!=', True)
|
('reservation', 'in', [None, False]),
|
||||||
])
|
])
|
||||||
elif _type == 'credit':
|
elif _type == 'credit':
|
||||||
dom.extend([
|
dom.extend([
|
||||||
['reservation', '!=', True],
|
['reservation', 'in', [None, False]],
|
||||||
['payment_term', '!=', self.default_payment_term['id']]
|
['payment_term', '!=', self.default_payment_term['id']]
|
||||||
])
|
])
|
||||||
elif _type == 'reservation':
|
elif _type == 'reservation':
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
__version__ = "6.0.29"
|
__version__ = "6.0.30"
|
||||||
|
|
2
pospro
2
pospro
|
@ -6,9 +6,7 @@ import argparse
|
||||||
import setproctitle
|
import setproctitle
|
||||||
import psutil
|
import psutil
|
||||||
import ctypes
|
import ctypes
|
||||||
from PySide6.QtCore import Qt, QCoreApplication
|
|
||||||
from PySide6.QtWidgets import QApplication, QMessageBox
|
from PySide6.QtWidgets import QApplication, QMessageBox
|
||||||
# from PyQt5.QtWidgets import QApplication
|
|
||||||
from app.commons.dblogin import Login
|
from app.commons.dblogin import Login
|
||||||
from app import main
|
from app import main
|
||||||
from logger_config import logger
|
from logger_config import logger
|
||||||
|
|
Loading…
Reference in New Issue