Fileview dialogs now use Qt Designer ui files.

Translation also updated.
This commit is contained in:
Vesa Pikki 2009-07-02 19:46:26 +03:00
parent 8694f6e982
commit 7e043b182d
10 changed files with 160 additions and 79 deletions

View File

@ -96,23 +96,18 @@ kate -l(line) (file)</source>
<context> <context>
<name>FileViewDialog</name> <name>FileViewDialog</name>
<message> <message>
<location filename="fileviewdialog.cpp" line="37"/> <location filename="fileviewdialog.cpp" line="47"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="fileviewdialog.cpp" line="57"/>
<source>Could not find the file: %1</source> <source>Could not find the file: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="fileviewdialog.cpp" line="61"/> <location filename="fileviewdialog.cpp" line="51"/>
<location filename="fileviewdialog.cpp" line="76"/> <location filename="fileviewdialog.cpp" line="66"/>
<source>Cppcheck</source> <source>Cppcheck</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="fileviewdialog.cpp" line="72"/> <location filename="fileviewdialog.cpp" line="62"/>
<source>Could not read the file: %1</source> <source>Could not read the file: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -310,6 +305,16 @@ kate -l(line) (file)</source>
Stop the checking before exiting.</source> Stop the checking before exiting.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="mainwindow.cpp" line="492"/>
<source>License</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="499"/>
<source>Authors</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="mainwindow.cpp" line="507"/> <location filename="mainwindow.cpp" line="507"/>
<source>XML files (*.xml);;Text files (*.txt)</source> <source>XML files (*.xml);;Text files (*.txt)</source>

View File

@ -107,25 +107,20 @@ kate -l(line) (file)</translation>
<context> <context>
<name>FileViewDialog</name> <name>FileViewDialog</name>
<message> <message>
<location filename="fileviewdialog.cpp" line="37"/> <location filename="fileviewdialog.cpp" line="47"/>
<source>Close</source>
<translation>Close</translation>
</message>
<message>
<location filename="fileviewdialog.cpp" line="57"/>
<source>Could not find the file: %1</source> <source>Could not find the file: %1</source>
<oldsource>Could not find the file: <oldsource>Could not find the file:
</oldsource> </oldsource>
<translation>Could not find the file: %1</translation> <translation>Could not find the file: %1</translation>
</message> </message>
<message> <message>
<location filename="fileviewdialog.cpp" line="61"/> <location filename="fileviewdialog.cpp" line="51"/>
<location filename="fileviewdialog.cpp" line="76"/> <location filename="fileviewdialog.cpp" line="66"/>
<source>Cppcheck</source> <source>Cppcheck</source>
<translation>Cppcheck</translation> <translation>Cppcheck</translation>
</message> </message>
<message> <message>
<location filename="fileviewdialog.cpp" line="72"/> <location filename="fileviewdialog.cpp" line="62"/>
<source>Could not read the file: %1</source> <source>Could not read the file: %1</source>
<translation>Could not read the file: %1</translation> <translation>Could not read the file: %1</translation>
</message> </message>
@ -325,6 +320,16 @@ Stop the checking before exiting.</source>
Stop the checking before exiting.</translation> Stop the checking before exiting.</translation>
</message> </message>
<message>
<location filename="mainwindow.cpp" line="492"/>
<source>License</source>
<translation>License</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="499"/>
<source>Authors</source>
<translation>Authors</translation>
</message>
<message> <message>
<location filename="mainwindow.cpp" line="507"/> <location filename="mainwindow.cpp" line="507"/>
<source>XML files (*.xml);;Text files (*.txt)</source> <source>XML files (*.xml);;Text files (*.txt)</source>

View File

