qasim: Added module.
git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1692 eaee96b3-f302-0410-b096-c6cfd47f7835
This commit is contained in:
parent
4c2d453bf8
commit
0668ddbb06
1 changed files with 70 additions and 61 deletions
|
@ -4,79 +4,88 @@ require 'Qt4'
|
||||||
|
|
||||||
# QaSiM // Qt Sshfs Mapper
|
# QaSiM // Qt Sshfs Mapper
|
||||||
|
|
||||||
VERSION="0.1"
|
|
||||||
|
|
||||||
def _ str
|
def _ str
|
||||||
Qt::Object.tr(str)
|
Qt::Object.tr(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def build_app
|
module Qasim
|
||||||
|
|
||||||
app = Qt::Application.new(ARGV)
|
VERSION="0.1"
|
||||||
si = Qt::SystemTrayIcon.new
|
|
||||||
|
|
||||||
std_icon = Qt::Icon.new('qasim.svg')
|
def build_app
|
||||||
alt_icon = Qt::Icon.new
|
|
||||||
blinking = false
|
|
||||||
|
|
||||||
si.icon = std_icon
|
app = Qt::Application.new(ARGV)
|
||||||
si.show
|
si = Qt::SystemTrayIcon.new
|
||||||
si.setToolTip("Qasim v%s" % VERSION);
|
|
||||||
|
|
||||||
Qt::Timer.new(app) do |timer|
|
std_icon = Qt::Icon.new('qasim.svg')
|
||||||
timer.connect(SIGNAL('timeout()')) do
|
alt_icon = Qt::Icon.new
|
||||||
si.icon = (si.icon.isNull ? std_icon : alt_icon) if blinking
|
blinking = false
|
||||||
|
|
||||||
|
si.icon = std_icon
|
||||||
|
si.show
|
||||||
|
|
||||||
|
si.showMessage("Qasim",
|
||||||
|
"funky funky notification", 2, 5000)
|
||||||
|
|
||||||
|
si.setToolTip("Qasim %s" % VERSION);
|
||||||
|
|
||||||
|
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
|
end
|
||||||
timer.start(500)
|
|
||||||
|
menu = Qt::Menu.new
|
||||||
|
|
||||||
|
['Diades', 'Daneel', 'Dolos'].each do |name|
|
||||||
|
itemx = Qt::Action.new(name, menu)
|
||||||
|
itemx.setCheckable true;
|
||||||
|
itemx.connect(SIGNAL(:triggered)) do
|
||||||
|
puts "%s => %s" % [name, itemx.checked ]
|
||||||
|
end
|
||||||
|
menu.addAction itemx;
|
||||||
|
end
|
||||||
|
|
||||||
|
menu.addSeparator
|
||||||
|
|
||||||
|
act_pref = Qt::Action.new _('&Preferences'), menu
|
||||||
|
act_pref.setIcon( Qt::Icon::fromTheme("configure") )
|
||||||
|
act_pref.setIconVisibleInMenu true
|
||||||
|
menu.addAction act_pref;
|
||||||
|
|
||||||
|
act_about = Qt::Action.new '&About', menu
|
||||||
|
act_about.setIcon( Qt::Icon::fromTheme("help-about") )
|
||||||
|
act_about.setIconVisibleInMenu true
|
||||||
|
menu.addAction act_about;
|
||||||
|
|
||||||
|
menu.addSeparator
|
||||||
|
|
||||||
|
act_quit = Qt::Action.new _('Quit'), menu
|
||||||
|
act_quit.setIcon( Qt::Icon::fromTheme("application-exit") )
|
||||||
|
act_quit.setIconVisibleInMenu true
|
||||||
|
act_quit.connect(SIGNAL(:triggered)) { app.quit }
|
||||||
|
menu.addAction act_quit
|
||||||
|
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
menu = Qt::Menu.new
|
|
||||||
|
|
||||||
['Diades', 'Daneel', 'Dolos'].each do |name|
|
|
||||||
itemx = Qt::Action.new(name, menu)
|
|
||||||
itemx.setCheckable true;
|
|
||||||
itemx.connect(SIGNAL(:triggered)) do
|
|
||||||
puts "%s => %s" % [name, itemx.checked ]
|
|
||||||
end
|
|
||||||
menu.addAction itemx;
|
|
||||||
end
|
|
||||||
|
|
||||||
menu.addSeparator
|
|
||||||
|
|
||||||
act_pref = Qt::Action.new _('&Preferences'), menu
|
|
||||||
act_pref.setIcon( Qt::Icon::fromTheme("configure") )
|
|
||||||
act_pref.setIconVisibleInMenu true
|
|
||||||
menu.addAction act_pref;
|
|
||||||
|
|
||||||
act_about = Qt::Action.new '&About', menu
|
|
||||||
act_about.setIcon( Qt::Icon::fromTheme("help-about") )
|
|
||||||
act_about.setIconVisibleInMenu true
|
|
||||||
menu.addAction act_about;
|
|
||||||
|
|
||||||
menu.addSeparator
|
|
||||||
|
|
||||||
act_quit = Qt::Action.new _('Quit'), menu
|
|
||||||
act_quit.setIcon( Qt::Icon::fromTheme("application-exit") )
|
|
||||||
act_quit.setIconVisibleInMenu true
|
|
||||||
act_quit.connect(SIGNAL(:triggered)) { app.quit }
|
|
||||||
menu.addAction act_quit
|
|
||||||
|
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
build_app
|
include Qasim
|
||||||
|
Qasim::build_app
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue