Skip to content

Commit

Permalink
v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Alsweider committed Dec 14, 2023
1 parent b77251c commit 35fcea0
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 29 deletions.
47 changes: 32 additions & 15 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ MainWindow::MainWindow(QWidget *parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);

textLaden();
bildLaden();

}

MainWindow::~MainWindow()
Expand All @@ -15,19 +19,8 @@ MainWindow::~MainWindow()

void MainWindow::on_pushButton_clicked()
{
ui->lineEdit->setText(getDesktopBackgroundFileName());

//Wenn der Pfad im Feld ist, aktiviere Knöpfe zum Kopieren und Öffnen
if (ui->lineEdit->text() != ""){
ui->pushButton_2->setEnabled(true);
ui->pushButton_3->setEnabled(true);
}

//Bild laden
desktopBackground.load(getDesktopBackgroundFileName());
desktopBackground = desktopBackground.scaled(200, 200, Qt::KeepAspectRatio);

ui->labelImage->setPixmap(desktopBackground);
textLaden();
bildLaden();
}

QString MainWindow::getDesktopBackgroundFileName() {
Expand Down Expand Up @@ -56,7 +49,7 @@ QString MainWindow::getDesktopBackgroundFileName() {

QString MainWindow::cleanUpPath(const QString &path) {
//Nur erlaubte Zeichen beibehalten (A-Z, a-z, 0-9, \, :, ., -)
QString allowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜẞabcdefghijklmnopqrstuvwxyzäöüß0123456789\\:.-/_, ";
QString allowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZÄÅÁÀÂÇÈÉÊËÎÏÔŒÖÙÛÜẞÐÍÓÚÝŸÞÆØabcdefghijklmnopqrstuvwxyzäáàâåöüßçðéèêëíîïóôœúùûýÿþæø0123456789\\:.-/_, ";

QString cleanedPath;
for (const QChar &ch : path) {
Expand All @@ -77,7 +70,10 @@ void MainWindow::on_pushButton_2_clicked()

void MainWindow::on_pushButton_3_clicked()
{
QString imagePath = getDesktopBackgroundFileName();
//QString imagePath = getDesktopBackgroundFileName();

//Nehmen wir lieber den Wert aus dem Label, um Verwirrung zu vermeiden
QString imagePath = ui->lineEdit->text();

//Überprüfen, ob der Dateipfad nicht leer ist
if (!imagePath.isEmpty()) {
Expand All @@ -91,3 +87,24 @@ void MainWindow::on_pushButton_4_clicked()
this->close();
}

//Bild in Anzeigetafel laden
void MainWindow::bildLaden(){
desktopBackground.load(getDesktopBackgroundFileName());
desktopBackground = desktopBackground.scaled(200, 200, Qt::KeepAspectRatio);
ui->pushButton_5->setText("");
ui->pushButton_5->setIcon(QIcon(desktopBackground));
ui->pushButton_5->setIconSize(desktopBackground.size());
}

//Text in Textfeld laden
void MainWindow::textLaden(){

ui->lineEdit->setText(getDesktopBackgroundFileName());

//Wenn der Pfad im Feld ist, aktiviere Knöpfe zum Kopieren und Öffnen
if (ui->lineEdit->text() != ""){
ui->pushButton_2->setEnabled(true);
ui->pushButton_3->setEnabled(true);
}
}

11 changes: 10 additions & 1 deletion mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#include <QPixmap>
#include <QClipboard>
#include <QDesktopServices>

#include <QWidget>
#include <QMouseEvent>



Expand All @@ -28,6 +29,7 @@ class MainWindow : public QMainWindow
QString getDesktopBackgroundFileName();
QString cleanUpPath(const QString&);


private slots:
void on_pushButton_clicked();

Expand All @@ -37,9 +39,16 @@ private slots:

void on_pushButton_4_clicked();




private:
Ui::MainWindow *ui;
QPixmap desktopBackground;
void bildLaden();
void textLaden();



};
#endif // MAINWINDOW_H
37 changes: 24 additions & 13 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>WasfurnBild v0.0.1</string>
<string>WasfurnBild v0.0.2</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
Expand Down Expand Up @@ -46,27 +46,21 @@
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QPushButton" name="pushButton_5">
<property name="minimumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="toolTip">
<string>Zeigt Desktop-Hintergrundbild, sobald Pfad ausgelesen wurde.</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(204, 204, 204);</string>
</property>
<property name="text">
<string/>
<string>Bild</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
Expand Down Expand Up @@ -101,5 +95,22 @@
</widget>
</widget>
<resources/>
<connections/>
<connections>
<connection>
<sender>pushButton_5</sender>
<signal>clicked()</signal>
<receiver>pushButton_3</receiver>
<slot>click()</slot>
<hints>
<hint type="sourcelabel">
<x>108</x>
<y>168</y>
</hint>
<hint type="destinationlabel">
<x>57</x>
<y>287</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0 comments on commit 35fcea0

Please sign in to comment.