lyrics-ebook 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +340 -0
- data/README +46 -0
- data/bin/lyrics-ebook +47 -0
- data/lib/eeepub/LICENSE +20 -0
- data/lib/eeepub/README.md +77 -0
- data/lib/eeepub/Rakefile +49 -0
- data/lib/eeepub/VERSION +1 -0
- data/lib/eeepub/examples/files/bar.html +42 -0
- data/lib/eeepub/examples/files/foo.html +42 -0
- data/lib/eeepub/examples/simple_epub.rb +25 -0
- data/lib/eeepub/lib/eeepub.rb +17 -0
- data/lib/eeepub/lib/eeepub/container_item.rb +108 -0
- data/lib/eeepub/lib/eeepub/easy.rb +100 -0
- data/lib/eeepub/lib/eeepub/maker.rb +127 -0
- data/lib/eeepub/lib/eeepub/ncx.rb +68 -0
- data/lib/eeepub/lib/eeepub/ocf.rb +112 -0
- data/lib/eeepub/lib/eeepub/opf.rb +148 -0
- data/lib/eeepub/spec/eeepub/easy_spec.rb +66 -0
- data/lib/eeepub/spec/eeepub/maker_spec.rb +124 -0
- data/lib/eeepub/spec/eeepub/ncx_spec.rb +80 -0
- data/lib/eeepub/spec/eeepub/ocf_spec.rb +43 -0
- data/lib/eeepub/spec/eeepub/opf_spec.rb +262 -0
- data/lib/eeepub/spec/eeepub_spec.rb +4 -0
- data/lib/eeepub/spec/spec_helper.rb +12 -0
- data/lib/lyrics_ebook.rb +71 -0
- data/lib/lyrics_ebook/cache2html.rb +33 -0
- data/lib/lyrics_ebook/cache_manager.rb +77 -0
- data/lib/lyrics_ebook/lyric.rb +32 -0
- data/lib/lyrics_ebook/lyric_download.rb +50 -0
- data/lib/lyrics_ebook/lyrics2html.rb +106 -0
- data/lib/lyrics_ebook/mini_lyrics_parser.rb +26 -0
- data/lib/lyrics_ebook/mp3_parser.rb +37 -0
- data/lib/wiki_lyrics/amarok/COPYING +340 -0
- data/lib/wiki_lyrics/amarok/README +51 -0
- data/lib/wiki_lyrics/amarok/amarok.rb +355 -0
- data/lib/wiki_lyrics/amarok/pluginadapter.rb +113 -0
- data/lib/wiki_lyrics/amarok/plugins.rb +95 -0
- data/lib/wiki_lyrics/amarok/wikilyrics.rb +578 -0
- data/lib/wiki_lyrics/amarok/wikilyrics.spec +4 -0
- data/lib/wiki_lyrics/amarok/wikipluginadapter.rb +392 -0
- data/lib/wiki_lyrics/cli/optionsparser.rb +228 -0
- data/lib/wiki_lyrics/cli/pluginadapter.rb +56 -0
- data/lib/wiki_lyrics/cli/plugins.rb +79 -0
- data/lib/wiki_lyrics/cli/wikilyrics.rb +178 -0
- data/lib/wiki_lyrics/cli/wikipluginadapter.rb +140 -0
- data/lib/wiki_lyrics/docs/COPYING +340 -0
- data/lib/wiki_lyrics/docs/ChangeLog +293 -0
- data/lib/wiki_lyrics/docs/HOWTO.pdf +0 -0
- data/lib/wiki_lyrics/docs/HOWTO.tex +151 -0
- data/lib/wiki_lyrics/docs/HOWTO.txt +139 -0
- data/lib/wiki_lyrics/docs/README +45 -0
- data/lib/wiki_lyrics/docs/TODO +12 -0
- data/lib/wiki_lyrics/gui/gui-gtk.rb +945 -0
- data/lib/wiki_lyrics/gui/gui-qt3.rb +785 -0
- data/lib/wiki_lyrics/gui/gui-qt4.rb +845 -0
- data/lib/wiki_lyrics/gui/gui-tk.rb +1104 -0
- data/lib/wiki_lyrics/gui/gui.rb +268 -0
- data/lib/wiki_lyrics/gui/test.rb +74 -0
- data/lib/wiki_lyrics/i18n/README +1 -0
- data/lib/wiki_lyrics/i18n/en.rb +181 -0
- data/lib/wiki_lyrics/i18n/es.rb +181 -0
- data/lib/wiki_lyrics/i18n/i18n.rb +126 -0
- data/lib/wiki_lyrics/i18n/sk.rb +174 -0
- data/lib/wiki_lyrics/itrans/COPYRIGHT +31 -0
- data/lib/wiki_lyrics/itrans/itrans +0 -0
- data/lib/wiki_lyrics/itrans/itrans.txt +8 -0
- data/lib/wiki_lyrics/itrans/lyric.txt +23 -0
- data/lib/wiki_lyrics/itrans/udvng.ifm +206 -0
- data/lib/wiki_lyrics/lyrics.rb +567 -0
- data/lib/wiki_lyrics/lyrics_AZLyrics.rb +113 -0
- data/lib/wiki_lyrics/lyrics_DarkLyrics.rb +124 -0
- data/lib/wiki_lyrics/lyrics_Giitaayan.rb +124 -0
- data/lib/wiki_lyrics/lyrics_Jamendo.rb +166 -0
- data/lib/wiki_lyrics/lyrics_LeosLyrics.rb +142 -0
- data/lib/wiki_lyrics/lyrics_LoudSongs.rb +135 -0
- data/lib/wiki_lyrics/lyrics_LyricWiki.rb +329 -0
- data/lib/wiki_lyrics/lyrics_LyricsDownload.rb +118 -0
- data/lib/wiki_lyrics/lyrics_LyricsMania.rb +141 -0
- data/lib/wiki_lyrics/lyrics_Lyriki.rb +287 -0
- data/lib/wiki_lyrics/lyrics_SeekLyrics.rb +108 -0
- data/lib/wiki_lyrics/lyrics_Sing365.rb +103 -0
- data/lib/wiki_lyrics/lyrics_TerraLetras.rb +126 -0
- data/lib/wiki_lyrics/mediawikilyrics.rb +1464 -0
- data/lib/wiki_lyrics/tests/plugin_tests.rb +161 -0
- data/lib/wiki_lyrics/tests/tests.rb +74 -0
- data/lib/wiki_lyrics/utils/formdata.rb +56 -0
- data/lib/wiki_lyrics/utils/htmlentities.rb +291 -0
- data/lib/wiki_lyrics/utils/http.rb +198 -0
- data/lib/wiki_lyrics/utils/itrans.rb +160 -0
- data/lib/wiki_lyrics/utils/kde.rb +88 -0
- data/lib/wiki_lyrics/utils/logger.rb +123 -0
- data/lib/wiki_lyrics/utils/strings.rb +378 -0
- data/lib/wiki_lyrics/utils/xmlhash.rb +111 -0
- data/lib/wiki_lyrics/wikilyrics.kdevelop +152 -0
- data/lib/wiki_lyrics/wikilyrics.kdevses +18 -0
- data/lib/wiki_lyrics/win/gtk_fix.bat +3 -0
- data/lib/wiki_lyrics/win/tk_fix.bat +3 -0
- data/lib/wiki_lyrics/win/wikilyrics.bat +4 -0
- data/lib/wiki_lyrics/win/win_fix.rb +52 -0
- data/templates/art_.erb.xhtml +29 -0
- data/templates/artists.erb.xhtml +19 -0
- data/templates/cover.erb.xhtml +22 -0
- data/test/cache_manager_test.rb +73 -0
- data/test/data/artist name/title name.lyric +6 -0
- data/test/lyric_test.rb +41 -0
- metadata +194 -0
@@ -0,0 +1,785 @@
|
|
1
|
+
# Copyright (C) 2006-2008 by Sergio Pistone
|
2
|
+
# sergio_pistone@yahoo.com.ar
|
3
|
+
#
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program; if not, write to the
|
16
|
+
# Free Software Foundation, Inc.,
|
17
|
+
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
18
|
+
|
19
|
+
begin
|
20
|
+
require "Qt3"
|
21
|
+
rescue LoadError
|
22
|
+
require "Qt"
|
23
|
+
raise LoadError.new( "Wrong Qt version found (Qt3 expected but Qt4 found)" ) if defined?( Qt::StringListModel )
|
24
|
+
end
|
25
|
+
require "date"
|
26
|
+
require File.expand_path( File.dirname( __FILE__ ) + "/../i18n/i18n" )
|
27
|
+
$KCODE="u" # unicode support
|
28
|
+
|
29
|
+
module QT3
|
30
|
+
|
31
|
+
def QT3.empty_string?( text )
|
32
|
+
return text ? (text.empty? ? true : text.strip().empty? ) : true
|
33
|
+
end
|
34
|
+
|
35
|
+
class BaseDialog < Qt::Dialog
|
36
|
+
|
37
|
+
attr_reader :values
|
38
|
+
|
39
|
+
def initialize( values )
|
40
|
+
super( nil )
|
41
|
+
@values = values
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_action_buttons( mode="right", accept_text=nil, cancel_text= nil )
|
45
|
+
accept_text = QT3.empty_string?( accept_text ) ? I18n.get( "gui.common.accept" ) : accept_text
|
46
|
+
cancel_text = QT3.empty_string?( cancel_text ) ? I18n.get( "gui.common.cancel" ) : cancel_text
|
47
|
+
@accept_button = Qt::PushButton.new( accept_text, self )
|
48
|
+
@cancel_button = Qt::PushButton.new( cancel_text, self )
|
49
|
+
connect( @accept_button, SIGNAL( "clicked()" ), self, SLOT( "accept()" ) )
|
50
|
+
connect( @cancel_button, SIGNAL( "clicked()" ), self, SLOT( "reject()" ) )
|
51
|
+
if mode == "left"
|
52
|
+
hbox = Qt::HBoxLayout.new( 4 )
|
53
|
+
hbox.setDirection( Qt::BoxLayout::LeftToRight )
|
54
|
+
hbox.addWidget( @accept_button )
|
55
|
+
hbox.addWidget( @cancel_button )
|
56
|
+
hbox.addStretch()
|
57
|
+
elsif mode == "split"
|
58
|
+
hbox = Qt::HBoxLayout.new( 4 )
|
59
|
+
hbox.addWidget( @accept_button, 1 )
|
60
|
+
hbox.addWidget( @cancel_button, 1 )
|
61
|
+
else
|
62
|
+
hbox = Qt::HBoxLayout.new( 4 )
|
63
|
+
hbox.addStretch()
|
64
|
+
hbox.addWidget( @accept_button )
|
65
|
+
hbox.addWidget( @cancel_button )
|
66
|
+
end
|
67
|
+
return hbox
|
68
|
+
end
|
69
|
+
protected :create_action_buttons
|
70
|
+
|
71
|
+
def accepted()
|
72
|
+
return result() == Qt::Dialog.Accepted
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class PluginsManagerDialog < BaseDialog
|
77
|
+
|
78
|
+
slots "move_up()", "move_down()", "add_plugin()", "remove_plugin()"
|
79
|
+
|
80
|
+
def initialize( values )
|
81
|
+
super( values )
|
82
|
+
|
83
|
+
setCaption( I18n.get( "gui.pluginsmanager.title", @values["script_name"] ) )
|
84
|
+
|
85
|
+
sites_group = Qt::GroupBox.new( I18n.get( "gui.pluginsmanager.sites" ), self )
|
86
|
+
|
87
|
+
@move_up_button = Qt::PushButton.new( I18n.get( "gui.pluginsmanager.sites.moveup" ), sites_group )
|
88
|
+
@move_down_button = Qt::PushButton.new( I18n.get( "gui.pluginsmanager.sites.movedown" ), sites_group )
|
89
|
+
|
90
|
+
@used_plugins_list = Qt::ListView.new( sites_group )
|
91
|
+
@used_plugins_list.setSelectionMode( Qt::ListView::Single )
|
92
|
+
@used_plugins_list.addColumn( I18n.get( "gui.pluginsmanager.sites.inuse" ), -1 )
|
93
|
+
@used_plugins_list.setResizeMode( Qt::ListView::LastColumn )
|
94
|
+
@used_plugins_list.setSorting( -1 )
|
95
|
+
@values["used_plugins"].reverse().each() do |plugin|
|
96
|
+
item = Qt::ListViewItem.new( @used_plugins_list, plugin )
|
97
|
+
@used_plugins_list.insertItem( item )
|
98
|
+
end
|
99
|
+
|
100
|
+
@add_button = Qt::PushButton.new( I18n.get( "gui.pluginsmanager.sites.add" ), sites_group )
|
101
|
+
@remove_button = Qt::PushButton.new( I18n.get( "gui.pluginsmanager.sites.remove" ), sites_group )
|
102
|
+
|
103
|
+
@unused_plugins_list = Qt::ListView.new( sites_group )
|
104
|
+
@unused_plugins_list.setSelectionMode( Qt::ListView::Single )
|
105
|
+
@unused_plugins_list.addColumn( I18n.get( "gui.pluginsmanager.sites.available" ), -1 )
|
106
|
+
@unused_plugins_list.setResizeMode( Qt::ListView::LastColumn )
|
107
|
+
@unused_plugins_list.setSorting( -1 )
|
108
|
+
@values["unused_plugins"].reverse().each() do |plugin|
|
109
|
+
item = Qt::ListViewItem.new( @unused_plugins_list, plugin )
|
110
|
+
@unused_plugins_list.insertItem( item )
|
111
|
+
end
|
112
|
+
|
113
|
+
misc_group = Qt::GroupBox.new( 1, Qt::Horizontal, I18n.get( "gui.pluginsmanager.misc" ), self )
|
114
|
+
|
115
|
+
@cleanup_lyrics_checkbox = Qt::CheckBox.new( misc_group )
|
116
|
+
@cleanup_lyrics_checkbox.setChecked( values["cleanup_lyrics"].to_s() == "true" )
|
117
|
+
@cleanup_lyrics_checkbox.setText( I18n.get( "gui.pluginsmanager.misc.cleanup" ) )
|
118
|
+
|
119
|
+
@single_threaded_checkbox = Qt::CheckBox.new( misc_group )
|
120
|
+
@single_threaded_checkbox.setChecked( values["single_threaded"].to_s() == "true" )
|
121
|
+
@single_threaded_checkbox.setText( I18n.get( "gui.pluginsmanager.misc.singlethreaded" ) )
|
122
|
+
|
123
|
+
@write_log_checkbox = Qt::CheckBox.new( misc_group )
|
124
|
+
@write_log_checkbox.setChecked( values["write_log"].to_s() == "true" )
|
125
|
+
@write_log_checkbox.setText( I18n.get( "gui.pluginsmanager.misc.writelog", "$HOME/.wikilyrics.log" ) )
|
126
|
+
|
127
|
+
buttons = create_action_buttons()
|
128
|
+
|
129
|
+
sites_group_layout = Qt::GridLayout.new( sites_group, 5, 4, 5 )
|
130
|
+
sites_group_layout.setRowSpacing( 0, 12 )
|
131
|
+
sites_group_layout.setColStretch( 1, 1 )
|
132
|
+
sites_group_layout.setColStretch( 3, 1 )
|
133
|
+
sites_group_layout.setRowStretch( 1, 1 )
|
134
|
+
sites_group_layout.setRowStretch( 4, 1 )
|
135
|
+
sites_group_layout.addWidget( @move_up_button, 2, 0 )
|
136
|
+
sites_group_layout.addWidget( @move_down_button, 3, 0 )
|
137
|
+
sites_group_layout.addMultiCellWidget( @used_plugins_list, 1, 4, 1, 1 )
|
138
|
+
sites_group_layout.addWidget( @add_button, 2, 2 )
|
139
|
+
sites_group_layout.addWidget( @remove_button, 3, 2 )
|
140
|
+
sites_group_layout.addMultiCellWidget( @unused_plugins_list, 1, 4, 3, 3 )
|
141
|
+
|
142
|
+
layout = Qt::VBoxLayout.new( self, 5 )
|
143
|
+
layout.addWidget( sites_group )
|
144
|
+
layout.addWidget( misc_group )
|
145
|
+
layout.addLayout( buttons )
|
146
|
+
|
147
|
+
connect( @move_up_button, SIGNAL( "clicked()" ), self, SLOT( "move_up()" ) )
|
148
|
+
connect( @move_down_button, SIGNAL( "clicked()" ), self, SLOT( "move_down()" ) )
|
149
|
+
connect( @add_button, SIGNAL( "clicked()" ), self, SLOT( "add_plugin()" ) )
|
150
|
+
connect( @remove_button, SIGNAL( "clicked()" ), self, SLOT( "remove_plugin()" ) )
|
151
|
+
|
152
|
+
update_accept_button()
|
153
|
+
|
154
|
+
resize( 400, 280 )
|
155
|
+
end
|
156
|
+
|
157
|
+
# workaround for buggy qlistview (works as expected only when sorting is disabled)
|
158
|
+
def list_view_move_item( list_view, item, after )
|
159
|
+
return if item == after
|
160
|
+
if after
|
161
|
+
item.moveItem( after )
|
162
|
+
else
|
163
|
+
list_view.takeItem( item )
|
164
|
+
list_view.insertItem( item )
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def move_up()
|
169
|
+
cur_item = @used_plugins_list.currentItem()
|
170
|
+
return if cur_item == nil
|
171
|
+
prev_item = cur_item.itemAbove()
|
172
|
+
return if prev_item == nil
|
173
|
+
prev_item = prev_item.itemAbove()
|
174
|
+
list_view_move_item( @used_plugins_list, cur_item, prev_item )
|
175
|
+
@used_plugins_list.setCurrentItem( cur_item )
|
176
|
+
end
|
177
|
+
|
178
|
+
def move_down()
|
179
|
+
cur_item = @used_plugins_list.currentItem()
|
180
|
+
return if cur_item == nil
|
181
|
+
next_item = cur_item.itemBelow()
|
182
|
+
return if next_item == nil
|
183
|
+
list_view_move_item( @used_plugins_list, cur_item, next_item )
|
184
|
+
@used_plugins_list.setCurrentItem( cur_item )
|
185
|
+
end
|
186
|
+
|
187
|
+
def add_plugin()
|
188
|
+
unused_cur_item = @unused_plugins_list.currentItem()
|
189
|
+
return if unused_cur_item == nil
|
190
|
+
@unused_plugins_list.takeItem( unused_cur_item )
|
191
|
+
@used_plugins_list.insertItem( unused_cur_item )
|
192
|
+
list_view_move_item( @used_plugins_list, unused_cur_item, @used_plugins_list.lastItem() )
|
193
|
+
@used_plugins_list.setCurrentItem( unused_cur_item )
|
194
|
+
update_accept_button()
|
195
|
+
end
|
196
|
+
|
197
|
+
def remove_plugin()
|
198
|
+
used_cur_item = @used_plugins_list.currentItem()
|
199
|
+
return if used_cur_item == nil
|
200
|
+
@used_plugins_list.takeItem( used_cur_item )
|
201
|
+
@unused_plugins_list.insertItem( used_cur_item )
|
202
|
+
list_view_move_item( @unused_plugins_list, used_cur_item, @unused_plugins_list.lastItem() )
|
203
|
+
@unused_plugins_list.setCurrentItem( used_cur_item )
|
204
|
+
update_accept_button()
|
205
|
+
end
|
206
|
+
|
207
|
+
def update_accept_button()
|
208
|
+
@accept_button.setEnabled( @used_plugins_list.childCount() > 0 )
|
209
|
+
end
|
210
|
+
|
211
|
+
def accept()
|
212
|
+
@values = {
|
213
|
+
"cleanup_lyrics" => @cleanup_lyrics_checkbox.isChecked(),
|
214
|
+
"single_threaded" => @single_threaded_checkbox.isChecked(),
|
215
|
+
"write_log" => @write_log_checkbox.isChecked(),
|
216
|
+
"used_plugins" => [],
|
217
|
+
"script_name" => @values["script_name"],
|
218
|
+
"unused_plugins" => []
|
219
|
+
}
|
220
|
+
child = @used_plugins_list.firstChild()
|
221
|
+
while ( child )
|
222
|
+
@values["used_plugins"].insert( -1, child.text( 0 ) )
|
223
|
+
child = child.itemBelow()
|
224
|
+
end
|
225
|
+
child = @unused_plugins_list.firstChild()
|
226
|
+
while ( child )
|
227
|
+
@values["unused_plugins"].insert( -1, child.text( 0 ) )
|
228
|
+
child = child.itemBelow()
|
229
|
+
end
|
230
|
+
super()
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
|
236
|
+
class WikiPluginDialog < BaseDialog
|
237
|
+
|
238
|
+
slots "toggle_submit_checked( bool )"
|
239
|
+
slots "toggle_review_checked( bool )"
|
240
|
+
slots "update_accept_button_state()"
|
241
|
+
|
242
|
+
def initialize( values )
|
243
|
+
super( values )
|
244
|
+
|
245
|
+
setCaption( I18n.get( "gui.wikiplugin.title", values["site_name"] ) )
|
246
|
+
|
247
|
+
general_group = Qt::GroupBox.new( I18n.get( "gui.wikiplugin.general" ), self )
|
248
|
+
general_group.setColumnLayout( 0, Qt::Vertical )
|
249
|
+
general_group.layout().setSpacing( 5 )
|
250
|
+
|
251
|
+
@submit_checkbox = Qt::CheckBox.new( general_group )
|
252
|
+
@submit_checkbox.setChecked( values["submit"].to_s() == "true" )
|
253
|
+
@submit_checkbox.setText( I18n.get( "gui.wikiplugin.general.submit", values["site_name"] ) )
|
254
|
+
|
255
|
+
@review_checkbox = Qt::CheckBox.new( general_group )
|
256
|
+
@review_checkbox.setEnabled( @submit_checkbox.isChecked() )
|
257
|
+
@review_checkbox.setChecked( @review_checkbox.isEnabled() && values["review"].to_s() == "true" )
|
258
|
+
@review_checkbox.setText( I18n.get( "gui.wikiplugin.general.review" ) )
|
259
|
+
|
260
|
+
@prompt_autogen_checkbox = Qt::CheckBox.new( general_group )
|
261
|
+
@prompt_autogen_checkbox.setEnabled( @review_checkbox.isChecked() )
|
262
|
+
@prompt_autogen_checkbox.setChecked( @prompt_autogen_checkbox.isEnabled() && values["prompt_autogen"].to_s() == "true" )
|
263
|
+
@prompt_autogen_checkbox.setText( I18n.get( "gui.wikiplugin.general.autogen" ) )
|
264
|
+
|
265
|
+
@prompt_no_lyrics_checkbox = Qt::CheckBox.new( general_group )
|
266
|
+
@prompt_no_lyrics_checkbox.setEnabled( @review_checkbox.isChecked() )
|
267
|
+
@prompt_no_lyrics_checkbox.setChecked( @prompt_no_lyrics_checkbox.isEnabled() && values["prompt_no_lyrics"].to_s() == "true" )
|
268
|
+
@prompt_no_lyrics_checkbox.setText( I18n.get( "gui.wikiplugin.general.nolyrics" ) )
|
269
|
+
|
270
|
+
login_group = Qt::GroupBox.new( I18n.get( "gui.wikiplugin.login" ), self )
|
271
|
+
login_group.setColumnLayout( 0, Qt::Vertical )
|
272
|
+
login_group.layout().setSpacing( 5 )
|
273
|
+
|
274
|
+
username_label = Qt::Label.new( I18n.get( "gui.wikiplugin.login.username" ), login_group )
|
275
|
+
@username_lineedit = Qt::LineEdit.new( values["username"], login_group )
|
276
|
+
|
277
|
+
password_label = Qt::Label.new( I18n.get( "gui.wikiplugin.login.password" ), login_group )
|
278
|
+
@password_lineedit = Qt::LineEdit.new( values["password"], login_group )
|
279
|
+
@password_lineedit.setEchoMode( Qt::LineEdit::Password )
|
280
|
+
|
281
|
+
buttons = create_action_buttons()
|
282
|
+
update_accept_button_state()
|
283
|
+
|
284
|
+
general_group_layout = Qt::GridLayout.new( general_group.layout() )
|
285
|
+
general_group_layout.setAlignment( Qt::AlignTop )
|
286
|
+
general_group_layout.addMultiCellWidget( @submit_checkbox, 0, 0, 0, 1 )
|
287
|
+
general_group_layout.addMultiCellWidget( @review_checkbox, 1, 1, 0, 1 )
|
288
|
+
general_group_layout.addMultiCellWidget( @prompt_autogen_checkbox, 2, 2, 0, 1 )
|
289
|
+
general_group_layout.addMultiCellWidget( @prompt_no_lyrics_checkbox, 3, 3, 0, 1 )
|
290
|
+
|
291
|
+
login_group_layout = Qt::GridLayout.new( login_group.layout() )
|
292
|
+
login_group_layout.setAlignment( Qt::AlignTop )
|
293
|
+
login_group_layout.addWidget( username_label, 1, 0 );
|
294
|
+
login_group_layout.addWidget( @username_lineedit, 1, 1 );
|
295
|
+
login_group_layout.addWidget( password_label, 2, 0 )
|
296
|
+
login_group_layout.addWidget( @password_lineedit, 2, 1 )
|
297
|
+
|
298
|
+
layout = Qt::GridLayout.new( self, 1, 1, 5 )
|
299
|
+
layout.addMultiCellWidget( general_group, 0, 0, 0, 2 )
|
300
|
+
layout.addMultiCellWidget( login_group, 1, 1, 0, 2 )
|
301
|
+
layout.addItem( Qt::SpacerItem.new( 81, 20, Qt::SizePolicy::Expanding, Qt::SizePolicy::Minimum ), 2, 0 );
|
302
|
+
layout.addMultiCellLayout( buttons, 2, 2, 0, 2 )
|
303
|
+
|
304
|
+
connect( @username_lineedit, SIGNAL( "textChanged(const QString&)" ), self, SLOT( "update_accept_button_state()" ) )
|
305
|
+
connect( @submit_checkbox, SIGNAL( "toggled(bool)" ), self, SLOT( "toggle_submit_checked(bool)" ) )
|
306
|
+
connect( @review_checkbox, SIGNAL( "toggled(bool)" ), self, SLOT( "toggle_review_checked(bool)" ) )
|
307
|
+
|
308
|
+
resize( 300, 50 )
|
309
|
+
end
|
310
|
+
|
311
|
+
def toggle_submit_checked( checked )
|
312
|
+
@review_checkbox.setEnabled( checked )
|
313
|
+
if ! checked
|
314
|
+
@review_checkbox.setChecked( false )
|
315
|
+
@prompt_autogen_checkbox.setChecked( false )
|
316
|
+
@prompt_no_lyrics_checkbox.setChecked( false )
|
317
|
+
end
|
318
|
+
update_accept_button_state()
|
319
|
+
end
|
320
|
+
|
321
|
+
def toggle_review_checked( checked )
|
322
|
+
@prompt_autogen_checkbox.setEnabled( checked )
|
323
|
+
@prompt_no_lyrics_checkbox.setEnabled( checked )
|
324
|
+
if ! checked
|
325
|
+
@prompt_autogen_checkbox.setChecked( false )
|
326
|
+
@prompt_no_lyrics_checkbox.setChecked( false )
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
def update_accept_button_state()
|
331
|
+
@accept_button.setEnabled( ! @submit_checkbox.isChecked() || ! @username_lineedit.text().empty? )
|
332
|
+
end
|
333
|
+
|
334
|
+
def accept()
|
335
|
+
@values = {
|
336
|
+
"submit" => @submit_checkbox.isChecked(),
|
337
|
+
"review" => @review_checkbox.isChecked(),
|
338
|
+
"prompt_autogen" => @prompt_autogen_checkbox.isChecked(),
|
339
|
+
"prompt_no_lyrics" => @prompt_no_lyrics_checkbox.isChecked(),
|
340
|
+
"username" => @username_lineedit.text(),
|
341
|
+
"password" => @password_lineedit.text(),
|
342
|
+
}
|
343
|
+
super()
|
344
|
+
end
|
345
|
+
|
346
|
+
end
|
347
|
+
|
348
|
+
class SubmitSongDialog < BaseDialog
|
349
|
+
|
350
|
+
slots "toggle_instrumental_checked( bool )"
|
351
|
+
|
352
|
+
def initialize( values )
|
353
|
+
super( values )
|
354
|
+
|
355
|
+
edit_mode = @values["edit_mode"].to_s() == "true"
|
356
|
+
setCaption( I18n.get( "gui.submitsong.title." + (edit_mode ? "edit" : "submit"), values["site_name"] ) )
|
357
|
+
|
358
|
+
artist_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.artist" )}</b>", self )
|
359
|
+
@artist_lineedit = Qt::LineEdit.new( values["artist"], self )
|
360
|
+
|
361
|
+
title_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.song" )}</b>", self )
|
362
|
+
@title_lineedit = Qt::LineEdit.new( values["title"], self )
|
363
|
+
|
364
|
+
credits_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.credits" )}</b>", self )
|
365
|
+
@credits_lineedit = Qt::LineEdit.new( values["credits"], self )
|
366
|
+
|
367
|
+
lyricist_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.lyricist" )}</b>", self )
|
368
|
+
@lyricist_lineedit = Qt::LineEdit.new( values["lyricist"], self )
|
369
|
+
|
370
|
+
year_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.year" )}</b>", self )
|
371
|
+
@year_spinbox = Qt::SpinBox.new( self )
|
372
|
+
@year_spinbox.setMinValue( 1900 )
|
373
|
+
@year_spinbox.setMaxValue( Date.today().year )
|
374
|
+
@year_spinbox.setValue( values["year"] )
|
375
|
+
|
376
|
+
album_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.album" )}</b>", self )
|
377
|
+
@album_lineedit = Qt::LineEdit.new( values["album"], self )
|
378
|
+
|
379
|
+
@instrumental_checkbox = Qt::CheckBox.new( self )
|
380
|
+
@instrumental_checkbox.setChecked( @values["instrumental"].to_s() == "true" )
|
381
|
+
@instrumental_checkbox.setText( I18n.get( "gui.submitsong.instrumental" ) )
|
382
|
+
|
383
|
+
@lyrics_text = Qt::TextEdit.new( self )
|
384
|
+
@lyrics_text.setTextFormat( Qt::TextEdit::PlainText )
|
385
|
+
@lyrics_text.setText( values["lyrics"] )
|
386
|
+
@lyrics_text.setDisabled( @instrumental_checkbox.isChecked() )
|
387
|
+
|
388
|
+
@reviewed_checkbox = Qt::CheckBox.new( self )
|
389
|
+
@reviewed_checkbox.setChecked( false )
|
390
|
+
@reviewed_checkbox.setText( I18n.get( "gui.common.reviewed" ) )
|
391
|
+
|
392
|
+
buttons = create_action_buttons( "split", I18n.get( "gui.common.submit" ) )
|
393
|
+
|
394
|
+
grid_layout = Qt::GridLayout.new( self, 9, 5, 5 )
|
395
|
+
grid_layout.addColSpacing( 2, 15 )
|
396
|
+
grid_layout.addWidget( artist_label, 0, 0, Qt::AlignRight )
|
397
|
+
grid_layout.addWidget( @artist_lineedit, 0, 1 )
|
398
|
+
grid_layout.addWidget( title_label, 0, 3, Qt::AlignRight )
|
399
|
+
grid_layout.addWidget( @title_lineedit, 0, 4 )
|
400
|
+
grid_layout.addWidget( credits_label, 1, 0, Qt::AlignRight )
|
401
|
+
grid_layout.addWidget( @credits_lineedit, 1, 1 )
|
402
|
+
grid_layout.addWidget( lyricist_label, 1, 3, Qt::AlignRight )
|
403
|
+
grid_layout.addWidget( @lyricist_lineedit, 1, 4 )
|
404
|
+
grid_layout.addWidget( year_label, 2, 0, Qt::AlignRight )
|
405
|
+
grid_layout.addWidget( @year_spinbox, 2, 1 )
|
406
|
+
grid_layout.addWidget( album_label, 2, 3, Qt::AlignRight )
|
407
|
+
grid_layout.addWidget( @album_lineedit, 2, 4 )
|
408
|
+
grid_layout.addMultiCellWidget( @instrumental_checkbox, 3, 3, 0, 4 )
|
409
|
+
grid_layout.addMultiCellWidget( @lyrics_text, 4, 4, 0, 4 )
|
410
|
+
grid_layout.addMultiCellWidget( @reviewed_checkbox, 5, 5, 0, 4 )
|
411
|
+
grid_layout.addMultiCellLayout( buttons, 6, 6, 0, 4 )
|
412
|
+
|
413
|
+
resize( 600, 400 )
|
414
|
+
|
415
|
+
connect( @instrumental_checkbox, SIGNAL( "toggled(bool)" ), self, SLOT( "toggle_instrumental_checked(bool)" ) )
|
416
|
+
|
417
|
+
end
|
418
|
+
|
419
|
+
def toggle_instrumental_checked( checked )
|
420
|
+
@lyrics_text.setDisabled( checked )
|
421
|
+
end
|
422
|
+
|
423
|
+
def accept()
|
424
|
+
@values = {
|
425
|
+
"artist" => @artist_lineedit.text(),
|
426
|
+
"year" => @year_spinbox.value(),
|
427
|
+
"album" => @album_lineedit.text(),
|
428
|
+
"title" => @title_lineedit.text(),
|
429
|
+
"lyrics" => @lyrics_text.text(),
|
430
|
+
"instrumental" => @instrumental_checkbox.isChecked(),
|
431
|
+
"lyricist" => @lyricist_lineedit.text(),
|
432
|
+
"credits" => @credits_lineedit.text(),
|
433
|
+
"reviewed" => @reviewed_checkbox.isChecked()
|
434
|
+
}
|
435
|
+
super()
|
436
|
+
end
|
437
|
+
|
438
|
+
end
|
439
|
+
|
440
|
+
class SubmitAlbumDialog < BaseDialog
|
441
|
+
|
442
|
+
slots "browse_image()"
|
443
|
+
|
444
|
+
def initialize( values )
|
445
|
+
super( values )
|
446
|
+
|
447
|
+
setCaption( I18n.get( "gui.submitalbum.title", values["site_name"] ) )
|
448
|
+
|
449
|
+
artist_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.artist" )}</b>", self )
|
450
|
+
@artist_lineedit = Qt::LineEdit.new( values["artist"], self )
|
451
|
+
|
452
|
+
year_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.year" )}</b>", self )
|
453
|
+
@year_spinbox = Qt::SpinBox.new( self )
|
454
|
+
@year_spinbox.setMinValue( 1900 )
|
455
|
+
@year_spinbox.setMaxValue( Date.today().year )
|
456
|
+
@year_spinbox.setValue( values["year"].to_i() )
|
457
|
+
|
458
|
+
month_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.month" )}</b>", self )
|
459
|
+
@month_spinbox = Qt::SpinBox.new( self )
|
460
|
+
@month_spinbox.setMinValue( 0 )
|
461
|
+
@month_spinbox.setMaxValue( 12 )
|
462
|
+
@month_spinbox.setValue( values["month"].to_i() )
|
463
|
+
|
464
|
+
day_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.day" )}</b>", self )
|
465
|
+
@day_spinbox = Qt::SpinBox.new( self )
|
466
|
+
@day_spinbox.setMinValue( 0 )
|
467
|
+
@day_spinbox.setMaxValue( 31 )
|
468
|
+
@day_spinbox.setValue( values["day"].to_i() )
|
469
|
+
|
470
|
+
album_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.album" )}</b>", self )
|
471
|
+
@album_lineedit = Qt::LineEdit.new( values["album"], self )
|
472
|
+
|
473
|
+
image_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.image" )}</b>", self )
|
474
|
+
image_label.setAlignment( Qt::AlignLeft )
|
475
|
+
|
476
|
+
@image_path_lineedit = Qt::LineEdit.new( values["image_path"], self )
|
477
|
+
if ! values.include?( "image_path" )
|
478
|
+
@image_path_lineedit.setEnabled( false )
|
479
|
+
@image_path_lineedit.setText( I18n.get( "gui.submitalbum.coverfound" ) )
|
480
|
+
else
|
481
|
+
@image_button = Qt::PushButton.new( "...", self )
|
482
|
+
connect( @image_button, SIGNAL( "clicked()" ), self, SLOT( "browse_image()" ) )
|
483
|
+
end
|
484
|
+
|
485
|
+
@tracks_text = Qt::TextEdit.new( self )
|
486
|
+
@tracks_text.setWordWrap( Qt::TextEdit::NoWrap )
|
487
|
+
@tracks_text.setTextFormat( Qt::PlainText )
|
488
|
+
@tracks_text.setText( values["tracks"] )
|
489
|
+
|
490
|
+
@reviewed_checkbox = Qt::CheckBox.new( self )
|
491
|
+
@reviewed_checkbox.setChecked( false )
|
492
|
+
@reviewed_checkbox.setText( I18n.get( "gui.common.reviewed" ) )
|
493
|
+
|
494
|
+
buttons = create_action_buttons( "split", I18n.get( "gui.common.submit" ) )
|
495
|
+
|
496
|
+
image_layout = Qt::HBoxLayout.new( 5 )
|
497
|
+
image_layout.addWidget( @image_path_lineedit )
|
498
|
+
image_layout.addWidget( @image_button ) if @values.include?( "image_path" )
|
499
|
+
|
500
|
+
grid_layout = Qt::GridLayout.new( self )
|
501
|
+
grid_layout.setMargin( 5 )
|
502
|
+
grid_layout.setSpacing( 5 )
|
503
|
+
grid_layout.setColStretch( 1, 2 )
|
504
|
+
grid_layout.setColStretch( 3, 2 )
|
505
|
+
grid_layout.setColStretch( 5, 2 )
|
506
|
+
grid_layout.addWidget( artist_label, 0, 0, Qt::AlignRight )
|
507
|
+
grid_layout.addMultiCellWidget( @artist_lineedit, 0, 0, 1, 5 )
|
508
|
+
grid_layout.addWidget( album_label, 1, 0, Qt::AlignRight )
|
509
|
+
grid_layout.addMultiCellWidget( @album_lineedit, 1, 1, 1, 5 )
|
510
|
+
grid_layout.addWidget( year_label, 2, 0, Qt::AlignRight )
|
511
|
+
grid_layout.addWidget( @year_spinbox, 2, 1 )
|
512
|
+
grid_layout.addWidget( month_label, 2, 2, Qt::AlignRight )
|
513
|
+
grid_layout.addWidget( @month_spinbox, 2, 3 )
|
514
|
+
grid_layout.addWidget( day_label, 2, 4, Qt::AlignRight )
|
515
|
+
grid_layout.addWidget( @day_spinbox, 2, 5 )
|
516
|
+
grid_layout.addWidget( image_label, 3, 0, Qt::AlignRight )
|
517
|
+
grid_layout.addMultiCellLayout( image_layout, 3, 3, 1, 5 )
|
518
|
+
grid_layout.addMultiCellWidget( @tracks_text, 4, 4, 0, 5 )
|
519
|
+
grid_layout.addMultiCellWidget( @reviewed_checkbox, 5, 5, 0, 5 )
|
520
|
+
grid_layout.addMultiCellLayout( buttons, 6, 6, 0, 5 )
|
521
|
+
|
522
|
+
resize( 600, 400 )
|
523
|
+
end
|
524
|
+
|
525
|
+
def browse_image()
|
526
|
+
dirname = @image_path_lineedit.text().strip()
|
527
|
+
dirname = QT3.empty_string?( dirname ) ? (ENV["HOME"] ? ENV["HOME"] : ".") : File.dirname( dirname )
|
528
|
+
dialog = Qt::FileDialog.new(
|
529
|
+
dirname,
|
530
|
+
I18n.get( "gui.uploadcover.browseimage.images" ) + " (*.jpg *.JPG *.png *.PNG *.bmp *.BMP);;" +
|
531
|
+
I18n.get( "gui.uploadcover.browseimage.allfiles" ) + " (*)",
|
532
|
+
self,
|
533
|
+
nil,
|
534
|
+
true
|
535
|
+
)
|
536
|
+
dialog.setCaption( I18n.get( "gui.uploadcover.browseimage.title" ) )
|
537
|
+
dialog.setMode( Qt::FileDialog::ExistingFile )
|
538
|
+
if dialog.exec() == Qt::Dialog::Accepted
|
539
|
+
image_path = dialog.selectedFile()
|
540
|
+
@image_path_lineedit.setText( image_path.strip() ) if ! QT3.empty_string?( image_path )
|
541
|
+
end
|
542
|
+
end
|
543
|
+
|
544
|
+
def accept()
|
545
|
+
aux = {
|
546
|
+
"artist" => @artist_lineedit.text(),
|
547
|
+
"album" => @album_lineedit.text(),
|
548
|
+
"year" => @year_spinbox.value(),
|
549
|
+
"month" => @month_spinbox.value(),
|
550
|
+
"day" => @day_spinbox.value(),
|
551
|
+
"tracks" => @tracks_text.text(),
|
552
|
+
"reviewed" => @reviewed_checkbox.isChecked()
|
553
|
+
}
|
554
|
+
aux["image_path"] = @image_path_lineedit.text() if @values.include?( "image_path" )
|
555
|
+
@values = aux
|
556
|
+
super()
|
557
|
+
end
|
558
|
+
|
559
|
+
end
|
560
|
+
|
561
|
+
|
562
|
+
class UploadCoverDialog < BaseDialog
|
563
|
+
|
564
|
+
slots "browse_image()"
|
565
|
+
|
566
|
+
def initialize( values )
|
567
|
+
super( values )
|
568
|
+
|
569
|
+
setCaption( I18n.get( "gui.uploadcover.title", values["site_name"] ) )
|
570
|
+
|
571
|
+
album_group = Qt::GroupBox.new( 2, Qt::Horizontal, I18n.get( "gui.common.album" ), self )
|
572
|
+
|
573
|
+
Qt::Label.new( I18n.get( "gui.common.artist" ), album_group )
|
574
|
+
@artist_lineedit = Qt::LineEdit.new( values["artist"], album_group )
|
575
|
+
|
576
|
+
Qt::Label.new( I18n.get( "gui.common.album" ), album_group )
|
577
|
+
@album_lineedit = Qt::LineEdit.new( values["album"], album_group )
|
578
|
+
|
579
|
+
Qt::Label.new( I18n.get( "gui.common.year" ), album_group )
|
580
|
+
@year_spinbox = Qt::SpinBox.new( album_group )
|
581
|
+
@year_spinbox.setMinValue( 1900 )
|
582
|
+
@year_spinbox.setMaxValue( Date.today().year() )
|
583
|
+
@year_spinbox.setValue( values["year"] )
|
584
|
+
|
585
|
+
image_group = Qt::GroupBox.new( 3, Qt::Horizontal, I18n.get( "gui.common.image" ), self )
|
586
|
+
|
587
|
+
Qt::Label.new( I18n.get( "gui.uploadcover.imagepath" ), image_group )
|
588
|
+
@image_path_lineedit = Qt::LineEdit.new( values["image_path"], image_group )
|
589
|
+
@image_path_lineedit.setText( values["image_path"] )
|
590
|
+
|
591
|
+
@image_button = Qt::PushButton.new( "...", image_group )
|
592
|
+
connect( @image_button, SIGNAL( "clicked()" ), self, SLOT( "browse_image()" ) )
|
593
|
+
|
594
|
+
buttons = create_action_buttons()
|
595
|
+
|
596
|
+
layout = Qt::VBoxLayout.new( self, 5 )
|
597
|
+
layout.addWidget( album_group )
|
598
|
+
layout.addWidget( image_group )
|
599
|
+
layout.addLayout( buttons )
|
600
|
+
|
601
|
+
resize( 400, 100 )
|
602
|
+
end
|
603
|
+
|
604
|
+
|
605
|
+
def browse_image()
|
606
|
+
dirname = @image_path_lineedit.text().strip()
|
607
|
+
dirname = QT3.empty_string?( dirname ) ? (ENV["HOME"] ? ENV["HOME"] : ".") : File.dirname( dirname )
|
608
|
+
dialog = Qt::FileDialog.new(
|
609
|
+
dirname,
|
610
|
+
I18n.get( "gui.uploadcover.browseimage.images" ) + " (*.jpg *.JPG *.png *.PNG *.bmp *.BMP);;" +
|
611
|
+
I18n.get( "gui.uploadcover.browseimage.allfiles" ) + " (*)",
|
612
|
+
self,
|
613
|
+
nil,
|
614
|
+
true
|
615
|
+
)
|
616
|
+
dialog.setCaption( I18n.get( "gui.uploadcover.browseimage.title" ) )
|
617
|
+
dialog.setMode( Qt::FileDialog::ExistingFile )
|
618
|
+
if dialog.exec() == Qt::Dialog::Accepted
|
619
|
+
image_path = dialog.selectedFile()
|
620
|
+
@image_path_lineedit.setText( image_path.strip() ) if ! QT3.empty_string?( image_path )
|
621
|
+
end
|
622
|
+
end
|
623
|
+
|
624
|
+
def accept()
|
625
|
+
@values = {
|
626
|
+
"artist" => @artist_lineedit.text(),
|
627
|
+
"album" => @album_lineedit.text(),
|
628
|
+
"year" => @year_spinbox.value(),
|
629
|
+
"image_path" => @image_path_lineedit.text()
|
630
|
+
}
|
631
|
+
super()
|
632
|
+
end
|
633
|
+
|
634
|
+
end
|
635
|
+
|
636
|
+
class FixPagesDialog < BaseDialog
|
637
|
+
|
638
|
+
slots "fetch_page()"
|
639
|
+
slots "fix_page()"
|
640
|
+
slots "submit_page()"
|
641
|
+
|
642
|
+
def setText( text_edit, text )
|
643
|
+
text_edit.clear()
|
644
|
+
text_edit.append( text )
|
645
|
+
end
|
646
|
+
|
647
|
+
def initialize( values )
|
648
|
+
super( values )
|
649
|
+
|
650
|
+
@fetch_func = eval( @values["fetch_func"] )
|
651
|
+
@fix_func = eval( @values["fix_func"] )
|
652
|
+
@submit_func = eval( @values["submit_func"] )
|
653
|
+
|
654
|
+
setCaption( "#{values["site_name"]} - #{values["title"]}" )
|
655
|
+
|
656
|
+
url_label = Qt::Label.new( "<b>#{I18n.get( "gui.common.url" )}</b>", self )
|
657
|
+
@url_lineedit = Qt::LineEdit.new( values["url"], self )
|
658
|
+
|
659
|
+
@page_text = Qt::TextEdit.new( self )
|
660
|
+
@page_text.setWordWrap( Qt::TextEdit::NoWrap )
|
661
|
+
@page_text.setTextFormat( Qt::PlainText )
|
662
|
+
@page_text.setFamily( "Monospace" )
|
663
|
+
|
664
|
+
@fetch_button = Qt::PushButton.new( I18n.get( "gui.common.load" ), self )
|
665
|
+
@fix_button = Qt::PushButton.new( I18n.get( "gui.common.fix" ), self )
|
666
|
+
@submit_button = Qt::PushButton.new( I18n.get( "gui.common.submit" ), self )
|
667
|
+
|
668
|
+
url_layout = Qt::HBoxLayout.new( 4 )
|
669
|
+
url_layout.setDirection( Qt::BoxLayout::LeftToRight )
|
670
|
+
url_layout.addWidget( url_label )
|
671
|
+
url_layout.addWidget( @url_lineedit )
|
672
|
+
|
673
|
+
buttons_layout = Qt::HBoxLayout.new( 4 )
|
674
|
+
buttons_layout.addStretch()
|
675
|
+
buttons_layout.addWidget( @fetch_button )
|
676
|
+
buttons_layout.addWidget( @fix_button )
|
677
|
+
buttons_layout.addWidget( @submit_button )
|
678
|
+
|
679
|
+
layout = Qt::GridLayout.new( self, 9, 5, 5 )
|
680
|
+
layout.addLayout( url_layout, 0, 0 )
|
681
|
+
layout.addWidget( @page_text, 1, 0 )
|
682
|
+
layout.addLayout( buttons_layout, 2, 0 )
|
683
|
+
|
684
|
+
connect( @fetch_button, SIGNAL( "clicked()" ), self, SLOT( "fetch_page()" ) )
|
685
|
+
connect( @fix_button, SIGNAL( "clicked()" ), self, SLOT( "fix_page()" ) )
|
686
|
+
connect( @submit_button, SIGNAL( "clicked()" ), self, SLOT( "submit_page()" ) )
|
687
|
+
|
688
|
+
resize( 600, 400 )
|
689
|
+
end
|
690
|
+
|
691
|
+
def fetch_page()
|
692
|
+
if (page_content = @fetch_func.call( @url_lineedit.text() ))
|
693
|
+
@original_content = page_content
|
694
|
+
@original_url = @url_lineedit.text()
|
695
|
+
setText( @page_text, page_content )
|
696
|
+
end
|
697
|
+
end
|
698
|
+
|
699
|
+
def fix_page()
|
700
|
+
setText( @page_text, @fix_func.call( @page_text.text() ) ) if @original_content
|
701
|
+
end
|
702
|
+
|
703
|
+
def submit_page()
|
704
|
+
if @original_content != nil && @original_content != (page_content = @page_text.text())
|
705
|
+
if @submit_func.call( @original_url, page_content )
|
706
|
+
@original_content = page_content
|
707
|
+
puts I18n.get( "gui.fixpages.success", @original_url )
|
708
|
+
else
|
709
|
+
puts I18n.get( "gui.fixpages.error", @original_url )
|
710
|
+
end
|
711
|
+
end
|
712
|
+
end
|
713
|
+
|
714
|
+
end
|
715
|
+
|
716
|
+
|
717
|
+
class SearchLyricsDialog < BaseDialog
|
718
|
+
|
719
|
+
def initialize( values )
|
720
|
+
super( values )
|
721
|
+
|
722
|
+
setCaption( I18n.get( "gui.searchlyrics.title" ) )
|
723
|
+
|
724
|
+
group = Qt::GroupBox.new( 2, Qt::Horizontal, I18n.get( "gui.searchlyrics.search" ), self )
|
725
|
+
|
726
|
+
Qt::Label.new( I18n.get( "gui.common.artist" ), group )
|
727
|
+
@artist_lineedit = Qt::LineEdit.new( values["artist"], group )
|
728
|
+
|
729
|
+
Qt::Label.new( I18n.get( "gui.common.song" ), group )
|
730
|
+
@title_lineedit = Qt::LineEdit.new( values["title"], group )
|
731
|
+
|
732
|
+
Qt::Label.new( I18n.get( "gui.common.album" ), group )
|
733
|
+
@album_lineedit = Qt::LineEdit.new( values["album"], group )
|
734
|
+
|
735
|
+
Qt::Label.new( I18n.get( "gui.common.year" ), group )
|
736
|
+
@year_spinbox = Qt::SpinBox.new( group )
|
737
|
+
@year_spinbox.setMinValue( 1900 )
|
738
|
+
@year_spinbox.setMaxValue( Date.today().year() )
|
739
|
+
@year_spinbox.setValue( values["year"] )
|
740
|
+
|
741
|
+
buttons = create_action_buttons()
|
742
|
+
|
743
|
+
layout = Qt::VBoxLayout.new( self, 5 )
|
744
|
+
layout.addWidget( group )
|
745
|
+
layout.addLayout( buttons )
|
746
|
+
|
747
|
+
resize( 300, 100 )
|
748
|
+
end
|
749
|
+
|
750
|
+
def accept()
|
751
|
+
@values = {
|
752
|
+
"artist" => @artist_lineedit.text(),
|
753
|
+
"title" => @title_lineedit.text(),
|
754
|
+
"album" => @album_lineedit.text(),
|
755
|
+
"year" => @year_spinbox.value(),
|
756
|
+
}
|
757
|
+
super()
|
758
|
+
end
|
759
|
+
|
760
|
+
end
|
761
|
+
|
762
|
+
|
763
|
+
class ShowLyricsDialog < BaseDialog
|
764
|
+
|
765
|
+
def initialize( values )
|
766
|
+
super( values )
|
767
|
+
|
768
|
+
title = I18n.get( "gui.lyrics.title", @values["title"], @values["artist"] )
|
769
|
+
title += " [#{@values["site_name"]}]" if @values["site_name"]
|
770
|
+
setCaption( title )
|
771
|
+
|
772
|
+
@lyrics_text = Qt::TextEdit.new( self )
|
773
|
+
@lyrics_text.setTextFormat( Qt::RichText )
|
774
|
+
@lyrics_text.setText( "<qt>" + values["lyrics"].gsub( "\n", "<br/>" ) + "</qt>" )
|
775
|
+
|
776
|
+
layout = Qt::GridLayout.new( self, 1, 1, 5 )
|
777
|
+
layout.addWidget( @lyrics_text, 0, 0 )
|
778
|
+
|
779
|
+
resize( 350, 400 )
|
780
|
+
end
|
781
|
+
|
782
|
+
end
|
783
|
+
|
784
|
+
|
785
|
+
end
|