@ -109,25 +109,20 @@ kate -l(line) (file)
<context> <context>
<name>FileViewDialog</name> <name>FileViewDialog</name>
<message> <message>
<location filename="fileviewdialog.cpp" line="37"/> <location filename="fileviewdialog.cpp" line="47"/>
<source>Close</source>
<translation>Sulje</translation>
</message>
<message>
<location filename="fileviewdialog.cpp" line="57"/>
<source>Could not find the file: %1</source> <source>Could not find the file: %1</source>
<oldsource>Could not find the file: <oldsource>Could not find the file:
</oldsource> </oldsource>
<translation>Tiedostoa %1 ei löytynyt</translation> <translation>Tiedostoa %1 ei löytynyt</translation>
</message> </message>
<message> <message>
<location filename="fileviewdialog.cpp" line="61"/> <location filename="fileviewdialog.cpp" line="51"/>
<location filename="fileviewdialog.cpp" line="76"/> <location filename="fileviewdialog.cpp" line="66"/>
<source>Cppcheck</source> <source>Cppcheck</source>
<translation>Cppcheck</translation> <translation>Cppcheck</translation>
</message> </message>
<message> <message>
<location filename="fileviewdialog.cpp" line="72"/> <location filename="fileviewdialog.cpp" line="62"/>
<source>Could not read the file: %1</source> <source>Could not read the file: %1</source>
<translation>Tiedoston %1 lukeminen epäonnistui</translation> <translation>Tiedoston %1 lukeminen epäonnistui</translation>
</message> </message>
@ -327,6 +322,16 @@ Stop the checking before exiting.</source>
Lopeta tarkistus ennen ohjelman sammuttamista.</translation> Lopeta tarkistus ennen ohjelman sammuttamista.</translation>
</message> </message>
<message>
<location filename="mainwindow.cpp" line="492"/>
<source>License</source>
<translation>Lisenssi</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="499"/>
<source>Authors</source>
<translation>Tekijät</translation>
</message>
<message> <message>
<location filename="mainwindow.cpp" line="507"/> <location filename="mainwindow.cpp" line="507"/>
<source>XML files (*.xml);;Text files (*.txt)</source> <source>XML files (*.xml);;Text files (*.txt)</source>

View File

@ -96,25 +96,20 @@ kate -l(line) (file)</source>
<context> <context>
<name>FileViewDialog</name> <name>FileViewDialog</name>
<message> <message>
<location filename="fileviewdialog.cpp" line="37"/> <location filename="fileviewdialog.cpp" line="47"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="fileviewdialog.cpp" line="57"/>
<source>Could not find the file: %1</source> <source>Could not find the file: %1</source>
<oldsource>Could not find the file: <oldsource>Could not find the file:
</oldsource> </oldsource>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="fileviewdialog.cpp" line="61"/> <location filename="fileviewdialog.cpp" line="51"/>
<location filename="fileviewdialog.cpp" line="76"/> <location filename="fileviewdialog.cpp" line="66"/>
<source>Cppcheck</source> <source>Cppcheck</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="fileviewdialog.cpp" line="72"/> <location filename="fileviewdialog.cpp" line="62"/>
<source>Could not read the file: %1</source> <source>Could not read the file: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -312,6 +307,16 @@ kate -l(line) (file)</source>
Stop the checking before exiting.</source> Stop the checking before exiting.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="mainwindow.cpp" line="492"/>
<source>License</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="499"/>
<source>Authors</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="mainwindow.cpp" line="507"/> <location filename="mainwindow.cpp" line="507"/>
<source>XML files (*.xml);;Text files (*.txt)</source> <source>XML files (*.xml);;Text files (*.txt)</source>

View File

@ -96,25 +96,20 @@ kate -l(line) (file)</source>
<context> <context>
<name>FileViewDialog</name> <name>FileViewDialog</name>
<message> <message>
<location filename="fileviewdialog.cpp" line="37"/> <location filename="fileviewdialog.cpp" line="47"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="fileviewdialog.cpp" line="57"/>
<source>Could not find the file: %1</source> <source>Could not find the file: %1</source>
<oldsource>Could not find the file: <oldsource>Could not find the file:
</oldsource> </oldsource>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="fileviewdialog.cpp" line="61"/> <location filename="fileviewdialog.cpp" line="51"/>
<location filename="fileviewdialog.cpp" line="76"/> <location filename="fileviewdialog.cpp" line="66"/>
<source>Cppcheck</source> <source>Cppcheck</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="fileviewdialog.cpp" line="72"/> <location filename="fileviewdialog.cpp" line="62"/>
<source>Could not read the file: %1</source> <source>Could not read the file: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -312,6 +307,16 @@ kate -l(line) (file)</source>
Stop the checking before exiting.</source> Stop the checking before exiting.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="mainwindow.cpp" line="492"/>
<source>License</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="499"/>
<source>Authors</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="mainwindow.cpp" line="507"/> <location filename="mainwindow.cpp" line="507"/>
<source>XML files (*.xml);;Text files (*.txt)</source> <source>XML files (*.xml);;Text files (*.txt)</source>

