Skip to content

Commit

Permalink
Merge pull request #14 from lyl-Lynx/dev
Browse files Browse the repository at this point in the history
Help menu added
  • Loading branch information
greg-ynx authored Mar 10, 2022
2 parents 34a3af2 + 62bdec2 commit 704369f
Show file tree
Hide file tree
Showing 12 changed files with 229 additions and 75 deletions.
9 changes: 0 additions & 9 deletions src/app/components/PatternGrid.py

This file was deleted.

Binary file not shown.
File renamed without changes.
84 changes: 84 additions & 0 deletions src/app/ui/AboutForm/AboutForm.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>About_Form</class>
<widget class="QWidget" name="About_Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>650</width>
<height>600</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>650</width>
<height>600</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>650</width>
<height>600</height>
</size>
</property>
<property name="windowTitle">
<string>About...</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>../../../assets/img/lyl8Lynx_logo.png</normaloff>../../../assets/img/lyl8Lynx_logo.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QGridLayout" name="textArea_grid_layout">
<item row="0" column="0">
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="enabled">
<bool>true</bool>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="bottom_horizontal_layout">
<item>
<spacer name="bottom_horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="close_button">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
72 changes: 72 additions & 0 deletions src/app/ui/AboutForm/UiAboutForm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'AboutForm.ui'
#
# Created by: PyQt5 UI code generator 5.15.6
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
import sys

from PyQt5 import QtCore, QtGui, QtWidgets


class UiAboutForm(object):

def __init__(self, about_form, title, icon_path, txt_file_path):

about_form.setObjectName("About_Form")
about_form.resize(650, 600)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(about_form.sizePolicy().hasHeightForWidth())
about_form.setSizePolicy(sizePolicy)
about_form.setMinimumSize(QtCore.QSize(650, 600))
about_form.setMaximumSize(QtCore.QSize(650, 600))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(icon_path), QtGui.QIcon.Normal, QtGui.QIcon.Off)
about_form.setWindowIcon(icon)
about_form.setWindowTitle(title)
self.about_form = about_form

self.gridLayout = QtWidgets.QGridLayout(about_form)
self.gridLayout.setObjectName("gridLayout")

self.textArea_grid_layout = QtWidgets.QGridLayout()
self.textArea_grid_layout.setObjectName("textArea_grid_layout")

self.plainTextEdit = QtWidgets.QPlainTextEdit(about_form)
self.plainTextEdit.setEnabled(True)
self.plainTextEdit.setFocusPolicy(QtCore.Qt.NoFocus)
self.plainTextEdit.setReadOnly(True)
self.plainTextEdit.setObjectName("plainTextEdit")
self.textArea_grid_layout.addWidget(self.plainTextEdit, 0, 0, 1, 1)

self.gridLayout.addLayout(self.textArea_grid_layout, 0, 0, 1, 1)

self.bottom_horizontal_layout = QtWidgets.QHBoxLayout()
self.bottom_horizontal_layout.setObjectName("bottom_horizontal_layout")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.bottom_horizontal_layout.addItem(spacerItem)

self.close_button = QtWidgets.QPushButton(about_form)
self.close_button.setObjectName("close_button")
self.close_button.clicked.connect(self.about_form.close)
self.bottom_horizontal_layout.addWidget(self.close_button)

self.gridLayout.addLayout(self.bottom_horizontal_layout, 1, 0, 1, 1)

self.retranslateUi(about_form)
self.set_text(txt_file_path)
QtCore.QMetaObject.connectSlotsByName(about_form)

def set_text(self, txt_file_path):
with open(txt_file_path, 'r', encoding='utf-8') as f:
content = f.read()
self.plainTextEdit.setPlainText(content)

def retranslateUi(self, about_form):
_translate = QtCore.QCoreApplication.translate
#about_form.setWindowTitle(_translate("About_Form", "About..."))
self.close_button.setText(_translate("About_Form", "Close"))
Binary file not shown.
105 changes: 43 additions & 62 deletions src/app/ui/MainWindow/UiMainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

import sys



from src.app.ui.TableView.UiTableViewForm import UiTableViewForm
from src.app.ui.AboutForm.UiAboutForm import UiAboutForm
import webbrowser
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QStandardItem, QColor
from PyQt5.QtWidgets import QPushButton
from src.app.components.PatternGrid import PatternGrid


