Implement review feedback
This commit is contained in:
@@ -376,7 +376,7 @@ QJsonObject BrowserAction::getErrorReply(const QString& action, const int errorC
|
||||
QJsonObject BrowserAction::buildMessage(const QString& nonce) const
|
||||
{
|
||||
QJsonObject message;
|
||||
message["version"] = KEEPASSX_VERSION;
|
||||
message["version"] = KEEPASSXC_VERSION;
|
||||
message["success"] = "true";
|
||||
message["nonce"] = nonce;
|
||||
return message;
|
||||
|
||||
@@ -76,7 +76,7 @@ int Remove::removeEntry(Database* database, const QString& databasePath, const Q
|
||||
QTextStream out(Utils::STDOUT, QIODevice::WriteOnly);
|
||||
QTextStream err(Utils::STDERR, QIODevice::WriteOnly);
|
||||
|
||||
Entry* entry = database->rootGroup()->findEntryByPath(entryPath);
|
||||
QPointer<Entry> entry = database->rootGroup()->findEntryByPath(entryPath);
|
||||
if (!entry) {
|
||||
err << QObject::tr("Entry %1 not found.").arg(entryPath) << endl;
|
||||
return EXIT_FAILURE;
|
||||
@@ -84,7 +84,8 @@ int Remove::removeEntry(Database* database, const QString& databasePath, const Q
|
||||
|
||||
QString entryTitle = entry->title();
|
||||
bool recycled = true;
|
||||
if (Tools::hasChild(database->metadata()->recycleBin(), entry) || !database->metadata()->recycleBinEnabled()) {
|
||||
auto* recycleBin = database->metadata()->recycleBin();
|
||||
if (!database->metadata()->recycleBinEnabled() || (recycleBin && recycleBin->findEntryByUuid(entry->uuid()))) {
|
||||
delete entry;
|
||||
recycled = false;
|
||||
} else {
|
||||
|
||||
@@ -72,6 +72,8 @@ void setStdinEcho(bool enable = true)
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace Test
|
||||
{
|
||||
QStringList nextPasswords = {};
|
||||
|
||||
/**
|
||||
@@ -85,6 +87,7 @@ void setNextPassword(const QString& password)
|
||||
{
|
||||
nextPasswords.append(password);
|
||||
}
|
||||
} // namespace Test
|
||||
|
||||
/**
|
||||
* Read a user password from STDIN or return a password previously
|
||||
@@ -97,8 +100,8 @@ QString getPassword()
|
||||
QTextStream out(STDOUT, QIODevice::WriteOnly);
|
||||
|
||||
// return preset password if one is set
|
||||
if (!nextPasswords.isEmpty()) {
|
||||
auto password = nextPasswords.takeFirst();
|
||||
if (!Test::nextPasswords.isEmpty()) {
|
||||
auto password = Test::nextPasswords.takeFirst();
|
||||
// simulate user entering newline
|
||||
out << endl;
|
||||
return password;
|
||||
|
||||
@@ -29,8 +29,12 @@ extern FILE* STDIN;
|
||||
|
||||
void setStdinEcho(bool enable);
|
||||
QString getPassword();
|
||||
void setNextPassword(const QString& password);
|
||||
int clipText(const QString& text);
|
||||
|
||||
namespace Test
|
||||
{
|
||||
void setNextPassword(const QString& password);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // KEEPASSXC_UTILS_H
|
||||
|
||||
@@ -40,7 +40,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
QCoreApplication::setApplicationVersion(KEEPASSX_VERSION);
|
||||
QCoreApplication::setApplicationVersion(KEEPASSXC_VERSION);
|
||||
|
||||
#ifdef QT_NO_DEBUG
|
||||
Bootstrap::bootstrapApplication();
|
||||
@@ -72,7 +72,7 @@ int main(int argc, char** argv)
|
||||
if (parser.positionalArguments().empty()) {
|
||||
if (parser.isSet("version")) {
|
||||
// Switch to parser.showVersion() when available (QT 5.4).
|
||||
out << KEEPASSX_VERSION << endl;
|
||||
out << KEEPASSXC_VERSION << endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
parser.showHelp();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef KEEPASSX_CONFIG_KEEPASSX_H
|
||||
#define KEEPASSX_CONFIG_KEEPASSX_H
|
||||
|
||||
#define KEEPASSX_VERSION "@KEEPASSXC_VERSION@"
|
||||
#define KEEPASSXC_VERSION "@KEEPASSXC_VERSION@"
|
||||
|
||||
#define KEEPASSX_SOURCE_DIR "@CMAKE_SOURCE_DIR@"
|
||||
#define KEEPASSX_BINARY_DIR "@CMAKE_BINARY_DIR@"
|
||||
|
||||
@@ -77,21 +77,6 @@ QString humanReadableFileSize(qint64 bytes, quint32 precision)
|
||||
return QString("%1 %2").arg(QLocale().toString(size, 'f', precision), units.at(i));
|
||||
}
|
||||
|
||||
bool hasChild(const QObject* parent, const QObject* child)
|
||||
{
|
||||
if (!parent || !child) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const QObjectList children = parent->children();
|
||||
for (QObject* c : children) {
|
||||
if (child == c || hasChild(c, child)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool readFromDevice(QIODevice* device, QByteArray& data, int size)
|
||||
{
|
||||
QByteArray buffer;
|
||||
|
||||
@@ -31,7 +31,6 @@ class QIODevice;
|
||||
namespace Tools
|
||||
{
|
||||
QString humanReadableFileSize(qint64 bytes, quint32 precision = 2);
|
||||
bool hasChild(const QObject* parent, const QObject* child);
|
||||
bool readFromDevice(QIODevice* device, QByteArray& data, int size = 16384);
|
||||
bool readAllFromDevice(QIODevice* device, QByteArray& data);
|
||||
QString imageReaderFilter();
|
||||
|
||||
@@ -37,7 +37,7 @@ AboutDialog::AboutDialog(QWidget* parent)
|
||||
setWindowFlags(Qt::Sheet);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
m_ui->nameLabel->setText(m_ui->nameLabel->text().replace("${VERSION}", KEEPASSX_VERSION));
|
||||
m_ui->nameLabel->setText(m_ui->nameLabel->text().replace("${VERSION}", KEEPASSXC_VERSION));
|
||||
QFont nameLabelFont = m_ui->nameLabel->font();
|
||||
nameLabelFont.setPointSize(nameLabelFont.pointSize() + 4);
|
||||
m_ui->nameLabel->setFont(nameLabelFont);
|
||||
@@ -52,7 +52,7 @@ AboutDialog::AboutDialog(QWidget* parent)
|
||||
}
|
||||
|
||||
QString debugInfo = "KeePassXC - ";
|
||||
debugInfo.append(tr("Version %1").arg(KEEPASSX_VERSION).append("\n"));
|
||||
debugInfo.append(tr("Version %1").arg(KEEPASSXC_VERSION).append("\n"));
|
||||
#ifndef KEEPASSXC_BUILD_TYPE_RELEASE
|
||||
debugInfo.append(tr("Build Type: %1").arg(KEEPASSXC_BUILD_TYPE).append("\n"));
|
||||
#endif
|
||||
|
||||
@@ -460,7 +460,8 @@ void DatabaseWidget::deleteEntries()
|
||||
selectedEntries.append(m_entryView->entryFromIndex(index));
|
||||
}
|
||||
|
||||
bool inRecycleBin = Tools::hasChild(m_db->metadata()->recycleBin(), selectedEntries.first());
|
||||
auto* recycleBin = m_db->metadata()->recycleBin();
|
||||
bool inRecycleBin = recycleBin && recycleBin->findEntryByUuid(selectedEntries.first()->uuid());
|
||||
if (inRecycleBin || !m_db->metadata()->recycleBinEnabled()) {
|
||||
QString prompt;
|
||||
if (selected.size() == 1) {
|
||||
@@ -688,9 +689,10 @@ void DatabaseWidget::deleteGroup()
|
||||
return;
|
||||
}
|
||||
|
||||
bool inRecycleBin = Tools::hasChild(m_db->metadata()->recycleBin(), currentGroup);
|
||||
auto* recycleBin = m_db->metadata()->recycleBin();
|
||||
bool inRecycleBin = recycleBin && recycleBin->findGroupByUuid(currentGroup->uuid());
|
||||
bool isRecycleBin = (currentGroup == m_db->metadata()->recycleBin());
|
||||
bool isRecycleBinSubgroup = Tools::hasChild(currentGroup, m_db->metadata()->recycleBin());
|
||||
bool isRecycleBinSubgroup = currentGroup->findGroupByUuid(m_db->metadata()->recycleBin()->uuid());
|
||||
if (inRecycleBin || isRecycleBin || isRecycleBinSubgroup || !m_db->metadata()->recycleBinEnabled()) {
|
||||
QMessageBox::StandardButton result = MessageBox::question(
|
||||
this,
|
||||
|
||||
@@ -29,7 +29,7 @@ WelcomeWidget::WelcomeWidget(QWidget* parent)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->welcomeLabel->setText(tr("Welcome to KeePassXC %1").arg(KEEPASSX_VERSION));
|
||||
m_ui->welcomeLabel->setText(tr("Welcome to KeePassXC %1").arg(KEEPASSXC_VERSION));
|
||||
QFont welcomeLabelFont = m_ui->welcomeLabel->font();
|
||||
welcomeLabelFont.setBold(true);
|
||||
welcomeLabelFont.setPointSize(welcomeLabelFont.pointSize() + 4);
|
||||
|
||||
@@ -234,11 +234,11 @@ bool GroupModel::dropMimeData(const QMimeData* data,
|
||||
}
|
||||
|
||||
Group* dragGroup = db->resolveGroup(groupUuid);
|
||||
if (!dragGroup || !Tools::hasChild(db, dragGroup) || dragGroup == db->rootGroup()) {
|
||||
if (!dragGroup || !db->rootGroup()->findGroupByUuid(dragGroup->uuid()) || dragGroup == db->rootGroup()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dragGroup == parentGroup || Tools::hasChild(dragGroup, parentGroup)) {
|
||||
if (dragGroup == parentGroup || dragGroup->findGroupByUuid(parentGroup->uuid())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ bool GroupModel::dropMimeData(const QMimeData* data,
|
||||
}
|
||||
|
||||
Entry* dragEntry = db->resolveEntry(entryUuid);
|
||||
if (!dragEntry || !Tools::hasChild(db, dragEntry)) {
|
||||
if (!dragEntry || !db->rootGroup()->findEntryByUuid(dragEntry->uuid())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ int main(int argc, char** argv)
|
||||
{
|
||||
Application app(argc, argv);
|
||||
Application::setApplicationName("keepassxc");
|
||||
Application::setApplicationVersion(KEEPASSX_VERSION);
|
||||
Application::setApplicationVersion(KEEPASSXC_VERSION);
|
||||
// don't set organizationName as that changes the return value of
|
||||
// QStandardPaths::writableLocation(QDesktopServices::DataLocation)
|
||||
Bootstrap::bootstrapApplication();
|
||||
|
||||
Reference in New Issue
Block a user