Modify classes to be QObjects
This commit is contained in:
@@ -25,14 +25,18 @@ namespace {
|
||||
const int SEPARATION = 6;
|
||||
}
|
||||
|
||||
ButtonHandler::ButtonHandler(const QVector<Button*> &v) {
|
||||
ButtonHandler::ButtonHandler(const QVector<Button*> &v, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
if (!v.isEmpty()) {
|
||||
m_distance = v[0]->getButtonBaseSize() + SEPARATION;
|
||||
m_vectorButtons = v;
|
||||
}
|
||||
}
|
||||
|
||||
ButtonHandler::ButtonHandler() {
|
||||
ButtonHandler::ButtonHandler(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void ButtonHandler::hide() {
|
||||
|
||||
@@ -20,15 +20,17 @@
|
||||
|
||||
#include "button.h"
|
||||
#include <QVector>
|
||||
#include <QObject>
|
||||
|
||||
class Button;
|
||||
class QRect;
|
||||
class QPoint;
|
||||
|
||||
class ButtonHandler {
|
||||
class ButtonHandler : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ButtonHandler(const QVector<Button*>&);
|
||||
ButtonHandler();
|
||||
ButtonHandler(const QVector<Button*>&, QObject *parent = 0);
|
||||
ButtonHandler(QObject *parent = 0);
|
||||
|
||||
void hide();
|
||||
void show();
|
||||
|
||||
@@ -83,7 +83,7 @@ CaptureWidget::CaptureWidget(QWidget *parent) :
|
||||
setCursor(Qt::CrossCursor);
|
||||
initShortcuts();
|
||||
// create buttons
|
||||
m_buttonHandler = new ButtonHandler();
|
||||
m_buttonHandler = new ButtonHandler(this);
|
||||
redefineButtons();
|
||||
m_buttonHandler->hide();
|
||||
// init screenshot
|
||||
@@ -99,8 +99,7 @@ CaptureWidget::CaptureWidget(QWidget *parent) :
|
||||
}
|
||||
|
||||
CaptureWidget::~CaptureWidget() {
|
||||
delete(m_buttonHandler);
|
||||
delete(m_screenshot);
|
||||
|
||||
}
|
||||
|
||||
// redefineButtons retrieves the buttons configured to be shown with the
|
||||
@@ -530,7 +529,7 @@ void CaptureWidget::createCapture() {
|
||||
close();
|
||||
return;
|
||||
}
|
||||
m_screenshot = new Screenshot(screen->grabWindow(0));
|
||||
m_screenshot = new Screenshot(screen->grabWindow(0), this);
|
||||
}
|
||||
|
||||
void CaptureWidget::initShortcuts() {
|
||||
|
||||
@@ -37,7 +37,10 @@
|
||||
|
||||
Screenshot::Screenshot(const QPixmap &p, QObject *parent) : QObject(parent),
|
||||
m_baseScreenshot(p),
|
||||
m_modifiedScreenshot(p) {}
|
||||
m_modifiedScreenshot(p)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Screenshot::~Screenshot() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user