1 Star 0 Fork 0

btwise/qtocc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
mainwindow.cpp 171.83 KB
一键复制 编辑 原始数据 按行查看 历史
btwise 提交于 2020-10-27 13:39 . update UI
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "plistparser.h"
#include "plistserializer.h"
#include <QFileDialog>
#include <QSettings>
#include <QBuffer>
#include <QMessageBox>
QString PlistFileName;
QVector<QString> filelist;
QWidgetList wdlist;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
loadLocal();
test(false); //是否显示测试按钮
title = "QtOpenCoreConfigurator V0.6.3-2020.10.21";
setWindowTitle(title);
ui->tabTotal->setCurrentIndex(0);
ui->tabACPI->setCurrentIndex(0);
ui->tabBooter->setCurrentIndex(0);
ui->tabDP->setCurrentIndex(0);
ui->tabKernel->setCurrentIndex(0);
ui->tabMisc->setCurrentIndex(0);
ui->tabNVRAM->setCurrentIndex(0);
ui->tabPlatformInfo->setCurrentIndex(0);
ui->tabUEFI->setCurrentIndex(0);
ui->btnExportSub->setVisible(false);
ui->btnImportSub->setVisible(false);
ui->tabTotal->tabBar()->setTabToolTip(0, tr("ACPI"));
ui->tabTotal->tabBar()->setTabToolTip(1, tr("Booter"));
ui->tabTotal->tabBar()->setTabToolTip(2, tr("DeviceProperties"));
//ui->tabTotal->tabBar()->setTabText(2, tr("Device\nProperties"));
ui->tabTotal->tabBar()->setTabToolTip(3, tr("Kernel"));
ui->tabTotal->tabBar()->setTabToolTip(4, tr("Misc"));
ui->tabTotal->tabBar()->setTabToolTip(5, tr("NVRAM"));
ui->tabTotal->tabBar()->setTabToolTip(6, tr("PlatformInfo"));
ui->tabTotal->tabBar()->setTabToolTip(7, tr("UEFI"));
QString tabBarStyle0 = "QTabBar::tab {min-width:100px;border: 0px solid;border-top-left-radius: 5px;border-top-right-radius: 5px;padding:2px;}\
QTabBar::tab:!selected {margin-top: 2px;}\
QTabWidget::pane{border:none;}\
QTabBar::tab{background:transparent;color:black;}\
QTabBar::tab:hover{background:rgba(0, 0, 255, 80);}\
QTabBar::tab:selected{border-color: white;background:rgba(0, 0, 255, 255);color:white;}";
QString tabBarStyle1 = "QTabBar::tab {min-width:100px;color: rgba(150,150,150);border: 2px solid;border-top-left-radius: 10px;border-top-right-radius: 10px;padding:5px;}\
QTabBar::tab:!selected {margin-top: 5px;} \
QTabBar::tab:selected {color: rgba(255,255,255);}";
QString tabBarStyle2 = "QTabBar::tab {min-width:100px;color: black;background-color:qlineargradient(x1:0, y1:0, x2:0, y2:1, stop: 0 #eeeeee, stop: 1 gray);border: 0px solid;border-top-left-radius: 10px;border-top-right-radius: 10px;padding:5px;}\
QTabBar::tab:!selected {margin-top: 5px;} \
QTabBar::tab:selected {color: blue;}";
QString tabBarStyle3 = "QTabWidget::pane{border:none;}\
QTabWidget::tab-bar{alignment:left;}\
QTabBar::tab{background:transparent;color:black;}\
QTabBar::tab:hover{background:rgba(0, 0, 255, 80);}\
QTabBar::tab:selected{border-color: white;background:rgba(0, 0, 255, 255);color:white;}";
//ui->tabACPI->setStyleSheet(tabBarStyle3);
ui->tabTotal->tabBar()->setStyle(new CustomTabStyle4);
//ui->tabACPI->tabBar()->setStyle(new CustomTabStyle2);
//ui->tabBooter->tabBar()->setStyle(new CustomTabStyle5);
//ui->tabDP->tabBar()->setStyle(new CustomTabStyle5);
//ui->tabKernel->tabBar()->setStyle(new CustomTabStyle5);
//ui->tabMisc->tabBar()->setStyle(new CustomTabStyle5);
//ui->tabNVRAM->tabBar()->setStyle(new CustomTabStyle5);
//ui->tabPlatformInfo->tabBar()->setStyle(new CustomTabStyle5);
//ui->tabUEFI->tabBar()->setStyle(new CustomTabStyle5);
ui->tabTotal->setIconSize(QSize(64, 64));
QIcon icon;
icon.addFile(":/icon.png");
//ui->tabTotal->setTabIcon(1, icon);
init_tr_str();
initui_booter();
initui_dp();
initui_kernel();
initui_misc();
initui_nvram();
initui_PlatformInfo();
initui_UEFI();
initui_acpi();
//主菜单
connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::on_btnOpen_clicked);
connect(ui->actionSave, &QAction::triggered, this, &MainWindow::on_btnSave_clicked);
connect(ui->actionSave_As, &QAction::triggered, this, &MainWindow::on_btnSaveAs_clicked);
connect(ui->actionAbout_2, &QAction::triggered, this, &MainWindow::about);
ui->btnSave->setEnabled(false);
ui->actionSave->setEnabled(false);
//接受文件拖放打开
this->setAcceptDrops(true);
ui->tabTotal->removeTab(8);
QFont font;
#ifdef Q_OS_WIN32
reg_win();
font.setPixelSize(17);
ui->tabTotal->setDocumentMode(false);
#endif
#ifdef Q_OS_LINUX
ui->btnMountEsp->setEnabled(false);
font.setPixelSize(12);
#endif
#ifdef Q_OS_MAC
font.setPixelSize(12);
#endif
QFileInfo appInfo(qApp->applicationFilePath());
ui->statusbar->showMessage(tr("Last modified): ") + appInfo.lastModified().toString("yyyy-MM-dd hh:mm:ss"));
//设置QToolTip颜色
/*QPalette palette = QToolTip::palette();
palette.setColor(QPalette::Inactive,QPalette::ToolTipBase,Qt::white); //设置ToolTip背景色
palette.setColor(QPalette::Inactive,QPalette::ToolTipText,QColor(50, 50, 255, 255)); //设置ToolTip字体色
QToolTip::setPalette(palette);
QToolTip::setFont(font);*/ //设置ToolTip字体
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::openFile(QString PlistFileName)
{
if(!PlistFileName.isEmpty())
setWindowTitle(title + " " + PlistFileName);
else
return;
//初始化
//ACPI
ui->table_acpi_add->setRowCount(0);
ui->table_acpi_del->setRowCount(0);
ui->table_acpi_patch->setRowCount(0);
//Booter
ui->table_booter->setRowCount(0);
//DP
ui->table_dp_add0->setRowCount(0);
ui->table_dp_add->setRowCount(0);
ui->table_dp_del0->setRowCount(0);
ui->table_dp_del->setRowCount(0);
//Kernel
ui->table_kernel_add->setRowCount(0);
ui->table_kernel_block->setRowCount(0);
ui->table_kernel_Force->setRowCount(0);
ui->table_kernel_patch->setRowCount(0);
//Misc
ui->tableBlessOverride->setRowCount(0);
ui->tableEntries->setRowCount(0);
ui->tableTools->setRowCount(0);
//UEFI
ui->table_uefi_drivers->setRowCount(0);
ui->table_uefi_ReservedMemory->setRowCount(0);
//NVRAM
ui->table_nv_add0->setRowCount(0);
ui->table_nv_add->setRowCount(0);
ui->table_nv_del0->setRowCount(0);
ui->table_nv_del->setRowCount(0);
ui->table_nv_ls0->setRowCount(0);
ui->table_nv_ls->setRowCount(0);
QFile file(PlistFileName);
QVariantMap map = PListParser::parsePList(&file).toMap();
loading = true;
ParserACPI(map);
ParserBooter(map);
ParserDP(map);
ParserKernel(map);
ParserMisc(map);
ParserNvram(map);
ParserPlatformInfo(map);
ParserUEFI(map);
loading = false;
ui->btnSave->setEnabled(true);
ui->actionSave->setEnabled(true);
}
void MainWindow::on_btnOpen_clicked()
{
QFileDialog fd;
PlistFileName = fd.getOpenFileName(this,"Config file","","Config file(*.plist);;All files(*.*)");
openFile(PlistFileName);
}
void MainWindow::on_btnTestWrite_clicked()
{
QString plistPath = QDir::homePath() + "/xx.plist";
qDebug() << plistPath;
//QString plistPath = "E:/xxx.plist";
QSettings Reg(plistPath, QSettings::NativeFormat);
Reg.setValue("ACPI", true);
qDebug() << Reg.value("ACPI");
int i = 1;
QString str_key = "/key";
QString str_class = "/class";
QString str_value ="/value";
Reg.setValue(QString::number(i) + str_key,"key1");
Reg.setValue("1/class","class1");
Reg.setValue("1/value","value1");
qDebug() << Reg.value("1/key").toString();
qDebug() << Reg.value("1/class").toString();
qDebug() << Reg.value("1/value").toString();
}
void MainWindow::on_btnParse_clicked()
{
QByteArray sample = "\
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\
<plist version=\"1.0\">\
<dict>\
<key>SomeKey</key>\
<string>Value1</string>\
<key>MyOtherKey</key>\
<string>Value2</string>\
</dict>\
</plist>";
QBuffer buffer(&sample);
//QVariantMap map = PListParser::parsePList(&buffer).toMap();
QFile file(QDir::homePath() + "/com.xx.plist");
QVariantMap map = PListParser::parsePList(&file).toMap();
//QString val = map["test"].toString();
qDebug() << map.firstKey();
qDebug() << map.lastKey();
qDebug() << map.keys();
qDebug() << map.count();
map = map["ACPI"].toMap();
QVariantList map2 = map["Add"].toList();
qDebug() << map2.at(0) << map2.count();
QVariantMap map3 = map2.at(0).toMap();
qDebug() << map3["Comment"].toString();
qDebug() << map3["Enabled"].toBool();
qDebug() << map3["Path"].toString();
}
void MainWindow::on_btnSerialize_clicked()
{
QFile file(QDir::homePath() + "/com.xx.plist");
QVariantMap map = PListParser::parsePList(&file).toMap();
QVariantMap foo;
QVariantMap sub;
//sub = foo["SomeKey"].toMap();
QString data = "2147483648";
sub["test"] = 12345;
qDebug() << data.toLongLong();
sub["A"] = 1;
foo["SomeOtherKey"] = sub;
foo["test2"] = true;
foo["test3"] = data.toLongLong();
//qDebug() << "PList:\n" << PListSerializer::toPList(foo).toNSString();
PListSerializer::toPList(foo , QDir::homePath() + "/test.plist");
}
void MainWindow::ParserACPI(QVariantMap map)
{
map = map["ACPI"].toMap();
if(map.isEmpty())
return;
//分析"Add"
QVariantList map_add = map["Add"].toList();
//qDebug() << map_add;
ui->table_acpi_add->setRowCount(map_add.count());//设置行的列数
for(int i = 0;i < map_add.count(); i++)
{
QVariantMap map3 = map_add.at(i).toMap();
QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map3["Path"].toString());
ui->table_acpi_add->setItem(i, 0, newItem1);
newItem1 = new QTableWidgetItem(map3["Comment"].toString());
ui->table_acpi_add->setItem(i, 1, newItem1);
init_enabled_data(ui->table_acpi_add , i , 2 , map3["Enabled"].toString());
}
//分析Delete
QVariantList map_del = map["Delete"].toList();
//qDebug() << map_del;
ui->table_acpi_del->setRowCount(map_del.count());//设置行的列数
for(int i = 0;i < map_del.count(); i++)
{
QVariantMap map3 = map_del.at(i).toMap();
QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(ByteToHexStr(map3["TableSignature"].toByteArray()));
ui->table_acpi_del->setItem(i, 0, newItem1);
newItem1 = new QTableWidgetItem(ByteToHexStr(map3["OemTableId"].toByteArray()));
ui->table_acpi_del->setItem(i, 1, newItem1);
newItem1 = new QTableWidgetItem(map3["TableLength"].toString());
ui->table_acpi_del->setItem(i, 2, newItem1);
newItem1 = new QTableWidgetItem(map3["Comment"].toString());
ui->table_acpi_del->setItem(i, 3, newItem1);
init_enabled_data(ui->table_acpi_del , i , 4 , map3["All"].toString());
init_enabled_data(ui->table_acpi_del , i , 5 , map3["Enabled"].toString());
}
//分析Patch
QVariantList map_patch = map["Patch"].toList();
ui->table_acpi_patch->setRowCount(map_patch.count());//设置行的列数
for(int i = 0;i < map_patch.count(); i++)
{
QVariantMap map3 = map_patch.at(i).toMap();
QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map3["TableSignature"].toString());
ui->table_acpi_patch->setItem(i, 0, newItem1);
newItem1 = new QTableWidgetItem(map3["OemTableId"].toString());
ui->table_acpi_patch->setItem(i, 1, newItem1);
newItem1 = new QTableWidgetItem(map3["TableLength"].toString());
ui->table_acpi_patch->setItem(i, 2, newItem1);
//newItem1 = new QTableWidgetItem(map3["Find"].toString());
ui->table_acpi_patch->setItem(i, 3, new QTableWidgetItem(ByteToHexStr(map3["Find"].toByteArray())));
newItem1 = new QTableWidgetItem(ByteToHexStr(map3["Replace"].toByteArray()));
ui->table_acpi_patch->setItem(i, 4, newItem1);
newItem1 = new QTableWidgetItem(map3["Comment"].toString());
ui->table_acpi_patch->setItem(i, 5, newItem1);
newItem1 = new QTableWidgetItem(map3["Mask"].toString());
ui->table_acpi_patch->setItem(i, 6, newItem1);
newItem1 = new QTableWidgetItem(map3["ReplaceMask"].toString());
ui->table_acpi_patch->setItem(i, 7, newItem1);
newItem1 = new QTableWidgetItem(map3["Count"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_acpi_patch->setItem(i, 8, newItem1);
newItem1 = new QTableWidgetItem(map3["Limit"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_acpi_patch->setItem(i, 9, newItem1);
newItem1 = new QTableWidgetItem(map3["Skip"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_acpi_patch->setItem(i, 10, newItem1);
init_enabled_data(ui->table_acpi_patch , i , 11 , map3["Enabled"].toString());
}
//分析Quirks
QVariantMap map_quirks = map["Quirks"].toMap();
ui->chkFadtEnableReset->setChecked(map_quirks["FadtEnableReset"].toBool());
ui->chkNormalizeHeaders->setChecked(map_quirks["NormalizeHeaders"].toBool());
ui->chkRebaseRegions->setChecked(map_quirks["RebaseRegions"].toBool());
ui->chkResetHwSig->setChecked(map_quirks["ResetHwSig"].toBool());
ui->chkResetLogoStatus->setChecked(map_quirks["ResetLogoStatus"].toBool());
}
void MainWindow::initui_acpi()
{
ui->btnExportMaster->setText(tr("Export") + " ACPI");
ui->btnImportMaster->setText(tr("Import") + " ACPI");
QTableWidgetItem *id0;
//ACPI-Add
ui->table_acpi_add->setColumnWidth(0,450);
id0 = new QTableWidgetItem(tr("Path"));
ui->table_acpi_add->setHorizontalHeaderItem(0, id0);
ui->table_acpi_add->setColumnWidth(1,350);
id0 = new QTableWidgetItem(tr("Comment"));
ui->table_acpi_add->setHorizontalHeaderItem(1, id0);
id0 = new QTableWidgetItem(tr("Enabled"));
ui->table_acpi_add->setHorizontalHeaderItem(2, id0);
ui->table_acpi_add->setAlternatingRowColors(true);//底色交替显示
//ACPI-Delete
id0=new QTableWidgetItem(tr("TableSignature"));
ui->table_acpi_del->setHorizontalHeaderItem(0, id0);
ui->table_acpi_del->setColumnWidth(1,250);
id0 = new QTableWidgetItem(tr("OemTableId"));
ui->table_acpi_del->setHorizontalHeaderItem(1,id0);
id0 = new QTableWidgetItem(tr("TableLength"));
ui->table_acpi_del->setHorizontalHeaderItem(2,id0);
ui->table_acpi_del->setColumnWidth(3,250);
id0 = new QTableWidgetItem(tr("Comment"));
ui->table_acpi_del->setHorizontalHeaderItem(3,id0);
id0 = new QTableWidgetItem(tr("All"));
ui->table_acpi_del->setHorizontalHeaderItem(4,id0);
id0 = new QTableWidgetItem(tr("Enabled"));
ui->table_acpi_del->setHorizontalHeaderItem(5,id0);
ui->table_acpi_del->setAlternatingRowColors(true);
//ACPI-Patch
ui->table_acpi_patch->setColumnWidth(0,150);
id0=new QTableWidgetItem(tr("TableSignature"));
ui->table_acpi_patch->setHorizontalHeaderItem(0, id0);
id0 = new QTableWidgetItem(tr("OemTableId"));
ui->table_acpi_patch->setHorizontalHeaderItem(1,id0);
id0 = new QTableWidgetItem(tr("TableLength"));
ui->table_acpi_patch->setHorizontalHeaderItem(2,id0);
ui->table_acpi_patch->setColumnWidth(3,200);
id0 = new QTableWidgetItem(tr("Find"));
ui->table_acpi_patch->setHorizontalHeaderItem(3,id0);
ui->table_acpi_patch->setColumnWidth(4,200);
id0 = new QTableWidgetItem(tr("Replace"));
ui->table_acpi_patch->setHorizontalHeaderItem(4,id0);
ui->table_acpi_patch->setColumnWidth(5,300);
id0 = new QTableWidgetItem(tr("Comment"));
ui->table_acpi_patch->setHorizontalHeaderItem(5,id0);
id0 = new QTableWidgetItem(tr("Mask"));
ui->table_acpi_patch->setHorizontalHeaderItem(6,id0);
id0 = new QTableWidgetItem(tr("ReplaceMask"));
ui->table_acpi_patch->setHorizontalHeaderItem(7,id0);
id0 = new QTableWidgetItem(tr("Count"));
ui->table_acpi_patch->setHorizontalHeaderItem(8,id0);
id0 = new QTableWidgetItem(tr("Limit"));
ui->table_acpi_patch->setHorizontalHeaderItem(9,id0);
id0 = new QTableWidgetItem(tr("Skip"));
ui->table_acpi_patch->setHorizontalHeaderItem(10,id0);
id0 = new QTableWidgetItem(tr("Enabled"));
ui->table_acpi_patch->setHorizontalHeaderItem(11,id0);
ui->table_acpi_patch->setAlternatingRowColors(true);
if(zh_cn)
{
ui->table_acpi_patch->horizontalHeaderItem(0)->setToolTip("匹配表签名等于该值,除非全为零。");
ui->table_acpi_patch->horizontalHeaderItem(1)->setToolTip("匹配表OEM ID等于此值,除非全为零。");
ui->table_acpi_patch->horizontalHeaderItem(2)->setToolTip("匹配表大小等于此值,除非为0。");
ui->table_acpi_patch->horizontalHeaderItem(3)->setToolTip("查找");
ui->table_acpi_patch->horizontalHeaderItem(4)->setToolTip("替换");
ui->table_acpi_patch->horizontalHeaderItem(5)->setToolTip("注释");
ui->table_acpi_patch->horizontalHeaderItem(6)->setToolTip("查找比较期间使用的数据按位掩码。 通过忽略未屏蔽(设置到零)位。 可以设置为空数据以忽略。 否则必须等于“替换大小”。");
ui->table_acpi_patch->horizontalHeaderItem(7)->setToolTip("替换期间使用的数据按位掩码。 通过更新遮罩(设置到非零)位。 可以设置为空数据以忽略。 否则必须等于“替换大小”。");
ui->table_acpi_patch->horizontalHeaderItem(8)->setToolTip("要应用的补丁出现次数。 0将补丁应用于所有发现的事件。");
ui->table_acpi_patch->horizontalHeaderItem(9)->setToolTip("要搜索的最大字节数。 可以设置为0以浏览整个ACPI表。");
ui->table_acpi_patch->horizontalHeaderItem(10)->setToolTip("完成替换之前要跳过的发现事件数。");
ui->table_acpi_patch->horizontalHeaderItem(11)->setToolTip("是否启用");
}
}
void MainWindow::initui_booter()
{
QTableWidgetItem *id0;
ui->table_booter->setColumnWidth(0,450);
id0 = new QTableWidgetItem(tr("Address"));
ui->table_booter->setHorizontalHeaderItem(0, id0);
ui->table_booter->setColumnWidth(1,350);
id0 = new QTableWidgetItem(tr("Comment"));
ui->table_booter->setHorizontalHeaderItem(1, id0);
id0 = new QTableWidgetItem(tr("Enabled"));
ui->table_booter->setHorizontalHeaderItem(2, id0);
ui->table_booter->setAlternatingRowColors(true);
if(zh_cn)
{
ui->table_booter->horizontalHeaderItem(0)->setToolTip("地址");
ui->table_booter->horizontalHeaderItem(1)->setToolTip("注释");
ui->table_booter->horizontalHeaderItem(2)->setToolTip("是否启用");
}
}
void MainWindow::ParserBooter(QVariantMap map)
{
map = map["Booter"].toMap();
if(map.isEmpty())
return;
QVariantList map_add = map["MmioWhitelist"].toList();
//qDebug() << map_add;
ui->table_booter->setRowCount(map_add.count());//设置行的列数
for(int i = 0;i < map_add.count(); i++)
{
QVariantMap map3 = map_add.at(i).toMap();
QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map3["Address"].toString());
ui->table_booter->setItem(i, 0, newItem1);
newItem1 = new QTableWidgetItem(map3["Comment"].toString());
ui->table_booter->setItem(i, 1, newItem1);
init_enabled_data(ui->table_booter , i , 2 , map3["Enabled"].toString());
}
//Quirks
QVariantMap map_quirks = map["Quirks"].toMap();
ui->chkAvoidRuntimeDefrag->setChecked(map_quirks["AvoidRuntimeDefrag"].toBool());
ui->chkDevirtualiseMmio->setChecked(map_quirks["DevirtualiseMmio"].toBool());
ui->chkDisableSingleUser->setChecked(map_quirks["DisableSingleUser"].toBool());
ui->chkDisableVariableWrite->setChecked(map_quirks["DisableVariableWrite"].toBool());
ui->chkDiscardHibernateMap->setChecked(map_quirks["DiscardHibernateMap"].toBool());
ui->chkEnableSafeModeSlide->setChecked(map_quirks["EnableSafeModeSlide"].toBool());
ui->chkEnableWriteUnprotector->setChecked(map_quirks["EnableWriteUnprotector"].toBool());
ui->chkForceExitBootServices->setChecked(map_quirks["ForceExitBootServices"].toBool());
ui->chkProtectMemoryRegions->setChecked(map_quirks["ProtectMemoryRegions"].toBool());
ui->chkProtectSecureBoot->setChecked(map_quirks["ProtectSecureBoot"].toBool());
ui->chkProtectUefiServices->setChecked(map_quirks["ProtectUefiServices"].toBool());
ui->chkProvideCustomSlide->setChecked(map_quirks["ProvideCustomSlide"].toBool());
ui->editProvideMaxSlide->setText(map_quirks["ProvideMaxSlide"].toString());
ui->chkRebuildAppleMemoryMap->setChecked(map_quirks["RebuildAppleMemoryMap"].toBool());
ui->chkSetupVirtualMap->setChecked(map_quirks["SetupVirtualMap"].toBool());
ui->chkSignalAppleOS->setChecked(map_quirks["SignalAppleOS"].toBool());
ui->chkSyncRuntimePermissions->setChecked(map_quirks["SyncRuntimePermissions"].toBool());
}
void MainWindow::initui_dp()
{
QTableWidgetItem *id0;
//Add
ui->table_dp_add0->setColumnWidth(0,400);
ui->table_dp_add0->setMinimumWidth(400);
id0 = new QTableWidgetItem(tr("PCILists"));
ui->table_dp_add0->setHorizontalHeaderItem(0, id0);
ui->table_dp_add0->setAlternatingRowColors(true);
ui->table_dp_add->setColumnWidth(0,300);
id0 = new QTableWidgetItem(tr("Key"));
ui->table_dp_add->setHorizontalHeaderItem(0, id0);
ui->table_dp_add->setColumnWidth(2,200);
id0 = new QTableWidgetItem(tr("Value"));
ui->table_dp_add->setHorizontalHeaderItem(2, id0);
id0 = new QTableWidgetItem(tr("Class"));
ui->table_dp_add->setHorizontalHeaderItem(1, id0);
ui->table_dp_add->setAlternatingRowColors(true);
//Delete
ui->table_dp_del0->setColumnWidth(0,400);
ui->table_dp_del0->setMinimumWidth(400);
id0 = new QTableWidgetItem(tr("PCILists"));
ui->table_dp_del0->setHorizontalHeaderItem(0, id0);
ui->table_dp_del0->setAlternatingRowColors(true);
ui->table_dp_del->setColumnWidth(0,350);
id0 = new QTableWidgetItem(tr("Value"));
ui->table_dp_del->setHorizontalHeaderItem(0, id0);
ui->table_dp_del->setAlternatingRowColors(true);
}
void MainWindow::ParserDP(QVariantMap map)
{
map = map["DeviceProperties"].toMap();
if(map.isEmpty())
return;
//Add
QVariantMap map_add = map["Add"].toMap();
QVariantMap map_sub;
ui->table_dp_add0->setRowCount(map_add.count());
QTableWidgetItem *newItem1;
for(int i = 0; i < map_add.count(); i ++)
{
newItem1 = new QTableWidgetItem(map_add.keys().at(i));
ui->table_dp_add0->setItem(i, 0, newItem1);
//加载子条目
map_sub = map_add[map_add.keys().at(i)].toMap();
ui->table_dp_add->setRowCount(map_sub.keys().count()); //子键的个数
for(int j = 0; j < map_sub.keys().count(); j++)
{
//QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map_sub.keys().at(j));//键
ui->table_dp_add->setItem(j, 0, newItem1);
QString dtype = map_sub[map_sub.keys().at(j)].typeName();
QString ztype;
if(dtype == "QByteArray")
ztype = "Data";
if(dtype == "QString")
ztype = "String";
if(dtype == "qlonglong")
ztype = "Number";
newItem1 = new QTableWidgetItem(ztype);//数据类型
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_dp_add->setItem(j, 1, newItem1);
QString type_name = map_sub[map_sub.keys().at(j)].typeName();
if( type_name == "QByteArray")
{
QByteArray tohex = map_sub[map_sub.keys().at(j)].toByteArray();
QString va = tohex.toHex().toUpper();
newItem1 = new QTableWidgetItem(va);
}
else
newItem1 = new QTableWidgetItem(map_sub[map_sub.keys().at(j)].toString());
ui->table_dp_add->setItem(j, 2, newItem1);
}
//保存子条目里面的数据,以便以后加载
write_ini("table_dp_add0" , ui->table_dp_add, i);
}
int last = ui->table_dp_add0->rowCount();
ui->table_dp_add0->setCurrentCell(last - 1 , 0);
//Delete
init_value(map["Delete"].toMap() , ui->table_dp_del0 , ui->table_dp_del);
}
void MainWindow::initui_kernel()
{
QTableWidgetItem *id0;
//Add
ui->table_kernel_add->setColumnCount(8);
ui->table_kernel_add->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("BundlePath"));
ui->table_kernel_add->setHorizontalHeaderItem(0, id0);
ui->table_kernel_add->horizontalHeaderItem(0)->setToolTip(strBundlePath);
ui->table_kernel_add->setColumnWidth(1,250);
id0 = new QTableWidgetItem(tr("Comment"));
ui->table_kernel_add->setHorizontalHeaderItem(1, id0);
ui->table_kernel_add->horizontalHeaderItem(1)->setToolTip(strComment);
ui->table_kernel_add->setColumnWidth(2,250);
id0 = new QTableWidgetItem(tr("ExecutablePath"));
ui->table_kernel_add->setHorizontalHeaderItem(2, id0);
ui->table_kernel_add->horizontalHeaderItem(2)->setToolTip(strExecutablePath);
ui->table_kernel_add->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("PlistPath"));
ui->table_kernel_add->setHorizontalHeaderItem(3, id0);
ui->table_kernel_add->horizontalHeaderItem(3)->setToolTip(strPlistPath);
ui->table_kernel_add->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("MinKernel"));
ui->table_kernel_add->setHorizontalHeaderItem(4, id0);
ui->table_kernel_add->horizontalHeaderItem(4)->setToolTip(strMinKernel);
ui->table_kernel_add->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("MaxKernel"));
ui->table_kernel_add->setHorizontalHeaderItem(5, id0);
ui->table_kernel_add->horizontalHeaderItem(5)->setToolTip(strMaxKernel);
ui->table_kernel_add->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("Enabled"));
ui->table_kernel_add->setHorizontalHeaderItem(6, id0);
ui->table_kernel_add->horizontalHeaderItem(6)->setToolTip(strEnabled);
ui->table_kernel_add->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("Arch"));
ui->table_kernel_add->setHorizontalHeaderItem(7, id0);
ui->table_kernel_add->horizontalHeaderItem(7)->setToolTip(strArch);
ui->table_kernel_add->setAlternatingRowColors(true);
//Block
ui->table_kernel_block->setColumnCount(6);
ui->table_kernel_block->setColumnWidth(0,350);
id0 = new QTableWidgetItem(tr("Identifier"));
ui->table_kernel_block->setHorizontalHeaderItem(0, id0);
ui->table_kernel_block->setColumnWidth(1,350);
id0 = new QTableWidgetItem(tr("Comment"));
ui->table_kernel_block->setHorizontalHeaderItem(1, id0);
ui->table_kernel_block->setColumnWidth(2,250);
id0 = new QTableWidgetItem(tr("MinKernel"));
ui->table_kernel_block->setHorizontalHeaderItem(2, id0);
ui->table_kernel_block->setColumnWidth(3,250);
id0 = new QTableWidgetItem(tr("MaxKernel"));
ui->table_kernel_block->setHorizontalHeaderItem(3, id0);
ui->table_kernel_block->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("Enabled"));
ui->table_kernel_block->setHorizontalHeaderItem(4, id0);
id0 = new QTableWidgetItem(tr("Arch"));
ui->table_kernel_block->setHorizontalHeaderItem(5, id0);
ui->table_kernel_block->setAlternatingRowColors(true);
//Force
ui->table_kernel_Force->setColumnCount(9);
ui->table_kernel_Force->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("BundlePath"));
ui->table_kernel_Force->setHorizontalHeaderItem(0, id0);
ui->table_kernel_Force->setColumnWidth(1,250);
id0 = new QTableWidgetItem(tr("Comment"));
ui->table_kernel_Force->setHorizontalHeaderItem(1, id0);
ui->table_kernel_Force->setColumnWidth(2,250);
id0 = new QTableWidgetItem(tr("ExecutablePath"));
ui->table_kernel_Force->setHorizontalHeaderItem(2, id0);
ui->table_kernel_Force->setColumnWidth(3,250);
id0 = new QTableWidgetItem(tr("Identifier"));
ui->table_kernel_Force->setHorizontalHeaderItem(3, id0);
ui->table_kernel_Force->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("PlistPath"));
ui->table_kernel_Force->setHorizontalHeaderItem(4, id0);
ui->table_kernel_Force->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("MinKernel"));
ui->table_kernel_Force->setHorizontalHeaderItem(5, id0);
ui->table_kernel_Force->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("MaxKernel"));
ui->table_kernel_Force->setHorizontalHeaderItem(6, id0);
ui->table_kernel_Force->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("Enabled"));
ui->table_kernel_Force->setHorizontalHeaderItem(7, id0);
ui->table_kernel_Force->setColumnWidth(0,250);
id0 = new QTableWidgetItem(tr("Arch"));
ui->table_kernel_Force->setHorizontalHeaderItem(8, id0);
ui->table_kernel_Force->setAlternatingRowColors(true);
//Patch
ui->table_kernel_patch->setColumnCount(14);
ui->table_kernel_patch->setColumnWidth(0,300);
id0 = new QTableWidgetItem(tr("Identifier"));
ui->table_kernel_patch->setHorizontalHeaderItem(0, id0);
ui->table_kernel_patch->setColumnWidth(0,350);
id0 = new QTableWidgetItem(tr("Base"));
ui->table_kernel_patch->setHorizontalHeaderItem(1, id0);
ui->table_kernel_patch->setColumnWidth(0,350);
id0 = new QTableWidgetItem(tr("Identifier"));
ui->table_kernel_patch->setHorizontalHeaderItem(2, id0);
ui->table_kernel_patch->setColumnWidth(3,300);
id0 = new QTableWidgetItem(tr("Find"));
ui->table_kernel_patch->setHorizontalHeaderItem(3, id0);
ui->table_kernel_patch->setColumnWidth(4,300);
id0 = new QTableWidgetItem(tr("Replace"));
ui->table_kernel_patch->setHorizontalHeaderItem(4, id0);
ui->table_kernel_patch->setColumnWidth(0,350);
id0 = new QTableWidgetItem(tr("Mask"));
ui->table_kernel_patch->setHorizontalHeaderItem(5, id0);
ui->table_kernel_patch->setColumnWidth(0,350);
id0 = new QTableWidgetItem(tr("ReplaceMask"));
ui->table_kernel_patch->setHorizontalHeaderItem(6, id0);
ui->table_kernel_patch->setColumnWidth(0,350);
id0 = new QTableWidgetItem(tr("MinKernel"));
ui->table_kernel_patch->setHorizontalHeaderItem(7, id0);
ui->table_kernel_patch->setColumnWidth(0,350);
id0 = new QTableWidgetItem(tr("MaxKernel"));
ui->table_kernel_patch->setHorizontalHeaderItem(8, id0);
ui->table_kernel_patch->setColumnWidth(0,350);
id0 = new QTableWidgetItem(tr("Count"));
ui->table_kernel_patch->setHorizontalHeaderItem(9, id0);
ui->table_kernel_patch->setColumnWidth(0,350);
id0 = new QTableWidgetItem(tr("Limit"));
ui->table_kernel_patch->setHorizontalHeaderItem(10, id0);
ui->table_kernel_patch->setColumnWidth(0,350);
id0 = new QTableWidgetItem(tr("Skip"));
ui->table_kernel_patch->setHorizontalHeaderItem(11, id0);
ui->table_kernel_patch->setColumnWidth(0,350);
id0 = new QTableWidgetItem(tr("Enabled"));
ui->table_kernel_patch->setHorizontalHeaderItem(12, id0);
id0 = new QTableWidgetItem(tr("Arch"));
ui->table_kernel_patch->setHorizontalHeaderItem(13, id0);
ui->table_kernel_patch->setAlternatingRowColors(true);
//Scheme
ui->cboxKernelArch->addItem("Auto");
ui->cboxKernelArch->addItem("i386");
ui->cboxKernelArch->addItem("i386-user32");
ui->cboxKernelArch->addItem("x86_64");
ui->cboxKernelCache->addItem("Auto");
ui->cboxKernelCache->addItem("Cacheless");
ui->cboxKernelCache->addItem("Mkext");
ui->cboxKernelCache->addItem("Prelinked");
}
void MainWindow::ParserKernel(QVariantMap map)
{
map = map["Kernel"].toMap();
if(map.isEmpty())
return;
//分析"Add"
QVariantList map_add = map["Add"].toList();
ui->table_kernel_add->setRowCount(map_add.count());//设置行的列数
for(int i = 0;i < map_add.count(); i++)
{
QVariantMap map3 = map_add.at(i).toMap();
QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map3["BundlePath"].toString());
ui->table_kernel_add->setItem(i, 0, newItem1);
newItem1 = new QTableWidgetItem(map3["Comment"].toString());
ui->table_kernel_add->setItem(i, 1, newItem1);
newItem1 = new QTableWidgetItem(map3["ExecutablePath"].toString());
ui->table_kernel_add->setItem(i, 2, newItem1);
newItem1 = new QTableWidgetItem(map3["PlistPath"].toString());
ui->table_kernel_add->setItem(i, 3, newItem1);
newItem1 = new QTableWidgetItem(map3["MinKernel"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_add->setItem(i, 4, newItem1);
newItem1 = new QTableWidgetItem(map3["MaxKernel"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_add->setItem(i, 5, newItem1);
init_enabled_data(ui->table_kernel_add , i , 6 , map3["Enabled"].toString());
newItem1 = new QTableWidgetItem(map3["Arch"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_add->setItem(i, 7, newItem1);
}
//Block
QVariantList map_block = map["Block"].toList();
ui->table_kernel_block->setRowCount(map_block.count());//设置行的列数
for(int i = 0;i < map_block.count(); i++)
{
QVariantMap map3 = map_block.at(i).toMap();
QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map3["Identifier"].toString());
ui->table_kernel_block->setItem(i, 0, newItem1);
newItem1 = new QTableWidgetItem(map3["Comment"].toString());
ui->table_kernel_block->setItem(i, 1, newItem1);
newItem1 = new QTableWidgetItem(map3["MinKernel"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_block->setItem(i, 2, newItem1);
newItem1 = new QTableWidgetItem(map3["MaxKernel"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_block->setItem(i, 3, newItem1);
init_enabled_data(ui->table_kernel_block , i , 4 , map3["Enabled"].toString());
newItem1 = new QTableWidgetItem(map3["Arch"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_block->setItem(i, 5, newItem1);
}
//分析"Force"
QVariantList map_Force = map["Force"].toList();
ui->table_kernel_Force->setRowCount(map_Force.count());//设置行的列数
for(int i = 0;i < map_Force.count(); i++)
{
QVariantMap map3 = map_Force.at(i).toMap();
QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map3["BundlePath"].toString());
ui->table_kernel_Force->setItem(i, 0, newItem1);
newItem1 = new QTableWidgetItem(map3["Comment"].toString());
ui->table_kernel_Force->setItem(i, 1, newItem1);
newItem1 = new QTableWidgetItem(map3["ExecutablePath"].toString());
ui->table_kernel_Force->setItem(i, 2, newItem1);
newItem1 = new QTableWidgetItem(map3["Identifier"].toString());
ui->table_kernel_Force->setItem(i, 3, newItem1);
newItem1 = new QTableWidgetItem(map3["PlistPath"].toString());
ui->table_kernel_Force->setItem(i, 4, newItem1);
newItem1 = new QTableWidgetItem(map3["MinKernel"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_Force->setItem(i, 5, newItem1);
newItem1 = new QTableWidgetItem(map3["MaxKernel"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_Force->setItem(i, 6, newItem1);
init_enabled_data(ui->table_kernel_Force , i , 7 , map3["Enabled"].toString());
newItem1 = new QTableWidgetItem(map3["Arch"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_Force->setItem(i, 8, newItem1);
}
//Patch
QVariantList map_patch = map["Patch"].toList();
ui->table_kernel_patch->setRowCount(map_patch.count());//设置行的列数
for(int i = 0;i < map_patch.count(); i++)
{
QVariantMap map3 = map_patch.at(i).toMap();
QByteArray ba = map3["Find"].toByteArray();
QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map3["Identifier"].toString());
ui->table_kernel_patch->setItem(i, 0, newItem1);
newItem1 = new QTableWidgetItem(map3["Base"].toString());
ui->table_kernel_patch->setItem(i, 1, newItem1);
newItem1 = new QTableWidgetItem(map3["Comment"].toString());
ui->table_kernel_patch->setItem(i, 2, newItem1);
//此时需要将ASCII转换成HEX
QByteArray tohex = map3["Find"].toByteArray();
QString va = tohex.toHex().toUpper();
newItem1 = new QTableWidgetItem(va);
ui->table_kernel_patch->setItem(i, 3, newItem1);
tohex = map3["Replace"].toByteArray();
va = tohex.toHex().toUpper();
newItem1 = new QTableWidgetItem(va);
ui->table_kernel_patch->setItem(i, 4, newItem1);
tohex = map3["Mask"].toByteArray();
va = tohex.toHex().toUpper();
newItem1 = new QTableWidgetItem(va);
ui->table_kernel_patch->setItem(i, 5, newItem1);
tohex = map3["ReplaceMask"].toByteArray();
va = tohex.toHex().toUpper();
newItem1 = new QTableWidgetItem(va);
ui->table_kernel_patch->setItem(i, 6, newItem1);
newItem1 = new QTableWidgetItem(map3["MinKernel"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_patch->setItem(i, 7, newItem1);
newItem1 = new QTableWidgetItem(map3["MaxKernel"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_patch->setItem(i, 8, newItem1);
newItem1 = new QTableWidgetItem(map3["Count"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_patch->setItem(i, 9, newItem1);
newItem1 = new QTableWidgetItem(map3["Limit"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_patch->setItem(i, 10, newItem1);
newItem1 = new QTableWidgetItem(map3["Skip"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_patch->setItem(i, 11, newItem1);
init_enabled_data(ui->table_kernel_patch , i , 12 , map3["Enabled"].toString());
newItem1 = new QTableWidgetItem(map3["Arch"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_patch->setItem(i, 13, newItem1);
}
//Emulate
QVariantMap map_Emulate = map["Emulate"].toMap();
ui->editCpuid1Data->setText(ByteToHexStr(map_Emulate["Cpuid1Data"].toByteArray()));
ui->editCpuid1Mask->setText(ByteToHexStr(map_Emulate["Cpuid1Mask"].toByteArray()));
ui->chkDummyPowerManagement->setChecked(map_Emulate["DummyPowerManagement"].toBool());
ui->editMaxKernel->setText(map_Emulate["MaxKernel"].toString());
ui->editMinKernel->setText(map_Emulate["MinKernel"].toString());
//Quirks
QVariantMap map_quirks = map["Quirks"].toMap();
ui->chkAppleCpuPmCfgLock->setChecked(map_quirks["AppleCpuPmCfgLock"].toBool());
ui->chkAppleXcpmCfgLock->setChecked(map_quirks["AppleXcpmCfgLock"].toBool());
ui->chkAppleXcpmExtraMsrs->setChecked(map_quirks["AppleXcpmExtraMsrs"].toBool());
ui->chkAppleXcpmForceBoost->setChecked(map_quirks["AppleXcpmForceBoost"].toBool());
ui->chkCustomSMBIOSGuid->setChecked(map_quirks["CustomSMBIOSGuid"].toBool());
ui->chkDisableIoMapper->setChecked(map_quirks["DisableIoMapper"].toBool());
ui->chkDisableRtcChecksum->setChecked(map_quirks["DisableRtcChecksum"].toBool());
ui->chkExternalDiskIcons->setChecked(map_quirks["ExternalDiskIcons"].toBool());
ui->chkIncreasePciBarSize->setChecked(map_quirks["IncreasePciBarSize"].toBool());
ui->chkLapicKernelPanic->setChecked(map_quirks["LapicKernelPanic"].toBool());
ui->chkPanicNoKextDump->setChecked(map_quirks["PanicNoKextDump"].toBool());
ui->chkPowerTimeoutKernelPanic->setChecked(map_quirks["PowerTimeoutKernelPanic"].toBool());
ui->chkThirdPartyDrives->setChecked(map_quirks["ThirdPartyDrives"].toBool());
ui->chkXhciPortLimit->setChecked(map_quirks["XhciPortLimit"].toBool());
ui->chkDisableLinkeditJettison->setChecked(map_quirks["DisableLinkeditJettison"].toBool());
ui->chkExtendBTFeatureFlags->setChecked(map_quirks["ExtendBTFeatureFlags"].toBool());
ui->chkLegacyCommpage->setChecked(map_quirks["LegacyCommpage"].toBool());
//Scheme
QVariantMap map_Scheme = map["Scheme"].toMap();
ui->chkFuzzyMatch->setChecked(map_Scheme["FuzzyMatch"].toBool());
QString hm = map_Scheme["KernelArch"].toString();
/*if(hm.trimmed() == "Auto")
ui->cboxKernelArch->setCurrentIndex(0);
if(hm.trimmed() == "i386")
ui->cboxKernelArch->setCurrentIndex(1);
if(hm.trimmed() == "x86_64")
ui->cboxKernelArch->setCurrentIndex(2);*/
ui->cboxKernelArch->setCurrentText(hm.trimmed());
hm = map_Scheme["KernelCache"].toString();
if(hm.trimmed() == "Auto")
ui->cboxKernelCache->setCurrentIndex(0);
if(hm.trimmed() == "Cacheless")
ui->cboxKernelCache->setCurrentIndex(1);
if(hm.trimmed() == "Mkext")
ui->cboxKernelCache->setCurrentIndex(2);
if(hm.trimmed() == "Prelinked")
ui->cboxKernelCache->setCurrentIndex(3);
}
void MainWindow::initui_misc()
{
//Boot
ui->cboxHibernateMode->addItem("None");
ui->cboxHibernateMode->addItem("Auto");
ui->cboxHibernateMode->addItem("RTC");
ui->cboxHibernateMode->addItem("NVRAM");
ui->cboxPickerMode->addItem("Builtin");
ui->cboxPickerMode->addItem("External");
ui->cboxPickerMode->addItem("Apple");
//Security
ui->cboxBootProtect->addItem("None");
ui->cboxBootProtect->addItem("Bootstrap");
ui->cboxDmgLoading->addItem("Disabled");
ui->cboxDmgLoading->addItem("Signed");
ui->cboxDmgLoading->addItem("Any");
ui->cboxVault->addItem("Optional");
ui->cboxVault->addItem("Basic");
ui->cboxVault->addItem("Secure");
ui->cboxSecureBootModel->setEditable(true);
ui->cboxSecureBootModel->addItem("Disabled");
ui->cboxSecureBootModel->addItem("Default");
//BlessOverride
QTableWidgetItem *id0;
ui->tableBlessOverride->setColumnWidth(0,1150);
id0 = new QTableWidgetItem(tr("BlessOverride"));
ui->tableBlessOverride->setHorizontalHeaderItem(0, id0);
ui->tableBlessOverride->setAlternatingRowColors(true);
//Entries
ui->tableEntries->setColumnWidth(0,550);
id0 = new QTableWidgetItem(tr("Path"));
ui->tableEntries->setHorizontalHeaderItem(0, id0);
id0 = new QTableWidgetItem(tr("Arguments"));
ui->tableEntries->setHorizontalHeaderItem(1, id0);
id0 = new QTableWidgetItem(tr("Name"));
ui->tableEntries->setHorizontalHeaderItem(2, id0);
ui->tableEntries->setColumnWidth(3,250);
id0 = new QTableWidgetItem(tr("Comment"));
ui->tableEntries->setHorizontalHeaderItem(3, id0);
id0 = new QTableWidgetItem(tr("Auxiliary"));
ui->tableEntries->setHorizontalHeaderItem(4, id0);
id0 = new QTableWidgetItem(tr("Enabled"));
ui->tableEntries->setHorizontalHeaderItem(5, id0);
ui->tableEntries->setAlternatingRowColors(true);
//Tools
ui->tableTools->setColumnWidth(0 , 450);
id0 = new QTableWidgetItem(tr("Path"));
ui->tableTools->setHorizontalHeaderItem(0, id0);
id0 = new QTableWidgetItem(tr("Arguments"));
ui->tableTools->setHorizontalHeaderItem(1, id0);
id0 = new QTableWidgetItem(tr("Name"));
ui->tableTools->setHorizontalHeaderItem(2, id0);
ui->tableTools->setColumnWidth(3,250);
id0 = new QTableWidgetItem(tr("Comment"));
ui->tableTools->setHorizontalHeaderItem(3, id0);
id0 = new QTableWidgetItem(tr("Auxiliary"));
ui->tableTools->setHorizontalHeaderItem(4, id0);
id0 = new QTableWidgetItem(tr("Enabled"));
ui->tableTools->setHorizontalHeaderItem(5, id0);
ui->tableTools->setAlternatingRowColors(true);
}
void MainWindow::ParserMisc(QVariantMap map)
{
map = map["Misc"].toMap();
if(map.isEmpty())
return;
//分析"Boot"
QVariantMap map_boot = map["Boot"].toMap();
ui->editConsoleAttributes->setText(map_boot["ConsoleAttributes"].toString());
QString hm = map_boot["HibernateMode"].toString();
if(hm.trimmed() == "None")
ui->cboxHibernateMode->setCurrentIndex(0);
if(hm.trimmed() == "Auto")
ui->cboxHibernateMode->setCurrentIndex(1);
if(hm.trimmed() == "RTC")
ui->cboxHibernateMode->setCurrentIndex(2);
if(hm.trimmed() == "NVRAM")
ui->cboxHibernateMode->setCurrentIndex(3);
ui->chkHideAuxiliary->setChecked(map_boot["HideAuxiliary"].toBool());
ui->editPickerAttributes->setText(map_boot["PickerAttributes"].toString());
ui->chkPickerAudioAssist->setChecked(map_boot["PickerAudioAssist"].toBool());
hm = map_boot["PickerMode"].toString();
if(hm.trimmed() == "Builtin")
ui->cboxPickerMode->setCurrentIndex(0);
if(hm.trimmed() == "External")
ui->cboxPickerMode->setCurrentIndex(1);
if(hm.trimmed() == "Apple")
ui->cboxPickerMode->setCurrentIndex(2);
ui->chkPollAppleHotKeys->setChecked(map_boot["PollAppleHotKeys"].toBool());
ui->chkShowPicker->setChecked(map_boot["ShowPicker"].toBool());
ui->editTakeoffDelay->setText(map_boot["TakeoffDelay"].toString());
ui->editTimeout->setText(map_boot["Timeout"].toString());
//Debug
QVariantMap map_debug = map["Debug"].toMap();
ui->chkAppleDebug->setChecked(map_debug["AppleDebug"].toBool());
ui->chkApplePanic->setChecked(map_debug["ApplePanic"].toBool());
ui->chkDisableWatchDog->setChecked(map_debug["DisableWatchDog"].toBool());
ui->editDisplayDelay->setText(map_debug["DisplayDelay"].toString());
ui->editDisplayLevel->setText(map_debug["DisplayLevel"].toString());
ui->chkSerialInit->setChecked(map_debug["SerialInit"].toBool());
ui->chkSysReport->setChecked(map_debug["SysReport"].toBool());
ui->editTarget->setText(map_debug["Target"].toString());
//Security
QVariantMap map_security = map["Security"].toMap();
ui->chkAllowNvramReset->setChecked(map_security["AllowNvramReset"].toBool());
ui->chkAllowSetDefault->setChecked(map_security["AllowSetDefault"].toBool());
ui->chkAuthRestart->setChecked(map_security["AuthRestart"].toBool());
hm = map_security["BootProtect"].toString();
if(hm.trimmed() == "None")
ui->cboxBootProtect->setCurrentIndex(0);
if(hm.trimmed() == "Bootstrap")
ui->cboxBootProtect->setCurrentIndex(1);
ui->editExposeSensitiveData->setText(map_security["ExposeSensitiveData"].toString());
ui->editHaltLevel->setText(map_security["HaltLevel"].toString());
ui->editScanPolicy->setText(map_security["ScanPolicy"].toString());
hm = map_security["Vault"].toString();
if(hm.trimmed() == "Optional")
ui->cboxVault->setCurrentIndex(0);
if(hm.trimmed() == "Basic")
ui->cboxVault->setCurrentIndex(1);
if(hm.trimmed() == "Secure")
ui->cboxVault->setCurrentIndex(2);
hm = map_security["DmgLoading"].toString();
if(hm.trimmed() == "Disabled")
ui->cboxDmgLoading->setCurrentIndex(0);
if(hm.trimmed() == "Signed")
ui->cboxDmgLoading->setCurrentIndex(1);
if(hm.trimmed() == "Any")
ui->cboxDmgLoading->setCurrentIndex(2);
ui->editApECID->setText(map_security["ApECID"].toString());
hm = map_security["SecureBootModel"].toString().trimmed();
if(hm == "")
hm = "Disabled";
ui->cboxSecureBootModel->setCurrentText(hm);
ui->chkEnablePassword->setChecked(map_security["EnablePassword"].toBool());
ui->editPasswordHash->setText(ByteToHexStr(map_security["PasswordHash"].toByteArray()));
ui->editPasswordSalt->setText(ByteToHexStr(map_security["PasswordSalt"].toByteArray()));
//BlessOverride(数组)
QVariantList map_BlessOverride = map["BlessOverride"].toList();
ui->tableBlessOverride->setRowCount(map_BlessOverride.count());//设置行的列数
for(int i = 0;i < map_BlessOverride.count(); i++)
{
QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map_BlessOverride.at(i).toString());
ui->tableBlessOverride->setItem(i, 0, newItem1);
}
//Entries
QVariantList map_Entries = map["Entries"].toList();
ui->tableEntries->setRowCount(map_Entries.count());//设置行的列数
for(int i = 0;i < map_Entries.count(); i++)
{
QVariantMap map3 = map_Entries.at(i).toMap();
QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map3["Path"].toString());
ui->tableEntries->setItem(i, 0, newItem1);
newItem1 = new QTableWidgetItem(map3["Arguments"].toString());
ui->tableEntries->setItem(i, 1, newItem1);
newItem1 = new QTableWidgetItem(map3["Name"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->tableEntries->setItem(i, 2, newItem1);
newItem1 = new QTableWidgetItem(map3["Comment"].toString());
ui->tableEntries->setItem(i, 3, newItem1);
init_enabled_data(ui->tableEntries , i , 4 , map3["Auxiliary"].toString());
init_enabled_data(ui->tableEntries , i , 5 , map3["Enabled"].toString());
}
//Tools
QVariantList map_Tools = map["Tools"].toList();
ui->tableTools->setRowCount(map_Tools.count());//设置行的列数
for(int i = 0;i < map_Tools.count(); i++)
{
QVariantMap map3 = map_Tools.at(i).toMap();
QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map3["Path"].toString());
ui->tableTools->setItem(i, 0, newItem1);
newItem1 = new QTableWidgetItem(map3["Arguments"].toString());
ui->tableTools->setItem(i, 1, newItem1);
newItem1 = new QTableWidgetItem(map3["Name"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->tableTools->setItem(i, 2, newItem1);
newItem1 = new QTableWidgetItem(map3["Comment"].toString());
ui->tableTools->setItem(i, 3, newItem1);
init_enabled_data(ui->tableTools , i , 4 , map3["Auxiliary"].toString());
init_enabled_data(ui->tableTools , i , 5 , map3["Enabled"].toString());
}
}
void MainWindow::initui_nvram()
{
QTableWidgetItem *id0;
//Add
ui->table_nv_add0->setColumnWidth(0,500);
ui->table_nv_add0->setMinimumWidth(300);
ui->table_nv_add0->setMaximumWidth(500);
id0 = new QTableWidgetItem(tr("UUID"));
ui->table_nv_add0->setHorizontalHeaderItem(0, id0);
ui->table_nv_add0->setAlternatingRowColors(true);
ui->table_nv_add->setColumnWidth(0,200);
id0 = new QTableWidgetItem(tr("Key"));
ui->table_nv_add->setHorizontalHeaderItem(0, id0);
ui->table_nv_add->setColumnWidth(2,350);
id0 = new QTableWidgetItem(tr("Value"));
ui->table_nv_add->setHorizontalHeaderItem(2, id0);
id0 = new QTableWidgetItem(tr("Class"));
ui->table_nv_add->setHorizontalHeaderItem(1, id0);
ui->table_nv_add->setAlternatingRowColors(true);
//Delete
ui->table_nv_del0->setColumnWidth(0,600);
id0 = new QTableWidgetItem(tr("UUID"));
ui->table_nv_del0->setHorizontalHeaderItem(0, id0);
ui->table_nv_del0->setAlternatingRowColors(true);
ui->table_nv_del->setColumnWidth(0,600);
id0 = new QTableWidgetItem(tr("Value"));
ui->table_nv_del->setHorizontalHeaderItem(0, id0);
ui->table_nv_del->setAlternatingRowColors(true);
//LegacySchema
ui->table_nv_ls0->setColumnWidth(0,600);
id0 = new QTableWidgetItem(tr("UUID"));
ui->table_nv_ls0->setHorizontalHeaderItem(0, id0);
ui->table_nv_ls0->setAlternatingRowColors(true);
ui->table_nv_ls->setColumnWidth(0,600);
id0 = new QTableWidgetItem(tr("Value"));
ui->table_nv_ls->setHorizontalHeaderItem(0, id0);
ui->table_nv_ls->setAlternatingRowColors(true);
QSplitter *splitterMain = new QSplitter(Qt::Horizontal,this);
splitterMain->addWidget(ui->table_nv_add0);
splitterMain->addWidget(ui->table_nv_add);
ui->gridLayout_nv_add->addWidget(splitterMain);
}
void MainWindow::ParserNvram(QVariantMap map)
{
map = map["NVRAM"].toMap();
if(map.isEmpty())
return;
//Add
QVariantMap map_add = map["Add"].toMap();
QVariantMap map_sub;
ui->table_nv_add0->setRowCount(map_add.count());
QTableWidgetItem *newItem1;
for(int i = 0; i < map_add.count(); i ++)
{
newItem1 = new QTableWidgetItem(map_add.keys().at(i));
ui->table_nv_add0->setItem(i, 0, newItem1);
//加载子条目
map_sub = map_add[map_add.keys().at(i)].toMap();
ui->table_nv_add->setRowCount(map_sub.keys().count()); //子键的个数
for(int j = 0; j < map_sub.keys().count(); j++)
{
//QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map_sub.keys().at(j));//键
ui->table_nv_add->setItem(j, 0, newItem1);
QString dtype = map_sub[map_sub.keys().at(j)].typeName();
QString ztype;
if(dtype == "QByteArray")
ztype = "Data";
if(dtype == "QString")
ztype = "String";
if(dtype == "qlonglong")
ztype = "Number";
newItem1 = new QTableWidgetItem(ztype);//数据类型
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_nv_add->setItem(j, 1, newItem1);
QString type_name = map_sub[map_sub.keys().at(j)].typeName();
if( type_name == "QByteArray")
{
QByteArray tohex = map_sub[map_sub.keys().at(j)].toByteArray();
QString va = tohex.toHex().toUpper();
newItem1 = new QTableWidgetItem(va);
}
else
newItem1 = new QTableWidgetItem(map_sub[map_sub.keys().at(j)].toString());
ui->table_nv_add->setItem(j, 2, newItem1);
}
//保存子条目里面的数据,以便以后加载
write_ini("table_nv_add0" , ui->table_nv_add, i);
}
int last = ui->table_nv_add0->rowCount();
ui->table_nv_add0->setCurrentCell(last - 1 , 0);
//Delete
init_value(map["Delete"].toMap() , ui->table_nv_del0 , ui->table_nv_del);
//LegacySchema
init_value(map["LegacySchema"].toMap() , ui->table_nv_ls0 , ui->table_nv_ls);
//分析Quirks
ui->chkLegacyEnable->setChecked(map["LegacyEnable"].toBool());
ui->chkLegacyOverwrite->setChecked(map["LegacyOverwrite"].toBool());
ui->chkWriteFlash->setChecked(map["WriteFlash"].toBool());
}
void MainWindow::write_ini(QString table_name , QTableWidget *mytable, int i)
{
QString plistPath = QDir::homePath() + "/" + table_name + QString::number(i + 1) + ".ini";
//qDebug() << plistPath;
QFile file(plistPath);
if(file.exists()) //如果文件存在,则先删除它
file.remove();
//QSettings Reg(plistPath, QSettings::NativeFormat);
QSettings Reg(plistPath, QSettings::IniFormat);//全平台都采用ini格式
for(int k = 0; k < mytable->rowCount(); k++)
{
Reg.setValue(QString::number(k + 1) + "/key", mytable->item(k , 0)->text());
Reg.setValue(QString::number(k + 1) + "/class", mytable->item(k , 1)->text());
Reg.setValue(QString::number(k + 1) + "/value", mytable->item(k , 2)->text());
}
//记录总数
Reg.setValue("total" , mytable->rowCount());
IniFile.push_back(plistPath);
}
void MainWindow::read_ini(QString table_name , QTableWidget *mytable , int i)
{
QString plistPath = QDir::homePath() + "/" + table_name + QString::number(i + 1) + ".ini";
//qDebug() << plistPath;
QFile file(plistPath);
if(file.exists())
{
QSettings Reg(plistPath, QSettings::IniFormat);
int count = Reg.value("total").toInt();
mytable->setRowCount(count);
QTableWidgetItem *newItem1;
for(int k = 0; k < count; k++)
{
newItem1 = new QTableWidgetItem(Reg.value(QString::number(k + 1) + "/key").toString());
mytable->setItem(k, 0, newItem1);
newItem1 = new QTableWidgetItem(Reg.value(QString::number(k + 1) + "/class").toString());
newItem1->setTextAlignment(Qt::AlignCenter);
mytable->setItem(k, 1, newItem1);
newItem1 = new QTableWidgetItem(Reg.value(QString::number(k + 1) + "/value").toString());
mytable->setItem(k, 2, newItem1);
}
}
}
void MainWindow::read_value_ini(QString table_name , QTableWidget *mytable , int i)
{
QString plistPath = QDir::homePath() + "/" + table_name + QString::number(i + 1) + ".ini";
//qDebug() << plistPath;
QFile file(plistPath);
if(file.exists())
{
QSettings Reg(plistPath, QSettings::IniFormat);
int count = Reg.value("total").toInt();
mytable->setRowCount(count);
QTableWidgetItem *newItem1;
for(int k = 0; k < count; k++)
{
newItem1 = new QTableWidgetItem(Reg.value(QString::number(k + 1) + "/key").toString());
mytable->setItem(k, 0, newItem1);
}
}
}
void MainWindow::on_table_dp_add0_cellClicked(int row, int column)
{
//读取ini数据并加载到table_dp_add中
//qDebug() << row;
loading = true;
if(column == 0)
read_ini("table_dp_add0" , ui->table_dp_add , row);
loading = false;
}
void MainWindow::on_table_dp_add_itemSelectionChanged()
{
}
void MainWindow::on_table_dp_add_itemChanged(QTableWidgetItem *item)
{
if(item->text().isEmpty())
{
}
//当条目有修改时,重新写入数据
if(!loading) //数据已经加载完成后
write_ini("table_dp_add0" , ui->table_dp_add, ui->table_dp_add0->currentRow());
}
void MainWindow::on_table_nv_add0_cellClicked(int row, int column)
{
loading = true;
if(column == 0)
read_ini("table_nv_add0" , ui->table_nv_add , row);
loading = false;
}
void MainWindow::on_table_nv_add_itemChanged(QTableWidgetItem *item)
{
if(item->text().isEmpty())
{
}
//当条目有修改时,重新写入数据
if(!loading) //数据已经加载完成后
write_ini("table_nv_add0" , ui->table_nv_add, ui->table_nv_add0->currentRow());
}
void MainWindow::init_value(QVariantMap map_fun , QTableWidget *table, QTableWidget *subtable)
{
//QVariantMap map_del = map["Delete"].toMap();
table->setRowCount(map_fun.count());
subtable->setRowCount(0);//归零,清除之前的残留
QTableWidgetItem *newItem1;
for(int i = 0; i < map_fun.count(); i ++)
{
newItem1 = new QTableWidgetItem(map_fun.keys().at(i));
table->setItem(i, 0, newItem1);
//加载子条目
QVariantList map_sub_list = map_fun[map_fun.keys().at(i)].toList(); //是个数组
subtable->setRowCount(map_sub_list.count()); //子键的个数
//qDebug() << map_sub_list.count();
for(int j = 0; j < map_sub_list.count(); j++)
{
//qDebug() << map_sub_list.at(j).toString();
newItem1 = new QTableWidgetItem(map_sub_list.at(j).toString());//键
subtable->setItem(j, 0, newItem1);
}
//保存子条目里面的数据,以便以后加载
write_value_ini(table->objectName() , subtable , i);
}
int last = table->rowCount();
table->setCurrentCell(last - 1 , 0);
}
void MainWindow::write_value_ini(QString tablename , QTableWidget *subtable , int i)
{
QString plistPath = QDir::homePath() + "/" + tablename + QString::number(i + 1) + ".ini";
//qDebug() << plistPath;
QFile file(plistPath);
if(file.exists()) //如果文件存在,则先删除它
file.remove();
//QSettings Reg(plistPath, QSettings::NativeFormat);
QSettings Reg(plistPath, QSettings::IniFormat);//全平台都采用ini格式
for(int k = 0; k < subtable->rowCount(); k++)
{
Reg.setValue(QString::number(k + 1) + "/key", subtable->item(k , 0)->text());
}
//记录总数
Reg.setValue("total" , subtable->rowCount());
IniFile.push_back(plistPath);
}
void MainWindow::on_table_nv_del0_cellClicked(int row, int column)
{
loading = true;
if(column == 0)
read_value_ini(ui->table_nv_del0->objectName() , ui->table_nv_del , row);
loading = false;
}
void MainWindow::on_table_nv_ls0_cellClicked(int row, int column)
{
loading = true;
if(column == 0)
read_value_ini(ui->table_nv_ls0->objectName() , ui->table_nv_ls , row);
loading = false;
}
void MainWindow::on_table_nv_del_itemChanged(QTableWidgetItem *item)
{
if(item->text().isEmpty())
{
}
if(!loading)
write_value_ini(ui->table_nv_del0->objectName() , ui->table_nv_del , ui->table_nv_del0->currentRow());
}
void MainWindow::on_table_nv_ls_itemChanged(QTableWidgetItem *item)
{
if(item->text().isEmpty())
{
}
if(!loading)
write_value_ini(ui->table_nv_ls0->objectName() , ui->table_nv_ls , ui->table_nv_ls0->currentRow());
}
void MainWindow::on_table_dp_del0_cellClicked(int row, int column)
{
loading = true;
if(column == 0)
read_value_ini(ui->table_dp_del0->objectName() , ui->table_dp_del , row);
loading = false;
}
void MainWindow::on_table_dp_del_itemChanged(QTableWidgetItem *item)
{
if(item->text().isEmpty())
{
}
if(!loading)
write_value_ini(ui->table_dp_del0->objectName() , ui->table_dp_del , ui->table_dp_del0->currentRow());
}
void MainWindow::initui_PlatformInfo()
{
ui->cboxUpdateSMBIOSMode->addItem("TryOverwrite");
ui->cboxUpdateSMBIOSMode->addItem("Create");
ui->cboxUpdateSMBIOSMode->addItem("Overwrite");
ui->cboxUpdateSMBIOSMode->addItem("Custom");
ui->cboxSystemMemoryStatus->addItem("");
ui->cboxSystemMemoryStatus->addItem("Auto");
ui->cboxSystemMemoryStatus->addItem("Upgradable");
ui->cboxSystemMemoryStatus->addItem("Soldered");
//Memory-Devices
QTableWidgetItem *id0;
ui->tableDevices->setColumnWidth(0,150);
id0 = new QTableWidgetItem(tr("AssetTag"));
ui->tableDevices->setHorizontalHeaderItem(0, id0);
id0 = new QTableWidgetItem(tr("BankLocator"));
ui->tableDevices->setHorizontalHeaderItem(1, id0);
ui->tableDevices->setColumnWidth(2,200);
id0 = new QTableWidgetItem(tr("DeviceLocator"));
ui->tableDevices->setHorizontalHeaderItem(2, id0);
id0 = new QTableWidgetItem(tr("Manufacturer"));
ui->tableDevices->setHorizontalHeaderItem(3, id0);
id0 = new QTableWidgetItem(tr("PartNumber"));
ui->tableDevices->setHorizontalHeaderItem(4, id0);
ui->tableDevices->setColumnWidth(5,200);
id0 = new QTableWidgetItem(tr("SerialNumber"));
ui->tableDevices->setHorizontalHeaderItem(5, id0);
id0 = new QTableWidgetItem(tr("Size"));
ui->tableDevices->setHorizontalHeaderItem(6, id0);
id0 = new QTableWidgetItem(tr("Speed"));
ui->tableDevices->setHorizontalHeaderItem(7, id0);
ui->tableDevices->setAlternatingRowColors(true);//底色交替显示
//ui->cboxSystemProductName->setEditable(true);
QStringList pi;
pi.push_back("");
pi.push_back("MacPro1,1 Intel Core Xeon 5130 x2 @ 2.00 GHz");
pi.push_back("MacPro2,1 Intel Xeon X5365 x2 @ 3.00 GHz");
pi.push_back("MacPro3,1 Intel Xeon E5462 x2 @ 2.80 GHz");
pi.push_back("MacPro4,1 Intel Xeon W3520 @ 2.66 GHz");
pi.push_back("MacPro5,1 Intel Xeon W3530 @ 2.80 GHz");
pi.push_back("MacPro6,1 Intel Xeon E5-1620 v2 @ 3.70 GHz");
pi.push_back("MacPro7,1 Intel Xeon W-3245M CPU @ 3.20 GHz");
pi.push_back("MacBook1,1 Intel Core Duo T2400 @ 1.83 GHz");
pi.push_back("MacBook2,1 Intel Core 2 Duo T5600 @ 1.83 GHz");
pi.push_back("MacBook3,1 Intel Core 2 Duo T7500 @ 2.20 GHz");
pi.push_back("MacBook4,1 Intel Core 2 Duo T8300 @ 2.40 GHz");
pi.push_back("MacBook5,1 Intel Core 2 Duo P8600 @ 2.40 GHz");
pi.push_back("MacBook5,2 Intel Core 2 Duo P7450 @ 2.13 GHz");
pi.push_back("MacBook6,1 Intel Core 2 Duo P7550 @ 2.26 GHz");
pi.push_back("MacBook7,1 Intel Core 2 Duo P8600 @ 2.40 GHz");
pi.push_back("MacBook8,1 Intel Core M 5Y51 @ 1.10 GHz");
pi.push_back("MacBook9,1 Intel Core m3-6Y30 @ 1.10 GHz");
pi.push_back("MacBook10,1 Intel Core m3-7Y32 @ 1.10 GHz");
pi.push_back("MacBookAir1,1 Intel Core 2 Duo P7500 @ 1.60 GHz");
pi.push_back("MacBookAir2,1 Intel Core 2 Duo SL9600 @ 2.13 GHz");
pi.push_back("MacBookAir3,1 Intel Core 2 Duo SU9400 @ 1.40 GHz");
pi.push_back("MacBookAir3,2 Intel Core 2 Duo SL9400 @ 1.86 GHz");
pi.push_back("MacBookAir4,1 Intel Core i5-2467M @ 1.60 GHz");
pi.push_back("MacBookAir4,2 Intel Core i5-2557M @ 1.70 GHz");
pi.push_back("MacBookAir5,1 Intel Core i5-3317U @ 1.70 GHz");
pi.push_back("MacBookAir5,2 Intel Core i5-3317U @ 1.70GHz");
pi.push_back("MacBookAir6,1 Intel Core i5-4250U @ 1.30 GHz");
pi.push_back("MacBookAir6,2 Intel Core i5-4250U @ 1.30 GHz");
pi.push_back("MacBookAir7,1 Intel Core i5-5250U @ 1.60 GHz");
pi.push_back("MacBookAir7,2 Intel Core i5-5250U @ 1.60 GHz");
pi.push_back("MacBookAir8,1 Intel Core i5-8210Y @ 1.60 GHz");
pi.push_back("MacBookAir8,2 Intel Core i5-8210Y @ 1.60 GHz");
pi.push_back("MacBookAir9,1 Intel Core i3-1000NG4 @ 1.10 GHz");
pi.push_back("MacBookPro1,1 Intel Core Duo L2400 @ 1.66 GHz");
pi.push_back("MacBookPro1,2 Intel Core Duo T2600 @ 2.16 GHz");
pi.push_back("MacBookPro2,1 Intel Core 2 Duo T7600 @ 2.33 GHz");
pi.push_back("MacBookPro2,2 Intel Core 2 Duo T7400 @ 2.16 GHz");
pi.push_back("MacBookPro3,1 Intel Core 2 Duo T7700 @ 2.40 GHz");
pi.push_back("MacBookPro4,1 Intel Core 2 Duo T8300 @ 2.40 GHz");
pi.push_back("MacBookPro5,1 Intel Core 2 Duo P8600 @ 2.40 GHz");
pi.push_back("MacBookPro5,2 Intel Core 2 Duo T9600 @ 2.80 GHz");
pi.push_back("MacBookPro5,3 Intel Core 2 Duo P8800 @ 2.66 GHz");
pi.push_back("MacBookPro5,4 Intel Core 2 Duo P8700 @ 2.53 GHz");
pi.push_back("MacBookPro5,5 Intel Core 2 Duo P7550 @ 2.26 GHz");
pi.push_back("MacBookPro6,1 Intel Core i5-540M @ 2.53 GHz");
pi.push_back("MacBookPro6,2 Intel Core i5-520M @ 2.40 GHz");
pi.push_back("MacBookPro7,1 Intel Core 2 Duo P8600 @ 2.40 GHz");
pi.push_back("MacBookPro8,1 Intel Core i5-2415M @ 2.30 GHz");
pi.push_back("MacBookPro8,2 Intel Core i7-2675QM @ 2.20 GHz");
pi.push_back("MacBookPro8,3 Intel Core i7-2820QM @ 2.30 GHz");
pi.push_back("MacBookPro9,1 Intel Core i7-3615QM @ 2.30 GHz");
pi.push_back("MacBookPro9,2 Intel Core i5-3210M @ 2.50 GHz");
pi.push_back("MacBookPro10,1 Intel Core i7-3615QM @ 2.30 GHz");
pi.push_back("MacBookPro10,2 Intel Core i5-3210M @ 2.50 GHz");
pi.push_back("MacBookPro11,1 Intel Core i5-4258U @ 2.40 GHz");
pi.push_back("MacBookPro11,2 Intel Core i7-4770HQ @ 2.20 GHz");
pi.push_back("MacBookPro11,3 Intel Core i7-4850HQ @ 2.30 GHz");
pi.push_back("MacBookPro11,4 Intel Core i7-4770HQ @ 2.20 GHz");
pi.push_back("MacBookPro11,5 Intel Core i7-4870HQ @ 2.50 GHz");
pi.push_back("MacBookPro12,1 Intel Core i5-5257U @ 2.70 GHz");
pi.push_back("MacBookPro13,1 Intel Core i5-6360U @ 2.00 GHz");
pi.push_back("MacBookPro13,2 Intel Core i7-6567U @ 3.30 GHz");
pi.push_back("MacBookPro13,3 Intel Core i7-6700HQ @ 2.60 GHz");
pi.push_back("MacBookPro14,1 Intel Core i5-7360U @ 2.30 GHz");
pi.push_back("MacBookPro14,2 Intel Core i5-7267U @ 3.10 GHz");
pi.push_back("MacBookPro14,3 Intel Core i7-7700HQ @ 2.80 GHz");
pi.push_back("MacBookPro15,1 Intel Core i7-8750H @ 2.20 GHz");
pi.push_back("MacBookPro15,2 Intel Core i7-8559U @ 2.70 GHz");
pi.push_back("MacBookPro15,3 Intel Core i7-8850H @ 2.60 GHz");
pi.push_back("MacBookPro15,4 Intel Core i5-8257U @ 1.40 GHz");
pi.push_back("MacBookPro16,1 Intel Core i7-9750H @ 2.60 GHz");
pi.push_back("MacBookPro16,2 Intel Core i5-1038NG7 @ 2.00 GHz");
pi.push_back("MacBookPro16,3 Intel Core i5-8257U @ 1.40 GHz");
pi.push_back("MacBookPro16,4 Intel Core i7-9750H @ 2.60 GHz");
pi.push_back("Macmini1,1 Intel Core Solo T1200 @ 1.50 GHz");
pi.push_back("Macmini2,1 Intel Core 2 Duo T5600 @ 1.83 GHz");
pi.push_back("Macmini3,1 Intel Core 2 Duo P7350 @ 2.00 GHz");
pi.push_back("Macmini4,1 Intel Core 2 Duo P8600 @ 2.40 GHz");
pi.push_back("Macmini5,1 Intel Core i5-2415M @ 2.30 GHz");
pi.push_back("Macmini5,2 Intel Core i5-2520M @ 2.50 GHz");
pi.push_back("Macmini5,3 Intel Core i7-2635QM @ 2.00 GHz");
pi.push_back("Macmini6,1 Intel Core i5-3210M @ 2.50 GHz");
pi.push_back("Macmini6,2 Intel Core i7-3615QM @ 2.30 GHz");
pi.push_back("Macmini7,1 Intel Core i5-4260U @ 1.40 GHz");
pi.push_back("Macmini8,1 Intel Core i7-8700B @ 3.20 GHz");
pi.push_back("Xserve1,1 Intel Xeon 5130 x2 @ 2.00 GHz");
pi.push_back("Xserve2,1 Intel Xeon E5462 x2 @ 2.80 GHz");
pi.push_back("Xserve3,1 Intel Xeon E5520 x2 @ 2.26 GHz");
pi.push_back("iMacPro1,1 Intel Xeon W-2140B CPU @ 3.20 GHz");
pi.push_back("iMac4,1 Intel Core Duo T2400 @ 1.83 GHz");
pi.push_back("iMac4,2 Intel Core Duo T2400 @ 1.83 GHz");
pi.push_back("iMac5,1 Intel Core 2 Duo T7200 @ 2.00 GHz");
pi.push_back("iMac5,2 Intel Core 2 Duo T5600 @ 1.83 GHz");
pi.push_back("iMac6,1 Intel Core 2 Duo T7400 @ 2.16 GHz");
pi.push_back("iMac7,1 Intel Core 2 Duo T7300 @ 2.00 GHz");
pi.push_back("iMac8,1 Intel Core 2 Duo E8435 @ 3.06 GHz");
pi.push_back("iMac9,1 Intel Core 2 Duo E8135 @ 2.66 GHz");
pi.push_back("iMac10,1 Intel Core 2 Duo E7600 @ 3.06 GHz");
pi.push_back("iMac11,1 Intel Core i5-750 @ 2.66 GHz");
pi.push_back("iMac11,2 Intel Core i3-540 @ 3.06 GHz");
pi.push_back("iMac11,3 Intel Core i5-760 @ 2.80 GHz");
pi.push_back("iMac12,1 Intel Core i5-2400S @ 2.50 GHz");
pi.push_back("iMac12,2 Intel Core i7-2600 @ 3.40 GHz");
pi.push_back("iMac13,1 Intel Core i7-3770S @ 3.10 GHz");
pi.push_back("iMac13,2 Intel Core i5-3470S @ 2.90 GHz");
pi.push_back("iMac13,3 Intel Core i5-3470S @ 2.90 GHz");
pi.push_back("iMac14,1 Intel Core i5-4570R @ 2.70 GHz");
pi.push_back("iMac14,2 Intel Core i7-4771 @ 3.50 GHz");
pi.push_back("iMac14,3 Intel Core i5-4570S @ 2.90 GHz");
pi.push_back("iMac14,4 Intel Core i5-4260U @ 1.40 GHz");
pi.push_back("iMac15,1 Intel Core i7-4790k @ 4.00 GHz");
pi.push_back("iMac16,1 Intel Core i5-5250U @ 1.60 GHz");
pi.push_back("iMac16,2 Intel Core i5-5675R @ 3.10 GHz");
pi.push_back("iMac17,1 Intel Core i5-6500 @ 3.20 GHz");
pi.push_back("iMac18,1 Intel Core i5-7360U @ 2.30 GHz");
pi.push_back("iMac18,2 Intel Core i5-7400 @ 3.00 GHz");
pi.push_back("iMac18,3 Intel Core i5-7600K @ 3.80 GHz");
pi.push_back("iMac19,1 Intel Core i9-9900K @ 3.60 GHz");
pi.push_back("iMac19,2 Intel Core i5-8500 @ 3.00 GHz");
pi.push_back("iMac20,1 Intel Core i5-10500 @ 3.10 GHz");
pi.push_back("iMac20,2 Intel Core i9-10910 @ 3.60 GHz");
ui->cboxSystemProductName->addItems(pi);
//获取当前Mac信息
QFileInfo appInfo(qApp->applicationDirPath());
si = new QProcess;
#ifdef Q_OS_WIN32
QFile file(appInfo.filePath() + "/macserial.exe");
if(file.exists())
gs->execute(appInfo.filePath() + "/macserial.exe" , QStringList() << "-s");//阻塞execute
else
{
ui->btnGenerate->setEnabled(false);
ui->btnSystemUUID->setEnabled(false);
}
ui->tabPlatformInfo->removeTab(4);
#endif
#ifdef Q_OS_LINUX
gs->execute(appInfo.filePath() + "/macserial" , QStringList() << "-s");
/*暂时屏蔽*/
ui->tabPlatformInfo->removeTab(4);
ui->btnGenerate->setEnabled(true);
#endif
#ifdef Q_OS_MAC
si->start(appInfo.filePath() + "/macserial" , QStringList() << "-s");
#endif
connect(si , SIGNAL(finished(int)) , this , SLOT(readResultSystemInfo()));
}
void MainWindow::ParserPlatformInfo(QVariantMap map)
{
map = map["PlatformInfo"].toMap();
if(map.isEmpty())
return;
ui->chkAutomatic->setChecked(map["Automatic"].toBool());
ui->chkCustomMemory->setChecked(map["CustomMemory"].toBool());
ui->chkUpdateDataHub->setChecked(map["UpdateDataHub"].toBool());
ui->chkUpdateNVRAM->setChecked(map["UpdateNVRAM"].toBool());
ui->chkUpdateSMBIOS->setChecked(map["UpdateSMBIOS"].toBool());
QString usm = map["UpdateSMBIOSMode"].toString();
if(usm.trimmed() == "TryOverwrite")
ui->cboxUpdateSMBIOSMode->setCurrentIndex(0);
if(usm.trimmed() == "Create")
ui->cboxUpdateSMBIOSMode->setCurrentIndex(1);
if(usm.trimmed() == "Overwrite")
ui->cboxUpdateSMBIOSMode->setCurrentIndex(2);
if(usm.trimmed() == "Custom")
ui->cboxUpdateSMBIOSMode->setCurrentIndex(3);
//Generic
QVariantMap mapGeneric = map["Generic"].toMap();
ui->chkAdviseWindows->setChecked(mapGeneric["AdviseWindows"].toBool());
ui->editMLB->setText(mapGeneric["MLB"].toString());
if(ui->editMLB_2->text().trimmed() == "")
ui->editMLB_2->setText(mapGeneric["MLB"].toString());
QByteArray ba = mapGeneric["ROM"].toByteArray();
QString va = ba.toHex().toUpper();
ui->editROM->setText(va);
if(ui->editROM_2->text().trimmed() == "")
ui->editROM_2->setText(va);
ui->chkSpoofVendor->setChecked(mapGeneric["SpoofVendor"].toBool());
ui->editProcessorTypeGeneric->setText(mapGeneric["ProcessorType"].toString());
ui->cboxSystemMemoryStatus->setCurrentText(mapGeneric["SystemMemoryStatus"].toString().trimmed());
//机型
QString spn = mapGeneric["SystemProductName"].toString();
for(int i = 0; i < ui->cboxSystemProductName->count(); i++)
{
if(getSystemProductName(ui->cboxSystemProductName->itemText(i)) == spn)
{
ui->cboxSystemProductName->setCurrentIndex(i);
break;
}
}
if(ui->editSystemProductName->text().trimmed() == "")
ui->editSystemProductName->setText(mapGeneric["SystemProductName"].toString());
if(ui->editSystemProductName_2->text().trimmed() == "")
ui->editSystemProductName_2->setText(mapGeneric["SystemProductName"].toString());
ui->editSystemSerialNumber->setText(mapGeneric["SystemSerialNumber"].toString());
if(ui->editSystemSerialNumber_data->text().trimmed() == "")
ui->editSystemSerialNumber_data->setText(mapGeneric["SystemSerialNumber"].toString());
if(ui->editSystemSerialNumber_2->text().trimmed() == "")
ui->editSystemSerialNumber_2->setText(mapGeneric["SystemSerialNumber"].toString());
ui->editSystemUUID->setText(mapGeneric["SystemUUID"].toString());
if(ui->editSystemUUID_data->text().trimmed() == "")
ui->editSystemUUID_data->setText(mapGeneric["SystemUUID"].toString());
if(ui->editSystemUUID_2->text().trimmed() == "")
ui->editSystemUUID_2->setText(mapGeneric["SystemUUID"].toString());
//DataHub
QVariantMap mapDataHub = map["DataHub"].toMap();
ui->editARTFrequency->setText(mapDataHub["ARTFrequency"].toString());
ui->editBoardProduct->setText(mapDataHub["BoardProduct"].toString());
ui->editBoardRevision->setText(ByteToHexStr(mapDataHub["BoardRevision"].toByteArray()));
ui->editDevicePathsSupported->setText(mapDataHub["DevicePathsSupported"].toString());
ui->editFSBFrequency->setText(mapDataHub["FSBFrequency"].toString());
ui->editInitialTSC->setText(mapDataHub["InitialTSC"].toString());
ui->editPlatformName->setText(mapDataHub["PlatformName"].toString());
ui->editSmcBranch->setText(ByteToHexStr(mapDataHub["SmcBranch"].toByteArray()));
ui->editSmcPlatform->setText(ByteToHexStr(mapDataHub["SmcPlatform"].toByteArray()));
ui->editSmcRevision->setText(ByteToHexStr(mapDataHub["SmcRevision"].toByteArray()));
ui->editStartupPowerEvents->setText(mapDataHub["StartupPowerEvents"].toString());
ui->editSystemProductName->setText(mapDataHub["SystemProductName"].toString());
if(ui->cboxSystemProductName->currentText() == "")
{
for(int i = 0; i < ui->cboxSystemProductName->count(); i++)
{
if(getSystemProductName(ui->cboxSystemProductName->itemText(i)) == mapDataHub["SystemProductName"].toString())
{
ui->cboxSystemProductName->setCurrentIndex(i);
break;
}
}
}
ui->editSystemSerialNumber_data->setText(mapDataHub["SystemSerialNumber"].toString());
if(ui->editSystemSerialNumber->text().trimmed() == "")
ui->editSystemSerialNumber->setText(mapDataHub["SystemSerialNumber"].toString());
ui->editSystemUUID_data->setText(mapDataHub["SystemUUID"].toString());
if(ui->editSystemUUID->text().trimmed() == "")
ui->editSystemUUID->setText(mapDataHub["SystemUUID"].toString());
//Memory
QVariantMap mapMemory = map["Memory"].toMap();
ui->editDataWidth->setText(mapMemory["DataWidth"].toString());
ui->editErrorCorrection->setText(mapMemory["ErrorCorrection"].toString());
ui->editFormFactor->setText(mapMemory["FormFactor"].toString());
ui->editMaxCapacity->setText(mapMemory["MaxCapacity"].toString());
ui->editTotalWidth->setText(mapMemory["TotalWidth"].toString());
ui->editType->setText(mapMemory["Type"].toString());
ui->editTypeDetail->setText(mapMemory["TypeDetail"].toString());
//Memory-Devices
QVariantList mapMemoryDevices = mapMemory["Devices"].toList();
ui->tableDevices->setRowCount(mapMemoryDevices.count());//设置行的列数
for(int i = 0;i < mapMemoryDevices.count(); i++)
{
QVariantMap map3 = mapMemoryDevices.at(i).toMap();
QTableWidgetItem *newItem1;
newItem1 = new QTableWidgetItem(map3["AssetTag"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->tableDevices->setItem(i, 0, newItem1);
newItem1 = new QTableWidgetItem(map3["BankLocator"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->tableDevices->setItem(i, 1, newItem1);
newItem1 = new QTableWidgetItem(map3["DeviceLocator"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->tableDevices->setItem(i, 2, newItem1);
newItem1 = new QTableWidgetItem(map3["Manufacturer"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->tableDevices->setItem(i, 3, newItem1);
newItem1 = new QTableWidgetItem(map3["PartNumber"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->tableDevices->setItem(i, 4, newItem1);
newItem1 = new QTableWidgetItem(map3["SerialNumber"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->tableDevices->setItem(i, 5, newItem1);
newItem1 = new QTableWidgetItem(map3["Size"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->tableDevices->setItem(i, 6, newItem1);
newItem1 = new QTableWidgetItem(map3["Speed"].toString());
newItem1->setTextAlignment(Qt::AlignCenter);
ui->tableDevices->setItem(i, 7, newItem1);
}
//PlatformNVRAM
QVariantMap mapPlatformNVRAM = map["PlatformNVRAM"].toMap();
ui->editBID->setText(mapPlatformNVRAM["BID"].toString());
ui->editMLB_2->setText(mapPlatformNVRAM["MLB"].toString());
if(ui->editMLB->text().trimmed() == "")
ui->editMLB->setText(mapPlatformNVRAM["MLB"].toString());
ui->editFirmwareFeatures->setText(ByteToHexStr(mapPlatformNVRAM["FirmwareFeatures"].toByteArray()));
ui->editFirmwareFeaturesMask->setText(ByteToHexStr(mapPlatformNVRAM["FirmwareFeaturesMask"].toByteArray()));
ui->editROM_2->setText(ByteToHexStr(mapPlatformNVRAM["ROM"].toByteArray()));
if(ui->editROM->text().trimmed() == "")
ui->editROM->setText(ByteToHexStr(mapPlatformNVRAM["ROM"].toByteArray()));
//SMBIOS
QVariantMap mapSMBIOS = map["SMBIOS"].toMap();
ui->editBIOSReleaseDate->setText(mapSMBIOS["BIOSReleaseDate"].toString());
ui->editBIOSVendor->setText(mapSMBIOS["BIOSVendor"].toString());
ui->editBIOSVersion->setText(mapSMBIOS["BIOSVersion"].toString());
ui->editBoardAssetTag->setText(mapSMBIOS["BoardAssetTag"].toString());
ui->editBoardLocationInChassis->setText(mapSMBIOS["BoardLocationInChassis"].toString());
ui->editBoardManufacturer->setText(mapSMBIOS["BoardManufacturer"].toString());
ui->editBoardProduct_2->setText(mapSMBIOS["BoardProduct"].toString());
ui->editBoardSerialNumber->setText(mapSMBIOS["BoardSerialNumber"].toString());
ui->editBoardType->setText(mapSMBIOS["BoardType"].toString());
ui->editBoardVersion->setText(mapSMBIOS["BoardVersion"].toString());
ui->editChassisAssetTag->setText(mapSMBIOS["ChassisAssetTag"].toString());
ui->editChassisManufacturer->setText(mapSMBIOS["ChassisManufacturer"].toString());
ui->editChassisSerialNumber->setText(mapSMBIOS["ChassisSerialNumber"].toString());
ui->editChassisType->setText(mapSMBIOS["ChassisType"].toString());
ui->editChassisVersion->setText(mapSMBIOS["ChassisVersion"].toString());
ui->editFirmwareFeatures_2->setText(ByteToHexStr(mapSMBIOS["FirmwareFeatures"].toByteArray()));
ui->editFirmwareFeaturesMask_2->setText(ByteToHexStr(mapSMBIOS["FirmwareFeaturesMask"].toByteArray()));
//ui->editMemoryFormFactor->setText(mapSMBIOS["MemoryFormFactor"].toString());
ui->editPlatformFeature->setText(mapSMBIOS["PlatformFeature"].toString());
ui->editProcessorType->setText(mapSMBIOS["ProcessorType"].toString());
ui->editSmcVersion->setText(ByteToHexStr(mapSMBIOS["SmcVersion"].toByteArray()));
ui->editSystemFamily->setText(mapSMBIOS["SystemFamily"].toString());
ui->editSystemManufacturer->setText(mapSMBIOS["SystemManufacturer"].toString());
ui->editSystemProductName_2->setText(mapSMBIOS["SystemProductName"].toString());
ui->editSystemSKUNumber->setText(mapSMBIOS["SystemSKUNumber"].toString());
ui->editSystemSerialNumber_2->setText(mapSMBIOS["SystemSerialNumber"].toString());
ui->editSystemUUID_2->setText(mapSMBIOS["SystemUUID"].toString());
ui->editSystemVersion->setText(mapSMBIOS["SystemVersion"].toString());
}
void MainWindow::initui_UEFI()
{
//Drivers
QTableWidgetItem *id0;
ui->table_uefi_drivers->setColumnWidth(0,1200);
id0 = new QTableWidgetItem(tr("Drivers"));
ui->table_uefi_drivers->setHorizontalHeaderItem(0, id0);
ui->table_uefi_drivers->setAlternatingRowColors(true);
//KeySupportMode
ui->cboxKeySupportMode->addItem("Auto");
ui->cboxKeySupportMode->addItem("V1");
ui->cboxKeySupportMode->addItem("V2");
ui->cboxKeySupportMode->addItem("AMI");
//Output
ui->cboxConsoleMode->setEditable(true);
ui->cboxConsoleMode->addItem("Max");
ui->cboxResolution->setEditable(true);
ui->cboxResolution->addItem("Max");
ui->cboxTextRenderer->addItem("BuiltinGraphics");
ui->cboxTextRenderer->addItem("SystemGraphics");
ui->cboxTextRenderer->addItem("SystemText");
ui->cboxTextRenderer->addItem("SystemGeneric");
//ReservedMemory
ui->table_uefi_ReservedMemory->setColumnWidth(0,300);
id0 = new QTableWidgetItem(tr("Address"));
ui->table_uefi_ReservedMemory->setHorizontalHeaderItem(0, id0);
ui->table_uefi_ReservedMemory->setColumnWidth(1,320);
id0 = new QTableWidgetItem(tr("Comment"));
ui->table_uefi_ReservedMemory->setHorizontalHeaderItem(1, id0);
ui->table_uefi_ReservedMemory->setColumnWidth(2,300);
id0 = new QTableWidgetItem(tr("Size"));
ui->table_uefi_ReservedMemory->setHorizontalHeaderItem(2, id0);
ui->table_uefi_ReservedMemory->setColumnWidth(3,210);
id0 = new QTableWidgetItem(tr("Type"));
ui->table_uefi_ReservedMemory->setHorizontalHeaderItem(3, id0);
id0 = new QTableWidgetItem(tr("Enabled"));
ui->table_uefi_ReservedMemory->setHorizontalHeaderItem(4, id0);
ui->table_uefi_ReservedMemory->setAlternatingRowColors(true);
}
void MainWindow::ParserUEFI(QVariantMap map)
{
map = map["UEFI"].toMap();
if(map.isEmpty())
return;
//分析APFS
QVariantMap map_apfs = map["APFS"].toMap();
ui->chkEnableJumpstart->setChecked(map_apfs["EnableJumpstart"].toBool());
ui->chkGlobalConnect->setChecked(map_apfs["GlobalConnect"].toBool());
ui->chkHideVerbose->setChecked(map_apfs["HideVerbose"].toBool());
ui->chkJumpstartHotPlug->setChecked(map_apfs["JumpstartHotPlug"].toBool());
ui->editMinDate->setText(map_apfs["MinDate"].toString());
ui->editMinVersion->setText(map_apfs["MinVersion"].toString());
//分析Audio
QVariantMap map_audio = map["Audio"].toMap();
ui->chkAudioSupport->setChecked(map_audio["AudioSupport"].toBool());
ui->chkPlayChime->setChecked(map_audio["PlayChime"].toBool());
ui->editAudioCodec->setText(map_audio["AudioCodec"].toString());
ui->editAudioDevice->setText(map_audio["AudioDevice"].toString());
ui->editAudioOut->setText(map_audio["AudioOut"].toString());
ui->editMinimumVolume->setText(map_audio["MinimumVolume"].toString());
ui->editVolumeAmplifier->setText(map_audio["VolumeAmplifier"].toString());
//Drivers
QTableWidgetItem *id0;
QVariantList map_Drivers = map["Drivers"].toList(); //数组
ui->table_uefi_drivers->setRowCount(map_Drivers.count());
for(int i = 0; i < map_Drivers.count(); i ++)
{
id0 = new QTableWidgetItem(map_Drivers.at(i).toString());
ui->table_uefi_drivers->setItem(i , 0 , id0);
}
ui->chkConnectDrivers->setChecked(map["ConnectDrivers"].toBool());
//分析Input
QVariantMap map_input = map["Input"].toMap();
ui->chkKeyFiltering->setChecked(map_input["KeyFiltering"].toBool());
ui->chkKeySupport->setChecked(map_input["KeySupport"].toBool());
ui->chkKeySwap->setChecked(map_input["KeySwap"].toBool());
ui->chkPointerSupport->setChecked(map_input["PointerSupport"].toBool());
ui->editKeyForgetThreshold->setText(map_input["KeyForgetThreshold"].toString());
ui->editKeyMergeThreshold->setText(map_input["KeyMergeThreshold"].toString());
ui->editPointerSupportMode->setText(map_input["PointerSupportMode"].toString());
ui->editTimerResolution->setText(map_input["TimerResolution"].toString());
QString ksm = map_input["KeySupportMode"].toString();
if(ksm.trimmed() == "Auto")
ui->cboxKeySupportMode->setCurrentIndex(0);
if(ksm.trimmed() == "V1")
ui->cboxKeySupportMode->setCurrentIndex(1);
if(ksm.trimmed() == "V2")
ui->cboxKeySupportMode->setCurrentIndex(2);
if(ksm.trimmed() == "AMI")
ui->cboxKeySupportMode->setCurrentIndex(3);
//Output
QVariantMap map_output = map["Output"].toMap();
ui->chkClearScreenOnModeSwitch->setChecked(map_output["ClearScreenOnModeSwitch"].toBool());
ui->chkDirectGopRendering->setChecked(map_output["DirectGopRendering"].toBool());
ui->chkIgnoreTextInGraphics->setChecked(map_output["IgnoreTextInGraphics"].toBool());
ui->chkProvideConsoleGop->setChecked(map_output["ProvideConsoleGop"].toBool());
ui->chkReconnectOnResChange->setChecked(map_output["ReconnectOnResChange"].toBool());
ui->chkReplaceTabWithSpace->setChecked(map_output["ReplaceTabWithSpace"].toBool());
ui->chkSanitiseClearScreen->setChecked(map_output["SanitiseClearScreen"].toBool());
ui->chkUgaPassThrough->setChecked(map_output["UgaPassThrough"].toBool());
ui->cboxConsoleMode->setCurrentText(map_output["ConsoleMode"].toString());
ui->cboxResolution->setCurrentText(map_output["Resolution"].toString());
ui->cboxTextRenderer->setCurrentText(map_output["TextRenderer"].toString());
//ProtocolOverrides
QVariantMap map_po = map["ProtocolOverrides"].toMap();
ui->chkAppleAudio->setChecked(map_po["AppleAudio"].toBool());
ui->chkAppleBootPolicy->setChecked(map_po["AppleBootPolicy"].toBool());
ui->chkAppleDebugLog->setChecked(map_po["AppleDebugLog"].toBool());
ui->chkAppleEvent->setChecked(map_po["AppleEvent"].toBool());
ui->chkAppleFramebufferInfo->setChecked(map_po["AppleFramebufferInfo"].toBool());
ui->chkAppleImageConversion->setChecked(map_po["AppleImageConversion"].toBool());
ui->chkAppleKeyMap->setChecked(map_po["AppleKeyMap"].toBool());
ui->chkAppleRtcRam->setChecked(map_po["AppleRtcRam"].toBool());
ui->chkAppleSmcIo->setChecked(map_po["AppleSmcIo"].toBool());
ui->chkAppleUserInterfaceTheme->setChecked(map_po["AppleUserInterfaceTheme"].toBool());
ui->chkDataHub->setChecked(map_po["DataHub"].toBool());
ui->chkDeviceProperties->setChecked(map_po["DeviceProperties"].toBool());
ui->chkFirmwareVolume->setChecked(map_po["FirmwareVolume"].toBool());
ui->chkHashServices->setChecked(map_po["HashServices"].toBool());
ui->chkOSInfo->setChecked(map_po["OSInfo"].toBool());
ui->chkUnicodeCollation->setChecked(map_po["UnicodeCollation"].toBool());
ui->chkAppleImg4Verification->setChecked(map_po["AppleImg4Verification"].toBool());
ui->chkAppleSecureBoot->setChecked(map_po["AppleSecureBoot"].toBool());
//Quirks
QVariantMap map_uefi_Quirks = map["Quirks"].toMap();
ui->chkDeduplicateBootOrder->setChecked(map_uefi_Quirks["DeduplicateBootOrder"].toBool());
ui->chkIgnoreInvalidFlexRatio->setChecked(map_uefi_Quirks["IgnoreInvalidFlexRatio"].toBool());
ui->chkReleaseUsbOwnership->setChecked(map_uefi_Quirks["ReleaseUsbOwnership"].toBool());
ui->chkRequestBootVarRouting->setChecked(map_uefi_Quirks["RequestBootVarRouting"].toBool());
ui->chkUnblockFsConnect->setChecked(map_uefi_Quirks["UnblockFsConnect"].toBool());
ui->editExitBootServicesDelay->setText(map_uefi_Quirks["ExitBootServicesDelay"].toString());
ui->editTscSyncTimeout->setText(map_uefi_Quirks["TscSyncTimeout"].toString());
//ReservedMemory
QTableWidgetItem *newItem1;
QVariantList map3 = map["ReservedMemory"].toList();
ui->table_uefi_ReservedMemory->setRowCount(map3.count());
for(int i = 0; i < map3.count(); i++)
{
QVariantMap map_sub = map3.at(i).toMap();
newItem1 = new QTableWidgetItem(map_sub["Address"].toString());
ui->table_uefi_ReservedMemory->setItem(i, 0, newItem1);
newItem1 = new QTableWidgetItem(map_sub["Comment"].toString());
ui->table_uefi_ReservedMemory->setItem(i, 1, newItem1);
newItem1 = new QTableWidgetItem(map_sub["Size"].toString());
ui->table_uefi_ReservedMemory->setItem(i, 2, newItem1);
newItem1 = new QTableWidgetItem(map_sub["Type"].toString());
ui->table_uefi_ReservedMemory->setItem(i, 3, newItem1);
init_enabled_data(ui->table_uefi_ReservedMemory , i , 4 , map_sub["Enabled"].toString());
}
}
void MainWindow::on_btnSave_clicked()
{
//QString FileName = QDir::homePath() + "/test.plist";
SavePlist(PlistFileName);
}
bool MainWindow::getBool(QTableWidget *table, int row, int column)
{
QString be = table->item(row , column)->text();
if(be.trimmed() == "true")
return true;
if(be.trimmed() == "false")
return false;
return false;
}
void MainWindow::SavePlist(QString FileName)
{
QVariantMap OpenCore;
OpenCore["ACPI"] = SaveACPI();
OpenCore["Booter"] = SaveBooter();
OpenCore["DeviceProperties"] = SaveDeviceProperties();
OpenCore["Kernel"] = SaveKernel();
OpenCore["Misc"] = SaveMisc();
OpenCore["NVRAM"] = SaveNVRAM();
OpenCore["PlatformInfo"] = SavePlatformInfo();
OpenCore["UEFI"] = SaveUEFI();
PListSerializer::toPList(OpenCore , FileName);
}
QVariantMap MainWindow::SaveACPI()
{
//ACPI
//Add
QVariantMap acpiMap;
QVariantList acpiAdd;
QVariantMap acpiAddSub;
for(int i = 0; i < ui->table_acpi_add->rowCount(); i ++)
{
acpiAddSub["Path"] = ui->table_acpi_add->item(i , 0)->text();
acpiAddSub["Comment"] = ui->table_acpi_add->item(i , 1)->text();
acpiAddSub["Enabled"] = getBool(ui->table_acpi_add , i , 2);
acpiAdd.append(acpiAddSub); //最后一层
acpiMap["Add"] = acpiAdd; //第二层
}
//Delete
QVariantList acpiDel;
QVariantMap acpiDelSub;
QString str;
for(int i = 0; i < ui->table_acpi_del->rowCount(); i ++)
{
str = ui->table_acpi_del->item(i , 0)->text();
acpiDelSub["TableSignature"] = HexStrToByte(str);
str = ui->table_acpi_del->item(i , 1)->text();
acpiDelSub["OemTableId"] = HexStrToByte(str);
acpiDelSub["TableLength"] = ui->table_acpi_del->item(i , 2)->text().toLongLong();
acpiDelSub["Comment"] = ui->table_acpi_del->item(i , 3)->text();
acpiDelSub["All"] = getBool(ui->table_acpi_del , i , 4);
acpiDelSub["Enabled"] = getBool(ui->table_acpi_del , i , 5);
acpiDel.append(acpiDelSub); //最后一层
acpiMap["Delete"] = acpiDel; //第二层
}
//Patch
QVariantList acpiPatch;
QVariantMap acpiPatchSub;
for(int i = 0; i < ui->table_acpi_patch->rowCount(); i ++)
{
str = ui->table_acpi_patch->item(i , 0)->text();
acpiPatchSub["TableSignature"] = HexStrToByte(str);
str = ui->table_acpi_patch->item(i , 1)->text();
acpiPatchSub["OemTableId"] = HexStrToByte(str);
acpiPatchSub["TableLength"] = ui->table_acpi_patch->item(i , 2)->text().toLongLong();
acpiPatchSub["Find"] = HexStrToByte(ui->table_acpi_patch->item(i , 3)->text());
acpiPatchSub["Replace"] = HexStrToByte(ui->table_acpi_patch->item(i , 4)->text());
acpiPatchSub["Comment"] = ui->table_acpi_patch->item(i , 5)->text();
acpiPatchSub["Mask"] = ui->table_acpi_patch->item(i , 6)->text().toLatin1();
acpiPatchSub["ReplaceMask"] = ui->table_acpi_patch->item(i , 7)->text().toLatin1();
acpiPatchSub["Count"] = ui->table_acpi_patch->item(i , 8)->text().toLongLong();
acpiPatchSub["Limit"] = ui->table_acpi_patch->item(i , 9)->text().toLongLong();
acpiPatchSub["Skip"] = ui->table_acpi_patch->item(i , 10)->text().toLongLong();
acpiPatchSub["Enabled"] = getBool(ui->table_acpi_patch , i , 11);
acpiPatch.append(acpiPatchSub); //最后一层
acpiMap["Patch"] = acpiPatch; //第二层
}
//Quirks
QVariantMap acpiQuirks;
acpiQuirks["FadtEnableReset"] = getChkBool(ui->chkFadtEnableReset);
acpiQuirks["NormalizeHeaders"] = getChkBool(ui->chkNormalizeHeaders);
acpiQuirks["RebaseRegions"] = getChkBool(ui->chkRebaseRegions);
acpiQuirks["ResetHwSig"] = getChkBool(ui->chkResetHwSig);
acpiQuirks["ResetLogoStatus"] = getChkBool(ui->chkResetLogoStatus);
acpiMap["Quirks"] = acpiQuirks;
return acpiMap;
}
QVariantMap MainWindow::SaveBooter()
{
//MmioWhitelist
QVariantMap subMap;
QVariantList arrayList;
QVariantMap valueList;
for(int i = 0; i < ui->table_booter->rowCount(); i ++)
{
QString str = ui->table_booter->item(i ,0)->text().trimmed();
valueList["Address"] = str.toLongLong();
valueList["Comment"] = ui->table_booter->item(i , 1)->text();
valueList["Enabled"] = getBool(ui->table_booter , i , 2);
arrayList.append(valueList); //最后一层
subMap["MmioWhitelist"] = arrayList; //第二层
}
//Quirks
QVariantMap mapQuirks;
mapQuirks["AvoidRuntimeDefrag"] = getChkBool(ui->chkAvoidRuntimeDefrag);
mapQuirks["DevirtualiseMmio"] = getChkBool(ui->chkDevirtualiseMmio);
mapQuirks["DisableSingleUser"] = getChkBool(ui->chkDisableSingleUser);
mapQuirks["DisableVariableWrite"] = getChkBool(ui->chkDisableVariableWrite);
mapQuirks["DiscardHibernateMap"] = getChkBool(ui->chkDiscardHibernateMap);
mapQuirks["EnableSafeModeSlide"] = getChkBool(ui->chkEnableSafeModeSlide);
mapQuirks["EnableWriteUnprotector"] = getChkBool(ui->chkEnableWriteUnprotector);
mapQuirks["ForceExitBootServices"] = getChkBool(ui->chkForceExitBootServices);
mapQuirks["ProtectMemoryRegions"] = getChkBool(ui->chkProtectMemoryRegions);
mapQuirks["ProtectSecureBoot"] = getChkBool(ui->chkProtectSecureBoot);
mapQuirks["ProtectUefiServices"] = getChkBool(ui->chkProtectUefiServices);
mapQuirks["ProvideCustomSlide"] = getChkBool(ui->chkProvideCustomSlide);
mapQuirks["ProvideMaxSlide"] = ui->editProvideMaxSlide->text().toLongLong();
mapQuirks["RebuildAppleMemoryMap"] = getChkBool(ui->chkRebuildAppleMemoryMap);
mapQuirks["SetupVirtualMap"] = getChkBool(ui->chkSetupVirtualMap);
mapQuirks["SignalAppleOS"] = getChkBool(ui->chkSignalAppleOS);
mapQuirks["SyncRuntimePermissions"] = getChkBool(ui->chkSyncRuntimePermissions);
subMap["Quirks"] = mapQuirks;
return subMap;
}
QVariantMap MainWindow::SaveDeviceProperties()
{
//Add
QVariantMap subMap;
QVariantMap dictList;
QVariantMap valueList;
QVariantList arrayList;
for(int i = 0; i < ui->table_dp_add0->rowCount(); i ++)
{
valueList.clear(); //先必须清理下列表,很重要
//先加载表中的数据
ui->table_dp_add0->setCurrentCell(i , 0);
on_table_dp_add0_cellClicked(i , 0);
for(int k = 0; k < ui->table_dp_add->rowCount(); k ++)
{
QString dataType = ui->table_dp_add->item(k , 1)->text(); //数据类型
QString value = ui->table_dp_add->item(k , 2)->text();
if(dataType == "String")
valueList[ui->table_dp_add->item(k , 0)->text()] = value;
if(dataType == "Data")
{
//将以字符串方式显示的16进制原样转换成QByteArray
valueList[ui->table_dp_add->item(k , 0)->text()] = HexStrToByte(value);
}
if(dataType == "Number")
valueList[ui->table_dp_add->item(k , 0)->text()] = value.toLongLong();
}
dictList[ui->table_dp_add0->item(i , 0)->text()] = valueList;
}
subMap["Add"] = dictList;
//Delete
dictList.clear(); //先清理之前的数据
for(int i = 0; i < ui->table_dp_del0->rowCount(); i ++)
{
valueList.clear(); //先必须清理下列表,很重要
arrayList.clear();
//先加载表中的数据
ui->table_dp_del0->setCurrentCell(i , 0);
on_table_dp_del0_cellClicked(i , 0);
for(int k = 0; k < ui->table_dp_del->rowCount(); k ++)
{
arrayList.append(ui->table_dp_del->item(k , 0)->text());
}
dictList[ui->table_dp_del0->item(i , 0)->text()] = arrayList;
}
subMap["Delete"] = dictList;
return subMap;
}
QVariantMap MainWindow::SaveKernel()
{
//Add
QVariantMap subMap;
QVariantList dictList;
QVariantMap valueList;
for(int i = 0; i < ui->table_kernel_add->rowCount(); i ++)
{
valueList["BundlePath"] = ui->table_kernel_add->item(i , 0)->text();
valueList["Comment"] = ui->table_kernel_add->item(i , 1)->text();
valueList["ExecutablePath"] = ui->table_kernel_add->item(i , 2)->text();
valueList["PlistPath"] = ui->table_kernel_add->item(i , 3)->text();
valueList["MinKernel"] = ui->table_kernel_add->item(i , 4)->text();
valueList["MaxKernel"] = ui->table_kernel_add->item(i , 5)->text();
valueList["Enabled"] = getBool(ui->table_kernel_add , i , 6);
valueList["Arch"] = ui->table_kernel_add->item(i , 7)->text();
dictList.append(valueList);
subMap["Add"] = dictList;
}
//Block
dictList.clear();//必须先清理之前的数据,否则之前的数据会加到当前数据里面来
valueList.clear();
for(int i = 0; i < ui->table_kernel_block->rowCount(); i ++)
{
valueList["Identifier"] = ui->table_kernel_block->item(i , 0)->text();
valueList["Comment"] = ui->table_kernel_block->item(i , 1)->text();
valueList["MinKernel"] = ui->table_kernel_block->item(i , 2)->text();
valueList["MaxKernel"] = ui->table_kernel_block->item(i , 3)->text();
valueList["Enabled"] = getBool(ui->table_kernel_block , i , 4);
valueList["Arch"] = ui->table_kernel_block->item(i , 5)->text();
dictList.append(valueList);
subMap["Block"] = dictList;
}
//Force
dictList.clear();
valueList.clear();
for(int i = 0; i < ui->table_kernel_Force->rowCount(); i ++)
{
valueList["BundlePath"] = ui->table_kernel_Force->item(i , 0)->text();
valueList["Comment"] = ui->table_kernel_Force->item(i , 1)->text();
valueList["ExecutablePath"] = ui->table_kernel_Force->item(i , 2)->text();
valueList["Identifier"] = ui->table_kernel_Force->item(i , 3)->text();
valueList["PlistPath"] = ui->table_kernel_Force->item(i , 4)->text();
valueList["MinKernel"] = ui->table_kernel_Force->item(i , 5)->text();
valueList["MaxKernel"] = ui->table_kernel_Force->item(i , 6)->text();
valueList["Enabled"] = getBool(ui->table_kernel_Force , i , 7);
valueList["Arch"] = ui->table_kernel_Force->item(i , 8)->text();
dictList.append(valueList);
subMap["Force"] = dictList;
}
//Patch
dictList.clear();
valueList.clear();
for(int i = 0; i < ui->table_kernel_patch->rowCount(); i ++)
{
valueList["Identifier"] = ui->table_kernel_patch->item(i , 0)->text();
valueList["Base"] = ui->table_kernel_patch->item(i , 1)->text();
valueList["Comment"] = ui->table_kernel_patch->item(i , 2)->text();
valueList["Find"] = HexStrToByte(ui->table_kernel_patch->item(i , 3)->text());
valueList["Replace"] = HexStrToByte(ui->table_kernel_patch->item(i , 4)->text());
valueList["Mask"] = HexStrToByte(ui->table_kernel_patch->item(i , 5)->text());
valueList["ReplaceMask"] = HexStrToByte(ui->table_kernel_patch->item(i , 6)->text());
valueList["MinKernel"] = ui->table_kernel_patch->item(i , 7)->text();
valueList["MaxKernel"] = ui->table_kernel_patch->item(i , 8)->text();
valueList["Count"] = ui->table_kernel_patch->item(i , 9)->text().toLongLong();
valueList["Limit"] = ui->table_kernel_patch->item(i , 10)->text().toLongLong();
valueList["Skip"] = ui->table_kernel_patch->item(i , 11)->text().toLongLong();
valueList["Enabled"] = getBool(ui->table_kernel_patch , i , 12);
valueList["Arch"] = ui->table_kernel_patch->item(i , 13)->text();
dictList.append(valueList);
subMap["Patch"] = dictList;
}
//Emulate
QVariantMap mapValue;
mapValue["Cpuid1Data"] = HexStrToByte(ui->editCpuid1Data->text());
mapValue["Cpuid1Mask"] = HexStrToByte(ui->editCpuid1Mask->text());
mapValue["DummyPowerManagement"] = getChkBool(ui->chkDummyPowerManagement);
mapValue["MaxKernel"] = ui->editMaxKernel->text().trimmed();
mapValue["MinKernel"] = ui->editMinKernel->text().trimmed();
subMap["Emulate"] = mapValue;
//Quirks
QVariantMap mapQuirks;
mapQuirks["AppleCpuPmCfgLock"] = getChkBool(ui->chkAppleCpuPmCfgLock);
mapQuirks["AppleXcpmCfgLock"] = getChkBool(ui->chkAppleXcpmCfgLock);
mapQuirks["AppleXcpmExtraMsrs"] = getChkBool(ui->chkAppleXcpmExtraMsrs);
mapQuirks["AppleXcpmForceBoost"] = getChkBool(ui->chkAppleXcpmForceBoost);
mapQuirks["CustomSMBIOSGuid"] = getChkBool(ui->chkCustomSMBIOSGuid);
mapQuirks["DisableIoMapper"] = getChkBool(ui->chkDisableIoMapper);
mapQuirks["DisableRtcChecksum"] = getChkBool(ui->chkDisableRtcChecksum);
mapQuirks["ExternalDiskIcons"] = getChkBool(ui->chkExternalDiskIcons);
mapQuirks["IncreasePciBarSize"] = getChkBool(ui->chkIncreasePciBarSize);
mapQuirks["LapicKernelPanic"] = getChkBool(ui->chkLapicKernelPanic);
mapQuirks["PanicNoKextDump"] = getChkBool(ui->chkPanicNoKextDump);
mapQuirks["PowerTimeoutKernelPanic"] = getChkBool(ui->chkPowerTimeoutKernelPanic);
mapQuirks["ThirdPartyDrives"] = getChkBool(ui->chkThirdPartyDrives);
mapQuirks["XhciPortLimit"] = getChkBool(ui->chkXhciPortLimit);
mapQuirks["DisableLinkeditJettison"] = getChkBool(ui->chkDisableLinkeditJettison);
mapQuirks["LegacyCommpage"] = getChkBool(ui->chkLegacyCommpage);
mapQuirks["ExtendBTFeatureFlags"] = getChkBool(ui->chkExtendBTFeatureFlags);
subMap["Quirks"] = mapQuirks;
//Scheme
QVariantMap mapScheme;
mapScheme["FuzzyMatch"] = getChkBool(ui->chkFuzzyMatch);
mapScheme["KernelArch"] = ui->cboxKernelArch->currentText();
mapScheme["KernelCache"] = ui->cboxKernelCache->currentText();
subMap["Scheme"] = mapScheme;
return subMap;
}
QVariantMap MainWindow::SaveMisc()
{
QVariantMap subMap;
QVariantList dictList;
QVariantMap valueList;
//BlessOverride
for(int i = 0; i < ui->tableBlessOverride->rowCount(); i++)
{
dictList.append(ui->tableBlessOverride->item(i , 0)->text());
}
subMap["BlessOverride"] = dictList;
//Boot
valueList["ConsoleAttributes"] = ui->editConsoleAttributes->text().toLongLong();
valueList["HibernateMode"] = ui->cboxHibernateMode->currentText();
valueList["HideAuxiliary"] = getChkBool(ui->chkHideAuxiliary);
valueList["PickerAttributes"] = ui->editPickerAttributes->text().toLongLong();
valueList["PickerAudioAssist"] = getChkBool(ui->chkPickerAudioAssist);
valueList["PickerMode"] = ui->cboxPickerMode->currentText();
valueList["PollAppleHotKeys"] = getChkBool(ui->chkPollAppleHotKeys);
valueList["ShowPicker"] = getChkBool(ui->chkShowPicker);
valueList["TakeoffDelay"] = ui->editTakeoffDelay->text().toLongLong();
valueList["Timeout"] = ui->editTimeout->text().toLongLong();
subMap["Boot"] = valueList;
//Debug
valueList.clear();
valueList["AppleDebug"] = getChkBool(ui->chkAppleDebug);
valueList["ApplePanic"] = getChkBool(ui->chkApplePanic);
valueList["DisableWatchDog"] = getChkBool(ui->chkDisableWatchDog);
valueList["DisplayDelay"] = ui->editDisplayDelay->text().toLongLong();
valueList["DisplayLevel"] = ui->editDisplayLevel->text().toLongLong();
valueList["SerialInit"] = getChkBool(ui->chkSerialInit);
valueList["SysReport"] = getChkBool(ui->chkSysReport);
valueList["Target"] = ui->editTarget->text().toLongLong();
subMap["Debug"] = valueList;
//Entries
valueList.clear();
dictList.clear();
for(int i = 0; i < ui->tableEntries->rowCount(); i ++)
{
valueList["Path"] = ui->tableEntries->item(i , 0)->text();
valueList["Arguments"] = ui->tableEntries->item(i , 1)->text();
valueList["Name"] = ui->tableEntries->item(i , 2)->text();
valueList["Comment"] = ui->tableEntries->item(i , 3)->text();
valueList["Auxiliary"] = getBool(ui->tableEntries , i ,4);
valueList["Enabled"] = getBool(ui->tableEntries , i ,5);
dictList.append(valueList);
}
subMap["Entries"] = dictList;
//Security
valueList.clear();
valueList["AllowNvramReset"] = getChkBool(ui->chkAllowNvramReset);
valueList["AllowSetDefault"] = getChkBool(ui->chkAllowSetDefault);
valueList["AuthRestart"] = getChkBool(ui->chkAuthRestart);
valueList["EnablePassword"] = getChkBool(ui->chkEnablePassword);
valueList["BootProtect"] = ui->cboxBootProtect->currentText();
valueList["DmgLoading"] = ui->cboxDmgLoading->currentText();
valueList["Vault"] = ui->cboxVault->currentText();
valueList["PasswordHash"] = HexStrToByte(ui->editPasswordHash->text());
valueList["PasswordSalt"] = HexStrToByte(ui->editPasswordSalt->text());
valueList["ExposeSensitiveData"] = ui->editExposeSensitiveData->text().toLongLong();
valueList["HaltLevel"] = ui->editHaltLevel->text().toLongLong(nullptr , 10);
qDebug() << ui->editHaltLevel->text().toLongLong(nullptr , 16);
valueList["ScanPolicy"] = ui->editScanPolicy->text().toLongLong();
valueList["ApECID"] = ui->editApECID->text().toLongLong();
QString hm = ui->cboxSecureBootModel->currentText().trimmed();
if(hm == "")
hm = "Disabled";
valueList["SecureBootModel"] = hm;
subMap["Security"] = valueList;
//Tools
valueList.clear();
dictList.clear();
for(int i = 0; i < ui->tableTools->rowCount(); i ++)
{
valueList["Path"] = ui->tableTools->item(i , 0)->text();
valueList["Arguments"] = ui->tableTools->item(i , 1)->text();
valueList["Name"] = ui->tableTools->item(i , 2)->text();
valueList["Comment"] = ui->tableTools->item(i , 3)->text();
valueList["Auxiliary"] = getBool(ui->tableTools , i ,4);
valueList["Enabled"] = getBool(ui->tableTools , i ,5);
dictList.append(valueList);
}
subMap["Tools"] = dictList;
return subMap;
}
QVariantMap MainWindow::SaveNVRAM()
{
//Add
QVariantMap subMap;
QVariantMap dictList;
QVariantList arrayList;
QVariantMap valueList;
for(int i = 0; i < ui->table_nv_add0->rowCount(); i ++)
{
valueList.clear(); //先必须清理下列表,很重要
//先加载表中的数据
ui->table_nv_add0->setCurrentCell(i , 0);
on_table_nv_add0_cellClicked(i , 0);
for(int k = 0; k < ui->table_nv_add->rowCount(); k ++)
{
QString dataType = ui->table_nv_add->item(k , 1)->text(); //数据类型
QString value = ui->table_nv_add->item(k , 2)->text();
if(dataType == "String")
valueList[ui->table_nv_add->item(k , 0)->text()] = value;
if(dataType == "Data")
{
//将以字符串方式显示的16进制原样转换成QByteArray
valueList[ui->table_nv_add->item(k , 0)->text()] = HexStrToByte(value);
}
if(dataType == "Number")
valueList[ui->table_nv_add->item(k , 0)->text()] = value.toLongLong();
}
dictList[ui->table_nv_add0->item(i , 0)->text()] = valueList;
}
subMap["Add"] = dictList;
//Delete
dictList.clear(); //先清理之前的数据
for(int i = 0; i < ui->table_nv_del0->rowCount(); i ++)
{
valueList.clear(); //先必须清理下列表,很重要
arrayList.clear();
//先加载表中的数据
ui->table_nv_del0->setCurrentCell(i , 0);
on_table_nv_del0_cellClicked(i , 0);
for(int k = 0; k < ui->table_nv_del->rowCount(); k ++)
{
arrayList.append(ui->table_nv_del->item(k , 0)->text());
}
dictList[ui->table_nv_del0->item(i , 0)->text()] = arrayList;
}
subMap["Delete"] = dictList;
//LegacySchema
dictList.clear(); //先清理之前的数据
for(int i = 0; i < ui->table_nv_ls0->rowCount(); i ++)
{
valueList.clear(); //先必须清理下列表,很重要
arrayList.clear();
//先加载表中的数据
ui->table_nv_ls0->setCurrentCell(i , 0);
on_table_nv_ls0_cellClicked(i , 0);
for(int k = 0; k < ui->table_nv_ls->rowCount(); k ++)
{
arrayList.append(ui->table_nv_ls->item(k , 0)->text());
}
dictList[ui->table_nv_ls0->item(i , 0)->text()] = arrayList;
}
subMap["LegacySchema"] = dictList;
subMap["LegacyEnable"] = getChkBool(ui->chkLegacyEnable);
subMap["LegacyOverwrite"] = getChkBool(ui->chkLegacyOverwrite);
subMap["WriteFlash"] = getChkBool(ui->chkWriteFlash);
return subMap;
}
QVariantMap MainWindow::SavePlatformInfo()
{
QVariantMap subMap;
QVariantMap valueList;
//DataHub
valueList.clear();
valueList["ARTFrequency"] = ui->editARTFrequency->text().toLongLong();
valueList["BoardProduct"] = ui->editBoardProduct->text();
valueList["BoardRevision"] = HexStrToByte(ui->editBoardRevision->text());
valueList["DevicePathsSupported"] = ui->editDevicePathsSupported->text().toLongLong();
valueList["FSBFrequency"] = ui->editFSBFrequency->text().toLongLong();
valueList["InitialTSC"] = ui->editInitialTSC->text().toLongLong();
valueList["PlatformName"] = ui->editPlatformName->text();
valueList["SmcBranch"] = HexStrToByte(ui->editSmcBranch->text());
valueList["SmcPlatform"] = HexStrToByte(ui->editSmcPlatform->text());
valueList["SmcRevision"] = HexStrToByte(ui->editSmcRevision->text());
valueList["StartupPowerEvents"] = ui->editStartupPowerEvents->text().toLongLong();
valueList["SystemProductName"] = ui->editSystemProductName->text();
valueList["SystemSerialNumber"] = ui->editSystemSerialNumber_data->text();
valueList["SystemUUID"] = ui->editSystemUUID_data->text();
subMap["DataHub"] = valueList;
//Memory
valueList.clear();
valueList["DataWidth"] = ui->editDataWidth->text().toLongLong();
valueList["ErrorCorrection"] = ui->editErrorCorrection->text().toLongLong();
valueList["FormFactor"] = ui->editFormFactor->text().toLongLong();
valueList["MaxCapacity"] = ui->editMaxCapacity->text().toLongLong();
valueList["TotalWidth"] = ui->editTotalWidth->text().toLongLong();
valueList["Type"] = ui->editType->text().toLongLong();
valueList["TypeDetail"] = ui->editTypeDetail->text().toLongLong();
//Memory-Devices
QVariantMap Map;
QVariantList Array;
QVariantMap AddSub;
for(int i = 0; i < ui->tableDevices->rowCount(); i ++)
{
AddSub["AssetTag"] = ui->tableDevices->item(i , 0)->text();
AddSub["BankLocator"] = ui->tableDevices->item(i , 1)->text();
AddSub["DeviceLocator"] = ui->tableDevices->item(i , 2)->text();
AddSub["Manufacturer"] = ui->tableDevices->item(i , 3)->text();
AddSub["PartNumber"] = ui->tableDevices->item(i , 4)->text();
AddSub["SerialNumber"] = ui->tableDevices->item(i , 5)->text();
AddSub["Size"] = ui->tableDevices->item(i , 6)->text().toLongLong();
AddSub["Speed"] = ui->tableDevices->item(i , 7)->text().toLongLong();
Array.append(AddSub); //最后一层
Map["Devices"] = Array; //第二层
}
if(ui->tableDevices->rowCount() > 0) //里面有数据才进行保存的动作
{
valueList["Devices"] =Map["Devices"];
}
subMap["Memory"] = valueList;
//Generic
valueList.clear();
valueList["AdviseWindows"] = getChkBool(ui->chkAdviseWindows);
valueList["MLB"] = ui->editMLB->text();
valueList["SystemMemoryStatus"] = ui->cboxSystemMemoryStatus->currentText().trimmed();
valueList["ProcessorType"] = ui->editProcessorTypeGeneric->text().toLongLong();
valueList["ROM"] = HexStrToByte(ui->editROM->text());
valueList["SpoofVendor"] = getChkBool(ui->chkSpoofVendor);
valueList["SystemProductName"] = getSystemProductName(ui->cboxSystemProductName->currentText());
valueList["SystemSerialNumber"] = ui->editSystemSerialNumber->text();
valueList["SystemUUID"] = ui->editSystemUUID->text();
subMap["Generic"] = valueList;
//PlatformNVRAM
valueList.clear();
valueList["BID"] = ui->editBID->text();
valueList["MLB"] = ui->editMLB_2->text();
valueList["FirmwareFeatures"] = HexStrToByte(ui->editFirmwareFeatures->text());
valueList["FirmwareFeaturesMask"] = HexStrToByte(ui->editFirmwareFeaturesMask->text());
valueList["ROM"] = HexStrToByte(ui->editROM_2->text());
subMap["PlatformNVRAM"] = valueList;
//SMBIOS
valueList.clear();
valueList["BIOSReleaseDate"] = ui->editBIOSReleaseDate->text();
valueList["BIOSVendor"] = ui->editBIOSVendor->text();
valueList["BIOSVersion"] = ui->editBIOSVersion->text();
valueList["BoardAssetTag"] = ui->editBoardAssetTag->text();
valueList["BoardLocationInChassis"] = ui->editBoardLocationInChassis->text();
valueList["BoardManufacturer"] = ui->editBoardManufacturer->text();
valueList["BoardProduct"] = ui->editBoardProduct_2->text();
valueList["BoardSerialNumber"] = ui->editBoardSerialNumber->text();
valueList["BoardType"] = ui->editBoardType->text().toLongLong();
valueList["BoardVersion"] = ui->editBoardVersion->text();
valueList["ChassisAssetTag"] = ui->editChassisAssetTag->text();
valueList["ChassisManufacturer"] = ui->editChassisManufacturer->text();
valueList["ChassisSerialNumber"] = ui->editChassisSerialNumber->text();
valueList["ChassisType"] = ui->editChassisType->text().toLongLong();
valueList["ChassisVersion"] = ui->editChassisVersion->text();
valueList["FirmwareFeatures"] = HexStrToByte(ui->editFirmwareFeatures_2->text());
valueList["FirmwareFeaturesMask"] = HexStrToByte(ui->editFirmwareFeaturesMask_2->text());
//valueList["MemoryFormFactor"] = ui->editMemoryFormFactor->text().toLongLong();
valueList["PlatformFeature"] = ui->editPlatformFeature->text().toLongLong();
valueList["ProcessorType"] = ui->editProcessorType->text().toLongLong();
valueList["SmcVersion"] = HexStrToByte(ui->editSmcVersion->text());
valueList["SystemFamily"] = ui->editSystemFamily->text();
valueList["SystemManufacturer"] = ui->editSystemManufacturer->text();
valueList["SystemProductName"] = ui->editSystemProductName_2->text();
valueList["SystemSKUNumber"] = ui->editSystemSKUNumber->text();
valueList["SystemSerialNumber"] = ui->editSystemSerialNumber_2->text();
valueList["SystemUUID"] = ui->editSystemUUID_2->text();
valueList["SystemVersion"] = ui->editSystemVersion->text();
subMap["SMBIOS"] = valueList;
subMap["Automatic"] = getChkBool(ui->chkAutomatic);
subMap["CustomMemory"] = getChkBool(ui->chkCustomMemory);
subMap["UpdateDataHub"] = getChkBool(ui->chkUpdateDataHub);
subMap["UpdateNVRAM"] = getChkBool(ui->chkUpdateNVRAM);
subMap["UpdateSMBIOS"] = getChkBool(ui->chkUpdateSMBIOS);
subMap["UpdateSMBIOSMode"] = ui->cboxUpdateSMBIOSMode->currentText();
return subMap;
}
QVariantMap MainWindow::SaveUEFI()
{
QVariantMap subMap;
QVariantMap dictList;
QVariantList arrayList;
QVariantMap valueList;
//APFS
dictList["EnableJumpstart"] = getChkBool(ui->chkEnableJumpstart);
dictList["GlobalConnect"] = getChkBool(ui->chkGlobalConnect);
dictList["HideVerbose"] = getChkBool(ui->chkHideVerbose);
dictList["JumpstartHotPlug"] = getChkBool(ui->chkJumpstartHotPlug);
dictList["MinDate"] = ui->editMinDate->text().toLongLong();
dictList["MinVersion"] = ui->editMinVersion->text().toLongLong();
subMap["APFS"] = dictList;
//Audio
dictList.clear();
dictList["AudioCodec"] = ui->editAudioCodec->text().toLongLong();
dictList["AudioDevice"] = ui->editAudioDevice->text();
dictList["AudioOut"] = ui->editAudioOut->text().toLongLong();
dictList["AudioSupport"] = getChkBool(ui->chkAudioSupport);
dictList["MinimumVolume"] = ui->editMinimumVolume->text().toLongLong();
dictList["PlayChime"] = getChkBool(ui->chkPlayChime);
dictList["VolumeAmplifier"] = ui->editVolumeAmplifier->text().toLongLong();
subMap["Audio"] = dictList;
//Drivers
arrayList.clear();
for(int i = 0; i < ui->table_uefi_drivers->rowCount(); i++)
{
arrayList.append(ui->table_uefi_drivers->item(i , 0)->text());
}
subMap["Drivers"] = arrayList;
subMap["ConnectDrivers"] = getChkBool(ui->chkConnectDrivers);
//Input
dictList.clear();
dictList["KeyFiltering"] = getChkBool(ui->chkKeyFiltering);
dictList["KeySupport"] = getChkBool(ui->chkKeySupport);
dictList["KeySwap"] = getChkBool(ui->chkKeySwap);
dictList["PointerSupport"] = getChkBool(ui->chkPointerSupport);
dictList["KeyForgetThreshold"] = ui->editKeyForgetThreshold->text().toLongLong();
dictList["KeyMergeThreshold"] = ui->editKeyMergeThreshold->text().toLongLong();
dictList["PointerSupportMode"] = ui->editPointerSupportMode->text();
dictList["TimerResolution"] = ui->editTimerResolution->text().toLongLong();
dictList["KeySupportMode"] = ui->cboxKeySupportMode->currentText();
subMap["Input"] = dictList;
//Output
dictList.clear();
dictList["ClearScreenOnModeSwitch"] = getChkBool(ui->chkClearScreenOnModeSwitch);
dictList["DirectGopRendering"] = getChkBool(ui->chkDirectGopRendering);
dictList["IgnoreTextInGraphics"] = getChkBool(ui->chkIgnoreTextInGraphics);
dictList["ProvideConsoleGop"] = getChkBool(ui->chkProvideConsoleGop);
dictList["ReconnectOnResChange"] = getChkBool(ui->chkReconnectOnResChange);
dictList["ReplaceTabWithSpace"] = getChkBool(ui->chkReplaceTabWithSpace);
dictList["SanitiseClearScreen"] = getChkBool(ui->chkSanitiseClearScreen);
dictList["UgaPassThrough"] = getChkBool(ui->chkUgaPassThrough);
dictList["ConsoleMode"] = ui->cboxConsoleMode->currentText();
dictList["Resolution"] = ui->cboxResolution->currentText();
dictList["TextRenderer"] = ui->cboxTextRenderer->currentText();
subMap["Output"] = dictList;
//ProtocolOverrides
dictList.clear();
dictList["AppleAudio"] = getChkBool(ui->chkAppleAudio);
dictList["AppleBootPolicy"] = getChkBool(ui->chkAppleBootPolicy);
dictList["AppleDebugLog"] = getChkBool(ui->chkAppleDebugLog);
dictList["AppleEvent"] = getChkBool(ui->chkAppleEvent);
dictList["AppleFramebufferInfo"] = getChkBool(ui->chkAppleFramebufferInfo);
dictList["AppleImageConversion"] = getChkBool(ui->chkAppleImageConversion);
dictList["AppleKeyMap"] = getChkBool(ui->chkAppleKeyMap);
dictList["AppleRtcRam"] = getChkBool(ui->chkAppleRtcRam);
dictList["AppleSmcIo"] = getChkBool(ui->chkAppleSmcIo);
dictList["AppleUserInterfaceTheme"] = getChkBool(ui->chkAppleUserInterfaceTheme);
dictList["DataHub"] = getChkBool(ui->chkDataHub);
dictList["DeviceProperties"] = getChkBool(ui->chkDeviceProperties);
dictList["FirmwareVolume"] = getChkBool(ui->chkFirmwareVolume);
dictList["HashServices"] = getChkBool(ui->chkHashServices);
dictList["OSInfo"] = getChkBool(ui->chkOSInfo);
dictList["UnicodeCollation"] = getChkBool(ui->chkUnicodeCollation);
dictList["AppleImg4Verification"] = getChkBool(ui->chkAppleImg4Verification);
dictList["AppleSecureBoot"] = getChkBool(ui->chkAppleSecureBoot);
subMap["ProtocolOverrides"] = dictList;
//Quirks
dictList.clear();
dictList["DeduplicateBootOrder"] = getChkBool(ui->chkDeduplicateBootOrder);
dictList["IgnoreInvalidFlexRatio"] = getChkBool(ui->chkIgnoreInvalidFlexRatio);
dictList["ReleaseUsbOwnership"] = getChkBool(ui->chkReleaseUsbOwnership);
dictList["RequestBootVarRouting"] = getChkBool(ui->chkRequestBootVarRouting);
dictList["UnblockFsConnect"] = getChkBool(ui->chkUnblockFsConnect);
dictList["ExitBootServicesDelay"] = ui->editExitBootServicesDelay->text().toLongLong();
dictList["TscSyncTimeout"] = ui->editTscSyncTimeout->text().toLongLong();
subMap["Quirks"] = dictList;
//ReservedMemory
arrayList.clear();
valueList.clear();
for(int i = 0; i < ui->table_uefi_ReservedMemory->rowCount(); i++)
{
valueList["Address"] = ui->table_uefi_ReservedMemory->item(i , 0)->text().toLongLong();
valueList["Comment"] = ui->table_uefi_ReservedMemory->item(i , 1)->text();
valueList["Size"] = ui->table_uefi_ReservedMemory->item(i , 2)->text().toLongLong();
valueList["Type"] = ui->table_uefi_ReservedMemory->item(i , 3)->text();
valueList["Enabled"] = getBool(ui->table_uefi_ReservedMemory , i ,4);
arrayList.append(valueList);
}
subMap["ReservedMemory"] = arrayList;
return subMap;
}
bool MainWindow::getChkBool(QCheckBox *chkbox)
{
if(chkbox->isChecked())
return true;
else
return false;
return false;
}
QString MainWindow::ByteToHexStr(QByteArray ba)
{
QString str = ba.toHex().toUpper();
return str;
}
QByteArray MainWindow::HexStrToByte(QString value)
{
QByteArray ba;
QVector<QString> byte;
int len = value.length();
int k = 0;
ba.resize(len/2);
for(int i = 0; i < len/2; i++)
{
//qDebug() << i << k;
byte.push_back(value.mid(k , 2));
ba[k/2] = byte[k/2].toUInt(nullptr , 16);
k = k + 2;
}
/*QString c1 , c2 , c3 , c4;
c1 = value.mid(0 , 2);
c2 = value.mid(2 , 2);
c3 = value.mid(4 , 2);
c4 = value.mid(6 , 2);
ba.resize(4);
ba[0] = c1.toUInt(nullptr , 16);
ba[1] = c2.toUInt(nullptr , 16);
ba[2] = c3.toUInt(nullptr , 16);
ba[3] = c4.toUInt(nullptr , 16);*/
return ba;
}
QByteArray MainWindow::HexStringToByteArray(QString HexString)
{
bool ok;
QByteArray ret;
HexString = HexString.trimmed();
HexString = HexString.simplified();
QStringList sl = HexString.split(" ");
foreach (QString s, sl) {
if(!s.isEmpty())
{
char c = s.toInt(&ok,16)&0xFF;
if(ok){
ret.append(c);
}else{
qDebug()<<"非法的16进制字符:"<<s;
QMessageBox::warning(0,tr("错误:"),QString("非法的16进制字符: \"%1\"").arg(s));
}
}
}
qDebug()<<ret;
return ret;
}
void MainWindow::on_table_acpi_add_cellClicked(int row, int column)
{
enabled_change(ui->table_acpi_add , row , column , 2);
}
void MainWindow::init_enabled_data(QTableWidget *table , int row , int column , QString str)
{
QTableWidgetItem *chkbox = new QTableWidgetItem(str);
table->setItem(row, column, chkbox);
table->item(row , column)->setTextAlignment(Qt::AlignCenter);
if(str == "true")
chkbox->setCheckState(Qt::Checked);
else
chkbox->setCheckState(Qt::Unchecked);
}
void MainWindow::enabled_change(QTableWidget *table , int row , int column , int cc)
{
if(column == cc)
{
if(table->item(row , column)->checkState() == Qt::Checked)
{
table->item(row , column)->setTextAlignment(Qt::AlignCenter);
table->item(row , column)->setText("true");
}
else
{
if(table->item(row , column)->checkState() == Qt::Unchecked)
{
table->item(row , column)->setTextAlignment(Qt::AlignCenter);
table->item(row , column)->setText("false");
}
}
}
}
void MainWindow::on_table_acpi_del_cellClicked(int row, int column)
{
enabled_change(ui->table_acpi_del , row , column , 4);
enabled_change(ui->table_acpi_del , row , column , 5);
}
void MainWindow::on_table_acpi_patch_cellClicked(int row, int column)
{
enabled_change(ui->table_acpi_patch , row , column , 11);
}
void MainWindow::on_table_booter_cellClicked(int row, int column)
{
enabled_change(ui->table_booter , row , column , 2);
}
void MainWindow::on_table_kernel_add_cellClicked(int row, int column)
{
enabled_change(ui->table_kernel_add , row , column , 6);
if(column == 7)
{
cboxArch = new QComboBox;
cboxArch->addItem("Any");
cboxArch->addItem("i386");
cboxArch->addItem("x86_64");
cboxArch->addItem("");
connect(cboxArch, SIGNAL(currentIndexChanged(QString)), this, SLOT(arch_addChange()));
c_row = row;
ui->table_kernel_add->setCellWidget(row , column , cboxArch);
cboxArch->setCurrentText(ui->table_kernel_add->item(row , 7)->text());
}
}
void MainWindow::on_table_kernel_block_cellClicked(int row, int column)
{
enabled_change(ui->table_kernel_block , row , column , 4);
if(column == 5)
{
cboxArch = new QComboBox;
cboxArch->addItem("Any");
cboxArch->addItem("i386");
cboxArch->addItem("x86_64");
cboxArch->addItem("");
connect(cboxArch, SIGNAL(currentIndexChanged(QString)), this, SLOT(arch_blockChange()));
c_row = row;
ui->table_kernel_block->setCellWidget(row , column , cboxArch);
cboxArch->setCurrentText(ui->table_kernel_block->item(row , 5)->text());
}
}
void MainWindow::on_table_kernel_patch_cellClicked(int row, int column)
{
enabled_change(ui->table_kernel_patch , row , column , 12);
if(column == 13)
{
cboxArch = new QComboBox;
cboxArch->addItem("Any");
cboxArch->addItem("i386");
cboxArch->addItem("x86_64");
cboxArch->addItem("");
connect(cboxArch, SIGNAL(currentIndexChanged(QString)), this, SLOT(arch_patchChange()));
c_row = row;
ui->table_kernel_patch->setCellWidget(row , column , cboxArch);
cboxArch->setCurrentText(ui->table_kernel_patch->item(row , 13)->text());
}
}
void MainWindow::on_tableEntries_cellClicked(int row, int column)
{
enabled_change(ui->tableEntries , row , column , 5);
enabled_change(ui->tableEntries , row , column , 4);
}
void MainWindow::on_tableTools_cellClicked(int row, int column)
{
enabled_change(ui->tableTools , row , column , 5);
enabled_change(ui->tableTools , row , column , 4);
}
void MainWindow::on_table_uefi_ReservedMemory_cellClicked(int row, int column)
{
enabled_change(ui->table_uefi_ReservedMemory , row , column , 4);
if(column == 3)
{
cboxReservedMemoryType = new QComboBox(this);
QStringList sl_type;
sl_type.append("");
sl_type.append("Reserved");
sl_type.append("LoaderCode");
sl_type.append("LoaderData");
sl_type.append("BootServiceCode");
sl_type.append("BootServiceData");
sl_type.append("RuntimeCode");
sl_type.append("RuntimeData");
sl_type.append("Available");
sl_type.append("Persistent");
sl_type.append("UnusableMemory");
sl_type.append("ACPIReclaimMemory");
sl_type.append("ACPIMemoryNVS");
sl_type.append("MemoryMappedIO");
sl_type.append("MemoryMappedIOPortSpace");
sl_type.append("PalCode");
cboxReservedMemoryType->addItems(sl_type);
connect(cboxReservedMemoryType, SIGNAL(currentIndexChanged(QString)), this, SLOT(ReservedMemoryTypeChange()));
c_row = row;
ui->table_uefi_ReservedMemory->setCellWidget(row , column , cboxReservedMemoryType);
cboxReservedMemoryType->setCurrentText(ui->table_uefi_ReservedMemory->item(row , 3)->text());
}
}
void MainWindow::on_btnKernelPatchAdd_clicked()
{
add_item(ui->table_kernel_patch , 12);
init_enabled_data(ui->table_kernel_patch , ui->table_kernel_patch->rowCount() - 1 , 12 , "true");
QTableWidgetItem *newItem1 = new QTableWidgetItem("Any");
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_patch->setItem(ui->table_kernel_patch->currentRow() , 13 , newItem1);
}
void MainWindow::on_btnKernelPatchDel_clicked()
{
del_item(ui->table_kernel_patch);
}
void MainWindow::on_btnQuickOpen1_clicked()
{
QString FileName = QDir::homePath() + "/Sample.plist";
QFile file(FileName);
QVariantMap map = PListParser::parsePList(&file).toMap();
loading = true;
ParserACPI(map);
ParserBooter(map);
ParserDP(map);
ParserKernel(map);
ParserMisc(map);
ParserNvram(map);
ParserPlatformInfo(map);
ParserUEFI(map);
loading = false;
}
void MainWindow::on_btnQuickOpen2_clicked()
{
QString FileName = QDir::homePath() + "/SampleFull.plist";
QFile file(FileName);
QVariantMap map = PListParser::parsePList(&file).toMap();
loading = true;
ParserACPI(map);
ParserBooter(map);
ParserDP(map);
ParserKernel(map);
ParserMisc(map);
ParserNvram(map);
ParserPlatformInfo(map);
ParserUEFI(map);
loading = false;
}
void MainWindow::add_item(QTableWidget *table , int total_column)
{
int t = table->rowCount();
table->setRowCount(t + 1);
//用""初始化各项值
for(int i = 0; i < total_column; i++)
{
table->setItem(t , i , new QTableWidgetItem(""));
}
table->setFocus();
table->setCurrentCell(t , 0);
}
void MainWindow::del_item(QTableWidget *table)
{
int t = table->currentRow();
table->removeRow(t);
table->setFocus();
table->setCurrentCell(t - 1 , 0);
if(t == 0)
table->setCurrentCell(0 , 0);
}
void MainWindow::on_btnACPIAdd_Del_clicked()
{
del_item(ui->table_acpi_add);
}
void MainWindow::on_btnACPIDel_Add_clicked()
{
add_item(ui->table_acpi_del , 5);
init_enabled_data(ui->table_acpi_del , ui->table_acpi_del->rowCount() - 1 , 4 , "false");
init_enabled_data(ui->table_acpi_del , ui->table_acpi_del->rowCount() - 1 , 5 , "true");
}
void MainWindow::on_btnACPIDel_Del_clicked()
{
del_item(ui->table_acpi_del);
}
void MainWindow::on_btnACPIPatch_Add_clicked()
{
add_item(ui->table_acpi_patch , 11);
init_enabled_data(ui->table_acpi_patch , ui->table_acpi_patch->rowCount() - 1 , 11 , "true");
}
void MainWindow::on_btnACPIPatch_Del_clicked()
{
del_item(ui->table_acpi_patch);
}
void MainWindow::on_btnBooter_Add_clicked()
{
add_item(ui->table_booter , 2);
init_enabled_data(ui->table_booter , ui->table_booter->rowCount() - 1 , 2 , "true");
}
void MainWindow::on_btnBooter_Del_clicked()
{
del_item(ui->table_booter);
}
void MainWindow::on_btnDPDel_Add0_clicked()
{
add_item(ui->table_dp_del0 , 1);
ui->table_dp_del->setRowCount(0); //先清除右边表中的所有条目
on_btnDPDel_Add_clicked(); //同时右边增加一个新条目
write_value_ini(ui->table_dp_del0->objectName() , ui->table_dp_del , ui->table_dp_del0->rowCount() - 1);
}
void MainWindow::on_btnDPDel_Del0_clicked()
{
//先记住被删的条目位置
int delindex = ui->table_dp_del0->currentRow();
int count = ui->table_dp_del0->rowCount();
QString qz = QDir::homePath() + "/" + ui->table_dp_del0->objectName();
QFile file(qz + QString::number(delindex + 1) + ".ini");
del_item(ui->table_dp_del0);
if(file.exists())
file.remove();
//改名,以适应新的索引
if(delindex < count)
{
for(int i = delindex; i < ui->table_dp_del0->rowCount(); i ++)
{
QFile file(qz + QString::number(i + 2) + ".ini");
file.rename(qz + QString::number(i + 1) + ".ini");
}
}
if(ui->table_dp_del0->rowCount() == 0)
{
ui->table_dp_del->setRowCount(0);
}
on_table_dp_del0_cellClicked(ui->table_dp_del0->currentRow() , 0);
}
void MainWindow::on_btnDPDel_Add_clicked()
{
if(ui->table_dp_del0->rowCount() == 0)
return;
loading = true;
add_item(ui->table_dp_del , 1);
loading = false;
//保存数据
write_value_ini(ui->table_dp_del0->objectName() , ui->table_dp_del , ui->table_dp_del0->currentRow());
}
void MainWindow::on_btnDPDel_Del_clicked()
{
del_item(ui->table_dp_del);
//保存数据
write_value_ini(ui->table_dp_del0->objectName() , ui->table_dp_del , ui->table_dp_del0->currentRow());
}
void MainWindow::on_btnACPIAdd_Add_clicked()
{
QFileDialog fd;
QString FileName = fd.getOpenFileName(this,"文件","","文件(*.aml);;所有文件(*.*)");
if(FileName.isEmpty())
return;
//QFile file(FileName);
int row = ui->table_acpi_add->rowCount() + 1;
ui->table_acpi_add->setRowCount(row);
ui->table_acpi_add->setItem(row - 1 , 0 , new QTableWidgetItem(QFileInfo(FileName).fileName()));
ui->table_acpi_add->setItem(row - 1 , 1 , new QTableWidgetItem(""));
init_enabled_data(ui->table_acpi_add , row - 1 , 2 , "true");
ui->table_acpi_add->setFocus();
ui->table_acpi_add->setCurrentCell(row - 1 , 0);
}
void MainWindow::on_btnDPAdd_Add0_clicked()
{
add_item(ui->table_dp_add0 , 1);
ui->table_dp_add->setRowCount(0); //先清除右边表中的所有条目
on_btnDPAdd_Add_clicked(); //同时右边增加一个新条目
write_ini(ui->table_dp_add0->objectName() , ui->table_dp_add , ui->table_dp_add0->rowCount() - 1);
}
void MainWindow::on_btnDPAdd_Del0_clicked()
{
//先记住被删的条目位置
int delindex = ui->table_dp_add0->currentRow();
int count = ui->table_dp_add0->rowCount();
QString qz = QDir::homePath() + "/" + ui->table_dp_add0->objectName();
QFile file(qz + QString::number(delindex + 1) + ".ini");
del_item(ui->table_dp_add0);
if(file.exists())
file.remove();
//改名,以适应新的索引
if(delindex < count)
{
for(int i = delindex; i < ui->table_dp_add0->rowCount(); i ++)
{
QFile file(qz + QString::number(i + 2) + ".ini");
file.rename(qz + QString::number(i + 1) + ".ini");
}
}
if(ui->table_dp_add0->rowCount() == 0)
{
ui->table_dp_add->setRowCount(0);
}
on_table_dp_add0_cellClicked(ui->table_dp_add0->currentRow() , 0);
}
void MainWindow::on_btnDPAdd_Add_clicked()
{
if(ui->table_dp_add0->rowCount() == 0)
return;
loading = true;
add_item(ui->table_dp_add , 3);
loading = false;
//保存数据
write_ini(ui->table_dp_add0->objectName() , ui->table_dp_add , ui->table_dp_add0->currentRow());
}
void MainWindow::on_btnDPAdd_Del_clicked()
{
del_item(ui->table_dp_add);
write_ini(ui->table_dp_add0->objectName() , ui->table_dp_add , ui->table_dp_add0->currentRow());
}
void MainWindow::on_btnKernelAdd_Add_clicked()
{
QFileDialog fd;
QStringList FileName;
#ifdef Q_OS_WIN32
// win
FileName.append(fd.getExistingDirectory());
//qDebug() << FileName[0];
#endif
#ifdef Q_OS_LINUX
// linux
FileName.append(fd.getExistingDirectory());
#endif
#ifdef Q_OS_MAC
// mac
FileName = fd.getOpenFileNames(this,"kext文件","","kext文件(*.kext);;所有文件(*.*)");
#endif
int file_count = FileName.count();
if(file_count == 0 || FileName[0] == "")
return;
for(int j = 0; j < file_count; j++)
{
QFileInfo fileInfo(FileName[j]);
QFileInfo fileInfoList;
QString filePath = fileInfo.absolutePath();
//qDebug() << filePath;
QDir fileDir(filePath + "/" + fileInfo.fileName() + "/Contents/MacOS/");
//qDebug() << fileDir;
if(fileDir.exists())//如果目录存在,则遍历里面的文件
{
fileDir.setFilter(QDir::Files); //只遍历本目录
QFileInfoList fileList = fileDir.entryInfoList();
int fileCount = fileList.count();
for(int i = 0; i < fileCount; i++)//一般只有一个二进制文件
{
fileInfoList = fileList[i];
}
}
QTableWidget *t = new QTableWidget;
t = ui->table_kernel_add;
int row = t->rowCount() + 1;
t->setRowCount(row);
t->setItem(row - 1 , 0 , new QTableWidgetItem(QFileInfo(FileName[j]).fileName()));
t->setItem(row - 1 , 1 , new QTableWidgetItem(""));
t->setItem(row - 1 , 2 , new QTableWidgetItem("Contents/MacOS/" + fileInfoList.fileName()));
t->setItem(row - 1 , 3 , new QTableWidgetItem("Contents/Info.plist"));
t->setItem(row - 1 , 4 , new QTableWidgetItem(""));
t->setItem(row - 1 , 5 , new QTableWidgetItem(""));
init_enabled_data(t , row - 1 , 6 , "true");
QTableWidgetItem *newItem1 = new QTableWidgetItem("x86_64");
newItem1->setTextAlignment(Qt::AlignCenter);
t->setItem(row - 1 , 7 , newItem1);
//如果里面还有PlugIns目录,则需要继续遍历插件目录
QDir piDir(filePath + "/" + fileInfo.fileName() + "/Contents/PlugIns/");
//qDebug() << piDir;
if(piDir.exists())
{
piDir.setFilter(QDir::Dirs); //过滤器:只遍历里面的目录
QFileInfoList fileList = piDir.entryInfoList();
int fileCount = fileList.count();
QVector<QString> kext_file;
qDebug() << fileCount;
for(int i = 0; i < fileCount; i++)//找出里面的kext文件(目录)
{
kext_file.push_back(fileList[i].fileName());
qDebug() << kext_file.at(i);
}
if(fileCount >= 3) //里面有目录
{
for(int i = 0; i < fileCount - 2; i++)
{
QDir fileDir(filePath + "/" + fileInfo.fileName() + "/Contents/PlugIns/" + kext_file[i + 2] + "/Contents/MacOS/");
if(fileDir.exists())
{
//qDebug() << fileDir;
fileDir.setFilter(QDir::Files); //只遍历本目录里面的文件
QFileInfoList fileList = fileDir.entryInfoList();
int fileCount = fileList.count();
for(int i = 0; i < fileCount; i++)//一般只有一个二进制文件
{
fileInfoList = fileList[i];
}
//写入到表里
int row = t->rowCount() + 1;
t->setRowCount(row);
t->setItem(row - 1 , 0 , new QTableWidgetItem(QFileInfo(FileName[j]).fileName() + "/Contents/PlugIns/" + kext_file[i + 2]));
t->setItem(row - 1 , 1 , new QTableWidgetItem(""));
t->setItem(row - 1 , 2 , new QTableWidgetItem("Contents/MacOS/" + fileInfoList.fileName()));
t->setItem(row - 1 , 3 , new QTableWidgetItem("Contents/Info.plist"));
t->setItem(row - 1 , 4 , new QTableWidgetItem(""));
t->setItem(row - 1 , 5 , new QTableWidgetItem(""));
init_enabled_data(t , row - 1 , 6 , "true");
QTableWidgetItem *newItem1 = new QTableWidgetItem("x86_64");
newItem1->setTextAlignment(Qt::AlignCenter);
t->setItem(row - 1 , 7 , newItem1);
}
}
}
}
t->setFocus();
t->setCurrentCell(row - 1 , 0);
}
}
void MainWindow::on_btnKernelBlock_Add_clicked()
{
add_item(ui->table_kernel_block , 4);
init_enabled_data(ui->table_kernel_block , ui->table_kernel_block->currentRow() , 4 , "true");
QTableWidgetItem *newItem1 = new QTableWidgetItem("Any");
newItem1->setTextAlignment(Qt::AlignCenter);
ui->table_kernel_block->setItem(ui->table_kernel_block->currentRow() , 5 , newItem1);
}
void MainWindow::on_btnKernelBlock_Del_clicked()
{
del_item(ui->table_kernel_block);
}
void MainWindow::on_btnMiscBO_Add_clicked()
{
add_item(ui->tableBlessOverride , 1);
ui->tableBlessOverride->setItem(ui->tableBlessOverride->currentRow() , 0 ,new QTableWidgetItem(""));
}
void MainWindow::on_btnMiscBO_Del_clicked()
{
del_item(ui->tableBlessOverride);
}
void MainWindow::on_btnMiscEntries_Add_clicked()
{
add_item(ui->tableEntries , 5);
init_enabled_data(ui->tableEntries , ui->tableEntries->rowCount() - 1 , 4 , "false");
init_enabled_data(ui->tableEntries , ui->tableEntries->rowCount() - 1 , 5 , "true");
}
void MainWindow::on_btnMiscTools_Add_clicked()
{
add_item(ui->tableTools , 5);
init_enabled_data(ui->tableTools , ui->tableTools->rowCount() - 1 , 4 , "false");
init_enabled_data(ui->tableTools , ui->tableTools->rowCount() - 1 , 5 , "true");
}
void MainWindow::on_btnMiscEntries_Del_clicked()
{
del_item(ui->tableEntries);
}
void MainWindow::on_btnMiscTools_Del_clicked()
{
del_item(ui->tableTools);
}
void MainWindow::on_btnNVRAMAdd_Add0_clicked()
{
add_item(ui->table_nv_add0 , 1);
ui->table_nv_add->setRowCount(0); //先清除右边表中的所有条目
on_btnNVRAMAdd_Add_clicked(); //同时右边增加一个新条目
write_ini(ui->table_nv_add0->objectName() , ui->table_nv_add , ui->table_nv_add0->rowCount() - 1);
}
void MainWindow::on_btnNVRAMAdd_Add_clicked()
{
if(ui->table_nv_add0->rowCount() == 0)
return;
loading = true;
add_item(ui->table_nv_add , 3);
loading = false;
//保存数据
write_ini(ui->table_nv_add0->objectName() , ui->table_nv_add , ui->table_nv_add0->currentRow());
}
void MainWindow::on_btnNVRAMAdd_Del0_clicked()
{
//先记住被删的条目位置
int delindex = ui->table_nv_add0->currentRow();
int count = ui->table_nv_add0->rowCount();
QString qz = QDir::homePath() + "/" + ui->table_nv_add0->objectName();
QFile file(qz + QString::number(delindex + 1) + ".ini");
del_item(ui->table_nv_add0);
if(file.exists())
file.remove();
//改名,以适应新的索引
if(delindex < count)
{
for(int i = delindex; i < ui->table_nv_add0->rowCount(); i ++)
{
QFile file(qz + QString::number(i + 2) + ".ini");
file.rename(qz + QString::number(i + 1) + ".ini");
}
}
if(ui->table_nv_add0->rowCount() == 0)
{
ui->table_nv_add->setRowCount(0);
}
on_table_nv_add0_cellClicked(ui->table_nv_add0->currentRow() , 0);
}
void MainWindow::on_btnNVRAMAdd_Del_clicked()
{
del_item(ui->table_nv_add);
write_ini(ui->table_nv_add0->objectName() , ui->table_nv_add , ui->table_nv_add0->currentRow());
}
void MainWindow::on_btnNVRAMDel_Add0_clicked()
{
add_item(ui->table_nv_del0 , 1);
ui->table_nv_del->setRowCount(0); //先清除右边表中的所有条目
on_btnNVRAMDel_Add_clicked(); //同时右边增加一个新条目
write_value_ini(ui->table_nv_del0->objectName() , ui->table_nv_del , ui->table_nv_del0->rowCount() - 1);
}
void MainWindow::on_btnNVRAMDel_Add_clicked()
{
if(ui->table_nv_del0->rowCount() == 0)
return;
loading = true;
add_item(ui->table_nv_del , 1);
loading = false;
//保存数据
write_value_ini(ui->table_nv_del0->objectName() , ui->table_nv_del , ui->table_nv_del0->currentRow());
}
void MainWindow::on_btnNVRAMLS_Add0_clicked()
{
add_item(ui->table_nv_ls0 , 1);
ui->table_nv_ls->setRowCount(0); //先清除右边表中的所有条目
on_btnNVRAMLS_Add_clicked(); //同时右边增加一个新条目
write_value_ini(ui->table_nv_ls0->objectName() , ui->table_nv_ls , ui->table_nv_ls0->rowCount() - 1);
}
void MainWindow::on_btnNVRAMLS_Add_clicked()
{
if(ui->table_nv_ls0->rowCount() == 0)
return;
loading = true;
add_item(ui->table_nv_ls , 1);
loading = false;
//保存数据
write_value_ini(ui->table_nv_ls0->objectName() , ui->table_nv_ls , ui->table_nv_ls0->currentRow());
}
void MainWindow::on_btnNVRAMDel_Del0_clicked()
{
//先记住被删的条目位置
int delindex = ui->table_nv_del0->currentRow();
int count = ui->table_nv_del0->rowCount();
QString qz = QDir::homePath() + "/" + ui->table_nv_del0->objectName();
QFile file(qz + QString::number(delindex + 1) + ".ini");
del_item(ui->table_nv_del0);
if(file.exists())
file.remove();
//改名,以适应新的索引
if(delindex < count)
{
for(int i = delindex; i < ui->table_nv_del0->rowCount(); i ++)
{
QFile file(qz + QString::number(i + 2) + ".ini");
file.rename(qz + QString::number(i + 1) + ".ini");
}
}
if(ui->table_nv_del0->rowCount() == 0)
{
ui->table_nv_del->setRowCount(0);
}
on_table_nv_del0_cellClicked(ui->table_nv_del0->currentRow() , 0);
}
void MainWindow::on_btnNVRAMLS_Del0_clicked()
{
//先记住被删的条目位置
int delindex = ui->table_nv_ls0->currentRow();
int count = ui->table_nv_ls0->rowCount();
QString qz = QDir::homePath() + "/" + ui->table_nv_ls0->objectName();
QFile file(qz + QString::number(delindex + 1) + ".ini");
del_item(ui->table_nv_ls0);
if(file.exists())
file.remove();
//改名,以适应新的索引
if(delindex < count)
{
for(int i = delindex; i < ui->table_nv_ls0->rowCount(); i ++)
{
QFile file(qz + QString::number(i + 2) + ".ini");
file.rename(qz + QString::number(i + 1) + ".ini");
}
}
if(ui->table_nv_ls0->rowCount() == 0)
{
ui->table_nv_ls->setRowCount(0);
}
on_table_nv_ls0_cellClicked(ui->table_nv_ls0->currentRow() , 0);
}
void MainWindow::on_btnNVRAMDel_Del_clicked()
{
del_item(ui->table_nv_del);
//保存数据
write_value_ini(ui->table_nv_del0->objectName() , ui->table_nv_del , ui->table_nv_del0->currentRow());
}
void MainWindow::on_btnNVRAMLS_Del_clicked()
{
del_item(ui->table_nv_ls);
//保存数据
write_value_ini(ui->table_nv_ls0->objectName() , ui->table_nv_ls , ui->table_nv_ls0->currentRow());
}
void MainWindow::on_btnUEFIRM_Add_clicked()
{
add_item(ui->table_uefi_ReservedMemory , 4);
init_enabled_data(ui->table_uefi_ReservedMemory , ui->table_uefi_ReservedMemory->rowCount() - 1 , 4 , "true");
}
void MainWindow::on_btnUEFIRM_Del_clicked()
{
del_item(ui->table_uefi_ReservedMemory);
}
void MainWindow::on_btnUEFIDrivers_Add_clicked()
{
QFileDialog fd;
QString FileName = fd.getOpenFileName(this,"文件","","文件(*.efi);;所有文件(*.*)");
if(FileName.isEmpty())
return;
//QFile file(FileName);
int row = ui->table_uefi_drivers->rowCount() + 1;
ui->table_uefi_drivers->setRowCount(row);
ui->table_uefi_drivers->setItem(row - 1 , 0 , new QTableWidgetItem(QFileInfo(FileName).fileName()));
ui->table_uefi_drivers->setFocus();
ui->table_uefi_drivers->setCurrentCell(row - 1 , 0);
}
void MainWindow::on_btnUEFIDrivers_Del_clicked()
{
del_item(ui->table_uefi_drivers);
}
void MainWindow::on_btnKernelAdd_Up_clicked()
{
QTableWidget *t = new QTableWidget;
t = ui->table_kernel_add;
t->setFocus();
if(t->rowCount() == 0 || t->currentRow() == 0 || t->currentRow() < 0)
return;
int cr = t->currentRow();
//先将上面的内容进行备份
QString item[8];
item[0] = t->item(cr - 1 , 0)->text();
item[1] = t->item(cr - 1 , 1)->text();
item[2] = t->item(cr - 1 , 2)->text();
item[3] = t->item(cr - 1 , 3)->text();
item[4] = t->item(cr - 1 , 4)->text();
item[5] = t->item(cr - 1 , 5)->text();
item[6] = t->item(cr - 1 , 6)->text();
item[7] = t->item(cr - 1 , 7)->text();
//将下面的内容移到上面
t->item(cr - 1 , 0)->setText(t->item(cr , 0)->text());
t->item(cr - 1 , 1)->setText(t->item(cr , 1)->text());
t->item(cr - 1 , 2)->setText(t->item(cr , 2)->text());
t->item(cr - 1 , 3)->setText(t->item(cr , 3)->text());
t->item(cr - 1 , 4)->setText(t->item(cr , 4)->text());
t->item(cr - 1 , 5)->setText(t->item(cr , 5)->text());
t->item(cr - 1 , 6)->setText(t->item(cr , 6)->text());
if(t->item(cr , 6)->text() == "true")
t->item(cr - 1 , 6)->setCheckState(Qt::Checked);
else
t->item(cr - 1 , 6)->setCheckState(Qt::Unchecked);
t->item(cr - 1 , 7)->setText(t->item(cr , 7)->text());
//最后将之前的备份恢复到下面
t->item(cr , 0)->setText(item[0]);
t->item(cr , 1)->setText(item[1]);
t->item(cr , 2)->setText(item[2]);
t->item(cr , 3)->setText(item[3]);
t->item(cr , 4)->setText(item[4]);
t->item(cr , 5)->setText(item[5]);
t->item(cr , 6)->setText(item[6]);
if(item[6] == "true")
t->item(cr , 6)->setCheckState(Qt::Checked);
else
t->item(cr , 6)->setCheckState(Qt::Unchecked);
t->item(cr , 7)->setText(item[7]);
t->setCurrentCell(cr - 1 , t->currentColumn());
}
void MainWindow::on_btnKernelAdd_Down_clicked()
{
QTableWidget *t = new QTableWidget;
t = ui->table_kernel_add;
if(t->currentRow() == t->rowCount() - 1 || t->currentRow() < 0)
return;
int cr = t->currentRow();
//先将下面的内容进行备份
QString item[8];
item[0] = t->item(cr + 1 , 0)->text();
item[1] = t->item(cr + 1 , 1)->text();
item[2] = t->item(cr + 1 , 2)->text();
item[3] = t->item(cr + 1 , 3)->text();
item[4] = t->item(cr + 1 , 4)->text();
item[5] = t->item(cr + 1 , 5)->text();
item[6] = t->item(cr + 1 , 6)->text();
item[7] = t->item(cr + 1 , 7)->text();
//将上面的内容移到下面
t->item(cr + 1 , 0)->setText(t->item(cr , 0)->text());
t->item(cr + 1 , 1)->setText(t->item(cr , 1)->text());
t->item(cr + 1 , 2)->setText(t->item(cr , 2)->text());
t->item(cr + 1 , 3)->setText(t->item(cr , 3)->text());
t->item(cr + 1 , 4)->setText(t->item(cr , 4)->text());
t->item(cr + 1 , 5)->setText(t->item(cr , 5)->text());
t->item(cr + 1 , 6)->setText(t->item(cr , 6)->text());
if(t->item(cr , 6)->text() == "true")
t->item(cr + 1 , 6)->setCheckState(Qt::Checked);
else
t->item(cr + 1 , 6)->setCheckState(Qt::Unchecked);
t->item(cr + 1 , 7)->setText(t->item(cr , 7)->text());
//最后将之前的备份恢复到上面
t->item(cr , 0)->setText(item[0]);
t->item(cr , 1)->setText(item[1]);
t->item(cr , 2)->setText(item[2]);
t->item(cr , 3)->setText(item[3]);
t->item(cr , 4)->setText(item[4]);
t->item(cr , 5)->setText(item[5]);
t->item(cr , 6)->setText(item[6]);
if(item[6] == "true")
t->item(cr , 6)->setCheckState(Qt::Checked);
else
t->item(cr , 6)->setCheckState(Qt::Unchecked);
t->item(cr , 7)->setText(item[7]);
t->setCurrentCell(cr + 1 , t->currentColumn());
}
void MainWindow::test(bool test)
{
if(test)
{
ui->btnTestWrite->setVisible(1);
}
else
{
ui->btnTestWrite->setVisible(0);
}
}
void MainWindow::on_btnSaveAs_clicked()
{
QFileDialog fd;
PlistFileName = fd.getSaveFileName(this,"配置文件","","配置文件(*.plist);;所有文件(*.*)");
if(!PlistFileName.isEmpty())
setWindowTitle(title + " " + PlistFileName);
else
return;
SavePlist(PlistFileName);
ui->btnSave->setEnabled(true);
ui->actionSave->setEnabled(true);
}
void MainWindow::about()
{
QMessageBox::about(this , tr("About") ,
QString::fromLocal8Bit("<a style='color: blue;' href = https://github.com/ic005k/QtOpenCoreConfig>QtOpenCoreConfigurator</a><br><a style='color: blue;' href = https://github.com/acidanthera/OpenCorePkg/releases>OpenCore</a><br><a style='color: blue;' href = https://github.com/williambj1/OpenCore-Factory/releases>OpenCore-Factory</a><br><a style='color: blue;' href = https://github.com/ic005k/QtiASL>QtiASL</a>"));
}
void MainWindow::on_btnKernelAdd_Del_clicked()
{
del_item(ui->table_kernel_add);
}
void MainWindow::on_table_dp_add_cellClicked(int row, int column)
{
if(column == 1)
{
cboxDataClass = new QComboBox;
cboxDataClass->addItem("Data");
cboxDataClass->addItem("String");
cboxDataClass->addItem("Number");
cboxDataClass->addItem("");
connect(cboxDataClass, SIGNAL(currentIndexChanged(QString)), this, SLOT(dataClassChange_dp()));
c_row = row;
ui->table_dp_add->setCellWidget(row , column , cboxDataClass);
cboxDataClass->setCurrentText(ui->table_dp_add->item(row , 1)->text());
}
}
void MainWindow::on_table_dp_add_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
{
if(currentRow == 0 && currentColumn == 0 && previousColumn == 0)
{
}
ui->table_dp_add->removeCellWidget(previousRow , 1);
}
void MainWindow::arch_addChange()
{
ui->table_kernel_add->item(c_row , 7)->setText(cboxArch->currentText());
}
void MainWindow::arch_ForceChange()
{
ui->table_kernel_Force->item(c_row , 8)->setText(cboxArch->currentText());
}
void MainWindow::arch_blockChange()
{
ui->table_kernel_block->item(c_row , 5)->setText(cboxArch->currentText());
}
void MainWindow::arch_patchChange()
{
ui->table_kernel_patch->item(c_row , 13)->setText(cboxArch->currentText());
}
void MainWindow::ReservedMemoryTypeChange()
{
ui->table_uefi_ReservedMemory->item(c_row , 3)->setText(cboxReservedMemoryType->currentText());
}
void MainWindow::dataClassChange_dp()
{
ui->table_dp_add->item(c_row , 1)->setText(cboxDataClass->currentText());
}
void MainWindow::dataClassChange_nv()
{
ui->table_nv_add->item(c_row , 1)->setText(cboxDataClass->currentText());
}
void MainWindow::on_table_nv_add_cellClicked(int row, int column)
{
if(column == 1)
{
cboxDataClass = new QComboBox;
cboxDataClass->addItem("Data");
cboxDataClass->addItem("String");
cboxDataClass->addItem("Number");
cboxDataClass->addItem("");
connect(cboxDataClass, SIGNAL(currentIndexChanged(QString)), this, SLOT(dataClassChange_nv()));
c_row = row;
ui->table_nv_add->setCellWidget(row , column , cboxDataClass);
cboxDataClass->setCurrentText(ui->table_nv_add->item(row , 1)->text());
}
}
void MainWindow::on_table_nv_add_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
{
if(currentRow == 0 && currentColumn == 0 && previousColumn == 0)
{
}
ui->table_nv_add->removeCellWidget(previousRow , 1);
}
void MainWindow::reg_win()
{
QString appPath = qApp->applicationFilePath();
QString dir = qApp->applicationDirPath();
// 注意路径的替换
appPath.replace("/", "\\");
QString type = "QtiASL";
QSettings *regType = new QSettings("HKEY_CLASSES_ROOT\\.plist", QSettings::NativeFormat);
QSettings *regIcon = new QSettings("HKEY_CLASSES_ROOT\\.plist\\DefaultIcon", QSettings::NativeFormat);
QSettings *regShell = new QSettings("HKEY_CLASSES_ROOT\\QtOpenCoreConfig\\shell\\open\\command", QSettings::NativeFormat);
regType->remove("Default");
regType->setValue("Default", type);
regIcon->remove("Default");
// 0 使用当前程序内置图标
regIcon->setValue("Default", appPath + ",1");
// 百分号问题
QString shell = "\"" + appPath + "\" ";
shell = shell + "\"%1\"";
regShell->remove("Default");
regShell->setValue("Default", shell);
delete regIcon;
delete regShell;
delete regType;
// 通知系统刷新
#ifdef Q_OS_WIN32
//::SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST|SHCNF_FLUSH, 0, 0);
#endif
}
void MainWindow::on_table_kernel_add_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
{
if(currentRow == 0 && currentColumn == 0 && previousColumn == 0)
{
}
ui->table_kernel_add->removeCellWidget(previousRow , 7);
}
void MainWindow::on_table_kernel_block_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
{
if(currentRow == 0 && currentColumn == 0 && previousColumn == 0)
{
}
ui->table_kernel_block->removeCellWidget(previousRow , 5);
}
void MainWindow::on_table_kernel_patch_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
{
if(currentRow == 0 && currentColumn == 0 && previousColumn == 0)
{
}
ui->table_kernel_patch->removeCellWidget(previousRow , 13);
}
QString MainWindow::getSystemProductName(QString arg1)
{
QString str;
for(int i = 0; i < arg1.count(); i++)
{
if(arg1.mid(i , 1) == " ")
{
str = arg1.mid(0 , i).trimmed();
break;
}
}
return str;
}
void MainWindow::on_cboxSystemProductName_currentIndexChanged(const QString &arg1)
{
if(!loading && arg1 != "")
{
QFileInfo appInfo(qApp->applicationDirPath());
gs = new QProcess;
QString str = getSystemProductName(arg1);
ui->editSystemProductName->setText(str);
ui->editSystemProductName_2->setText(str);
#ifdef Q_OS_WIN32
// win
//QFile file(appInfo.filePath() + "/macserial.exe");
gs->start(appInfo.filePath() + "/macserial.exe" , QStringList() << "-m" << str);//阻塞为execute
#endif
#ifdef Q_OS_LINUX
// linux
gs->start(appInfo.filePath() + "/macserial" , QStringList() << "-m" << str);
#endif
#ifdef Q_OS_MAC
// mac
gs->start(appInfo.filePath() + "/macserial" , QStringList() << "-m" << str);
#endif
connect(gs , SIGNAL(finished(int)) , this , SLOT(readResult()));
//connect(gs , SIGNAL(readyRead()) , this , SLOT(readResult()));
}
}
void MainWindow::readResult()
{
QTextEdit *textMacInfo = new QTextEdit;
QTextCodec* gbkCodec = QTextCodec::codecForName("UTF-8");
textMacInfo->clear();
QString result = gbkCodec->toUnicode(gs->readAll());
textMacInfo->append(result);
//取第三行的数据,第一行留给提示用
QString str = textMacInfo->document()->findBlockByNumber(2).text().trimmed();
//qDebug() << result;
QString str1, str2;
for(int i = 0; i < str.count(); i++)
{
if(str.mid(i , 1) == "|")
{
str1 = str.mid(0 , i).trimmed();
str2 = str.mid(i + 1 , str.count() - i + 1).trimmed();
}
}
ui->editSystemSerialNumber->setText(str1);
ui->editSystemSerialNumber_data->setText(str1);
ui->editSystemSerialNumber_2->setText(str1);
ui->editMLB->setText(str2);
ui->editMLB_2->setText(str2);
on_btnSystemUUID_clicked();
}
void MainWindow::readResultSystemInfo()
{
ui->textMacInfo->clear();
QTextCodec* gbkCodec = QTextCodec::codecForName("UTF-8");
QString result = gbkCodec->toUnicode(si->readAll());
ui->textMacInfo->append(result);
//qDebug() << result;
}
void MainWindow::on_btnGenerate_clicked()
{
on_cboxSystemProductName_currentIndexChanged(ui->cboxSystemProductName->currentText());
}
void MainWindow::on_btnSystemUUID_clicked()
{
QUuid id = QUuid::createUuid();
QString strTemp = id.toString();
QString strId = strTemp.mid(1 , strTemp.count() - 2).toUpper();
ui->editSystemUUID->setText(strId);
ui->editSystemUUID_data->setText(strId);
ui->editSystemUUID_2->setText(strId);
}
void MainWindow::on_table_kernel_Force_cellClicked(int row, int column)
{
enabled_change(ui->table_kernel_Force , row , column , 7);
if(column == 8)
{
cboxArch = new QComboBox;
cboxArch->addItem("Any");
cboxArch->addItem("i386");
cboxArch->addItem("x86_64");
cboxArch->addItem("");
connect(cboxArch, SIGNAL(currentIndexChanged(QString)), this, SLOT(arch_ForceChange()));
c_row = row;
ui->table_kernel_Force->setCellWidget(row , column , cboxArch);
cboxArch->setCurrentText(ui->table_kernel_Force->item(row , 8)->text());
}
}
void MainWindow::on_table_kernel_Force_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
{
if(currentRow == 0 && currentColumn == 0 && previousColumn == 0)
{
}
ui->table_kernel_Force->removeCellWidget(previousRow , 8);
}
void MainWindow::on_btnKernelForce_Add_clicked()
{
QTableWidget *t = new QTableWidget;
t = ui->table_kernel_Force;
int row = t->rowCount() + 1;
t->setRowCount(row);
t->setItem(row - 1 , 0 , new QTableWidgetItem(""));
t->setItem(row - 1 , 1 , new QTableWidgetItem(""));
t->setItem(row - 1 , 2 , new QTableWidgetItem(""));
t->setItem(row - 1 , 3 , new QTableWidgetItem(""));
t->setItem(row - 1 , 4 , new QTableWidgetItem("Contents/Info.plist"));
t->setItem(row - 1 , 5 , new QTableWidgetItem(""));
t->setItem(row - 1 , 6 , new QTableWidgetItem(""));
init_enabled_data(t , row - 1 , 7 , "false");
QTableWidgetItem *newItem1 = new QTableWidgetItem("Any");
newItem1->setTextAlignment(Qt::AlignCenter);
t->setItem(row - 1 , 8 , newItem1);
}
void MainWindow::on_btnKernelForce_Del_clicked()
{
del_item(ui->table_kernel_Force);
}
void MainWindow::dragEnterEvent (QDragEnterEvent *e)
{
if (e->mimeData()->hasFormat("text/uri-list")) {
e->acceptProposedAction();
}
}
void MainWindow::dropEvent (QDropEvent *e)
{
QList<QUrl> urls = e->mimeData()->urls();
if (urls.isEmpty()) {
return;
}
QString fileName = urls.first().toLocalFile();
if (fileName.isEmpty()) {
return;
}
PlistFileName = fileName;
openFile(fileName);
}
#ifdef Q_OS_WIN32
void MainWindow::runAdmin(QString file, QString arg)
{
QString exePath = file;
WCHAR exePathArray[1024] = {0};
exePath.toWCharArray(exePathArray);
QString command = arg;//"-mount:*";//带参数运行
WCHAR commandArr[1024] = {0};
command.toWCharArray(commandArr);
HINSTANCE hNewExe = ShellExecute(NULL, L"runas", exePathArray, commandArr, NULL, SW_SHOWMAXIMIZED);//SW_NORMAL SW_SHOWMAXIMIZED
if(hNewExe){};
}
#endif
void MainWindow::mount_esp()
{
#ifdef Q_OS_WIN32
//di = new QProcess;
//di->execute("mountvol.exe", QStringList() << "x:" << "/s");//阻塞
QString exec = QCoreApplication::applicationDirPath() + "/FindESP.exe";
//runAdmin(exec, "-unmount:*");
runAdmin(exec, "-mount:*");//可选参数-Updater
QString exec2 = QCoreApplication::applicationDirPath() + "/winfile.exe";
runAdmin(exec2, NULL);//此时参数为空
#endif
#ifdef Q_OS_LINUX
#endif
#ifdef Q_OS_MAC
di = new QProcess;
di->start("diskutil" , QStringList() << "list");
connect(di , SIGNAL(finished(int)) , this , SLOT(readResultDiskInfo()));
#endif
}
void MainWindow::readResultDiskInfo()
{
ui->textDiskInfo->clear();
ui->textDiskInfo->setReadOnly(true);
QTextCodec* gbkCodec = QTextCodec::codecForName("UTF-8");
QString result = gbkCodec->toUnicode(di->readAll());
ui->textDiskInfo->append(result);
QString str0, str1, strEfiDisk;
int count = ui->textDiskInfo->document()->lineCount();
for(int i = 0; i < count; i++)
{
str0 = ui->textDiskInfo->document()->findBlockByNumber(i).text().trimmed();
str1 = str0.mid(3, str0.count() - 3).trimmed();
if(str1.mid(0, 3).toUpper() == "EFI")
{
strEfiDisk = str1.mid(str1.count() - 7, 7);
mount_esp_mac(strEfiDisk);
}
//qDebug() << strEfiDisk << str1;
}
}
void MainWindow::mount_esp_mac(QString strEfiDisk)
{
QString str5 = "diskutil mount " + strEfiDisk;
QString str_ex = "do shell script " + QString::fromLatin1("\"%1\"").arg(str5) + " with administrator privileges";
QString fileName = QDir::homePath() + "/qtocc.applescript";
QFile fi(fileName);
if(fi.exists())
fi.remove();
QSaveFile file(fileName);
QString errorMessage;
if (file.open(QFile::WriteOnly | QFile::Text)) {
QTextStream out(&file);
out << str_ex;
if (!file.commit()) {
errorMessage = tr("Cannot write file %1:\n%2.")
.arg(QDir::toNativeSeparators(fileName), file.errorString());
}
} else {
errorMessage = tr("Cannot open file %1 for writing:\n%2.")
.arg(QDir::toNativeSeparators(fileName), file.errorString());
}
QProcess *dm = new QProcess;
dm->execute("osascript", QStringList() << fileName);
}
void MainWindow::on_btnMountEsp_clicked()
{
mount_esp();
}
void MainWindow::closeEvent(QCloseEvent *event)
{
if(event){};
for(int i = 0; i < IniFile.count(); i++)
{
QFile file(IniFile.at(i));
//qDebug() << IniFile.at(i);
if(file.exists())
{
file.remove();
i = -1;
}
}
}
void MainWindow::on_table_uefi_ReservedMemory_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
{
if(currentRow == 0 && currentColumn == 0 && previousColumn == 0)
{
}
ui->table_uefi_ReservedMemory->removeCellWidget(previousRow , 3);
}
void MainWindow::loadLocal()
{
QTextCodec *codec = QTextCodec::codecForName("System");
QTextCodec::setCodecForLocale(codec);
static QTranslator translator; //该对象要一直存在,注意用static
QLocale locale;
if( locale.language() == QLocale::English ) //获取系统语言环境
{
zh_cn = false;
}
else if( locale.language() == QLocale::Chinese )
{
bool tr = false;
tr = translator.load(":/cn.qm");
if(tr)
{
qApp->installTranslator(&translator);
zh_cn = true;
}
ui->retranslateUi(this);
}
}
void MainWindow::on_btnHelp_clicked()
{
QFileInfo appInfo(qApp->applicationDirPath());
QString qtManulFile = appInfo.filePath() + "/Configuration.pdf";
QDesktopServices::openUrl(QUrl::fromLocalFile(qtManulFile));
}
void MainWindow::init_tr_str()
{
strArch = tr("Kext architecture (Any, i386, x86_64).");
strBundlePath = tr("Kext bundle path (e.g. Lilu.kext or MyKext.kext/Contents/PlugIns/MySubKext.kext).");
strComment = tr("Comment.");
strEnabled = tr("This kernel driver will not be added unless set to true.");
strExecutablePath = tr("Kext executable path relative to bundle (e.g. Contents/MacOS/Lilu).");
strMaxKernel = tr("Adds kernel driver on specified macOS version or older.");
strMinKernel = tr("Adds kernel driver on specified macOS version or newer.");
strPlistPath = tr(" Kext Info.plist path relative to bundle (e.g. Contents/Info.plist).");
}
void MainWindow::on_btnExportMaster_clicked()
{
QFileDialog fd;
QString defname;
int index = ui->tabTotal->currentIndex();
switch (index) {
case 0:defname = "ACPI";
break;
case 1:defname = "Booter";
break;
case 2:defname = "DeviceProperties";
break;
case 3:defname = "Kernel";
break;
case 4:defname = "Misc";
break;
case 5:defname = "NVRAM";
break;
case 6:defname = "PlatformInfo";
break;
case 7:defname = "UEFI";
}
QString FileName = fd.getSaveFileName(this,tr("Save File"), defname,tr("Config file(*.plist);;All files(*.*)"));
if(FileName.isEmpty())
return;
QVariantMap OpenCore;
switch (index) {
case 0:
OpenCore["ACPI"] = SaveACPI();
break;
case 1:OpenCore["Booter"] = SaveBooter();
break;
case 2:OpenCore["DeviceProperties"] = SaveDeviceProperties();
break;
case 3:OpenCore["Kernel"] = SaveKernel();
break;
case 4:OpenCore["Misc"] = SaveMisc();
break;
case 5:OpenCore["NVRAM"] = SaveNVRAM();
break;
case 6:OpenCore["PlatformInfo"] = SavePlatformInfo();
break;
case 7: OpenCore["UEFI"] = SaveUEFI();
break;
}
PListSerializer::toPList(OpenCore , FileName);
}
void MainWindow::on_btnImportMaster_clicked()
{
QFileDialog fd;
QString defname;
int index = ui->tabTotal->currentIndex();
switch (index) {
case 0:defname = "ACPI.plist";
break;
case 1:defname = "Booter.plist";
break;
case 2:defname = "DeviceProperties.plist";
break;
case 3:defname = "Kernel.plist";
break;
case 4:defname = "Misc.plist";
break;
case 5:defname = "NVRAM.plist";
break;
case 6:defname = "PlatformInfo.plist";
break;
case 7:defname = "UEFI.plist";
}
QString FileName = fd.getOpenFileName(this,tr("Open File"), defname,tr("Config file(*.plist);;All files(*.*)"));
if(FileName.isEmpty())
return;
loading = true;
QFile file(FileName);
QVariantMap map = PListParser::parsePList(&file).toMap();
switch (index) {
case 0:
//ACPI
ui->table_acpi_add->setRowCount(0);
ui->table_acpi_del->setRowCount(0);
ui->table_acpi_patch->setRowCount(0);
ParserACPI(map);
break;
case 1:
//Booter
ui->table_booter->setRowCount(0);
ParserBooter(map);
break;
case 2:
//DP
ui->table_dp_add0->setRowCount(0);
ui->table_dp_add->setRowCount(0);
ui->table_dp_del0->setRowCount(0);
ui->table_dp_del->setRowCount(0);
ParserDP(map);
break;
case 3:
//Kernel
ui->table_kernel_add->setRowCount(0);
ui->table_kernel_block->setRowCount(0);
ui->table_kernel_Force->setRowCount(0);
ui->table_kernel_patch->setRowCount(0);
ParserKernel(map);
break;
case 4:
//Misc
ui->tableBlessOverride->setRowCount(0);
ui->tableEntries->setRowCount(0);
ui->tableTools->setRowCount(0);
ParserMisc(map);
break;
case 5:
//NVRAM
ui->table_nv_add0->setRowCount(0);
ui->table_nv_add->setRowCount(0);
ui->table_nv_del0->setRowCount(0);
ui->table_nv_del->setRowCount(0);
ui->table_nv_ls0->setRowCount(0);
ui->table_nv_ls->setRowCount(0);
ParserNvram(map);
break;
case 6:
ParserPlatformInfo(map);
break;
case 7:
//UEFI
ui->table_uefi_drivers->setRowCount(0);
ui->table_uefi_ReservedMemory->setRowCount(0);
ParserUEFI(map);
break;
}
loading = false;
}
void MainWindow::on_tabTotal_tabBarClicked(int index)
{
switch (index) {
case 0:
ui->btnExportMaster->setText(tr("Export") + " ACPI");
ui->btnImportMaster->setText(tr("Import") + " ACPI");
break;
case 1:
ui->btnExportMaster->setText(tr("Export") + " Booter");
ui->btnImportMaster->setText(tr("Import") + " Booter");
break;
case 2:
ui->btnExportMaster->setText(tr("Export") + " DeviceProperties");
ui->btnImportMaster->setText(tr("Import") + " DeviceProperties");
break;
case 3:
ui->btnExportMaster->setText(tr("Export") + " Kernel");
ui->btnImportMaster->setText(tr("Import") + " Kernel");
break;
case 4:
ui->btnExportMaster->setText(tr("Export") + " Misc");
ui->btnImportMaster->setText(tr("Import") + " Misc");
break;
case 5:
ui->btnExportMaster->setText(tr("Export") + " NVRAM");
ui->btnImportMaster->setText(tr("Import") + " NVRAM");
break;
case 6:
ui->btnExportMaster->setText(tr("Export") + " PlatformInfo");
ui->btnImportMaster->setText(tr("Import") + " PlatformInfo");
break;
case 7:
ui->btnExportMaster->setText(tr("Export") + " UEFI");
ui->btnImportMaster->setText(tr("Import") + " UEFI");
break;
}
}
void MainWindow::on_tabTotal_currentChanged(int index)
{
on_tabTotal_tabBarClicked(index);
}
void MainWindow::on_btnDevices_add_clicked()
{
add_item(ui->tableDevices, 8);
}
void MainWindow::on_btnDevices_del_clicked()
{
del_item(ui->tableDevices);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/btwise/qtocc.git
git@gitee.com:btwise/qtocc.git
btwise
qtocc
qtocc
master

搜索帮助