71
gui/file.ui Normal file
View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Fileview</class>
<widget class="QDialog" name="Fileview">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Fileview</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextEdit" name="mText">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="mButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>mButtons</sender>
<signal>accepted()</signal>
<receiver>Fileview</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>mButtons</sender>
<signal>rejected()</signal>
<receiver>Fileview</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -26,27 +26,17 @@
#include <QMessageBox> #include <QMessageBox>
#include "fileviewdialog.h" #include "fileviewdialog.h"
FileViewDialog::FileViewDialog(const QString &file, QWidget *parent) FileViewDialog::FileViewDialog(const QString &file,
const QString &title,
QWidget *parent)
: QDialog(parent) : QDialog(parent)
{ {
QString title = FormatTitle(file); mUI.setupUi(this);
setWindowTitle(title); setWindowTitle(title);
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
QVBoxLayout *mainLayout = new QVBoxLayout(); LoadTextFile(file, mUI.mText);
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);
} }
void FileViewDialog::LoadTextFile(const QString &filename, QTextEdit *edit) void FileViewDialog::LoadTextFile(const QString &filename, QTextEdit *edit)
@ -86,13 +76,3 @@ void FileViewDialog::LoadTextFile(const QString &filename, QTextEdit *edit)
QString filestringdata(filedata); QString filestringdata(filedata);
edit->setPlainText(filestringdata); edit->setPlainText(filestringdata);
} }
QString FileViewDialog::FormatTitle(const QString &filename)
{
QString title(filename);
if (title.startsWith(":"))
{
title.remove(0, 1);
}
return title;
}

View File

@ -21,9 +21,8 @@
#include <QDialog> #include <QDialog>
#include <QString> #include <QString>
#include "ui_file.h"
class QWidget;
class QTextEdit;
/** /**
* @brief File view -dialog. * @brief File view -dialog.
@ -35,7 +34,10 @@ class FileViewDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
FileViewDialog(const QString &file, QWidget *parent = 0); FileViewDialog(const QString &file,
const QString &title,
QWidget *parent = 0);
protected: protected:
@ -53,6 +55,8 @@ protected:
* @param filename File to load. * @param filename File to load.
*/ */
QString FormatTitle(const QString &filename); QString FormatTitle(const QString &filename);
Ui::Fileview mUI;
}; };
#endif // FILEVIEW_DIALOG_H #endif // FILEVIEW_DIALOG_H

View File

@ -15,6 +15,7 @@ FORMS = main.ui \
resultsview.ui \ resultsview.ui \
application.ui \ application.ui \
settings.ui \ settings.ui \
file.ui \
about.ui about.ui
TRANSLATIONS = cppcheck_fi.ts \ TRANSLATIONS = cppcheck_fi.ts \

View File

@ -489,14 +489,14 @@ void MainWindow::About()
void MainWindow::ShowLicense() void MainWindow::ShowLicense()
{ {
FileViewDialog *dlg = new FileViewDialog(":COPYING", this); FileViewDialog *dlg = new FileViewDialog(":COPYING",tr("License"), this);
dlg->resize(550, 400); dlg->resize(570, 400);
dlg->exec(); dlg->exec();
} }
void MainWindow::ShowAuthors() void MainWindow::ShowAuthors()
{ {
FileViewDialog *dlg = new FileViewDialog(":AUTHORS", this); FileViewDialog *dlg = new FileViewDialog(":AUTHORS",tr("Authors"), this);
dlg->resize(350, 400); dlg->resize(350, 400);
dlg->exec(); dlg->exec();
} }