Add option to open log file

This commit is contained in:
BigBahss 2021-02-03 10:24:59 -05:00 committed by huderlem
parent e3edb503ed
commit 6335151c39
7 changed files with 21 additions and 3 deletions

View file

@ -2649,6 +2649,7 @@
<string>Help</string>
</property>
<addaction name="actionAbout_Porymap"/>
<addaction name="actionOpen_Log_File"/>
</widget>
<widget class="QMenu" name="menuOptions">
<property name="title">
@ -2944,6 +2945,11 @@
<string>Export Map Timelapse Image...</string>
</property>
</action>
<action name="actionOpen_Log_File">
<property name="text">
<string>Open Log File</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

View file

@ -42,6 +42,7 @@ public:
ParseUtil();
void set_root(QString);
static QString readTextFile(QString);
static int textFileLineCount(const QString &path);
void strip_comment(QString*);
QList<QStringList>* parseAsm(QString);
int evaluateDefine(QString, QMap<QString, int>*);

View file

@ -154,6 +154,7 @@ public:
void shouldReselectEvents();
void scaleMapView(int);
void openInTextEditor(const QString &path, int lineNum = 0) const;
public slots:
void openMapScripts() const;
@ -188,7 +189,6 @@ private:
QString getMovementPermissionText(uint16_t collision, uint16_t elevation);
QString getMetatileDisplayMessage(uint16_t metatileId);
bool eventLimitReached(Map *, QString);
void openInTextEditor(const QString &path, int lineNum = 0) const;
bool startDetachedProcess(const QString &command,
const QString &workingDirectory = QString(),
qint64 *pid = nullptr) const;

View file

@ -222,6 +222,7 @@ private slots:
void on_toolButton_ExpandAll_clicked();
void on_toolButton_CollapseAll_clicked();
void on_actionAbout_Porymap_triggered();
void on_actionOpen_Log_File_triggered();
void on_pushButton_AddCustomHeaderField_clicked();
void on_pushButton_DeleteCustomHeaderField_clicked();
void on_tableWidget_CustomHeaderFields_cellChanged(int row, int column);

View file

@ -49,11 +49,16 @@ QString ParseUtil::readTextFile(QString path) {
in.setCodec("UTF-8");
QString text = "";
while (!in.atEnd()) {
text += in.readLine() + "\n";
text += in.readLine() + '\n';
}
return text;
}
int ParseUtil::textFileLineCount(const QString &path) {
const QString text = readTextFile(path);
return text.split('\n').count() + 1;
}
QList<QStringList>* ParseUtil::parseAsm(QString filename) {
QList<QStringList> *parsed = new QList<QStringList>;

View file

@ -2078,7 +2078,6 @@ bool Editor::startDetachedProcess(const QString &command, const QString &working
logInfo("Executing command: " + command);
QProcess process;
#ifdef Q_OS_WIN
// Windows is WeirdChamp
QStringList arguments = ParseUtil::splitShellCommand(command);
const QString program = arguments.takeFirst();
QFileInfo programFileInfo(program);

View file

@ -2691,6 +2691,12 @@ void MainWindow::on_actionAbout_Porymap_triggered()
window->show();
}
void MainWindow::on_actionOpen_Log_File_triggered() {
const QString logPath = getLogPath();
const int lineCount = ParseUtil::textFileLineCount(logPath);
editor->openInTextEditor(logPath, lineCount);
}
void MainWindow::on_actionEdit_Preferences_triggered() {
if (!preferenceEditor) {
preferenceEditor = new PreferenceEditor(this);