Skip to content

Commit 27e7f88

Browse files
committed
update builder code
1 parent 14057cd commit 27e7f88

File tree

7 files changed

+976
-1
lines changed

7 files changed

+976
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
open_converter.pro.user
2-
build*
2+
build-*
33
.vscode
44
.DS_Store
55
./src/.DS_Store
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright 2024 Jack Lau
3+
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef ENCODE_SETTING_H
19+
#define ENCODE_SETTING_H
20+
21+
#include <QMainWindow>
22+
#include "encode_parameter.h"
23+
24+
namespace Ui {
25+
class EncodeSetting;
26+
}
27+
28+
class EncodeSetting : public QMainWindow {
29+
Q_OBJECT
30+
protected:
31+
// this event is called, when a new translator is loaded or the system
32+
// language is changed
33+
void changeEvent(QEvent *);
34+
35+
public:
36+
explicit EncodeSetting(QWidget *parent = nullptr,
37+
EncodeParameter *encodeParamter = NULL);
38+
39+
~EncodeSetting();
40+
41+
bool get_Encode_Parameter(EncodeParameter *ep);
42+
43+
bool get_Available();
44+
45+
public slots:
46+
void cancel_Pushed();
47+
48+
void apply_Pushed();
49+
50+
private:
51+
EncodeParameter *encodeParameter = NULL;
52+
53+
Ui::EncodeSetting *ui;
54+
};
55+
56+
#endif // ENCODE_SETTING_H
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* Copyright 2024 Jack Lau
3+
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef OPEN_CONVERTER_H
19+
#define OPEN_CONVERTER_H
20+
21+
#include <QMainWindow>
22+
#include "info.h"
23+
#include "converter.h"
24+
#include "encode_setting.h"
25+
#include <QMessageBox>
26+
#include <QFileDialog>
27+
#include <QThread>
28+
#include <QTranslator>
29+
#include <QDragEnterEvent>
30+
#include <QDropEvent>
31+
#include <QMimeData>
32+
#include <QLineEdit>
33+
34+
QT_BEGIN_NAMESPACE
35+
namespace Ui {
36+
class OpenConverter;
37+
}
38+
QT_END_NAMESPACE
39+
40+
class OpenConverter : public QMainWindow {
41+
Q_OBJECT
42+
protected:
43+
// this event is called, when a new translator is loaded or the system
44+
// language is changed
45+
void changeEvent(QEvent *);
46+
47+
// this event is called, when the user drags and drops a file onto the
48+
void dragEnterEvent(QDragEnterEvent *event) override;
49+
void dropEvent(QDropEvent *event) override;
50+
signals:
51+
void activateConverterThread(QString src, QString dst);
52+
protected slots:
53+
void slotLanguageChanged(QAction *);
54+
public slots:
55+
void apply_Pushed();
56+
57+
void convert_Pushed();
58+
59+
void encode_Setting_Pushed();
60+
61+
void info_Display(QuickInfo *info);
62+
63+
void update_Process_Bar(double result);
64+
65+
void update_Time_Required(double result);
66+
67+
void handle_Converter_Result(bool flag);
68+
69+
public:
70+
OpenConverter(QWidget *parent = nullptr);
71+
~OpenConverter();
72+
73+
private:
74+
// loads a language by the given language shortcur (e.g. de, en)
75+
void loadLanguage(const QString &rLanguage);
76+
77+
QTranslator m_translator; // contains the translations for this application
78+
// QTranslator m_translatorQt; // contains the translations for qt
79+
QString m_currLang; // contains the currently loaded language
80+
QString m_langPath; // Path of language files. This is always fixed to
81+
// /languages.
82+
83+
Ui::OpenConverter *ui;
84+
85+
Info *info = NULL;
86+
87+
EncodeParameter *encodeParameter = NULL;
88+
89+
EncodeSetting *encodeSetting = NULL;
90+
91+
ProcessParameter *processParameter = NULL;
92+
93+
Converter *converter = NULL;
94+
95+
double processNumber = 0;
96+
97+
QMessageBox *displayResult = NULL;
98+
99+
QThread converterThread;
100+
};
101+
#endif // OPEN_CONVERTER_H

src/builder/src/encode_setting.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include "encode_setting.h"
2+
#include "ui_encode_setting.h"
3+
4+
/* Receive pointers from widget */
5+
EncodeSetting::EncodeSetting(QWidget *parent, EncodeParameter *encodeParamter)
6+
: QMainWindow(parent), encodeParameter(encodeParamter),
7+
ui(new Ui::EncodeSetting) {
8+
ui->setupUi(this);
9+
10+
connect(ui->pushButton_cancel, SIGNAL(clicked(bool)), this,
11+
SLOT(cancel_Pushed()));
12+
13+
connect(ui->pushButton_apply, SIGNAL(clicked(bool)), this,
14+
SLOT(apply_Pushed()));
15+
}
16+
17+
void EncodeSetting::changeEvent(QEvent *event) {
18+
if (event->type() == QEvent::LanguageChange) {
19+
ui->retranslateUi(this);
20+
}
21+
QMainWindow::changeEvent(event);
22+
}
23+
24+
bool EncodeSetting::get_Available() { return encodeParameter->get_Available(); }
25+
26+
bool EncodeSetting::get_Encode_Parameter(EncodeParameter *ep) {
27+
ep = encodeParameter;
28+
if (ep != NULL) {
29+
return true;
30+
}
31+
32+
return false;
33+
}
34+
35+
void EncodeSetting::cancel_Pushed() {
36+
// close the sub window
37+
close();
38+
}
39+
40+
void EncodeSetting::apply_Pushed() {
41+
/* get the encoder's parameter of video */
42+
if (!ui->lineEdit_videoCodec->text().toStdString().empty())
43+
encodeParameter->set_Video_Codec_Name(
44+
ui->lineEdit_videoCodec->text().toStdString());
45+
else
46+
encodeParameter->set_Video_Codec_Name("");
47+
encodeParameter->set_Video_Bit_Rate(
48+
ui->lineEdit_videoBitRate->text().toLong());
49+
50+
if (!ui->lineEdit_audioCodec->text().toStdString().empty())
51+
encodeParameter->set_Audio_Codec_Name(
52+
ui->lineEdit_audioCodec->text().toStdString());
53+
else
54+
encodeParameter->set_Audio_Codec_Name("");
55+
encodeParameter->set_Audio_Bit_Rate(
56+
ui->lineEdit_audioBitRate->text().toLong());
57+
// close the sub window
58+
close();
59+
}
60+
61+
EncodeSetting::~EncodeSetting() { delete ui; }

