ruby-netmon-qt 1.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef00043ddd797d7eb54541887a7fc555b4cf364776c4816fd1c0595846b1bfa5
4
- data.tar.gz: ae2776b9ba39d934ca00e2429e025b45b7dc2465a45ff63c3632051c4cadcbbc
3
+ metadata.gz: ec8bdd6a57990ad26094807149172feac0d65dc8790a3788216085f545090144
4
+ data.tar.gz: c07ba1349e86146dee02190e0d6aae81c008387c37f3c23a2e6c4aea08bcf8c2
5
5
  SHA512:
6
- metadata.gz: 97834105620607927518ef39a38e3430cd22debf3c1e56637c850ab7ee1f63e774307764bf938e45512efd607d0b6d4fbc84bb016437d252281e5d6c12f0f371
7
- data.tar.gz: c43afc8ec1c5d1fac3e97a8cce5fc90f8844d11727172ccdb57a31e54442e86a90228678003d47dd3eca41b1749c000ef9a4913c1430c66ab9bf61d32a31e430
6
+ metadata.gz: 23ce6e3b2d47265fc48fa4304a44b6915bf5b60bd511f0b659adba90adc7e0a239096e6e4db6819433c3dde6bcbcca6868deea45ebf9f9ba4363fd2c8e96b29c
7
+ data.tar.gz: 3f8b114bcfc95c85953c6280f49b4223d0b740ea979ef1c87d43d437024f6c2fc2e324106ff48dd2b1e46c1c3131065180e1985f08f501a8380a50d670127f7f
data/.rubocop.yml CHANGED
@@ -8,3 +8,7 @@ AllCops:
8
8
  Exclude:
9
9
  - "bin/**/*"
10
10
  - "tmp/**/*"
11
+
12
+ Style/GlobalVars:
13
+ AllowedVariables:
14
+ - '$qApp'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # NetmonQt
1
+ # RubyNetmonQt
2
2
 
3
3
  A simple network monitor on Linux.
4
4
 
@@ -18,7 +18,7 @@ gem install ruby-netmon-qt
18
18
  To launch the GUI:
19
19
 
20
20
  ```sh
21
- netmon-qt
21
+ ruby-netmon-qt
22
22
  ```
23
23
 
24
24
  ## Screenshot
@@ -1,4 +1,4 @@
1
- class ConnsTableView < RubyQt6::Bando::QWidget
1
+ class MainWindowConnsTableView < RubyQt6::Bando::QWidget
2
2
  class SortFilterProxyModel < RubyQt6::Bando::QSortFilterProxyModel
3
3
  def filter_accepts_row(source_row, source_parent)
