Refactor II + init work for context menu

This commit is contained in:
Alvaro Muñoz 2017-04-06 23:55:40 +02:00
parent b2bebb9821
commit 610ab0d7de
8 changed files with 110 additions and 15159 deletions

View File

@ -18,8 +18,6 @@
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/r2ui.js"></script> <script type="text/javascript" src="qrc:/graph/html/graph/lib/js/r2ui.js"></script>
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/disasm.js"></script> <script type="text/javascript" src="qrc:/graph/html/graph/lib/js/disasm.js"></script>
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/jquery-1.9.0.js"></script> <script type="text/javascript" src="qrc:/graph/html/graph/lib/js/jquery-1.9.0.js"></script>
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/jquery-ui-latest.js"></script>
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/jquery.scrollTo-latest.js"></script>
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/graph_panel.js"></script> <script type="text/javascript" src="qrc:/graph/html/graph/lib/js/graph_panel.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready( function() { $(document).ready( function() {
@ -29,8 +27,10 @@
// Initialize and render graph // Initialize and render graph
r2ui.graph_panel = new GraphPanel(); r2ui.graph_panel = new GraphPanel();
r2ui.graph_panel.set_theme("light");
r2ui.graph_panel.seek(location.hash.substring(1)); r2ui.graph_panel.seek(location.hash.substring(1));
r2ui.graph_panel.init_handlers();
//r2ui.graph_panel.init_context_menu();
r2ui.graph_panel.render("light");
}); });
</script> </script>
</head> </head>

View File