src/builder/src/encode_setting.ui

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>EncodeSetting</class>
4+
<widget class="QMainWindow" name="EncodeSetting">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>480</width>
10+
<height>640</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>MainWindow</string>
15+
</property>
16+
<widget class="QWidget" name="centralwidget">
17+
<widget class="QWidget" name="gridLayoutWidget">
18+
<property name="geometry">
19+
<rect>
20+
<x>20</x>
21+
<y>50</y>
22+
<width>431</width>
23+
<height>161</height>
24+
</rect>
25+
</property>
26+
<layout class="QGridLayout" name="gridLayout">
27+
<item row="0" column="2">
28+
<widget class="QLineEdit" name="lineEdit_videoCodec"/>
29+
</item>
30+
<item row="1" column="2">
31+
<widget class="QLineEdit" name="lineEdit_videoBitRate"/>
32+
</item>
33+
<item row="0" column="0">
34+
<widget class="QLabel" name="label_video">
35+
<property name="text">
36+
<string>video:</string>
37+
</property>
38+
</widget>
39+
</item>
40+
<item row="2" column="2">
41+
<widget class="QLineEdit" name="lineEdit_videoPreset"/>
42+
</item>
43+
<item row="0" column="1">
44+
<widget class="QLabel" name="label_videoCodec">
45+
<property name="text">
46+
<string>codec</string>
47+
</property>
48+
</widget>
49+
</item>
50+
<item row="1" column="1">
51+
<widget class="QLabel" name="label_videoBitRate">
52+
<property name="text">
53+
<string>bit_rate</string>
54+
</property>
55+
</widget>
56+
</item>
57+
<item row="2" column="1">
58+
<widget class="QLabel" name="label_videoPreset">
59+
<property name="text">
60+
<string>preset</string>
61+
</property>
62+
</widget>
63+
</item>
64+
</layout>
65+
</widget>
66+
<widget class="QWidget" name="gridLayoutWidget_2">
67+
<property name="geometry">
68+
<rect>
69+
<x>20</x>
70+
<y>240</y>
71+
<width>431</width>
72+
<height>161</height>
73+
</rect>
74+
</property>
75+
<layout class="QGridLayout" name="gridLayout_3">
76+
<item row="0" column="2">
77+
<widget class="QLineEdit" name="lineEdit_audioCodec"/>
78+
</item>
79+
<item row="1" column="2">
80+
<widget class="QLineEdit" name="lineEdit_audioBitRate"/>
81+
</item>
82+
<item row="0" column="0">
83+
<widget class="QLabel" name="label_9">
84+
<property name="text">
85+
<string>audio:</string>
86+
</property>
87+
</widget>
88+
</item>
89+
<item row="2" column="2">
90+
<widget class="QLineEdit" name="lineEdit_audioPreset"/>
91+
</item>
92+
<item row="0" column="1">
93+
<widget class="QLabel" name="label_audioCodec">
94+
<property name="text">
95+
<string>codec</string>
96+
</property>
97+
</widget>
98+
</item>
99+
<item row="1" column="1">
100+
<widget class="QLabel" name="label_audioBitRate">
101+
<property name="text">
102+
<string>bit_rate</string>
103+
</property>
104+
</widget>
105+
</item>
106+
<item row="2" column="1">
107+
<widget class="QLabel" name="label_audioPreset">
108+
<property name="text">
109+
<string>preset</string>
110+
</property>
111+
</widget>
112+
</item>
113+
</layout>
114+
</widget>
115+
<widget class="QWidget" name="horizontalLayoutWidget">
116+
<property name="geometry">
117+
<rect>
118+
<x>20</x>
119+
<y>430</y>
120+
<width>431</width>
121+
<height>80</height>
122+
</rect>
123+
</property>
124+
<layout class="QHBoxLayout" name="horizontalLayout">
125+
<item>
126+
<widget class="QPushButton" name="pushButton_cancel">
127+
<property name="text">
128+
<string>Cancel</string>
129+
</property>
130+
</widget>
131+
</item>
132+
<item>
133+
<widget class="QPushButton" name="pushButton_apply">
134+
<property name="text">
135+
<string>Apply</string>
136+
</property>
137+
</widget>
138+
</item>
139+
</layout>
140+
</widget>
141+
</widget>
142+
<widget class="QMenuBar" name="menubar">
143+
<property name="geometry">
144+
<rect>
145+
<x>0</x>
146+
<y>0</y>
147+
<width>480</width>
148+
<height>37</height>
149+
</rect>
150+
</property>
151+
</widget>
152+
<widget class="QStatusBar" name="statusbar"/>
153+
</widget>
154+
<resources/>
155+
<connections/>
156+
</ui>

0 commit comments

Comments
 (0)