diff options
Diffstat (limited to 'src-qt5')
5 files changed, 33 insertions, 6 deletions
diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp b/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp index 65979c46..52a29c01 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp @@ -18,6 +18,8 @@ #include <QTimer> #include <QMessageBox> #include <QActionGroup> +#include <QPrinter> +#include <QPrintDialog> #include "PlainTextEditor.h" MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ @@ -87,6 +89,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ 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->actionPrint, SIGNAL(triggered()), this, SLOT(Print()) ); connect(ui->menuSyntax_Highlighting, SIGNAL(triggered(QAction*)), this, SLOT(UpdateHighlighting(QAction*)) ); connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged()) ); connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabClosed(int)) ); @@ -144,6 +147,7 @@ void MainUI::updateIcons(){ 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->actionPrint->setIcon(LXDG::findIcon("printer") ); ui->actionFind->setIcon(LXDG::findIcon("edit-find") ); ui->actionReplace->setIcon(LXDG::findIcon("edit-find-replace") ); ui->menuSyntax_Highlighting->setIcon( LXDG::findIcon("format-text-color") ); @@ -239,7 +243,20 @@ void MainUI::SaveFile(){ void MainUI::SaveFileAs(){ PlainTextEditor *cur = currentEditor(); if(cur==0){ return; } - cur->SaveFile(true); + cur->SaveFile(true); +} + +void MainUI::Print() { + QPrinter *print = new QPrinter(QPrinter::HighResolution); + QPrintDialog dialog(print, NULL); + dialog.setWindowTitle(tr("Print Content")); + dialog.setOptions( QAbstractPrintDialog::PrintCurrentPage | QAbstractPrintDialog::PrintToFile ); + if(currentEditor()->textCursor().hasSelection()) { + dialog.setOptions( QAbstractPrintDialog::PrintCurrentPage | QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintSelection ); + } + if(dialog.exec() == QDialog::Accepted) { + currentEditor()->print(print); + } } void MainUI::fontChanged(const QFont&){ @@ -422,7 +439,7 @@ void MainUI::findNext(){ if(!found){ //Try starting back at the top of the file cur->moveCursor(QTextCursor::Start); - cur->find( ui->line_find->text(), ui->tool_find_casesensitive->isChecked() ? QTextDocument::FindCaseSensitively : QTextDocument::FindFlags() ); + cur->find( ui->line_find->text(), ui->tool_find_casesensitive->isChecked() ? QTextDocument::FindCaseSensitively : QTextDocument::FindFlags() ); } } @@ -433,7 +450,7 @@ void MainUI::findPrev(){ if(!found){ //Try starting back at the bottom of the file cur->moveCursor(QTextCursor::End); - cur->find( ui->line_find->text(), ui->tool_find_casesensitive->isChecked() ? QTextDocument::FindCaseSensitively | QTextDocument::FindBackward : QTextDocument::FindBackward ); + cur->find( ui->line_find->text(), ui->tool_find_casesensitive->isChecked() ? QTextDocument::FindCaseSensitively | QTextDocument::FindBackward : QTextDocument::FindBackward ); } } diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.h b/src-qt5/desktop-utils/lumina-textedit/MainUI.h index 845a4a19..963443b6 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.h +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.h @@ -52,6 +52,7 @@ private slots: void CloseFile(); //current file only void SaveFile(); void SaveFileAs(); + void Print(); void fontChanged(const QFont &font); void updateStatusTip(); void changeFontSize(int newFontSize); diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.ui b/src-qt5/desktop-utils/lumina-textedit/MainUI.ui index aa7669b2..a09f1bb1 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.ui +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.ui @@ -185,7 +185,7 @@ <x>0</x> <y>0</y> <width>505</width> - <height>20</height> + <height>21</height> </rect> </property> <property name="contextMenuPolicy"> @@ -202,6 +202,7 @@ <addaction name="actionSave_File"/> <addaction name="actionSave_File_As"/> <addaction name="separator"/> + <addaction name="actionPrint"/> <addaction name="actionClose"/> </widget> <widget class="QMenu" name="menuView"> @@ -433,6 +434,14 @@ <string>Right</string> </property> </action> + <action name="actionPrint"> + <property name="text"> + <string>Print</string> + </property> + <property name="shortcut"> + <string>Ctrl+P</string> + </property> + </action> </widget> <resources/> <connections/> diff --git a/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.pro b/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.pro index 9dfd8fea..df9093e6 100644 --- a/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.pro +++ b/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.pro @@ -1,6 +1,6 @@ include("$${PWD}/../../OS-detect.pri") -QT += core gui widgets +QT += core gui widgets printsupport TARGET = lumina-textedit target.path = $${L_BINDIR} diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/cpp.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/cpp.syntax index 4efd7fb3..ada90b24 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/cpp.syntax +++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/cpp.syntax @@ -27,7 +27,7 @@ }, { "name": "keywords", - "words": ["char", "class", "const", "double", "enum", "explicit", "extern", "float", "friend", "inline", "int", "long", "namespace", "operator", "private", "protected", "public", "short", "signals", "signed", "slots", "static", "struct", "template", "typedef", "typename", "union", "using","unsigned", "virtual", "void", "volatile", "true", "false", "bool"], + "words": ["char", "class", "const", "double", "enum", "explicit", "extern", "float", "friend", "inline", "int", "long", "namespace", "operator", "private", "protected", "public", "short", "signals", "signed", "slots", "static", "struct", "template", "typedef", "typename", "union", "using","unsigned", "virtual", "void", "volatile", "true", "false", "bool", "and", "or", "not"], "foreground": "colors/keyword", "font_weight": "bold" }, |