@ -178,7 +178,7 @@ BBGraph.prototype.render = function() {
$("#minimap").css("left", $("#main_panel").width() - minimap_width); $("#minimap").css("left", $("#main_panel").width() - minimap_width);
$("#minimap").css("top", $("#center_panel").position().top - 40); $("#minimap").css("top", $("#center_panel").position().top - 40);
$("#center_panel").bind('scroll', update_minimap); //$("#center_panel").bind('scroll', update_minimap);
paper.on( "cell:pointerup", function( cellview, evt, x, y) { paper.on( "cell:pointerup", function( cellview, evt, x, y) {
var model = cellview.model; var model = cellview.model;
@ -209,10 +209,10 @@ BBGraph.prototype.render = function() {
if (delta_x < 0) delta_x = 0; if (delta_x < 0) delta_x = 0;
if (delta_y < 0) delta_y = 0; if (delta_y < 0) delta_y = 0;
if ($("#radareApp_mp").length) { if ($("#radareApp_mp").length) {
$("#main_panel").scrollTo({ top:delta_y, left:delta_x - delta/scale } ); //$("#main_panel").scrollTo({ top:delta_y, left:delta_x - delta/scale } );
console.log(1); console.log(1);
} else { } else {
$('#center_panel').scrollTo({ top:delta_y, left:delta_x - delta/scale } ); //$('#center_panel').scrollTo({ top:delta_y, left:delta_x - delta/scale } );
console.log('debug:'); console.log('debug:');
console.log(delta_y, delta_x, scale); console.log(delta_y, delta_x, scale);
console.log($('#center_panel')); console.log($('#center_panel'));
@ -849,39 +849,39 @@ Element.prototype.documentOffsetTop = function () {
return this.offsetTop + ( this.offsetParent ? this.offsetParent.documentOffsetTop() : 0 ); return this.offsetTop + ( this.offsetParent ? this.offsetParent.documentOffsetTop() : 0 );
}; };
function scroll_to_address(address) { // function scroll_to_address(address) {
var elements = $(".insaddr.addr_" + address); // var elements = $(".insaddr.addr_" + address);
var top = elements[0].documentOffsetTop() - window.innerHeight / 2; // var top = elements[0].documentOffsetTop() - window.innerHeight / 2;
top = Math.max(0,top); // top = Math.max(0,top);
$("#main_panel").scrollTo({'top':top, 'left':0}); // $("#main_panel").scrollTo({'top':top, 'left':0});
} // }
function has_scrollbar(divnode) { // function has_scrollbar(divnode) {
if(divnode.scrollHeight > divnode.clientHeight) return true; // if(divnode.scrollHeight > divnode.clientHeight) return true;
return false; // return false;
} // }
function on_scroll(event) { // function on_scroll(event) {
if (!r2ui.graph_panel.scrolling) { // if (!r2ui.graph_panel.scrolling) {
var panel_disas = $("#main_panel").tabs("option", "active") === 0 ? true : false; // var panel_disas = $("#main_panel").tabs("option", "active") === 0 ? true : false;
event.preventDefault(); // event.preventDefault();
} // }
} // }
function scroll_to_element(element) { // function scroll_to_element(element) {
if (element === undefined || element === null) return; // if (element === undefined || element === null) return;
var top = Math.max(0,element.documentOffsetTop() - ( window.innerHeight / 2 )); // var top = Math.max(0,element.documentOffsetTop() - ( window.innerHeight / 2 ));
$('#center_panel').scrollTo(top, {axis: 'y'}); // $('#center_panel').scrollTo(top, {axis: 'y'});
r2ui.graph_panel.scroll_offset = top; // r2ui.graph_panel.scroll_offset = top;
} // }
//
function store_scroll_offset() { // function store_scroll_offset() {
r2ui.graph_panel.scroll_offset = $('#center_panel').scrollTop(); // r2ui.graph_panel.scroll_offset = $('#center_panel').scrollTop();
} // }
//
function scroll_to_last_offset() { // function scroll_to_last_offset() {
if (r2ui.graph_panel.scroll_offset !== null) $('#center_panel').scrollTo(r2ui.graph_panel.scroll_offset, {axis: 'y'}); // if (r2ui.graph_panel.scroll_offset !== null) $('#center_panel').scrollTo(r2ui.graph_panel.scroll_offset, {axis: 'y'});
} // }
function rename(offset, old_value, new_value, space) { function rename(offset, old_value, new_value, space) {
if (space === undefined) space = "functions"; if (space === undefined) space = "functions";

View File

@ -1,4 +1,3 @@
// Graph Panel // Graph Panel
var GraphPanel = function () { var GraphPanel = function () {
this.graph = null; this.graph = null;
@ -13,24 +12,27 @@ var GraphPanel = function () {
this.renameOldValue = ""; this.renameOldValue = "";
this.rbox = null; this.rbox = null;
this.panel = $("#disasm_tab")[0]; this.panel = $("#disasm_tab")[0];
this.scroll_offset = null;
this.minimap = true; this.minimap = true;
this.instructions = []; this.instructions = [];
this.scrolling = false; //this.scroll_offset = null;
//this.scrolling = false;
}; };
GraphPanel.prototype.render = function(mode) { GraphPanel.prototype.init_handlers = function() {
// Unbind mouse and key events from document
$("#center_panel").unbind("click");
$(document).unbind("keypress");
$(document).unbind("click");
$(document).unbind("dblclick");
$("#center_panel").unbind( "click" ); // Bind custom functions to mouse and key events
$(document).unbind( "keypress" ); //$("#center_panel").scroll(on_scroll);
$(document).unbind( "click" );
$(document).unbind( "dblclick" );
$("#center_panel").scroll(on_scroll);
$(document).keypress(handleKeypress); $(document).keypress(handleKeypress);
$(document).click(handleClick); $(document).click(handleClick);
$(document).dblclick(handleDoubleClick); $(document).dblclick(handleDoubleClick);
};
GraphPanel.prototype.init_context_menu = function() {
// Context menu for disas addresses: // Context menu for disas addresses:
$(document).contextmenu({ $(document).contextmenu({
delegate: ".addr", delegate: ".addr",
@ -158,8 +160,25 @@ GraphPanel.prototype.render = function(mode) {
} }
}); });
};
GraphPanel.prototype.render = function(theme) {
// Set theme
if (theme === "dark") {
document.getElementById('dark_theme').disabled = false;
document.getElementById('light_theme').disabled = true;
} else if (theme === "light") {
document.getElementById('dark_theme').disabled = true;
document.getElementById('light_theme').disabled = false;
}
r2ui.load_colors();
// Show graph and seek to entrypoint // Show graph and seek to entrypoint
this.display_graph(); $("#main_panel").removeClass("ec_gui_background");
$("#main_panel").addClass("ec_gui_alt_background");
if ($('#minimap').length) $('#minimap')[0].innerHTML = "";
var addr = null; var addr = null;
if (this.selected_offset !== null) { if (this.selected_offset !== null) {
addr = this.selected_offset; addr = this.selected_offset;
@ -172,18 +191,21 @@ GraphPanel.prototype.render = function(mode) {
} else { } else {
addr = r2.get_flag_address(addr); addr = r2.get_flag_address(addr);
} }
scroll_to_address(addr); //scroll_to_address(addr);
}; };
GraphPanel.prototype.set_theme = function(theme) { GraphPanel.prototype.getElementsUnderCursor = function() {
if (theme === "dark") { var elements = document.querySelectorAll(':hover');
document.getElementById('dark_theme').disabled = false; var index;
document.getElementById('light_theme').disabled = true; for (index = 0; index < elements.length; ++index) {
} else if (theme === "light") { var element = elements[index];
document.getElementById('dark_theme').disabled = true;
document.getElementById('light_theme').disabled = false; // Look for an offset item
if (element.className.indexOf("addr") > 0 && element.className.indexOf("ec_offset") > 0) {
return "{'offset':'" + element.innerText + "'}";
}
} }
r2ui.load_colors(); return "{}";
} }
GraphPanel.prototype.seek = function(addr, scroll) { GraphPanel.prototype.seek = function(addr, scroll) {
@ -201,12 +223,6 @@ GraphPanel.prototype.seek = function(addr, scroll) {
rehighlight_iaddress(addr); rehighlight_iaddress(addr);
}; };
GraphPanel.prototype.display_graph = function() {
$("#main_panel").removeClass("ec_gui_background");
$("#main_panel").addClass("ec_gui_alt_background");
if ($('#minimap').length) $('#minimap')[0].innerHTML = "";
};
GraphPanel.prototype.goToAddress = function() { GraphPanel.prototype.goToAddress = function() {
if (this.renaming === null && this.selected !== null && (this.selected.className.indexOf(" addr ") > -1)) { if (this.renaming === null && this.selected !== null && (this.selected.className.indexOf(" addr ") > -1)) {
var address = get_address_from_class(this.selected); var address = get_address_from_class(this.selected);
@ -250,27 +266,27 @@ GraphPanel.prototype.handleInputTextChange = function() {
var address = get_address_from_class(instruction); var address = get_address_from_class(instruction);
update_binary_details(); update_binary_details();
r2ui.seek(address, false); r2ui.seek(address, false);
scroll_to_address(address); //scroll_to_address(address);
} }
}; };
function scroll_to_address(address, pos) { // function scroll_to_address(address, pos) {
if (address === undefined || address === null) return; // if (address === undefined || address === null) return;
var offset = 0; // var offset = 0;
if (pos == "top") offset = $('#center_panel').height(); // if (pos == "top") offset = $('#center_panel').height();
else if (pos == "bottom") offset = 0; // else if (pos == "bottom") offset = 0;
else offset = window.innerHeight / 2; // else offset = window.innerHeight / 2;
var elements = $(".insaddr.addr_" + address); // var elements = $(".insaddr.addr_" + address);
if (elements === undefined || elements === null) return; // if (elements === undefined || elements === null) return;
if (elements[0] === undefined || elements[0] === null) return; // if (elements[0] === undefined || elements[0] === null) return;
var top = elements[0].documentOffsetTop() - offset; // var top = elements[0].documentOffsetTop() - offset;
top = Math.max(0,top); // top = Math.max(0,top);
$('#center_panel').scrollTo(top, {axis: 'y'}); // $('#center_panel').scrollTo(top, {axis: 'y'});
r2ui.graph_panel.scroll_offset = top; // r2ui.graph_panel.scroll_offset = top;
} // }
function handleClick(inEvent) { function handleClick(inEvent) {
console.log("CLICK!")
if ($(inEvent.target).hasClass('addr')) { if ($(inEvent.target).hasClass('addr')) {
if ($(inEvent.target).hasClass('history')) { if ($(inEvent.target).hasClass('history')) {
var idx = inEvent.target.className.split(" ").filter(function(x) { return x.substr(0,"history_idx_".length) == "history_idx_"; }); var idx = inEvent.target.className.split(" ").filter(function(x) { return x.substr(0,"history_idx_".length) == "history_idx_"; });
@ -302,7 +318,7 @@ function handleClick(inEvent) {
if (get_more_instructions) { if (get_more_instructions) {
r2ui.seek(address, false); r2ui.seek(address, false);
rehighlight_iaddress(address); rehighlight_iaddress(address);
scroll_to_address(address); //scroll_to_address(address);
} }
} }
} else if ($(inEvent.target).hasClass('fvar') || $(inEvent.target).hasClass('farg')) { } else if ($(inEvent.target).hasClass('fvar') || $(inEvent.target).hasClass('farg')) {
@ -320,6 +336,7 @@ function handleClick(inEvent) {
} }
function handleDoubleClick (inEvent) { function handleDoubleClick (inEvent) {
console.log("DOUBLE CLICK!")
if ($(inEvent.target).hasClass('addr') && !$(inEvent.target).hasClass('insaddr')) { if ($(inEvent.target).hasClass('addr') && !$(inEvent.target).hasClass('insaddr')) {
var address = get_address_from_class(inEvent.target); var address = get_address_from_class(inEvent.target);
do_jumpto(address); do_jumpto(address);
@ -328,6 +345,7 @@ function handleDoubleClick (inEvent) {
// key handler // key handler
function handleKeypress(inEvent) { function handleKeypress(inEvent) {
console.log("KEYPRESS!")
var keynum = inEvent.keyCode || inEvent.charCode || inEvent.which || 0; var keynum = inEvent.keyCode || inEvent.charCode || inEvent.which || 0;
var key = String.fromCharCode(keynum); var key = String.fromCharCode(keynum);
@ -364,7 +382,7 @@ function handleKeypress(inEvent) {
r2ui.graph_panel.selected_offset = address; r2ui.graph_panel.selected_offset = address;
} }
rehighlight_iaddress(address); rehighlight_iaddress(address);
scroll_to_address(address); //scroll_to_address(address);
} }
} }
// k Seek to previous instruction // k Seek to previous instruction
@ -387,7 +405,7 @@ function handleKeypress(inEvent) {
r2ui.graph_panel.selected_offset = address; r2ui.graph_panel.selected_offset = address;
} }
rehighlight_iaddress(address); rehighlight_iaddress(address);
scroll_to_address(address); //scroll_to_address(address);
} }
} }
// c Define function // c Define function
@ -420,7 +438,7 @@ function handleKeypress(inEvent) {
// go back in history // go back in history
var addr = r2ui.history_prev(); var addr = r2ui.history_prev();
if (addr !== undefined && addr !== null) r2ui.seek(addr, false); if (addr !== undefined && addr !== null) r2ui.seek(addr, false);
scroll_to_address(addr); //scroll_to_address(addr);
} }
} }
// enter // enter
@ -439,7 +457,7 @@ function do_jumpto(address) {
r2ui.seek(address, true); r2ui.seek(address, true);
} }
rehighlight_iaddress(address); rehighlight_iaddress(address);
scroll_to_address(address); //scroll_to_address(address);
} }
function do_rename(element, inEvent) { function do_rename(element, inEvent) {
@ -456,9 +474,9 @@ function do_rename(element, inEvent) {
var new_name = prompt('New name', old_value); var new_name = prompt('New name', old_value);
if (new_name !== null) { if (new_name !== null) {
rename(address, old_value, new_name, space); rename(address, old_value, new_name, space);
store_scroll_offset(); //store_scroll_offset();
r2ui.seek("$$", false); r2ui.seek("$$", false);
scroll_to_last_offset(); //scroll_to_last_offset();
} }
} else if (r2ui.graph_panel.renaming === null && element !== null && $(element).hasClass("addr")) { } else if (r2ui.graph_panel.renaming === null && element !== null && $(element).hasClass("addr")) {
r2ui.graph_panel.selected = element; r2ui.graph_panel.selected = element;
@ -511,7 +529,7 @@ function do_comment(element) {
if (c !== null) { if (c !== null) {
r2.cmd('CC ' + c + " @ " + address); r2.cmd('CC ' + c + " @ " + address);
r2ui.seek(address, false); r2ui.seek(address, false);
scroll_to_address(address); //scroll_to_address(address);
} }
} }
@ -521,7 +539,7 @@ function do_undefine(element) {
r2.update_flags(); r2.update_flags();
update_binary_details(); update_binary_details();
r2ui.seek(address, false); r2ui.seek(address, false);
scroll_to_address(address); //scroll_to_address(address);
} }
function do_define(element) { function do_define(element) {
@ -532,6 +550,6 @@ function do_define(element) {
r2.update_flags(); r2.update_flags();
update_binary_details(); update_binary_details();
r2ui.seek(address, false); r2ui.seek(address, false);
scroll_to_address(address); //scroll_to_address(address);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,187 +0,0 @@
/*!
* jQuery.scrollTo
* Copyright (c) 2007-2014 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
* Licensed under MIT
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
* @projectDescription Easy element scrolling using jQuery.
* @author Ariel Flesler
* @version 1.4.14
*/
;(function (define) {
'use strict';
define(['jquery'], function ($) {
var $scrollTo = $.scrollTo = function( target, duration, settings ) {
return $(window).scrollTo( target, duration, settings );
};
$scrollTo.defaults = {
axis:'xy',
duration: 0,
limit:true
};
// Returns the element that needs to be animated to scroll the window.
// Kept for backwards compatibility (specially for localScroll & serialScroll)
$scrollTo.window = function( scope ) {
return $(window)._scrollable();
};
// Hack, hack, hack :)
// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
$.fn._scrollable = function() {
return this.map(function() {
var elem = this,
isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1;
if (!isWin)
return elem;
var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;
return /webkit/i.test(navigator.userAgent) || doc.compatMode == 'BackCompat' ?
doc.body :
doc.documentElement;
});
};
$.fn.scrollTo = function( target, duration, settings ) {
if (typeof duration == 'object') {
settings = duration;
duration = 0;
}
if (typeof settings == 'function')
settings = { onAfter:settings };
if (target == 'max')
target = 9e9;
settings = $.extend( {}, $scrollTo.defaults, settings );
// Speed is still recognized for backwards compatibility
duration = duration || settings.duration;
// Make sure the settings are given right
settings.queue = settings.queue && settings.axis.length > 1;
if (settings.queue)
// Let's keep the overall duration
duration /= 2;
settings.offset = both( settings.offset );
settings.over = both( settings.over );
return this._scrollable().each(function() {
// Null target yields nothing, just like jQuery does
if (target == null) return;
var elem = this,
$elem = $(elem),
targ = target, toff, attr = {},
win = $elem.is('html,body');
switch (typeof targ) {
// A number will pass the regex
case 'number':
case 'string':
if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
targ = both( targ );
// We are done
break;
}
// Relative/Absolute selector, no break!
targ = win ? $(targ) : $(targ, this);
if (!targ.length) return;
case 'object':
// DOMElement / jQuery
if (targ.is || targ.style)
// Get the real position of the target
toff = (targ = $(targ)).offset();
}
var offset = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset;
$.each( settings.axis.split(''), function( i, axis ) {
var Pos = axis == 'x' ? 'Left' : 'Top',
pos = Pos.toLowerCase(),
key = 'scroll' + Pos,
old = elem[key],
max = $scrollTo.max(elem, axis);
if (toff) {// jQuery / DOMElement
attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );
// If it's a dom element, reduce the margin
if (settings.margin) {
attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
}
attr[key] += offset[pos] || 0;
if(settings.over[pos])
// Scroll to a fraction of its width/height
attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos];
} else {
var val = targ[pos];
// Handle percentage values
attr[key] = val.slice && val.slice(-1) == '%' ?
parseFloat(val) / 100 * max
: val;
}
// Number or 'number'
if (settings.limit && /^\d+$/.test(attr[key]))
// Check the limits
attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max );
// Queueing axes
if (!i && settings.queue) {
// Don't waste time animating, if there's no need.
if (old != attr[key])
// Intermediate animation
animate( settings.onAfterFirst );
// Don't animate this axis again in the next iteration.
delete attr[key];
}
});
animate( settings.onAfter );
function animate( callback ) {
$elem.animate( attr, duration, settings.easing, callback && function() {
callback.call(this, targ, settings);
});
}
}).end();
};
// Max scrolling position, works on quirks mode
// It only fails (not too badly) on IE, quirks mode.
$scrollTo.max = function( elem, axis ) {
var Dim = axis == 'x' ? 'Width' : 'Height',
scroll = 'scroll'+Dim;
if (!$(elem).is('html,body'))
return elem[scroll] - $(elem)[Dim.toLowerCase()]();
var size = 'client' + Dim,
html = elem.ownerDocument.documentElement,
body = elem.ownerDocument.body;
return Math.max( html[scroll], body[scroll] ) - Math.min( html[size] , body[size] );
};
function both( val ) {
return $.isFunction(val) || $.isPlainObject(val) ? val : { top:val, left:val };
}
// AMD requirement
return $scrollTo;
})
}(typeof define === 'function' && define.amd ? define : function (deps, factory) {
if (typeof module !== 'undefined' && module.exports) {
// Node
module.exports = factory(require('jquery'));
} else {
factory(jQuery);
}
}));

View File

@ -30,7 +30,6 @@ r2ui.load_colors = function () {
} }
} }
} }
console.log(r2ui.colors)
}; };
// Basic Blocks // Basic Blocks

