Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement persisting UI states #294

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Console::Console(QWidget *parent) : QPlainTextEdit(parent) {
});

m_localEchoEnabled = RipesSettings::value(RIPES_SETTING_CONSOLEECHO).toBool();

// Retrieve and store saved window size and state
m_savedSize = RipesSettings::value(RIPES_SETTING_CONSOLESIZE).toSize();
m_savedState = static_cast<Qt::WindowStates>(RipesSettings::value(RIPES_SETTING_CONSOLESTATE).toInt());
}

void Console::putData(const QByteArray &bytes) {
Expand Down Expand Up @@ -109,7 +113,19 @@ void Console::keyPressEvent(QKeyEvent *e) {
}
}
}
}
}
}

void Console::resizeEvent(QResizeEvent *event) {
QPlainTextEdit::resizeEvent(event);
m_savedSize = event->size();
m_savedState = windowState();
}

void Console::moveEvent(QMoveEvent *event) {
QPlainTextEdit::moveEvent(event);
m_savedSize = event->pos();
m_savedState = windowState();
}

} // namespace Ripes
6 changes: 6 additions & 0 deletions src/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ class Console : public QPlainTextEdit {

protected:
void keyPressEvent(QKeyEvent *e) override;
void resizeEvent(QResizeEvent *) override;
void moveEvent(QMoveEvent *) override;

private:
void backspace();

bool m_localEchoEnabled = false;
QFont m_font;
QString m_buffer;

// window size & state.
QVariant m_savedSize;
Qt::WindowStates m_savedState;
};

} // namespace Ripes
2 changes: 2 additions & 0 deletions src/ripessettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace Ripes {
#define RIPES_SETTING_CONSOLEFONT ("console_font")
#define RIPES_SETTING_INDENTAMT ("editor_indent")
#define RIPES_SETTING_UIUPDATEPS ("ui_update_ps")
#define RIPES_SETTING_CONSOLESIZE ("console/windowsize")
#define RIPES_SETTING_CONSOLESTATE ("console/windowstate")

#define RIPES_SETTING_ASSEMBLER_TEXTSTART ("text_start")
#define RIPES_SETTING_ASSEMBLER_DATASTART ("data_start")
Expand Down