Fix filename validity check
This commit is contained in:
parent
38d8226204
commit
6c5dff0be6
@ -28,8 +28,8 @@ private slots:
|
|||||||
void on_actionSettings_triggered();
|
void on_actionSettings_triggered();
|
||||||
void on_actionColor_Picker_triggered();
|
void on_actionColor_Picker_triggered();
|
||||||
void on_actionAbout_triggered();
|
void on_actionAbout_triggered();
|
||||||
|
|
||||||
void on_actionActive_window_triggered();
|
void on_actionActive_window_triggered();
|
||||||
|
void on_actionAbort_triggered();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static MainWindow *inst();
|
static MainWindow *inst();
|
||||||
|
@ -84,6 +84,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<addaction name="actionStart"/>
|
<addaction name="actionStart"/>
|
||||||
<addaction name="actionStop"/>
|
<addaction name="actionStop"/>
|
||||||
|
<addaction name="actionAbort"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuScreenshot"/>
|
<addaction name="menuScreenshot"/>
|
||||||
@ -136,6 +137,11 @@
|
|||||||
<string>Active window</string>
|
<string>Active window</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionAbort">
|
||||||
|
<property name="text">
|
||||||
|
<string>Abort</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -29,6 +29,17 @@ WId PlatformBackend::getActiveWID() {
|
|||||||
return (WId)GetForegroundWindow();
|
return (WId)GetForegroundWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString illegal(QStringLiteral("<>:\"/\|?*"));
|
||||||
|
QStringList illegalNames({ "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7",
|
||||||
|
"COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" });
|
||||||
|
|
||||||
bool PlatformBackend::filenamValid(QString name) {
|
bool PlatformBackend::filenamValid(QString name) {
|
||||||
return IsValidFileName(name.toLocal8Bit().constData()) == 0;
|
unsigned int periods = 0;
|
||||||
|
for (QChar c : name) {
|
||||||
|
if (c == '.') periods++;
|
||||||
|
if (illegal.contains(c)) return false;
|
||||||
|
if (c < 32) return false;
|
||||||
|
}
|
||||||
|
if (periods == name.length()) return false;
|
||||||
|
return !illegalNames.contains(name);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user