Restore GUI comportement.

This commit is contained in:
Glenn Y. Rolland 2015-09-02 16:38:09 +02:00
parent 042e324632
commit ac9f89c6de
3 changed files with 21 additions and 20 deletions

View file

@ -66,6 +66,7 @@ module Qasim
super super
@active_maps = nil @active_maps = nil
@config = Config.new @config = Config.new
#@config.parse
@map_manager = MapManager.new @config @map_manager = MapManager.new @config
@map_manager.parse_maps @map_manager.parse_maps
end end

View file

@ -12,7 +12,7 @@ module Qasim
def initialize def initialize
@config = Config.new @config = Config.new
#@config.parse_cmd_line ARGV @map_manager = MapManager.new @config
@map_menu = nil @map_menu = nil
@context_menu = nil @context_menu = nil
@ -38,7 +38,7 @@ module Qasim
) )
msg.arguments = [ APP_NAME, Qt::Variant.from_value( 0, "unsigned int" ), msg.arguments = [ APP_NAME, Qt::Variant.from_value( 0, "unsigned int" ),
icon, title, body, [], {}, -1 ] icon, title, body, [], {}, -1 ]
rep = bus.call( msg ) _rep = bus.call( msg )
# if rep.type == Qt::DBusMessage # if rep.type == Qt::DBusMessage
# si.showMessage("Qasim", # si.showMessage("Qasim",
@ -51,12 +51,12 @@ module Qasim
# #
def build_map_menu def build_map_menu
# reload maps dynamically # reload maps dynamically
@config.parse_maps @map_manager.parse_maps
@map_menu ||= Qt::Menu.new @map_menu ||= Qt::Menu.new
@map_menu.clear @map_menu.clear
previous_host = nil previous_host = nil
@config.maps.sort do |mx,my| @map_manager.sort do |mx,my|
mx.host <=> my.host mx.host <=> my.host
end.each do |map| end.each do |map|
if map.host != previous_host and not previous_host.nil? then if map.host != previous_host and not previous_host.nil? then
@ -64,7 +64,7 @@ module Qasim
end end
itemx = Qt::Action.new(map.name, @map_menu) itemx = Qt::Action.new(map.name, @map_menu)
itemx.setCheckable true; itemx.setCheckable true;
if map.connected? then if map.mounted? then
itemx.setChecked true itemx.setChecked true
end end
itemx.connect(SIGNAL(:triggered)) do itemx.connect(SIGNAL(:triggered)) do
@ -131,7 +131,7 @@ module Qasim
act_pref.setIconVisibleInMenu true act_pref.setIconVisibleInMenu true
act_pref.setEnabled false act_pref.setEnabled false
act_pref.connect(SIGNAL(:triggered)) do act_pref.connect(SIGNAL(:triggered)) do
res = @pref_dialog.show _res = @pref_dialog.show
end end
@context_menu.addAction act_pref; @context_menu.addAction act_pref;
@ -140,7 +140,7 @@ module Qasim
act_about.setIconVisibleInMenu true act_about.setIconVisibleInMenu true
#act_about.setEnabled true #act_about.setEnabled true
act_about.connect(SIGNAL(:triggered)) do act_about.connect(SIGNAL(:triggered)) do
res = @about_dialog.show _res = @about_dialog.show
end end
@context_menu.addAction act_about; @context_menu.addAction act_about;
@ -170,8 +170,8 @@ module Qasim
@pref_dialog = Qasim::Ui::Preferences.new @main_win @pref_dialog = Qasim::Ui::Preferences.new @main_win
std_icon = Qt::Icon.new( ":/qasim/qasim-icon" ) std_icon = Qt::Icon.new( ":/qasim/qasim-icon" )
alt_icon = Qt::Icon.new _alt_icon = Qt::Icon.new
blinking = false _blinking = false
@systray.icon = std_icon @systray.icon = std_icon
@systray.show @systray.show
@ -205,7 +205,7 @@ module Qasim
def lock_set def lock_set
begin begin
# create an exclusive lock file # create an exclusive lock file
have_lock = true _have_lock = true
FileUtils.mkdir_p APP_CONFIG_DIR unless File.exist? APP_CONFIG_DIR FileUtils.mkdir_p APP_CONFIG_DIR unless File.exist? APP_CONFIG_DIR
lockfname = File.join APP_CONFIG_DIR, "lock" lockfname = File.join APP_CONFIG_DIR, "lock"
@ -214,7 +214,7 @@ module Qasim
f = IO.open(fd) f = IO.open(fd)
f.syswrite( "#{Process.pid}\n" ) f.syswrite( "#{Process.pid}\n" )
f.close f.close
rescue Errno::EEXIST => e rescue Errno::EEXIST => _e
# test if the other process still exist # test if the other process still exist
masterpid = File.read(lockfname).strip masterpid = File.read(lockfname).strip
other_path = "/proc/#{masterpid.to_i}" other_path = "/proc/#{masterpid.to_i}"

View file

@ -7,22 +7,22 @@ class Qasim::MapManager
end end
def sort &blk def sort &blk
@maps.sort &blk @maps.sort(&blk)
end end
def select &blk def select &blk
@maps.select &blk @maps.select(&blk)
end end
def each &blk def each &blk
@maps.each &blk @maps.each blk
end end
def parse_maps &blk def parse_maps &blk
@maps = [] @maps = []
map_dirs = [@config.config_dir, Qasim::APP_SYSCONFIG_DIR].select{ |d| map_dirs = [@config.config_dir, Qasim::APP_SYSCONFIG_DIR].select do |d|
File.exist? d and File.directory? d File.exist? d and File.directory? d
} end
Find.find(*map_dirs) do |path| Find.find(*map_dirs) do |path|
# Skip unwanted files fast # Skip unwanted files fast
@ -30,7 +30,7 @@ class Qasim::MapManager
next unless File.basename(path) =~ /.map$/ next unless File.basename(path) =~ /.map$/
begin begin
map = Qasim::Map.from_file self, path map = Qasim::Map.from_file @config, path
yield map if block_given? yield map if block_given?
@maps.push map @maps.push map
rescue Qasim::Map::ParseError rescue Qasim::Map::ParseError