-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialog.js
180 lines (167 loc) · 5.21 KB
/
dialog.js
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/**
* ダイアログ関連
*
*/
//--------------------------------
// モジュール
//--------------------------------
const { app, dialog, remote } = require('electron');
const common = require('./common');
const config = require('./config');
const i18n = require('./i18n');
const path = require('path');
//--------------------------------
// グローバル変数
//--------------------------------
const locale = config.get('locale') // 「言語」の設定情報を取得
const _ = new i18n(locale, 'dialog') // ダイアログ用のテキスト情報をロード
const _d = new i18n(locale, 'default') // デフォルトのテキスト情報をロード
/**
* 「今すぐ再起動しますか」ダイアログ
*
* @param {object} win
*/
const reboot = function(win){
const dialogOpts = {
type: 'info',
buttons: [_.t('BUTTON-REBOOT'), _.t('BUTTON-LATER')],
message: _.t('REBOOT_CONFIRM_TITLE'),
detail: _.t('REBOOT_CONFIRM_DETAIL')
}
// すぐに再起動するか確認
dialog.showMessageBox(win, dialogOpts).then((returnValue) => {
if (returnValue.response === 0){
app.relaunch() // 再起動の準備
app.exit(0) // アプリ終了
}
})
}
/**
* アバウト画面を表示
*/
const openAboutDialog = function() {
p = require('./package.json');
let re = dialog.showMessageBox(common.mainWin, {
title:_.t('ABOUT'),
message: _d.t('APPNAME') + '3' ,
detail: 'Ver.'+ p.version + '\r©' + _d.t('AUTHOR')
});
//console.log(re);
}
/**
* 動画/音声を開くファイルダイアログを表示
*/
const openVideoDialog = function() {
//未保存データの処理
if (common.isDirty == true) {
const lang = common.config.get('locale') || app.getLocale();
const _ = new i18n(lang, 'dialog');
const options = {
type: 'warning',
buttons: [_.t('UNSAVED_DATA_SAVE_CONTINUE'), _.t('UNSAVED_DATA_DISPOSE_CONTINUE'), _.t('UNSAVED_DATA_CANCEL')],
title: _.t('UNSAVED_DATA_TITLE'),
message: _.t('UNSAVED_DATA_MESSAGE_CONTINUE').replace('%1', path.basename(common.mediaPath).replace(path.extname(common.mediaPath),".dggn.txt")),
defaultId: 3,
cancelId: 2
};
switch (this.showConfirmation(options)) {
case 0: //上書き保存して開く
common.saveLog();
break;
case 1: //破棄して開く
break;
case 2: //キャンセル
return;
}
}
let result = dialog.showOpenDialogSync(common.mainWin, {
title: _.t('OPEN_VIDEO_TITLE'),
//defaultPath:"",
//message: "", //masOS only
properties: ['openFile'],
filters: [
{ name: _.t('MEDIAFILES'), extensions: ['mp4','mp3','wav','webm','ogv','ogg'] },
//{ name: _.t('ALLFILES'), extensions: ['*'] },
]
});
if (result != undefined) {
//common.app.createWindow();
common.clearLog();
common.openMediaFile(result[0]);
}
}
/**
* ログファイルを開くダイアログを表示
*/
const openLog = function() {
let result = dialog.showOpenDialogSync(common.mainWin, {
title: _.t('OPEN_LOG_FILE'),
defaultPath: path.dirname(common.mediaPath),
//message: "", //masOS only
properties: ['openFile'],
filters: [
{ name: _.t('MULTI_EXTENTIONS'), extensions: ['txt','csv','srt'] },
{ name: _.t('LOGFILES'), extensions: ['dggn.txt'] },
{ name: _.t('PREMIERE_TXT'), extensions: ['txt'] },
{ name: _.t('PREMIERE_MARKER_CSV'), extensions: ['csv'] },
{ name: _.t('SRT_FILE'), extensions: ['srt'] }
]
});
if (result != undefined) {
let format = '';
if (result[0].endsWith('.dggn.txt')) {
//動画眼2.0形式ログ
common.openLogFile(result[0], false);
} else if (result[0].endsWith('.txt')) {
//その他の.txt拡張子の形式
common.importLogFile(result[0], false);
} else if (result[0].endsWith('.csv')) {
//Premier Pro マーカーCSVファイル
common.importPremiereMarkerCSVFile(result[0], false);
} else if (result[0].endsWith('.srt')) {
//srt形式ファイル
common.importSrtFile(result[0], false);
}
}
}
/**
* ログファイルの別名保存ダイアログを表示
*/
const saveLogAs = function() {
let savePath = dialog.showSaveDialogSync(common.mainWin, {
title: _.t('SAVE_LOG_FILE_AS'),
defaultPath:path.dirname(common.mediaPath),
filters: [
{ name: _.t('LOGFILES'), extensions: ['dggn.txt'] },
{ name: _.t('LOGFILES1'), extensions: ['txt'] },
{ name: _.t('YOURUBE_CHAPTER'), extensions: ['youtube.txt'] },
]
});
if (savePath != undefined) {
let format = '';
if (savePath.endsWith('.dggn.txt')) {
format = '2.0';
} else if (savePath.endsWith('.youtube.txt')) {
format = 'youtube';
} else {
format = '1.0';
}
console.log(format);
common.saveLog(savePath, format, false);
}
}
const showConfirmation = function(options) {
const result = dialog.showMessageBoxSync(common.mainWin, options);
return result;
}
//--------------------------------
// exports
//--------------------------------
module.exports = {
reboot: reboot,
openAboutDialog: openAboutDialog,
openVideoDialog: openVideoDialog,
openLog: openLog,
saveLogAs: saveLogAs,
showConfirmation: showConfirmation,
}