parent
52b6872f85
commit
4cf1c980c5
@ -65,7 +65,8 @@ SOURCES += main.cpp\
|
||||
hotkeyinputdialog.cpp \
|
||||
cropeditor/drawing/arrowitem.cpp \
|
||||
uploaders/default/imgursettingsdialog.cpp \
|
||||
uploaders/default/imgplusuploader.cpp
|
||||
uploaders/default/imgplusuploader.cpp \
|
||||
filenamevalidator.cpp
|
||||
|
||||
HEADERS += mainwindow.hpp \
|
||||
cropeditor/cropeditor.hpp \
|
||||
@ -109,7 +110,8 @@ HEADERS += mainwindow.hpp \
|
||||
hotkeyinputdialog.hpp \
|
||||
cropeditor/drawing/arrowitem.hpp \
|
||||
uploaders/default/imgursettingsdialog.hpp \
|
||||
uploaders/default/imgplusuploader.hpp
|
||||
uploaders/default/imgplusuploader.hpp \
|
||||
filenamevalidator.hpp
|
||||
|
||||
CONFIG += link_pkgconfig
|
||||
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
|
||||
#define PLATFORMBACKEND_HPP
|
||||
#include <QtGlobal>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#ifdef Q_OS_MACOS
|
||||
#include <platformspecifics/mac/macbackend.hpp>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#ifdef Q_OS_WIN
|
||||
#include <platformspecifics/u32/u32backend.hpp>
|
||||
#endif
|
||||
#ifdef __unix__
|
||||
#ifdef Q_OS_UNIX
|
||||
#include <platformspecifics/x11/x11backend.hpp>
|
||||
#endif
|
||||
|
||||
|
@ -11,3 +11,7 @@ QPixmap PlatformBackend::getCursor() {
|
||||
pid_t PlatformBackend::pid() {
|
||||
return getpid();
|
||||
}
|
||||
|
||||
bool PlatformBackend::filenameValid(QString name) {
|
||||
return !name.contains('/');
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ public:
|
||||
static PlatformBackend inst;
|
||||
return inst;
|
||||
}
|
||||
bool filenameValid(QString name);
|
||||
};
|
||||
|
||||
#endif // MACBACKEND_HPP
|
||||
|
@ -28,3 +28,7 @@ DWORD PlatformBackend::pid() {
|
||||
WId PlatformBackend::getActiveWID() {
|
||||
return (WId)GetForegroundWindow();
|
||||
}
|
||||
|
||||
bool PlatformBackend::filenamValid(QString name) {
|
||||
return IsValidFileName(name.toLocal8Bit().constData()) == 0;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ public:
|
||||
return inst;
|
||||
}
|
||||
WId getActiveWID();
|
||||
bool filenamValid(QString name);
|
||||
};
|
||||
|
||||
#endif // U32BACKEND_HPP
|
||||
|
@ -54,3 +54,7 @@ WId PlatformBackend::getActiveWID() {
|
||||
delete treeReply;
|
||||
return window;
|
||||
}
|
||||
|
||||
bool PlatformBackend::filenameValid(QString name) {
|
||||
return !name.contains('/');
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ public:
|
||||
return inst;
|
||||
}
|
||||
WId getActiveWID();
|
||||
bool filenameValid(QString name);
|
||||
};
|
||||
|
||||
#endif // X11BACKEND_HPP
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "settingsdialog.hpp"
|
||||
#include "filenamevalidator.hpp"
|
||||
#include "hotkeyinputdialog.hpp"
|
||||
#include "mainwindow.hpp"
|
||||
#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->cropY->setValue(settings::settings().value("cropy", 0).toInt());
|
||||
setWindowTitle("Settings");
|
||||
ui->nameScheme->setValidator(new FilenameValidator(ui->nameScheme));
|
||||
#ifndef PLATFORM_CAPABILITY_CURSOR
|
||||
ui->captureCursor->setEnabled(false);
|
||||
ui->captureCursor->setText("Capture cursor (disabled: implementation missing)");
|
||||
|
Loading…
Reference in New Issue
Block a user