View File

@ -82,8 +82,6 @@
<file>html/graph/lib/js/joint.js</file> <file>html/graph/lib/js/joint.js</file>
<file>html/graph/lib/js/joint.layout.DirectedGraph.js</file> <file>html/graph/lib/js/joint.layout.DirectedGraph.js</file>
<file>html/graph/lib/js/jquery-1.9.0.js</file> <file>html/graph/lib/js/jquery-1.9.0.js</file>
<file>html/graph/lib/js/jquery-ui-latest.js</file>
<file>html/graph/lib/js/jquery.scrollTo-latest.js</file>
<file>html/graph/lib/js/r2.js</file> <file>html/graph/lib/js/r2.js</file>
<file>html/graph/lib/js/r2ui.js</file> <file>html/graph/lib/js/r2ui.js</file>
</qresource> </qresource>

View File

@ -68,6 +68,8 @@ MemoryWidget::MemoryWidget(MainWindow *main, QWidget *parent) :
// Hide graph webview scrollbars // Hide graph webview scrollbars
ui->graphWebView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); ui->graphWebView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
ui->graphWebView->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); ui->graphWebView->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
// Debug console
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
// Add margin to function name line edit // Add margin to function name line edit
@ -1728,7 +1730,7 @@ void MemoryWidget::frameLoadFinished(bool ok) {
if (ok) { if (ok) {
QSettings settings; QSettings settings;
if (settings.value("dark").toBool()) { if (settings.value("dark").toBool()) {
QString js = "r2ui.graph_panel.set_theme('dark');"; QString js = "r2ui.graph_panel.render('dark');";
ui->graphWebView->page()->mainFrame()->evaluateJavaScript(js); ui->graphWebView->page()->mainFrame()->evaluateJavaScript(js);
} }
} }