Skip to content

Commit

Permalink
output in nider
Browse files Browse the repository at this point in the history
  • Loading branch information
nerososft committed Jun 12, 2017
1 parent 1ac6f36 commit d3e519a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 57 deletions.
109 changes: 53 additions & 56 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
#include <QSpacerItem>
#include <QSignalMapper>

QLabel *q;
QLabel *q;
void MainWindow::initUi(){

ui->setupUi(this);
q = new QLabel("Col: Row: ");
this->statusBar()->addWidget(q);

QFile qssfile(":/styles/base.qss");
qssfile.open(QFile::ReadOnly);
QString qss;
qss = qssfile.readAll();
// this->setStyleSheet(qss);
qssfile.open(QFile::ReadOnly);
QString qss;
qss = qssfile.readAll();
// this->setStyleSheet(qss);


this->setupEditor();
this->setupEditor();

}

Expand All @@ -58,22 +58,22 @@ void MainWindow::setupEditor()

ui->textEdit->setFont(font);

highlighter = new Highlighter(ui->textEdit->document());
highlighter = new Highlighter(ui->textEdit->document());

for(int i = 0;i<9;i++){
QPushButton* editorTopB = new QPushButton("");
editorTopB->setStyleSheet("background:rgba(0, 128, 255,0);color:rgb(255, 255, 255);border:none;margin:0;padding:4px;padding-left:20px;padding-right:20px;margin-left:1px;");
this->editorTop[i] = editorTopB;
connect(editorTop[i], SIGNAL(clicked()), this->signalMapper, SLOT(map()));
}
connect(signalMapper, SIGNAL(mapped(QString)), this, SLOT(onTopClicked(QString)));
this->editorTop[0]->setStyleSheet("background:rgb(0, 128, 255);color:rgb(255, 255, 255);border:none;margin:0;padding:4px;padding-left:20px;padding-right:20px;margin-left:1px;");
this->editorTop[0]->setText("欢迎页");
for(int i = 0;i<9;i++){
QPushButton* editorTopB = new QPushButton("");
editorTopB->setStyleSheet("background:rgba(0, 128, 255,0);color:rgb(255, 255, 255);border:none;margin:0;padding:4px;padding-left:20px;padding-right:20px;margin-left:1px;");
this->editorTop[i] = editorTopB;
connect(editorTop[i], SIGNAL(clicked()), this->signalMapper, SLOT(map()));
}
connect(signalMapper, SIGNAL(mapped(QString)), this, SLOT(onTopClicked(QString)));
this->editorTop[0]->setStyleSheet("background:rgb(0, 128, 255);color:rgb(255, 255, 255);border:none;margin:0;padding:4px;padding-left:20px;padding-right:20px;margin-left:1px;");
this->editorTop[0]->setText("欢迎页");


for (int i = 0;i<9;i++){
this->ui->edit_title->addWidget(editorTop[i]);
}
for (int i = 0;i<9;i++){
this->ui->edit_title->addWidget(editorTop[i]);
}

}

Expand All @@ -95,42 +95,42 @@ void MainWindow::on_actionOpen_Project_triggered()
{
QFileDialog projectDialog;
QString path = projectDialog.getOpenFileName(this, tr("Open Nide project"), ".", tr("Nide project Files(*.nproj)"));
if(path.length() != 0) {
QFile file(path);
FileHelper fileHelper;
JsonHelper jsonHelper;
QString buffer = fileHelper.loadFileToString(path);
this->projectOBJ = jsonHelper.getJsonObjectFromString(buffer);
if(path.length() != 0) {
QFile file(path);
FileHelper fileHelper;
JsonHelper jsonHelper;
QString buffer = fileHelper.loadFileToString(path);
this->projectOBJ = jsonHelper.getJsonObjectFromString(buffer);

this->pp = new Project(this->projectOBJ);
this->ui->projectName->setText(this->pp->getProjectName());
this->ui->listView_undo->setModel(this->pp->getTaskUndo());
this->ui->listView_doing->setModel(this->pp->getTaskDoing());
this->ui->listView_done->setModel(this->pp->getTaskDone());
this->ui->treeViewProject->setModel(this->pp->getProjectTree());
this->pp = new Project(this->projectOBJ);
this->ui->projectName->setText(this->pp->getProjectName());
this->ui->listView_undo->setModel(this->pp->getTaskUndo());
this->ui->listView_doing->setModel(this->pp->getTaskDoing());
this->ui->listView_done->setModel(this->pp->getTaskDone());
this->ui->treeViewProject->setModel(this->pp->getProjectTree());



this->projectPath = QFileInfo(path).absolutePath()+"/";
projectDialog.close();
this->projectPath = QFileInfo(path).absolutePath()+"/";
projectDialog.close();

}
}

}