class UiMainWindow(object):
Expand All @@ -31,10 +31,29 @@ def __init__(self, main_window):
size_policy.setHeightForWidth(main_window.sizePolicy().hasHeightForWidth())
main_window.setSizePolicy(size_policy)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("../../../assets/img/pattern_builder_icon.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
icon.addPixmap(QtGui.QPixmap("../../../assets/img/pattern_builder_icon.ico"), QtGui.QIcon.Normal,
QtGui.QIcon.Off)
main_window.setWindowIcon(icon)
self.main_window = main_window

self.help_pattern_builder_widget = QtWidgets.QWidget()
self.help_pattern_builder_form = UiAboutForm(self.help_pattern_builder_widget,
"Pattern builder help",
"../../../assets/img/QuestionMark.png",
"../../../assets/txt/help_pattern_builder.txt")

self.about_pattern_builder_widget = QtWidgets.QWidget()
self.about_pattern_builder_form = UiAboutForm(self.about_pattern_builder_widget,
"About Pattern Builder",
"../../../assets/img/pattern_builder_logo_c_800px.png",
"../../../assets/txt/about_pattern_builder.txt")

self.about_lyl_lynx_widget = QtWidgets.QWidget()
self.about_lyl_lynx_form = UiAboutForm(self.about_lyl_lynx_widget,
"About lyl-Lynx",
"../../../assets/img/lyl8Lynx_logo.png",
"../../../assets/txt/about_lyl_lynx.txt")

self.colors_widget = QtWidgets.QWidget()
self.table_view_form = UiTableViewForm(self.colors_widget)
self.table_view_form.close_button.clicked.connect(self.update_colors_select)
Expand Down Expand Up @@ -177,11 +196,15 @@ def __init__(self, main_window):
self.verticalLayout.addWidget(self.toolBox_colors_title)

self.colors_comboBox = QtWidgets.QComboBox(self.toolBox_frame)
self.colors_comboBox.setMaxVisibleItems(64)
self.colors_comboBox.setMaxVisibleItems(16)
model = self.colors_comboBox.model()
self.colors_comboBox.setObjectName("colors_comboBox")
initial_items = self.table_view_form.get_all()
for item in initial_items:
self.colors_comboBox.addItem(str(item['id']))
c_item = QStandardItem()
c_item.setText(str(item['id']))
c_item.setBackground(QColor(item['Hex']))
model.appendRow(c_item)
self.selected_color_id = int(self.colors_comboBox.currentText())
self.verticalLayout.addWidget(self.colors_comboBox)

Expand Down Expand Up @@ -222,26 +245,6 @@ def __init__(self, main_window):

self.verticalLayout.addLayout(self.reset_button_horizontal_layout)

self.save_button_horizontal_layout = QtWidgets.QHBoxLayout()
self.save_button_horizontal_layout.setObjectName("save_button_horizontal_layout")

spacerItem7 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.save_button_horizontal_layout.addItem(spacerItem7)

self.save_button = QtWidgets.QPushButton(self.toolBox_frame)
size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
size_policy.setHorizontalStretch(0)
size_policy.setVerticalStretch(0)
size_policy.setHeightForWidth(self.save_button.sizePolicy().hasHeightForWidth())
self.save_button.setSizePolicy(size_policy)
self.save_button.setObjectName("save_button")
self.save_button_horizontal_layout.addWidget(self.save_button)

spacerItem8 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.save_button_horizontal_layout.addItem(spacerItem8)

self.verticalLayout.addLayout(self.save_button_horizontal_layout)

self.export_button_horizontal_layout = QtWidgets.QHBoxLayout()
self.export_button_horizontal_layout.setObjectName("export_button_horizontal_layout")

Expand Down Expand Up @@ -341,30 +344,6 @@ def __init__(self, main_window):
self.statusbar.setObjectName("statusbar")
main_window.setStatusBar(self.statusbar)

self.action_new = QtWidgets.QAction(main_window)
icon4 = QtGui.QIcon()
icon4.addPixmap(QtGui.QPixmap("../../../assets/img/NewFile.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.action_new.setIcon(icon4)
self.action_new.setObjectName("action_new")

self.action_open = QtWidgets.QAction(main_window)
icon5 = QtGui.QIcon()
icon5.addPixmap(QtGui.QPixmap("../../../assets/img/OpenFile.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.action_open.setIcon(icon5)
self.action_open.setObjectName("action_open")

self.action_save = QtWidgets.QAction(main_window)
icon6 = QtGui.QIcon()
icon6.addPixmap(QtGui.QPixmap("../../../assets/img/Save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.action_save.setIcon(icon6)
self.action_save.setObjectName("action_save")

self.action_save_as = QtWidgets.QAction(main_window)
icon7 = QtGui.QIcon()
icon7.addPixmap(QtGui.QPixmap("../../../assets/img/SaveAs.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.action_save_as.setIcon(icon7)
self.action_save_as.setObjectName("action_save_as")

self.action_matrix_text_file_txt = QtWidgets.QAction(main_window)
self.action_matrix_text_file_txt.setObjectName("action_matrix_text_file_txt")

Expand Down Expand Up @@ -421,22 +400,26 @@ def __init__(self, main_window):
icon8.addPixmap(QtGui.QPixmap("../../../assets/img/QuestionMark.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.action_help.setIcon(icon8)
self.action_help.setObjectName("action_help")
self.action_help.triggered.connect(self.help_pattern_builder_widget.show)

self.action_about_pb = QtWidgets.QAction(main_window)
self.action_about_pb.setIcon(icon3)
self.action_about_pb.setObjectName("action_about_pb")
self.action_about_pb.triggered.connect(self.about_pattern_builder_widget.show)

self.action_about_author = QtWidgets.QAction(main_window)
icon9 = QtGui.QIcon()
icon9.addPixmap(QtGui.QPixmap("../../../assets/img/lyl8Lynx_logo.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.action_about_author.setIcon(icon9)
self.action_about_author.setObjectName("action_about_author")
self.action_about_author.triggered.connect(self.about_lyl_lynx_widget.show)

self.action_join_us = QtWidgets.QAction(main_window)
icon10 = QtGui.QIcon()
icon10.addPixmap(QtGui.QPixmap("../../../assets/img/GitHub.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.action_join_us.setIcon(icon10)
self.action_join_us.setObjectName("action_join_us")
self.action_join_us.triggered.connect(self.redirect_to_github_repo)

self.menu_matrix.addAction(self.action_matrix_text_file_txt)
self.menu_matrix.addAction(self.action_matrix_json)
Expand All @@ -461,11 +444,6 @@ def __init__(self, main_window):
self.menu_pattern.addAction(self.action_pattern_pdf)
self.menu_export_as.addAction(self.menu_pattern.menuAction())

self.menu_file.addAction(self.action_new)
self.menu_file.addAction(self.action_open)
self.menu_file.addSeparator()
self.menu_file.addAction(self.action_save)
self.menu_file.addAction(self.action_save_as)
self.menu_file.addAction(self.menu_export_as.menuAction())

self.menu_help.addAction(self.action_help)
Expand Down Expand Up @@ -496,15 +474,19 @@ def colors_count(self):
def update_colors_select(self):
items = self.table_view_form.get_all().copy()
self.colors_comboBox.clear()
model = self.colors_comboBox.model()
for item in items:
self.colors_comboBox.addItem(str(item['id']))
c_item = QStandardItem()
c_item.setText(str(item['id']))
c_item.setBackground(QColor(item['Hex']))
model.appendRow(c_item)

def switch_button_color(self):
button = self.main_window.sender()
params = self.get_selected_color()
print(params)
button.setText(str(params['id']))
button.setStyleSheet("background-color : "+params['Hex'])
button.setStyleSheet("background-color : " + params['Hex'])

def update_matrix_size(self):
for row in range(self.get_height()):
Expand Down Expand Up @@ -532,6 +514,9 @@ def on_change_size(self):
self.gridLayout.itemAt(i).widget().setParent(None)
self.update_matrix_size()

def redirect_to_github_repo(self):
webbrowser.open('https://github.com/lyl-Lynx/Pattern-Builder')

def retranslate_ui(self, main_window):
_translate = QtCore.QCoreApplication.translate
main_window.setWindowTitle(_translate("main_window", "Pattern Builder by lyl-Lynx"))
Expand All @@ -542,17 +527,12 @@ def retranslate_ui(self, main_window):
self.toolBox_colors_title.setText(_translate("main_window", "Colors"))
self.colors_table_button.setText(_translate("main_window", "Open colors table"))
self.reset_button.setText(_translate("main_window", "Reset pattern"))
self.save_button.setText(_translate("main_window", "Save"))
self.export_button.setText(_translate("main_window", "Export"))
self.menu_file.setTitle(_translate("main_window", "File"))
self.menu_export_as.setTitle(_translate("main_window", "Export as..."))
self.menu_matrix.setTitle(_translate("main_window", "Matrix"))
self.menu_pattern.setTitle(_translate("main_window", "Pattern"))
self.menu_help.setTitle(_translate("main_window", "Help"))
self.action_new.setText(_translate("main_window", "New..."))
self.action_open.setText(_translate("main_window", "Open..."))
self.action_save.setText(_translate("main_window", "Save"))
self.action_save_as.setText(_translate("main_window", "Save as..."))
self.action_matrix_text_file_txt.setText(_translate("main_window", "Text file (.txt)"))
self.action_matrix_json.setText(_translate("main_window", "JSON (.json)"))
self.action_matrix_tabler_csv.setText(_translate("main_window", "Tabler (.csv)"))
Expand All @@ -575,6 +555,7 @@ def retranslate_ui(self, main_window):
self.action_about_author.setText(_translate("main_window", "About lyl-Lynx"))
self.action_join_us.setText(_translate("main_window", "Join us on GitHub !"))


if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
Expand Down
Loading

0 comments on commit 704369f

Please sign in to comment.