From 7e043b182dd4f91e9786b3b89dbf857c83027015 Mon Sep 17 00:00:00 2001 From: Vesa Pikki Date: Thu, 2 Jul 2009 19:46:26 +0300 Subject: [PATCH] Fileview dialogs now use Qt Designer ui files. Translation also updated. --- gui/cppcheck_de.ts | 23 ++++++++------ gui/cppcheck_en.ts | 23 ++++++++------ gui/cppcheck_fi.ts | 23 ++++++++------ gui/cppcheck_ru.ts | 23 ++++++++------ gui/cppcheck_se.ts | 23 ++++++++------ gui/file.ui | 71 ++++++++++++++++++++++++++++++++++++++++++ gui/fileviewdialog.cpp | 36 +++++---------------- gui/fileviewdialog.h | 10 ++++-- gui/gui.pro | 1 + gui/mainwindow.cpp | 6 ++-- 10 files changed, 160 insertions(+), 79 deletions(-) create mode 100644 gui/file.ui diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts index b63f49005..daf990687 100644 --- a/gui/cppcheck_de.ts +++ b/gui/cppcheck_de.ts @@ -96,23 +96,18 @@ kate -l(line) (file) FileViewDialog - - Close - - - - + Could not find the file: %1 - - + + Cppcheck - + Could not read the file: %1 @@ -310,6 +305,16 @@ kate -l(line) (file) Stop the checking before exiting. + + + License + + + + + Authors + + XML files (*.xml);;Text files (*.txt) diff --git a/gui/cppcheck_en.ts b/gui/cppcheck_en.ts index c09a4ddce..b4b9e64bf 100644 --- a/gui/cppcheck_en.ts +++ b/gui/cppcheck_en.ts @@ -107,25 +107,20 @@ kate -l(line) (file) FileViewDialog - - Close - Close - - - + Could not find the file: %1 Could not find the file: Could not find the file: %1 - - + + Cppcheck Cppcheck - + Could not read the file: %1 Could not read the file: %1 @@ -325,6 +320,16 @@ Stop the checking before exiting. Stop the checking before exiting. + + + License + License + + + + Authors + Authors + XML files (*.xml);;Text files (*.txt) diff --git a/gui/cppcheck_fi.ts b/gui/cppcheck_fi.ts index b324d3c53..d43228a9b 100644 --- a/gui/cppcheck_fi.ts +++ b/gui/cppcheck_fi.ts @@ -109,25 +109,20 @@ kate -l(line) (file) FileViewDialog - - Close - Sulje - - - + Could not find the file: %1 Could not find the file: Tiedostoa %1 ei löytynyt - - + + Cppcheck Cppcheck - + Could not read the file: %1 Tiedoston %1 lukeminen epäonnistui @@ -327,6 +322,16 @@ Stop the checking before exiting. Lopeta tarkistus ennen ohjelman sammuttamista. + + + License + Lisenssi + + + + Authors + Tekijät + XML files (*.xml);;Text files (*.txt) diff --git a/gui/cppcheck_ru.ts b/gui/cppcheck_ru.ts index d281e7efb..da08c165a 100644 --- a/gui/cppcheck_ru.ts +++ b/gui/cppcheck_ru.ts @@ -96,25 +96,20 @@ kate -l(line) (file) FileViewDialog - - Close - - - - + Could not find the file: %1 Could not find the file: - - + + Cppcheck - + Could not read the file: %1 @@ -312,6 +307,16 @@ kate -l(line) (file) Stop the checking before exiting. + + + License + + + + + Authors + + XML files (*.xml);;Text files (*.txt) diff --git a/gui/cppcheck_se.ts b/gui/cppcheck_se.ts index d281e7efb..da08c165a 100644 --- a/gui/cppcheck_se.ts +++ b/gui/cppcheck_se.ts @@ -96,25 +96,20 @@ kate -l(line) (file) FileViewDialog - - Close - - - - + Could not find the file: %1 Could not find the file: - - + + Cppcheck - + Could not read the file: %1 @@ -312,6 +307,16 @@ kate -l(line) (file) Stop the checking before exiting. + + + License + + + + + Authors + + XML files (*.xml);;Text files (*.txt) diff --git a/gui/file.ui b/gui/file.ui new file mode 100644 index 000000000..22a581d76 --- /dev/null +++ b/gui/file.ui @@ -0,0 +1,71 @@ + + + Fileview + + + + 0 + 0 + 400 + 300 + + + + Fileview + + + + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + mButtons + accepted() + Fileview + accept() + + + 248 + 254 + + + 157 + 274 + + + + + mButtons + rejected() + Fileview + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/gui/fileviewdialog.cpp b/gui/fileviewdialog.cpp index d2c309152..4f76df068 100644 --- a/gui/fileviewdialog.cpp +++ b/gui/fileviewdialog.cpp @@ -26,27 +26,17 @@ #include #include "fileviewdialog.h" -FileViewDialog::FileViewDialog(const QString &file, QWidget *parent) +FileViewDialog::FileViewDialog(const QString &file, + const QString &title, + QWidget *parent) : QDialog(parent) { - QString title = FormatTitle(file); + mUI.setupUi(this); + + setWindowTitle(title); - - QVBoxLayout *mainLayout = new QVBoxLayout(); - QHBoxLayout *btnLayout = new QHBoxLayout(); - QPushButton *quit = new QPushButton(tr("Close")); - QTextEdit *edit = new QTextEdit(); - edit->setReadOnly(true); - - mainLayout->addWidget(edit); - mainLayout->addLayout(btnLayout); - btnLayout->addStretch(); - btnLayout->addWidget(quit); - setLayout(mainLayout); - - connect(quit, SIGNAL(clicked()), this, SLOT(close())); - - LoadTextFile(file, edit); + connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept())); + LoadTextFile(file, mUI.mText); } void FileViewDialog::LoadTextFile(const QString &filename, QTextEdit *edit) @@ -86,13 +76,3 @@ void FileViewDialog::LoadTextFile(const QString &filename, QTextEdit *edit) QString filestringdata(filedata); edit->setPlainText(filestringdata); } - -QString FileViewDialog::FormatTitle(const QString &filename) -{ - QString title(filename); - if (title.startsWith(":")) - { - title.remove(0, 1); - } - return title; -} diff --git a/gui/fileviewdialog.h b/gui/fileviewdialog.h index 04979178c..c6c0a19d4 100644 --- a/gui/fileviewdialog.h +++ b/gui/fileviewdialog.h @@ -21,9 +21,8 @@ #include #include +#include "ui_file.h" -class QWidget; -class QTextEdit; /** * @brief File view -dialog. @@ -35,7 +34,10 @@ class FileViewDialog : public QDialog { Q_OBJECT public: - FileViewDialog(const QString &file, QWidget *parent = 0); + FileViewDialog(const QString &file, + const QString &title, + QWidget *parent = 0); + protected: @@ -53,6 +55,8 @@ protected: * @param filename File to load. */ QString FormatTitle(const QString &filename); + + Ui::Fileview mUI; }; #endif // FILEVIEW_DIALOG_H diff --git a/gui/gui.pro b/gui/gui.pro index 75e73b1ab..eeccb840f 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -15,6 +15,7 @@ FORMS = main.ui \ resultsview.ui \ application.ui \ settings.ui \ + file.ui \ about.ui TRANSLATIONS = cppcheck_fi.ts \ diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 73235127a..30eb9b070 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -489,14 +489,14 @@ void MainWindow::About() void MainWindow::ShowLicense() { - FileViewDialog *dlg = new FileViewDialog(":COPYING", this); - dlg->resize(550, 400); + FileViewDialog *dlg = new FileViewDialog(":COPYING",tr("License"), this); + dlg->resize(570, 400); dlg->exec(); } void MainWindow::ShowAuthors() { - FileViewDialog *dlg = new FileViewDialog(":AUTHORS", this); + FileViewDialog *dlg = new FileViewDialog(":AUTHORS",tr("Authors"), this); dlg->resize(350, 400); dlg->exec(); }