From 0ad14ca06d0cf69ff644ecd564045bfcdb483804 Mon Sep 17 00:00:00 2001 From: Onat Bas Date: Sat, 23 Dec 2023 17:48:09 -0500 Subject: [PATCH] pin.template now replaces forgot pin functions --- src/nickelnote.cc | 49 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/src/nickelnote.cc b/src/nickelnote.cc index 5973fe6..807a590 100644 --- a/src/nickelnote.cc +++ b/src/nickelnote.cc @@ -17,16 +17,17 @@ //typedef typedef QWidget FullScreenDragonPowerView; +typedef QWidget PinInputDialog; -FullScreenDragonPowerView *(*setupUi)(FullScreenDragonPowerView *); +FullScreenDragonPowerView *(*powerViewConstructor)(FullScreenDragonPowerView *); +PinInputDialog *(*pinInputConstructor)(PinInputDialog *); extern "C" __attribute__((visibility("default"))) FullScreenDragonPowerView* _fullScreenDragonPowerView_constructor(FullScreenDragonPowerView *_this){ - auto view = setupUi(_this); - QWidget* widget = qobject_cast(view); + auto view = powerViewConstructor(_this); - if (widget) { - QBoxLayout* layout = dynamic_cast(widget->layout()); + if (view) { + QBoxLayout* layout = dynamic_cast(view->layout()); if (layout){ layout->insertWidget(0, new StyledTextBrowser()); } @@ -34,6 +35,31 @@ extern "C" __attribute__((visibility("default"))) FullScreenDragonPowerView* _fu return view; } +extern "C" __attribute__((visibility("default"))) PinInputDialog* _pinCodeInputDialog_constructor(PinInputDialog *_this){ + + auto view = pinInputConstructor(_this); + + if (view) { + QWidget* forgotPin = view->findChild("lblForgotPin"); + if (forgotPin){ + QWidget* parentOfFoundWidget = forgotPin->parentWidget(); + if (parentOfFoundWidget) { + QLayout* parentLayout = parentOfFoundWidget->layout(); + parentLayout->replaceWidget(forgotPin, new StyledTextBrowser()); + delete forgotPin; + } + } + + QWidget* signout = view->findChild("lblSignout"); + if (signout){ + signout->setParent(nullptr); + delete signout; + } + } + return view; +} + + struct nh_info NickelNote = { .name = "NickelNote", .desc = "show a note on the main screen during sleep.", @@ -46,9 +72,16 @@ struct nh_hook NickelNoteHook[] = { .sym = "_ZN25FullScreenDragonPowerViewC1Ev", .sym_new = "_fullScreenDragonPowerView_constructor", .lib = "libnickel.so.1.0.0", - .out = nh_symoutptr(setupUi), - .desc= "Play with the Dragon!" - } , + .out = nh_symoutptr(powerViewConstructor), + .desc= "Change power down sleep view." + }, + { + .sym = "_ZN18PinCodeInputDialogC1EP7QWidget", + .sym_new = "_pinCodeInputDialog_constructor", + .lib = "libnickel.so.1.0.0", + .out = nh_symoutptr(pinInputConstructor), + .desc= "Change input pin dialog." + }, {0} };