From 6acf67d88067dfa53bd5b29c1e475b111163b63a Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 18 Apr 2016 11:31:08 -0400 Subject: Get almost everything else setup and functional. Now tabs can be closed/opened/moved just fine, the line numbers can be enabled/disabled, etc... --- desktop-utilities/lumina-textedit/MainUI.cpp | 32 +++++++++++++++++++++++++++- desktop-utilities/lumina-textedit/MainUI.h | 6 ++++++ desktop-utilities/lumina-textedit/MainUI.ui | 3 +++ 3 files changed, 40 insertions(+), 1 deletion(-) (limited to 'desktop-utilities/lumina-textedit') diff --git a/desktop-utilities/lumina-textedit/MainUI.cpp b/desktop-utilities/lumina-textedit/MainUI.cpp index eae57f6e..f3e29d30 100644 --- a/desktop-utilities/lumina-textedit/MainUI.cpp +++ b/desktop-utilities/lumina-textedit/MainUI.cpp @@ -30,6 +30,9 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->actionSave_File, SIGNAL(triggered()), this, SLOT(SaveFile()) ); connect(ui->actionSave_File_As, SIGNAL(triggered()), this, SLOT(SaveFileAs()) ); connect(ui->menuSyntax_Highlighting, SIGNAL(triggered(QAction*)), this, SLOT(UpdateHighlighting(QAction*)) ); + connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged()) ); + connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabClosed(int)) ); + connect(ui->actionLine_Numbers, SIGNAL(toggled(bool)), this, SLOT(showLineNumbers(bool)) ); updateIcons(); } @@ -127,6 +130,13 @@ void MainUI::UpdateHighlighting(QAction *act){ cur->LoadSyntaxRule(act->text()); } +void MainUI::showLineNumbers(bool show){ + for(int i=0; itabWidget->count(); i++){ + PlainTextEditor *edit = static_cast(ui->tabWidget->widget(i)); + edit->showLineNumbers(show); + } +} + void MainUI::updateTab(QString file){ PlainTextEditor *cur = currentEditor(); if(cur==0){ return; } //should never happen @@ -136,4 +146,24 @@ void MainUI::updateTab(QString file){ ui->tabWidget->setTabText(index,(changes ? "*" : "") + file.section("/",-1)); ui->actionSave_File->setEnabled(changes); ui->actionSave_File_As->setEnabled(changes); -} \ No newline at end of file +} + +void MainUI::tabChanged(){ + //update the buttons/menus based on the current widget + PlainTextEditor *cur = currentEditor(); + if(cur==0){ return; } //should never happen though + bool changes = cur->hasChange(); + ui->actionSave_File->setEnabled(changes); + ui->actionSave_File_As->setEnabled(changes); +} + +void MainUI::tabClosed(int tab){ + PlainTextEditor *edit = static_cast(ui->tabWidget->widget(tab)); + if(edit==0){ return; } //should never happen + if(edit->hasChange()){ + //Verify if the user wants to lose any unsaved changes + + } + ui->tabWidget->removeTab(tab); + edit->deleteLater(); +} diff --git a/desktop-utilities/lumina-textedit/MainUI.h b/desktop-utilities/lumina-textedit/MainUI.h index 7db77433..9d16933d 100644 --- a/desktop-utilities/lumina-textedit/MainUI.h +++ b/desktop-utilities/lumina-textedit/MainUI.h @@ -40,9 +40,15 @@ private slots: void OpenFile(QString file = ""); void SaveFile(); void SaveFileAs(); + + //Other Menu Actions void UpdateHighlighting(QAction*); + void showLineNumbers(bool); + //Tab Interactions void updateTab(QString); + void tabChanged(); + void tabClosed(int); }; #endif \ No newline at end of file diff --git a/desktop-utilities/lumina-textedit/MainUI.ui b/desktop-utilities/lumina-textedit/MainUI.ui index 01b20dc1..56598ce4 100644 --- a/desktop-utilities/lumina-textedit/MainUI.ui +++ b/desktop-utilities/lumina-textedit/MainUI.ui @@ -32,6 +32,9 @@ true + + true + false -- cgit