1
#!/usr/bin/env ruby -wKU
6
raise "Pass toolbars-state data as argument." if ARGV.length != 1
7
data = Base64.decode64(ARGV[0])
9
$toolBarStateMarker = 0xfe
10
$toolBarStateMarkerEx = 0xfc
11
$dockWidgetStateMarker = 0xfd
19
def unpack(format, byte_length)
20
result = @data.unpack("@#{@offset}#{format}")
21
@offset += byte_length
26
bytes = unpack("N", 4)[0]
27
return "" if bytes == 0xffffffff
29
Iconv.open('UTF-8', 'UCS-2BE') do |cd|
30
result = cd.iconv(@data[@offset, bytes])
39
max_unsigned = 2**length
40
(num >= mid) ? num - max_unsigned : num
43
def unpackRect(geom0, geom1)
50
x = (geom0 & 0x0000ffff) - 0x7FFF
51
y = (geom1 & 0x0000ffff) - 0x7FFF
56
w = geom0 & 0x0000ffff;
57
h = geom1 & 0x0000ffff;
60
return "(x:#{x} y:#{y} w:#{w} h:#{h} floating:#{floating != 0 ? 'true' : 'false'})"
63
def toolBarAreaName(pos)
72
def toolBarAreaLayoutRestoreState(tmarker)
73
lines = unpack("N", 4)[0]
74
(0...lines).each do |j|
75
pos = unpack("N", 4)[0]
76
cnt = unpack("N", 4)[0]
78
objectName = readQString
79
shown = unpack("C", 1)[0]
80
item_pos = unpack("N", 4)[0]
81
item_size = unpack("N", 4)[0]
82
geom0 = unpack("N", 4)[0]
85
if tmarker == $toolBarStateMarkerEx
86
geom1 = unpack("N", 4)[0]
87
rect = unpackRect(geom0, geom1)
90
puts "\tpos: #{toolBarAreaName(pos)}"
91
puts "\tshown: #{shown != 0 ? 'true' : 'false'}"
92
puts "\titem_pos: #{item_pos}"
93
puts "\titem_size: #{item_size}"
94
puts "\trect: #{rect}"
99
def dockAreaLayoutRestoreState
100
puts "dockAreaLayoutRestoreState:"
101
cnt = unpack("N", 4)[0]
102
(0...cnt).each do |i|
106
width, height = unpack("NN", 8)
107
puts "\tcentralWidgetRect = #{width} x #{height}"
110
puts "\tcornerData[#{i}] = #{unpack('N', 4)}"
115
marker, version = unpack("NN", 8)
116
raise "Incompatible format: #{marker}, #{version}" if marker != 0xff or version != 0
119
marker = unpack("C", 1)[0]
122
when $toolBarStateMarker, $toolBarStateMarkerEx
123
# puts "toolBarAreaLayoutRestoreState"
124
toolBarAreaLayoutRestoreState(marker)
125
when $dockWidgetStateMarker
126
# puts "dockAreaLayoutRestoreState"
127
dockAreaLayoutRestoreState
130
break if @offset >= @data.length
135
MainWinState.new(data).restoreState