rename: att -> att_browser

This commit is contained in:
2026-10-17 11:38:55 +02:00
parent 495a0696ba
commit 483b3f87ba
11 changed files with 97 additions and 49 deletions
+14 -6
View File
@@ -88,7 +88,7 @@ BrowserWindow::BrowserWindow(const Session &session, const QUrl &startUrl, QWidg
void BrowserWindow::setupUi()
{
setWindowTitle(QStringLiteral("att"));
setWindowTitle(QStringLiteral("att_browser"));
resize(1280, 800);
auto *central = new QWidget(this);
@@ -134,8 +134,8 @@ void BrowserWindow::connectView()
setPageFullScreen(request.toggleOn());
});
connect(m_view, &QWebEngineView::titleChanged, this, [this](const QString &title) {
setWindowTitle(title.isEmpty() ? QStringLiteral("att")
: QStringLiteral("%1 - att").arg(title));
setWindowTitle(title.isEmpty() ? QStringLiteral("att_browser")
: QStringLiteral("%1 - att_browser").arg(title));
m_session.history->updateTitle(m_view->url(), title);
});
connect(m_view, &QWebEngineView::loadFinished, this, [this](bool ok) {
@@ -344,11 +344,11 @@ bool BrowserWindow::handleNormalModeKey(QKeyEvent *event)
return true;
}
if (text == QLatin1String("j")) {
scrollBy(0, kScrollStep);
scrollByCssPx(0, config::kScrollStepPx);
return true;
}
if (text == QLatin1String("k")) {
scrollBy(0, -kScrollStep);
scrollByCssPx(0, -config::kScrollStepPx);
return true;
}
if (text == QLatin1String("h")) {
@@ -500,7 +500,7 @@ void BrowserWindow::runCommand(const QString &command)
} else if (name == QLatin1String("version")) {
// The Chromium security patch level is what says how far behind
// Chrome's fixes this build is; "nix flake update" moves it forward.
m_status->showMessage(QStringLiteral("att %1, Qt %2, Chromium %3, security patches %4")
m_status->showMessage(QStringLiteral("att_browser %1, Qt %2, Chromium %3, security patches %4")
.arg(QCoreApplication::applicationVersion(),
QString::fromLatin1(qVersion()),
QString::fromLatin1(qWebEngineChromiumVersion()),
@@ -655,6 +655,14 @@ void BrowserWindow::scrollBy(int dx, int dy)
QCoreApplication::sendEvent(target, &event);
}
void BrowserWindow::scrollByCssPx(int dx, int dy)
{
// Wheel deltas are screen pixels, which the page zoom shrinks (at 125% a
// 25px wheel moves 20 CSS px). qutebrowser's scroll-px counts CSS pixels.
const double zoom = m_view->zoomFactor();
scrollBy(qRound(dx * zoom), qRound(dy * zoom));
}
void BrowserWindow::scrollPages(double factor)
{
scrollBy(0, qRound(m_view->height() * factor));
+1
View File
@@ -66,6 +66,7 @@ private:
void placeCompletion();
void openUrl(const QString &input, bool newWindow);
void scrollBy(int dx, int dy);
void scrollByCssPx(int dx, int dy);
void scrollPages(double factor);
void scrollToEnd(bool bottom);
void focusView();
+4
View File
@@ -17,6 +17,10 @@ inline constexpr std::array kZoomLevels = {
1.25, 1.50, 1.75, 2.00, 2.50, 3.00, 4.00, 5.00,
};
// What "j" / "k" do: qutebrowser's "scroll-px 0 25" / "scroll-px 0 -25". In
// CSS pixels, so the step grows with the zoom like qutebrowser's does.
inline constexpr int kScrollStepPx = 25;
// content.cookies.accept = no-3rdparty: refuse cookies a page's third-party
// requests try to set or send. Blocks most cross-site tracking; a few embedded
// logins (e.g. some comment widgets) stop working.
+1 -1
View File
@@ -230,7 +230,7 @@ QString wrap(const Greasemonkey::Metadata &meta, const QString &requiredCode, co
QJsonObject info{
{QStringLiteral("script"), script},
{QStringLiteral("scriptMetaStr"), meta.block},
{QStringLiteral("scriptHandler"), QStringLiteral("att")},
{QStringLiteral("scriptHandler"), QStringLiteral("att_browser")},
{QStringLiteral("version"), QCoreApplication::applicationVersion()},
};
+1 -1
View File
@@ -44,7 +44,7 @@ QString sandboxDisabledReason(int argc, char **argv)
return QStringLiteral("QTWEBENGINE_CHROMIUM_FLAGS contains --no-sandbox");
for (int i = 1; i < argc; ++i) {
if (QLatin1String(argv[i]) == QLatin1String("--no-sandbox"))
return QStringLiteral("att was started with --no-sandbox");
return QStringLiteral("att_browser was started with --no-sandbox");
}
return {};
}
+33 -4
View File
@@ -9,6 +9,9 @@
#include <QApplication>
#include <QCommandLineParser>
#include <QDir>
#include <QFileInfo>
#include <QStandardPaths>
#include <QWebEngineProfile>
namespace {
@@ -48,18 +51,44 @@ constexpr auto kStyleSheet = R"(
}
)";
// Before the rename, the browser was "att" with organization "att", so its
// data was in ~/.local/share/att/att and ~/.cache/att/att. Move those to the
// new locations once, before anything opens a file there, so cookies, history
// and userscripts survive. A new directory that already exists is left alone.
void migrateOldDataDirs()
{
const auto migrate = [](QStandardPaths::StandardLocation generic,
QStandardPaths::StandardLocation app) {
const QString base = QStandardPaths::writableLocation(generic);
const QString oldPath = base + QStringLiteral("/att/att");
const QString newPath = QStandardPaths::writableLocation(app);
if (!QFileInfo::exists(oldPath) || QFileInfo::exists(newPath))
return;
QDir().mkpath(QFileInfo(newPath).path());
if (QDir().rename(oldPath, newPath))
QDir(base).rmdir(QStringLiteral("att")); // only if now empty
else
qWarning("att_browser: could not move %s to %s", qPrintable(oldPath),
qPrintable(newPath));
};
migrate(QStandardPaths::GenericDataLocation, QStandardPaths::AppDataLocation);
migrate(QStandardPaths::GenericCacheLocation, QStandardPaths::CacheLocation);
}
} // namespace
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QCoreApplication::setApplicationName(QStringLiteral("att"));
// No organization name, so the data lives in ~/.local/share/att_browser
// rather than a doubled att_browser/att_browser.
QCoreApplication::setApplicationName(QStringLiteral("att_browser"));
QCoreApplication::setApplicationVersion(QStringLiteral("0.1.0"));
QCoreApplication::setOrganizationName(QStringLiteral("att"));
migrateOldDataDirs();
QCommandLineParser parser;
parser.setApplicationDescription(
QStringLiteral("att - a minimal, keyboard-driven browser"));
QStringLiteral("att_browser - a minimal, keyboard-driven browser"));
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument(QStringLiteral("url"), QStringLiteral("URL to open."));
@@ -97,7 +126,7 @@ int main(int argc, char *argv[])
firstWindow->show();
const QString sandboxOff = hardening::sandboxDisabledReason(argc, argv);
if (!sandboxOff.isEmpty()) {
qWarning("att: Chromium's sandbox is disabled: %s", qPrintable(sandboxOff));
qWarning("att_browser: Chromium's sandbox is disabled: %s", qPrintable(sandboxOff));
firstWindow->showMessage(QStringLiteral("Sandbox disabled: %1").arg(sandboxOff), true);
}
// After the window exists, so its status bar shows their messages. The