Switched the method of how the Designer UI file is used in the LogView class to "The Single Inheritance Approach" (with "Using a Pointer Member Variable"). This is the method which Qt recommends for large projects.
This commit is contained in:
parent
4a8dd85d7e
commit
21e1fd7945
@ -30,7 +30,7 @@
|
|||||||
#define VER_LAMEXP_MINOR_LO 7
|
#define VER_LAMEXP_MINOR_LO 7
|
||||||
#define VER_LAMEXP_TYPE Alpha
|
#define VER_LAMEXP_TYPE Alpha
|
||||||
#define VER_LAMEXP_PATCH 7
|
#define VER_LAMEXP_PATCH 7
|
||||||
#define VER_LAMEXP_BUILD 1223
|
#define VER_LAMEXP_BUILD 1224
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Tool versions (minimum expected versions!)
|
// Tool versions (minimum expected versions!)
|
||||||
|
@ -21,29 +21,38 @@
|
|||||||
|
|
||||||
#include "Dialog_LogView.h"
|
#include "Dialog_LogView.h"
|
||||||
|
|
||||||
|
//UIC includes
|
||||||
|
#include "../tmp/UIC_LogViewDialog.h"
|
||||||
|
|
||||||
|
//Internal
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
|
//Qt includes
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
LogViewDialog::LogViewDialog(QWidget *parent)
|
LogViewDialog::LogViewDialog(QWidget *parent)
|
||||||
:
|
:
|
||||||
QDialog(parent)
|
QDialog(parent),
|
||||||
|
m_acceptIcon(new QIcon(":/icons/accept.png")),
|
||||||
|
m_oldIcon(new QIcon()),
|
||||||
|
ui(new Ui::LogViewDialog)
|
||||||
{
|
{
|
||||||
//Init the dialog, from the .ui file
|
//Init the dialog, from the .ui file
|
||||||
setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
|
||||||
|
|
||||||
//Translate
|
//Translate
|
||||||
headerText->setText(QString("<b>%1</b><br>%2").arg(tr("Log File"), tr("The log file shows detailed information about the selected job.")));
|
ui->headerText->setText(QString("<b>%1</b><br>%2").arg(tr("Log File"), tr("The log file shows detailed information about the selected job.")));
|
||||||
|
|
||||||
//Clear
|
//Clear
|
||||||
textEdit->clear();
|
ui->textEdit->clear();
|
||||||
|
|
||||||
//Enable buttons
|
//Enable buttons
|
||||||
connect(buttonCopy, SIGNAL(clicked()), this, SLOT(copyButtonClicked()));
|
connect(ui->buttonCopy, SIGNAL(clicked()), this, SLOT(copyButtonClicked()));
|
||||||
connect(buttonSave, SIGNAL(clicked()), this, SLOT(saveButtonClicked()));
|
connect(ui->buttonSave, SIGNAL(clicked()), this, SLOT(saveButtonClicked()));
|
||||||
|
|
||||||
//Init flags
|
//Init flags
|
||||||
m_clipboardUsed = false;
|
m_clipboardUsed = false;
|
||||||
@ -55,20 +64,28 @@ LogViewDialog::~LogViewDialog(void)
|
|||||||
{
|
{
|
||||||
QApplication::clipboard()->clear();
|
QApplication::clipboard()->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LAMEXP_DELETE(m_oldIcon);
|
||||||
|
LAMEXP_DELETE(m_acceptIcon);
|
||||||
|
LAMEXP_DELETE(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
int LogViewDialog::exec(const QStringList &logData)
|
int LogViewDialog::exec(const QStringList &logData)
|
||||||
{
|
{
|
||||||
textEdit->setPlainText(logData.join("\n"));
|
ui->textEdit->setPlainText(logData.join("\n"));
|
||||||
return QDialog::exec();
|
return QDialog::exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogViewDialog::copyButtonClicked(void)
|
void LogViewDialog::copyButtonClicked(void)
|
||||||
{
|
{
|
||||||
QMimeData *mime = new QMimeData();
|
QMimeData *mime = new QMimeData();
|
||||||
mime->setData("text/plain", textEdit->toPlainText().toUtf8().constData());
|
mime->setData("text/plain", ui->textEdit->toPlainText().toUtf8().constData());
|
||||||
QApplication::clipboard()->setMimeData(mime);
|
QApplication::clipboard()->setMimeData(mime);
|
||||||
m_clipboardUsed = true;
|
m_clipboardUsed = true;
|
||||||
|
m_oldIcon->swap(ui->buttonCopy->icon());
|
||||||
|
ui->buttonCopy->setIcon(*m_acceptIcon);
|
||||||
|
ui->buttonCopy->blockSignals(true);
|
||||||
|
QTimer::singleShot(1250, this, SLOT(restoreIcon()));
|
||||||
MessageBeep(MB_ICONINFORMATION);
|
MessageBeep(MB_ICONINFORMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,10 +98,20 @@ void LogViewDialog::saveButtonClicked(void)
|
|||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if(file.open(QIODevice::WriteOnly))
|
if(file.open(QIODevice::WriteOnly))
|
||||||
{
|
{
|
||||||
QByteArray data = textEdit->toPlainText().toUtf8();
|
QByteArray data = ui->textEdit->toPlainText().toUtf8();
|
||||||
data.replace("\n", "\r\n");
|
data.replace("\n", "\r\n");
|
||||||
file.write(data.constData(), data.size());
|
file.write(data.constData(), data.size());
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogViewDialog::restoreIcon(void)
|
||||||
|
{
|
||||||
|
if(!m_oldIcon->isNull())
|
||||||
|
{
|
||||||
|
ui->buttonCopy->setIcon(*m_oldIcon);
|
||||||
|
ui->buttonCopy->blockSignals(false);
|
||||||
|
m_oldIcon->swap(QIcon());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -21,11 +21,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "..\tmp\UIC_LogViewDialog.h"
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
class LogViewDialog : public QDialog, private Ui::LogViewDialog
|
//Class declarations
|
||||||
|
class QIcon;
|
||||||
|
|
||||||
|
//UIC forward declartion
|
||||||
|
namespace Ui {
|
||||||
|
class LogViewDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class LogViewDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -39,6 +45,13 @@ public slots:
|
|||||||
void copyButtonClicked(void);
|
void copyButtonClicked(void);
|
||||||
void saveButtonClicked(void);
|
void saveButtonClicked(void);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void restoreIcon(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Ui::LogViewDialog *ui; //for Qt UIC
|
||||||
|
|
||||||
bool m_clipboardUsed;
|
bool m_clipboardUsed;
|
||||||
|
const QIcon *m_acceptIcon;
|
||||||
|
QIcon *m_oldIcon;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user