mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
Code Style Update
- Everything is beautiful now
This commit is contained in:
@@ -7,8 +7,7 @@
|
|||||||
#include "Layer/PaintingArea.h"
|
#include "Layer/PaintingArea.h"
|
||||||
|
|
||||||
// IntelliPhotoGui constructor
|
// IntelliPhotoGui constructor
|
||||||
IntelliPhotoGui::IntelliPhotoGui()
|
IntelliPhotoGui::IntelliPhotoGui(){
|
||||||
{
|
|
||||||
//create Gui elements and lay them out
|
//create Gui elements and lay them out
|
||||||
createGui();
|
createGui();
|
||||||
// Create actions
|
// Create actions
|
||||||
@@ -22,10 +21,8 @@ IntelliPhotoGui::IntelliPhotoGui()
|
|||||||
showMaximized();
|
showMaximized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// User tried to close the app
|
// User tried to close the app
|
||||||
void IntelliPhotoGui::closeEvent(QCloseEvent *event)
|
void IntelliPhotoGui::closeEvent(QCloseEvent *event){
|
||||||
{
|
|
||||||
// If they try to close maybeSave() returns true
|
// If they try to close maybeSave() returns true
|
||||||
// if no changes have been made and the app closes
|
// if no changes have been made and the app closes
|
||||||
if (maybeSave()) {
|
if (maybeSave()) {
|
||||||
@@ -39,8 +36,7 @@ void IntelliPhotoGui::closeEvent(QCloseEvent *event)
|
|||||||
|
|
||||||
// Check if the current image has been changed and then
|
// Check if the current image has been changed and then
|
||||||
// open a dialog to open a file
|
// open a dialog to open a file
|
||||||
void IntelliPhotoGui::slotOpen()
|
void IntelliPhotoGui::slotOpen(){
|
||||||
{
|
|
||||||
// Check if changes have been made since last save
|
// Check if changes have been made since last save
|
||||||
// maybeSave() returns true if no changes have been made
|
// maybeSave() returns true if no changes have been made
|
||||||
if (maybeSave()) {
|
if (maybeSave()) {
|
||||||
@@ -59,8 +55,7 @@ void IntelliPhotoGui::slotOpen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Called when the user clicks Save As in the menu
|
// Called when the user clicks Save As in the menu
|
||||||
void IntelliPhotoGui::slotSave()
|
void IntelliPhotoGui::slotSave(){
|
||||||
{
|
|
||||||
// A QAction represents the action of the user clicking
|
// A QAction represents the action of the user clicking
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
QAction *action = qobject_cast<QAction *>(sender());
|
||||||
|
|
||||||
@@ -72,8 +67,7 @@ void IntelliPhotoGui::slotSave()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Opens a dialog that allows the user to create a New Layer
|
// Opens a dialog that allows the user to create a New Layer
|
||||||
void IntelliPhotoGui::slotCreateNewLayer()
|
void IntelliPhotoGui::slotCreateNewLayer(){
|
||||||
{
|
|
||||||
// Stores button value
|
// Stores button value
|
||||||
bool ok1, ok2;
|
bool ok1, ok2;
|
||||||
|
|
||||||
@@ -95,8 +89,7 @@ void IntelliPhotoGui::slotCreateNewLayer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Opens a dialog that allows the user to delete a Layer
|
// Opens a dialog that allows the user to delete a Layer
|
||||||
void IntelliPhotoGui::slotDeleteLayer()
|
void IntelliPhotoGui::slotDeleteLayer(){
|
||||||
{
|
|
||||||
// Stores button value
|
// Stores button value
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
@@ -119,7 +112,6 @@ void slotCreateFloodFillTool(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IntelliPhotoGui::slotSetActiveAlpha(){
|
void IntelliPhotoGui::slotSetActiveAlpha(){
|
||||||
// Stores button value
|
// Stores button value
|
||||||
bool ok1, ok2;
|
bool ok1, ok2;
|
||||||
@@ -239,18 +231,14 @@ void IntelliPhotoGui::slotCreateLineTool(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open an about dialog
|
// Open an about dialog
|
||||||
void IntelliPhotoGui::slotAboutDialog()
|
void IntelliPhotoGui::slotAboutDialog(){
|
||||||
{
|
|
||||||
// Window title and text to display
|
// Window title and text to display
|
||||||
QMessageBox::about(this, tr("About Painting"),
|
QMessageBox::about(this, tr("About Painting"),
|
||||||
tr("<p><b>IntelliPhoto</b> Some nice ass looking software</p>"));
|
tr("<p><b>IntelliPhoto</b> Some nice ass looking software</p>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define menu actions that call functions
|
// Define menu actions that call functions
|
||||||
void IntelliPhotoGui::createActions()
|
void IntelliPhotoGui::createActions(){
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
// Get a list of the supported file formats
|
// Get a list of the supported file formats
|
||||||
// QImageWriter is used to write images to files
|
// QImageWriter is used to write images to files
|
||||||
foreach (QByteArray format, QImageWriter::supportedImageFormats()) {
|
foreach (QByteArray format, QImageWriter::supportedImageFormats()) {
|
||||||
@@ -277,8 +265,6 @@ void IntelliPhotoGui::createActions()
|
|||||||
// Attach each PNG in save Menu
|
// Attach each PNG in save Menu
|
||||||
actionSaveAs.append(pngSaveAction);
|
actionSaveAs.append(pngSaveAction);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create exit action and tie to IntelliPhotoGui::close()
|
// Create exit action and tie to IntelliPhotoGui::close()
|
||||||
actionExit = new QAction(tr("&Exit"), this);
|
actionExit = new QAction(tr("&Exit"), this);
|
||||||
actionExit->setShortcuts(QKeySequence::Quit);
|
actionExit->setShortcuts(QKeySequence::Quit);
|
||||||
@@ -357,8 +343,7 @@ void IntelliPhotoGui::createActions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the menubar
|
// Create the menubar
|
||||||
void IntelliPhotoGui::createMenus()
|
void IntelliPhotoGui::createMenus(){
|
||||||
{
|
|
||||||
// Create Save As option and the list of file types
|
// Create Save As option and the list of file types
|
||||||
saveAsMenu = new QMenu(tr("&Save As"), this);
|
saveAsMenu = new QMenu(tr("&Save As"), this);
|
||||||
foreach (QAction *action, actionSaveAs)
|
foreach (QAction *action, actionSaveAs)
|
||||||
@@ -440,8 +425,7 @@ void IntelliPhotoGui::setIntelliStyle(){
|
|||||||
this->menuBar()->setStyleSheet("color:rgb(255,255,255)");
|
this->menuBar()->setStyleSheet("color:rgb(255,255,255)");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntelliPhotoGui::maybeSave()
|
bool IntelliPhotoGui::maybeSave(){
|
||||||
{
|
|
||||||
// Check for changes since last save
|
// Check for changes since last save
|
||||||
|
|
||||||
//TODO insert variable for modified status here to make an save exit message
|
//TODO insert variable for modified status here to make an save exit message
|
||||||
@@ -468,8 +452,7 @@ bool IntelliPhotoGui::maybeSave()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat)
|
bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat){
|
||||||
{
|
|
||||||
// Define path, name and default file type
|
// Define path, name and default file type
|
||||||
QString initialPath = QDir::currentPath() + "/untitled." + fileFormat;
|
QString initialPath = QDir::currentPath() + "/untitled." + fileFormat;
|
||||||
|
|
||||||
@@ -485,9 +468,7 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat)
|
|||||||
if (fileName.isEmpty()) {
|
if (fileName.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Call for the file to be saved
|
// Call for the file to be saved
|
||||||
return paintingArea->save(fileName, fileFormat.constData());
|
return paintingArea->save(fileName, fileFormat.constData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ class IntelliTool;
|
|||||||
|
|
||||||
class IntelliColorPicker;
|
class IntelliColorPicker;
|
||||||
|
|
||||||
class IntelliPhotoGui : public QMainWindow
|
class IntelliPhotoGui : public QMainWindow{
|
||||||
{
|
|
||||||
// Declares our class as a QObject which is the base class
|
// Declares our class as a QObject which is the base class
|
||||||
// for all Qt objects
|
// for all Qt objects
|
||||||
// QObjects handle events
|
// QObjects handle events
|
||||||
|
|||||||
@@ -1,4 +1,2 @@
|
|||||||
#include"IntelliHelper.h"
|
#include"IntelliHelper.h"
|
||||||
#include<algorithm>
|
#include<algorithm>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ public:
|
|||||||
return (p1.x()-p3.x())*(p2.y()-p3.y())-(p2.x()-p3.x())*(p1.y()-p3.y());
|
return (p1.x()-p3.x())*(p2.y()-p3.y())-(p2.x()-p3.x())*(p1.y()-p3.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline bool isInTriangle(QPoint& A, QPoint& B, QPoint& C, QPoint& P){
|
static inline bool isInTriangle(QPoint& A, QPoint& B, QPoint& C, QPoint& P){
|
||||||
float val1, val2, val3;
|
float val1, val2, val3;
|
||||||
bool neg, pos;
|
bool neg, pos;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include "Tool/IntelliToolPlain.h"
|
#include "Tool/IntelliToolPlain.h"
|
||||||
#include "Tool/IntelliToolLine.h"
|
#include "Tool/IntelliToolLine.h"
|
||||||
|
|
||||||
|
|
||||||
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
||||||
:QWidget(parent){
|
:QWidget(parent){
|
||||||
this->Tool = nullptr;
|
this->Tool = nullptr;
|
||||||
@@ -40,7 +39,6 @@ PaintingArea::~PaintingArea(){
|
|||||||
delete Tool;
|
delete Tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PaintingArea::setUp(int maxWidth, int maxHeight){
|
void PaintingArea::setUp(int maxWidth, int maxHeight){
|
||||||
//set standart parameter
|
//set standart parameter
|
||||||
this->maxWidth = maxWidth;
|
this->maxWidth = maxWidth;
|
||||||
@@ -85,7 +83,7 @@ void PaintingArea::slotDeleteActiveLayer(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintingArea::setLayerToActive(int index) {
|
void PaintingArea::setLayerToActive(int index){
|
||||||
if(index>=0&&index<static_cast<int>(layerBundle.size())){
|
if(index>=0&&index<static_cast<int>(layerBundle.size())){
|
||||||
this->activeLayer=index;
|
this->activeLayer=index;
|
||||||
}
|
}
|
||||||
@@ -97,10 +95,8 @@ void PaintingArea::setAlphaOfLayer(int index, int alpha){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Used to load the image and place it in the widget
|
// Used to load the image and place it in the widget
|
||||||
bool PaintingArea::open(const QString &fileName)
|
bool PaintingArea::open(const QString &fileName){
|
||||||
{
|
|
||||||
if(this->activeLayer==-1){
|
if(this->activeLayer==-1){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -112,8 +108,7 @@ bool PaintingArea::open(const QString &fileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save the current image
|
// Save the current image
|
||||||
bool PaintingArea::save(const QString &fileName, const char *fileFormat)
|
bool PaintingArea::save(const QString &fileName, const char *fileFormat){
|
||||||
{
|
|
||||||
if(layerBundle.size()==0){
|
if(layerBundle.size()==0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -136,7 +131,6 @@ bool PaintingArea::save(const QString &fileName, const char *fileFormat)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Color the image area with white
|
// Color the image area with white
|
||||||
void PaintingArea::floodFill(int r, int g, int b, int a){
|
void PaintingArea::floodFill(int r, int g, int b, int a){
|
||||||
if(this->activeLayer==-1){
|
if(this->activeLayer==-1){
|
||||||
@@ -198,8 +192,7 @@ void PaintingArea::createLineTool(){
|
|||||||
// If a mouse button is pressed check if it was the
|
// If a mouse button is pressed check if it was the
|
||||||
// left button and if so store the current position
|
// left button and if so store the current position
|
||||||
// Set that we are currently drawing
|
// Set that we are currently drawing
|
||||||
void PaintingArea::mousePressEvent(QMouseEvent *event)
|
void PaintingArea::mousePressEvent(QMouseEvent *event){
|
||||||
{
|
|
||||||
if(Tool == nullptr)
|
if(Tool == nullptr)
|
||||||
return;
|
return;
|
||||||
int x = event->x()-layerBundle[activeLayer].widthOffset;
|
int x = event->x()-layerBundle[activeLayer].widthOffset;
|
||||||
@@ -212,12 +205,10 @@ void PaintingArea::mousePressEvent(QMouseEvent *event)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// When the mouse moves if the left button is clicked
|
// When the mouse moves if the left button is clicked
|
||||||
// we call the drawline function which draws a line
|
// we call the drawline function which draws a line
|
||||||
// from the last position to the current
|
// from the last position to the current
|
||||||
void PaintingArea::mouseMoveEvent(QMouseEvent *event)
|
void PaintingArea::mouseMoveEvent(QMouseEvent *event){
|
||||||
{
|
|
||||||
if(Tool == nullptr)
|
if(Tool == nullptr)
|
||||||
return;
|
return;
|
||||||
int x = event->x()-layerBundle[activeLayer].widthOffset;
|
int x = event->x()-layerBundle[activeLayer].widthOffset;
|
||||||
@@ -227,8 +218,7 @@ void PaintingArea::mouseMoveEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the button is released we set variables to stop drawing
|
// If the button is released we set variables to stop drawing
|
||||||
void PaintingArea::mouseReleaseEvent(QMouseEvent *event)
|
void PaintingArea::mouseReleaseEvent(QMouseEvent *event){
|
||||||
{
|
|
||||||
if(Tool == nullptr)
|
if(Tool == nullptr)
|
||||||
return;
|
return;
|
||||||
int x = event->x()-layerBundle[activeLayer].widthOffset;
|
int x = event->x()-layerBundle[activeLayer].widthOffset;
|
||||||
@@ -244,8 +234,7 @@ void PaintingArea::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
// QPainter provides functions to draw on the widget
|
// QPainter provides functions to draw on the widget
|
||||||
// The QPaintEvent is sent to widgets that need to
|
// The QPaintEvent is sent to widgets that need to
|
||||||
// update themselves
|
// update themselves
|
||||||
void PaintingArea::paintEvent(QPaintEvent *event)
|
void PaintingArea::paintEvent(QPaintEvent *event){
|
||||||
{
|
|
||||||
this->assembleLayers();
|
this->assembleLayers();
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
@@ -256,13 +245,11 @@ void PaintingArea::paintEvent(QPaintEvent *event)
|
|||||||
|
|
||||||
// Resize the image to slightly larger then the main window
|
// Resize the image to slightly larger then the main window
|
||||||
// to cut down on the need to resize the image
|
// to cut down on the need to resize the image
|
||||||
void PaintingArea::resizeEvent(QResizeEvent *event)
|
void PaintingArea::resizeEvent(QResizeEvent *event){
|
||||||
{
|
|
||||||
//TODO wait till tool works
|
//TODO wait till tool works
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PaintingArea::resizeImage(QImage *image_res, const QSize &newSize){
|
void PaintingArea::resizeImage(QImage *image_res, const QSize &newSize){
|
||||||
//TODO implement
|
//TODO implement
|
||||||
}
|
}
|
||||||
@@ -281,7 +268,6 @@ void PaintingArea::activateLowerLayer(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PaintingArea::assembleLayers(bool forSaving){
|
void PaintingArea::assembleLayers(bool forSaving){
|
||||||
if(forSaving){
|
if(forSaving){
|
||||||
Canvas->fill(Qt::GlobalColor::transparent);
|
Canvas->fill(Qt::GlobalColor::transparent);
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ enum class LineStyle{
|
|||||||
DOTTED_LINE
|
DOTTED_LINE
|
||||||
};
|
};
|
||||||
|
|
||||||
class IntelliToolLine : public IntelliTool
|
class IntelliToolLine : public IntelliTool{
|
||||||
{
|
|
||||||
QPoint start;
|
QPoint start;
|
||||||
int lineWidth;
|
int lineWidth;
|
||||||
LineStyle lineStyle;
|
LineStyle lineStyle;
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
#include "IntelliTool.h"
|
#include "IntelliTool.h"
|
||||||
#include "QColor"
|
#include "QColor"
|
||||||
|
|
||||||
class IntelliToolPlainTool : public IntelliTool
|
class IntelliToolPlainTool : public IntelliTool{
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
IntelliToolPlainTool(PaintingArea *Area, IntelliColorPicker* colorPicker);
|
IntelliToolPlainTool(PaintingArea *Area, IntelliColorPicker* colorPicker);
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]){
|
||||||
{
|
|
||||||
// The main application
|
// The main application
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
@@ -14,7 +13,3 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user