mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-03-13 09:36:42 -04:00
parent
ca68031795
commit
ecf2e2da5a
@ -42,6 +42,11 @@ namespace Utils
|
|||||||
QTextStream STDIN;
|
QTextStream STDIN;
|
||||||
QTextStream DEVNULL;
|
QTextStream DEVNULL;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
UINT origCodePage;
|
||||||
|
UINT origOutputCodePage;
|
||||||
|
#endif
|
||||||
|
|
||||||
void setDefaultTextStreams()
|
void setDefaultTextStreams()
|
||||||
{
|
{
|
||||||
auto fd = new QFile();
|
auto fd = new QFile();
|
||||||
@ -65,6 +70,9 @@ namespace Utils
|
|||||||
DEVNULL.setDevice(fd);
|
DEVNULL.setDevice(fd);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
origCodePage = GetConsoleCP();
|
||||||
|
origOutputCodePage = GetConsoleOutputCP();
|
||||||
|
|
||||||
// On Windows, we ask via keepassxc-cli.exe.manifest to use UTF-8,
|
// On Windows, we ask via keepassxc-cli.exe.manifest to use UTF-8,
|
||||||
// but the console code-page isn't automatically changed to match.
|
// but the console code-page isn't automatically changed to match.
|
||||||
SetConsoleCP(GetACP());
|
SetConsoleCP(GetACP());
|
||||||
@ -72,6 +80,14 @@ namespace Utils
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resetTextStreams()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
SetConsoleCP(origCodePage);
|
||||||
|
SetConsoleOutputCP(origOutputCodePage);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void setStdinEcho(bool enable = true)
|
void setStdinEcho(bool enable = true)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@ -39,6 +39,7 @@ namespace Utils
|
|||||||
static const QStringList EntryFieldNames(QStringList() << UuidFieldName << TagsFieldName);
|
static const QStringList EntryFieldNames(QStringList() << UuidFieldName << TagsFieldName);
|
||||||
|
|
||||||
void setDefaultTextStreams();
|
void setDefaultTextStreams();
|
||||||
|
void resetTextStreams();
|
||||||
|
|
||||||
void setStdinEcho(bool enable);
|
void setStdinEcho(bool enable);
|
||||||
bool loadFileKey(const QString& path, QSharedPointer<FileKey>& fileKey);
|
bool loadFileKey(const QString& path, QSharedPointer<FileKey>& fileKey);
|
||||||
|
@ -181,6 +181,8 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
QCoreApplication::setApplicationVersion(KEEPASSXC_VERSION);
|
QCoreApplication::setApplicationVersion(KEEPASSXC_VERSION);
|
||||||
|
// Cleanup code pages after cli exits
|
||||||
|
QObject::connect(&app, &QCoreApplication::destroyed, &app, [] { Utils::resetTextStreams(); });
|
||||||
|
|
||||||
Bootstrap::bootstrap(config()->get(Config::GUI_Language).toString());
|
Bootstrap::bootstrap(config()->get(Config::GUI_Language).toString());
|
||||||
Utils::setDefaultTextStreams();
|
Utils::setDefaultTextStreams();
|
||||||
@ -218,7 +220,9 @@ int main(int argc, char** argv)
|
|||||||
// Switch to parser.showVersion() when available (QT 5.4).
|
// Switch to parser.showVersion() when available (QT 5.4).
|
||||||
out << KEEPASSXC_VERSION << endl;
|
out << KEEPASSXC_VERSION << endl;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
} else if (parser.isSet(debugInfoOption)) {
|
}
|
||||||
|
|
||||||
|
if (parser.isSet(debugInfoOption)) {
|
||||||
QString debugInfo = Tools::debugInfo().append("\n").append(Crypto::debugInfo());
|
QString debugInfo = Tools::debugInfo().append("\n").append(Crypto::debugInfo());
|
||||||
out << debugInfo << endl;
|
out << debugInfo << endl;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
@ -176,6 +176,8 @@ int main(int argc, char** argv)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils::setDefaultTextStreams();
|
||||||
|
|
||||||
// Apply the configured theme before creating any GUI elements
|
// Apply the configured theme before creating any GUI elements
|
||||||
app.applyTheme();
|
app.applyTheme();
|
||||||
|
|
||||||
@ -196,9 +198,6 @@ int main(int argc, char** argv)
|
|||||||
mainWindow.setAllowScreenCapture(parser.isSet(allowScreenCaptureOption));
|
mainWindow.setAllowScreenCapture(parser.isSet(allowScreenCaptureOption));
|
||||||
|
|
||||||
const bool pwstdin = parser.isSet(pwstdinOption);
|
const bool pwstdin = parser.isSet(pwstdinOption);
|
||||||
if (!fileNames.isEmpty() && pwstdin) {
|
|
||||||
Utils::setDefaultTextStreams();
|
|
||||||
}
|
|
||||||
for (const QString& filename : fileNames) {
|
for (const QString& filename : fileNames) {
|
||||||
QString password;
|
QString password;
|
||||||
if (pwstdin) {
|
if (pwstdin) {
|
||||||
@ -232,5 +231,7 @@ int main(int argc, char** argv)
|
|||||||
__lsan_disable();
|
__lsan_disable();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Utils::resetTextStreams();
|
||||||
|
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user