29 #include <QFileDialog> 30 #include <QMessageBox> 31 #include <QStandardPaths> 55 QString path = QStandardPaths::locate(QStandardPaths::DocumentsLocation,
"",
56 QStandardPaths::LocateDirectory);
57 if (path.endsWith(
"/") or path.endsWith(
"\\")) path.remove(path.size()-1,1);
58 LOGSTATUS <<
"Open file open dialog" << width << height;
59 QString fileName = QFileDialog::getOpenFileName(
nullptr,
60 tr(
"Please choose a Midi file"),
"", tr(
"Midi files (*.mid *.midi *.MID)"));
79 QStandardPaths::LocateDirectory);
80 if (path.endsWith(
"/") or path.endsWith(
"\\")) path.remove(path.size()-1,1);
81 LOGSTATUS <<
"Searching path is:" << path <<
" Open file-save dialog";
82 QString filename = QFileDialog::getSaveFileName(0,tr(
"Save custom temperament"),
83 path, tr(
"Temperament files")+
" (*.tem);;"+tr(
"All files") +
" (*)");
84 if (filename ==
"")
return;
85 if (not filename.contains(
".")) filename +=
".tem";
88 QFile file (filename);
89 if (not file.open(QIODevice::WriteOnly))
91 QMessageBox ::information (0,tr(
"Could not write to disk."),file.errorString());
96 QTextStream out(&file);
97 out <<
tag <<
"\n" << data1 <<
"\n" << data2 <<
"\n" << data3;
115 QStandardPaths::LocateDirectory);
116 if (path.endsWith(
"/") or path.endsWith(
"\\")) path.remove(path.size()-1,1);
117 LOGSTATUS <<
"Searching path is:" << path;
118 QString filename = QFileDialog::getOpenFileName(0,tr(
"Load custom temperament"),
119 path, tr(
"Temperament files")+
" (*.tem);;"+tr(
"All files") +
" (*)");
120 if (filename ==
"")
return;
121 if (not filename.contains(
".")) filename +=
".tem";
122 LOGMESSAGE <<
"Loading from file" << filename;
123 QFile file (filename);
124 if (not file.open(QIODevice::ReadOnly))
126 QMessageBox ::information (0,tr(
"Could not read from disk."),file.errorString());
131 QTextStream in(&file);
132 QString firstline = in.readLine();
133 if (firstline !=
tag)
135 QMessageBox ::information (0,tr(
"Reading Error"),tr(
"This is not a data file generated by JustIntonation"));
140 QString data1 = in.readLine();
141 QString data2 = in.readLine();
142 QString data3 = in.readLine();
143 LOGSTATUS <<
"Content: " << data1 << data2 << data3;
FileHandler()
Constructor.
void setModuleName(const QString &name)
Specify the name of the class-specific module.
void loadedData(QVariant data1, QVariant data2, QVariant data3)
void openMidiFile(QString fileName, bool autostart)
void saveData(QString data1, QString data2, QString data3)
Save data (string) to file.
void loadData()
Load data (string) from file.
#define INT_TEMPERAMENT_DIR
void openMidiFileDialog(int width, int height)
Private slot: Open file open dialog.