mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-16 13:20:33 +02:00
All basic features of Qt
This commit is contained in:
@@ -103,3 +103,26 @@ QLabel* LayerManager::getDisplayable(){
|
|||||||
this->imgLabel->setPixmap(aMap);
|
this->imgLabel->setPixmap(aMap);
|
||||||
return imgLabel;
|
return imgLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LayerManager::floodFillLayer(int r, int g, int b){
|
||||||
|
for(size_t i=0; i< static_cast<size_t>(this->getLayerCount()); i++){
|
||||||
|
if(MetaEbenen[i].a==255){
|
||||||
|
Ebenen[i]->floodFill(r,g,b);
|
||||||
|
this->UpdateLabel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerManager::UpdateLabel(){
|
||||||
|
//Tranzparenz der Ebenen muss möglich sein
|
||||||
|
QPixmap aMap;
|
||||||
|
for(size_t i=0; i<static_cast<size_t>(this->getLayerCount()); i++){
|
||||||
|
if(MetaEbenen[i].a==255){
|
||||||
|
aMap = Ebenen[i]->getAsPixmap();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->imgLabel->setPixmap(aMap);
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include<vector>
|
#include<vector>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -34,6 +35,9 @@ private:
|
|||||||
|
|
||||||
//all the meta data parallel to Ebenen Container
|
//all the meta data parallel to Ebenen Container
|
||||||
std::vector<EbenenMetaDaten> MetaEbenen;
|
std::vector<EbenenMetaDaten> MetaEbenen;
|
||||||
|
|
||||||
|
//updates the display
|
||||||
|
void UpdateLabel();
|
||||||
public:
|
public:
|
||||||
LayerManager();
|
LayerManager();
|
||||||
~LayerManager();
|
~LayerManager();
|
||||||
@@ -59,6 +63,9 @@ public:
|
|||||||
//delets a layer at the given index
|
//delets a layer at the given index
|
||||||
void DeleteLayer(int idx);
|
void DeleteLayer(int idx);
|
||||||
|
|
||||||
|
//fill active Layer
|
||||||
|
void floodFillLayer(int r, int g, int b);
|
||||||
|
|
||||||
//returns the output ready label
|
//returns the output ready label
|
||||||
QLabel* getDisplayable();
|
QLabel* getDisplayable();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#include "ui_intelligui.h"
|
#include "ui_intelligui.h"
|
||||||
#include "LayerManager.h"
|
#include "LayerManager.h"
|
||||||
|
|
||||||
|
#include<QDebug>
|
||||||
|
|
||||||
IntelliGUI::IntelliGUI(QWidget *parent)
|
IntelliGUI::IntelliGUI(QWidget *parent)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
ui(new Ui::IntelliGUI){
|
ui(new Ui::IntelliGUI){
|
||||||
@@ -21,13 +23,28 @@ IntelliGUI::IntelliGUI(QWidget *parent)
|
|||||||
|
|
||||||
//setup all gui elements down here
|
//setup all gui elements down here
|
||||||
this->EinKnopf = new QPushButton("Ein Knopf");
|
this->EinKnopf = new QPushButton("Ein Knopf");
|
||||||
|
this->Red = new QLineEdit();
|
||||||
|
this->Blue = new QLineEdit();
|
||||||
|
this->Green = new QLineEdit();
|
||||||
|
|
||||||
|
//Manage signals and slots in here
|
||||||
|
QObject::connect(EinKnopf, SIGNAL(clicked()), this, SLOT(on_EinKnopf_clicked()));
|
||||||
|
|
||||||
//Merge all gui elements to Layout down here
|
//Merge all gui elements to Layout down here
|
||||||
this->Layout->addWidget(this->EinKnopf, 0,10);
|
this->Layout->addWidget(this->EinKnopf, 0,10);
|
||||||
this->Layout->addWidget(this->EbenenManager->getDisplayable(),1,1,10,10);
|
this->Layout->addWidget(this->Red, 1,10);
|
||||||
//this->Layout->addWidget(this->EbenenManager->getDisplayable(),0,0,10,10);
|
this->Layout->addWidget(this->Green, 2,10);
|
||||||
|
this->Layout->addWidget(this->Blue, 3,10);
|
||||||
|
this->Layout->addWidget(this->EbenenManager->getDisplayable(),0,0,10,10);
|
||||||
|
|
||||||
|
|
||||||
|
//set style here
|
||||||
|
this->setStyleSheet("background-color:rgb(60,60,60)");
|
||||||
|
this->EinKnopf->setStyleSheet("color:rgb(250,250,250)");
|
||||||
|
this->Red->setStyleSheet("color:rgb(250,250,250)");
|
||||||
|
this->Green->setStyleSheet("color:rgb(250,250,250)");
|
||||||
|
this->Blue->setStyleSheet("color:rgb(250,250,250)");
|
||||||
|
|
||||||
//Layout is set in here
|
//Layout is set in here
|
||||||
this->setLayout(Layout);
|
this->setLayout(Layout);
|
||||||
}
|
}
|
||||||
@@ -39,6 +56,18 @@ IntelliGUI::~IntelliGUI(){
|
|||||||
delete EbenenManager;
|
delete EbenenManager;
|
||||||
|
|
||||||
//delete all Gui elements down here
|
//delete all Gui elements down here
|
||||||
|
delete EinKnopf;
|
||||||
|
delete Red;
|
||||||
|
delete Blue;
|
||||||
|
delete Green;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void IntelliGUI::on_EinKnopf_clicked(){
|
||||||
|
int redCol = Red->text().toInt();
|
||||||
|
int greCol = Green->text().toInt();
|
||||||
|
int bluCol = Blue->text().toInt();
|
||||||
|
qDebug() << redCol << " " << greCol << " " << bluCol << '\n';
|
||||||
|
EbenenManager->floodFillLayer(redCol, greCol, bluCol);
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <LayerManager.h>
|
#include <LayerManager.h>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class IntelliGUI; }
|
namespace Ui { class IntelliGUI; }
|
||||||
@@ -22,6 +23,9 @@ class IntelliGUI : public QMainWindow
|
|||||||
|
|
||||||
//Declare all Gui elements down here
|
//Declare all Gui elements down here
|
||||||
QPushButton *EinKnopf;
|
QPushButton *EinKnopf;
|
||||||
|
QLineEdit *Red;
|
||||||
|
QLineEdit *Blue;
|
||||||
|
QLineEdit *Green;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::IntelliGUI *ui;
|
Ui::IntelliGUI *ui;
|
||||||
@@ -32,6 +36,7 @@ public:
|
|||||||
//Delets everything in connection to one project
|
//Delets everything in connection to one project
|
||||||
~IntelliGUI();
|
~IntelliGUI();
|
||||||
|
|
||||||
private slots:
|
public slots:
|
||||||
|
void on_EinKnopf_clicked();
|
||||||
};
|
};
|
||||||
#endif // INTELLIGUI_H
|
#endif // INTELLIGUI_H
|
||||||
|
|||||||
@@ -22,3 +22,11 @@ QPixmap Layer::getAsPixmap(){
|
|||||||
return QPixmap::fromImage(*(this->Canvas));
|
return QPixmap::fromImage(*(this->Canvas));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Layer::floodFill(int r, int g, int b){
|
||||||
|
for(int i=0; i<width; i++){
|
||||||
|
for(int j=0; j<height; j++){
|
||||||
|
this->Canvas->setPixelColor(i,j,QColor(r,g,b,255));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ public:
|
|||||||
//load an image to the canvas
|
//load an image to the canvas
|
||||||
void loadImage(const QString& fileName);
|
void loadImage(const QString& fileName);
|
||||||
|
|
||||||
|
//flood fills canvas
|
||||||
|
void floodFill(int r, int g, int b);
|
||||||
|
|
||||||
//return the image as QPixmap
|
//return the image as QPixmap
|
||||||
QPixmap getAsPixmap();
|
QPixmap getAsPixmap();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#include<QDebug>
|
||||||
|
|
||||||
#include "intelligui.h"
|
#include "intelligui.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@@ -7,6 +9,7 @@
|
|||||||
#include<QImage>
|
#include<QImage>
|
||||||
#include<QPixmap>
|
#include<QPixmap>
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication application(argc, argv);
|
QApplication application(argc, argv);
|
||||||
|
|||||||
Reference in New Issue
Block a user