-
Notifications
You must be signed in to change notification settings - Fork 4
/
wps-launcher.v
96 lines (86 loc) · 2.79 KB
/
wps-launcher.v
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
import ui
import os
const (
win_width = 512
win_height = 512
)
struct App {
mut:
window &ui.Window = unsafe {nil}
}
fn main() {
if os.args.len > 1 {
mut f := os.args[1].to_lower()
if f.contains("~") {
f.replace("~", os.home_dir())
println(f)
}
if f.ends_with(".doc") || f.ends_with(".docx") {
mut process := os.new_process(os.resource_abs_path("opt/kingsoft/wps-office/office6/wps"))
process.set_args([f])
process.run()
}
if f.ends_with(".xls") || f.ends_with(".xlsx") {
mut process := os.new_process(os.resource_abs_path("opt/kingsoft/wps-office/office6/et"))
process.set_args([f])
process.run()
}
if f.ends_with(".ppt") || f.ends_with(".pptx") {
mut process := os.new_process(os.resource_abs_path("opt/kingsoft/wps-office/office6/wpp"))
process.set_args([f])
process.run()
}
if f.ends_with(".pdf") {
mut process := os.new_process(os.resource_abs_path("opt/kingsoft/wps-office/office6/wpspdf"))
process.set_args([f])
process.run()
}
} else {
mut wps := os.resource_abs_path("usr/share/icons/hicolor/256x256/mimetypes/wps-office2019-wpsmain.png")
mut et := os.resource_abs_path("usr/share/icons/hicolor/256x256/mimetypes/wps-office2019-etmain.png")
mut wpp := os.resource_abs_path("usr/share/icons/hicolor/256x256/mimetypes/wps-office2019-wppmain.png")
mut pdf := os.resource_abs_path("usr/share/icons/hicolor/256x256/mimetypes/wps-office2019-pdfmain.png")
mut app := &App{}
app.window = ui.window(
width: win_width
height: win_height
title: 'WPS Office Launcher'
mode: .resizable
children: [
ui.row(
children: [
ui.column(
children: [
ui.picture(width: 256, height: 256, path: wps, on_click: click_wps),
ui.picture(width: 256, height: 256, path: et, on_click: click_et)
]
),
ui.column(
children: [
ui.picture(width: 256, height: 256, path: wpp, on_click: click_wpp),
ui.picture(width: 256, height: 256, path: pdf, on_click: click_wpspdf)
]
),
]
),
]
)
ui.run(app.window)
}
}
fn click_wps(pic &ui.Picture) {
mut process := os.new_process(os.resource_abs_path("opt/kingsoft/wps-office/office6/wps"))
process.run()
}
fn click_et(pic &ui.Picture) {
mut process := os.new_process(os.resource_abs_path("opt/kingsoft/wps-office/office6/et"))
process.run()
}
fn click_wpp(pic &ui.Picture) {
mut process := os.new_process(os.resource_abs_path("opt/kingsoft/wps-office/office6/wpp"))
process.run()
}
fn click_wpspdf(pic &ui.Picture) {
mut process := os.new_process(os.resource_abs_path("opt/kingsoft/wps-office/office6/wpspdf"))
process.run()
}