</property>
</widget>
</item>
+
+ <!-- Zoom factor. -->
+ <item row="5" column="0">
+ <widget class="QLabel">
+ <property name="text">
+ <string>Zoom factor</string>
+ </property>
+ </widget>
+ </item>
+
+ <item row="5" column="1">
+ <widget class="QComboBox" name="zoomFactorComboBox">
+ <item>
+ <property name="text">
+ <string>System default</string>
+ </property>
+ </item>
+
+ <item>
+ <property name="text">
+ <string>Custom</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+
+ <item row="6" column="1">
+ <widget class="QDoubleSpinBox" name="customZoomFactorSpinBox">
+ <property name="toolTip">
+ <string>Set the zoom factor between 0.25 and 5.00. The default is 1.00.</string>
+ </property>
+
+ <property name="minimum">
+ <double>0.250000000000000</double>
+ </property>
+
+ <property name="maximum">
+ <double>5.000000000000000</double>
+ </property>
+
+ <property name="singleStep">
+ <double>0.250000000000000</double>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
javaScriptLabelPointer = domainSettingsDialogUi.javaScriptLabel;
userAgentComboBoxPointer = domainSettingsDialogUi.userAgentComboBox;
userAgentLabelPointer = domainSettingsDialogUi.userAgentLabel;
+ zoomFactorComboBoxPointer = domainSettingsDialogUi.zoomFactorComboBox;
+ customZoomFactorSpinBoxPointer = domainSettingsDialogUi.customZoomFactorSpinBox;
QPushButton *addDomainButtonPointer = domainSettingsDialogUi.addDomainButton;
deleteDomainButtonPointer = domainSettingsDialogUi.deleteDomainButton;
QDialogButtonBox *dialogButtonBoxPointer = domainSettingsDialogUi.dialogButtonBox;
connect(domainNameLineEditPointer, SIGNAL(textEdited(QString)), this, SLOT(domainNameChanged(QString)));
connect(javaScriptComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(javaScriptChanged(int)));
connect(userAgentComboBoxPointer, SIGNAL(currentTextChanged(QString)), this, SLOT(userAgentChanged(QString)));
+ connect(zoomFactorComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(zoomFactorComboBoxChanged(int)));
+ connect(customZoomFactorSpinBoxPointer, SIGNAL(valueChanged(double)), this, SLOT(customZoomFactorChanged(double)));
// Connect the buttons.
connect(addDomainButtonPointer, SIGNAL(released()), this, SLOT(showAddMessageBox()));
reject();
}
-void DomainSettingsDialog::domainNameChanged(QString updatedDomainName) const
+void DomainSettingsDialog::customZoomFactorChanged(const double &newValue) const
+{
+ // Update the domains table model.
+ domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR)),
+ newValue);
+
+ // Update the UI.
+ updateUi();
+}
+
+
+void DomainSettingsDialog::domainNameChanged(const QString &updatedDomainName) const
{
// Update the domains table model.
domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex(), updatedDomainName);
}
-void DomainSettingsDialog::domainSelected(QModelIndex modelIndex) const
+void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const
{
// Populate the domain name line edit pointer.
domainNameLineEditPointer->setText(modelIndex.data().toString());
// Set the custom user agent if specified.
if (userAgentIndex == -1) userAgentComboBoxPointer->setCurrentText(userAgent);
+ // Get the zoom factor combo box index.
+ int zoomFactorComboBoxIndex = modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::ZOOM_FACTOR)).data().toInt();
+
+ // Populate the zoom factor combo box.
+ zoomFactorComboBoxPointer->setCurrentIndex(zoomFactorComboBoxIndex);
+
+ // Populate the custom zoom factor spin box.
+ customZoomFactorSpinBoxPointer->setValue(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR)).data().toDouble());
+
+ // Set the initial visibility of the custom zoom factor spin box.
+ customZoomFactorSpinBoxPointer->setVisible(zoomFactorComboBoxIndex);
+
// Populate the labels.
populateJavaScriptLabel();
populateUserAgentLabel(userAgentComboBoxPointer->currentText());
updateUi();
}
-void DomainSettingsDialog::javaScriptChanged(int newIndex) const
+void DomainSettingsDialog::javaScriptChanged(const int &newIndex) const
{
// Update the domains table model.
domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT)),
// Create a new domain record.
QSqlRecord newDomainRecord = QSqlDatabase::database(DomainsDatabaseHelper::CONNECTION_NAME).record(DomainsDatabaseHelper::DOMAINS_TABLE);
- // Add the new domain name.
+ // Set the values for the new domain.
newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOMAIN_NAME), newDomainName);
-
- // Set the default value of `0` for JavaScript.
- newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT), 0);
-
- // Set the default value for the user agent.
+ newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT), DomainsDatabaseHelper::SYSTEM_DEFAULT);
newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::USER_AGENT), UserAgentHelper::SYSTEM_DEFAULT_DATABASE);
+ newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::ZOOM_FACTOR), DomainsDatabaseHelper::SYSTEM_DEFAULT);
+ newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR), 1.0);
// Insert the new domain. `-1` appends it to the end.
domainsTableModelPointer->insertRecord(-1, newDomainRecord);
domainSettingsWidgetPointer->setVisible(domainsTableModelPointer->rowCount() > 0);
}
-void DomainSettingsDialog::userAgentChanged(const QString updatedUserAgent) const
+void DomainSettingsDialog::userAgentChanged(const QString &updatedUserAgent) const
{
// Update the domains table model.
domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::USER_AGENT)),
updateUi();
}
+void DomainSettingsDialog::zoomFactorComboBoxChanged(const int &newIndex) const
+{
+ // Update the domains table model.
+ domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::ZOOM_FACTOR)),
+ newIndex);
+
+ // Update the visibility of the custom zoom factor spin box.
+ customZoomFactorSpinBoxPointer->setVisible(newIndex);
+ // Update the UI.
+ updateUi();
+}
// Qt toolkit headers.
#include <QDialog>
+#include <QDoubleSpinBox>
#include <QLabel>
#include <QtSql>
// The private slots.
void apply() const;
void cancel();
- void domainNameChanged(QString updatedDomainName) const;
- void domainSelected(QModelIndex modelIndex) const;
- void javaScriptChanged(int newIndex) const;
+ void customZoomFactorChanged(const double &newValue) const;
+ void domainNameChanged(const QString &updatedDomainName) const;
+ void domainSelected(const QModelIndex &modelIndex) const;
+ void javaScriptChanged(const int &newIndex) const;
void ok();
void reset() const;
void showAddMessageBox();
void showDeleteMessageBox() const;
- void userAgentChanged(const QString updatedUserAgent) const;
+ void userAgentChanged(const QString &updatedUserAgent) const;
+ void zoomFactorComboBoxChanged(const int &newIndex) const;
private:
// The private variables.
QPushButton *applyButtonPointer;
+ QDoubleSpinBox *customZoomFactorSpinBoxPointer;
QPushButton *deleteDomainButtonPointer;
QListView *domainsListViewPointer;
KLineEdit *domainNameLineEditPointer;
QPushButton *resetButtonPointer;
QComboBox *userAgentComboBoxPointer;
QLabel *userAgentLabelPointer;
+ QComboBox *zoomFactorComboBoxPointer;
// The private functions.
void populateJavaScriptLabel() const;
const QString DomainsDatabaseHelper::DOMAINS_TABLE = "domains";
// Define the private static schema constants.
-const int DomainsDatabaseHelper::SCHEMA_VERSION = 2;
+const int DomainsDatabaseHelper::SCHEMA_VERSION = 3;
// Define the public static database field names.
const QString DomainsDatabaseHelper::_ID = "_id";
const QString DomainsDatabaseHelper::DOMAIN_NAME = "domain_name";
const QString DomainsDatabaseHelper::JAVASCRIPT = "javascript";
const QString DomainsDatabaseHelper::USER_AGENT = "user_agent";
+const QString DomainsDatabaseHelper::ZOOM_FACTOR = "zoom_factor";
+const QString DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR = "custom_zoom_factor";
// The default constructor.
DomainsDatabaseHelper::DomainsDatabaseHelper() {}
// Set the default value.
domainsDatabase.exec("UPDATE " + DOMAINS_TABLE + " SET " + JAVASCRIPT + " = 0" );
+ // Fallthrough to the next case.
[[fallthrough]];
}
{
// Add the User Agent column.
domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + USER_AGENT + " TEXT DEFAULT '" + UserAgentHelper::SYSTEM_DEFAULT_DATABASE + "'");
+
+ // Fallthrough to the next case.
+ [[fallthrough]];
+ }
+
+ // Upgrade from schema version 2.
+ case 2:
+ {
+ // Add the Zoom Factor columns.
+ domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ZOOM_FACTOR + " INTEGER DEFAULT 0");
+ domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + CUSTOM_ZOOM_FACTOR + " REAL DEFAULT 1.0");
}
}
createTableQuery.prepare("CREATE TABLE " + DOMAINS_TABLE + "(" +
_ID + " INTEGER PRIMARY KEY, " +
DOMAIN_NAME + " TEXT, " +
- JAVASCRIPT + " INTEGER DEFAULT 0," +
- USER_AGENT + " TEXT DEFAULT '" + UserAgentHelper::SYSTEM_DEFAULT_DATABASE + "')"
+ JAVASCRIPT + " INTEGER DEFAULT 0, " +
+ USER_AGENT + " TEXT DEFAULT '" + UserAgentHelper::SYSTEM_DEFAULT_DATABASE + "', " +
+ ZOOM_FACTOR + " INTEGER DEFAULT 0, " +
+ CUSTOM_ZOOM_FACTOR + " REAL DEFAULT 1.0)"
);
// Execute the query.
static const int SYSTEM_DEFAULT = 0;
static const int DISABLED = 1;
static const int ENABLED = 2;
+ static const int CUSTOM = 1;
// The public constants.
static const QString _ID;
static const QString CONNECTION_NAME;
+ static const QString CUSTOM_ZOOM_FACTOR;
static const QString DOMAIN_NAME;
static const QString DOMAINS_TABLE;
static const QString JAVASCRIPT;
static const QString USER_AGENT;
+ static const QString ZOOM_FACTOR;
private:
// The private static constants.
<!-- The menu bar. -->
<MenuBar>
<Menu name="on_the_fly_settings"> <text>On-The-Fly Settings</text>
- <Menu name="user_agent"> <text>User Agent</text>
+ <Menu name="user_agent" icon="user-group-properties"> <text>User Agent</text>
<Action name="user_agent_privacy_browser" />
<Action name="user_agent_firefox_linux" />
<Action name="user_agent_chromium_linux" />
<Separator />
- <Menu name="search_engine"> <text>Search Engine</text>
+ <Menu name="search_engine" icon="search"> <text>Search Engine</text>
<Action name="search_engine_mojeek" />
<Action name="search_engine_monocles" />
<Action name="search_engine_metager" />
}
// This exists as a separate function from `applyDomainSettings()` so it can be listed as a slot and function without the need for a boolean argument.
-void BrowserView::applyDomainSettingsAndReload() const
+// Once <https://redmine.stoutner.com/issues/799> has been resolved this can be `const`.
+void BrowserView::applyDomainSettingsAndReload()
{
// Apply the domain settings. `true` reloads the website.
applyDomainSettings(webEngineViewPointer->url().host(), true);
}
// This exists as a separate function from `applyDomainSettings()` so it can be listed as a slot and function without the need for a boolean argument.
-void BrowserView::applyDomainSettingsWithoutReloading(const QString &hostname) const
+// Once <https://redmine.stoutner.com/issues/799> has been resolved this can be `const`.
+void BrowserView::applyDomainSettingsWithoutReloading(const QString &hostname)
{
// Apply the domain settings `false` does not reload the website.
applyDomainSettings(hostname, false);
}
-void BrowserView::applyDomainSettings(const QString &hostname, const bool reloadWebsite) const
+// Once <https://redmine.stoutner.com/issues/799> has been resolved this can be `const`.
+void BrowserView::applyDomainSettings(const QString &hostname, const bool reloadWebsite)
{
// Get the record for the hostname.
QSqlQuery domainQuery = DomainsDatabaseHelper::getDomainQuery(hostname);
// Set the user agent.
webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getResultingDomainSettingsUserAgent(domainRecord.field(DomainsDatabaseHelper::USER_AGENT).value().toString()));
+ // Check if a custom zoom factor is set. This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
+ if (domainRecord.field(DomainsDatabaseHelper::ZOOM_FACTOR).value().toInt())
+ {
+ // Store the current zoom factor.
+ currentZoomFactor = domainRecord.field(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR).value().toDouble();
+ }
+ else
+ {
+ // Reset the current zoom factor.
+ currentZoomFactor = Settings::zoomFactor();
+ }
+
// Set the zoom factor.
- webEngineViewPointer->setZoomFactor(Settings::zoomFactor());
+ webEngineViewPointer->setZoomFactor(currentZoomFactor);
// Apply the domain settings palette to the URL line edit.
emit updateDomainSettingsIndicator(true);
// Set the user agent.
webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getUserAgentFromDatabaseName(Settings::userAgent()));
+ // Store the current zoom factor.
+ currentZoomFactor = Settings::zoomFactor();
+
// Set the zoom factor.
- webEngineViewPointer->setZoomFactor(Settings::zoomFactor());
+ webEngineViewPointer->setZoomFactor(currentZoomFactor);
// Apply the no domain settings palette to the URL line edit.
emit updateDomainSettingsIndicator(false);
emit updateBackAction(webEngineHistoryPointer->canGoBack());
emit updateForwardAction(webEngineHistoryPointer->canGoForward());
- // Reapply the zoom factor. This is a bug in QWebEngineView that resets the zoom with every load. Hopefully it will be fixed in Qt6. <https://bugreports.qt.io/browse/QTBUG-51992>
- webEngineViewPointer->setZoomFactor(Settings::zoomFactor());
+ // Reapply the zoom factor. This is a bug in QWebEngineView that resets the zoom with every load. <https://redmine.stoutner.com/issues/799>
+ webEngineViewPointer->setZoomFactor(currentZoomFactor);
}
public Q_SLOTS:
// The public slots.
void applyApplicationSettings();
- void applyDomainSettingsAndReload() const;
- void applyDomainSettingsWithoutReloading(const QString &hostname) const;
+ void applyDomainSettingsAndReload();
+ void applyDomainSettingsWithoutReloading(const QString &hostname);
void applyOnTheFlySearchEngine(QAction *searchEngineActionPointer);
void applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const;
void back() const;
private:
// The private variables.
+ double currentZoomFactor; // This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
QString searchEngineUrl;
QWebEngineHistory *webEngineHistoryPointer;
QWebEngineProfile *webEngineProfilePointer;
QWebEngineView *webEngineViewPointer;
// The private functions.
- void applyDomainSettings(const QString &hostname, const bool reloadWebsite) const;
+ void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
};
#endif
domainSettingsActionPointer->setText(i18nc("Domain Settings button", "Domain Settings"));
// Set the action icons.
- //refreshActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
+ userAgentPrivacyBrowserActionPointer->setIcon(QIcon(":/icons/privacy-mode"));
+ userAgentFirefoxLinuxActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("firefox-esr")));
+ userAgentChromiumLinuxActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("chromium")));
+ userAgentFirefoxWindowsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("firefox-esr")));
+ userAgentChromeWindowsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("chromium")));
+ userAgentEdgeWindowsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties")));
+ userAgentSafariMacosActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties")));
+ userAgentCustomActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties")));
+ searchEngineMojeekActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
+ searchEngineMonoclesActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
+ searchEngineMetagerActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
+ searchEngineGoogleActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("im-google")));
+ searchEngineBingActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
+ searchEngineYahooActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("im-yahoo")));
+ searchEngineCustomActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
+ zoomFactorActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("zoom")));
domainSettingsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("network-server-symbolic")));
// Update the on-the-fly menus.