feat: new gui
4
.gitignore
vendored
@@ -158,3 +158,7 @@ cython_debug/
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
# KKAFIO stuff
|
||||
traceback.log
|
||||
app/config/
|
||||
78
KKAFIO.py
@@ -1,48 +1,40 @@
|
||||
import customtkinter
|
||||
import platform
|
||||
import customtkinter
|
||||
import ctypes
|
||||
# coding:utf-8
|
||||
import os
|
||||
import sys
|
||||
|
||||
from gui.frames.sidebar import Sidebar
|
||||
from gui.frames.logger import LoggerTextBox
|
||||
from gui.util.config import Config
|
||||
from gui.util.linker import Linker
|
||||
from PySide6.QtCore import Qt, QTranslator
|
||||
from PySide6.QtGui import QFont
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from qfluentwidgets import FluentTranslator
|
||||
|
||||
class App(customtkinter.CTk):
|
||||
def __init__(self):
|
||||
super().__init__("#18173C")
|
||||
self.configure_window()
|
||||
linker = Linker(self)
|
||||
config = Config(linker, "config.json")
|
||||
sidebar = Sidebar(self, linker, config, fg_color="#25224F")
|
||||
sidebar.grid(row=0, column=0, sticky="nsw")
|
||||
logger = LoggerTextBox(self, linker, config, fg_color="#262250")
|
||||
logger.grid(row=0, column=2, pady=20, sticky="nsew")
|
||||
config.load_config()
|
||||
from app.common.config import cfg
|
||||
from app.view.main_window import MainWindow
|
||||
|
||||
def configure_window(self):
|
||||
self.title("KKAFIO")
|
||||
self.geometry(f"{1500}x{850}")
|
||||
self.iconbitmap('gui/icons/karin.ico')
|
||||
"""
|
||||
solution to Settings Frame and Logger Frame widths not being
|
||||
consistent between different windows scaling factors
|
||||
"""
|
||||
self.scaling_factor = self.get_scaling_factor()
|
||||
self.grid_columnconfigure(0, weight=0)
|
||||
self.grid_columnconfigure(1, weight=0, minsize=650*self.scaling_factor)
|
||||
self.grid_columnconfigure(2, weight=1, minsize=506*self.scaling_factor)
|
||||
self.grid_rowconfigure(0, weight=1)
|
||||
|
||||
def get_scaling_factor(self):
|
||||
system = platform.system()
|
||||
|
||||
if system == 'Windows':
|
||||
user32 = ctypes.windll.user32
|
||||
return user32.GetDpiForSystem() / 96.0
|
||||
|
||||
return 1.0 # Default scaling factor for unknown or unsupported systems
|
||||
# enable dpi scale
|
||||
if cfg.get(cfg.dpiScale) != "Auto":
|
||||
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"
|
||||
os.environ["QT_SCALE_FACTOR"] = str(cfg.get(cfg.dpiScale))
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = App()
|
||||
app.mainloop()
|
||||
# create application
|
||||
app = QApplication(sys.argv)
|
||||
app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)
|
||||
|
||||
# fixes issue: https://github.com/zhiyiYo/PyQt-Fluent-Widgets/issues/848
|
||||
if sys.platform == 'win32' and sys.getwindowsversion().build >= 22000:
|
||||
app.setStyle("fusion")
|
||||
|
||||
|
||||
# internationalization
|
||||
locale = cfg.get(cfg.language).value
|
||||
translator = FluentTranslator(locale)
|
||||
galleryTranslator = QTranslator()
|
||||
galleryTranslator.load(locale, "gallery", ".", ":/gallery/i18n")
|
||||
|
||||
app.installTranslator(translator)
|
||||
app.installTranslator(galleryTranslator)
|
||||
|
||||
# create main window
|
||||
w = MainWindow()
|
||||
w.show()
|
||||
app.exec()
|
||||
687
LICENSE
@@ -1,21 +1,674 @@
|
||||
MIT License
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (c) 2023 RedDeadDepresso
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Preamble
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
|
||||
158
app/common/config.py
Normal file
@@ -0,0 +1,158 @@
|
||||
# coding:utf-8
|
||||
import os
|
||||
import sys
|
||||
from enum import Enum
|
||||
|
||||
from PySide6.QtCore import QLocale
|
||||
from qfluentwidgets import (qconfig, QConfig, ConfigItem, OptionsConfigItem, BoolValidator,
|
||||
OptionsValidator, RangeConfigItem, RangeValidator,
|
||||
FolderListValidator, Theme, FolderValidator, ConfigSerializer, __version__)
|
||||
|
||||
|
||||
class Language(Enum):
|
||||
""" Language enumeration """
|
||||
|
||||
CHINESE_SIMPLIFIED = QLocale(QLocale.Chinese, QLocale.China)
|
||||
CHINESE_TRADITIONAL = QLocale(QLocale.Chinese, QLocale.HongKong)
|
||||
ENGLISH = QLocale(QLocale.English)
|
||||
AUTO = QLocale()
|
||||
|
||||
|
||||
class LanguageSerializer(ConfigSerializer):
|
||||
""" Language serializer """
|
||||
|
||||
def serialize(self, language):
|
||||
return language.value.name() if language != Language.AUTO else "Auto"
|
||||
|
||||
def deserialize(self, value: str):
|
||||
return Language(QLocale(value)) if value != "Auto" else Language.AUTO
|
||||
|
||||
|
||||
def isWin11():
|
||||
return sys.platform == 'win32' and sys.getwindowsversion().build >= 22000
|
||||
|
||||
|
||||
class Config(QConfig):
|
||||
""" Config of application """
|
||||
|
||||
# core
|
||||
gamePath = ConfigItem("Core", "GamePath", "", FolderValidator())
|
||||
|
||||
# createBackup
|
||||
backupEnable = ConfigItem(
|
||||
"CreateBackup", "Enable", False, BoolValidator()
|
||||
)
|
||||
backupPath = ConfigItem(
|
||||
"CreateBackup", "OutputPath", "", FolderValidator()
|
||||
)
|
||||
filename = ConfigItem(
|
||||
"CreateBackup", "Filename", "",
|
||||
)
|
||||
userData = ConfigItem(
|
||||
"CreateBackup", "UserData", False, BoolValidator()
|
||||
)
|
||||
mods = ConfigItem(
|
||||
"CreateBackup", "mods", False, BoolValidator()
|
||||
)
|
||||
bepInEx = ConfigItem(
|
||||
"CreateBackup", "BepInEx", False, BoolValidator()
|
||||
)
|
||||
|
||||
# fckks
|
||||
fckksEnable = ConfigItem(
|
||||
"FCKKS", "Enable", False, BoolValidator()
|
||||
)
|
||||
fccksPath = ConfigItem(
|
||||
"FCKKS", "InputPath", "", FolderValidator()
|
||||
)
|
||||
convert = ConfigItem(
|
||||
"FCKKS", "Convert", False, BoolValidator()
|
||||
)
|
||||
|
||||
# installChara
|
||||
installEnable = ConfigItem(
|
||||
"InstallChara", "Enable", False, BoolValidator()
|
||||
)
|
||||
gamePath = ConfigItem(
|
||||
"InstallChara", "InputPath", "", FolderValidator())
|
||||
fileConflicts = OptionsConfigItem(
|
||||
"InstallChara", "FileConflicts", "Skip", OptionsValidator(["Skip", "Replace", "Rename"])
|
||||
)
|
||||
archivePassword = OptionsConfigItem(
|
||||
"InstallChara", "FileConflicts", "Skip", OptionsValidator(["Skip", "Request Password"])
|
||||
)
|
||||
|
||||
# removeChara
|
||||
removeEnable = ConfigItem(
|
||||
"RemoveChara", "Enable", False, BoolValidator()
|
||||
)
|
||||
gamePath = ConfigItem(
|
||||
"InstallChara", "InputPath", "", FolderValidator())
|
||||
|
||||
# main window
|
||||
micaEnabled = ConfigItem("MainWindow", "MicaEnabled", isWin11(), BoolValidator())
|
||||
dpiScale = OptionsConfigItem(
|
||||
"MainWindow", "DpiScale", "Auto", OptionsValidator([1, 1.25, 1.5, 1.75, 2, "Auto"]), restart=True)
|
||||
language = OptionsConfigItem(
|
||||
"MainWindow", "Language", Language.AUTO, OptionsValidator(Language), LanguageSerializer(), restart=True)
|
||||
|
||||
# Material
|
||||
blurRadius = RangeConfigItem("Material", "AcrylicBlurRadius", 15, RangeValidator(0, 40))
|
||||
|
||||
# software update
|
||||
checkUpdateAtStartUp = ConfigItem("Update", "CheckUpdateAtStartUp", True, BoolValidator())
|
||||
|
||||
# def validate(self):
|
||||
# Logger.log_info("SCRIPT", "Validating config")
|
||||
# self.ok = True
|
||||
# self.tasks = self.config_data["Core"]["Tasks"]
|
||||
# self.create_gamepath()
|
||||
|
||||
# for task in self.tasks:
|
||||
# if self.config_data[task]["Enable"]:
|
||||
# if "InputPath" in self.config_data[task]:
|
||||
# path = self.config_data[task]["InputPath"]
|
||||
# elif "OutputPath" in self.config_data[task]:
|
||||
# path = self.config_data[task]["OutputPath"]
|
||||
# if not os.path.exists(path):
|
||||
# Logger.log_error("SCRIPT", f"Path invalid for task {task}")
|
||||
# raise Exception()
|
||||
|
||||
# self.install_chara = self.config_data.get("InstallChara", {})
|
||||
# self.create_backup = self.config_data.get("CreateBackup", {})
|
||||
# self.remove_chara = self.config_data.get("RemoveChara", {})
|
||||
# self.fc_kks = self.config_data.get("FCKKS", {})
|
||||
|
||||
# def create_gamepath(self):
|
||||
# base = self.config_data["Core"]["GamePath"]
|
||||
# self.game_path = {
|
||||
# "base": base,
|
||||
# "UserData": os.path.join(base, "UserData"),
|
||||
# "BepInEx": os.path.join(base, "BepInEx"),
|
||||
# "mods": os.path.join(base, "mods"),
|
||||
# "chara": os.path.join(base, "UserData\\chara\\female"),
|
||||
# "coordinate": os.path.join(base, "UserData\coordinate"),
|
||||
# "Overlays": os.path.join(base, "UserData\Overlays")
|
||||
# }
|
||||
|
||||
# for path in self.game_path.values():
|
||||
# if not os.path.exists(path):
|
||||
# Logger.log_error("SCRIPT", "Game path not valid")
|
||||
# raise Exception()
|
||||
|
||||
|
||||
YEAR = 2023
|
||||
AUTHOR = "zhiyiYo"
|
||||
VERSION = __version__
|
||||
HELP_URL = "https://qfluentwidgets.com"
|
||||
REPO_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets"
|
||||
EXAMPLE_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/PySide6/examples"
|
||||
FEEDBACK_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets/issues"
|
||||
RELEASE_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets/releases/latest"
|
||||
ZH_SUPPORT_URL = "https://qfluentwidgets.com/zh/price/"
|
||||
EN_SUPPORT_URL = "https://qfluentwidgets.com/price/"
|
||||
|
||||
|
||||
cfg = Config()
|
||||
cfg.themeMode.value = Theme.AUTO
|
||||
qconfig.load('app/config/config.json', cfg)
|
||||
@@ -5,7 +5,9 @@ import patoolib
|
||||
import customtkinter
|
||||
import subprocess
|
||||
import time
|
||||
from util.logger import Logger
|
||||
|
||||
from app.common.logger import logger
|
||||
|
||||
|
||||
class FileManager:
|
||||
|
||||
@@ -41,11 +43,11 @@ class FileManager:
|
||||
already_exists = os.path.exists(destination_path)
|
||||
|
||||
if already_exists and conflicts == "Skip":
|
||||
Logger.log_skipped(type, base_name)
|
||||
logger.log_skipped(type, base_name)
|
||||
return
|
||||
|
||||
elif already_exists and conflicts == "Replace":
|
||||
Logger.log_replaced(type, base_name)
|
||||
logger.log_replaced(type, base_name)
|
||||
|
||||
elif already_exists and conflicts == "Rename":
|
||||
max_retries = 3
|
||||
@@ -56,7 +58,7 @@ class FileManager:
|
||||
new_source_path = f"{filename}_{new_name}{file_extension}"
|
||||
os.rename(source_path, new_source_path)
|
||||
source_path = new_source_path
|
||||
Logger.log_renamed(type, base_name)
|
||||
logger.log_renamed(type, base_name)
|
||||
|
||||
filename, file_extension = os.path.splitext(destination_path)
|
||||
destination_path = f"{filename}_{new_name}{file_extension}"
|
||||
@@ -65,20 +67,20 @@ class FileManager:
|
||||
if attempt < max_retries - 1:
|
||||
time.sleep(1) # Wait for 1 second before retrying
|
||||
else:
|
||||
Logger.log_error(type, f"Failed to rename {base_name} after {max_retries} attempts.")
|
||||
logger.log_error(type, f"Failed to rename {base_name} after {max_retries} attempts.")
|
||||
return
|
||||
|
||||
try:
|
||||
shutil.copy(source_path, destination_path)
|
||||
print(f"File copied successfully from {source_path} to {destination_path}")
|
||||
if not already_exists:
|
||||
Logger.log_success(type, base_name)
|
||||
logger.log_success(type, base_name)
|
||||
except FileNotFoundError:
|
||||
Logger.log_error(type, f"{base_name} does not exist.")
|
||||
logger.log_error(type, f"{base_name} does not exist.")
|
||||
except PermissionError:
|
||||
Logger.log_error(type, f"Permission denied for {base_name}")
|
||||
logger.log_error(type, f"Permission denied for {base_name}")
|
||||
except Exception as e:
|
||||
Logger.log_error(type, f"An error occurred: {e}")
|
||||
logger.log_error(type, f"An error occurred: {e}")
|
||||
|
||||
def find_and_remove(self, type, source_path, destination_folder):
|
||||
source_path = source_path[0]
|
||||
@@ -87,15 +89,15 @@ class FileManager:
|
||||
if os.path.exists(destination_path):
|
||||
try:
|
||||
os.remove(destination_path)
|
||||
Logger.log_removed(type, base_name)
|
||||
logger.log_removed(type, base_name)
|
||||
except OSError as e:
|
||||
Logger.log_error(type, base_name)
|
||||
logger.log_error(type, base_name)
|
||||
|
||||
def create_archive(self, folders, archive_path):
|
||||
# Specify the full path to the 7zip executable
|
||||
path_to_7zip = patoolib.util.find_program("7z")
|
||||
if not path_to_7zip:
|
||||
Logger.log_error("SCRIPT", "7zip not found. Unable to create backup")
|
||||
logger.log_error("SCRIPT", "7zip not found. Unable to create backup")
|
||||
raise Exception()
|
||||
|
||||
if os.path.exists(archive_path+".7z"):
|
||||
@@ -133,7 +135,7 @@ class FileManager:
|
||||
# Print the output
|
||||
for line in process.stdout.decode().split('\n'):
|
||||
if line.strip() != "":
|
||||
Logger.log_info("7-Zip", line)
|
||||
logger.log_info("7-Zip", line)
|
||||
# Check the return code
|
||||
if process.returncode not in [0, 1]:
|
||||
raise Exception()
|
||||
@@ -141,7 +143,7 @@ class FileManager:
|
||||
def extract_archive(self, archive_path):
|
||||
try:
|
||||
archive_name = os.path.basename(archive_path)
|
||||
Logger.log_info("ARCHIVE", f"Extracting {archive_name}")
|
||||
logger.log_info("ARCHIVE", f"Extracting {archive_name}")
|
||||
extract_path = os.path.join(f"{os.path.splitext(archive_path)[0]}_{datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')}")
|
||||
patoolib.extract_archive(archive_path, outdir=extract_path)
|
||||
return extract_path
|
||||
@@ -161,5 +163,7 @@ class FileManager:
|
||||
except:
|
||||
text = f"Wrong password or {archive_name} is corrupted. Please enter password again or click Cancel"
|
||||
|
||||
Logger.log_skipped("ARCHIVE", archive_name)
|
||||
logger.log_skipped("ARCHIVE", archive_name)
|
||||
|
||||
|
||||
fileManager = FileManager()
|
||||
110
app/common/logger.py
Normal file
@@ -0,0 +1,110 @@
|
||||
import logging
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from typing import Union
|
||||
|
||||
from app.common.signal_bus import signalBus
|
||||
|
||||
|
||||
class Logger:
|
||||
"""
|
||||
Logger class for logging
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
:param logger_signal: Logger Box signal
|
||||
"""
|
||||
# Init logger box signal, logs and logger
|
||||
# logger box signal is used to output log to logger box
|
||||
self.logs = ""
|
||||
self.logger_signal = signalBus.loggerSignal
|
||||
self.logger = logging.getLogger("BAAS_Logger")
|
||||
formatter = logging.Formatter("%(levelname)8s |%(asctime)20s | %(message)s ")
|
||||
handler1 = logging.StreamHandler(stream=sys.stdout)
|
||||
handler1.setFormatter(formatter)
|
||||
self.logger.setLevel(logging.INFO)
|
||||
self.logger.addHandler(handler1)
|
||||
|
||||
def __out__(self, message: str, level: int = 1, raw_print=False) -> None:
|
||||
"""
|
||||
Output log
|
||||
:param message: log message
|
||||
:param level: log level
|
||||
:return: None
|
||||
"""
|
||||
# If raw_print is True, output log to logger box
|
||||
if raw_print:
|
||||
self.logs += message
|
||||
self.logger_signal.emit(message)
|
||||
return
|
||||
|
||||
while len(logging.root.handlers) > 0:
|
||||
logging.root.handlers.pop()
|
||||
# Status Text: INFO, WARNING, ERROR, CRITICAL
|
||||
status = [' INFO', ' WARNING', ' ERROR', 'CRITICAL']
|
||||
# Status Color: Blue, Orange, Red, Purple
|
||||
statusColor = ['#2d8cf0', '#f90', '#ed3f14', '#3e0480']
|
||||
# Status HTML: <b style="color:$color">status</b>
|
||||
statusHtml = [
|
||||
f'<b style="color:{_color};">{status}</b>'
|
||||
for _color, status in zip(statusColor, status)]
|
||||
# If logger box is not None, output log to logger box
|
||||
# else output log to console
|
||||
if self.logger_signal is not None:
|
||||
message = message.replace('\n', '<br>').replace(' ', ' ')
|
||||
adding = (f'''
|
||||
<div style="font-family: Consolas, monospace;color:{statusColor[level - 1]};">
|
||||
{statusHtml[level - 1]} | {datetime.now().strftime("%Y-%m-%d %H:%M:%S")} | {message}
|
||||
</div>
|
||||
''')
|
||||
self.logs += adding
|
||||
self.logger_signal.emit(adding)
|
||||
else:
|
||||
print(f'{statusHtml[level - 1]} | {datetime.now().strftime("%Y-%m-%d %H:%M:%S")} | {message}')
|
||||
|
||||
def info(self, message: str) -> None:
|
||||
"""
|
||||
:param message: log message
|
||||
|
||||
Output info log
|
||||
"""
|
||||
self.__out__(message, 1)
|
||||
|
||||
def warning(self, message: str) -> None:
|
||||
"""
|
||||
:param message: log message
|
||||
|
||||
Output warn log
|
||||
"""
|
||||
self.__out__(message, 2)
|
||||
|
||||
def error(self, message: Union[str, Exception]) -> None:
|
||||
"""
|
||||
:param message: log message
|
||||
|
||||
Output error log
|
||||
"""
|
||||
self.__out__(message, 3)
|
||||
|
||||
def critical(self, message: str) -> None:
|
||||
"""
|
||||
:param message: log message
|
||||
|
||||
Output critical log
|
||||
"""
|
||||
self.__out__(message, 4)
|
||||
|
||||
def line(self) -> None:
|
||||
"""
|
||||
Output line
|
||||
"""
|
||||
# While the line print do not need wrapping, we
|
||||
# use raw_print=True to output log to logger box
|
||||
self.__out__(
|
||||
'<div style="font-family: Consolas, monospace;color:#2d8cf0;">--------------'
|
||||
'-------------------------------------------------------------'
|
||||
'-------------------</div>', raw_print=True)
|
||||
|
||||
|
||||
logger = Logger()
|
||||
261049
app/common/resource.py
Normal file
20
app/common/signal_bus.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# coding: utf-8
|
||||
from PySide6.QtCore import QObject, Signal
|
||||
from qfluentwidgets import SettingCardGroup
|
||||
|
||||
|
||||
class SignalBus(QObject):
|
||||
""" Signal bus """
|
||||
|
||||
switchToSettingGroup = Signal(SettingCardGroup)
|
||||
micaEnableChanged = Signal(bool)
|
||||
supportSignal = Signal()
|
||||
|
||||
selectAllClicked = Signal()
|
||||
clearAllClicked = Signal()
|
||||
startSignal = Signal()
|
||||
stopSignal = Signal()
|
||||
loggerSignal = Signal(str)
|
||||
|
||||
|
||||
signalBus = SignalBus()
|
||||
21
app/common/style_sheet.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# coding: utf-8
|
||||
from enum import Enum
|
||||
|
||||
from qfluentwidgets import StyleSheetBase, Theme, isDarkTheme, qconfig
|
||||
|
||||
|
||||
class StyleSheet(StyleSheetBase, Enum):
|
||||
""" Style sheet """
|
||||
|
||||
LINK_CARD = "link_card"
|
||||
SAMPLE_CARD = "sample_card"
|
||||
HOME_INTERFACE = "home_interface"
|
||||
ICON_INTERFACE = "icon_interface"
|
||||
VIEW_INTERFACE = "view_interface"
|
||||
SETTING_INTERFACE = "setting_interface"
|
||||
GALLERY_INTERFACE = "gallery_interface"
|
||||
NAVIGATION_VIEW_INTERFACE = "navigation_view_interface"
|
||||
|
||||
def path(self, theme=Theme.AUTO):
|
||||
theme = qconfig.theme if theme == Theme.AUTO else theme
|
||||
return f":/gallery/qss/{theme.value.lower()}/{self.value}.qss"
|
||||
45
app/components/line_edit_card.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# coding:utf-8
|
||||
from typing import Union
|
||||
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtGui import QIcon
|
||||
|
||||
from qfluentwidgets import ConfigItem, FluentIconBase, LineEdit, SettingCard
|
||||
|
||||
from ..common.config import qconfig
|
||||
|
||||
|
||||
class LineEditSettingCard(SettingCard):
|
||||
""" Setting card with a line edit """
|
||||
|
||||
def __init__(self, configItem: ConfigItem, icon: Union[str, QIcon, FluentIconBase], title, content=None, parent=None):
|
||||
"""
|
||||
Parameters
|
||||
----------
|
||||
configItem: OptionsConfigItem
|
||||
configuration item operated by the card
|
||||
|
||||
icon: str | QIcon | FluentIconBase
|
||||
the icon to be drawn
|
||||
|
||||
title: str
|
||||
the title of card
|
||||
|
||||
content: str
|
||||
the content of card
|
||||
|
||||
parent: QWidget
|
||||
parent widget
|
||||
"""
|
||||
super().__init__(icon, title, content, parent)
|
||||
self.configItem = configItem
|
||||
self.lineEdit = LineEdit(self)
|
||||
self.hBoxLayout.addWidget(self.lineEdit, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addSpacing(16)
|
||||
|
||||
self.lineEdit.setText(qconfig.get(configItem))
|
||||
configItem.valueChanged.connect(self.setValue)
|
||||
self.lineEdit.textChanged.connect(self.setValue)
|
||||
|
||||
def setValue(self, value):
|
||||
qconfig.set(self.configItem, value)
|
||||
55
app/components/navigation_action_buttons.py
Normal file
@@ -0,0 +1,55 @@
|
||||
# coding:utf-8
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QHBoxLayout, QVBoxLayout, QWidget
|
||||
|
||||
from qfluentwidgets import PushButton
|
||||
|
||||
from app.common.signal_bus import signalBus
|
||||
|
||||
|
||||
class NavigationActionButtons(QWidget):
|
||||
""" Navigation widget with select all and clear all buttons """
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.mainLayout = QVBoxLayout()
|
||||
self.upperLayout = QHBoxLayout()
|
||||
self.lowerLayout = QHBoxLayout()
|
||||
|
||||
self.selectAllButton = PushButton("Select All")
|
||||
self.clearAllButton = PushButton("Clear All")
|
||||
self.startButton = PushButton("Start")
|
||||
|
||||
self.__initLayout()
|
||||
self.__connectSignalToSlot()
|
||||
|
||||
def __initLayout(self):
|
||||
self.upperLayout.addWidget(self.selectAllButton, alignment=Qt.AlignVCenter)
|
||||
self.upperLayout.addWidget(self.clearAllButton, alignment=Qt.AlignVCenter)
|
||||
self.lowerLayout.addWidget(self.startButton, alignment=Qt.AlignVCenter)
|
||||
|
||||
self.mainLayout.addLayout(self.upperLayout)
|
||||
self.mainLayout.addSpacing(20)
|
||||
self.mainLayout.addLayout(self.lowerLayout)
|
||||
|
||||
self.setLayout(self.mainLayout)
|
||||
|
||||
def __connectSignalToSlot(self):
|
||||
self.selectAllButton.clicked.connect(self.onSelectAllClicked)
|
||||
self.clearAllButton.clicked.connect(self.onClearAllClicked)
|
||||
|
||||
signalBus.startSignal.connect(lambda: self.startButton.setText("Stop"))
|
||||
signalBus.stopSignal.connect(lambda: self.startButton.setText("Start"))
|
||||
|
||||
def onSelectAllClicked(self):
|
||||
signalBus.selectAllClicked.emit()
|
||||
|
||||
def onClearAllClicked(self):
|
||||
signalBus.clearAllClicked.emit()
|
||||
|
||||
def onStartClicked(self):
|
||||
text = self.startButton.text()
|
||||
if text == "Start":
|
||||
signalBus.startSignal.emit()
|
||||
elif text == "Stop":
|
||||
signalBus.stopSignal.emit()
|
||||
36
app/components/navigation_checkbox.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# coding:utf-8
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QHBoxLayout, QWidget
|
||||
|
||||
from qfluentwidgets import ToolButton, CheckBox
|
||||
from qfluentwidgets.common.icon import FluentIcon as FIF
|
||||
|
||||
from app.common.signal_bus import signalBus
|
||||
|
||||
|
||||
class NavigationCheckBox(QWidget):
|
||||
def __init__(self, text, settingGroup) -> None:
|
||||
super().__init__()
|
||||
self.layout = QHBoxLayout()
|
||||
self.checkBox = CheckBox(text)
|
||||
self.toolButton = ToolButton(FIF.SETTING)
|
||||
self.settingGroup = settingGroup
|
||||
|
||||
self.__initLayout()
|
||||
self.__connectSignalToSlot()
|
||||
|
||||
def __initLayout(self):
|
||||
self.layout.addWidget(self.checkBox, alignment=Qt.AlignmentFlag.AlignLeft)
|
||||
self.layout.addWidget(self.toolButton, alignment=Qt.AlignmentFlag.AlignRight)
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def __connectSignalToSlot(self):
|
||||
self.toolButton.clicked.connect(lambda: signalBus.switchToSettingGroup.emit(self.settingGroup))
|
||||
signalBus.selectAllClicked.connect(lambda: self.checkBox.setChecked(True))
|
||||
signalBus.clearAllClicked.connect(lambda: self.checkBox.setChecked(False))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
68
app/components/navigation_logo.py
Normal file
@@ -0,0 +1,68 @@
|
||||
# coding:utf-8
|
||||
import os
|
||||
import subprocess
|
||||
from typing import Union, List
|
||||
|
||||
from PySide6.QtCore import (Qt, Signal, QRect, QRectF, QPropertyAnimation, Property, QMargins,
|
||||
QEasingCurve, QPoint, QEvent, QSize)
|
||||
from PySide6.QtGui import QColor, QPainter, QPen, QIcon, QCursor, QFont, QBrush, QPixmap, QImage, QMouseEvent
|
||||
from PySide6.QtWidgets import QHBoxLayout, QVBoxLayout, QLabel, QWidget, QStyle, QStyleOptionButton
|
||||
from collections import deque
|
||||
|
||||
from qfluentwidgets import BodyLabel, FlyoutAnimationType, Flyout, FlyoutView, PushButton, ToolButton, CheckBox
|
||||
from qfluentwidgets.common.config import isDarkTheme
|
||||
from qfluentwidgets.common.style_sheet import themeColor
|
||||
from qfluentwidgets.common.icon import drawIcon, toQIcon
|
||||
from qfluentwidgets.common.icon import FluentIcon as FIF
|
||||
from qfluentwidgets.common.font import setFont
|
||||
from qfluentwidgets.components.navigation import NavigationAvatarWidget, NavigationWidget
|
||||
|
||||
|
||||
class NavigationLogoWidget(NavigationWidget):
|
||||
""" Navigation widget with a logo """
|
||||
|
||||
def __init__(self, logo_path: str, logo_size: QSize = None, parent=None):
|
||||
super().__init__(isSelectable=False, parent=parent)
|
||||
self.logo_path = logo_path
|
||||
self.logo_size = logo_size if logo_size else QSize(parent.width(), 36)
|
||||
self.initUI()
|
||||
|
||||
def initUI(self):
|
||||
layout = QVBoxLayout()
|
||||
layout.setContentsMargins(0, 0, 0, 0) # Remove margins to fully center the QLabel
|
||||
|
||||
self.logoLabel = QLabel(self)
|
||||
self.logoLabel.setAlignment(Qt.AlignCenter) # Center the QLabel itself
|
||||
self.setLogo(self.logo_path)
|
||||
|
||||
layout.addWidget(self.logoLabel)
|
||||
layout.setAlignment(Qt.AlignCenter) # Center the QLabel within the layout
|
||||
|
||||
self.setLayout(layout)
|
||||
self.setFixedSize(self.logo_size)
|
||||
|
||||
def setLogo(self, logo_path: str):
|
||||
self.logo_path = logo_path
|
||||
pixmap = QPixmap(logo_path)
|
||||
if not pixmap.isNull():
|
||||
if self.logo_size:
|
||||
pixmap = pixmap.scaled(self.logo_size, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
||||
self.logoLabel.setPixmap(pixmap)
|
||||
|
||||
def setLogoSize(self, logo_size: QSize):
|
||||
self.logo_size = logo_size
|
||||
self.setFixedSize(logo_size)
|
||||
self.setLogo(self.logo_path)
|
||||
|
||||
def setCompacted(self, isCompacted: bool):
|
||||
""" set whether the widget is compacted """
|
||||
if isCompacted == self.isCompacted:
|
||||
return
|
||||
|
||||
self.isCompacted = isCompacted
|
||||
if isCompacted:
|
||||
self.setFixedSize(40, 36)
|
||||
else:
|
||||
self.setFixedSize(self.logo_size if self.logo_size else QSize(self.parent().width(), 36))
|
||||
|
||||
self.update()
|
||||
17
app/modules/base.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from app.common.config import cfg
|
||||
|
||||
|
||||
class Request:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
|
||||
class Handler:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
def set_next(self):
|
||||
pass
|
||||
|
||||
def handle(self):
|
||||
pass
|
||||
BIN
app/resource/i18n/gallery.zh_CN.qm
Normal file
1806
app/resource/i18n/gallery.zh_CN.ts
Normal file
BIN
app/resource/i18n/gallery.zh_HK.qm
Normal file
1806
app/resource/i18n/gallery.zh_HK.ts
Normal file
BIN
app/resource/images/logo.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
47
app/resource/qss/dark/gallery_interface.qss
Normal file
@@ -0,0 +1,47 @@
|
||||
GalleryInterface,
|
||||
ToolBar,
|
||||
#view {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
border: none;
|
||||
}
|
||||
|
||||
|
||||
ToolBar>CaptionLabel {
|
||||
color: white;
|
||||
}
|
||||
|
||||
ExampleCard {
|
||||
background-color: transparent;
|
||||
color: white;
|
||||
}
|
||||
|
||||
TitleLabel,
|
||||
StrongBodyLabel {
|
||||
color: white;
|
||||
}
|
||||
|
||||
ExampleCard>#card {
|
||||
border: 1px solid rgb(36, 36, 36);
|
||||
border-radius: 10px;
|
||||
background-color: rgba(0, 0, 0, 0.1795);
|
||||
}
|
||||
|
||||
ExampleCard>#card QLabel {
|
||||
font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
color: white;
|
||||
}
|
||||
|
||||
ExampleCard>#card InfoBadge {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
|
||||
#sourceWidget {
|
||||
background-color: rgba(255, 255, 255, 0.09);
|
||||
border-top: 1px solid rgb(36, 36, 36);
|
||||
border-bottom-left-radius: 10px;
|
||||
border-bottom-right-radius: 10px;
|
||||
}
|
||||
17
app/resource/qss/dark/home_interface.qss
Normal file
@@ -0,0 +1,17 @@
|
||||
SettingInterface,
|
||||
#view {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
BannerWidget > #galleryLabel {
|
||||
font: 42px 'Segoe UI SemiBold', 'Microsoft YaHei SemiBold';
|
||||
background-color: transparent;
|
||||
color: white;
|
||||
padding-left: 28px;
|
||||
}
|
||||
55
app/resource/qss/dark/icon_interface.qss
Normal file
@@ -0,0 +1,55 @@
|
||||
IconCard {
|
||||
background-color: rgb(43, 43, 43);
|
||||
border: 1px solid rgb(29, 29, 29);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
IconCard > QLabel {
|
||||
color: rgb(207, 207, 207);
|
||||
font: 11px 'Segoe UI', 'PingFang SC';
|
||||
}
|
||||
|
||||
IconCard[isSelected=true] {
|
||||
background-color: --ThemeColorPrimary;
|
||||
}
|
||||
|
||||
IconCard[isSelected=true] > QLabel {
|
||||
color: black;
|
||||
}
|
||||
|
||||
#scrollWidget, #iconView {
|
||||
background-color: rgb(32, 32, 32);
|
||||
}
|
||||
|
||||
IconCardView {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
#iconView {
|
||||
border: 1px solid rgb(36, 36, 36);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
IconInfoPanel {
|
||||
background-color: rgb(43, 43, 43);
|
||||
border-left: 1px solid rgb(29, 29, 29);
|
||||
border-top-right-radius: 10px;
|
||||
border-bottom-right-radius: 10px;
|
||||
}
|
||||
|
||||
IconInfoPanel>#nameLabel {
|
||||
font: 15px 'Segoe UI', 'PingFang SC';
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
}
|
||||
|
||||
IconInfoPanel>#subTitleLabel {
|
||||
font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
color: white;
|
||||
}
|
||||
|
||||
IconInfoPanel>QLabel {
|
||||
font: 12px 'Segoe UI', 'PingFang SC';
|
||||
color: rgb(207, 207, 207);
|
||||
}
|
||||
|
||||
29
app/resource/qss/dark/link_card.qss
Normal file
@@ -0,0 +1,29 @@
|
||||
LinkCard {
|
||||
border: 1px solid rgb(46, 46, 46);
|
||||
border-radius: 10px;
|
||||
background-color: rgba(39, 39, 39, 0.95);
|
||||
}
|
||||
|
||||
LinkCard:hover {
|
||||
background-color: rgba(39, 39, 39, 0.93);
|
||||
border: 1px solid rgb(66, 66, 66);
|
||||
}
|
||||
|
||||
#titleLabel {
|
||||
font: 18px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
color: white;
|
||||
}
|
||||
|
||||
#contentLabel {
|
||||
font: 12px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
color: rgb(208, 208, 208);
|
||||
}
|
||||
|
||||
LinkCardView {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#view {
|
||||
background-color: transparent;
|
||||
}
|
||||
16
app/resource/qss/dark/navigation_view_interface.qss
Normal file
@@ -0,0 +1,16 @@
|
||||
PivotInterface QLabel,
|
||||
TabInterface QLabel {
|
||||
padding-left: 10px;
|
||||
font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
color: white;
|
||||
}
|
||||
|
||||
#controlPanel BodyLabel {
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
#controlPanel {
|
||||
background-color: rgb(43, 43, 43);
|
||||
border-left: 1px solid rgb(50, 50, 50);
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
15
app/resource/qss/dark/sample_card.qss
Normal file
@@ -0,0 +1,15 @@
|
||||
#titleLabel {
|
||||
color: white;
|
||||
font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#contentLabel {
|
||||
color: rgb(208, 208, 208);
|
||||
font: 12px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
}
|
||||
|
||||
#viewTitleLabel {
|
||||
color: white;
|
||||
font: 20px "Segoe UI SemiBold", "Microsoft YaHei", 'PingFang SC';
|
||||
}
|
||||
17
app/resource/qss/dark/setting_interface.qss
Normal file
@@ -0,0 +1,17 @@
|
||||
SettingInterface, #scrollWidget {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
/* 标签 */
|
||||
QLabel#settingLabel {
|
||||
font: 33px 'Microsoft YaHei Light';
|
||||
background-color: transparent;
|
||||
color: white;
|
||||
}
|
||||
|
||||
5
app/resource/qss/dark/view_interface.qss
Normal file
@@ -0,0 +1,5 @@
|
||||
#frame {
|
||||
border: 1px solid rgba(255, 255, 255, 13);
|
||||
border-radius: 5px;
|
||||
background-color: transparent;
|
||||
}
|
||||
46
app/resource/qss/light/gallery_interface.qss
Normal file
@@ -0,0 +1,46 @@
|
||||
GalleryInterface, ToolBar, #view {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
border: none;
|
||||
}
|
||||
|
||||
ToolBar > StrongBodyLabel {
|
||||
color: black;
|
||||
}
|
||||
|
||||
ToolBar > CaptionLabel {
|
||||
color: rgb(95, 95, 95);
|
||||
}
|
||||
|
||||
ExampleCard {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
TitleLabel,
|
||||
StrongBodyLabel {
|
||||
color: black;
|
||||
}
|
||||
|
||||
ExampleCard > #card {
|
||||
border: 1px solid rgba(0, 0, 0, 0.05);
|
||||
border-radius: 10px;
|
||||
background-color: rgba(0, 0, 0, 0.024);
|
||||
}
|
||||
|
||||
ExampleCard > #card QLabel {
|
||||
font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
color: black;
|
||||
}
|
||||
|
||||
ExampleCard> #card InfoBadge {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#sourceWidget {
|
||||
background-color: rgba(255, 255, 255, 0.667);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.05);
|
||||
border-bottom-left-radius: 10px;
|
||||
border-bottom-right-radius: 10px;
|
||||
}
|
||||
19
app/resource/qss/light/home_interface.qss
Normal file
@@ -0,0 +1,19 @@
|
||||
SettingInterface,
|
||||
#view {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
BannerWidget > #galleryLabel {
|
||||
font: 42px 'Segoe UI SemiBold', 'Microsoft YaHei SemiBold';
|
||||
background-color: transparent;
|
||||
color: black;
|
||||
padding-left: 28px;
|
||||
}
|
||||
|
||||
|
||||
57
app/resource/qss/light/icon_interface.qss
Normal file
@@ -0,0 +1,57 @@
|
||||
IconCard {
|
||||
background-color: rgb(251, 251, 251);
|
||||
border: 1px solid rgb(229, 229, 229);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
IconCard > QLabel {
|
||||
color: rgb(96, 96, 96);
|
||||
font: 11px 'Segoe UI', 'PingFang SC';
|
||||
}
|
||||
|
||||
IconCard[isSelected=true] {
|
||||
background-color: --ThemeColorPrimary;
|
||||
}
|
||||
|
||||
IconCard[isSelected=true] > QLabel {
|
||||
color: white;
|
||||
}
|
||||
|
||||
#scrollWidget, #iconView {
|
||||
background-color: rgb(243, 243, 243);
|
||||
}
|
||||
|
||||
IconCardView {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
#iconView {
|
||||
border: 1px solid rgb(234, 234, 234);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
|
||||
IconInfoPanel {
|
||||
background-color: rgb(251, 251, 251);
|
||||
border-left: 1px solid rgb(229, 229, 229);
|
||||
border-top-right-radius: 10px;
|
||||
border-bottom-right-radius: 10px;
|
||||
}
|
||||
|
||||
|
||||
IconInfoPanel > #nameLabel {
|
||||
font: 15px 'Segoe UI', 'PingFang SC';
|
||||
font-weight: bold;
|
||||
color: black;
|
||||
}
|
||||
|
||||
IconInfoPanel > #subTitleLabel {
|
||||
font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
color: black;
|
||||
}
|
||||
|
||||
IconInfoPanel > QLabel {
|
||||
font: 12px 'Segoe UI', 'PingFang SC';
|
||||
color: rgb(96, 96, 96);
|
||||
}
|
||||
|
||||
29
app/resource/qss/light/link_card.qss
Normal file
@@ -0,0 +1,29 @@
|
||||
LinkCard {
|
||||
border: 1px solid rgb(234, 234, 234);
|
||||
border-radius: 10px;
|
||||
background-color: rgba(249, 249, 249, 0.95);
|
||||
}
|
||||
|
||||
LinkCard:hover {
|
||||
background-color: rgba(249, 249, 249, 0.93);
|
||||
border: 1px solid rgb(220, 220, 220);
|
||||
}
|
||||
|
||||
#titleLabel {
|
||||
font: 18px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
color: black;
|
||||
}
|
||||
|
||||
#contentLabel {
|
||||
font: 12px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
color: rgb(93, 93, 93);
|
||||
}
|
||||
|
||||
LinkCardView {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#view {
|
||||
background-color: transparent;
|
||||
}
|
||||
16
app/resource/qss/light/navigation_view_interface.qss
Normal file
@@ -0,0 +1,16 @@
|
||||
PivotInterface QLabel,
|
||||
TabInterface QLabel {
|
||||
padding-left: 10px;
|
||||
font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
color: black;
|
||||
}
|
||||
|
||||
#controlPanel BodyLabel {
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
#controlPanel {
|
||||
background-color: white;
|
||||
border-left: 1px solid rgb(229, 229, 229);
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
15
app/resource/qss/light/sample_card.qss
Normal file
@@ -0,0 +1,15 @@
|
||||
#titleLabel {
|
||||
color: black;
|
||||
font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#contentLabel {
|
||||
color: rgb(118, 118, 118);
|
||||
font: 12px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
|
||||
}
|
||||
|
||||
#viewTitleLabel {
|
||||
color: black;
|
||||
font: 20px "Segoe UI SemiBold", "Microsoft YaHei", 'PingFang SC';
|
||||
}
|
||||
15
app/resource/qss/light/setting_interface.qss
Normal file
@@ -0,0 +1,15 @@
|
||||
SettingInterface, #scrollWidget {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
|
||||
/* 标签 */
|
||||
QLabel#settingLabel {
|
||||
font: 33px 'Microsoft YaHei Light';
|
||||
background-color: transparent;
|
||||
}
|
||||
5
app/resource/qss/light/view_interface.qss
Normal file
@@ -0,0 +1,5 @@
|
||||
#frame {
|
||||
border: 1px solid rgba(0, 0, 0, 15);
|
||||
border-radius: 5px;
|
||||
background-color: transparent;
|
||||
}
|
||||
154
app/resource/resource.qrc
Normal file
@@ -0,0 +1,154 @@
|
||||
<RCC>
|
||||
<qresource prefix="/gallery">
|
||||
<file>images/controls/Acrylic.png</file>
|
||||
<file>images/controls/AnimatedIcon.png</file>
|
||||
<file>images/controls/AnimatedVisualPlayer.png</file>
|
||||
<file>images/controls/AnimationInterop.png</file>
|
||||
<file>images/controls/AppBarButton.png</file>
|
||||
<file>images/controls/AppBarSeparator.png</file>
|
||||
<file>images/controls/AppBarToggleButton.png</file>
|
||||
<file>images/controls/AutomationProperties.png</file>
|
||||
<file>images/controls/AutoSuggestBox.png</file>
|
||||
<file>images/controls/Border.png</file>
|
||||
<file>images/controls/BreadcrumbBar.png</file>
|
||||
<file>images/controls/Button.png</file>
|
||||
<file>images/controls/CalendarDatePicker.png</file>
|
||||
<file>images/controls/CalendarView.png</file>
|
||||
<file>images/controls/Canvas.png</file>
|
||||
<file>images/controls/Checkbox.png</file>
|
||||
<file>images/controls/Clipboard.png</file>
|
||||
<file>images/controls/ColorPaletteResources.png</file>
|
||||
<file>images/controls/ColorPicker.png</file>
|
||||
<file>images/controls/ComboBox.png</file>
|
||||
<file>images/controls/CommandBar.png</file>
|
||||
<file>images/controls/CommandBarFlyout.png</file>
|
||||
<file>images/controls/CompactSizing.png</file>
|
||||
<file>images/controls/ConnectedAnimation.png</file>
|
||||
<file>images/controls/ContentDialog.png</file>
|
||||
<file>images/controls/CreateMultipleWindows.png</file>
|
||||
<file>images/controls/DataGrid.png</file>
|
||||
<file>images/controls/DatePicker.png</file>
|
||||
<file>images/controls/DropDownButton.png</file>
|
||||
<file>images/controls/EasingFunction.png</file>
|
||||
<file>images/controls/Expander.png</file>
|
||||
<file>images/controls/FilePicker.png</file>
|
||||
<file>images/controls/FlipView.png</file>
|
||||
<file>images/controls/Flyout.png</file>
|
||||
<file>images/controls/Grid.png</file>
|
||||
<file>images/controls/GridView.png</file>
|
||||
<file>images/controls/HyperlinkButton.png</file>
|
||||
<file>images/controls/IconElement.png</file>
|
||||
<file>images/controls/Image.png</file>
|
||||
<file>images/controls/ImplicitTransition.png</file>
|
||||
<file>images/controls/InfoBadge.png</file>
|
||||
<file>images/controls/InfoBar.png</file>
|
||||
<file>images/controls/InkCanvas.png</file>
|
||||
<file>images/controls/InkToolbar.png</file>
|
||||
<file>images/controls/InputValidation.png</file>
|
||||
<file>images/controls/ItemsRepeater.png</file>
|
||||
<file>images/controls/Line.png</file>
|
||||
<file>images/controls/ListBox.png</file>
|
||||
<file>images/controls/ListView.png</file>
|
||||
<file>images/controls/MediaPlayerElement.png</file>
|
||||
<file>images/controls/MenuBar.png</file>
|
||||
<file>images/controls/MenuFlyout.png</file>
|
||||
<file>images/controls/NavigationView.png</file>
|
||||
<file>images/controls/NumberBox.png</file>
|
||||
<file>images/controls/PageTransition.png</file>
|
||||
<file>images/controls/ParallaxView.png</file>
|
||||
<file>images/controls/PasswordBox.png</file>
|
||||
<file>images/controls/PersonPicture.png</file>
|
||||
<file>images/controls/PipsPager.png</file>
|
||||
<file>images/controls/Pivot.png</file>
|
||||
<file>images/controls/ProgressBar.png</file>
|
||||
<file>images/controls/ProgressRing.png</file>
|
||||
<file>images/controls/PullToRefresh.png</file>
|
||||
<file>images/controls/RadialGradientBrush.png</file>
|
||||
<file>images/controls/RadioButton.png</file>
|
||||
<file>images/controls/RadioButtons.png</file>
|
||||
<file>images/controls/RatingControl.png</file>
|
||||
<file>images/controls/RelativePanel.png</file>
|
||||
<file>images/controls/RepeatButton.png</file>
|
||||
<file>images/controls/RevealFocus.png</file>
|
||||
<file>images/controls/RichEditBox.png</file>
|
||||
<file>images/controls/RichTextBlock.png</file>
|
||||
<file>images/controls/ScrollViewer.png</file>
|
||||
<file>images/controls/SemanticZoom.png</file>
|
||||
<file>images/controls/Shape.png</file>
|
||||
<file>images/controls/Slider.png</file>
|
||||
<file>images/controls/Sound.png</file>
|
||||
<file>images/controls/SplitButton.png</file>
|
||||
<file>images/controls/SplitView.png</file>
|
||||
<file>images/controls/StackPanel.png</file>
|
||||
<file>images/controls/StandardUICommand.png</file>
|
||||
<file>images/controls/SwipeControl.png</file>
|
||||
<file>images/controls/TabView.png</file>
|
||||
<file>images/controls/TeachingTip.png</file>
|
||||
<file>images/controls/TextBlock.png</file>
|
||||
<file>images/controls/TextBox.png</file>
|
||||
<file>images/controls/ThemeTransition.png</file>
|
||||
<file>images/controls/TimePicker.png</file>
|
||||
<file>images/controls/TitleBar.png</file>
|
||||
<file>images/controls/ToggleButton.png</file>
|
||||
<file>images/controls/ToggleSplitButton.png</file>
|
||||
<file>images/controls/ToggleSwitch.png</file>
|
||||
<file>images/controls/ToolTip.png</file>
|
||||
<file>images/controls/TreeView.png</file>
|
||||
<file>images/controls/VariableSizedWrapGrid.png</file>
|
||||
<file>images/controls/Viewbox.png</file>
|
||||
<file>images/controls/WebView.png</file>
|
||||
<file>images/controls/XamlUICommand.png</file>
|
||||
<file>images/icons/EmojiTabSymbols_black.svg</file>
|
||||
<file>images/icons/EmojiTabSymbols_white.svg</file>
|
||||
<file>images/icons/Grid_black.svg</file>
|
||||
<file>images/icons/Grid_white.svg</file>
|
||||
<file>images/icons/Menu_black.svg</file>
|
||||
<file>images/icons/Menu_white.svg</file>
|
||||
<file>images/icons/Text_black.svg</file>
|
||||
<file>images/icons/Text_white.svg</file>
|
||||
<file>images/icons/Price_black.svg</file>
|
||||
<file>images/icons/Price_white.svg</file>
|
||||
<file>images/chidanta.jpg</file>
|
||||
<file>images/chidanta2.jpg</file>
|
||||
<file>images/chidanta3.jpg</file>
|
||||
<file>images/chidanta4.jpg</file>
|
||||
<file>images/chidanta5.jpg</file>
|
||||
<file>images/header.png</file>
|
||||
<file>images/header1.png</file>
|
||||
<file>images/kunkun.png</file>
|
||||
<file>images/logo.png</file>
|
||||
<file>images/shoko.png</file>
|
||||
<file>images/Gyro.jpg</file>
|
||||
<file>images/SBR.jpg</file>
|
||||
<file>images/Dvd.png</file>
|
||||
<file>images/Singer.png</file>
|
||||
<file>images/MusicNote.png</file>
|
||||
<file>images/Smiling_with_heart.png</file>
|
||||
<file>images/Shoko1.jpg</file>
|
||||
<file>images/Shoko2.jpg</file>
|
||||
<file>images/Shoko3.jpg</file>
|
||||
<file>images/Shoko4.jpg</file>
|
||||
|
||||
<file>qss/dark/gallery_interface.qss</file>
|
||||
<file>qss/dark/home_interface.qss</file>
|
||||
<file>qss/dark/icon_interface.qss</file>
|
||||
<file>qss/dark/link_card.qss</file>
|
||||
<file>qss/dark/sample_card.qss</file>
|
||||
<file>qss/dark/setting_interface.qss</file>
|
||||
<file>qss/dark/view_interface.qss</file>
|
||||
<file>qss/dark/navigation_view_interface.qss</file>
|
||||
|
||||
<file>qss/light/gallery_interface.qss</file>
|
||||
<file>qss/light/home_interface.qss</file>
|
||||
<file>qss/light/icon_interface.qss</file>
|
||||
<file>qss/light/link_card.qss</file>
|
||||
<file>qss/light/sample_card.qss</file>
|
||||
<file>qss/light/setting_interface.qss</file>
|
||||
<file>qss/light/view_interface.qss</file>
|
||||
<file>qss/light/navigation_view_interface.qss</file>
|
||||
|
||||
<file>i18n/gallery.zh_CN.qm</file>
|
||||
<file>i18n/gallery.zh_HK.qm</file>
|
||||
|
||||
</qresource>
|
||||
</RCC>
|
||||
61
app/view/logger_interface.py
Normal file
@@ -0,0 +1,61 @@
|
||||
# coding:utf-8
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QLabel, QVBoxLayout, QHBoxLayout, QFrame
|
||||
from qfluentwidgets import PushButton, TextEdit
|
||||
|
||||
from ..common.signal_bus import signalBus
|
||||
from ..common.style_sheet import StyleSheet
|
||||
|
||||
|
||||
class LoggerInterface(QFrame):
|
||||
""" Setting interface """
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
# setting label
|
||||
self.mainLayout = QVBoxLayout()
|
||||
self.topLayout = QHBoxLayout()
|
||||
self.settingLabel = QLabel(self.tr("Log"))
|
||||
self.clearBUtton = PushButton('Clear')
|
||||
self.autoscrollButton = PushButton('Autoscroll Off')
|
||||
self.loggerBox = TextEdit()
|
||||
self.loggerBox.setReadOnly(True)
|
||||
|
||||
self.__initWidget()
|
||||
|
||||
def __initWidget(self):
|
||||
self.resize(1000, 800)
|
||||
self.setObjectName('loggerInterface')
|
||||
|
||||
# initialize style sheet
|
||||
self.settingLabel.setObjectName('settingLabel')
|
||||
StyleSheet.SETTING_INTERFACE.apply(self)
|
||||
|
||||
# initialize layout
|
||||
self.__initLayout()
|
||||
self.__connectSignalToSlot()
|
||||
|
||||
def __initLayout(self):
|
||||
self.topLayout.addWidget(self.settingLabel, alignment=Qt.AlignmentFlag.AlignLeft)
|
||||
self.topLayout.addWidget(self.clearBUtton, alignment=Qt.AlignmentFlag.AlignRight)
|
||||
self.topLayout.addWidget(self.autoscrollButton, alignment=Qt.AlignmentFlag.AlignRight)
|
||||
|
||||
self.mainLayout.addLayout(self.topLayout)
|
||||
self.mainLayout.setSpacing(28)
|
||||
self.mainLayout.addWidget(self.loggerBox)
|
||||
|
||||
self.setLayout(self.mainLayout)
|
||||
self.setContentsMargins(36, 10, 36, 28)
|
||||
|
||||
def setAutoscroll(self, text):
|
||||
text = self.autoscrollButton.text()
|
||||
if text == "Autoscroll Off":
|
||||
self.autoscrollButton.setText("Autoscroll On")
|
||||
elif text == "Autoscroll On":
|
||||
self.autoscrollButton.setText("Autoscroll Off")
|
||||
|
||||
def __connectSignalToSlot(self):
|
||||
""" connect signal to slot """
|
||||
signalBus.loggerSignal.connect(self.loggerBox.append)
|
||||
self.clearBUtton.clicked.connect(self.loggerBox.clear)
|
||||
self.autoscrollButton.clicked.connect(self.setAutoscroll)
|
||||
102
app/view/main_window.py
Normal file
@@ -0,0 +1,102 @@
|
||||
# coding: utf-8
|
||||
from typing import List
|
||||
from PySide6.QtCore import Qt, Signal, QEasingCurve, QUrl, QSize
|
||||
from PySide6.QtGui import QIcon, QDesktopServices, QColor
|
||||
from PySide6.QtWidgets import QApplication, QHBoxLayout, QFrame, QWidget
|
||||
|
||||
from qfluentwidgets import (NavigationAvatarWidget, NavigationItemPosition, MessageBox, FluentWindow,
|
||||
SplashScreen, PushButton)
|
||||
from qfluentwidgets import FluentIcon as FIF
|
||||
|
||||
from .logger_interface import LoggerInterface
|
||||
from .setting_interface import SettingInterface
|
||||
from ..common.config import ZH_SUPPORT_URL, EN_SUPPORT_URL, cfg
|
||||
from ..common.signal_bus import signalBus
|
||||
from ..common import resource
|
||||
from ..components.navigation_checkbox import NavigationCheckBox
|
||||
from ..components.navigation_action_buttons import NavigationActionButtons
|
||||
from ..components.navigation_logo import NavigationLogoWidget
|
||||
|
||||
|
||||
class MainWindow(FluentWindow):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.initWindow()
|
||||
|
||||
# create sub interface
|
||||
self.loggerInterface = LoggerInterface(self)
|
||||
self.settingInterface = SettingInterface(self)
|
||||
|
||||
# enable acrylic effect
|
||||
self.navigationInterface.setAcrylicEnabled(True)
|
||||
self.navigationInterface.setMenuButtonVisible(False)
|
||||
self.navigationInterface.setCollapsible(False)
|
||||
|
||||
self.connectSignalToSlot()
|
||||
|
||||
# add items to navigation interface
|
||||
self.initNavigation()
|
||||
self.splashScreen.finish()
|
||||
|
||||
def connectSignalToSlot(self):
|
||||
signalBus.micaEnableChanged.connect(self.setMicaEffectEnabled)
|
||||
signalBus.switchToSettingGroup.connect(self.switchToSetting)
|
||||
signalBus.supportSignal.connect(self.onSupport)
|
||||
|
||||
def initNavigation(self):
|
||||
# add navigation items
|
||||
self.navigationInterface.addWidget(
|
||||
'Logo',
|
||||
NavigationLogoWidget('gui/icons/karin.png', QSize(160, 160)),
|
||||
position=NavigationItemPosition.TOP
|
||||
)
|
||||
self.navigationInterface.panel.topLayout.setAlignment(Qt.AlignCenter)
|
||||
scrollLayout = self.navigationInterface.panel.scrollLayout
|
||||
scrollLayout.addWidget(NavigationCheckBox('Create Backup', self.settingInterface.backupGroup))
|
||||
scrollLayout.addWidget(NavigationCheckBox('Filter and Convert KKS', self.settingInterface.fckksGroup))
|
||||
scrollLayout.addWidget(NavigationCheckBox('Install Chara', self.settingInterface.installGroup))
|
||||
scrollLayout.addWidget(NavigationCheckBox('Remove Chara', self.settingInterface.removeGroup))
|
||||
scrollLayout.addWidget(NavigationActionButtons())
|
||||
|
||||
# add custom widget to bottom
|
||||
self.addSubInterface(
|
||||
self.loggerInterface, FIF.CALENDAR, self.tr('Log'), NavigationItemPosition.BOTTOM)
|
||||
self.addSubInterface(
|
||||
self.settingInterface, FIF.SETTING, self.tr('Settings'), NavigationItemPosition.BOTTOM)
|
||||
|
||||
def initWindow(self):
|
||||
self.resize(960, 780)
|
||||
self.setMinimumWidth(760)
|
||||
self.setWindowIcon(QIcon(':/gallery/images/logo.png'))
|
||||
self.setWindowTitle('KKAFIO')
|
||||
|
||||
self.setMicaEffectEnabled(cfg.get(cfg.micaEnabled))
|
||||
|
||||
# create splash screen
|
||||
self.splashScreen = SplashScreen(self.windowIcon(), self)
|
||||
self.splashScreen.setIconSize(QSize(106, 106))
|
||||
self.splashScreen.raise_()
|
||||
|
||||
desktop = QApplication.screens()[0].availableGeometry()
|
||||
w, h = desktop.width(), desktop.height()
|
||||
self.move(w//2 - self.width()//2, h//2 - self.height()//2)
|
||||
self.show()
|
||||
QApplication.processEvents()
|
||||
|
||||
def onSupport(self):
|
||||
language = cfg.get(cfg.language).value
|
||||
if language.name() == "zh_CN":
|
||||
QDesktopServices.openUrl(QUrl(ZH_SUPPORT_URL))
|
||||
else:
|
||||
QDesktopServices.openUrl(QUrl(EN_SUPPORT_URL))
|
||||
|
||||
def resizeEvent(self, e):
|
||||
super().resizeEvent(e)
|
||||
if hasattr(self, 'splashScreen'):
|
||||
self.splashScreen.resize(self.size())
|
||||
|
||||
def switchToSetting(self, settingGroup):
|
||||
""" switch to sample """
|
||||
self.stackedWidget.setCurrentWidget(self.settingInterface, False)
|
||||
self.settingInterface.scrollToGroup(settingGroup)
|
||||
338
app/view/setting_interface.py
Normal file
@@ -0,0 +1,338 @@
|
||||
# coding:utf-8
|
||||
from qfluentwidgets import (SettingCardGroup, SwitchSettingCard, FolderListSettingCard,
|
||||
OptionsSettingCard, PushSettingCard,
|
||||
HyperlinkCard, PrimaryPushSettingCard, ScrollArea,
|
||||
ComboBoxSettingCard, ExpandLayout, Theme, CustomColorSettingCard,
|
||||
setTheme, setThemeColor, RangeSettingCard, isDarkTheme)
|
||||
from qfluentwidgets import FluentIcon as FIF
|
||||
from qfluentwidgets import InfoBar
|
||||
from PySide6.QtCore import Qt, Signal, QUrl, QStandardPaths
|
||||
from PySide6.QtGui import QDesktopServices
|
||||
from PySide6.QtWidgets import QWidget, QLabel, QFileDialog
|
||||
|
||||
from ..common.config import cfg, HELP_URL, FEEDBACK_URL, AUTHOR, VERSION, YEAR, isWin11
|
||||
from ..components.line_edit_card import LineEditSettingCard
|
||||
from ..common.signal_bus import signalBus
|
||||
from ..common.style_sheet import StyleSheet
|
||||
|
||||
|
||||
class SettingInterface(ScrollArea):
|
||||
""" Setting interface """
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.scrollWidget = QWidget()
|
||||
self.expandLayout = ExpandLayout(self.scrollWidget)
|
||||
|
||||
# setting label
|
||||
self.settingLabel = QLabel(self.tr("Settings"), self)
|
||||
|
||||
# core
|
||||
self.coreGroup = SettingCardGroup(
|
||||
self.tr("Core"), self.scrollWidget)
|
||||
self.gamePathCard = PushSettingCard(
|
||||
self.tr('Choose folder'),
|
||||
FIF.GAME,
|
||||
self.tr("Koikatsu directory"),
|
||||
cfg.get(cfg.gamePath),
|
||||
self.coreGroup
|
||||
)
|
||||
|
||||
# createBackup
|
||||
self.backupGroup = SettingCardGroup(
|
||||
self.tr("Create Backup"), self.scrollWidget)
|
||||
self.backupPathCard = PushSettingCard(
|
||||
self.tr('Choose folder'),
|
||||
FIF.ZIP_FOLDER,
|
||||
self.tr("Backup directory"),
|
||||
cfg.get(cfg.gamePath),
|
||||
self.backupGroup
|
||||
)
|
||||
self.filenameCard = LineEditSettingCard(
|
||||
cfg.filename,
|
||||
FIF.ZIP_FOLDER,
|
||||
self.tr('Name for the backup zip file'),
|
||||
None,
|
||||
parent=self.backupGroup
|
||||
)
|
||||
self.modsCard = SwitchSettingCard(
|
||||
FIF.FOLDER,
|
||||
self.tr('mods'),
|
||||
None,
|
||||
configItem=cfg.mods,
|
||||
parent=self.backupGroup
|
||||
)
|
||||
self.userDataCard = SwitchSettingCard(
|
||||
FIF.FOLDER,
|
||||
self.tr('UserData'),
|
||||
None,
|
||||
configItem=cfg.userData,
|
||||
parent=self.backupGroup
|
||||
)
|
||||
self.bepInExCard = SwitchSettingCard(
|
||||
FIF.FOLDER,
|
||||
self.tr('BepInEx'),
|
||||
None,
|
||||
configItem=cfg.bepInEx,
|
||||
parent=self.backupGroup
|
||||
)
|
||||
|
||||
# fckks
|
||||
self.fckksGroup = SettingCardGroup(
|
||||
self.tr("Filter & Convert"), self.scrollWidget)
|
||||
self.fckksPathCard = PushSettingCard(
|
||||
self.tr('Choose folder'),
|
||||
FIF.DOWNLOAD,
|
||||
self.tr("Input directory"),
|
||||
cfg.get(cfg.gamePath),
|
||||
self.fckksGroup
|
||||
)
|
||||
self.convertCard = SwitchSettingCard(
|
||||
FIF.UPDATE,
|
||||
self.tr('Convert'),
|
||||
self.tr('Convert filtered KKS cards to KK card and store them in the KKS_to_KK directory'),
|
||||
configItem=cfg.convert,
|
||||
parent=self.fckksGroup
|
||||
)
|
||||
|
||||
# installChara
|
||||
self.installGroup = SettingCardGroup(
|
||||
self.tr("Install Chara"), self.scrollWidget)
|
||||
self.installPathCard = PushSettingCard(
|
||||
self.tr('Choose folder'),
|
||||
FIF.DOWNLOAD,
|
||||
self.tr("Input directory"),
|
||||
cfg.get(cfg.gamePath),
|
||||
self.installGroup,
|
||||
)
|
||||
self.fileConflictsCard = ComboBoxSettingCard(
|
||||
cfg.fileConflicts,
|
||||
FIF.CANCEL_MEDIUM,
|
||||
self.tr('If file conflicts:'),
|
||||
None,
|
||||
texts=["Skip", "Replace", "Rename"],
|
||||
parent=self.installGroup
|
||||
)
|
||||
self.archivePasswordCard = ComboBoxSettingCard(
|
||||
cfg.archivePassword,
|
||||
FIF.QUESTION,
|
||||
self.tr('If password is required for archives:'),
|
||||
texts=["Skip", "Request Password"],
|
||||
parent=self.installGroup
|
||||
)
|
||||
|
||||
# removeChara
|
||||
self.removeGroup = SettingCardGroup(
|
||||
self.tr("Remove Chara"), self.scrollWidget)
|
||||
self.removePathCard = PushSettingCard(
|
||||
self.tr('Choose folder'),
|
||||
FIF.DOWNLOAD,
|
||||
self.tr("Input directory"),
|
||||
cfg.get(cfg.gamePath),
|
||||
self.removeGroup,
|
||||
)
|
||||
|
||||
# personalization
|
||||
self.personalGroup = SettingCardGroup(
|
||||
self.tr('Personalization'), self.scrollWidget)
|
||||
self.micaCard = SwitchSettingCard(
|
||||
FIF.TRANSPARENT,
|
||||
self.tr('Mica effect'),
|
||||
self.tr('Apply semi transparent to windows and surfaces'),
|
||||
cfg.micaEnabled,
|
||||
self.personalGroup
|
||||
)
|
||||
self.themeCard = OptionsSettingCard(
|
||||
cfg.themeMode,
|
||||
FIF.BRUSH,
|
||||
self.tr('Application theme'),
|
||||
self.tr("Change the appearance of your application"),
|
||||
texts=[
|
||||
self.tr('Light'), self.tr('Dark'),
|
||||
self.tr('Use system setting')
|
||||
],
|
||||
parent=self.personalGroup
|
||||
)
|
||||
self.themeColorCard = CustomColorSettingCard(
|
||||
cfg.themeColor,
|
||||
FIF.PALETTE,
|
||||
self.tr('Theme color'),
|
||||
self.tr('Change the theme color of you application'),
|
||||
self.personalGroup
|
||||
)
|
||||
self.zoomCard = OptionsSettingCard(
|
||||
cfg.dpiScale,
|
||||
FIF.ZOOM,
|
||||
self.tr("Interface zoom"),
|
||||
self.tr("Change the size of widgets and fonts"),
|
||||
texts=[
|
||||
"100%", "125%", "150%", "175%", "200%",
|
||||
self.tr("Use system setting")
|
||||
],
|
||||
parent=self.personalGroup
|
||||
)
|
||||
self.languageCard = ComboBoxSettingCard(
|
||||
cfg.language,
|
||||
FIF.LANGUAGE,
|
||||
self.tr('Language'),
|
||||
self.tr('Set your preferred language for UI'),
|
||||
texts=['简体中文', '繁體中文', 'English', self.tr('Use system setting')],
|
||||
parent=self.personalGroup
|
||||
)
|
||||
|
||||
# material
|
||||
self.materialGroup = SettingCardGroup(
|
||||
self.tr('Material'), self.scrollWidget)
|
||||
self.blurRadiusCard = RangeSettingCard(
|
||||
cfg.blurRadius,
|
||||
FIF.ALBUM,
|
||||
self.tr('Acrylic blur radius'),
|
||||
self.tr('The greater the radius, the more blurred the image'),
|
||||
self.materialGroup
|
||||
)
|
||||
|
||||
# update software
|
||||
self.updateSoftwareGroup = SettingCardGroup(
|
||||
self.tr("Software update"), self.scrollWidget)
|
||||
self.updateOnStartUpCard = SwitchSettingCard(
|
||||
FIF.UPDATE,
|
||||
self.tr('Check for updates when the application starts'),
|
||||
self.tr('The new version will be more stable and have more features'),
|
||||
configItem=cfg.checkUpdateAtStartUp,
|
||||
parent=self.updateSoftwareGroup
|
||||
)
|
||||
|
||||
# application
|
||||
self.aboutGroup = SettingCardGroup(self.tr('About'), self.scrollWidget)
|
||||
self.helpCard = HyperlinkCard(
|
||||
HELP_URL,
|
||||
self.tr('Open help page'),
|
||||
FIF.HELP,
|
||||
self.tr('Help'),
|
||||
self.tr(
|
||||
'Discover new features and learn useful tips about PyQt-Fluent-Widgets'),
|
||||
self.aboutGroup
|
||||
)
|
||||
self.feedbackCard = PrimaryPushSettingCard(
|
||||
self.tr('Provide feedback'),
|
||||
FIF.FEEDBACK,
|
||||
self.tr('Provide feedback'),
|
||||
self.tr('Help us improve PyQt-Fluent-Widgets by providing feedback'),
|
||||
self.aboutGroup
|
||||
)
|
||||
self.aboutCard = PrimaryPushSettingCard(
|
||||
self.tr('Check update'),
|
||||
FIF.INFO,
|
||||
self.tr('About'),
|
||||
'© ' + self.tr('Copyright') + f" {YEAR}, {AUTHOR}. " +
|
||||
self.tr('Version') + " " + VERSION,
|
||||
self.aboutGroup
|
||||
)
|
||||
|
||||
self.__initWidget()
|
||||
|
||||
def __initWidget(self):
|
||||
self.resize(1000, 800)
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
self.setViewportMargins(0, 80, 0, 20)
|
||||
self.setWidget(self.scrollWidget)
|
||||
self.setWidgetResizable(True)
|
||||
self.setObjectName('settingInterface')
|
||||
|
||||
# initialize style sheet
|
||||
self.scrollWidget.setObjectName('scrollWidget')
|
||||
self.settingLabel.setObjectName('settingLabel')
|
||||
StyleSheet.SETTING_INTERFACE.apply(self)
|
||||
|
||||
self.micaCard.setEnabled(isWin11())
|
||||
|
||||
# initialize layout
|
||||
self.__initLayout()
|
||||
self.__connectSignalToSlot()
|
||||
|
||||
def __initLayout(self):
|
||||
self.settingLabel.move(36, 30)
|
||||
|
||||
# add cards to group
|
||||
self.coreGroup.addSettingCard(self.gamePathCard)
|
||||
|
||||
self.backupGroup.addSettingCard(self.backupPathCard)
|
||||
self.backupGroup.addSettingCard(self.filenameCard)
|
||||
self.backupGroup.addSettingCard(self.modsCard)
|
||||
self.backupGroup.addSettingCard(self.userDataCard)
|
||||
self.backupGroup.addSettingCard(self.bepInExCard)
|
||||
|
||||
self.fckksGroup.addSettingCard(self.fckksPathCard)
|
||||
self.fckksGroup.addSettingCard(self.convertCard)
|
||||
|
||||
self.installGroup.addSettingCard(self.installPathCard)
|
||||
self.installGroup.addSettingCard(self.fileConflictsCard)
|
||||
self.installGroup.addSettingCard(self.archivePasswordCard)
|
||||
|
||||
self.removeGroup.addSettingCard(self.removePathCard)
|
||||
|
||||
self.personalGroup.addSettingCard(self.micaCard)
|
||||
self.personalGroup.addSettingCard(self.themeCard)
|
||||
self.personalGroup.addSettingCard(self.themeColorCard)
|
||||
self.personalGroup.addSettingCard(self.zoomCard)
|
||||
self.personalGroup.addSettingCard(self.languageCard)
|
||||
|
||||
self.materialGroup.addSettingCard(self.blurRadiusCard)
|
||||
|
||||
self.updateSoftwareGroup.addSettingCard(self.updateOnStartUpCard)
|
||||
|
||||
self.aboutGroup.addSettingCard(self.helpCard)
|
||||
self.aboutGroup.addSettingCard(self.feedbackCard)
|
||||
self.aboutGroup.addSettingCard(self.aboutCard)
|
||||
|
||||
# add setting card group to layout
|
||||
self.expandLayout.setSpacing(28)
|
||||
self.expandLayout.setContentsMargins(36, 10, 36, 0)
|
||||
self.expandLayout.addWidget(self.coreGroup)
|
||||
self.expandLayout.addWidget(self.backupGroup)
|
||||
self.expandLayout.addWidget(self.fckksGroup)
|
||||
self.expandLayout.addWidget(self.installGroup)
|
||||
self.expandLayout.addWidget(self.removeGroup)
|
||||
self.expandLayout.addWidget(self.personalGroup)
|
||||
self.expandLayout.addWidget(self.materialGroup)
|
||||
self.expandLayout.addWidget(self.updateSoftwareGroup)
|
||||
self.expandLayout.addWidget(self.aboutGroup)
|
||||
|
||||
def __showRestartTooltip(self):
|
||||
""" show restart tooltip """
|
||||
InfoBar.success(
|
||||
self.tr('Updated successfully'),
|
||||
self.tr('Configuration takes effect after restart'),
|
||||
duration=1500,
|
||||
parent=self
|
||||
)
|
||||
|
||||
# def __onDownloadFolderCardClicked(self):
|
||||
# """ download folder card clicked slot """
|
||||
# folder = QFileDialog.getExistingDirectory(
|
||||
# self, self.tr("Choose folder"), "./")
|
||||
# if not folder or cfg.get(cfg.downloadFolder) == folder:
|
||||
# return
|
||||
|
||||
# cfg.set(cfg.downloadFolder, folder)
|
||||
# self.downloadFolderCard.setContent(folder)
|
||||
|
||||
def __connectSignalToSlot(self):
|
||||
""" connect signal to slot """
|
||||
cfg.appRestartSig.connect(self.__showRestartTooltip)
|
||||
|
||||
# music in the pc
|
||||
# self.downloadFolderCard.clicked.connect(
|
||||
# self.__onDownloadFolderCardClicked)
|
||||
|
||||
# personalization
|
||||
self.themeCard.optionChanged.connect(lambda ci: setTheme(cfg.get(ci)))
|
||||
self.themeColorCard.colorChanged.connect(lambda c: setThemeColor(c))
|
||||
self.micaCard.checkedChanged.connect(signalBus.micaEnableChanged)
|
||||
|
||||
# about
|
||||
self.feedbackCard.clicked.connect(
|
||||
lambda: QDesktopServices.openUrl(QUrl(FEEDBACK_URL)))
|
||||
|
||||
def scrollToGroup(self, group):
|
||||
self.verticalScrollBar().setValue(group.y())
|
||||
37
config.json
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"Core": {
|
||||
"GamePath": "",
|
||||
"Tasks": [
|
||||
"CreateBackup",
|
||||
"FCKKS",
|
||||
"InstallChara",
|
||||
"RemoveChara"
|
||||
]
|
||||
},
|
||||
"InstallChara": {
|
||||
"Enable": false,
|
||||
"InputPath": "",
|
||||
"FileConflicts": "Skip",
|
||||
"ArchivePassword": "Skip",
|
||||
"AbdataZipmod": ""
|
||||
},
|
||||
"RemoveChara": {
|
||||
"Enable": false,
|
||||
"InputPath": ""
|
||||
},
|
||||
"FCKKS": {
|
||||
"Enable": false,
|
||||
"InputPath": "",
|
||||
"Convert": true
|
||||
},
|
||||
"CreateBackup": {
|
||||
"Enable": false,
|
||||
"OutputPath": "",
|
||||
"Filename": "",
|
||||
"GameFolders": {
|
||||
"UserData": false,
|
||||
"mods": false,
|
||||
"BepInEx": false
|
||||
}
|
||||
}
|
||||
}
|
||||
19
gallery.pro
Normal file
@@ -0,0 +1,19 @@
|
||||
SOURCES += app/view/main_window.py \
|
||||
app/view/setting_interface.py \
|
||||
app/view/basic_input_interface.py \
|
||||
app/view/dialog_interface.py \
|
||||
app/view/menu_interface.py \
|
||||
app/view/gallery_interface.py \
|
||||
app/view/status_info_interface.py \
|
||||
app/view/scroll_interface.py \
|
||||
app/common/translator.py \
|
||||
app/view/material_interface.py \
|
||||
app/view/layout_interface.py \
|
||||
app/view/text_interface.py \
|
||||
app/view/icon_interface.py \
|
||||
app/view/view_interface.py \
|
||||
app/view/date_time_interface.py \
|
||||
app/view/navigation_view_interface.py \
|
||||
|
||||
TRANSLATIONS += app/resource/i18n/gallery.zh_CN.ts \
|
||||
app/resource/i18n/gallery.zh_HK.ts
|
||||
@@ -1,12 +0,0 @@
|
||||
import customtkinter
|
||||
class CTkNotification(customtkinter.CTkFrame):
|
||||
def __init__(self, text, master, **kwargs):
|
||||
super().__init__(master=master, **kwargs)
|
||||
self.label = customtkinter.CTkLabel(self, text=text, width=200, wraplength=200, font=("Inter", 16))
|
||||
self.label.grid(row=0, column=0, sticky="nsew")
|
||||
self.close_button = customtkinter.CTkButton(self, width=40, text="X", command=self.destroy, fg_color="transparent")
|
||||
self.close_button.grid(row=0, column=1)
|
||||
self.progress_bar = customtkinter.CTkProgressBar(self, progress_color="white", determinate_speed=0.4)
|
||||
self.progress_bar.grid(row=1, column=0, columnspan=2, sticky="nsew")
|
||||
self.progress_bar.set(0)
|
||||
self.progress_bar.start()
|
||||
@@ -1,212 +0,0 @@
|
||||
"""
|
||||
CTkToolTip Widget
|
||||
version: 0.8
|
||||
"""
|
||||
|
||||
import time
|
||||
import sys
|
||||
import customtkinter
|
||||
from tkinter import Toplevel, Frame
|
||||
|
||||
|
||||
class CTkToolTip(Toplevel):
|
||||
"""
|
||||
Creates a ToolTip (pop-up) widget for customtkinter.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
widget: any = None,
|
||||
message: str = None,
|
||||
delay: float = 0.2,
|
||||
follow: bool = True,
|
||||
x_offset: int = +20,
|
||||
y_offset: int = +10,
|
||||
bg_color: str = None,
|
||||
corner_radius: int = 10,
|
||||
border_width: int = 0,
|
||||
border_color: str = None,
|
||||
alpha: float = 0.95,
|
||||
padding: tuple = (10, 2),
|
||||
**message_kwargs):
|
||||
|
||||
super().__init__()
|
||||
|
||||
self.widget = widget
|
||||
|
||||
self.withdraw()
|
||||
|
||||
# Disable ToolTip's title bar
|
||||
self.overrideredirect(True)
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
self.transparent_color = self.widget._apply_appearance_mode(
|
||||
customtkinter.ThemeManager.theme["CTkToplevel"]["fg_color"])
|
||||
self.attributes("-transparentcolor", self.transparent_color)
|
||||
self.transient()
|
||||
elif sys.platform.startswith("darwin"):
|
||||
self.transparent_color = 'systemTransparent'
|
||||
self.attributes("-transparent", True)
|
||||
self.transient(self.master)
|
||||
else:
|
||||
self.transparent_color = '#000001'
|
||||
corner_radius = 0
|
||||
self.transient()
|
||||
|
||||
self.resizable(width=True, height=True)
|
||||
|
||||
# Make the background transparent
|
||||
self.config(background=self.transparent_color)
|
||||
|
||||
# StringVar instance for msg string
|
||||
self.messageVar = customtkinter.StringVar()
|
||||
self.message = message
|
||||
self.messageVar.set(self.message)
|
||||
|
||||
self.delay = delay
|
||||
self.follow = follow
|
||||
self.x_offset = x_offset
|
||||
self.y_offset = y_offset
|
||||
self.corner_radius = corner_radius
|
||||
self.alpha = alpha
|
||||
self.border_width = border_width
|
||||
self.padding = padding
|
||||
self.bg_color = customtkinter.ThemeManager.theme["CTkFrame"]["fg_color"] if bg_color is None else bg_color
|
||||
self.border_color = border_color
|
||||
self.disable = False
|
||||
|
||||
# visibility status of the ToolTip inside|outside|visible
|
||||
self.status = "outside"
|
||||
self.last_moved = 0
|
||||
self.attributes('-alpha', self.alpha)
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
if self.widget._apply_appearance_mode(self.bg_color) == self.transparent_color:
|
||||
self.transparent_color = "#000001"
|
||||
self.config(background=self.transparent_color)
|
||||
self.attributes("-transparentcolor", self.transparent_color)
|
||||
|
||||
# Add the message widget inside the tooltip
|
||||
self.transparent_frame = Frame(self, bg=self.transparent_color)
|
||||
self.transparent_frame.pack(padx=0, pady=0, fill="both", expand=True)
|
||||
|
||||
self.frame = customtkinter.CTkFrame(self.transparent_frame, bg_color=self.transparent_color,
|
||||
corner_radius=self.corner_radius,
|
||||
border_width=self.border_width, fg_color=self.bg_color,
|
||||
border_color=self.border_color)
|
||||
self.frame.pack(padx=0, pady=0, fill="both", expand=True)
|
||||
|
||||
self.message_label = customtkinter.CTkLabel(self.frame, textvariable=self.messageVar, **message_kwargs)
|
||||
self.message_label.pack(fill="both", padx=self.padding[0] + self.border_width,
|
||||
pady=self.padding[1] + self.border_width, expand=True)
|
||||
|
||||
if self.widget.winfo_name() != "tk":
|
||||
if self.frame.cget("fg_color") == self.widget.cget("bg_color"):
|
||||
if not bg_color:
|
||||
self._top_fg_color = self.frame._apply_appearance_mode(
|
||||
customtkinter.ThemeManager.theme["CTkFrame"]["top_fg_color"])
|
||||
if self._top_fg_color != self.transparent_color:
|
||||
self.frame.configure(fg_color=self._top_fg_color)
|
||||
|
||||
# Add bindings to the widget without overriding the existing ones
|
||||
self.widget.bind("<Enter>", self.on_enter, add="+")
|
||||
self.widget.bind("<Leave>", self.on_leave, add="+")
|
||||
self.widget.bind("<Motion>", self.on_enter, add="+")
|
||||
self.widget.bind("<B1-Motion>", self.on_enter, add="+")
|
||||
self.widget.bind("<Destroy>", lambda _: self.hide(), add="+")
|
||||
|
||||
def show(self) -> None:
|
||||
"""
|
||||
Enable the widget.
|
||||
"""
|
||||
self.disable = False
|
||||
|
||||
def on_enter(self, event) -> None:
|
||||
"""
|
||||
Processes motion within the widget including entering and moving.
|
||||
"""
|
||||
|
||||
if self.disable:
|
||||
return
|
||||
self.last_moved = time.time()
|
||||
|
||||
# Set the status as inside for the very first time
|
||||
if self.status == "outside":
|
||||
self.status = "inside"
|
||||
|
||||
# If the follow flag is not set, motion within the widget will make the ToolTip dissapear
|
||||
if not self.follow:
|
||||
self.status = "inside"
|
||||
self.withdraw()
|
||||
|
||||
# Calculate available space on the right side of the widget relative to the screen
|
||||
root_width = self.winfo_screenwidth()
|
||||
widget_x = event.x_root
|
||||
space_on_right = root_width - widget_x
|
||||
|
||||
# Calculate the width of the tooltip's text based on the length of the message string
|
||||
text_width = self.message_label.winfo_reqwidth()
|
||||
|
||||
# Calculate the offset based on available space and text width to avoid going off-screen on the right side
|
||||
offset_x = self.x_offset
|
||||
if space_on_right < text_width + 20: # Adjust the threshold as needed
|
||||
offset_x = -text_width - 20 # Negative offset when space is limited on the right side
|
||||
|
||||
# Offsets the ToolTip using the coordinates od an event as an origin
|
||||
self.geometry(f"+{event.x_root + offset_x}+{event.y_root + self.y_offset}")
|
||||
|
||||
# Time is in integer: milliseconds
|
||||
self.after(int(self.delay * 1000), self._show)
|
||||
|
||||
def on_leave(self, event=None) -> None:
|
||||
"""
|
||||
Hides the ToolTip temporarily.
|
||||
"""
|
||||
|
||||
if self.disable: return
|
||||
self.status = "outside"
|
||||
self.withdraw()
|
||||
|
||||
def _show(self) -> None:
|
||||
"""
|
||||
Displays the ToolTip.
|
||||
"""
|
||||
|
||||
if not self.widget.winfo_exists():
|
||||
self.hide()
|
||||
self.destroy()
|
||||
|
||||
if self.status == "inside" and time.time() - self.last_moved >= self.delay:
|
||||
self.status = "visible"
|
||||
self.deiconify()
|
||||
|
||||
def hide(self) -> None:
|
||||
"""
|
||||
Disable the widget from appearing.
|
||||
"""
|
||||
if not self.winfo_exists():
|
||||
return
|
||||
self.withdraw()
|
||||
self.disable = True
|
||||
|
||||
def is_disabled(self) -> None:
|
||||
"""
|
||||
Return the window state
|
||||
"""
|
||||
return self.disable
|
||||
|
||||
def get(self) -> None:
|
||||
"""
|
||||
Returns the text on the tooltip.
|
||||
"""
|
||||
return self.messageVar.get()
|
||||
|
||||
def configure(self, message: str = None, delay: float = None, bg_color: str = None, **kwargs):
|
||||
"""
|
||||
Set new message or configure the label parameters.
|
||||
"""
|
||||
if delay: self.delay = delay
|
||||
if bg_color: self.frame.configure(fg_color=bg_color)
|
||||
|
||||
self.messageVar.set(message)
|
||||
self.message_label.configure(**kwargs)
|
||||
@@ -1,448 +0,0 @@
|
||||
"""
|
||||
CustomTkinter Messagebox
|
||||
Author: Akash Bora
|
||||
Version: 2.5
|
||||
"""
|
||||
|
||||
import customtkinter
|
||||
from PIL import Image, ImageTk
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from typing import Literal
|
||||
|
||||
class CTkMessagebox(customtkinter.CTkToplevel):
|
||||
ICONS = {
|
||||
"check": None,
|
||||
"cancel": None,
|
||||
"info": None,
|
||||
"question": None,
|
||||
"warning": None
|
||||
}
|
||||
ICON_BITMAP = {}
|
||||
def __init__(self,
|
||||
master: any = None,
|
||||
width: int = 400,
|
||||
height: int = 200,
|
||||
title: str = "CTkMessagebox",
|
||||
message: str = "This is a CTkMessagebox!",
|
||||
option_1: str = "OK",
|
||||
option_2: str = None,
|
||||
option_3: str = None,
|
||||
options: list = [],
|
||||
border_width: int = 1,
|
||||
border_color: str = "default",
|
||||
button_color: str = "default",
|
||||
bg_color: str = "default",
|
||||
fg_color: str = "default",
|
||||
text_color: str = "default",
|
||||
title_color: str = "default",
|
||||
button_text_color: str = "default",
|
||||
button_width: int = None,
|
||||
button_height: int = None,
|
||||
cancel_button_color: str = None,
|
||||
cancel_button: str = None, # types: circle, cross or none
|
||||
button_hover_color: str = "default",
|
||||
icon: str = "info",
|
||||
icon_size: tuple = None,
|
||||
corner_radius: int = 15,
|
||||
justify: str = "right",
|
||||
font: tuple = None,
|
||||
header: bool = False,
|
||||
topmost: bool = True,
|
||||
fade_in_duration: int = 0,
|
||||
sound: bool = False,
|
||||
option_focus: Literal[1, 2, 3] = None):
|
||||
|
||||
super().__init__()
|
||||
|
||||
|
||||
self.master_window = master
|
||||
|
||||
self.width = 250 if width<250 else width
|
||||
self.height = 150 if height<150 else height
|
||||
|
||||
if self.master_window is None:
|
||||
self.spawn_x = int((self.winfo_screenwidth()-self.width)/2)
|
||||
self.spawn_y = int((self.winfo_screenheight()-self.height)/2)
|
||||
else:
|
||||
self.spawn_x = int(self.master_window.winfo_width() * .5 + self.master_window.winfo_x() - .5 * self.width + 7)
|
||||
self.spawn_y = int(self.master_window.winfo_height() * .5 + self.master_window.winfo_y() - .5 * self.height + 20)
|
||||
|
||||
self.after(10)
|
||||
self.geometry(f"{self.width}x{self.height}+{self.spawn_x}+{self.spawn_y}")
|
||||
self.title(title)
|
||||
self.resizable(width=False, height=False)
|
||||
self.fade = fade_in_duration
|
||||
|
||||
if self.fade:
|
||||
self.fade = 20 if self.fade<20 else self.fade
|
||||
self.attributes("-alpha", 0)
|
||||
|
||||
if not header:
|
||||
self.overrideredirect(1)
|
||||
|
||||
if topmost:
|
||||
self.attributes("-topmost", True)
|
||||
else:
|
||||
self.transient(self.master_window)
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
self.transparent_color = self._apply_appearance_mode(self.cget("fg_color"))
|
||||
self.attributes("-transparentcolor", self.transparent_color)
|
||||
default_cancel_button = "cross"
|
||||
elif sys.platform.startswith("darwin"):
|
||||
self.transparent_color = 'systemTransparent'
|
||||
self.attributes("-transparent", True)
|
||||
default_cancel_button = "circle"
|
||||
else:
|
||||
self.transparent_color = '#000001'
|
||||
corner_radius = 0
|
||||
default_cancel_button = "cross"
|
||||
|
||||
self.lift()
|
||||
|
||||
self.config(background=self.transparent_color)
|
||||
self.protocol("WM_DELETE_WINDOW", self.button_event)
|
||||
self.grid_columnconfigure(0, weight=1)
|
||||
self.grid_rowconfigure(0, weight=1)
|
||||
self.x = self.winfo_x()
|
||||
self.y = self.winfo_y()
|
||||
self._title = title
|
||||
self.message = message
|
||||
self.font = font
|
||||
self.justify = justify
|
||||
self.sound = sound
|
||||
self.cancel_button = cancel_button if cancel_button else default_cancel_button
|
||||
self.round_corners = corner_radius if corner_radius<=30 else 30
|
||||
self.button_width = button_width if button_width else self.width/4
|
||||
self.button_height = button_height if button_height else 28
|
||||
|
||||
if self.fade: self.attributes("-alpha", 0)
|
||||
|
||||
if self.button_height>self.height/4: self.button_height = self.height/4 -20
|
||||
self.dot_color = cancel_button_color
|
||||
self.border_width = border_width if border_width<6 else 5
|
||||
|
||||
if type(options) is list and len(options)>0:
|
||||
try:
|
||||
option_1 = options[-1]
|
||||
option_2 = options[-2]
|
||||
option_3 = options[-3]
|
||||
except IndexError: None
|
||||
|
||||
if bg_color=="default":
|
||||
self.bg_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkFrame"]["fg_color"])
|
||||
else:
|
||||
self.bg_color = bg_color
|
||||
|
||||
if fg_color=="default":
|
||||
self.fg_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkFrame"]["top_fg_color"])
|
||||
else:
|
||||
self.fg_color = fg_color
|
||||
|
||||
default_button_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkButton"]["fg_color"])
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
if self.bg_color==self.transparent_color or self.fg_color==self.transparent_color:
|
||||
self.configure(fg_color="#000001")
|
||||
self.transparent_color = "#000001"
|
||||
self.attributes("-transparentcolor", self.transparent_color)
|
||||
|
||||
if button_color=="default":
|
||||
self.button_color = (default_button_color, default_button_color, default_button_color)
|
||||
else:
|
||||
if type(button_color) is tuple:
|
||||
if len(button_color)==2:
|
||||
self.button_color = (button_color[0], button_color[1], default_button_color)
|
||||
elif len(button_color)==1:
|
||||
self.button_color = (button_color[0], default_button_color, default_button_color)
|
||||
else:
|
||||
self.button_color = button_color
|
||||
else:
|
||||
self.button_color = (button_color, button_color, button_color)
|
||||
|
||||
if text_color=="default":
|
||||
self.text_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkLabel"]["text_color"])
|
||||
else:
|
||||
self.text_color = text_color
|
||||
|
||||
if title_color=="default":
|
||||
self.title_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkLabel"]["text_color"])
|
||||
else:
|
||||
self.title_color = title_color
|
||||
|
||||
if button_text_color=="default":
|
||||
self.bt_text_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkButton"]["text_color"])
|
||||
else:
|
||||
self.bt_text_color = button_text_color
|
||||
|
||||
if button_hover_color=="default":
|
||||
self.bt_hv_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkButton"]["hover_color"])
|
||||
else:
|
||||
self.bt_hv_color = button_hover_color
|
||||
|
||||
if border_color=="default":
|
||||
self.border_color = self._apply_appearance_mode(customtkinter.ThemeManager.theme["CTkFrame"]["border_color"])
|
||||
else:
|
||||
self.border_color = border_color
|
||||
|
||||
if icon_size:
|
||||
self.size_height = icon_size[1] if icon_size[1]<=self.height-100 else self.height-100
|
||||
self.size = (icon_size[0], self.size_height)
|
||||
else:
|
||||
self.size = (self.height/4, self.height/4)
|
||||
|
||||
self.icon = self.load_icon(icon, icon_size) if icon else None
|
||||
|
||||
self.frame_top = customtkinter.CTkFrame(self, corner_radius=self.round_corners, width=self.width, border_width=self.border_width,
|
||||
bg_color=self.transparent_color, fg_color=self.bg_color, border_color=self.border_color)
|
||||
self.frame_top.grid(sticky="nswe")
|
||||
|
||||
if button_width:
|
||||
self.frame_top.grid_columnconfigure(0, weight=1)
|
||||
else:
|
||||
self.frame_top.grid_columnconfigure((1,2,3), weight=1)
|
||||
|
||||
if button_height:
|
||||
self.frame_top.grid_rowconfigure((0,1,3), weight=1)
|
||||
else:
|
||||
self.frame_top.grid_rowconfigure((0,1,2), weight=1)
|
||||
|
||||
self.frame_top.bind("<B1-Motion>", self.move_window)
|
||||
self.frame_top.bind("<ButtonPress-1>", self.oldxyset)
|
||||
|
||||
if self.cancel_button=="cross":
|
||||
self.button_close = customtkinter.CTkButton(self.frame_top, corner_radius=10, width=0, height=0, hover=False, border_width=0,
|
||||
text_color=self.dot_color if self.dot_color else self.title_color,
|
||||
text="✕", fg_color="transparent", command=self.button_event)
|
||||
self.button_close.grid(row=0, column=5, sticky="ne", padx=5+self.border_width, pady=5+self.border_width)
|
||||
elif self.cancel_button=="circle":
|
||||
self.button_close = customtkinter.CTkButton(self.frame_top, corner_radius=10, width=10, height=10, hover=False, border_width=0,
|
||||
text="", fg_color=self.dot_color if self.dot_color else "#c42b1c", command=self.button_event)
|
||||
self.button_close.grid(row=0, column=5, sticky="ne", padx=10, pady=10)
|
||||
|
||||
self.title_label = customtkinter.CTkLabel(self.frame_top, width=1, text=self._title, text_color=self.title_color, font=self.font)
|
||||
self.title_label.grid(row=0, column=0, columnspan=6, sticky="nw", padx=(15,30), pady=5)
|
||||
self.title_label.bind("<B1-Motion>", self.move_window)
|
||||
self.title_label.bind("<ButtonPress-1>", self.oldxyset)
|
||||
|
||||
self.info = customtkinter.CTkButton(self.frame_top, width=1, height=self.height/2, corner_radius=0, text=self.message, font=self.font,
|
||||
fg_color=self.fg_color, hover=False, text_color=self.text_color, image=self.icon)
|
||||
self.info._text_label.configure(wraplength=self.width/2, justify="left")
|
||||
self.info.grid(row=1, column=0, columnspan=6, sticky="nwes", padx=self.border_width)
|
||||
|
||||
if self.info._text_label.winfo_reqheight()>self.height/2:
|
||||
height_offset = int((self.info._text_label.winfo_reqheight())-(self.height/2) + self.height)
|
||||
self.geometry(f"{self.width}x{height_offset}")
|
||||
|
||||
|
||||
self.option_text_1 = option_1
|
||||
|
||||
self.button_1 = customtkinter.CTkButton(self.frame_top, text=self.option_text_1, fg_color=self.button_color[0],
|
||||
width=self.button_width, font=self.font, text_color=self.bt_text_color,
|
||||
hover_color=self.bt_hv_color, height=self.button_height,
|
||||
command=lambda: self.button_event(self.option_text_1))
|
||||
|
||||
|
||||
self.option_text_2 = option_2
|
||||
if option_2:
|
||||
self.button_2 = customtkinter.CTkButton(self.frame_top, text=self.option_text_2, fg_color=self.button_color[1],
|
||||
width=self.button_width, font=self.font, text_color=self.bt_text_color,
|
||||
hover_color=self.bt_hv_color, height=self.button_height,
|
||||
command=lambda: self.button_event(self.option_text_2))
|
||||
|
||||
self.option_text_3 = option_3
|
||||
if option_3:
|
||||
self.button_3 = customtkinter.CTkButton(self.frame_top, text=self.option_text_3, fg_color=self.button_color[2],
|
||||
width=self.button_width, font=self.font, text_color=self.bt_text_color,
|
||||
hover_color=self.bt_hv_color, height=self.button_height,
|
||||
command=lambda: self.button_event(self.option_text_3))
|
||||
|
||||
if self.justify=="center":
|
||||
if button_width:
|
||||
columns = [4,3,2]
|
||||
span = 1
|
||||
else:
|
||||
columns = [4,2,0]
|
||||
span = 2
|
||||
if option_3:
|
||||
self.frame_top.columnconfigure((0,1,2,3,4,5), weight=1)
|
||||
self.button_1.grid(row=2, column=columns[0], columnspan=span, sticky="news", padx=(0,10), pady=10)
|
||||
self.button_2.grid(row=2, column=columns[1], columnspan=span, sticky="news", padx=10, pady=10)
|
||||
self.button_3.grid(row=2, column=columns[2], columnspan=span, sticky="news", padx=(10,0), pady=10)
|
||||
elif option_2:
|
||||
self.frame_top.columnconfigure((0,5), weight=1)
|
||||
columns = [2,3]
|
||||
self.button_1.grid(row=2, column=columns[0], sticky="news", padx=(0,5), pady=10)
|
||||
self.button_2.grid(row=2, column=columns[1], sticky="news", padx=(5,0), pady=10)
|
||||
else:
|
||||
if button_width:
|
||||
self.frame_top.columnconfigure((0,1,2,3,4,5), weight=1)
|
||||
else:
|
||||
self.frame_top.columnconfigure((0,2,4), weight=2)
|
||||
self.button_1.grid(row=2, column=columns[1], columnspan=span, sticky="news", padx=(0,10), pady=10)
|
||||
elif self.justify=="left":
|
||||
self.frame_top.columnconfigure((0,1,2,3,4,5), weight=1)
|
||||
if button_width:
|
||||
columns = [0,1,2]
|
||||
span = 1
|
||||
else:
|
||||
columns = [0,2,4]
|
||||
span = 2
|
||||
if option_3:
|
||||
self.button_1.grid(row=2, column=columns[2], columnspan=span, sticky="news", padx=(0,10), pady=10)
|
||||
self.button_2.grid(row=2, column=columns[1], columnspan=span, sticky="news", padx=10, pady=10)
|
||||
self.button_3.grid(row=2, column=columns[0], columnspan=span, sticky="news", padx=(10,0), pady=10)
|
||||
elif option_2:
|
||||
self.button_1.grid(row=2, column=columns[1], columnspan=span, sticky="news", padx=10, pady=10)
|
||||
self.button_2.grid(row=2, column=columns[0], columnspan=span, sticky="news", padx=(10,0), pady=10)
|
||||
else:
|
||||
self.button_1.grid(row=2, column=columns[0], columnspan=span, sticky="news", padx=(10,0), pady=10)
|
||||
else:
|
||||
self.frame_top.columnconfigure((0,1,2,3,4,5), weight=1)
|
||||
if button_width:
|
||||
columns = [5,4,3]
|
||||
span = 1
|
||||
else:
|
||||
columns = [4,2,0]
|
||||
span = 2
|
||||
self.button_1.grid(row=2, column=columns[0], columnspan=span, sticky="news", padx=(0,10), pady=10)
|
||||
if option_2:
|
||||
self.button_2.grid(row=2, column=columns[1], columnspan=span, sticky="news", padx=10, pady=10)
|
||||
if option_3:
|
||||
self.button_3.grid(row=2, column=columns[2], columnspan=span, sticky="news", padx=(10,0), pady=10)
|
||||
|
||||
if header:
|
||||
self.title_label.configure(text="")
|
||||
self.title_label.grid_configure(pady=0)
|
||||
self.button_close.configure(text_color=self.bg_color)
|
||||
self.frame_top.configure(corner_radius=0)
|
||||
|
||||
if self.winfo_exists():
|
||||
self.grab_set()
|
||||
|
||||
if self.sound:
|
||||
self.bell()
|
||||
|
||||
if self.fade:
|
||||
self.fade_in()
|
||||
|
||||
if option_focus:
|
||||
self.option_focus = option_focus
|
||||
self.focus_button(self.option_focus)
|
||||
else:
|
||||
if not self.option_text_2 and not self.option_text_3:
|
||||
self.button_1.focus()
|
||||
self.button_1.bind("<Return>", lambda event: self.button_event(self.option_text_1))
|
||||
|
||||
self.bind("<Escape>", lambda e: self.button_event())
|
||||
|
||||
def focus_button(self, option_focus):
|
||||
try:
|
||||
self.selected_button = getattr(self, "button_"+str(option_focus))
|
||||
self.selected_button.focus()
|
||||
self.selected_button.configure(border_color=self.bt_hv_color, border_width=3)
|
||||
self.selected_option = getattr(self, "option_text_"+str(option_focus))
|
||||
self.selected_button.bind("<Return>", lambda event: self.button_event(self.selected_option))
|
||||
except AttributeError:
|
||||
return
|
||||
|
||||
self.bind("<Left>", lambda e: self.change_left())
|
||||
self.bind("<Right>", lambda e: self.change_right())
|
||||
|
||||
def change_left(self):
|
||||
if self.option_focus==3:
|
||||
return
|
||||
|
||||
self.selected_button.unbind("<Return>")
|
||||
self.selected_button.configure(border_width=0)
|
||||
|
||||
if self.option_focus==1:
|
||||
if self.option_text_2:
|
||||
self.option_focus = 2
|
||||
|
||||
elif self.option_focus==2:
|
||||
if self.option_text_3:
|
||||
self.option_focus = 3
|
||||
|
||||
self.focus_button(self.option_focus)
|
||||
|
||||
def change_right(self):
|
||||
if self.option_focus==1:
|
||||
return
|
||||
|
||||
self.selected_button.unbind("<Return>")
|
||||
self.selected_button.configure(border_width=0)
|
||||
|
||||
if self.option_focus==2:
|
||||
self.option_focus = 1
|
||||
|
||||
elif self.option_focus==3:
|
||||
self.option_focus = 2
|
||||
|
||||
self.focus_button(self.option_focus)
|
||||
|
||||
def load_icon(self, icon, icon_size):
|
||||
if icon not in self.ICONS or self.ICONS[icon] is None:
|
||||
if icon in ["check", "cancel", "info", "question", "warning"]:
|
||||
image_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'icons', icon + '.png')
|
||||
else:
|
||||
image_path = icon
|
||||
if icon_size:
|
||||
size_height = icon_size[1] if icon_size[1] <= self.height - 100 else self.height - 100
|
||||
size = (icon_size[0], size_height)
|
||||
else:
|
||||
size = (self.height / 4, self.height / 4)
|
||||
self.ICONS[icon] = customtkinter.CTkImage(Image.open(image_path), size=size)
|
||||
self.ICON_BITMAP[icon] = ImageTk.PhotoImage(file=image_path)
|
||||
self.after(200, lambda: self.iconphoto(False, self.ICON_BITMAP[icon]))
|
||||
return self.ICONS[icon]
|
||||
|
||||
def fade_in(self):
|
||||
for i in range(0,110,10):
|
||||
if not self.winfo_exists():
|
||||
break
|
||||
self.attributes("-alpha", i/100)
|
||||
self.update()
|
||||
time.sleep(1/self.fade)
|
||||
|
||||
def fade_out(self):
|
||||
for i in range(100,0,-10):
|
||||
if not self.winfo_exists():
|
||||
break
|
||||
self.attributes("-alpha", i/100)
|
||||
self.update()
|
||||
time.sleep(1/self.fade)
|
||||
|
||||
def get(self):
|
||||
if self.winfo_exists():
|
||||
self.master.wait_window(self)
|
||||
return self.event
|
||||
|
||||
def oldxyset(self, event):
|
||||
self.oldx = event.x
|
||||
self.oldy = event.y
|
||||
|
||||
def move_window(self, event):
|
||||
self.y = event.y_root - self.oldy
|
||||
self.x = event.x_root - self.oldx
|
||||
self.geometry(f'+{self.x}+{self.y}')
|
||||
|
||||
def button_event(self, event=None):
|
||||
try:
|
||||
self.button_1.configure(state="disabled")
|
||||
self.button_2.configure(state="disabled")
|
||||
self.button_3.configure(state="disabled")
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
if self.fade:
|
||||
self.fade_out()
|
||||
self.grab_release()
|
||||
self.destroy()
|
||||
self.event = event
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = CTkMessagebox()
|
||||
app.mainloop()
|
||||
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 17 KiB |
@@ -1,63 +0,0 @@
|
||||
import customtkinter
|
||||
from gui.custom_widgets.ctk_tooltip import CTkToolTip
|
||||
from tkinter import filedialog, END
|
||||
|
||||
class CreateBackupFrame(customtkinter.CTkFrame):
|
||||
def __init__(self, master, linker, config, **kwargs):
|
||||
super().__init__(master, **kwargs)
|
||||
self.linker = linker
|
||||
self.config = config
|
||||
self.create_widgets()
|
||||
self.bind_to_config()
|
||||
|
||||
def create_widgets(self):
|
||||
self.login_settings_label = customtkinter.CTkLabel(self, text="Create Backup Settings", font=customtkinter.CTkFont(family="Inter", size=30, weight="bold"))
|
||||
self.login_settings_label.grid(row=0, column=0, columnspan =2, sticky="nw", padx=20, pady=20)
|
||||
|
||||
self.create_downloadpath_widgets()
|
||||
self.create_filename_widgets()
|
||||
self.create_folders_widgets()
|
||||
self.linker.login = self
|
||||
|
||||
def create_downloadpath_widgets(self):
|
||||
self.downloadpath = customtkinter.CTkLabel(self, text="Output Directory:", font=customtkinter.CTkFont(size=20, underline=True))
|
||||
self.downloadpath.grid(row=3, column=0, padx=40, pady=(20, 10), sticky="nw")
|
||||
|
||||
self.downloadpath_entry = customtkinter.CTkEntry(self, font=customtkinter.CTkFont(family="Inter", size=16))
|
||||
self.downloadpath_entry.grid(row=4, column=0, columnspan=2, padx=(60,0), pady=(20, 10), sticky="nsew")
|
||||
|
||||
self.downloadpath_button = customtkinter.CTkButton(self, width=50, text="Select", command = self.open_folder)
|
||||
self.downloadpath_button.grid(row=4, column=2, padx=20, pady=(20, 10), sticky="nsew")
|
||||
|
||||
def create_filename_widgets(self):
|
||||
self.filename_label = customtkinter.CTkLabel(self, text="Filename")
|
||||
self.filename_label.grid(row=5, column=0)
|
||||
self.filename_entry = customtkinter.CTkEntry(self, font=customtkinter.CTkFont(family="Inter", size=16))
|
||||
self.filename_entry.grid(row=6, column=0, columnspan=2, padx=(60,0), pady=(20, 10), sticky="nsew")
|
||||
|
||||
def create_folders_widgets(self):
|
||||
self.folders_label = customtkinter.CTkLabel(self, text="Game Folders:")
|
||||
self.folders_label.grid(row=7, column=0)
|
||||
|
||||
self.userdata_checkbox = customtkinter.CTkCheckBox(self, text="Userdata")
|
||||
self.userdata_checkbox.grid(row=8, column=0)
|
||||
|
||||
self.mods_checkbox = customtkinter.CTkCheckBox(self, text="mods")
|
||||
self.mods_checkbox.grid(row=8, column=1)
|
||||
|
||||
self.bepinex_checkbox = customtkinter.CTkCheckBox(self, text="BepInEx")
|
||||
self.bepinex_checkbox.grid(row=8, column=2)
|
||||
|
||||
def bind_to_config(self):
|
||||
self.config.bind(self.downloadpath_entry, ["CreateBackup", "OutputPath"])
|
||||
self.config.bind(self.filename_entry, ["CreateBackup", "Filename"])
|
||||
self.config.bind(self.userdata_checkbox, ["CreateBackup", "GameFolders", "UserData"])
|
||||
self.config.bind(self.mods_checkbox, ["CreateBackup", "GameFolders", "mods"])
|
||||
self.config.bind(self.bepinex_checkbox, ["CreateBackup", "GameFolders", "BepInEx"])
|
||||
|
||||
def open_folder(self):
|
||||
folderpath = filedialog.askdirectory()
|
||||
if folderpath != "":
|
||||
self.downloadpath_entry.delete(0, END)
|
||||
self.downloadpath_entry.insert(0, folderpath)
|
||||
self.config.save_to_json(["CreateBackup", "OutputPath"])
|
||||
@@ -1,44 +0,0 @@
|
||||
import customtkinter
|
||||
from gui.custom_widgets.ctk_tooltip import CTkToolTip
|
||||
from tkinter import filedialog, END
|
||||
|
||||
class FilterConvertKKSFrame(customtkinter.CTkFrame):
|
||||
def __init__(self, master, linker, config, **kwargs):
|
||||
super().__init__(master, **kwargs)
|
||||
self.linker = linker
|
||||
self.config = config
|
||||
self.create_widgets()
|
||||
self.bind_to_config()
|
||||
|
||||
def create_widgets(self):
|
||||
self.login_settings_label = customtkinter.CTkLabel(self, text="Filter & Convert KKS Chara Settings", font=customtkinter.CTkFont(family="Inter", size=30, weight="bold"))
|
||||
self.login_settings_label.grid(row=0, column=0, columnspan=2, sticky="nw", padx=20, pady=20)
|
||||
|
||||
self.create_downloadpath_widgets()
|
||||
self.create_convert_widgets()
|
||||
self.linker.login = self
|
||||
|
||||
def create_downloadpath_widgets(self):
|
||||
self.downloadpath = customtkinter.CTkLabel(self, text="Input Directory:", font=customtkinter.CTkFont(size=20, underline=True))
|
||||
self.downloadpath.grid(row=3, column=0, padx=40, pady=(20, 10), sticky="nw")
|
||||
|
||||
self.downloadpath_entry = customtkinter.CTkEntry(self, font=customtkinter.CTkFont(family="Inter", size=16))
|
||||
self.downloadpath_entry.grid(row=4, column=0, columnspan=2, padx=(60,0), pady=(20, 10), sticky="nsew")
|
||||
|
||||
self.downloadpath_button = customtkinter.CTkButton(self, width=50, text="Select", command = self.open_folder)
|
||||
self.downloadpath_button.grid(row=4, column=2, padx=20, pady=(20, 10), sticky="nsew")
|
||||
|
||||
def create_convert_widgets(self):
|
||||
self.convert_checkbox = customtkinter.CTkCheckBox(self, text="Convert KKS to KK Chara")
|
||||
self.convert_checkbox.grid(row=5, column=0)
|
||||
|
||||
def bind_to_config(self):
|
||||
self.config.bind(self.downloadpath_entry, ["FCKKS", "InputPath"])
|
||||
self.config.bind(self.convert_checkbox, ["FCKKS", "Convert"])
|
||||
|
||||
def open_folder(self):
|
||||
folderpath = filedialog.askdirectory()
|
||||
if folderpath != "":
|
||||
self.downloadpath_entry.delete(0, END)
|
||||
self.downloadpath_entry.insert(0, folderpath)
|
||||
self.config.save_to_json(["FCKKS", "InputPath"])
|
||||
@@ -1,56 +0,0 @@
|
||||
import customtkinter
|
||||
from gui.custom_widgets.ctk_tooltip import CTkToolTip
|
||||
from tkinter import filedialog, END
|
||||
|
||||
class InstallCharaFrame(customtkinter.CTkFrame):
|
||||
def __init__(self, master, linker, config, **kwargs):
|
||||
super().__init__(master, **kwargs)
|
||||
self.linker = linker
|
||||
self.config = config
|
||||
self.create_widgets()
|
||||
self.bind_to_config()
|
||||
|
||||
def create_widgets(self):
|
||||
self.login_settings_label = customtkinter.CTkLabel(self, text="Install Chara Settings", font=customtkinter.CTkFont(family="Inter", size=30, weight="bold"))
|
||||
self.login_settings_label.grid(row=0, column=0, columnspan =2, sticky="nw", padx=20, pady=20)
|
||||
|
||||
self.create_downloadpath_widgets()
|
||||
self.create_conflict_widgets()
|
||||
self.create_password_widgets()
|
||||
self.linker.login = self
|
||||
|
||||
def create_downloadpath_widgets(self):
|
||||
self.downloadpath = customtkinter.CTkLabel(self, text="Input Directory:", font=customtkinter.CTkFont(size=20, underline=True))
|
||||
self.downloadpath.grid(row=3, column=0, padx=40, pady=(20, 10), sticky="nw")
|
||||
|
||||
self.downloadpath_entry = customtkinter.CTkEntry(self, font=customtkinter.CTkFont(family="Inter", size=16))
|
||||
self.downloadpath_entry.grid(row=4, column=0, columnspan=2, padx=(60,0), pady=(20, 10), sticky="nsew")
|
||||
|
||||
self.downloadpath_button = customtkinter.CTkButton(self, width=50, text="Select", command = self.open_folder)
|
||||
self.downloadpath_button.grid(row=4, column=2, padx=20, pady=(20, 10), sticky="nsew")
|
||||
|
||||
def create_conflict_widgets(self):
|
||||
self.conflict_label = customtkinter.CTkLabel(self, text="If file conflicts:", font=customtkinter.CTkFont(size=20))
|
||||
self.conflict_label.grid(row=6, column=0, padx=20, pady=(20, 10))
|
||||
|
||||
self.conflict_dropdown = customtkinter.CTkOptionMenu(self, values=["Skip", "Replace", "Rename"])
|
||||
self.conflict_dropdown.grid(row=6, column=1, padx=20, pady=(20, 10))
|
||||
|
||||
def create_password_widgets(self):
|
||||
self.password_label = customtkinter.CTkLabel(self, text="If password required for archives:", font=customtkinter.CTkFont(size=20), wraplength=200)
|
||||
self.password_label.grid(row=7, column=0, padx=20, pady=(20, 10))
|
||||
|
||||
self.password_dropdown = customtkinter.CTkOptionMenu(self, values=["Skip", "Request Password"])
|
||||
self.password_dropdown.grid(row=7, column=1, padx=20, pady=(20, 10))
|
||||
|
||||
def bind_to_config(self):
|
||||
self.config.bind(self.downloadpath_entry, ["InstallChara", "InputPath"])
|
||||
self.config.bind(self.conflict_dropdown, ["InstallChara", "FileConflicts"])
|
||||
self.config.bind(self.password_dropdown, ["InstallChara", "ArchivePassword"])
|
||||
|
||||
def open_folder(self):
|
||||
folderpath = filedialog.askdirectory()
|
||||
if folderpath != "":
|
||||
self.downloadpath_entry.delete(0, END)
|
||||
self.downloadpath_entry.insert(0, folderpath)
|
||||
self.config.save_to_json(["InstallChara", "InputPath"])
|
||||
@@ -1,39 +0,0 @@
|
||||
import customtkinter
|
||||
|
||||
class LoggerTextBox(customtkinter.CTkFrame):
|
||||
def __init__(self, master, linker, config, **kwargs):
|
||||
super().__init__(master=master, **kwargs)
|
||||
self.linker = linker
|
||||
self.config = config
|
||||
self.grid_rowconfigure(0, weight=0)
|
||||
self.grid_rowconfigure(1, weight=1)
|
||||
self.grid_columnconfigure(0, weight=1)
|
||||
|
||||
self.log_label = customtkinter.CTkLabel(self, text="Log",font=customtkinter.CTkFont(family="Inter", size=30, weight="bold"))
|
||||
self.log_label.grid(row=0, column=0, sticky="nw", padx=20, pady=(20,0))
|
||||
# Button to toggle autoscroll
|
||||
self.toggle_autoscroll_button = customtkinter.CTkButton(self, height=35, text="Autoscroll On", command=self.toggle_autoscroll, font=("Inter", 16))
|
||||
self.toggle_autoscroll_button.grid(row=0, column=1, padx=20, pady=20, sticky="nsew")
|
||||
self.autoscroll_enabled = True # Initially, autoscroll is enabled
|
||||
self.log_textbox = customtkinter.CTkTextbox(self, state="disabled", font=("Inter", 16), wrap="word")
|
||||
self.log_textbox.grid(row=1, column=0,columnspan=4, padx=20, pady=20, sticky="nsew")
|
||||
self.log_level_colors = {
|
||||
"[MSG]": "white",
|
||||
"[INFO]": "light blue",
|
||||
"[SUCCESS]": "light green",
|
||||
"[ERROR]": "red",
|
||||
"[SKIPPED]": "orange",
|
||||
"[REPLACED]": "orange",
|
||||
"[RENAMED]": "orange",
|
||||
"[REMOVED]": "orange",
|
||||
}
|
||||
for level, color in self.log_level_colors.items():
|
||||
self.log_textbox.tag_config(level, foreground=color)
|
||||
self.linker.logger = self
|
||||
|
||||
def toggle_autoscroll(self):
|
||||
self.autoscroll_enabled = not self.autoscroll_enabled
|
||||
if self.autoscroll_enabled:
|
||||
self.toggle_autoscroll_button.configure(text="Autoscroll On")
|
||||
else:
|
||||
self.toggle_autoscroll_button.configure(text="Autoscroll Off")
|
||||
@@ -1,38 +0,0 @@
|
||||
import customtkinter
|
||||
from gui.custom_widgets.ctk_tooltip import CTkToolTip
|
||||
from tkinter import filedialog, END
|
||||
|
||||
class RemoveCharaFrame(customtkinter.CTkFrame):
|
||||
def __init__(self, master, linker, config, **kwargs):
|
||||
super().__init__(master, **kwargs)
|
||||
self.linker = linker
|
||||
self.config = config
|
||||
self.create_widgets()
|
||||
self.bind_to_config()
|
||||
|
||||
def create_widgets(self):
|
||||
self.login_settings_label = customtkinter.CTkLabel(self, text="Remove Chara Settings", font=customtkinter.CTkFont(family="Inter", size=30, weight="bold"))
|
||||
self.login_settings_label.grid(row=0, column=0, columnspan =2, sticky="nw", padx=20, pady=20)
|
||||
|
||||
self.create_downloadpath_widgets()
|
||||
self.linker.login = self
|
||||
|
||||
def create_downloadpath_widgets(self):
|
||||
self.downloadpath = customtkinter.CTkLabel(self, text="Input Directory:", font=customtkinter.CTkFont(size=20, underline=True))
|
||||
self.downloadpath.grid(row=3, column=0, padx=40, pady=(20, 10), sticky="nw")
|
||||
|
||||
self.downloadpath_entry = customtkinter.CTkEntry(self, font=customtkinter.CTkFont(family="Inter", size=16))
|
||||
self.downloadpath_entry.grid(row=4, column=0, columnspan=2, padx=(60,0), pady=(20, 10), sticky="nsew")
|
||||
|
||||
self.downloadpath_button = customtkinter.CTkButton(self, width=50, text="Select", command = self.open_folder)
|
||||
self.downloadpath_button.grid(row=4, column=2, padx=20, pady=(20, 10), sticky="nsew")
|
||||
|
||||
def bind_to_config(self):
|
||||
self.config.bind(self.downloadpath_entry, ["RemoveChara", "InputPath"])
|
||||
|
||||
def open_folder(self):
|
||||
folderpath = filedialog.askdirectory()
|
||||
if folderpath != "":
|
||||
self.downloadpath_entry.delete(0, END)
|
||||
self.downloadpath_entry.insert(0, folderpath)
|
||||
self.config.save_to_json(["RemoveChara", "InputPath"])
|
||||
@@ -1,128 +0,0 @@
|
||||
import customtkinter
|
||||
from PIL import Image
|
||||
from gui.frames.install_chara import InstallCharaFrame
|
||||
from gui.frames.remove_chara import RemoveCharaFrame
|
||||
from gui.frames.fc_kks import FilterConvertKKSFrame
|
||||
from gui.frames.create_backup import CreateBackupFrame
|
||||
from gui.custom_widgets.ctk_tooltip import CTkToolTip
|
||||
from tkinter import filedialog, END
|
||||
|
||||
|
||||
class Sidebar(customtkinter.CTkFrame):
|
||||
def __init__(self, master, linker, config, **kwargs):
|
||||
self.master = master
|
||||
self.linker = linker
|
||||
self.config = config
|
||||
super().__init__(master=self.master, **kwargs)
|
||||
self.grid_rowconfigure((0, 1, 2), weight=1)
|
||||
self.grid_columnconfigure(0, weight=1)
|
||||
karin_logo = customtkinter.CTkImage(light_image=Image.open("gui/icons/karin.png"), size=(152,152))
|
||||
karin_logo_label = customtkinter.CTkLabel(self, image=karin_logo, text="")
|
||||
karin_logo_label.grid(row=0, column=0, sticky="nsew")
|
||||
self.gear_on = customtkinter.CTkImage(Image.open("gui/icons/gear_on.png"), size=(50,38))
|
||||
self.gear_off = customtkinter.CTkImage(Image.open("gui/icons/gear_off.png"), size=(50,38))
|
||||
self.create_module_frames()
|
||||
self.create_all_button_frame()
|
||||
self.create_gamepath_frame()
|
||||
self.create_start_button()
|
||||
self.create_notification_frames()
|
||||
self.linker.sidebar = self
|
||||
|
||||
def create_module_frames(self):
|
||||
|
||||
self.checkbox_frame = customtkinter.CTkFrame(self, fg_color="transparent", border_color="white", border_width=2)
|
||||
self.checkbox_frame.grid(row=1, column=0, columnspan=4, padx=10, pady=10, sticky="w")
|
||||
self.prettify = {
|
||||
"InstallChara": "Install Chara",
|
||||
"RemoveChara": "Remove Chara",
|
||||
"CreateBackup": "Create Backup",
|
||||
"FCKKS": "F&C KKS"
|
||||
}
|
||||
|
||||
self.module_list = [["CreateBackup", CreateBackupFrame], ["FCKKS", FilterConvertKKSFrame], ["InstallChara", InstallCharaFrame], ["RemoveChara", RemoveCharaFrame]]
|
||||
for index, sublist in enumerate(self.module_list):
|
||||
module = sublist[0]
|
||||
self.linker.modules_dictionary[module] = {}
|
||||
self.create_module_checkbox(module, index)
|
||||
self.create_module_button(module, index)
|
||||
frame = sublist[1](self.master, self.linker, self.config, fg_color="#262250")
|
||||
self.linker.modules_dictionary[module]['frame'] = frame
|
||||
self.linker.modules_dictionary["CreateBackup"]["button"].configure(image=self.gear_on)
|
||||
self.linker.modules_dictionary["CreateBackup"]["checkbox"].configure(text_color="#53B9E9")
|
||||
self.current_frame = self.linker.modules_dictionary["CreateBackup"]["frame"] # Update the current frame
|
||||
self.current_frame.grid(row=0, column=1, padx=20, pady=20, sticky="nsew")
|
||||
|
||||
def create_module_checkbox(self, module, i):
|
||||
self.linker.modules_dictionary[module]['checkbox'] = customtkinter.CTkCheckBox(
|
||||
self.checkbox_frame, text=self.prettify[module], text_color="#FFFFFF", font=("Inter", 16), command=lambda x=[module, "Enable"]: self.config.save_to_json(x))
|
||||
self.linker.modules_dictionary[module]['checkbox'].grid(row=i, column=0, columnspan=2,padx=20, pady=(10, 5), sticky="nw")
|
||||
self.linker.widgets[module]['Enable'] = self.linker.modules_dictionary[module]['checkbox']
|
||||
|
||||
def create_module_button(self, module, i):
|
||||
self.linker.modules_dictionary[module]['button'] = customtkinter.CTkButton(
|
||||
self.checkbox_frame, width=50, image=self.gear_off, text="", fg_color="transparent", command=lambda x=module: self.display_settings(module))
|
||||
self.linker.modules_dictionary[module]['button'].grid(row=i, column=1, padx=(40,0), pady=(2,0), sticky="nw")
|
||||
|
||||
def create_all_button_frame(self):
|
||||
self.select_all_button = customtkinter.CTkButton(self.checkbox_frame, width=100, text="Select All", fg_color="#DC621D", font=("Inter",20), command=self.select_all)
|
||||
self.select_all_button.grid(row=4, column=0, padx=10, pady=(15,20), sticky="w")
|
||||
self.clear_all_button = customtkinter.CTkButton(self.checkbox_frame, width=100, text="Clear All", fg_color="#DC621D", font=("Inter",20), command=self.clear_all)
|
||||
self.clear_all_button.grid(row=4, column=1, padx=10, pady=(15,20), sticky="w")
|
||||
|
||||
def create_gamepath_frame(self):
|
||||
self.gamepath_frame = customtkinter.CTkFrame(self, fg_color="transparent")
|
||||
self.gamepath_frame.grid(row=2, column=0)
|
||||
|
||||
self.gamepath_label = customtkinter.CTkLabel(self.gamepath_frame, text="Game Directory", font=customtkinter.CTkFont(size=16, family="Inter", underline=True))
|
||||
self.gamepath_label.grid(row=0, column=0, padx=(0, 10), sticky="nw")
|
||||
|
||||
self.gamepath_entry = customtkinter.CTkEntry(self.gamepath_frame, font=customtkinter.CTkFont(family="Inter", size=16))
|
||||
self.gamepath_entry.grid(row=1, column=0, columnspan=2)
|
||||
self.config.bind(self.gamepath_entry, ["Core", "GamePath"])
|
||||
self.gamepath_button = customtkinter.CTkButton(self.gamepath_frame, width=50, text="Select", command = self.open_folder)
|
||||
self.gamepath_button.grid(row=1, column=1)
|
||||
|
||||
def create_start_button(self):
|
||||
self.start_button = customtkinter.CTkButton(self, text="Start", width=200, height=40, command=self.linker.start_stop, font=customtkinter.CTkFont(family="Inter", size=16))
|
||||
self.start_button.grid(row=3, column=0, pady=20, sticky="n")
|
||||
|
||||
def create_notification_frames(self):
|
||||
for index, element in enumerate(["Template", "Queue", "Configuration"]):
|
||||
frame = customtkinter.CTkFrame(self, fg_color="transparent", height=50)
|
||||
if index == 0:
|
||||
top_pady=170
|
||||
else:
|
||||
top_pady=0
|
||||
frame.grid(row=3+index, column=0, sticky="s", pady=(top_pady,0))
|
||||
self.linker.name_to_sidebar_frame[element] = frame
|
||||
|
||||
def select_all(self):
|
||||
for module in self.linker.modules_dictionary:
|
||||
self.linker.modules_dictionary[module]["checkbox"].select()
|
||||
self.config.config_data[module]["Enable"] = True
|
||||
self.config.save_file("Configuration")
|
||||
|
||||
def clear_all(self):
|
||||
for module in self.linker.modules_dictionary:
|
||||
self.linker.modules_dictionary[module]["checkbox"].deselect()
|
||||
self.config.config_data[module]["Enable"] = False
|
||||
self.config.save_file("Configuration")
|
||||
|
||||
def display_settings(self, module):
|
||||
for key in self.linker.modules_dictionary:
|
||||
if key == module:
|
||||
self.linker.modules_dictionary[key]["button"].configure(image=self.gear_on)
|
||||
self.linker.modules_dictionary[key]["checkbox"].configure(text_color="#53B9E9")
|
||||
self.current_frame.grid_remove() # Hide the current frame
|
||||
self.current_frame = self.linker.modules_dictionary[key]["frame"] # Update the current frame
|
||||
self.current_frame.grid(row=0, column=1, padx=20, pady=20, sticky="nsew")
|
||||
else:
|
||||
self.linker.modules_dictionary[key]["button"].configure(image=self.gear_off)
|
||||
self.linker.modules_dictionary[key]["checkbox"].configure(text_color="#FFFFFF")
|
||||
|
||||
def open_folder(self):
|
||||
folderpath = filedialog.askdirectory()
|
||||
if folderpath != "":
|
||||
self.gamepath_entry.delete(0, END)
|
||||
self.gamepath_entry.insert(0, folderpath)
|
||||
self.config.save_to_json(["Core", "GamePath"])
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 48 KiB |
@@ -1,85 +0,0 @@
|
||||
import sys
|
||||
import json
|
||||
import customtkinter
|
||||
|
||||
class Config:
|
||||
def __init__(self, linker, config_file):
|
||||
self.linker = linker
|
||||
self.config_file = config_file
|
||||
self.config_data = self.read()
|
||||
self.linker.widgets = self.set_values_to_none(self.config_data)
|
||||
linker.config = self
|
||||
|
||||
def read(self):
|
||||
# Read the JSON file
|
||||
try:
|
||||
with open(self.config_file, 'r') as json_file:
|
||||
config_data = json.load(json_file)
|
||||
return config_data
|
||||
except FileNotFoundError:
|
||||
print(f"Config file '{self.config_file}' not found.")
|
||||
sys.exit(1)
|
||||
except json.JSONDecodeError:
|
||||
print(f"Invalid JSON format in '{self.config_file}'.")
|
||||
sys.exit(1)
|
||||
|
||||
def set_values_to_none(self, input_dict):
|
||||
result = {}
|
||||
for key, value in input_dict.items():
|
||||
if isinstance(value, dict):
|
||||
result[key] = self.set_values_to_none(value)
|
||||
else:
|
||||
result[key] = None
|
||||
return result
|
||||
|
||||
def load_config(self, widgets=None, config_data=None):
|
||||
if widgets == None:
|
||||
widgets = self.linker.widgets
|
||||
config_data = self.config_data
|
||||
for key in widgets:
|
||||
if isinstance(widgets[key], dict) and isinstance(config_data[key], dict):
|
||||
self.load_config(widgets[key], config_data[key])
|
||||
else:
|
||||
if widgets[key] is not None:
|
||||
if isinstance(widgets[key], customtkinter.CTkCheckBox):
|
||||
if config_data[key] == True:
|
||||
widgets[key].select()
|
||||
else:
|
||||
widgets[key].deselect()
|
||||
elif isinstance(widgets[key], customtkinter.CTkEntry):
|
||||
widgets[key].insert(0, config_data[key])
|
||||
else:
|
||||
widgets[key].set(config_data[key])
|
||||
|
||||
def bind(self, widget, list_keys):
|
||||
|
||||
if isinstance(widget, customtkinter.CTkEntry):
|
||||
widget.bind("<KeyRelease>", lambda event, x=list_keys: self.save_to_json(x))
|
||||
elif isinstance(widget, (customtkinter.CTkCheckBox)):
|
||||
widget.configure(command=lambda x=list_keys: self.save_to_json(x))
|
||||
else:
|
||||
widget.configure(command=lambda x, y=list_keys: self.save_to_json(y))
|
||||
|
||||
widgets_dictionary = self.linker.widgets
|
||||
for key in list_keys[:-1]:
|
||||
widgets_dictionary = widgets_dictionary[key]
|
||||
widgets_dictionary[list_keys[-1]] = widget
|
||||
|
||||
def save_to_json(self, list_keys):
|
||||
widget = self.linker.widgets
|
||||
data = self.config_data
|
||||
for i in list_keys[:-1]:
|
||||
widget = widget[i]
|
||||
data = data[i]
|
||||
widget = widget[list_keys[-1]]
|
||||
value = widget.get()
|
||||
if isinstance(widget, customtkinter.CTkCheckBox):
|
||||
value = True if value==1 else False
|
||||
data[list_keys[-1]] = value
|
||||
self.save_file("Configuration")
|
||||
|
||||
def save_file(self, name=None):
|
||||
with open("config.json", "w") as config_file:
|
||||
json.dump(self.config_data, config_file, indent=2)
|
||||
if name:
|
||||
self.linker.show_notification(name)
|
||||
@@ -1,67 +0,0 @@
|
||||
import subprocess
|
||||
import threading
|
||||
from gui.custom_widgets.ctk_notification import CTkNotification
|
||||
|
||||
class Linker:
|
||||
def __init__(self, master):
|
||||
self.config = None
|
||||
self.widgets = {}
|
||||
self.logger = None
|
||||
self.login = None
|
||||
# script.py process
|
||||
self.script = None
|
||||
self.master = master
|
||||
self.modules_dictionary = {}
|
||||
self.name_to_sidebar_frame = {}
|
||||
|
||||
def terminate_script(self):
|
||||
# If process is running, terminate it
|
||||
self.script.terminate()
|
||||
self.script = None
|
||||
self.sidebar.start_button.configure(text="Start", fg_color = ['#3B8ED0', '#1F6AA5'])
|
||||
|
||||
def start_stop(self):
|
||||
if hasattr(self, 'script') and self.script is not None:
|
||||
self.terminate_script()
|
||||
else:
|
||||
# If process is not running, start it
|
||||
self.script = subprocess.Popen(['python', 'script.py'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
threading.Thread(target=self.read_output).start()
|
||||
self.sidebar.start_button.configure(text="Stop", fg_color = "crimson")
|
||||
|
||||
def read_output(self):
|
||||
while self.script is not None:
|
||||
line = self.script.stdout.readline().decode('utf-8')
|
||||
if line == "":
|
||||
if hasattr(self, 'script') and self.script is not None:
|
||||
self.master.after(10, self.terminate_script)
|
||||
return
|
||||
|
||||
# Check if line contains any log level
|
||||
for level, color in self.logger.log_level_colors.items():
|
||||
if level in line:
|
||||
# Display output in text box with color
|
||||
self.logger.log_textbox.configure(state="normal")
|
||||
if level == "[MSG]":
|
||||
self.logger.log_textbox.insert("end", "-" * 87 + "\n", level)
|
||||
line = line.replace("[MSG]", "")
|
||||
self.logger.log_textbox.insert("end", line, level)
|
||||
elif level == "[INFO]" and "Start Task:" in line:
|
||||
self.logger.log_textbox.insert("end", "*" * 87 + "\n", level)
|
||||
self.logger.log_textbox.insert("end", line, level)
|
||||
else:
|
||||
self.logger.log_textbox.insert("end", line, level)
|
||||
self.logger.log_textbox.configure(state="disabled")
|
||||
break
|
||||
|
||||
if self.logger.autoscroll_enabled:
|
||||
self.logger.log_textbox.yview_moveto(1.0)
|
||||
|
||||
def show_notification(self, name):
|
||||
sidebar_frame = self.name_to_sidebar_frame[name]
|
||||
if self.script:
|
||||
new_notification = CTkNotification(text= f"{name} was saved but will be read by the script in the next run.", master=sidebar_frame, fg_color="orange")
|
||||
else:
|
||||
new_notification = CTkNotification(text= f"{name} was saved successfully.", master=sidebar_frame, fg_color="green")
|
||||
new_notification.grid(row=0, column=0, sticky="nsew")
|
||||
self.sidebar.master.after(2500, new_notification.destroy)
|
||||
@@ -1,121 +0,0 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
CC0 1.0 Universal
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without fear
|
||||
of later claims of infringement build upon, modify, incorporate in other
|
||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||
and for any purposes, including without limitation commercial purposes.
|
||||
These owners may contribute to the Commons to promote the ideal of a free
|
||||
culture and the further production of creative, cultural and scientific
|
||||
works, or to gain reputation or greater distribution for their Work in
|
||||
part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not
|
||||
limited to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
iii. publicity and privacy rights pertaining to a person's image or
|
||||
likeness depicted in a Work;
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||
in a Work;
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation
|
||||
thereof, including any amended or successor version of such
|
||||
directive); and
|
||||
vii. other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||
of action, whether now known or unknown (including existing as well as
|
||||
future claims and causes of action), in the Work (i) in all territories
|
||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||
treaty (including future time extensions), (iii) in any current or future
|
||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||
including without limitation commercial, advertising or promotional
|
||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||
member of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal or
|
||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||
as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||
be judged legally invalid or ineffective under applicable law, then the
|
||||
Waiver shall be preserved to the maximum extent permitted taking into
|
||||
account Affirmer's express Statement of Purpose. In addition, to the
|
||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future
|
||||
time extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"License"). The License shall be deemed effective as of the date CC0 was
|
||||
applied by Affirmer to the Work. Should any part of the License for any
|
||||
reason be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||
of the License, and in such case Affirmer hereby affirms that he or she
|
||||
will not (i) exercise any of his or her remaining Copyright and Related
|
||||
Rights in the Work or (ii) assert any associated claims and causes of
|
||||
action with respect to the Work, in either case contrary to Affirmer's
|
||||
express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
b. Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy, or
|
||||
the present or absence of errors, whether or not discoverable, all to
|
||||
the greatest extent permissible under applicable law.
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person's Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the
|
||||
Work.
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to
|
||||
this CC0 or use of the Work.
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Akash Bora
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,121 +0,0 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
CC0 1.0 Universal
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without fear
|
||||
of later claims of infringement build upon, modify, incorporate in other
|
||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||
and for any purposes, including without limitation commercial purposes.
|
||||
These owners may contribute to the Commons to promote the ideal of a free
|
||||
culture and the further production of creative, cultural and scientific
|
||||
works, or to gain reputation or greater distribution for their Work in
|
||||
part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not
|
||||
limited to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
iii. publicity and privacy rights pertaining to a person's image or
|
||||
likeness depicted in a Work;
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||
in a Work;
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation
|
||||
thereof, including any amended or successor version of such
|
||||
directive); and
|
||||
vii. other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||
of action, whether now known or unknown (including existing as well as
|
||||
future claims and causes of action), in the Work (i) in all territories
|
||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||
treaty (including future time extensions), (iii) in any current or future
|
||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||
including without limitation commercial, advertising or promotional
|
||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||
member of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal or
|
||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||
as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||
be judged legally invalid or ineffective under applicable law, then the
|
||||
Waiver shall be preserved to the maximum extent permitted taking into
|
||||
account Affirmer's express Statement of Purpose. In addition, to the
|
||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future
|
||||
time extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"License"). The License shall be deemed effective as of the date CC0 was
|
||||
applied by Affirmer to the Work. Should any part of the License for any
|
||||
reason be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||
of the License, and in such case Affirmer hereby affirms that he or she
|
||||
will not (i) exercise any of his or her remaining Copyright and Related
|
||||
Rights in the Work or (ii) assert any associated claims and causes of
|
||||
action with respect to the Work, in either case contrary to Affirmer's
|
||||
express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
b. Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy, or
|
||||
the present or absence of errors, whether or not discoverable, all to
|
||||
the greatest extent permissible under applicable law.
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person's Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the
|
||||
Work.
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to
|
||||
this CC0 or use of the Work.
|
||||
@@ -1,186 +0,0 @@
|
||||
import os
|
||||
import re as regex
|
||||
import codecs
|
||||
import shutil
|
||||
import tkinter
|
||||
from tkinter import Tk, filedialog, messagebox, ttk
|
||||
|
||||
path = os.getcwd()
|
||||
png_list = []
|
||||
png_count = 0
|
||||
kks_card_list = []
|
||||
kks_folder = "_KKS_card_"
|
||||
kks_folder2 = "_KKS_to_KK_"
|
||||
do_convert_default = True
|
||||
|
||||
|
||||
def get_list(folder_path):
|
||||
new_list = []
|
||||
for (_, _, files) in os.walk(folder_path):
|
||||
for filename in files:
|
||||
if regex.match(r".*(\.png)$", filename):
|
||||
new_list.append(filename)
|
||||
return new_list
|
||||
|
||||
|
||||
def check_png(card_path):
|
||||
with codecs.open(card_path, "rb") as card:
|
||||
data = card.read()
|
||||
card_type = 0
|
||||
if data.find(b"KoiKatuChara") != -1:
|
||||
card_type = 1
|
||||
if data.find(b"KoiKatuCharaSP") != -1:
|
||||
card_type = 2
|
||||
elif data.find(b"KoiKatuCharaSun") != -1:
|
||||
card_type = 3
|
||||
print(f"[{card_type}] {card_path}")
|
||||
return card_type
|
||||
|
||||
|
||||
def do_convert_check_event():
|
||||
print(f"convert = {do_convert.get()}")
|
||||
|
||||
|
||||
def convert_kk(card_name, card_path, destination_path):
|
||||
with codecs.open(card_path, mode="rb") as card:
|
||||
data = card.read()
|
||||
|
||||
replace_list = [
|
||||
[b"\x15\xe3\x80\x90KoiKatuCharaSun", b"\x12\xe3\x80\x90KoiKatuChara"],
|
||||
[b"Parameter\xa7version\xa50.0.6", b"Parameter\xa7version\xa50.0.5"],
|
||||
[b"version\xa50.0.6\xa3sex", b"version\xa50.0.5\xa3sex"],
|
||||
]
|
||||
|
||||
for text in replace_list:
|
||||
data = data.replace(text[0], text[1])
|
||||
|
||||
new_file_path = os.path.normpath(os.path.join(destination_path, f"KKS2KK_{card_name}"))
|
||||
# print(f"new_file_path {new_file_path}")
|
||||
|
||||
with codecs.open(new_file_path, "wb") as new_card:
|
||||
new_card.write(data)
|
||||
|
||||
|
||||
def c_get_list():
|
||||
global path, png_list, png_count, png_count_t
|
||||
b_sel['state'] = 'disabled'
|
||||
path = filedialog.askdirectory(title="Select target path (folder contain cards)", mustexist=True)
|
||||
|
||||
if path:
|
||||
print(f"path: {path}")
|
||||
os.chdir(path)
|
||||
else:
|
||||
print("no path")
|
||||
b_sel['state'] = 'normal'
|
||||
return
|
||||
|
||||
png_list = get_list(path)
|
||||
png_count = len(png_list)
|
||||
png_count_t.set(f"png found: {png_count}")
|
||||
|
||||
if png_count > 0:
|
||||
b_p['state'] = 'normal'
|
||||
else:
|
||||
b_p['state'] = 'disabled'
|
||||
|
||||
b_sel['state'] = 'normal'
|
||||
|
||||
|
||||
def process_png():
|
||||
global path, png_list, kks_folder, kks_folder2, kks_card_list, window, png_count, png_count_t
|
||||
|
||||
count = len(png_list)
|
||||
if count > 0:
|
||||
bar = ttk.Progressbar(window, maximum=count, length=250)
|
||||
bar.pack(pady=10)
|
||||
bar_val = 0
|
||||
print("0: unknown / 1: kk / 2: kksp / 3: kks")
|
||||
for png in png_list:
|
||||
if check_png(png) == 3:
|
||||
kks_card_list.append(png)
|
||||
bar_val = bar_val + 1
|
||||
bar['value'] = bar_val
|
||||
window.update()
|
||||
bar.destroy()
|
||||
else:
|
||||
messagebox.showinfo("Done", f"no PNG found")
|
||||
return
|
||||
|
||||
count = len(kks_card_list)
|
||||
if count > 0:
|
||||
print(kks_card_list)
|
||||
|
||||
target_folder = os.path.normpath(os.path.join(path, kks_folder))
|
||||
target_folder2 = os.path.normpath(os.path.join(path, kks_folder2))
|
||||
if not os.path.isdir(target_folder):
|
||||
os.mkdir(kks_folder)
|
||||
|
||||
is_convert = do_convert.get()
|
||||
if is_convert:
|
||||
print(f"do convert is [{is_convert}]")
|
||||
if not os.path.isdir(target_folder2):
|
||||
os.mkdir(target_folder2)
|
||||
|
||||
for card in kks_card_list:
|
||||
source = os.path.normpath(os.path.join(path, card))
|
||||
target = os.path.normpath(os.path.join(target_folder, card))
|
||||
|
||||
# copy & convert before move
|
||||
if is_convert:
|
||||
convert_kk(card, source, target_folder2)
|
||||
|
||||
# move file
|
||||
shutil.move(source, target)
|
||||
|
||||
if is_convert:
|
||||
messagebox.showinfo("Done", f"[{count}] cards\nmove to [{kks_folder}] folder\nconvert and save to [{kks_folder2}] folder")
|
||||
else:
|
||||
messagebox.showinfo("Done", f"[{count}] cards\nmove to [{kks_folder}] folder")
|
||||
else:
|
||||
messagebox.showinfo("Done", f"no KKS card found")
|
||||
|
||||
# reset
|
||||
png_list = []
|
||||
kks_card_list = []
|
||||
png_count = 0
|
||||
png_count_t.set(f"png found: 0")
|
||||
b_p['state'] = 'disabled'
|
||||
|
||||
|
||||
window = Tk()
|
||||
# window.withdraw()
|
||||
window.title("KKSCF")
|
||||
w = 300
|
||||
h = 350
|
||||
ltx = int((window.winfo_screenwidth() - w) / 2)
|
||||
lty = int((window.winfo_screenheight() - h) / 2)
|
||||
window.geometry(f'{w}x{h}+{ltx}+{lty}')
|
||||
|
||||
tkinter.Label(window, text=" ", pady=5).pack()
|
||||
|
||||
b_sel = tkinter.Button(window, text="Select folder contain cards", padx=10, pady=10, relief="raised", bd=3, command=c_get_list)
|
||||
b_sel.pack()
|
||||
|
||||
tkinter.Label(window, text=" ", pady=5).pack()
|
||||
|
||||
png_count_t = tkinter.StringVar()
|
||||
png_count_t.set(f"png found: {png_count}")
|
||||
tkinter.Label(window, textvariable=png_count_t, pady=10).pack()
|
||||
|
||||
tkinter.Label(window, text=" ", pady=5).pack()
|
||||
|
||||
do_convert = tkinter.BooleanVar()
|
||||
do_convert.set(do_convert_default)
|
||||
do_convert_check = tkinter.Checkbutton(window, text='copy & convert KKS to KK', variable=do_convert, command=do_convert_check_event)
|
||||
do_convert_check.pack()
|
||||
|
||||
tkinter.Label(window, text=" ", pady=5).pack()
|
||||
|
||||
b_p = tkinter.Button(window, text="Process", relief="raised", padx=10, pady=10, bd=3, command=process_png)
|
||||
b_p.pack()
|
||||
b_p['state'] = 'disabled'
|
||||
|
||||
tkinter.Label(window, text=" ", pady=5).pack()
|
||||
|
||||
window.mainloop()
|
||||
exit(0)
|
||||
13
script.py
@@ -4,13 +4,12 @@ try:
|
||||
with open('traceback.log', 'w') as f:
|
||||
pass
|
||||
|
||||
from util.config import Config
|
||||
from util.logger import Logger
|
||||
from util.file_manager import FileManager
|
||||
from modules.install_chara import InstallChara
|
||||
from modules.remove_chara import RemoveChara
|
||||
from modules.fc_kks import FilterConvertKKS
|
||||
from modules.create_backup import CreateBackup
|
||||
from app.common.logger import Logger
|
||||
from app.modules.install_chara import InstallChara
|
||||
from app.modules.remove_chara import RemoveChara
|
||||
from app.modules.fc_kks import FilterConvertKKS
|
||||
from app.modules.create_backup import CreateBackup
|
||||
|
||||
|
||||
class Script:
|
||||
def __init__(self, config, file_manager):
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
import sys
|
||||
import json
|
||||
import os
|
||||
from util.logger import Logger
|
||||
|
||||
class Config:
|
||||
def __init__(self, config_file):
|
||||
Logger.log_info("SCRIPT", "Initializing config module")
|
||||
self.config_file = config_file
|
||||
self.ok = False
|
||||
self.initialized = False
|
||||
self.config_data = None
|
||||
self.changed = False
|
||||
self.read()
|
||||
|
||||
def read(self):
|
||||
backup_config = self._deepcopy_dict(self.__dict__)
|
||||
|
||||
try:
|
||||
with open(self.config_file, 'r') as json_file:
|
||||
self.config_data = json.load(json_file)
|
||||
except FileNotFoundError:
|
||||
Logger.log_error("SCRIPT", f"Config file '{self.config_file}' not found.")
|
||||
sys.exit(1)
|
||||
except json.JSONDecodeError:
|
||||
Logger.log_error("SCRIPT", f"Invalid JSON format in '{self.config_file}'.")
|
||||
sys.exit(1)
|
||||
|
||||
self.validate()
|
||||
|
||||
if self.ok and not self.initialized:
|
||||
Logger.log_info("SCRIPT", "Starting KKAFIO!")
|
||||
self.initialized = True
|
||||
self.changed = True
|
||||
elif not self.ok and not self.initialized:
|
||||
Logger.log_error("SCRIPT", "Invalid config. Please check your config file.")
|
||||
sys.exit(1)
|
||||
elif not self.ok and self.initialized:
|
||||
Logger.log_warning("SCRIPT", "Config change detected, but with problems. Rolling back config.")
|
||||
self._rollback_config(backup_config)
|
||||
elif self.ok and self.initialized:
|
||||
if backup_config != self.__dict__:
|
||||
Logger.log_warning("SCRIPT", "Config change detected. Hot-reloading.")
|
||||
self.changed = True
|
||||
|
||||
def validate(self):
|
||||
Logger.log_info("SCRIPT", "Validating config")
|
||||
self.ok = True
|
||||
self.tasks = self.config_data["Core"]["Tasks"]
|
||||
self.create_gamepath()
|
||||
|
||||
for task in self.tasks:
|
||||
if self.config_data[task]["Enable"]:
|
||||
if "InputPath" in self.config_data[task]:
|
||||
path = self.config_data[task]["InputPath"]
|
||||
elif "OutputPath" in self.config_data[task]:
|
||||
path = self.config_data[task]["OutputPath"]
|
||||
if not os.path.exists(path):
|
||||
Logger.log_error("SCRIPT", f"Path invalid for task {task}")
|
||||
raise Exception()
|
||||
|
||||
self.install_chara = self.config_data.get("InstallChara", {})
|
||||
self.create_backup = self.config_data.get("CreateBackup", {})
|
||||
self.remove_chara = self.config_data.get("RemoveChara", {})
|
||||
self.fc_kks = self.config_data.get("FCKKS", {})
|
||||
|
||||
def create_gamepath(self):
|
||||
base = self.config_data["Core"]["GamePath"]
|
||||
self.game_path = {
|
||||
"base": base,
|
||||
"UserData": os.path.join(base, "UserData"),
|
||||
"BepInEx": os.path.join(base, "BepInEx"),
|
||||
"mods": os.path.join(base, "mods"),
|
||||
"chara": os.path.join(base, "UserData\\chara\\female"),
|
||||
"coordinate": os.path.join(base, "UserData\coordinate"),
|
||||
"Overlays": os.path.join(base, "UserData\Overlays")
|
||||
}
|
||||
|
||||
for path in self.game_path.values():
|
||||
if not os.path.exists(path):
|
||||
Logger.log_error("SCRIPT", "Game path not valid")
|
||||
raise Exception()
|
||||
|
||||
def _deepcopy_dict(self, dictionary):
|
||||
from copy import deepcopy
|
||||
return deepcopy(dictionary)
|
||||
|
||||
def _rollback_config(self, config):
|
||||
for key, value in config.items():
|
||||
setattr(self, key, value)
|
||||
@@ -1,34 +0,0 @@
|
||||
class Logger(object):
|
||||
|
||||
@classmethod
|
||||
def log_msg(cls, type, msg):
|
||||
print(f"[MSG][{type}] {msg}")
|
||||
|
||||
@classmethod
|
||||
def log_success(cls, type, msg):
|
||||
print(f"[SUCCESS][{type}] {msg}")
|
||||
|
||||
@classmethod
|
||||
def log_skipped(cls, type, msg):
|
||||
print(f"[SKIPPED][{type}] {msg}")
|
||||
|
||||
@classmethod
|
||||
def log_replaced(cls, type, msg):
|
||||
print(f"[REPLACED][{type}] {msg}")
|
||||
|
||||
@classmethod
|
||||
def log_renamed(cls, type, msg):
|
||||
print(f"[RENAMED][{type}] {msg}")
|
||||
|
||||
@classmethod
|
||||
def log_removed(cls, type, msg):
|
||||
print(f"[REMOVED][{type}] {msg}")
|
||||
|
||||
@classmethod
|
||||
def log_error(cls, type, msg):
|
||||
print(f"[ERROR][{type}] {msg}")
|
||||
|
||||
@classmethod
|
||||
def log_info(cls, type, msg):
|
||||
print(f"[INFO][{type}] {msg}")
|
||||
|
||||