- fix: crash when create new file
- implement: two editor view
This commit is contained in:
parent
47f754ca0f
commit
59390203e3
4
NEWS.md
4
NEWS.md
|
@ -1,3 +1,7 @@
|
|||
Version 0.6.6
|
||||
- fix: crash when create new file
|
||||
- implement: two editor view
|
||||
|
||||
Version 0.6.5
|
||||
- implement: export as rtf / export as html
|
||||
- fix: the contents copied/exported are not correctly syntax colored
|
||||
|
|
|
@ -382,6 +382,28 @@ bool Editor::isNew() const noexcept {
|
|||
QTabWidget* Editor::pageControl() noexcept{
|
||||
return mParentPageControl;
|
||||
}
|
||||
static int findWidgetInPageControl(QTabWidget* pageControl, QWidget* child) {
|
||||
for (int i=0;i<pageControl->count();i++) {
|
||||
if (pageControl->widget(i)==child)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
void Editor::setPageControl(QTabWidget *newPageControl)
|
||||
{
|
||||
if (mParentPageControl==newPageControl)
|
||||
return;
|
||||
if (mParentPageControl!=nullptr) {
|
||||
int index = findWidgetInPageControl(mParentPageControl,this);
|
||||
if (index>=0)
|
||||
mParentPageControl->removeTab(index);
|
||||
}
|
||||
mParentPageControl= newPageControl;
|
||||
if (newPageControl!=nullptr) {
|
||||
mParentPageControl->addTab(this,"");
|
||||
updateCaption();
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::undoSymbolCompletion(int pos)
|
||||
{
|
||||
|
|
|
@ -124,6 +124,7 @@ public:
|
|||
void activate();
|
||||
|
||||
QTabWidget* pageControl() noexcept;
|
||||
void setPageControl(QTabWidget* newPageControl);
|
||||
|
||||
void updateCaption(const QString& newCaption=QString());
|
||||
void applySettings();
|
||||
|
|
|
@ -24,8 +24,8 @@ EditorList::EditorList(QTabWidget* leftPageWidget,
|
|||
Editor* EditorList::newEditor(const QString& filename, const QByteArray& encoding,
|
||||
bool inProject, bool newFile,
|
||||
QTabWidget* page) {
|
||||
QTabWidget * parentPageControl = NULL;
|
||||
if (page == NULL)
|
||||
QTabWidget * parentPageControl = nullptr;
|
||||
if (page == nullptr)
|
||||
parentPageControl = getNewEditorPageControl();
|
||||
else
|
||||
parentPageControl = page;
|
||||
|
@ -38,13 +38,25 @@ Editor* EditorList::newEditor(const QString& filename, const QByteArray& encodin
|
|||
}
|
||||
|
||||
QTabWidget* EditorList::getNewEditorPageControl() const {
|
||||
//todo: return widget depends on layout
|
||||
return mLeftPageWidget;
|
||||
return getFocusedPageControl();
|
||||
}
|
||||
|
||||
QTabWidget* EditorList::getFocusedPageControl() const {
|
||||
//todo:
|
||||
return mLeftPageWidget;
|
||||
switch(mLayout) {
|
||||
case LayoutShowType::lstLeft:
|
||||
return mLeftPageWidget;
|
||||
case LayoutShowType::lstRight:
|
||||
return mRightPageWidget;
|
||||
case LayoutShowType::lstBoth: {
|
||||
Editor* editor = dynamic_cast<Editor*>(mRightPageWidget->currentWidget());
|
||||
if (editor && editor->hasFocus())
|
||||
return mRightPageWidget;
|
||||
return mLeftPageWidget;
|
||||
}
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void EditorList::showLayout(LayoutShowType layout)
|
||||
|
@ -55,7 +67,6 @@ void EditorList::showLayout(LayoutShowType layout)
|
|||
// Apply widths if layout does not change
|
||||
switch(mLayout) {
|
||||
case LayoutShowType::lstLeft:
|
||||
case LayoutShowType::lstNone:
|
||||
mLeftPageWidget->setVisible(true);
|
||||
mRightPageWidget->setVisible(false);
|
||||
break;
|
||||
|
@ -71,16 +82,18 @@ void EditorList::showLayout(LayoutShowType layout)
|
|||
|
||||
Editor* EditorList::getEditor(int index, QTabWidget* tabsWidget) const {
|
||||
QTabWidget* selectedWidget;
|
||||
if (tabsWidget == NULL) {
|
||||
selectedWidget = getFocusedPageControl(); // todo: get focused widget
|
||||
if (tabsWidget == nullptr) {
|
||||
selectedWidget = getFocusedPageControl();
|
||||
} else {
|
||||
selectedWidget = tabsWidget;
|
||||
}
|
||||
if (!selectedWidget)
|
||||
return nullptr;
|
||||
if (index == -1) {
|
||||
index = selectedWidget->currentIndex();
|
||||
}
|
||||
if (index<0 || index >= selectedWidget->count()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return (Editor*)selectedWidget->widget(index);
|
||||
}
|
||||
|
@ -133,6 +146,25 @@ bool EditorList::closeEditor(Editor* editor, bool transferFocus, bool force) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool EditorList::swapEditor(Editor *editor)
|
||||
{
|
||||
Q_ASSERT(editor!=nullptr);
|
||||
beginUpdate();
|
||||
auto action = finally([this](){
|
||||
endUpdate();
|
||||
});
|
||||
//remember old index
|
||||
QTabWidget* fromPageControl = editor->pageControl();
|
||||
if (fromPageControl == mLeftPageWidget) {
|
||||
editor->setPageControl(mRightPageWidget);
|
||||
} else {
|
||||
editor->setPageControl(mLeftPageWidget);
|
||||
}
|
||||
updateLayout();
|
||||
editor->activate();
|
||||
return true;
|
||||
}
|
||||
|
||||
void EditorList::beginUpdate() {
|
||||
if (mUpdateCount==0) {
|
||||
mPanel->setUpdatesEnabled(false);
|
||||
|
@ -241,7 +273,6 @@ bool EditorList::closeAll(bool force) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -305,10 +336,6 @@ bool EditorList::getContentFromOpenedEditor(const QString &filename, QStringList
|
|||
void EditorList::getVisibleEditors(Editor *&left, Editor *&right)
|
||||
{
|
||||
switch(mLayout) {
|
||||
case LayoutShowType::lstNone:
|
||||
left = nullptr;
|
||||
right = nullptr;
|
||||
break;
|
||||
case LayoutShowType::lstLeft:
|
||||
left = getEditor(-1,mLeftPageWidget);
|
||||
right = nullptr;
|
||||
|
@ -326,11 +353,9 @@ void EditorList::getVisibleEditors(Editor *&left, Editor *&right)
|
|||
|
||||
void EditorList::updateLayout()
|
||||
{
|
||||
if (mLeftPageWidget->count() ==0 && mRightPageWidget->count() == 0)
|
||||
showLayout(LayoutShowType::lstNone);
|
||||
else if (mLeftPageWidget->count() > 0 && mRightPageWidget->count() == 0)
|
||||
if (mRightPageWidget->count() == 0)
|
||||
showLayout(LayoutShowType::lstLeft);
|
||||
else if (mLeftPageWidget->count() ==0 && mRightPageWidget->count() > 0)
|
||||
else if (mLeftPageWidget->count() ==0)
|
||||
showLayout(LayoutShowType::lstRight);
|
||||
else
|
||||
showLayout(LayoutShowType::lstBoth);
|
||||
|
|
|
@ -11,7 +11,6 @@ class EditorList
|
|||
{
|
||||
public:
|
||||
enum class LayoutShowType{
|
||||
lstNone,
|
||||
lstLeft,
|
||||
lstRight,
|
||||
lstBoth
|
||||
|
@ -24,12 +23,14 @@ public:
|
|||
|
||||
Editor* newEditor(const QString& filename, const QByteArray& encoding,
|
||||
bool inProject, bool newFile,
|
||||
QTabWidget* page=NULL);
|
||||
QTabWidget* page=nullptr);
|
||||
|
||||
Editor* getEditor(int index=-1, QTabWidget* tabsWidget=NULL) const;
|
||||
Editor* getEditor(int index=-1, QTabWidget* tabsWidget=nullptr) const;
|
||||
|
||||
bool closeEditor(Editor* editor, bool transferFocus=true, bool force=false);
|
||||
|
||||
bool swapEditor(Editor* editor);
|
||||
|
||||
bool closeAll(bool force = false);
|
||||
|
||||
void forceCloseEditor(Editor* editor);
|
||||
|
|
|
@ -1654,14 +1654,14 @@ void MainWindow::buildContextMenus()
|
|||
connect(ui->EditorTabsLeft->tabBar(),
|
||||
&QWidget::customContextMenuRequested,
|
||||
this,
|
||||
&MainWindow::onEditorTabContextMenu
|
||||
&MainWindow::onEditorLeftTabContextMenu
|
||||
);
|
||||
|
||||
ui->EditorTabsRight->tabBar()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->EditorTabsRight->tabBar(),
|
||||
&QWidget::customContextMenuRequested,
|
||||
this,
|
||||
&MainWindow::onEditorTabContextMenu
|
||||
&MainWindow::onEditorRightTabContextMenu
|
||||
);
|
||||
|
||||
//context menu signal for Compile Issue view
|
||||
|
@ -2278,21 +2278,38 @@ void MainWindow::onEditorContextMenu(const QPoint &pos)
|
|||
|
||||
}
|
||||
|
||||
void MainWindow::onEditorTabContextMenu(const QPoint &pos)
|
||||
void MainWindow::onEditorRightTabContextMenu(const QPoint &pos)
|
||||
{
|
||||
int index = ui->EditorTabsLeft->tabBar()->tabAt(pos);
|
||||
onEditorTabContextMenu(ui->EditorTabsRight,pos);
|
||||
}
|
||||
|
||||
void MainWindow::onEditorLeftTabContextMenu(const QPoint &pos)
|
||||
{
|
||||
onEditorTabContextMenu(ui->EditorTabsLeft,pos);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::onEditorTabContextMenu(QTabWidget* tabWidget, const QPoint &pos)
|
||||
{
|
||||
int index = tabWidget->tabBar()->tabAt(pos);
|
||||
if (index<0)
|
||||
return;
|
||||
ui->EditorTabsLeft->setCurrentIndex(index);
|
||||
tabWidget->setCurrentIndex(index);
|
||||
QMenu menu(this);
|
||||
QTabBar* tabBar = ui->EditorTabsLeft->tabBar();
|
||||
QTabBar* tabBar = tabWidget->tabBar();
|
||||
menu.addAction(ui->actionClose);
|
||||
menu.addAction(ui->actionClose_All);
|
||||
menu.addSeparator();
|
||||
menu.addAction(ui->actionOpen_Containing_Folder);
|
||||
menu.addAction(ui->actionOpen_Terminal);
|
||||
menu.addSeparator();
|
||||
menu.addAction(ui->actionMove_To_Other_View);
|
||||
menu.addSeparator();
|
||||
menu.addAction(ui->actionFile_Properties);
|
||||
ui->actionMove_To_Other_View->setEnabled(
|
||||
tabWidget==ui->EditorTabsRight
|
||||
|| tabWidget->count()>1
|
||||
);
|
||||
|
||||
menu.exec(tabBar->mapToGlobal(pos));
|
||||
}
|
||||
|
@ -2529,6 +2546,12 @@ void MainWindow::on_EditorTabsLeft_tabCloseRequested(int index)
|
|||
mEditorList->closeEditor(editor);
|
||||
}
|
||||
|
||||
void MainWindow::on_EditorTabsRight_tabCloseRequested(int index)
|
||||
{
|
||||
Editor* editor = mEditorList->getEditor(index,ui->EditorTabsRight);
|
||||
mEditorList->closeEditor(editor);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionOpen_triggered()
|
||||
{
|
||||
try {
|
||||
|
@ -3507,6 +3530,11 @@ void MainWindow::on_EditorTabsLeft_tabBarDoubleClicked(int index)
|
|||
maximizeEditor();
|
||||
}
|
||||
|
||||
void MainWindow::on_EditorTabsRight_tabBarDoubleClicked(int index)
|
||||
{
|
||||
maximizeEditor();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionClose_triggered()
|
||||
{
|
||||
|
@ -3979,7 +4007,7 @@ PSymbolUsageManager &MainWindow::symbolUsageManager()
|
|||
|
||||
void MainWindow::on_EditorTabsLeft_currentChanged(int index)
|
||||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
Editor * editor = mEditorList->getEditor(-1,ui->EditorTabsLeft);
|
||||
if (editor) {
|
||||
editor->reparseTodo();
|
||||
}
|
||||
|
@ -3988,7 +4016,7 @@ void MainWindow::on_EditorTabsLeft_currentChanged(int index)
|
|||
|
||||
void MainWindow::on_EditorTabsRight_currentChanged(int index)
|
||||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
Editor * editor = mEditorList->getEditor(-1,ui->EditorTabsRight);
|
||||
if (editor) {
|
||||
editor->reparseTodo();
|
||||
}
|
||||
|
@ -4215,3 +4243,12 @@ void MainWindow::on_actionExport_As_HTML_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionMove_To_Other_View_triggered()
|
||||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor) {
|
||||
mEditorList->swapEditor(editor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,9 @@ public slots:
|
|||
void onMemoryExamineReady(const QStringList& value);
|
||||
void onLocalsReady(const QStringList& value);
|
||||
void onEditorContextMenu(const QPoint& pos);
|
||||
void onEditorTabContextMenu(const QPoint& pos);
|
||||
void onEditorRightTabContextMenu(const QPoint& pos);
|
||||
void onEditorLeftTabContextMenu(const QPoint& pos);
|
||||
void onEditorTabContextMenu(QTabWidget* tabWidget, const QPoint& pos);
|
||||
void disableDebugActions();
|
||||
void enableDebugActions();
|
||||
void onTodoParseStarted();
|
||||
|
@ -203,6 +205,7 @@ private slots:
|
|||
void on_actionNew_triggered();
|
||||
|
||||
void on_EditorTabsLeft_tabCloseRequested(int index);
|
||||
void on_EditorTabsRight_tabCloseRequested(int index);
|
||||
|
||||
void on_actionOpen_triggered();
|
||||
|
||||
|
@ -315,6 +318,7 @@ private slots:
|
|||
void on_splitterMessages_splitterMoved(int pos, int index);
|
||||
|
||||
void on_EditorTabsLeft_tabBarDoubleClicked(int index);
|
||||
void on_EditorTabsRight_tabBarDoubleClicked(int index);
|
||||
|
||||
void on_actionClose_triggered();
|
||||
|
||||
|
@ -377,7 +381,6 @@ private slots:
|
|||
void on_classBrowser_doubleClicked(const QModelIndex &index);
|
||||
|
||||
void on_EditorTabsLeft_currentChanged(int index);
|
||||
|
||||
void on_EditorTabsRight_currentChanged(int index);
|
||||
|
||||
void on_tableTODO_doubleClicked(const QModelIndex &index);
|
||||
|
@ -396,6 +399,8 @@ private slots:
|
|||
|
||||
void on_actionExport_As_HTML_triggered();
|
||||
|
||||
void on_actionMove_To_Other_View_triggered();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
EditorList *mEditorList;
|
||||
|
|
|
@ -1832,6 +1832,14 @@
|
|||
<string>Export As HTML</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMove_To_Other_View">
|
||||
<property name="text">
|
||||
<string>Move To Other View</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+M</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
@ -670,6 +670,8 @@ void SynEditTextPainter::PaintFoldAttributes()
|
|||
LastNonBlank = vLine - 1;
|
||||
while (LastNonBlank + 1 < edit->mLines->count() && edit->mLines->getString(LastNonBlank).isEmpty())
|
||||
LastNonBlank++;
|
||||
if (LastNonBlank>=edit->lines()->count())
|
||||
continue;
|
||||
LineIndent = edit->getLineIndent(edit->mLines->getString(LastNonBlank));
|
||||
int braceLevel = edit->mLines->ranges(LastNonBlank).braceLevel;
|
||||
int indentLevel = braceLevel ;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <QStringList>
|
||||
|
||||
#define DEVCPP_VERSION "0.6.5"
|
||||
#define DEVCPP_VERSION "0.6.6"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#define APP_SETTSINGS_FILENAME "redpandacpp.ini"
|
||||
|
|
Loading…
Reference in New Issue