Skip to content
This repository was archived by the owner on May 27, 2023. It is now read-only.

Commit e9c0b75

Browse files
Add files via upload
1 parent 7254d75 commit e9c0b75

File tree

10 files changed

+366
-0
lines changed

10 files changed

+366
-0
lines changed

LOGO.ico

22.1 KB
Binary file not shown.

LOGO.png

162 KB
Loading

Version.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef VERSION_H
2+
#define VERSION_H
3+
4+
#include <QString>
5+
6+
static QString _VGL2XSL_Version="0.1.0";
7+
8+
#endif // VERSION_H

VogenLyrics2XSLyrics.pro

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
QT += core gui
2+
3+
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4+
5+
CONFIG += c++11
6+
7+
# You can make your code fail to compile if it uses deprecated APIs.
8+
# In order to do so, uncomment the following line.
9+
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
10+
11+
SOURCES += \
12+
main.cpp \
13+
mainwindow.cpp
14+
15+
HEADERS += \
16+
Version.h \
17+
mainwindow.h
18+
19+
FORMS += \
20+
mainwindow.ui
21+
22+
# Default rules for deployment.
23+
qnx: target.path = /tmp/$${TARGET}/bin
24+
else: unix:!android: target.path = /opt/$${TARGET}/bin
25+
!isEmpty(target.path): INSTALLS += target
26+
27+
RESOURCES += \
28+
src.qrc
29+
30+
OTHER_FILES += icon.rc
31+
32+
RC_FILE += icon.rc

icon.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IDI_ICON1 ICON DISCARDABLE "LOGO.ico"

main.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "mainwindow.h"
2+
3+
#include <QApplication>
4+
5+
int main(int argc, char *argv[])
6+
{
7+
QApplication a(argc, argv);
8+
MainWindow w;
9+
w.show();
10+
return a.exec();
11+
}

