From c88d80f3dfb57b701ca17f474cf3c651d4191318 Mon Sep 17 00:00:00 2001 From: leminlimez <59540996+leminlimez@users.noreply.github.com> Date: Mon, 31 Mar 2025 14:29:36 -0400 Subject: [PATCH] add option to use the foreground for ca videos --- devicemanagement/device_manager.py | 2 +- gui/main_window.py | 8 +++++- qt/mainwindow.ui | 39 ++++++++++++++++++------------ qt/mainwindow_ui.py | 28 ++++++++++++--------- qt/ui_mainwindow.py | 28 ++++++++++++--------- tweaks/posterboard_tweak.py | 10 +++++++- 6 files changed, 74 insertions(+), 41 deletions(-) diff --git a/devicemanagement/device_manager.py b/devicemanagement/device_manager.py index 100a302..73981fe 100644 --- a/devicemanagement/device_manager.py +++ b/devicemanagement/device_manager.py @@ -430,7 +430,7 @@ class DeviceManager: except Exception as e: # ignore clean up errors print(str(e)) - msg = "Your device will now restart.\nRemember to turn Find My back on!" + msg = "Your device will now restart.\n\nRemember to turn Find My back on!" if not self.auto_reboot: msg = "Please restart your device to see changes." show_alert(ApplyAlertMessage(txt="All done! " + msg, title="Success!", icon=QMessageBox.Information)) diff --git a/gui/main_window.py b/gui/main_window.py index 2c48ffc..6cce321 100644 --- a/gui/main_window.py +++ b/gui/main_window.py @@ -178,7 +178,9 @@ class MainWindow(QtWidgets.QMainWindow): self.ui.clearSuggestedBtn.clicked.connect(self.on_clearSuggestedBtn_clicked) self.ui.caVideoChk.toggled.connect(self.on_caVideoChk_toggled) self.ui.reverseLoopChk.toggled.connect(self.on_reverseLoopChk_toggled) + self.ui.useForegroundChk.toggled.connect(self.on_useForegroundChk_toggled) self.ui.reverseLoopChk.hide() # hide by default + self.ui.useForegroundChk.hide() self.ui.findPBBtn.clicked.connect(self.on_findPBBtn_clicked) self.ui.pbHelpBtn.clicked.connect(self.on_pbHelpBtn_clicked) @@ -923,7 +925,7 @@ class MainWindow(QtWidgets.QMainWindow): spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) # main layout layout = QtWidgets.QHBoxLayout(widget) - layout.setContentsMargins(0, 0, 0, 9) + layout.setContentsMargins(0, 0, 0, 3) layout.addWidget(titleBtn) layout.addItem(spacer) layout.addWidget(delBtn) @@ -1017,13 +1019,17 @@ class MainWindow(QtWidgets.QMainWindow): self.ui.pbVideoThumbLbl.hide() self.ui.clearSuggestedBtn.hide() self.ui.reverseLoopChk.show() + self.ui.useForegroundChk.show() else: self.ui.chooseThumbBtn.show() self.ui.pbVideoThumbLbl.show() self.ui.clearSuggestedBtn.show() self.ui.reverseLoopChk.hide() + self.ui.useForegroundChk.hide() def on_reverseLoopChk_toggled(self, checked: bool): tweaks["PosterBoard"].reverse_video = checked + def on_useForegroundChk_toggled(self, checked: bool): + tweaks["PosterBoard"].use_foreground = checked def on_findPBBtn_clicked(self): webbrowser.open_new_tab("https://cowabun.ga/wallpapers") diff --git a/qt/mainwindow.ui b/qt/mainwindow.ui index 5b1d1d2..0a349f1 100644 --- a/qt/mainwindow.ui +++ b/qt/mainwindow.ui @@ -4148,7 +4148,7 @@ To work properly, also disable the daemon using the toggle above. 0 - 9 + 0 @@ -4270,21 +4270,6 @@ To work properly, also disable the daemon using the toggle above. - - - - QFrame { - color: #414141; -} - - - QFrame::Plain - - - Qt::Horizontal - - - @@ -4402,6 +4387,21 @@ To work properly, also disable the daemon using the toggle above. + + + + QFrame { + color: #414141; +} + + + QFrame::Plain + + + Qt::Horizontal + + + @@ -4590,6 +4590,13 @@ Will show up in Collections + + + + Make Foreground (hides clock) + + + diff --git a/qt/mainwindow_ui.py b/qt/mainwindow_ui.py index 160573d..1611e47 100644 --- a/qt/mainwindow_ui.py +++ b/qt/mainwindow_ui.py @@ -2187,7 +2187,7 @@ class Ui_Nugget(object): self.horizontalLayout_203 = QHBoxLayout(self.horizontalWidget_53) self.horizontalLayout_203.setSpacing(10) self.horizontalLayout_203.setObjectName(u"horizontalLayout_203") - self.horizontalLayout_203.setContentsMargins(0, 9, 0, 9) + self.horizontalLayout_203.setContentsMargins(0, 9, 0, 0) self.toolButton_103 = QToolButton(self.horizontalWidget_53) self.toolButton_103.setObjectName(u"toolButton_103") self.toolButton_103.setEnabled(True) @@ -2249,16 +2249,6 @@ class Ui_Nugget(object): self.verticalLayout_143.addWidget(self.horizontalWidget_53) - self.line_123 = QFrame(self.posterboardPage) - self.line_123.setObjectName(u"line_123") - self.line_123.setStyleSheet(u"QFrame {\n" -" color: #414141;\n" -"}") - self.line_123.setFrameShadow(QFrame.Plain) - self.line_123.setFrameShape(QFrame.Shape.HLine) - - self.verticalLayout_143.addWidget(self.line_123) - self.pbPagePicker = QWidget(self.posterboardPage) self.pbPagePicker.setObjectName(u"pbPagePicker") sizePolicy5 = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed) @@ -2314,6 +2304,16 @@ class Ui_Nugget(object): self.verticalLayout_143.addWidget(self.pbPagePicker) + self.line_123 = QFrame(self.posterboardPage) + self.line_123.setObjectName(u"line_123") + self.line_123.setStyleSheet(u"QFrame {\n" +" color: #414141;\n" +"}") + self.line_123.setFrameShadow(QFrame.Plain) + self.line_123.setFrameShape(QFrame.Shape.HLine) + + self.verticalLayout_143.addWidget(self.line_123) + self.pbActionLbl = QLabel(self.posterboardPage) self.pbActionLbl.setObjectName(u"pbActionLbl") @@ -2414,6 +2414,11 @@ class Ui_Nugget(object): self.verticalLayout_39.addWidget(self.reverseLoopChk) + self.useForegroundChk = QCheckBox(self.pbVideoPage) + self.useForegroundChk.setObjectName(u"useForegroundChk") + + self.verticalLayout_39.addWidget(self.useForegroundChk) + self.horizontalLayout_30 = QHBoxLayout() self.horizontalLayout_30.setObjectName(u"horizontalLayout_30") self.chooseThumbBtn = QToolButton(self.pbVideoPage) @@ -3841,6 +3846,7 @@ class Ui_Nugget(object): #endif // QT_CONFIG(tooltip) self.caVideoChk.setText(QCoreApplication.translate("Nugget", u"Loop (use CoreAnimation method)", None)) self.reverseLoopChk.setText(QCoreApplication.translate("Nugget", u"Reverse on Loop", None)) + self.useForegroundChk.setText(QCoreApplication.translate("Nugget", u"Make Foreground (hides clock)", None)) #if QT_CONFIG(tooltip) self.chooseThumbBtn.setToolTip(QCoreApplication.translate("Nugget", u"Choose a photo for the wallpaper to freeze on when finished (.heic files only)", None)) #endif // QT_CONFIG(tooltip) diff --git a/qt/ui_mainwindow.py b/qt/ui_mainwindow.py index d9fad3f..f878bd8 100644 --- a/qt/ui_mainwindow.py +++ b/qt/ui_mainwindow.py @@ -2187,7 +2187,7 @@ class Ui_Nugget(object): self.horizontalLayout_203 = QHBoxLayout(self.horizontalWidget_53) self.horizontalLayout_203.setSpacing(10) self.horizontalLayout_203.setObjectName(u"horizontalLayout_203") - self.horizontalLayout_203.setContentsMargins(0, 9, 0, 9) + self.horizontalLayout_203.setContentsMargins(0, 9, 0, 0) self.toolButton_103 = QToolButton(self.horizontalWidget_53) self.toolButton_103.setObjectName(u"toolButton_103") self.toolButton_103.setEnabled(True) @@ -2249,16 +2249,6 @@ class Ui_Nugget(object): self.verticalLayout_143.addWidget(self.horizontalWidget_53) - self.line_123 = QFrame(self.posterboardPage) - self.line_123.setObjectName(u"line_123") - self.line_123.setStyleSheet(u"QFrame {\n" -" color: #414141;\n" -"}") - self.line_123.setFrameShadow(QFrame.Plain) - self.line_123.setFrameShape(QFrame.HLine) - - self.verticalLayout_143.addWidget(self.line_123) - self.pbPagePicker = QWidget(self.posterboardPage) self.pbPagePicker.setObjectName(u"pbPagePicker") sizePolicy5 = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed) @@ -2314,6 +2304,16 @@ class Ui_Nugget(object): self.verticalLayout_143.addWidget(self.pbPagePicker) + self.line_123 = QFrame(self.posterboardPage) + self.line_123.setObjectName(u"line_123") + self.line_123.setStyleSheet(u"QFrame {\n" +" color: #414141;\n" +"}") + self.line_123.setFrameShadow(QFrame.Plain) + self.line_123.setFrameShape(QFrame.HLine) + + self.verticalLayout_143.addWidget(self.line_123) + self.pbActionLbl = QLabel(self.posterboardPage) self.pbActionLbl.setObjectName(u"pbActionLbl") @@ -2414,6 +2414,11 @@ class Ui_Nugget(object): self.verticalLayout_39.addWidget(self.reverseLoopChk) + self.useForegroundChk = QCheckBox(self.pbVideoPage) + self.useForegroundChk.setObjectName(u"useForegroundChk") + + self.verticalLayout_39.addWidget(self.useForegroundChk) + self.horizontalLayout_30 = QHBoxLayout() self.horizontalLayout_30.setObjectName(u"horizontalLayout_30") self.chooseThumbBtn = QToolButton(self.pbVideoPage) @@ -3841,6 +3846,7 @@ class Ui_Nugget(object): #endif // QT_CONFIG(tooltip) self.caVideoChk.setText(QCoreApplication.translate("Nugget", u"Loop (use CoreAnimation method)", None)) self.reverseLoopChk.setText(QCoreApplication.translate("Nugget", u"Reverse on Loop", None)) + self.useForegroundChk.setText(QCoreApplication.translate("Nugget", u"Make Foreground (hides clock)", None)) #if QT_CONFIG(tooltip) self.chooseThumbBtn.setToolTip(QCoreApplication.translate("Nugget", u"Choose a photo for the wallpaper to freeze on when finished (.heic files only)", None)) #endif // QT_CONFIG(tooltip) diff --git a/tweaks/posterboard_tweak.py b/tweaks/posterboard_tweak.py index dc8fa58..f904e60 100644 --- a/tweaks/posterboard_tweak.py +++ b/tweaks/posterboard_tweak.py @@ -67,6 +67,7 @@ class PosterboardTweak(Tweak): self.videoFile = None self.loop_video = False self.reverse_video = False + self.use_foreground = False self.bundle_id = "com.apple.PosterBoard" self.resetting = False self.resetType = 0 # 0 for descriptor, 1 for prb, 2 for suggested photos @@ -211,7 +212,14 @@ class PosterboardTweak(Tweak): source_dir = get_bundle_files("files/posterboard/VideoCAML") video_output_dir = os.path.join(output_dir, "descriptor/VideoCAML") copytree(source_dir, video_output_dir, dirs_exist_ok=True) - contents_path = os.path.join(video_output_dir, "versions/1/contents/9183.Custom-810w-1080h@2x~ipad.wallpaper/9183.Custom_Background-810w-1080h@2x~ipad.ca") + contents_path = os.path.join(video_output_dir, "versions/1/contents/9183.Custom-810w-1080h@2x~ipad.wallpaper") + if self.use_foreground: + # rename the foreground layer to background + bg_path = os.path.join(contents_path, "9183.Custom_Background-810w-1080h@2x~ipad.ca") + contents_path = os.path.join(contents_path, "9183.Custom_Floating-810w-1080h@2x~ipad.ca") + os.rename(contents_path, bg_path) + else: + contents_path = os.path.join(contents_path, "9183.Custom_Background-810w-1080h@2x~ipad.ca") print(f"path at {contents_path}, creating caml") video_handler.create_caml(video_path=self.videoFile, output_file=contents_path, auto_reverses=self.reverse_video, update_label=update_label)