2011-07-19 08:36:52 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
require 'Qt4'
|
|
|
|
|
2011-07-19 14:56:21 +00:00
|
|
|
def _ str
|
|
|
|
Qt::Object.tr(str)
|
|
|
|
end
|
|
|
|
|
2011-07-19 08:36:52 +00:00
|
|
|
app = Qt::Application.new(ARGV)
|
|
|
|
si = Qt::SystemTrayIcon.new
|
|
|
|
|
2011-07-19 11:35:04 +00:00
|
|
|
std_icon = Qt::Icon.new('qtsshfsmapper.svg')
|
2011-07-19 08:36:52 +00:00
|
|
|
alt_icon = Qt::Icon.new
|
|
|
|
blinking = false
|
|
|
|
|
|
|
|
si.icon = std_icon
|
|
|
|
si.show
|
|
|
|
|
|
|
|
Qt::Timer.new(app) do |timer|
|
|
|
|
timer.connect(SIGNAL('timeout()')) do
|
|
|
|
si.icon = (si.icon.isNull ? std_icon : alt_icon) if blinking
|
|
|
|
end
|
|
|
|
timer.start(500)
|
|
|
|
end
|
|
|
|
|
|
|
|
menu = Qt::Menu.new
|
|
|
|
|
2011-07-19 11:35:04 +00:00
|
|
|
['Diades', 'Daneel', 'Dolos'].each do |name|
|
2011-07-19 14:56:21 +00:00
|
|
|
itemx = Qt::Action.new(name, menu)
|
2011-07-19 11:35:04 +00:00
|
|
|
itemx.setCheckable true;
|
|
|
|
itemx.connect(SIGNAL(:triggered)) { puts itemx.checked }
|
|
|
|
menu.addAction itemx;
|
|
|
|
end
|
|
|
|
|
|
|
|
menu.addSeparator
|
|
|
|
|
2011-07-19 14:56:21 +00:00
|
|
|
act_pref = Qt::Action.new _('&Preferences'), menu
|
|
|
|
act_pref.setIcon( Qt::Icon::fromTheme("configure") )
|
|
|
|
act_pref.setIconVisibleInMenu true
|
2011-07-19 11:35:04 +00:00
|
|
|
menu.addAction act_pref;
|
|
|
|
|
|
|
|
act_about = Qt::Action.new '&About', menu
|
2011-07-19 14:56:21 +00:00
|
|
|
act_about.setIcon( Qt::Icon::fromTheme("help-about") )
|
|
|
|
act_about.setIconVisibleInMenu true
|
2011-07-19 11:35:04 +00:00
|
|
|
menu.addAction act_about;
|
|
|
|
|
|
|
|
menu.addSeparator
|
|
|
|
|
2011-07-19 14:56:21 +00:00
|
|
|
act_quit = Qt::Action.new _('Quit'), menu
|
|
|
|
act_quit.setIcon( Qt::Icon::fromTheme("application-exit") )
|
|
|
|
act_quit.setIconVisibleInMenu true
|
2011-07-19 11:35:04 +00:00
|
|
|
act_quit.connect(SIGNAL(:triggered)) { app.quit }
|
|
|
|
menu.addAction act_quit
|
2011-07-19 08:36:52 +00:00
|
|
|
|
|
|
|
si.contextMenu = menu
|
|
|
|
|
|
|
|
si.connect(SIGNAL('activated(QSystemTrayIcon::ActivationReason)')) do |reason|
|
|
|
|
case reason
|
|
|
|
when Qt::SystemTrayIcon::Trigger
|
|
|
|
blinking = !blinking
|
|
|
|
si.icon = blinking ? alt_icon : std_icon
|
|
|
|
when Qt::SystemTrayIcon::MiddleClick: puts 'Middle Click'
|
|
|
|
when Qt::SystemTrayIcon::Context: puts 'Right Click'
|
|
|
|
when Qt::SystemTrayIcon::DoubleClick: puts 'Double Click'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
app.exec
|