mainwindow.cpp

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#include "mainwindow.h"
2+
#include "ui_mainwindow.h"
3+
4+
MainWindow::MainWindow(QWidget *parent)
5+
: QMainWindow(parent)
6+
, ui(new Ui::MainWindow)
7+
{
8+
ui->setupUi(this);
9+
ui->about->setText("Vogen采样歌词转XStudio采样歌词 版本"+::_VGL2XSL_Version+"\n©2021 無常.保留所有权利.\nQt版本:"+QString(qVersion())+" 编译时间:"+QString(__DATE__)+" "+QString(__TIME__));
10+
}
11+
12+
MainWindow::~MainWindow()
13+
{
14+
delete ui;
15+
}
16+
17+
18+
void MainWindow::on_getInput_clicked()
19+
{
20+
QString dir=QFileDialog::getExistingDirectory(this,"选择一个目录",QDir::currentPath());
21+
if(!dir.isEmpty()){
22+
QDir::setCurrent(dir);
23+
ui->InputDir->setText(dir);
24+
}
25+
}
26+
27+
28+
void MainWindow::on_getOutput_clicked()
29+
{
30+
QString dir=QFileDialog::getExistingDirectory(this,"选择一个目录",QDir::currentPath());
31+
if(!dir.isEmpty()){
32+
QDir::setCurrent(dir);
33+
ui->OutputDir->setText(dir);
34+
}
35+
}
36+
37+
38+
void MainWindow::on_Run_clicked()
39+
{
40+
ui->out->clear();
41+
ui->out->appendPlainText("["+QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")+"]");
42+
if(ui->InputDir->text().isEmpty()){
43+
ui->out->appendPlainText("未选择输入目录!");
44+
return;
45+
}
46+
if(ui->OutputDir->text().isEmpty()){
47+
ui->out->appendPlainText("未选择输出目录!");
48+
return;
49+
}
50+
int modef=0;
51+
QDir dir(ui->InputDir->text());
52+
dir.setFilter(QDir::Files);
53+
for(uint i=0;i<dir.count();i++){
54+
if(dir[i].endsWith(".txt")){
55+
QFile infile(dir.path()+"/"+dir[i]);
56+
if(infile.open(QIODevice::ReadOnly|QIODevice::Text)){
57+
ui->out->appendPlainText("读取文件:"+dir.path()+"/"+dir[i]);
58+
QString indata=infile.readAll();
59+
infile.close();
60+
61+
QStringList indatasplit=indata.split("\n",Qt::SkipEmptyParts);
62+
QString outdata;
63+
for(int j=0;j<indatasplit.size();j++){
64+
QStringList indatachar=indatasplit.at(j).split(" ",Qt::SkipEmptyParts);
65+
QString outstemp;
66+
for(int k=0;k<indatachar.size();k++){
67+
if(indatachar.at(k).size()>=2){
68+
outstemp+=indatachar.at(k).at(0);
69+
}
70+
}
71+
outdata+=outstemp;
72+
outdata+="\n";
73+
}
74+
75+
QFile outfile(ui->OutputDir->text()+"/"+dir[i]);
76+
bool okf=true;
77+
78+
if(outfile.exists()){
79+
if(modef==-1){
80+
okf=false;
81+
}else if(modef==1){
82+
okf=true;
83+
}else{
84+
QMessageBox::StandardButton result=QMessageBox::warning(this,"覆盖文件","文件"+ui->OutputDir->text()+"/"+dir[i]+"已经存在!\n是否覆盖?",QMessageBox::StandardButtons(QMessageBox::Yes|QMessageBox::YesToAll|QMessageBox::No|QMessageBox::NoToAll|QMessageBox::Cancel),QMessageBox::Cancel);
85+
if(result==QMessageBox::Yes){
86+
okf=true;
87+
}else if(result==QMessageBox::YesToAll){
88+
okf=true;
89+
modef=1;
90+
}else if(result==QMessageBox::No){
91+
okf=false;
92+
}else if(result==QMessageBox::NoToAll){
93+
okf=false;
94+
modef=-1;
95+
}else{
96+
ui->out->appendPlainText("操作取消!");
97+
break;
98+
}
99+
}
100+
}
101+
if(okf){
102+
if(outfile.open(QIODevice::WriteOnly|QIODevice::Text|QIODevice::Truncate)){
103+
ui->out->appendPlainText("写入文件:"+ui->OutputDir->text()+"/"+dir[i]);
104+
outfile.write(outdata.toUtf8());
105+
outfile.close();
106+
}else{
107+
ui->out->appendPlainText("未能写入文件:"+ui->OutputDir->text()+"/"+dir[i]);
108+
}
109+
}else{
110+
ui->out->appendPlainText("跳过文件:"+ui->OutputDir->text()+"/"+dir[i]);
111+
}
112+
113+
114+
}else{
115+
ui->out->appendPlainText("未能读取文件:"+dir.path()+"/"+dir[i]);
116+
}
117+
}
118+
}
119+
}
120+

mainwindow.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#ifndef MAINWINDOW_H
2+
#define MAINWINDOW_H
3+
4+
#include <QMainWindow>
5+
#include "Version.h"
6+
#include <QDir>
7+
#include <QDateTime>
8+
#include <QFile>
9+
#include <QStringList>
10+
#include <QFileDialog>
11+
#include <QMessageBox>
12+
13+
QT_BEGIN_NAMESPACE
14+
namespace Ui { class MainWindow; }
15+
QT_END_NAMESPACE
16+
17+
class MainWindow : public QMainWindow
18+
{
19+
Q_OBJECT
20+
21+
public:
22+
MainWindow(QWidget *parent = nullptr);
23+
~MainWindow();
24+
25+
private slots:
26+
void on_getInput_clicked();
27+
28+
void on_getOutput_clicked();
29+
30+
void on_Run_clicked();
31+
32+
private:
33+
Ui::MainWindow *ui;
34+
};
35+
#endif // MAINWINDOW_H

