From fbfc3e91cc6efa39a174b4cc65a14c89440844a3 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 19 Apr 2016 10:11:44 -0400 Subject: Get a lot more of lumina-textedit done. Almost everything is complete now except for the color-selection dialog. --- desktop-utilities/lumina-textedit/MainUI.cpp | 46 ++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 9 deletions(-) (limited to 'desktop-utilities/lumina-textedit/MainUI.cpp') diff --git a/desktop-utilities/lumina-textedit/MainUI.cpp b/desktop-utilities/lumina-textedit/MainUI.cpp index f3e29d30..53fa0ca6 100644 --- a/desktop-utilities/lumina-textedit/MainUI.cpp +++ b/desktop-utilities/lumina-textedit/MainUI.cpp @@ -10,12 +10,15 @@ #include "syntaxSupport.h" #include +#include #include #include MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->setupUi(this); + settings = new QSettings("lumina-desktop","lumina-textedit"); + Custom_Syntax::SetupDefaultColors(settings); //pre-load any color settings as needed this->setWindowTitle(tr("Text Editor")); ui->tabWidget->clear(); //Update the menu of available syntax highlighting modes @@ -23,17 +26,25 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ for(int i=0; imenuSyntax_Highlighting->addAction(smodes[i]); } + ui->actionLine_Numbers->setChecked( settings->value("showLineNumbers",true).toBool() ); //Setup any connections connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(close()) ); connect(ui->actionNew_File, SIGNAL(triggered()), this, SLOT(NewFile()) ); connect(ui->actionOpen_File, SIGNAL(triggered()), this, SLOT(OpenFile()) ); + connect(ui->actionClose_File, SIGNAL(triggered()), this, SLOT(CloseFile()) ); 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)) ); + connect(ui->actionCustomize_Colors, SIGNAL(triggered()), this, SLOT(ModifyColors()) ); updateIcons(); + //Now load the initial size of the window + QSize lastSize = settings->value("lastSize",QSize()).toSize(); + if(lastSize.width() > this->sizeHint().width() && lastSize.height() > this->sizeHint().height() ){ + this->resize(lastSize); + } } MainUI::~MainUI(){ @@ -42,24 +53,23 @@ MainUI::~MainUI(){ void MainUI::LoadArguments(QStringList args){ //CLI arguments for(int i=0; itabWidget->count()<1){ - NewFile(); - }*/ } // ================= // PUBLIC SLOTS //================= void MainUI::updateIcons(){ + this->setWindowIcon( LXDG::findIcon("document-edit") ); ui->actionClose->setIcon(LXDG::findIcon("application-exit") ); ui->actionNew_File->setIcon(LXDG::findIcon("document-new") ); ui->actionOpen_File->setIcon(LXDG::findIcon("document-open") ); + ui->actionClose_File->setIcon(LXDG::findIcon("document-close") ); ui->actionSave_File->setIcon(LXDG::findIcon("document-save") ); ui->actionSave_File_As->setIcon(LXDG::findIcon("document-save-as") ); ui->menuSyntax_Highlighting->setIcon( LXDG::findIcon("format-text-color") ); + ui->actionCustomize_Colors->setIcon( LXDG::findIcon("format-fill-color") ); } @@ -100,7 +110,7 @@ void MainUI::OpenFile(QString file){ files << file; } for(int i=0; itabWidget->addTab(edit, files[i].section("/",-1)); @@ -112,6 +122,11 @@ void MainUI::OpenFile(QString file){ } } +void MainUI::CloseFile(){ + int index = ui->tabWidget->currentIndex(); + if(index>=0){ tabClosed(index); } +} + void MainUI::SaveFile(){ PlainTextEditor *cur = currentEditor(); if(cur==0){ return; } @@ -131,18 +146,31 @@ void MainUI::UpdateHighlighting(QAction *act){ } void MainUI::showLineNumbers(bool show){ + settings->setValue("showLineNumbers",show); for(int i=0; itabWidget->count(); i++){ PlainTextEditor *edit = static_cast(ui->tabWidget->widget(i)); edit->showLineNumbers(show); } } +void MainUI::ModifyColors(){ + +} + void MainUI::updateTab(QString file){ - PlainTextEditor *cur = currentEditor(); + PlainTextEditor *cur = 0; + int index = -1; + for(int i=0; itabWidget->count(); i++){ + PlainTextEditor *tmp = static_cast(ui->tabWidget->widget(i)); + if(tmp->currentFile()==file){ + cur = tmp; + index = i; + break; + } + } if(cur==0){ return; } //should never happen - int index = ui->tabWidget->currentIndex(); - if(index<0){ index = 0; } //FALLBACK - use the first tab bool changes = cur->hasChange(); + //qDebug() << "Update Tab:" << file << cur << changes; ui->tabWidget->setTabText(index,(changes ? "*" : "") + file.section("/",-1)); ui->actionSave_File->setEnabled(changes); ui->actionSave_File_As->setEnabled(changes); -- cgit