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

View file

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

View file

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

View file

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

View file

@ -49,11 +49,16 @@ QString ParseUtil::readTextFile(QString path) {
in.setCodec("UTF-8"); in.setCodec("UTF-8");
QString text = ""; QString text = "";
while (!in.atEnd()) { while (!in.atEnd()) {
text += in.readLine() + "\n"; text += in.readLine() + '\n';
} }
return text; 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>* ParseUtil::parseAsm(QString filename) {
QList<QStringList> *parsed = new QList<QStringList>; 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); logInfo("Executing command: " + command);
QProcess process; QProcess process;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// Windows is WeirdChamp
QStringList arguments = ParseUtil::splitShellCommand(command); QStringList arguments = ParseUtil::splitShellCommand(command);
const QString program = arguments.takeFirst(); const QString program = arguments.takeFirst();
QFileInfo programFileInfo(program); QFileInfo programFileInfo(program);

View file

@ -2691,6 +2691,12 @@ void MainWindow::on_actionAbout_Porymap_triggered()
window->show(); 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() { void MainWindow::on_actionEdit_Preferences_triggered() {
if (!preferenceEditor) { if (!preferenceEditor) {
preferenceEditor = new PreferenceEditor(this); preferenceEditor = new PreferenceEditor(this);