1
2
3
4
5
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
39
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
#!/usr/bin/env ruby
#
#
# Form implementation generated from reading ui file 'selector.ui'
#
# Created: Fri Dec 2 23:40:46 2005
# by: The QtRuby User Interface Compiler (rbuic)
#
# WARNING! All changes made in this file will be lost!
#
# Ruby script for generic amarok database scripts
# (c) 2005 Seb Ruiz <me@sebruiz.net>
# Released under the GPL v2 license
begin
require 'Korundum'
rescue LoadError
error = 'Korundum (KDE bindings for ruby) from tdebindings v3.4 is required for this script.'
system("dcop", "amarok", "playlist", "popupMessage", "DatabaseScripts: #{error}")
exit
end
class DatabaseScriptChooser < Qt::Dialog
attr_reader :m_optionCombo
attr_reader :m_saveText
attr_reader :m_saveDir
attr_reader :m_okayButton
Q_SLOTS 'optionChanged(int)', 'textChanged(const QString &)', 'accept()', 'cancel()'
def initialize(parent = nil, name = nil, modal = false, fl = 0)
super
if name.nil?
setName("Database Script Chooser")
end
@Form1Layout = Qt::GridLayout.new(self, 1, 1, 2, 2, 'Form1Layout')
@tqlayout3 = Qt::VBoxLayout.new(nil, 0, 2, 'tqlayout3')
@m_optionCombo = Qt::ComboBox.new(false, self, "m_optionCombo")
@tqlayout3.addWidget(@m_optionCombo)
@tqlayout1 = Qt::HBoxLayout.new(nil, 0, 2, 'tqlayout1')
@m_saveText = Qt::Label.new(self, "m_saveText")
@tqlayout1.addWidget(@m_saveText)
@m_saveDir = KDE::URLRequester.new(self, "m_saveDir")
@m_saveDir.setMode( KDE::File::Directory | KDE::File::ExistingOnly );
@m_saveDir.setURL( ENV["HOME"] )
@tqlayout1.addWidget(@m_saveDir)
@tqlayout3.addLayout(@tqlayout1)
@spacer1 = Qt::SpacerItem.new(20, 21, Qt::SizePolicy::Minimum, Qt::SizePolicy::Expanding)
@tqlayout3.addItem(@spacer1)
@tqlayout2 = Qt::HBoxLayout.new(nil, 0, 2, 'tqlayout2')
@m_cancelButton = Qt::PushButton.new(self, "@m_cancelButton")
@tqlayout2.addWidget(@m_cancelButton)
@spacer2 = Qt::SpacerItem.new(61, 20, Qt::SizePolicy::Expanding, Qt::SizePolicy::Minimum)
@tqlayout2.addItem(@spacer2)
@m_okayButton = Qt::PushButton.new(self, "m_okayButton")
@tqlayout2.addWidget(@m_okayButton)
@tqlayout3.addLayout(@tqlayout2)
connect( @m_optionCombo, SIGNAL( "activated(int)" ), self, SLOT( "optionChanged(int)" ) );
connect( @m_okayButton, SIGNAL( "clicked()" ), self, SLOT( "accept()" ) )
connect( @m_cancelButton, SIGNAL( "clicked()" ), self, SLOT( "cancel()" ) )
connect( @m_saveDir, SIGNAL( "textChanged(const QString &)" ),
self, SLOT( "textChanged(const QString &)" ) );
@Form1Layout.addLayout(@tqlayout3, 0, 0)
languageChange()
resize( Qt::Size.new(356, 137).expandedTo(minimumSizeHint()) )
clearWState( WState_Polished )
end
def optionChanged( i )
@m_saveDir.setEnabled( i == 0 )
@m_saveText.setEnabled( i == 0 )
end
def textChanged(s)
@m_okayButton.setEnabled( !s.empty?() )
end
def accept()
arg = ""
case @m_optionCombo.currentItem()
when 0 # Backup
filename = File.dirname( File.expand_path( __FILE__ ) ) + "/backupDatabase.rb"
arg = @m_saveDir.url()
when 1 # Optimise
filename = File.dirname( File.expand_path( __FILE__ ) ) + "/staleStatistics.rb"
end
system("ruby", filename, arg)
done( 0 )
end
def cancel()
done( 0 )
end
#
# Sets the strings of the subwidgets using the current
# language.
#
def languageChange()
setCaption( trUtf8("Database Scripts") )
@m_optionCombo.clear()
# add combo box items
@m_optionCombo.insertItem( trUtf8("Backup Database") )
@m_optionCombo.insertItem( trUtf8("Optimise Database") )
@m_saveText.setText( trUtf8("Save location:") )
@m_cancelButton.setText( trUtf8("Cancel") )
@m_okayButton.setText( trUtf8("Go!") )
end
protected :languageChange
end
if $0 == __FILE__
about = KDE::AboutData.new("databaseScriptChooser", "DatabaseScriptChooser", "0.1")
KDE::CmdLineArgs.init(ARGV, about)
a = KDE::Application.new
w = DatabaseScriptChooser.new
a.mainWidget = w
w.show
a.exec
end
|