mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Allow manual editing of browser extension connection keys
This commit is contained in:
parent
d5de042529
commit
287e822e02
@ -187,6 +187,18 @@ QString BrowserSettings::proxyLocation()
|
||||
return m_nativeMessageInstaller.getProxyPath();
|
||||
}
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
QString BrowserSettings::customExtensionId()
|
||||
{
|
||||
return config()->get(Config::Browser_CustomExtensionId).toString();
|
||||
}
|
||||
|
||||
void BrowserSettings::setCustomExtensionId(const QString& id)
|
||||
{
|
||||
config()->set(Config::Browser_CustomExtensionId, id);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool BrowserSettings::updateBinaryPath()
|
||||
{
|
||||
return config()->get(Config::Browser_UpdateBinaryPath).toBool();
|
||||
|
@ -64,6 +64,10 @@ public:
|
||||
QString customProxyLocation();
|
||||
void setCustomProxyLocation(const QString& location);
|
||||
QString proxyLocation();
|
||||
#ifdef QT_DEBUG
|
||||
QString customExtensionId();
|
||||
void setCustomExtensionId(const QString& id);
|
||||
#endif
|
||||
bool updateBinaryPath();
|
||||
void setUpdateBinaryPath(bool enabled);
|
||||
bool allowExpiredCredentials();
|
||||
|
@ -80,6 +80,11 @@ BrowserSettingsWidget::BrowserSettingsWidget(QWidget* parent)
|
||||
m_ui->firefoxSupport->setText("Firefox and Tor Browser");
|
||||
#endif
|
||||
m_ui->browserGlobalWarningWidget->setVisible(false);
|
||||
|
||||
#ifndef QT_DEBUG
|
||||
m_ui->customExtensionId->setVisible(false);
|
||||
m_ui->customExtensionLabel->setVisible(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
BrowserSettingsWidget::~BrowserSettingsWidget()
|
||||
@ -152,6 +157,10 @@ void BrowserSettingsWidget::loadSettings()
|
||||
m_ui->browserGlobalWarningWidget->setAutoHideTimeout(-1);
|
||||
#endif
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
m_ui->customExtensionId->setText(settings->customExtensionId());
|
||||
#endif
|
||||
|
||||
validateCustomProxyLocation();
|
||||
}
|
||||
|
||||
@ -190,6 +199,10 @@ void BrowserSettingsWidget::saveSettings()
|
||||
settings->setSupportKphFields(m_ui->supportKphFields->isChecked());
|
||||
settings->setNoMigrationPrompt(m_ui->noMigrationPrompt->isChecked());
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
settings->setCustomExtensionId(m_ui->customExtensionId->text());
|
||||
#endif
|
||||
|
||||
settings->setBrowserSupport(BrowserShared::CHROME, m_ui->chromeSupport->isChecked());
|
||||
settings->setBrowserSupport(BrowserShared::CHROMIUM, m_ui->chromiumSupport->isChecked());
|
||||
settings->setBrowserSupport(BrowserShared::FIREFOX, m_ui->firefoxSupport->isChecked());
|
||||
|
@ -378,6 +378,33 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="customExtensionBox">
|
||||
<property name="topMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="customExtensionLabel">
|
||||
<property name="text">
|
||||
<string>Custom extension ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="customExtensionId">
|
||||
<property name="accessibleName">
|
||||
<string>Custom extension ID</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
|
@ -276,6 +276,12 @@ QJsonObject NativeMessageInstaller::constructFile(SupportedBrowsers browser)
|
||||
for (const QString& origin : ALLOWED_ORIGINS) {
|
||||
arr.append(origin);
|
||||
}
|
||||
#ifdef QT_DEBUG
|
||||
auto customId = browserSettings()->customExtensionId();
|
||||
if (!customId.isEmpty()) {
|
||||
arr.append(QString("chrome-extension://%1/").arg(customId));
|
||||
}
|
||||
#endif
|
||||
script["allowed_origins"] = arr;
|
||||
}
|
||||
|
||||
|
@ -153,6 +153,9 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
||||
{Config::Browser_SearchInAllDatabases, {QS("Browser/SearchInAllDatabases"), Roaming, false}},
|
||||
{Config::Browser_SupportKphFields, {QS("Browser/SupportKphFields"), Roaming, true}},
|
||||
{Config::Browser_NoMigrationPrompt, {QS("Browser/NoMigrationPrompt"), Roaming, false}},
|
||||
#ifdef QT_DEBUG
|
||||
{Config::Browser_CustomExtensionId, {QS("Browser/CustomExtensionId"), Local, {}}},
|
||||
#endif
|
||||
|
||||
// SSHAgent
|
||||
{Config::SSHAgent_Enabled, {QS("SSHAgent/Enabled"), Roaming, false}},
|
||||
|
@ -134,6 +134,9 @@ public:
|
||||
Browser_SearchInAllDatabases,
|
||||
Browser_SupportKphFields,
|
||||
Browser_NoMigrationPrompt,
|
||||
#ifdef QT_DEBUG
|
||||
Browser_CustomExtensionId,
|
||||
#endif
|
||||
|
||||
SSHAgent_Enabled,
|
||||
SSHAgent_UseOpenSSH,
|
||||
|
@ -45,6 +45,8 @@ DatabaseSettingsWidgetBrowser::DatabaseSettingsWidgetBrowser(QWidget* parent)
|
||||
connect(m_ui->customDataTable->selectionModel(),
|
||||
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||
SLOT(toggleRemoveButton(QItemSelection)));
|
||||
connect(m_ui->customDataTable, SIGNAL(doubleClicked(QModelIndex)), SLOT(editIndex(QModelIndex)));
|
||||
connect(m_customDataModel, SIGNAL(itemChanged(QStandardItem*)), SLOT(editFinished(QStandardItem*)));
|
||||
// clang-format on
|
||||
|
||||
connect(m_ui->removeCustomDataButton, SIGNAL(clicked()), SLOT(removeSelectedKey()));
|
||||
@ -127,9 +129,11 @@ void DatabaseSettingsWidgetBrowser::updateModel()
|
||||
QString strippedKey = key;
|
||||
strippedKey.remove(BrowserService::ASSOCIATE_KEY_PREFIX);
|
||||
auto created = customData()->value(QString("%1_%2").arg(CustomData::Created, strippedKey));
|
||||
auto createdItem = new QStandardItem(created);
|
||||
createdItem->setEditable(false);
|
||||
m_customDataModel->appendRow(QList<QStandardItem*>()
|
||||
<< new QStandardItem(strippedKey)
|
||||
<< new QStandardItem(customData()->value(key)) << new QStandardItem(created));
|
||||
<< new QStandardItem(customData()->value(key)) << createdItem);
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,6 +276,52 @@ void DatabaseSettingsWidgetBrowser::refreshDatabaseID()
|
||||
m_db->rootGroup()->setUuid(QUuid::createUuid());
|
||||
}
|
||||
|
||||
void DatabaseSettingsWidgetBrowser::editIndex(const QModelIndex& index)
|
||||
{
|
||||
Q_ASSERT(index.isValid());
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_valueInEdit = index.data().toString();
|
||||
m_ui->customDataTable->edit(index);
|
||||
}
|
||||
|
||||
void DatabaseSettingsWidgetBrowser::editFinished(QStandardItem* item)
|
||||
{
|
||||
const QItemSelectionModel* itemSelectionModel = m_ui->customDataTable->selectionModel();
|
||||
|
||||
if (itemSelectionModel) {
|
||||
auto indexList = itemSelectionModel->selectedRows(item->column());
|
||||
if (indexList.length() > 0) {
|
||||
QString newValue = item->index().data().toString();
|
||||
|
||||
// The key is edited
|
||||
if (item->column() == 0) {
|
||||
// Get the old key/value pair, remove it and replace it
|
||||
m_valueInEdit.insert(0, BrowserService::ASSOCIATE_KEY_PREFIX);
|
||||
auto tempValue = customData()->value(m_valueInEdit);
|
||||
newValue.insert(0, BrowserService::ASSOCIATE_KEY_PREFIX);
|
||||
|
||||
m_db->metadata()->customData()->remove(m_valueInEdit);
|
||||
m_db->metadata()->customData()->set(newValue, tempValue);
|
||||
} else {
|
||||
// Replace just the value
|
||||
for (const QString& key : m_db->metadata()->customData()->keys()) {
|
||||
if (key.startsWith(BrowserService::ASSOCIATE_KEY_PREFIX)) {
|
||||
if (m_valueInEdit == m_db->metadata()->customData()->value(key)) {
|
||||
m_db->metadata()->customData()->set(key, newValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Updates the shared key list after the list is cleared
|
||||
void DatabaseSettingsWidgetBrowser::updateSharedKeyList()
|
||||
{
|
||||
|
@ -64,6 +64,8 @@ private slots:
|
||||
void removeStoredPermissions();
|
||||
void convertAttributesToCustomData();
|
||||
void refreshDatabaseID();
|
||||
void editIndex(const QModelIndex& index);
|
||||
void editFinished(QStandardItem* item);
|
||||
|
||||
private:
|
||||
void updateModel();
|
||||
@ -77,6 +79,7 @@ protected:
|
||||
private:
|
||||
QPointer<CustomData> m_customData;
|
||||
QPointer<QStandardItemModel> m_customDataModel;
|
||||
QString m_valueInEdit;
|
||||
};
|
||||
|
||||
#endif // KEEPASSXC_DATABASESETTINGSWIDGETBROWSER_H
|
||||
|
Loading…
Reference in New Issue
Block a user