Skip to content

Commit

Permalink
Status bar & File save
Browse files Browse the repository at this point in the history
  • Loading branch information
Vescrity committed May 14, 2024
1 parent 33afc09 commit ae4822f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 12 additions & 2 deletions workspace/editor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "editor.h"
#include "ui_editor.h"

#include <QFileDialog>
Editor::Editor(QWidget *parent, const NoteList &l)
: QMainWindow(parent), ui(new Ui::Editor), current_list(l)
{
Expand All @@ -11,6 +11,9 @@ Editor::Editor(QWidget *parent, const NoteList &l)
current_list.set_bpm(100);
}
ui->bpmSpinBox->setValue(current_list.get_bpm());
numerator = ui->numeratorSpinBox->value();
power2 = ui->power2Box->currentIndex();
ui->statusBar->showMessage(tr("初始化已完成"));
}

Editor::~Editor()
Expand All @@ -25,7 +28,14 @@ void Editor::set_list(const NoteList &l)

void Editor::on_actionMidi_triggered()
{
current_list.save_midi("temp.mid", numerator, power2);
QString fname=QFileDialog::getSaveFileName(this,tr("保存文件"),QDir::currentPath(),tr("MIDI 文件(*.mid)"));
if(!fname.isEmpty()){
current_list.save_midi(fname.toStdString(), numerator, power2);
ui->statusBar->showMessage(tr("文件已导出"));
}
else{
ui->statusBar->showMessage(tr("导出已取消"));
}
}

void Editor::on_power2Box_currentIndexChanged(int index)
Expand Down
6 changes: 5 additions & 1 deletion workspace/editor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;拍数/分钟。&lt;/p&gt;&lt;p&gt;改变此值只会影响 midi 的 bpm 信息而不会影响实际播放速度。&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>bpm: </string>
</property>
Expand Down Expand Up @@ -110,12 +113,13 @@
</widget>
<widget class="QMenu" name="menu_2">
<property name="title">
<string>摆设</string>
<string>关于</string>
</property>
</widget>
<addaction name="menu"/>
<addaction name="menu_2"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionMidi">
<property name="text">
<string>Midi</string>
Expand Down

0 comments on commit ae4822f

Please sign in to comment.