Skip to content

Commit

Permalink
Added set_window_title() to ImageCanvas and JsonViewer
Browse files Browse the repository at this point in the history
  • Loading branch information
ij96 committed Jan 29, 2019
1 parent bb39008 commit 18e50d6
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 76 deletions.
12 changes: 6 additions & 6 deletions image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Image::Image(QWidget *parent) : QLabel(parent) {
viewer->setWidget(window_label);
}

QWidget *Image::window() const {
return viewer;
void Image::set_window_title(QString title) {
viewer->setWindowTitle(title);
}

void Image::mousePressEvent(QMouseEvent *event) {
Expand Down Expand Up @@ -49,10 +49,6 @@ ImageCanvas::ImageCanvas(QWidget *parent) : QWidget(parent) {
setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
}

Image *ImageCanvas::image() const {
return image_label;
}

void ImageCanvas::setPixmap(const QPixmap &pixmap) {
image_label->setPixmap(pixmap);
image_label->update_image();
Expand All @@ -61,6 +57,10 @@ void ImageCanvas::setPixmap(const QPixmap &pixmap) {
resizeEvent(&event);
}

void ImageCanvas::set_window_title(QString title) {
image_label->setWindowTitle(title);
}

void ImageCanvas::resizeEvent(QResizeEvent *event) {
const QPixmap *pm = image_label->pixmap();
if (!pm || pm->isNull()) {
Expand Down
6 changes: 3 additions & 3 deletions image.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class Image: public QLabel {
explicit Image(QWidget *parent = 0);

void update_image();

QWidget *window() const;
void set_window_title(QString title);

protected:
virtual void mousePressEvent(QMouseEvent *ev);
Expand All @@ -22,14 +21,15 @@ class Image: public QLabel {
QLabel *window_label;
};


class ImageCanvas : public QWidget{
Q_OBJECT

public:
explicit ImageCanvas(QWidget *parent = 0);

Image *image() const;
void setPixmap(const QPixmap &pixmap);
void set_window_title(QString title);

protected:
virtual void resizeEvent(QResizeEvent *event);
Expand Down
11 changes: 6 additions & 5 deletions jsonviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ JsonViewer::JsonViewer(QWidget *parent) : QWidget(parent) {

window->setWindowModality(Qt::NonModal);
window->setWindowFlags(Qt::Window);
window->setWindowTitle(tr("JSON viewer"));
window->setLayout(window_layout);
window->resize(800, 640);
}

void JsonViewer::update(qint32 song_id, QJsonObject info, QJsonObject lyrics) {
void JsonViewer::update(QJsonObject info, QJsonObject lyrics) {
QJsonDocument doc;
QString formatted_json_string;

Expand All @@ -33,10 +32,12 @@ void JsonViewer::update(qint32 song_id, QJsonObject info, QJsonObject lyrics) {
doc.setObject(lyrics);
formatted_json_string = doc.toJson(QJsonDocument::Indented);
lyrics_json_text->setText(formatted_json_string);

window->setWindowTitle(tr("JSON viewer, ID = %1").arg(song_id));
}

void JsonViewer::show() {
void JsonViewer::show() const {
window->show();
}

void JsonViewer::set_window_title(QString title) {
window->setWindowTitle(title);
}
5 changes: 3 additions & 2 deletions jsonviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class JsonViewer : public QWidget {

public:
explicit JsonViewer(QWidget *parent = 0);
void update(qint32 song_id, QJsonObject info, QJsonObject lyrics);
void show();
void update(QJsonObject info, QJsonObject lyrics);
void set_window_title(QString title);
void show() const;

private:
QLabel *window;
Expand Down
105 changes: 53 additions & 52 deletions language/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,242 +4,243 @@
<context>
<name>MainWindow</name>
<message>
<location filename="../mainwindow.cpp" line="396"/>
<location filename="../mainwindow.cpp" line="219"/>
<location filename="../mainwindow.cpp" line="447"/>
<source>JSON viewer, ID = %1</source>
<translation>查看JSON,ID = %1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="432"/>
<location filename="../mainwindow.cpp" line="405"/>
<source>163 Lyrics Getter %1</source>
<translation>163歌词获取器 %1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="436"/>
<location filename="../mainwindow.cpp" line="409"/>
<source>Song ID:</source>
<translation>歌曲ID:</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="437"/>
<location filename="../mainwindow.cpp" line="410"/>
<source>Get lyrics</source>
<translation>获取歌词</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="438"/>
<location filename="../mainwindow.cpp" line="411"/>
<source>Title:</source>
<translation>标题:</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="439"/>
<location filename="../mainwindow.cpp" line="412"/>
<source>Artist:</source>
<translation>歌手:</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="440"/>
<location filename="../mainwindow.cpp" line="413"/>
<source>Album:</source>
<translation>专辑:</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="443"/>
<location filename="../mainwindow.cpp" line="468"/>
<location filename="../mainwindow.cpp" line="416"/>
<location filename="../mainwindow.cpp" line="441"/>
<source>Save cover image</source>
<translation>保存封面图片</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="445"/>
<location filename="../mainwindow.cpp" line="418"/>
<source>Original lyrics:</source>
<translation>歌词:</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="446"/>
<location filename="../mainwindow.cpp" line="466"/>
<location filename="../mainwindow.cpp" line="419"/>
<location filename="../mainwindow.cpp" line="439"/>
<source>Save original lyrics</source>
<translation>保存歌词</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="447"/>
<location filename="../mainwindow.cpp" line="420"/>
<source>Submit lyrics to 163</source>
<translation>上传歌词</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="449"/>
<location filename="../mainwindow.cpp" line="422"/>
<source>Translated lyrics:</source>
<translation>翻译:</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="450"/>
<location filename="../mainwindow.cpp" line="467"/>
<location filename="../mainwindow.cpp" line="423"/>
<location filename="../mainwindow.cpp" line="440"/>
<source>Save translated lyrics</source>
<translation>保存翻译</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="451"/>
<location filename="../mainwindow.cpp" line="424"/>
<source>Submit translation to 163</source>
<translation>上传翻译</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="453"/>
<location filename="../mainwindow.cpp" line="426"/>
<source>Show LRC tags</source>
<translation>显示LRC标签</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="453"/>
<location filename="../mainwindow.cpp" line="426"/>
<source>Hide LRC tags</source>
<translation>隐藏LRC标签</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="454"/>
<location filename="../mainwindow.cpp" line="427"/>
<source>Order tags</source>
<translation>标签排序</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="454"/>
<location filename="../mainwindow.cpp" line="427"/>
<source>Unorder tags</source>
<translation>标签不排序</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="456"/>
<location filename="../mainwindow.cpp" line="429"/>
<source>Status:</source>
<translation>状况:</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="460"/>
<location filename="../mainwindow.cpp" line="433"/>
<source>File</source>
<translation>文件</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="463"/>
<location filename="../mainwindow.cpp" line="436"/>
<source>Tools</source>
<translation>工具</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="469"/>
<location filename="../mainwindow.cpp" line="442"/>
<source>Quit</source>
<translation>退出</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="470"/>
<location filename="../mainwindow.cpp" line="443"/>
<source>JSON viewer</source>
<translation>查看JSON</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="461"/>
<location filename="../mainwindow.cpp" line="434"/>
<source>Options</source>
<translation>选项</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="324"/>
<location filename="../mainwindow.cpp" line="331"/>
<source> Lyrics has been uploaded.</source>
<translation>歌词审核中。</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="327"/>
<location filename="../mainwindow.cpp" line="334"/>
<source> Translation has been uploaded.</source>
<translation>翻译审核中。</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="441"/>
<location filename="../mainwindow.cpp" line="414"/>
<source>Lyrics
uploader:</source>
<translation>歌词上传者:</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="442"/>
<location filename="../mainwindow.cpp" line="415"/>
<source>Translation
uploader:</source>
<translation>翻译上传者:</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="462"/>
<location filename="../mainwindow.cpp" line="435"/>
<source>Language</source>
<translation>语言</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="464"/>
<location filename="../mainwindow.cpp" line="471"/>
<location filename="../mainwindow.cpp" line="437"/>
<location filename="../mainwindow.cpp" line="444"/>
<source>About</source>
<translation>关于</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="212"/>
<location filename="../mainwindow.cpp" line="474"/>
<location filename="../mainwindow.cpp" line="216"/>
<location filename="../mainwindow.cpp" line="450"/>
<source>Album cover art: %1</source>
<translation>专辑封面:%1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="234"/>
<location filename="../mainwindow.cpp" line="241"/>
<source>Text file (*.txt)</source>
<translation>文本文件 (*.txt)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="238"/>
<location filename="../mainwindow.cpp" line="285"/>
<location filename="../mainwindow.cpp" line="245"/>
<location filename="../mainwindow.cpp" line="292"/>
<source>Save As</source>
<translation>保存为</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="287"/>
<location filename="../mainwindow.cpp" line="294"/>
<source>Images (*.jpg *.png)</source>
<translation>图像 (*.jpg *.png)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="199"/>
<location filename="../mainwindow.cpp" line="203"/>
<source>Getting song information and lyrics...</source>
<translation>正在获取歌曲信息及歌词…</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="230"/>
<location filename="../mainwindow.cpp" line="237"/>
<source> (translated)</source>
<translation> (翻译)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="235"/>
<location filename="../mainwindow.cpp" line="242"/>
<source>LRC lyrics file (*.lrc)</source>
<translation>LRC歌词文件 (*.lrc)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="246"/>
<location filename="../mainwindow.cpp" line="253"/>
<source>Application</source>
<translation>应用</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="247"/>
<location filename="../mainwindow.cpp" line="254"/>
<source>Cannot write file %1:
%2.</source>
<translation>无法写入 %1:
%2。</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="301"/>
<location filename="../mainwindow.cpp" line="308"/>
<source>About %1</source>
<translation>关于%1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="302"/>
<location filename="../mainwindow.cpp" line="309"/>
<source>Get lyrics from NetEase Cloud Music (&lt;a href=&quot;http://music.163.com&quot;&gt;music.163.com&lt;/a&gt;)&lt;br/&gt;Author: ij96&lt;br/&gt;&lt;a href=&quot;http://github.com/ij96/163-lyrics-getter&quot;&gt;GitHub page&lt;/a&gt;</source>
<translation>获取网易云音乐歌词 (&lt;a href=&quot;http://music.163.com&quot;&gt;music.163.com&lt;/a&gt;)&lt;br/&gt;作者: ij96&lt;br/&gt;&lt;a href=&quot;http://github.com/ij96/163-lyrics-getter&quot;&gt;GitHub页面&lt;/a&gt;</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="321"/>
<location filename="../mainwindow.cpp" line="328"/>
<source>All found.</source>
<translation>歌词与翻译都已找到。</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="312"/>
<location filename="../mainwindow.cpp" line="319"/>
<source>Song does not exist.</source>
<translation>歌曲不存在。</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="317"/>
<location filename="../mainwindow.cpp" line="324"/>
<source>Lyrics do not exist.</source>
<translation>歌词不存在。</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="319"/>
<location filename="../mainwindow.cpp" line="326"/>
<source>Lyrics found, but translated lyrics not found.</source>
<translation>已找到歌词,但无翻译。</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="315"/>
<location filename="../mainwindow.cpp" line="322"/>
<source>Song is instrumental - no lyrics should exist.</source>
<translation>纯音乐 - 无歌词。</translation>
</message>
Expand Down
Loading

0 comments on commit 18e50d6

Please sign in to comment.