Skip to content

Commit

Permalink
v0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Alsweider authored Dec 14, 2023
1 parent 554bc2c commit 7305bee
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
22 changes: 14 additions & 8 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ MainWindow::MainWindow(QWidget *parent)

textLaden();
bildLaden();

}

MainWindow::~MainWindow()
Expand Down Expand Up @@ -46,7 +45,6 @@ QString MainWindow::getDesktopBackgroundFileName() {
return wallpaperPath;
}


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

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

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

//Überprüfen, ob der Dateipfad nicht leer ist
Expand All @@ -89,22 +85,32 @@ void MainWindow::on_pushButton_4_clicked()

//Bild in Anzeigetafel laden
void MainWindow::bildLaden(){
QSize neueGroesse = ui->pushButton_5->size();
desktopBackground.load(getDesktopBackgroundFileName());
desktopBackground = desktopBackground.scaled(200, 200, Qt::KeepAspectRatio);
desktopBackground = desktopBackground.scaled(neueGroesse, 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);
}
}

void MainWindow::resizeEvent(QResizeEvent *event) {
QSize neueGroesse = ui->pushButton_5->size();
//Lade das Bild aus dem Textfeld
desktopBackground.load(ui->lineEdit->text());
desktopBackground = desktopBackground.scaled(neueGroesse, Qt::KeepAspectRatio);
ui->pushButton_5->setText("");
ui->pushButton_5->setIcon(QIcon(desktopBackground));
ui->pushButton_5->setIconSize(desktopBackground.size());

QMainWindow::resizeEvent(event); //Rufe die Basisimplementierung auf
}
7 changes: 4 additions & 3 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class MainWindow : public QMainWindow
QString cleanUpPath(const QString&);


protected:
void resizeEvent(QResizeEvent *event) override;


private slots:
void on_pushButton_clicked();

Expand All @@ -40,15 +44,12 @@ private slots:
void on_pushButton_4_clicked();




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



};
#endif // MAINWINDOW_H
11 changes: 10 additions & 1 deletion 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.2</string>
<string>WasfurnBild v0.0.3</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
Expand Down Expand Up @@ -47,12 +47,21 @@
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pushButton_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="toolTip">
<string>Klicken um Bild im System-Bildbetrachter zu öffnen.</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(204, 204, 204);</string>
</property>
Expand Down

0 comments on commit 7305bee

Please sign in to comment.