void MainWindow::on_textEdit_textChanged()
{
QTextCursor cursor = ui->textEdit->textCursor();
int ColNum = cursor.columnNumber();
int RowNum = cursor.blockNumber();
q->setText("Col: "+QString::number(ColNum,10)+" Row: "+QString::number(RowNum,10));
QTextCursor cursor = ui->textEdit->textCursor();
int ColNum = cursor.columnNumber();
int RowNum = cursor.blockNumber();
q->setText("Col: "+QString::number(ColNum,10)+" Row: "+QString::number(RowNum,10));
}
void MainWindow::EditAddFileTitle(QString filename){
if(!this->editorManager.isFileOpened(filename,this->projectPath)){
QPushButton* push = new QPushButton(filename);
push->setStyleSheet("background:rgb(0, 128, 255);color:rgb(255, 255, 255);border:none;margin:0;padding:4px;padding-left:20px;padding-right:20px;margin-left:1px;");
this->ui->edit_title->addWidget(push,0);
}
if(!this->editorManager.isFileOpened(filename,this->projectPath)){
QPushButton* push = new QPushButton(filename);
push->setStyleSheet("background:rgb(0, 128, 255);color:rgb(255, 255, 255);border:none;margin:0;padding:4px;padding-left:20px;padding-right:20px;margin-left:1px;");
this->ui->edit_title->addWidget(push,0);
}
}


Expand All @@ -140,15 +140,14 @@ void MainWindow::onTopClicked(QString index){
if(this->fileIndex!=""){
FileHelper filehelper;
if(!filehelper.saveFile(this->projectPath+this->fileIndex,this->ui->textEdit->toPlainText())){
ErrorHelper err;
err.Error("文件"+this->projectPath+this->fileIndex+"保存失败");
this->ui->textBrowser_output->setText(this->ui->textBrowser_output->toPlainText()+"\n"+"文件"+this->projectPath+this->fileIndex+"保存失败");
}else{
if(!this->fileManager.updateFileBuffer(this->fileIndex,this->ui->textEdit->toPlainText())){
ErrorHelper err;
err.Error("buffer"+this->projectPath+this->fileIndex+"更新失败");
this->ui->textBrowser_output->setText(this->ui->textBrowser_output->toPlainText()+"\n"+"buffer"+this->projectPath+this->fileIndex+"更新失败");
}
}
qDebug()<<"文件"+this->projectPath+this->fileIndex+"保存成功";
this->ui->textBrowser_output->setText(this->ui->textBrowser_output->toPlainText()+"\n"+"文件"+this->projectPath+this->fileIndex+"保存成功");

}
this->fileIndex = index;

Expand All @@ -161,16 +160,16 @@ void MainWindow::renderTitle(QString file){

for(int i = 0;i<opened.size();i++){
this->editorTop[i]->setText(opened.at(i));
if(opened.at(i)==file){
if(opened.at(i)==file){
this->editorTop[i]->setStyleSheet("background:rgb(0, 128, 255);color:rgb(255, 255, 255);border:none;margin:0;padding:4px;padding-left:20px;padding-right:20px;margin-left:1px;");
}else{
this->editorTop[i]->setStyleSheet("background:rgb(45, 45, 48);color:rgb(255, 255, 255);border:none;margin:0;padding:4px;padding-left:20px;padding-right:20px;margin-left:1px;");
this->editorTop[i]->setStyleSheet("background:rgb(45, 45, 48);color:rgb(255, 255, 255);border:none;margin:0;padding:4px;padding-left:20px;padding-right:20px;margin-left:1px;");

}
QString ff = editorTop[i]->text();
this->signalMapper->setMapping(editorTop[i], ff);

}
}

}

Expand All @@ -189,15 +188,13 @@ void MainWindow::on_treeViewProject_clicked(const QModelIndex &index)
if(this->fileIndex!=""){
FileHelper filehelper;
if(!filehelper.saveFile(this->projectPath+this->fileIndex,this->ui->textEdit->toPlainText())){
ErrorHelper err;
err.Error("文件"+this->projectPath+this->fileIndex+"保存失败");
this->ui->textBrowser_output->setText(this->ui->textBrowser_output->toPlainText()+"\n"+"文件"+this->projectPath+this->fileIndex+"保存失败");
}else{
if(!this->fileManager.updateFileBuffer(this->fileIndex,this->ui->textEdit->toPlainText())){
ErrorHelper err;
err.Error("buffer"+this->projectPath+this->fileIndex+"更新失败");
this->ui->textBrowser_output->setText(this->ui->textBrowser_output->toPlainText()+"\n"+"buffer"+this->projectPath+this->fileIndex+"更新失败");
}
}
qDebug()<<"文件"+this->projectPath+this->fileIndex+"保存成功";
this->ui->textBrowser_output->setText(this->ui->textBrowser_output->toPlainText()+"\n"+"文件"+this->projectPath+this->fileIndex+"保存成功");
}
this->fileIndex = str;

Expand Down
11 changes: 10 additions & 1 deletion mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ background:rgb(35, 35, 38);
}</string>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab_5">
<attribute name="title">
Expand Down Expand Up @@ -508,6 +508,15 @@ color:rgb(255, 0, 0);</string>
<attribute name="title">
<string>输出</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QTextBrowser" name="textBrowser_output">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_7">
<attribute name="title">
Expand Down

0 comments on commit d3e519a

Please sign in to comment.