feature: save main window and toolbar layout
This commit is contained in:
parent
264e3533d9
commit
7467934c98
|
@ -22,18 +22,18 @@ void CaretList::addCaret(Editor *editor, int line, int aChar)
|
|||
caret->aChar = aChar;
|
||||
mList.append(caret);
|
||||
mIndex++;
|
||||
qDebug()<<"add caret:"<<mIndex<<":"<<mList.count();
|
||||
//qDebug()<<"add caret:"<<mIndex<<":"<<mList.count();
|
||||
}
|
||||
|
||||
bool CaretList::hasPrevious() const
|
||||
{
|
||||
qDebug()<<"has previous:"<<mIndex<<":"<<mList.count();
|
||||
//qDebug()<<"has previous:"<<mIndex<<":"<<mList.count();
|
||||
return mIndex>0;
|
||||
}
|
||||
|
||||
bool CaretList::hasNext() const
|
||||
{
|
||||
qDebug()<<"has next:"<<mIndex<<":"<<mList.count();
|
||||
//qDebug()<<"has next:"<<mIndex<<":"<<mList.count();
|
||||
return mIndex<mList.count()-1;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ PEditorCaret CaretList::gotoAndGetPrevious()
|
|||
if (!hasPrevious())
|
||||
return PEditorCaret();
|
||||
mIndex--;
|
||||
qDebug()<<"move previous:"<<mIndex<<":"<<mList.count();
|
||||
//qDebug()<<"move previous:"<<mIndex<<":"<<mList.count();
|
||||
if (mIndex<mList.count())
|
||||
return mList[mIndex];
|
||||
return PEditorCaret();
|
||||
|
@ -53,7 +53,7 @@ PEditorCaret CaretList::gotoAndGetNext()
|
|||
if (!hasNext())
|
||||
return PEditorCaret();
|
||||
mIndex++;
|
||||
qDebug()<<"move next:"<<mIndex<<":"<<mList.count();
|
||||
//qDebug()<<"move next:"<<mIndex<<":"<<mList.count();
|
||||
if (mIndex>=0)
|
||||
return mList[mIndex];
|
||||
return PEditorCaret();
|
||||
|
@ -85,7 +85,7 @@ void CaretList::unPause()
|
|||
|
||||
void CaretList::linesDeleted(const Editor *editor, int firstLine, int count)
|
||||
{
|
||||
qDebug()<<"deleted:"<<mIndex<<":"<<mList.count();
|
||||
//qDebug()<<"deleted:"<<mIndex<<":"<<mList.count();
|
||||
for (int i=mList.count()-1;i>=0;i--) {
|
||||
if (mList[i]->editor == editor
|
||||
&& mList[i]->line>=firstLine) {
|
||||
|
@ -99,7 +99,7 @@ void CaretList::linesDeleted(const Editor *editor, int firstLine, int count)
|
|||
|
||||
void CaretList::linesInserted(const Editor *editor, int firstLine, int count)
|
||||
{
|
||||
qDebug()<<"inserted:"<<mIndex<<":"<<mList.count();
|
||||
//qDebug()<<"inserted:"<<mIndex<<":"<<mList.count();
|
||||
for(PEditorCaret& caret:mList) {
|
||||
if (caret->editor == editor
|
||||
&& caret->line >= firstLine)
|
||||
|
|
|
@ -102,9 +102,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
updateEditorActions();
|
||||
updateCaretActions();
|
||||
applySettings();
|
||||
applyUISettings();
|
||||
|
||||
openCloseMessageSheet(false);
|
||||
mPreviousHeight = 250;
|
||||
|
||||
connect(ui->debugConsole,&QConsole::commandInput,this,&MainWindow::onDebugCommandInput);
|
||||
connect(ui->cbEvaluate->lineEdit(), &QLineEdit::returnPressed,
|
||||
|
@ -287,6 +286,15 @@ void MainWindow::applySettings()
|
|||
updateDebuggerSettings();
|
||||
}
|
||||
|
||||
void MainWindow::applyUISettings()
|
||||
{
|
||||
openCloseMessageSheet(false);
|
||||
mPreviousHeight = 250;
|
||||
const Settings::UI& settings = pSettings->ui();
|
||||
restoreGeometry(settings.mainWindowGeometry());
|
||||
restoreState(settings.mainWindowState());
|
||||
}
|
||||
|
||||
QFileSystemWatcher *MainWindow::fileSystemWatcher()
|
||||
{
|
||||
return &mFileSystemWatcher;
|
||||
|
@ -1153,6 +1161,10 @@ void MainWindow::on_actionOpen_triggered()
|
|||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event) {
|
||||
Settings::UI& settings = pSettings->ui();
|
||||
settings.setMainWindowState(saveState());
|
||||
settings.setMainWindowGeometry(saveGeometry());
|
||||
pSettings->ui().save();
|
||||
if (!mEditorList->closeAll(false)) {
|
||||
event->ignore();
|
||||
return ;
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
void showSearchPanel();
|
||||
|
||||
void applySettings();
|
||||
void applyUISettings();
|
||||
QFileSystemWatcher* fileSystemWatcher();
|
||||
|
||||
void removeActiveBreakpoints();
|
||||
|
|
|
@ -880,7 +880,7 @@
|
|||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBarCompile">
|
||||
<widget class="QToolBar" name="toolbarCompile">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
|
@ -901,7 +901,7 @@
|
|||
<addaction name="actionCompile_Run"/>
|
||||
<addaction name="actionRebuild"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBarDebug">
|
||||
<widget class="QToolBar" name="toolbarDebug">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
|
|
|
@ -25,7 +25,8 @@ Settings::Settings(const QString &filename):
|
|||
mDebugger(this),
|
||||
mCodeCompletion(this),
|
||||
mCodeFormatter(this),
|
||||
mHistory(this)
|
||||
mHistory(this),
|
||||
mUI(this)
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
@ -83,6 +84,7 @@ void Settings::load()
|
|||
mHistory.load();
|
||||
mCodeCompletion.load();
|
||||
mCodeFormatter.load();
|
||||
mUI.load();
|
||||
}
|
||||
|
||||
Settings::Dirs &Settings::dirs()
|
||||
|
@ -125,6 +127,11 @@ Settings::CodeFormatter &Settings::codeFormatter()
|
|||
return mCodeFormatter;
|
||||
}
|
||||
|
||||
Settings::UI &Settings::ui()
|
||||
{
|
||||
return mUI;
|
||||
}
|
||||
|
||||
Settings::History& Settings::history()
|
||||
{
|
||||
return mHistory;
|
||||
|
@ -3564,3 +3571,40 @@ void Settings::CodeFormatter::setBraceStyle(int newBraceStyle)
|
|||
{
|
||||
mBraceStyle = newBraceStyle;
|
||||
}
|
||||
|
||||
Settings::UI::UI(Settings *settings):_Base(settings,SETTING_UI)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const QByteArray &Settings::UI::mainWindowGeometry() const
|
||||
{
|
||||
return mMainWindowGeometry;
|
||||
}
|
||||
|
||||
void Settings::UI::setMainWindowGeometry(const QByteArray &newMainWindowGeometry)
|
||||
{
|
||||
mMainWindowGeometry = newMainWindowGeometry;
|
||||
}
|
||||
|
||||
const QByteArray &Settings::UI::mainWindowState() const
|
||||
{
|
||||
return mMainWindowState;
|
||||
}
|
||||
|
||||
void Settings::UI::setMainWindowState(const QByteArray &newMainWindowState)
|
||||
{
|
||||
mMainWindowState = newMainWindowState;
|
||||
}
|
||||
|
||||
void Settings::UI::doSave()
|
||||
{
|
||||
saveValue("main_window_state",mMainWindowState);
|
||||
saveValue("main_window_geometry",mMainWindowGeometry);
|
||||
}
|
||||
|
||||
void Settings::UI::doLoad()
|
||||
{
|
||||
mMainWindowState = value("main_window_state",QByteArray()).toByteArray();
|
||||
mMainWindowGeometry = value("main_window_geometry",QByteArray()).toByteArray();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#define SETTING_EXECUTOR "Executor"
|
||||
#define SETTING_DEBUGGER "Debugger"
|
||||
#define SETTING_HISTORY "History"
|
||||
#define SETTING_UI "UI"
|
||||
#define SETTING_CODE_COMPLETION "CodeCompletion"
|
||||
#define SETTING_CODE_FORMATTER "CodeFormatter"
|
||||
#define SETTING_COMPILTER_SETS "CompilerSets"
|
||||
|
@ -684,6 +685,25 @@ public:
|
|||
void doLoad() override;
|
||||
};
|
||||
|
||||
class UI: public _Base {
|
||||
public:
|
||||
explicit UI(Settings *settings);
|
||||
|
||||
const QByteArray &mainWindowState() const;
|
||||
void setMainWindowState(const QByteArray &newMainWindowState);
|
||||
|
||||
const QByteArray &mainWindowGeometry() const;
|
||||
void setMainWindowGeometry(const QByteArray &newMainWindowGeometry);
|
||||
|
||||
private:
|
||||
QByteArray mMainWindowState;
|
||||
QByteArray mMainWindowGeometry;
|
||||
|
||||
protected:
|
||||
void doSave() override;
|
||||
void doLoad() override;
|
||||
};
|
||||
|
||||
class Debugger: public _Base {
|
||||
public:
|
||||
explicit Debugger(Settings* settings);
|
||||
|
@ -904,6 +924,7 @@ public:
|
|||
History& history();
|
||||
CodeCompletion &codeCompletion();
|
||||
CodeFormatter &codeFormatter();
|
||||
UI &ui();
|
||||
QString filename() const;
|
||||
|
||||
private:
|
||||
|
@ -918,6 +939,7 @@ private:
|
|||
CodeCompletion mCodeCompletion;
|
||||
CodeFormatter mCodeFormatter;
|
||||
History mHistory;
|
||||
UI mUI;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue