feature: next / previous editor
fix: history file menu not get updated
This commit is contained in:
parent
2471259a41
commit
56ff4a6c35
|
@ -79,7 +79,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
||||||
}
|
}
|
||||||
QFileInfo fileInfo(mFilename);
|
QFileInfo fileInfo(mFilename);
|
||||||
if (mParentPageControl!=nullptr) {
|
if (mParentPageControl!=nullptr) {
|
||||||
mParentPageControl->addTab(this,QString());
|
int index = mParentPageControl->addTab(this,QString());
|
||||||
updateCaption();
|
updateCaption();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +132,10 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
||||||
this, &Editor::onLinesDeleted);
|
this, &Editor::onLinesDeleted);
|
||||||
connect(this,&SynEdit::linesInserted,
|
connect(this,&SynEdit::linesInserted,
|
||||||
this, &Editor::onLinesInserted);
|
this, &Editor::onLinesInserted);
|
||||||
|
|
||||||
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(this, &QWidget::customContextMenuRequested,
|
||||||
|
pMainWindow, &MainWindow::onEditorContextMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
Editor::~Editor() {
|
Editor::~Editor() {
|
||||||
|
|
|
@ -164,6 +164,26 @@ int EditorList::pageCount()
|
||||||
return mLeftPageWidget->count()+mRightPageWidget->count();
|
return mLeftPageWidget->count()+mRightPageWidget->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorList::selectNextPage()
|
||||||
|
{
|
||||||
|
QTabWidget * pageControl = getFocusedPageControl();
|
||||||
|
if (pageControl && pageControl->count()>0) {
|
||||||
|
pageControl->setCurrentIndex(
|
||||||
|
(pageControl->currentIndex()+1) % pageControl->count()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorList::selectPreviousPage()
|
||||||
|
{
|
||||||
|
QTabWidget * pageControl = getFocusedPageControl();
|
||||||
|
if (pageControl && pageControl->count()>0) {
|
||||||
|
pageControl->setCurrentIndex(
|
||||||
|
(pageControl->currentIndex()+pageControl->count()-1) % pageControl->count()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Editor *EditorList::operator[](int index)
|
Editor *EditorList::operator[](int index)
|
||||||
{
|
{
|
||||||
if (index>=0 && index<mLeftPageWidget->count()) {
|
if (index>=0 && index<mLeftPageWidget->count()) {
|
||||||
|
|
|
@ -44,6 +44,8 @@ public:
|
||||||
void applyColorSchemes(const QString& name);
|
void applyColorSchemes(const QString& name);
|
||||||
bool isFileOpened(const QString& name);
|
bool isFileOpened(const QString& name);
|
||||||
int pageCount();
|
int pageCount();
|
||||||
|
void selectNextPage();
|
||||||
|
void selectPreviousPage();
|
||||||
|
|
||||||
Editor* operator[](int index);
|
Editor* operator[](int index);
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
this, &MainWindow::onAutoSaveTimeout);
|
this, &MainWindow::onAutoSaveTimeout);
|
||||||
resetAutoSaveTimer();
|
resetAutoSaveTimer();
|
||||||
|
|
||||||
|
connect(ui->menuFile, &QMenu::aboutToShow,
|
||||||
|
this,&MainWindow::rebuildOpenedFileHisotryMenu);
|
||||||
|
|
||||||
buildContextMenus();
|
buildContextMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1082,11 +1085,10 @@ void MainWindow::doAutoSave(Editor *e)
|
||||||
|
|
||||||
void MainWindow::buildContextMenus()
|
void MainWindow::buildContextMenus()
|
||||||
{
|
{
|
||||||
ui->watchView->setContextMenuPolicy(Qt::ActionsContextMenu);
|
ui->watchView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
ui->watchView->addAction(ui->actionAdd_Watch);
|
connect(ui->watchView,&QWidget::customContextMenuRequested,
|
||||||
ui->watchView->addAction(ui->actionRemove_Watch);
|
this, &MainWindow::onWatchViewContextMenu);
|
||||||
ui->watchView->addAction(ui->actionRemove_All_Watches);
|
|
||||||
ui->watchView->addAction(ui->actionModify_Watch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::maximizeEditor()
|
void MainWindow::maximizeEditor()
|
||||||
|
@ -1126,6 +1128,34 @@ void MainWindow::onAutoSaveTimeout()
|
||||||
updateStatusbarMessage(tr("%1 files autosaved").arg(updateCount));
|
updateStatusbarMessage(tr("%1 files autosaved").arg(updateCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onWatchViewContextMenu(const QPoint &pos)
|
||||||
|
{
|
||||||
|
QMenu menu(this);
|
||||||
|
menu.addAction(ui->actionAdd_Watch);
|
||||||
|
menu.addAction(ui->actionRemove_Watch);
|
||||||
|
menu.addAction(ui->actionRemove_All_Watches);
|
||||||
|
menu.addAction(ui->actionModify_Watch);
|
||||||
|
menu.exec(ui->watchView->mapToGlobal(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onEditorContextMenu(const QPoint &pos)
|
||||||
|
{
|
||||||
|
Editor * editor = mEditorList->getEditor();
|
||||||
|
if (!editor)
|
||||||
|
return;
|
||||||
|
QMenu menu(this);
|
||||||
|
menu.addAction(ui->actionCompile_Run);
|
||||||
|
menu.addAction(ui->actionDebug);
|
||||||
|
int line = editor->caretY();
|
||||||
|
if (editor->hasBreakpoint(line)) {
|
||||||
|
//todo: breakpoint property
|
||||||
|
}
|
||||||
|
//todo: goto declaretion
|
||||||
|
//todo: goto definition
|
||||||
|
menu.exec(editor->viewport()->mapToGlobal(pos));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onFileChanged(const QString &path)
|
void MainWindow::onFileChanged(const QString &path)
|
||||||
{
|
{
|
||||||
Editor *e = mEditorList->getOpenedEditorByFilename(path);
|
Editor *e = mEditorList->getOpenedEditorByFilename(path);
|
||||||
|
@ -2096,3 +2126,15 @@ void MainWindow::on_actionMaximize_Editor_triggered()
|
||||||
maximizeEditor();
|
maximizeEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_actionNext_Editor_triggered()
|
||||||
|
{
|
||||||
|
mEditorList->selectNextPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_actionPrevious_Editor_triggered()
|
||||||
|
{
|
||||||
|
mEditorList->selectPreviousPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,7 @@ public slots:
|
||||||
void onStartParsing();
|
void onStartParsing();
|
||||||
void onEndParsing(int total, int updateView);
|
void onEndParsing(int total, int updateView);
|
||||||
void onEvalValueReady(const QString& value);
|
void onEvalValueReady(const QString& value);
|
||||||
|
void onEditorContextMenu(const QPoint& pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void openFiles(const QStringList& files);
|
void openFiles(const QStringList& files);
|
||||||
|
@ -134,6 +135,7 @@ private:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onAutoSaveTimeout();
|
void onAutoSaveTimeout();
|
||||||
|
void onWatchViewContextMenu(const QPoint& pos);
|
||||||
void onFileChanged(const QString& path);
|
void onFileChanged(const QString& path);
|
||||||
|
|
||||||
void on_actionNew_triggered();
|
void on_actionNew_triggered();
|
||||||
|
@ -258,6 +260,10 @@ private slots:
|
||||||
|
|
||||||
void on_actionMaximize_Editor_triggered();
|
void on_actionMaximize_Editor_triggered();
|
||||||
|
|
||||||
|
void on_actionNext_Editor_triggered();
|
||||||
|
|
||||||
|
void on_actionPrevious_Editor_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
EditorList *mEditorList;
|
EditorList *mEditorList;
|
||||||
|
|
|
@ -751,7 +751,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>946</width>
|
<width>946</width>
|
||||||
<height>22</height>
|
<height>25</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
|
@ -843,6 +843,9 @@
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionClose_All"/>
|
<addaction name="actionClose_All"/>
|
||||||
<addaction name="actionMaximize_Editor"/>
|
<addaction name="actionMaximize_Editor"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionNext_Editor"/>
|
||||||
|
<addaction name="actionPrevious_Editor"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuEdit"/>
|
<addaction name="menuEdit"/>
|
||||||
|
@ -1476,6 +1479,32 @@
|
||||||
<string>Ctrl+F11</string>
|
<string>Ctrl+F11</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionNext_Editor">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normalon>:/icons/images/newlook24/038-Forward.png</normalon>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Next</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+Tab</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionPrevious_Editor">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normalon>:/icons/images/newlook24/006-Back.png</normalon>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Previous</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+Shift+Tab</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
Loading…
Reference in New Issue