mainwindow.ui

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>MainWindow</class>
4+
<widget class="QMainWindow" name="MainWindow">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>800</width>
10+
<height>600</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Vogen采样歌词转XStudio采样歌词</string>
15+
</property>
16+
<property name="windowIcon">
17+
<iconset resource="src.qrc">
18+
<normaloff>:/icons/LOGO.png</normaloff>:/icons/LOGO.png</iconset>
19+
</property>
20+
<widget class="QWidget" name="centralwidget">
21+
<layout class="QGridLayout" name="gridLayout_3">
22+
<item row="0" column="0">
23+
<widget class="QGroupBox" name="groupBox">
24+
<property name="title">
25+
<string>Vogen采样歌词转XStudio采样歌词</string>
26+
</property>
27+
<layout class="QGridLayout" name="gridLayout">
28+
<item row="0" column="0">
29+
<widget class="QLabel" name="label">
30+
<property name="text">
31+
<string>输入文件夹</string>
32+
</property>
33+
<property name="buddy">
34+
<cstring>InputDir</cstring>
35+
</property>
36+
</widget>
37+
</item>
38+
<item row="0" column="1" colspan="3">
39+
<widget class="QLineEdit" name="InputDir">
40+
<property name="readOnly">
41+
<bool>true</bool>
42+
</property>
43+
<property name="placeholderText">
44+
<string>未选择文件夹</string>
45+
</property>
46+
</widget>
47+
</item>
48+
<item row="0" column="4">
49+
<widget class="QPushButton" name="getInput">
50+
<property name="text">
51+
<string>浏览</string>
52+
</property>
53+
</widget>
54+
</item>
55+
<item row="1" column="0">
56+
<widget class="QLabel" name="label_2">
57+
<property name="text">
58+
<string>输出文件夹</string>
59+
</property>
60+
<property name="buddy">
61+
<cstring>OutputDir</cstring>
62+
</property>
63+
</widget>
64+
</item>
65+
<item row="1" column="1" colspan="3">
66+
<widget class="QLineEdit" name="OutputDir">
67+
<property name="readOnly">
68+
<bool>true</bool>
69+
</property>
70+
<property name="placeholderText">
71+
<string>未选择文件夹</string>
72+
</property>
73+
</widget>
74+
</item>
75+
<item row="1" column="4">
76+
<widget class="QPushButton" name="getOutput">
77+
<property name="text">
78+
<string>浏览</string>
79+
</property>
80+
</widget>
81+
</item>
82+
<item row="2" column="1">
83+
<spacer name="horizontalSpacer">
84+
<property name="orientation">
85+
<enum>Qt::Horizontal</enum>
86+
</property>
87+
<property name="sizeHint" stdset="0">
88+
<size>
89+
<width>241</width>
90+
<height>20</height>
91+
</size>
92+
</property>
93+
</spacer>
94+
</item>
95+
<item row="2" column="2">
96+
<widget class="QPushButton" name="Run">
97+
<property name="text">
98+
<string>转换</string>
99+
</property>
100+
</widget>
101+
</item>
102+
<item row="2" column="3">
103+
<spacer name="horizontalSpacer_2">
104+
<property name="orientation">
105+
<enum>Qt::Horizontal</enum>
106+
</property>
107+
<property name="sizeHint" stdset="0">
108+
<size>
109+
<width>240</width>
110+
<height>20</height>
111+
</size>
112+
</property>
113+
</spacer>
114+
</item>
115+
</layout>
116+
</widget>
117+
</item>
118+
<item row="1" column="0">
119+
<widget class="QGroupBox" name="groupBox_2">
120+
<property name="title">
121+
<string>输出</string>
122+
</property>
123+
<layout class="QGridLayout" name="gridLayout_2">
124+
<item row="0" column="0">
125+
<widget class="QPlainTextEdit" name="out">
126+
<property name="readOnly">
127+
<bool>true</bool>
128+
</property>
129+
<property name="placeholderText">
130+
<string>无输出</string>
131+
</property>
132+
</widget>
133+
</item>
134+
</layout>
135+
</widget>
136+
</item>
137+
<item row="2" column="0">
138+
<widget class="QLabel" name="about">
139+
<property name="text">
140+
<string/>
141+
</property>
142+
<property name="alignment">
143+
<set>Qt::AlignCenter</set>
144+
</property>
145+
</widget>
146+
</item>
147+
</layout>
148+
</widget>
149+
</widget>
150+
<resources>
151+
<include location="src.qrc"/>
152+
</resources>
153+
<connections/>
154+
</ui>

src.qrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<RCC>
2+
<qresource prefix="/icons">
3+
<file>LOGO.png</file>
4+
</qresource>
5+
</RCC>

0 commit comments

Comments
 (0)