4
4
  {
@@ -1,4 +1,4 @@
1
- class ConnsTableView < RubyQt6::Bando::QWidget
1
+ class MainWindowConnsTableView < RubyQt6::Bando::QWidget
2
2
  class StatusBar < RubyQt6::Bando::QWidget
3
3
  def initialize(storeproxymodel)
4
4
  super()
@@ -1,4 +1,4 @@
1
- class ConnsTableView < RubyQt6::Bando::QWidget
1
+ class MainWindowConnsTableView < RubyQt6::Bando::QWidget
2
2
  # rubocop:disable Layout
3
3
  COLUMN_CONNECTION_KEY = 0
4
4
  COLUMN_PROCESS_NAME = 1
@@ -2,7 +2,7 @@ require_relative "connstableview/sortfilterproxymodel"
2
2
  require_relative "connstableview/statusbar"
3
3
  require_relative "connstableview/store"
4
4
 
5
- class ConnsTableView < RubyQt6::Bando::QWidget
5
+ class MainWindowConnsTableView < RubyQt6::Bando::QWidget
6
6
  QSS_BUTTON_AUTOREFRESH = "
7
7
  QPushButton {
8
8
  background: #EFF0F1;
@@ -24,9 +24,6 @@ class ConnsTableView < RubyQt6::Bando::QWidget
24
24
  slot "_on_autorefreshbtn_toggled(bool)"
25
25
  slot "_on_autorefresh_timer_timeout()"
26
26
  slot "_on_tableview_custom_context_menu_requested(QPoint)"
27
- slot "_on_endprocess_action_triggered()"
28
- slot "_on_whois_action_triggered()"
29
- slot "_on_copy_action_triggered()"
30
27
  end
31
28
 
32
29
  attr_reader :processfilter, :protocolfilter, :statefilter, :userfilter
@@ -59,15 +56,13 @@ class ConnsTableView < RubyQt6::Bando::QWidget
59
56
  end
60
57
 
61
58
  def initialize_actions
62
- @endprocess_action = initialize_actions_act(QIcon::ThemeIcon::ApplicationExit, "End Process", :_on_endprocess_action_triggered)
63
- @whois_action = initialize_actions_act(QIcon::ThemeIcon::EditFind, "", :_on_whois_action_triggered)
64
- @copy_action = initialize_actions_act(QIcon::ThemeIcon::EditCopy, "", :_on_copy_action_triggered)
59
+ @endprocess_action = initialize_actions_act(QIcon::ThemeIcon::ApplicationExit, "End Process")
60
+ @whois_action = initialize_actions_act(QIcon::ThemeIcon::EditFind, "")
61
+ @copy_action = initialize_actions_act(QIcon::ThemeIcon::EditCopy, "")
65
62
  end
66
63
 
67
- def initialize_actions_act(icon, text, slot)
68
- action = QAction.new(QIcon.from_theme(icon), text, self)
69
- action.triggered.connect(self, slot)
70
- action
64
+ def initialize_actions_act(icon, text)
65
+ QAction.new(QIcon.from_theme(icon), text, self)
71
66
  end
72
67
 
73
68
  def initialize_toolbar
@@ -201,40 +196,36 @@ class ConnsTableView < RubyQt6::Bando::QWidget
201
196
  menu.set_attribute(Qt::WA_DeleteOnClose)
202
197
 
203
198
  pid = @lastindex.sibling_at_column(COLUMN_PROCESS_ID).data.value.to_s
204
- remote_address = @lastindex.sibling_at_column(COLUMN_REMOTE_ADDRESS).data.value
205
- remote_address = remote_address.contains(".") ? remote_address : "#{remote_address[0, 12]}..."
199
+ remote_address = @lastindex.sibling_at_column(COLUMN_REMOTE_ADDRESS).data.value.to_s
200
+ remote_address = remote_address.include?(".") ? remote_address : "#{remote_address[0, 12]}..."
201
+ text = @lastindex.data.value.to_s
206
202
 
207
203
  @endprocess_action.set_enabled(pid.to_i.nonzero?)
208
204
  @whois_action.set_text("Whois #{remote_address} - via IPinfo")
209
- @copy_action.set_text("Copy \"#{@lastindex.data.value}\"")
205
+ @copy_action.set_text("Copy \"#{text}\"")
210
206
 
211
207
  menu.add_action(@endprocess_action)
212
208
  menu.add_separator
213
209
  menu.add_action(@whois_action)
214
210
  menu.add_action(@copy_action)
215
211
 
216
- menu.exec(@tableview.viewport.map_to_global(position))
212
+ case menu.exec(@tableview.viewport.map_to_global(position))
213
+ when @endprocess_action then _on_endprocess_action_triggered(pid)
214
+ when @whois_action then _on_whois_action_triggered(remote_address)
215
+ when @copy_action then _on_copy_action_triggered(text)
216
+ end
217
217
  end
218
218
 
219
- def _on_endprocess_action_triggered
220
- return unless @lastindex.valid?
221
-
222
- pid = @lastindex.sibling_at_column(COLUMN_PROCESS_ID).data.value
219
+ def _on_endprocess_action_triggered(pid)
223
220
  QProcess.execute("kill", QStringList.new << "-9" << pid)
224
221
  end
225
222
 
226
- def _on_whois_action_triggered
227
- return unless @lastindex.valid?
228
-
229
- remote_address = @lastindex.sibling_at_column(COLUMN_REMOTE_ADDRESS).data.value
223
+ def _on_whois_action_triggered(remote_address)
230
224
  url = QUrl.new("https://ipinfo.io/#{remote_address}")
231
225
  QDesktopServices.open_url(url)
232
226
  end
233
227
 
234
- def _on_copy_action_triggered
235
- return unless @lastindex.valid?
236
-
237
- text = @lastindex.data.value
228
+ def _on_copy_action_triggered(text)
238
229
  QApplication.clipboard.set_text(text)
239
230
  end
240
231
  end
@@ -0,0 +1,28 @@
1
+ class MainWindow < RubyQt6::Bando::QMainWindow
2
+ private
3
+
4
+ def initialize_ui
5
+ initialize_central_widget
6
+ initialize_statusbar
7
+
8
+ set_context_menu_policy(Qt::NoContextMenu)
9
+ end
10
+
11
+ def initialize_central_widget
12
+ @connstableview = MainWindowConnsTableView.new
13
+
14
+ centralwidget = QWidget.new
15
+ mainlayout = QHBoxLayout.new(centralwidget)
16
+ mainlayout.add_widget(@connstableview)
17
+
18
+ set_central_widget(centralwidget)
19
+ end
20
+
21
+ def initialize_statusbar
22
+ statusbar = QStatusBar.new
23
+ statusbar.set_contents_margins(12, 0, 12, 0)
24
+ statusbar.add_permanent_widget(@connstableview.statusbar, 1)
25
+
26
+ set_status_bar(statusbar)
27
+ end
28
+ end
@@ -1,3 +1,6 @@
1
+ require_relative "mainwindow/components"
2
+ require_relative "mainwindow/ui"
3
+
1
4
  class MainWindow < RubyQt6::Bando::QMainWindow
2
5
  q_object do
3
6
  end
@@ -5,36 +8,12 @@ class MainWindow < RubyQt6::Bando::QMainWindow
5
8
  def initialize
6
9
  super
7
10
 
8
- initialize_central_widget
9
- initialize_statusbar
10
-
11
- set_context_menu_policy(Qt::NoContextMenu)
11
+ initialize_ui
12
12
  NetmonQt.settings.GET_mainwindow_geometry_and_restore_to(self)
13
13
  end
14
14
 
15
15
  def close_event(evt)
16
16
  NetmonQt.settings.PUT_mainwindow_geometry(self)
17
-
18
17
  _close_event(evt)
19
18
  end
20
-
21
- private
22
-
23
- def initialize_central_widget
24
- @connstableview = ConnsTableView.new
25
-
26
- centralwidget = QWidget.new
27
- mainlayout = QHBoxLayout.new(centralwidget)
28
- mainlayout.add_widget(@connstableview)
29
-
30
- set_central_widget(centralwidget)
31
- end
32
-
33
- def initialize_statusbar
34
- statusbar = QStatusBar.new
35
- statusbar.set_contents_margins(12, 0, 12, 0)
36
- statusbar.add_permanent_widget(@connstableview.statusbar, 1)
37
-
38
- set_status_bar(statusbar)
39
- end
40
19
  end
data/lib/netmon-qt/app.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require_relative "config"
2
2
  require_relative "lib"
3
3
 
4
- require_relative "app/components"
5
4
  require_relative "app/services"
6
5
  require_relative "app/views"
7
6
 
@@ -17,7 +16,8 @@ module NetmonQt
17
16
  end
18
17
 
19
18
  def exec
20
- Contrib::SigHandler.new(@app)
19
+ handler = Ctrlc::Handler.new
20
+ handler.exec
21
21
 
22
22
  @mainwindow.show
23
23
  @app.exec
@@ -1,12 +1,14 @@
1
- module Contrib
2
- class SigHandler < RubyQt6::Bando::QObject
1
+ module Ctrlc
2
+ class Handler < RubyQt6::Bando::QObject
3
3
  q_object do
4
4
  slot "_noop()"
5
5
  end
6
6
 
7
- def initialize(parent)
8
- super
7
+ def initialize
8
+ super($qApp)
9
+ end
9
10
 
11
+ def exec
10
12
  ["INT", "TERM"].each do |sig|
11
13
  Signal.trap(sig) { |_| QApplication.quit }
12
14
  end
@@ -0,0 +1 @@
1
+ require_relative "ctrlc/handler"
data/lib/netmon-qt/lib.rb CHANGED
@@ -1,2 +1,2 @@
1
- require_relative "lib/contrib"
1
+ require_relative "lib/ctrlc"
2
2
  require_relative "lib/netmon"
@@ -1,3 +1,3 @@
1
1
  module NetmonQt
2
- VERSION = "1.0.1"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-netmon-qt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Doe
@@ -37,11 +37,10 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '6.0'
40
- description: A simple network monitor on Linux.
41
40
  email:
42
41
  - johndoe@example.com
43
42
  executables:
44
- - netmon-qt
43
+ - ruby-netmon-qt
45
44
  extensions: []
46
45
  extra_rdoc_files: []
47
46
  files:
@@ -50,7 +49,7 @@ files:
50
49
  - LICENSE
51
50
  - README.md
52
51
  - Rakefile
53
- - exe/netmon-qt
52
+ - exe/ruby-netmon-qt
54
53
  - lib/netmon-qt.rb
55
54
  - lib/netmon-qt/app.rb
56
55
  - lib/netmon-qt/app/assets/README.md
@@ -326,21 +325,22 @@ files:
326
325
  - lib/netmon-qt/app/assets/flags/za.svg
327
326
  - lib/netmon-qt/app/assets/flags/zm.svg
328
327
  - lib/netmon-qt/app/assets/flags/zw.svg
329
- - lib/netmon-qt/app/components.rb
330
- - lib/netmon-qt/app/components/connstableview.rb
331
- - lib/netmon-qt/app/components/connstableview/sortfilterproxymodel.rb
332
- - lib/netmon-qt/app/components/connstableview/statusbar.rb
333
- - lib/netmon-qt/app/components/connstableview/store.rb
334
328
  - lib/netmon-qt/app/services.rb
335
329
  - lib/netmon-qt/app/services/conns_lookup_service.rb
336
330
  - lib/netmon-qt/app/views.rb
337
331
  - lib/netmon-qt/app/views/mainwindow.rb
332
+ - lib/netmon-qt/app/views/mainwindow/components.rb
333
+ - lib/netmon-qt/app/views/mainwindow/components/connstableview.rb
334
+ - lib/netmon-qt/app/views/mainwindow/components/connstableview/sortfilterproxymodel.rb
335
+ - lib/netmon-qt/app/views/mainwindow/components/connstableview/statusbar.rb
336
+ - lib/netmon-qt/app/views/mainwindow/components/connstableview/store.rb
337
+ - lib/netmon-qt/app/views/mainwindow/ui.rb
338
338
  - lib/netmon-qt/config.rb
339
339
  - lib/netmon-qt/config/initializers/qt6.rb
340
340
  - lib/netmon-qt/config/settings.rb
341
341
  - lib/netmon-qt/lib.rb
342
- - lib/netmon-qt/lib/contrib.rb
343
- - lib/netmon-qt/lib/contrib/sighandler.rb
342
+ - lib/netmon-qt/lib/ctrlc.rb
343
+ - lib/netmon-qt/lib/ctrlc/handler.rb
344
344
  - lib/netmon-qt/lib/netmon.rb
345
345
  - lib/netmon-qt/lib/netmon/connection.rb
346
346
  - lib/netmon-qt/lib/netmon/localaddresschecker.rb
@@ -348,11 +348,9 @@ files:
348
348
  - lib/netmon-qt/version.rb
349
349
  - misc/screenshots/mainwindow.png
350
350
  homepage: https://github.com/souk4711/ruby-netmon-qt
351
- licenses: []
352
- metadata:
353
- homepage_uri: https://github.com/souk4711/ruby-netmon-qt
354
- source_code_uri: https://github.com/souk4711/ruby-netmon-qt
355
- changelog_uri: https://github.com/souk4711/ruby-netmon-qt
351
+ licenses:
352
+ - GPL-3.0-only
353
+ metadata: {}
356
354
  rdoc_options: []
357
355
  require_paths:
358
356
  - lib
@@ -1 +0,0 @@
1
- require_relative "contrib/sighandler"
File without changes