Class: Idb::AppListDialog

Inherits:
Qt::Dialog
  • Object
show all
Defined in:
lib/gui/app_list_dialog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ AppListDialog

Returns a new instance of AppListDialog.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/gui/app_list_dialog.rb', line 6

def initialize(*args)
  super(*args)

  setWindowTitle("App Selection")
  @layout = Qt::GridLayout.new
  setLayout(@layout)

  @app_list = Qt::ListWidget.new self
  @app_list.setSortingEnabled(true)
  @app_list.connect(SIGNAL('itemDoubleClicked(QListWidgetItem*)')) do |_item|
    emit accept
  end
  @layout.addWidget @app_list, 0, 0, 1, 2

  @save_button = Qt::PushButton.new "Select"
  @save_button.setDefault true

  @save_button.connect(SIGNAL(:released)) do |_x|
    accept
  end
  @cancel_button = Qt::PushButton.new "Cancel"
  @cancel_button.connect(SIGNAL(:released)) do |_x|
    reject
  end

  @save_button.setEnabled(false) unless refresh_app_list

  @layout.addWidget @save_button, 1, 1
  @layout.addWidget @cancel_button, 1, 0

  setFixedHeight(500)
  setFixedWidth(400)
end

Instance Attribute Details

#app_listObject

Returns the value of attribute app_list.



4
5
6
# File 'lib/gui/app_list_dialog.rb', line 4

def app_list
  @app_list
end

Instance Method Details

#refresh_app_listObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/gui/app_list_dialog.rb', line 40

def refresh_app_list
  if $device.ios_version >= 8 && $device.ios_version != 10
    refresh_msg = "Refreshing uicache to ensure app information is" \
                  "up-to-date. This may take a few seconds."
    box = Qt::MessageBox.new 1, "Refreshing...", refresh_msg
    box.setStandardButtons(0)
    box.show
    box.raise
    # need to refresh iOS uicache in case app was installed after last reboot.
    # Otherwise /var/mobile/Library/MobileInstallation/LastLaunchServicesMap.plist
    # will be out of date
    $device.ops.execute "/bin/su mobile -c /usr/bin/uicache"
    box.hide
  end

  begin
    app_uuids = $device.app_uuids
  rescue StandardError
    error = Qt::MessageBox.new
    msg = "Unable to get list of applications. Ensure that " \
          "you have at least one non-system app installed."
    error.setInformativeText(msg)
    error.setIcon(Qt::MessageBox::Critical)
    error.exec
    return false
  end

  progress = Qt::ProgressDialog.new "Reading App list...", nil, 1, app_uuids.size, self
  progress.setAutoClose true
  progress.setWindowModality(Qt::WindowModal)
  progress.show
  progress.raise

  app_uuids.each do |uuid|
    a = App.new uuid

    i = AppListWidgetItem.new @app_list, 0
    i.setText(a.bundle_id.to_s + " => " + a.bundle_name.to_s)
    i.app = a
    @app_list.add_item i
    progress.setValue(progress.value + 1)
  end
end