Skip to content

Commit

Permalink
v0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Alsweider authored Dec 22, 2023
1 parent 882308b commit 5379816
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
18 changes: 13 additions & 5 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,28 @@ QString MainWindow::getDesktopBackgroundFileName() {
return wallpaperPath;
}

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

QString cleanedPath;
for (const QChar &ch : path) {
if (allowedChars.contains(ch)) {
cleanedPath.append(ch);
bool foundDriveLetter = false;

for (int i = 0; i < path.length(); ++i) {
QChar ch = path.at(i);
//Abfrage ob Laufwerksbuchstabe gefolgt von Doppelpunkt und Rückstrich gefunden wurde
if (ch.isUpper() && i + 2 < path.length() && path.at(i + 1) == QLatin1Char(':') && path.at(i + 2) == QLatin1Char('\\') && !foundDriveLetter){
foundDriveLetter = true;
cleanedPath.clear();
}

cleanedPath.append(ch);
}

return cleanedPath;
}



void MainWindow::on_pushButton_2_clicked()
{
QClipboard *clipboard = QApplication::clipboard();
Expand Down
1 change: 1 addition & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QWidget>
#include <QMouseEvent>
#include <QTimer>
#include <QImageReader>



Expand Down
2 changes: 1 addition & 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.4</string>
<string>WasfurnBild v0.0.5</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
Expand Down

0 comments on commit 5379816

Please sign in to comment.