parent
52b6872f85
commit
4cf1c980c5
@ -65,7 +65,8 @@ SOURCES += main.cpp\
|
|||||||
hotkeyinputdialog.cpp \
|
hotkeyinputdialog.cpp \
|
||||||
cropeditor/drawing/arrowitem.cpp \
|
cropeditor/drawing/arrowitem.cpp \
|
||||||
uploaders/default/imgursettingsdialog.cpp \
|
uploaders/default/imgursettingsdialog.cpp \
|
||||||
uploaders/default/imgplusuploader.cpp
|
uploaders/default/imgplusuploader.cpp \
|
||||||
|
filenamevalidator.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.hpp \
|
HEADERS += mainwindow.hpp \
|
||||||
cropeditor/cropeditor.hpp \
|
cropeditor/cropeditor.hpp \
|
||||||
@ -109,7 +110,8 @@ HEADERS += mainwindow.hpp \
|
|||||||
hotkeyinputdialog.hpp \
|
hotkeyinputdialog.hpp \
|
||||||
cropeditor/drawing/arrowitem.hpp \
|
cropeditor/drawing/arrowitem.hpp \
|
||||||
uploaders/default/imgursettingsdialog.hpp \
|
uploaders/default/imgursettingsdialog.hpp \
|
||||||
uploaders/default/imgplusuploader.hpp
|
uploaders/default/imgplusuploader.hpp \
|
||||||
|
filenamevalidator.hpp
|
||||||
|
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
PKGCONFIG += libavformat libavcodec libswscale libavutil
|
PKGCONFIG += libavformat libavcodec libswscale libavutil
|
||||||
|
12
filenamevalidator.cpp
Normal file
12
filenamevalidator.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "filenamevalidator.hpp"
|
||||||
|
|
||||||
|
#include <formatter.hpp>
|
||||||
|
#include <platformbackend.hpp>
|
||||||
|
|
||||||
|
FilenameValidator::FilenameValidator(QObject *parent) : QValidator(parent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
QValidator::State FilenameValidator::validate(QString &input, int &) const {
|
||||||
|
QString name = formatter::format(input, "lol");
|
||||||
|
return PlatformBackend::inst().filenameValid(name) ? State::Acceptable : State::Invalid;
|
||||||
|
}
|
12
filenamevalidator.hpp
Normal file
12
filenamevalidator.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef FILENAMEVALIDATOR_HPP
|
||||||
|
#define FILENAMEVALIDATOR_HPP
|
||||||
|
|
||||||
|
#include <QValidator>
|
||||||
|
|
||||||
|
class FilenameValidator : public QValidator {
|
||||||
|
public:
|
||||||
|
FilenameValidator(QObject *parent = nullptr);
|
||||||
|
QValidator::State validate(QString &input, int &) const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FILENAMEVALIDATOR_HPP
|
@ -1,13 +1,14 @@
|
|||||||
#ifndef PLATFORMBACKEND_HPP
|
#ifndef PLATFORMBACKEND_HPP
|
||||||
#define PLATFORMBACKEND_HPP
|
#define PLATFORMBACKEND_HPP
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef Q_OS_MACOS
|
||||||
#include <platformspecifics/mac/macbackend.hpp>
|
#include <platformspecifics/mac/macbackend.hpp>
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef Q_OS_WIN
|
||||||
#include <platformspecifics/u32/u32backend.hpp>
|
#include <platformspecifics/u32/u32backend.hpp>
|
||||||
#endif
|
#endif
|
||||||
#ifdef __unix__
|
#ifdef Q_OS_UNIX
|
||||||
#include <platformspecifics/x11/x11backend.hpp>
|
#include <platformspecifics/x11/x11backend.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -11,3 +11,7 @@ QPixmap PlatformBackend::getCursor() {
|
|||||||
pid_t PlatformBackend::pid() {
|
pid_t PlatformBackend::pid() {
|
||||||
return getpid();
|
return getpid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PlatformBackend::filenameValid(QString name) {
|
||||||
|
return !name.contains('/');
|
||||||
|
}
|
||||||
|
@ -13,6 +13,7 @@ public:
|
|||||||
static PlatformBackend inst;
|
static PlatformBackend inst;
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
bool filenameValid(QString name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MACBACKEND_HPP
|
#endif // MACBACKEND_HPP
|
||||||
|
@ -28,3 +28,7 @@ DWORD PlatformBackend::pid() {
|
|||||||
WId PlatformBackend::getActiveWID() {
|
WId PlatformBackend::getActiveWID() {
|
||||||
return (WId)GetForegroundWindow();
|
return (WId)GetForegroundWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PlatformBackend::filenamValid(QString name) {
|
||||||
|
return IsValidFileName(name.toLocal8Bit().constData()) == 0;
|
||||||
|
}
|
||||||
|
@ -17,6 +17,7 @@ public:
|
|||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
WId getActiveWID();
|
WId getActiveWID();
|
||||||
|
bool filenamValid(QString name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // U32BACKEND_HPP
|
#endif // U32BACKEND_HPP
|
||||||
|
@ -54,3 +54,7 @@ WId PlatformBackend::getActiveWID() {
|
|||||||
delete treeReply;
|
delete treeReply;
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PlatformBackend::filenameValid(QString name) {
|
||||||
|
return !name.contains('/');
|
||||||
|
}
|
||||||
|
@ -16,6 +16,7 @@ public:
|
|||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
WId getActiveWID();
|
WId getActiveWID();
|
||||||
|
bool filenameValid(QString name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // X11BACKEND_HPP
|
#endif // X11BACKEND_HPP
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "settingsdialog.hpp"
|
#include "settingsdialog.hpp"
|
||||||
|
#include "filenamevalidator.hpp"
|
||||||
#include "hotkeyinputdialog.hpp"
|
#include "hotkeyinputdialog.hpp"
|
||||||
#include "mainwindow.hpp"
|
#include "mainwindow.hpp"
|
||||||
#include "ui_settingsdialog.h"
|
#include "ui_settingsdialog.h"
|
||||||
@ -77,6 +78,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Se
|
|||||||
ui->cropX->setValue(settings::settings().value("cropx", 0).toInt());
|
ui->cropX->setValue(settings::settings().value("cropx", 0).toInt());
|
||||||
ui->cropY->setValue(settings::settings().value("cropy", 0).toInt());
|
ui->cropY->setValue(settings::settings().value("cropy", 0).toInt());
|
||||||
setWindowTitle("Settings");
|
setWindowTitle("Settings");
|
||||||
|
ui->nameScheme->setValidator(new FilenameValidator(ui->nameScheme));
|
||||||
#ifndef PLATFORM_CAPABILITY_CURSOR
|
#ifndef PLATFORM_CAPABILITY_CURSOR
|
||||||
ui->captureCursor->setEnabled(false);
|
ui->captureCursor->setEnabled(false);
|
||||||
ui->captureCursor->setText("Capture cursor (disabled: implementation missing)");
|
ui->captureCursor->setText("Capture cursor (disabled: implementation missing)");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user