diff --git a/conf/tracking.lua b/conf/tracking.lua deleted file mode 100644 index 5b5e48a0..00000000 --- a/conf/tracking.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - enabled = true -} diff --git a/src/app/Application.cpp b/src/app/Application.cpp old mode 100644 new mode 100755 index cca7e065..1fb5ca33 --- a/src/app/Application.cpp +++ b/src/app/Application.cpp @@ -84,30 +84,6 @@ static LONG WINAPI exceptionFilter(PEXCEPTION_POINTERS info) } #endif -namespace { - -const QString kUserAgentFmt = "%1/%2 (%3)"; - -QString userAgentSystem() -{ -#if defined(Q_OS_WIN) - QOperatingSystemVersion current = QOperatingSystemVersion::current(); - if (current < QOperatingSystemVersion::Windows8) { - return "Windows NT 6.1"; - } else if (current < QOperatingSystemVersion::Windows10) { - return "Windows NT 6.2"; - } else { - return "Windows NT 10.0"; - } -#elif defined(Q_OS_MAC) - return "Macintosh"; -#else - return "Linux"; -#endif -} - -} // anon. namespace - Application::Application(int &argc, char **argv, bool haltOnParseError) : QApplication(argc, argv) { @@ -224,33 +200,12 @@ Application::Application(int &argc, char **argv, bool haltOnParseError) // Initialize git library. git::Repository::init(); - connect(this, &Application::aboutToQuit, [this] { + connect(this, &Application::aboutToQuit, [] { // Clean up git library. // Make sure windows are really deleted. sendPostedEvents(nullptr, QEvent::DeferredDelete); git::Repository::shutdown(); }); - - // Read tracking settings. - settings.beginGroup("tracking"); - QByteArray tid(GITTYUP_TRACKING_ID); - if (!tid.isEmpty() && settings.value("enabled", true).toBool()) { - // Get or create persistent client ID. - mClientId = settings.value("id").toString(); - if (mClientId.isEmpty()) { - mClientId = QUuid::createUuid().toString(); - settings.setValue("id", mClientId); - } - - // Fire and forget, except to free the reply. - mTrackingMgr = new QNetworkAccessManager(this); - connect(mTrackingMgr, &QNetworkAccessManager::finished, - [](QNetworkReply *reply) { - reply->deleteLater(); - }); - } - - settings.endGroup(); } void Application::autoUpdate() @@ -318,33 +273,6 @@ Theme *Application::theme() return static_cast(instance())->mTheme.data(); } -void Application::track(const QString &screen) -{ - QUrlQuery query; - query.addQueryItem("t", "screenview"); - query.addQueryItem("cd", screen); - - static_cast(instance())->track(query); -} - -void Application::track( - const QString &category, - const QString &action, - const QString &label, - int value) -{ - QUrlQuery query; - query.addQueryItem("t", "event"); - query.addQueryItem("ec", category); - query.addQueryItem("ea", action); - if (!label.isEmpty()) - query.addQueryItem("el", label); - if (value >= 0) - query.addQueryItem("ev", QString::number(value)); - - static_cast(instance())->track(query); -} - bool Application::event(QEvent *event) { if (event->type() == QEvent::FileOpen) @@ -353,32 +281,6 @@ bool Application::event(QEvent *event) return QApplication::event(event); } -void Application::track(const QUrlQuery &query) -{ - if (!mTrackingMgr) - return; - - QString sys = userAgentSystem(); - QString language = QLocale().uiLanguages().first(); - QString userAgent = kUserAgentFmt.arg(GITTYUP_NAME, GITTYUP_VERSION, sys); - - QUrlQuery tmp = query; - tmp.addQueryItem("v", "1"); - tmp.addQueryItem("ds", "app"); - tmp.addQueryItem("ul", language); - tmp.addQueryItem("ua", userAgent); - tmp.addQueryItem("an", GITTYUP_NAME); - tmp.addQueryItem("av", GITTYUP_VERSION); - tmp.addQueryItem("tid", GITTYUP_TRACKING_ID); - tmp.addQueryItem("cid", mClientId); - -// QString header = "application/x-www-form-urlencoded"; -// QNetworkRequest request(QUrl("http://google-analytics.com/collect")); -// request.setHeader(QNetworkRequest::ContentTypeHeader, header); - -// mTrackingMgr->post(request, tmp.query().toUtf8()); -} - void Application::handleSslErrors( QNetworkReply *reply, const QList &errors) diff --git a/src/app/Application.h b/src/app/Application.h old mode 100644 new mode 100755 index d292598c..1d5d82e1 --- a/src/app/Application.h +++ b/src/app/Application.h @@ -30,27 +30,16 @@ public: static Theme *theme(); - static void track(const QString &screen); - static void track( - const QString &category, - const QString &action, - const QString &label = QString(), - int value = -1); - protected: bool event(QEvent *event) override; private: void registerService(); - void track(const QUrlQuery &query); void handleSslErrors(QNetworkReply *reply, const QList &errors); QString mPathspec = QString(); QScopedPointer mTheme; QStringList mPositionalArguments; - - QString mClientId; - QNetworkAccessManager *mTrackingMgr = nullptr; }; #endif diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt old mode 100644 new mode 100755 index f1abbf6c..0399b3e3 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -57,7 +57,6 @@ target_compile_definitions(app GITTYUP_NAME="${GITTYUP_NAME}" GITTYUP_VERSION="${GITTYUP_VERSION}" PRIVATE - GITTYUP_TRACKING_ID="${GITTYUP_TRACKING_ID}" QT_TRANSLATIONS_DIR="${QT_TRANSLATIONS_DIR}" ) diff --git a/src/dialogs/AboutDialog.cpp b/src/dialogs/AboutDialog.cpp index 7b98887c..75fab29a 100644 --- a/src/dialogs/AboutDialog.cpp +++ b/src/dialogs/AboutDialog.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -29,7 +30,7 @@ namespace { -const QString kEmail = "TODO"; +const QString kEmail = QStringLiteral("TODO"); const QString kUrl = "https://stackoverflow.com/questions/tagged/gittyup?sort=frequent"; @@ -86,7 +87,7 @@ AboutDialog::AboutDialog(QWidget *parent) QString revision = GITTYUP_BUILD_REVISION; QDateTime dateTime = QDateTime::fromString(GITTYUP_BUILD_DATE, Qt::ISODate); - QString date = dateTime.date().toString(Qt::DefaultLocaleLongDate); + QString date = dateTime.date().toString(QLocale().dateFormat(QLocale::LongFormat)); QString text = kTextFmt.arg(name, version, date, revision, kUrl, kEmail); QLabel *label = new QLabel(text, this); label->setWordWrap(true); @@ -102,21 +103,8 @@ AboutDialog::AboutDialog(QWidget *parent) browser->setOpenLinks(false); browser->document()->setDocumentMargin(12); browser->document()->setDefaultStyleSheet(kStyleSheet); - connect(browser, &QTextBrowser::anchorClicked, [this](const QUrl &url) { - if (url.isLocalFile() && - QFileInfo(url.toLocalFile()).fileName() == "opt-out") { - Settings::instance()->setValue("tracking/enabled", false); - QString text = - tr("Usage reporting has been disabled. Restart " - "the application for changes to take effect."); - QMessageBox::information(this, tr("Usage Reporting Disabled"), text); - return; - } - QDesktopServices::openUrl(url); - }); - - connect(mTabs, &QTabBar::currentChanged, [this, browser](int index) { + connect(mTabs, &QTabBar::currentChanged, this, [this, browser](int index) { QString url = Settings::docDir().filePath(mTabs->tabData(index).toString()); browser->setSource(QUrl::fromLocalFile(url)); }); diff --git a/src/dialogs/ConfigDialog.cpp b/src/dialogs/ConfigDialog.cpp old mode 100644 new mode 100755 index f712f27d..7370a662 --- a/src/dialogs/ConfigDialog.cpp +++ b/src/dialogs/ConfigDialog.cpp @@ -108,35 +108,42 @@ public: init(); // Connect signals after initializing fields. - connect(mName, &QLineEdit::textChanged, [this](const QString &text) { - mRepo.config().setValue("user.name", text); + connect(mName, &QLineEdit::textChanged, this, [this](const QString &text) { + git::Config config = mRepo.config(); + config.setValue("user.name", text); }); - connect(mEmail, &QLineEdit::textChanged, [this](const QString &text) { - mRepo.config().setValue("user.email", text); + connect(mEmail, &QLineEdit::textChanged, this, [this](const QString &text) { + git::Config config = mRepo.config(); + config.setValue("user.email", text); }); - connect(mFetch, &QCheckBox::toggled, [this, view](bool checked) { - mRepo.appConfig().setValue("autofetch.enable", checked); + connect(mFetch, &QCheckBox::toggled, view, [this, view](bool checked) { + git::Config config = mRepo.config(); + config.setValue("autofetch.enable", checked); view->startFetchTimer(); }); using Signal = void (QSpinBox::*)(int); auto signal = static_cast(&QSpinBox::valueChanged); - connect(mFetchMinutes, signal, [this](int value) { - mRepo.appConfig().setValue("autofetch.minutes", value); + connect(mFetchMinutes, signal, this, [this](int value) { + git::Config config = mRepo.config(); + config.setValue("autofetch.minutes", value); }); - connect(mPushCommit, &QCheckBox::toggled, [this](bool checked) { - mRepo.appConfig().setValue("autopush.enable", checked); + connect(mPushCommit, &QCheckBox::toggled, this, [this](bool checked) { + git::Config config = mRepo.config(); + config.setValue("autopush.enable", checked); }); - connect(mPullUpdate, &QCheckBox::toggled, [this](bool checked) { - mRepo.appConfig().setValue("autoupdate.enable", checked); + connect(mPullUpdate, &QCheckBox::toggled, this, [this](bool checked) { + git::Config config = mRepo.config(); + config.setValue("autoupdate.enable", checked); }); - connect(mAutoPrune, &QCheckBox::toggled, [this](bool checked) { - mRepo.appConfig().setValue("autoprune.enable", checked); + connect(mAutoPrune, &QCheckBox::toggled, this, [this](bool checked) { + git::Config config = mRepo.config(); + config.setValue("autoprune.enable", checked); }); } @@ -221,7 +228,7 @@ public: } }); - connect(table->selectionModel(), &QItemSelectionModel::selectionChanged, + connect(table->selectionModel(), &QItemSelectionModel::selectionChanged, this, [table, footer] { QModelIndexList indexes = table->selectionModel()->selectedRows(); footer->setMinusEnabled(!indexes.isEmpty()); @@ -270,9 +277,9 @@ public: Footer *footer = new Footer(mTable); footer->setPlusEnabled(repo.head().isValid()); - connect(footer, &Footer::plusClicked, [this, repo] { + connect(footer, &Footer::plusClicked, this, [this, repo] { NewBranchDialog *dialog = new NewBranchDialog(repo, git::Commit(), this); - connect(dialog, &QDialog::accepted, this, [this, repo, dialog] { + connect(dialog, &QDialog::accepted, this, [repo, dialog] { QString name = dialog->name(); git::Commit commit = dialog->target(); git::Branch branch = git::Repository(repo).createBranch(name, commit); @@ -285,7 +292,7 @@ public: dialog->open(); }); - connect(footer, &Footer::minusClicked, [this] { + connect(footer, &Footer::minusClicked, this, [this] { // Get all selected branches before removing any. QList branches; QModelIndexList indexes = mTable->selectionModel()->selectedRows(); @@ -366,7 +373,7 @@ public: table->horizontalHeader()->setSectionResizeMode( SubmoduleTableModel::Url, QHeaderView::Stretch); - connect(table, &QTableView::doubleClicked, [view](const QModelIndex &index) { + connect(table, &QTableView::doubleClicked, this, [view](const QModelIndex &index) { QVariant var = index.data(SubmoduleTableModel::SubmoduleRole); view->openSubmodule(var.value()); }); @@ -399,7 +406,7 @@ public: // enable QCheckBox *enable = new QCheckBox(tr("Enable indexing"), this); enable->setChecked(config.value("index.enable", true)); - connect(enable, &QCheckBox::toggled, [view](bool checked) { + connect(enable, &QCheckBox::toggled, this, [view](bool checked) { git::Config config = view->repo().appConfig(); config.setValue("index.enable", checked); @@ -417,7 +424,7 @@ public: terms->setMaximum(99999999); terms->setSingleStep(100000); terms->setValue(config.value("index.termlimit", 1000000)); - connect(terms, signal, [view](int value) { + connect(terms, signal, this, [view](int value) { view->repo().appConfig().setValue("index.termlimit", value); }); @@ -430,7 +437,7 @@ public: QSpinBox *context = new QSpinBox(this); QLabel *contextLabel = new QLabel(tr("lines"), this); context->setValue(config.value("index.contextlines", 3)); - connect(context, signal, [view](int value) { + connect(context, signal, this, [view](int value) { view->repo().appConfig().setValue("index.contextlines", value); }); @@ -462,7 +469,7 @@ public: // remove QPushButton *remove = new QPushButton(tr("Remove Index"), this); remove->setEnabled(view->index()->isValid()); - connect(remove, &QPushButton::clicked, [view, remove] { + connect(remove, &QPushButton::clicked, this, [view, remove] { Index *index = view->index(); view->cancelIndexing(); index->remove(); @@ -488,7 +495,7 @@ public: { if (!view->repo().lfsIsInitialized()) { QPushButton *button = new QPushButton(tr("Initialize LFS"), this); - connect(button, &QPushButton::clicked, [this, view] { + connect(button, &QPushButton::clicked, this, [this, view] { view->lfsInitialize(); window()->close(); }); @@ -500,7 +507,6 @@ public: return; } - Settings *settings = Settings::instance(); git::Repository repo = view->repo(); QListView *list = new QListView(this); @@ -512,7 +518,7 @@ public: list->setModel(model); QFutureWatcher *watcher = new QFutureWatcher(this); - connect(watcher, &QFutureWatcher::finished, [model, watcher] { + connect(watcher, &QFutureWatcher::finished, this, [model, watcher] { model->setStringList(watcher->result()); watcher->deleteLater(); }); @@ -520,7 +526,7 @@ public: watcher->setFuture(QtConcurrent::run(repo, &git::Repository::lfsTracked)); Footer *footer = new Footer(list); - connect(footer, &Footer::plusClicked, [this, repo, model] { + connect(footer, &Footer::plusClicked, this, [this, repo, model] { QDialog *dialog = new QDialog(this); dialog->setAttribute(Qt::WA_DeleteOnClose); @@ -554,7 +560,7 @@ public: layout->addLayout(form); layout->addWidget(buttons); - connect(pattern, &QLineEdit::textChanged, [track](const QString &text) { + connect(pattern, &QLineEdit::textChanged, this, [track](const QString &text) { track->setEnabled(!text.isEmpty()); }); @@ -567,7 +573,7 @@ public: dialog->open(); }); - connect(footer, &Footer::minusClicked, [this, list, repo, model] { + connect(footer, &Footer::minusClicked, this, [list, repo, model] { git::Repository tmp(repo); QModelIndexList indexes = list->selectionModel()->selectedRows(); foreach (const QModelIndex &index, indexes) { @@ -605,16 +611,18 @@ public: QLineEdit *urlLineEdit = new QLineEdit( map.value("Endpoint").section(" ", 0, 0)); connect(urlLineEdit, &QLineEdit::textChanged, - [this, repo](const QString &text) { - repo.config().setValue("lfs.url", text); + [repo](const QString &text) { + git::Config config = repo.config(); + config.setValue("lfs.url", text); }); // pruneoffsetdays QSpinBox *pruneOffsetDays = new QSpinBox(this); pruneOffsetDays->setValue(map.value("PruneOffsetDays").toInt()); auto signal = QOverload::of(&QSpinBox::valueChanged); - connect(pruneOffsetDays, signal, [this, repo](int value) { - repo.config().setValue("lfs.pruneoffsetdays", value); + connect(pruneOffsetDays, signal, [repo](int value) { + git::Config config = repo.config(); + config.setValue("lfs.pruneoffsetdays", value); }); QHBoxLayout *pruneOffsetLayout = new QHBoxLayout; pruneOffsetLayout->addWidget(pruneOffsetDays); @@ -627,18 +635,20 @@ public: bool fetchRecentEnabled = map.value("FetchRecentAlways").contains("true"); fetchRecentAlways->setChecked(fetchRecentEnabled); connect(fetchRecentAlways, &QCheckBox::toggled, - [settings, repo](bool checked) { - repo.config().setValue("lfs.fetchrecentalways", checked); + [repo](bool checked) { + git::Config config = repo.config(); + config.setValue("lfs.fetchrecentalways", checked); }); // fetchrecentrefsdays QSpinBox *fetchRecentRefsDays = new QSpinBox(this); fetchRecentRefsDays->setValue(map.value("FetchRecentRefsDays").toInt()); fetchRecentRefsDays->setEnabled(fetchRecentEnabled); - connect(fetchRecentRefsDays, signal, [this, repo](int value) { - repo.config().setValue("lfs.fetchrecentrefsdays", value); + connect(fetchRecentRefsDays, signal, [repo](int value) { + git::Config config = repo.config(); + config.setValue("lfs.fetchrecentrefsdays", value); }); - connect(fetchRecentAlways, &QCheckBox::toggled, + connect(fetchRecentAlways, &QCheckBox::toggled, this, [fetchRecentRefsDays](bool checked) { fetchRecentRefsDays->setEnabled(checked); }); @@ -651,10 +661,11 @@ public: QSpinBox *fetchRecentCommitsDays = new QSpinBox(this); fetchRecentCommitsDays->setValue(map.value("FetchRecentCommitsDays").toInt()); fetchRecentCommitsDays->setEnabled(fetchRecentEnabled); - connect(fetchRecentCommitsDays, signal, [this, repo](int value) { - repo.config().setValue("lfs.fetchrecentcommitsdays", value); + connect(fetchRecentCommitsDays, signal, [repo](int value) { + git::Config config = repo.config(); + config.setValue("lfs.fetchrecentcommitsdays", value); }); - connect(fetchRecentAlways, &QCheckBox::toggled, + connect(fetchRecentAlways, &QCheckBox::toggled, this, [fetchRecentCommitsDays](bool checked) { fetchRecentCommitsDays->setEnabled(checked); }); @@ -666,7 +677,7 @@ public: // lfs environment QPushButton *environment = new QPushButton(tr("View Environment")); - connect(environment, &QAbstractButton::clicked, [this, view] { + connect(environment, &QAbstractButton::clicked, this, [view] { git::Repository repo = view->repo(); QDialog *dialog = new QDialog(); @@ -687,7 +698,7 @@ public: }); QPushButton *deinit = new QPushButton(tr("Deinitialize LFS")); - connect(deinit, &QAbstractButton::clicked, [this, view] { + connect(deinit, &QAbstractButton::clicked, this, [this, view] { QString title = tr("Deinitialize LFS?"); QString text = tr("Are you sure you want uninstall LFS from this repository?"); @@ -727,8 +738,6 @@ public: ConfigDialog::ConfigDialog(RepoView *view, Index index) : QDialog(view) { - Application::track("ConfigDialog"); - setMinimumWidth(500); setAttribute(Qt::WA_DeleteOnClose); setContextMenuPolicy(Qt::NoContextMenu); @@ -756,7 +765,7 @@ ConfigDialog::ConfigDialog(RepoView *view, Index index) // Track actions in a group. mActions = new QActionGroup(this); - connect(mActions, &QActionGroup::triggered, [this](QAction *action) { + connect(mActions, &QActionGroup::triggered, this, [this](QAction *action) { mStack->setCurrentIndex(mActions->actions().indexOf(action)); setWindowTitle(action->text()); }); @@ -831,7 +840,7 @@ ConfigDialog::ConfigDialog(RepoView *view, Index index) // Add edit button. QPushButton *edit = buttons->addButton(tr("Edit Config File..."), QDialogButtonBox::ResetRole); - connect(edit, &QPushButton::clicked, this, [this, view, generalPanel] { + connect(edit, &QPushButton::clicked, this, [view, generalPanel] { QString file = view->repo().dir().filePath("config"); if (EditorWindow *window = view->openEditor(file)) connect(window->widget(), &BlameEditor::saved, diff --git a/src/dialogs/SettingsDialog.cpp b/src/dialogs/SettingsDialog.cpp old mode 100644 new mode 100755 index 279708a8..a0837cb4 --- a/src/dialogs/SettingsDialog.cpp +++ b/src/dialogs/SettingsDialog.cpp @@ -120,13 +120,10 @@ public: mStoreCredentials = new QCheckBox( tr("Store credentials in secure storage"), this); - mUsageReporting = new QCheckBox( - tr("Allow collection of usage data"), this); QLabel *privacy = new QLabel(tr("View privacy policy")); connect(privacy, &QLabel::linkActivated, [] { AboutDialog::openSharedInstance(AboutDialog::Privacy); }); - mUsageReporting->setEnabled(false); QFormLayout *form = new QFormLayout; form->addRow(tr("User name:"), mName); @@ -137,7 +134,6 @@ public: form->addRow(QString(), mAutoPrune); form->addRow(tr("Language:"), mNoTranslation); form->addRow(tr("Credentials:"), mStoreCredentials); - form->addRow(tr("Usage reporting:"), mUsageReporting); form->addRow(QString(), privacy); QVBoxLayout *layout = new QVBoxLayout(this); @@ -148,14 +144,16 @@ public: // Connect signals after initializing fields. connect(mName, &QLineEdit::textChanged, [](const QString &text) { - git::Config::global().setValue("user.name", text); + git::Config config = git::Config::global(); + config.setValue("user.name", text); }); connect(mEmail, &QLineEdit::textChanged, [](const QString &text) { - git::Config::global().setValue("user.email", text); + git::Config config = git::Config::global(); + config.setValue("user.email", text); }); - connect(mFetch, &QCheckBox::toggled, [](bool checked) { + connect(mFetch, &QCheckBox::toggled, this, [](bool checked) { Settings::instance()->setValue("global/autofetch/enable", checked); foreach (MainWindow *window, MainWindow::windows()) { for (int i = 0; i < window->count(); ++i) @@ -188,10 +186,6 @@ public: Settings::instance()->setValue("credential/store", checked); delete CredentialHelper::instance(); }); - - connect(mUsageReporting, &QCheckBox::toggled, [](bool checked) { - Settings::instance()->setValue("tracking/enabled", checked); - }); } void init() @@ -214,7 +208,6 @@ public: mNoTranslation->setChecked(settings->value("translation/disable").toBool()); mStoreCredentials->setChecked(settings->value("credential/store").toBool()); - mUsageReporting->setChecked(settings->value("tracking/enabled").toBool()); } private: @@ -228,7 +221,6 @@ private: QCheckBox *mAutoPrune; QCheckBox *mNoTranslation; QCheckBox *mStoreCredentials; - QCheckBox *mUsageReporting; }; class ToolsPanel : public QWidget @@ -242,7 +234,7 @@ public: // external editor QLineEdit *editTool = new QLineEdit(this); editTool->setText(mConfig.value("gui.editor")); - connect(editTool, &QLineEdit::textChanged, [this](const QString &text) { + connect(editTool, &QLineEdit::textChanged, this, [this](const QString &text) { if (text.isEmpty()) { mConfig.remove("gui.editor"); } else { @@ -258,7 +250,7 @@ public: QCheckBox *backup = new QCheckBox(tr("Keep backup of merge files (.orig)"), this); backup->setChecked(mConfig.value("mergetool.keepBackup")); - connect(backup, &QCheckBox::toggled, [this](bool checked) { + connect(backup, &QCheckBox::toggled, this, [this](bool checked) { mConfig.setValue("mergetool.keepBackup", checked); }); @@ -291,16 +283,16 @@ private: // React to combo box selections. auto signal = QOverload::of(&QComboBox::currentIndexChanged); - connect(comboBox, signal, [this, key, comboBox](int index) { + connect(comboBox, signal, this, [this, key, comboBox](int index) { mConfig.setValue(key, comboBox->currentText()); }); QPushButton *configure = new QPushButton(tr("Configure"), this); - connect(configure, &QPushButton::clicked, [this, comboBox, type] { + connect(configure, &QPushButton::clicked, this, [this, comboBox, type] { ExternalToolsDialog *dialog = new ExternalToolsDialog(type, this); // Update combo box when external tools dialog closes. - connect(dialog, &QDialog::finished, [dialog, comboBox, type] { + connect(dialog, &QDialog::finished, this, [comboBox, type] { QString name = comboBox->currentText(); populateExternalTools(comboBox, type); comboBox->setCurrentIndex(comboBox->findText(name)); @@ -380,8 +372,7 @@ public: model->item(comboBox->count() - 1)->setEnabled(false); auto signal = QOverload::of(&QComboBox::currentIndexChanged); - connect(comboBox, signal, [this, parent, comboBox] { - + connect(comboBox, signal, this, [this, parent, comboBox] { //Add new theme if (comboBox->currentIndex() == comboBox->count() - 2) { QDialog dialog; @@ -396,7 +387,7 @@ public: create->setEnabled(false); QLineEdit *nameField = new QLineEdit(&dialog); - connect(nameField, &QLineEdit::textChanged, [this, create, nameField] { + connect(nameField, &QLineEdit::textChanged, this, [create, nameField] { create->setEnabled(!nameField->text().isEmpty()); }); @@ -444,7 +435,7 @@ public: if (mb.clickedButton() == restart) { QWidget *dialog = window(); - QTimer::singleShot(0, [dialog] { + QTimer::singleShot(0, this, [dialog] { // Close the dialog. dialog->close(); @@ -800,7 +791,7 @@ SettingsDialog::SettingsDialog(Index index, QWidget *parent) // Track actions in a group. QActionGroup *actions = new QActionGroup(this); - connect(actions, &QActionGroup::triggered, + connect(actions, &QActionGroup::triggered, this, [this, stack, description, edit](QAction *action) { int index = action->data().toInt(); bool config = (index < Window); @@ -902,8 +893,6 @@ SettingsDialog::SettingsDialog(Index index, QWidget *parent) void SettingsDialog::openSharedInstance(Index index) { - Application::track("SettingsDialog"); - static QPointer dialog; if (dialog) { dialog->show(); diff --git a/src/dialogs/StartDialog.cpp b/src/dialogs/StartDialog.cpp index 30a46e13..e2e6f74e 100644 --- a/src/dialogs/StartDialog.cpp +++ b/src/dialogs/StartDialog.cpp @@ -413,7 +413,7 @@ StartDialog::StartDialog(QWidget *parent) mRepoList = new QListView(this); mRepoList->setIconSize(QSize(32, 32)); mRepoList->setSelectionMode(QAbstractItemView::ExtendedSelection); - connect(mRepoList, &QListView::clicked, [this](const QModelIndex &index) { + connect(mRepoList, &QListView::clicked, this, [this](const QModelIndex &index) { if (!index.data(Qt::UserRole).isValid()) { switch (index.row()) { case RepoModel::Clone: mClone->trigger(); break; @@ -427,12 +427,12 @@ StartDialog::StartDialog(QWidget *parent) RepoModel *repoModel = new RepoModel(mRepoList); mRepoList->setModel(repoModel); - connect(repoModel, &RepoModel::modelReset, [this] { + connect(repoModel, &RepoModel::modelReset, this, [this] { mRepoList->setCurrentIndex(mRepoList->model()->index(0, 0)); }); mRepoFooter = new Footer(mRepoList); - connect(mRepoFooter, &Footer::minusClicked, [this] { + connect(mRepoFooter, &Footer::minusClicked, this, [this] { // Sort selection in reverse order. QModelIndexList indexes = mRepoList->selectionModel()->selectedIndexes(); std::sort(indexes.begin(), indexes.end(), @@ -449,9 +449,9 @@ StartDialog::StartDialog(QWidget *parent) mRepoFooter->setPlusMenu(repoPlusMenu); mClone = repoPlusMenu->addAction(tr("Clone Repository")); - connect(mClone, &QAction::triggered, [this] { + connect(mClone, &QAction::triggered, this, [this] { CloneDialog *dialog = new CloneDialog(CloneDialog::Clone, this); - connect(dialog, &CloneDialog::accepted, [this, dialog] { + connect(dialog, &CloneDialog::accepted, this, [this, dialog] { if (MainWindow *window = openWindow(dialog->path())) window->currentView()->addLogEntry( dialog->message(), dialog->messageTitle()); @@ -460,7 +460,7 @@ StartDialog::StartDialog(QWidget *parent) }); mOpen = repoPlusMenu->addAction(tr("Open Existing Repository")); - connect(mOpen, &QAction::triggered, [this] { + connect(mOpen, &QAction::triggered, this, [this] { // FIXME: Filter out non-git dirs. QFileDialog *dialog = new QFileDialog(this, tr("Open Repository"), QDir::homePath()); @@ -473,9 +473,9 @@ StartDialog::StartDialog(QWidget *parent) }); mInit = repoPlusMenu->addAction(tr("Initialize New Repository")); - connect(mInit, &QAction::triggered, [this] { + connect(mInit, &QAction::triggered, this, [this] { CloneDialog *dialog = new CloneDialog(CloneDialog::Init, this); - connect(dialog, &CloneDialog::accepted, [this, dialog] { + connect(dialog, &CloneDialog::accepted, this, [this, dialog] { if (MainWindow *window = openWindow(dialog->path())) window->currentView()->addLogEntry(dialog->message(), dialog->messageTitle()); }); @@ -486,7 +486,7 @@ StartDialog::StartDialog(QWidget *parent) mRepoFooter->setContextMenu(repoContextMenu); QAction *clear = repoContextMenu->addAction(tr("Clear All")); - connect(clear, &QAction::triggered, [this] { + connect(clear, &QAction::triggered, [] { RecentRepositories::instance()->clear(); }); @@ -496,7 +496,7 @@ StartDialog::StartDialog(QWidget *parent) showFullPath->setCheckable(true); showFullPath->setChecked(recentChecked); repoModel->setShowFullPath(recentChecked); - connect(showFullPath, &QAction::triggered, [repoModel](bool checked) { + connect(showFullPath, &QAction::triggered, this, [repoModel](bool checked) { QSettings().setValue("start/recent/fullpath", checked); repoModel->setShowFullPath(checked); }); @@ -520,13 +520,13 @@ StartDialog::StartDialog(QWidget *parent) mHostTree->setExpandsOnDoubleClick(false); mHostTree->setIconSize(QSize(32, 32)); mHostTree->setSelectionMode(QAbstractItemView::ExtendedSelection); - connect(mHostTree, &QTreeView::clicked, [this](const QModelIndex &index) { + connect(mHostTree, &QTreeView::clicked, this, [this](const QModelIndex &index) { int rows = mHostTree->model()->rowCount(index); if (!rows && !index.data(RepositoryRole).isValid()) edit(index); }); - connect(mHostTree, &QTreeView::doubleClicked, + connect(mHostTree, &QTreeView::doubleClicked, this, [this](const QModelIndex &index) { QModelIndex parent = index.parent(); if (parent.isValid()) { @@ -542,7 +542,7 @@ StartDialog::StartDialog(QWidget *parent) HostModel *hostModel = new HostModel(style(), mHostTree); mHostTree->setModel(hostModel); - connect(hostModel, &QAbstractItemModel::modelReset, [this] { + connect(hostModel, &QAbstractItemModel::modelReset, this, [this] { QModelIndex index = mHostTree->model()->index(0, 0); mHostTree->setRootIsDecorated(index.data(AccountRole).isValid()); mHostTree->expandAll(); @@ -551,14 +551,14 @@ StartDialog::StartDialog(QWidget *parent) mHostTree->setItemDelegate(new ProgressDelegate(this)); mHostFooter = new Footer(mHostTree); - connect(mHostFooter, &Footer::plusClicked, [this] { edit(); }); + connect(mHostFooter, &Footer::plusClicked, this, [this] { edit(); }); connect(mHostFooter, &Footer::minusClicked, this, &StartDialog::remove); QMenu *hostContextMenu = new QMenu(this); mHostFooter->setContextMenu(hostContextMenu); QAction *refresh = hostContextMenu->addAction(tr("Refresh")); - connect(refresh, &QAction::triggered, [] { + connect(refresh, &QAction::triggered, this, [] { Accounts *accounts = Accounts::instance(); for (int i = 0; i < accounts->count(); ++i) accounts->account(i)->connect(); @@ -569,14 +569,14 @@ StartDialog::StartDialog(QWidget *parent) showFullName->setCheckable(true); showFullName->setChecked(remoteChecked); hostModel->setShowFullName(remoteChecked); - connect(showFullName, &QAction::triggered, [hostModel](bool checked) { + connect(showFullName, &QAction::triggered, this, [hostModel](bool checked) { QSettings().setValue("start/remote/fullname", checked); hostModel->setShowFullName(checked); }); // Clear the other list when this selection changes. QItemSelectionModel *repoSelModel = mRepoList->selectionModel(); - connect(repoSelModel, &QItemSelectionModel::selectionChanged, [this] { + connect(repoSelModel, &QItemSelectionModel::selectionChanged, this, [this] { if (!mRepoList->selectionModel()->selectedIndexes().isEmpty()) mHostTree->clearSelection(); updateButtons(); @@ -584,7 +584,7 @@ StartDialog::StartDialog(QWidget *parent) // Clear the other list when this selection changes. QItemSelectionModel *hostSelModel = mHostTree->selectionModel(); - connect(hostSelModel, &QItemSelectionModel::selectionChanged, [this] { + connect(hostSelModel, &QItemSelectionModel::selectionChanged, this, [this] { if (!mHostTree->selectionModel()->selectedIndexes().isEmpty()) mRepoList->clearSelection(); updateButtons(); @@ -671,8 +671,6 @@ void StartDialog::accept() StartDialog *StartDialog::openSharedInstance() { - Application::track("StartDialog"); - static QPointer dialog; if (dialog) { dialog->show(); @@ -776,7 +774,7 @@ void StartDialog::edit(const QModelIndex &index) return; CloneDialog *dialog = new CloneDialog(CloneDialog::Clone, this, repo); - connect(dialog, &CloneDialog::accepted, [this, index, dialog] { + connect(dialog, &CloneDialog::accepted, this, [this, index, dialog] { // Set local path. Account *account = Accounts::instance()->account(index.parent().row()); account->setRepositoryPath(index.row(), dialog->path()); diff --git a/src/ui/AdvancedSearchWidget.cpp b/src/ui/AdvancedSearchWidget.cpp index a693bd94..28728998 100644 --- a/src/ui/AdvancedSearchWidget.cpp +++ b/src/ui/AdvancedSearchWidget.cpp @@ -48,7 +48,7 @@ public: mCalendar->setWindowFlags(Qt::Popup); mCalendar->setVisible(false); - connect(mCalendar, &QCalendarWidget::clicked, [this](const QDate &date) { + connect(mCalendar, &QCalendarWidget::clicked, this, [this](const QDate &date) { setCurrentText(date.toString(Index::dateFormat())); hidePopup(); }); @@ -195,7 +195,6 @@ void AdvancedSearchWidget::accept() } emit accepted(fields.join(' ')); - Application::track("search", "search", "advanced", fields.size()); hide(); } diff --git a/src/ui/RepoView.cpp b/src/ui/RepoView.cpp index b3ad04e5..1f944286 100644 --- a/src/ui/RepoView.cpp +++ b/src/ui/RepoView.cpp @@ -154,8 +154,6 @@ private: RepoView::RepoView(const git::Repository &repo, MainWindow *parent) : QSplitter(Qt::Vertical, parent), mRepo(repo) { - Application::track("RepoView"); - setHandleWidth(0); setAttribute(Qt::WA_DeleteOnClose); @@ -177,12 +175,12 @@ RepoView::RepoView(const git::Repository &repo, MainWindow *parent) // Initialize index. mIndex = new Index(repo, this); SearchField *searchField = toolBar->searchField(); - connect(&mIndexer, &QProcess::started, [searchField] { + connect(&mIndexer, &QProcess::started, this, [searchField] { searchField->setPlaceholderText(tr("Indexing...")); }); using Signal = void (QProcess::*)(int,QProcess::ExitStatus); auto signal = static_cast(&QProcess::finished); - connect(&mIndexer, signal, + connect(&mIndexer, signal, this, [this, searchField](int code, QProcess::ExitStatus status) { Q_UNUSED(code) @@ -202,7 +200,7 @@ RepoView::RepoView(const git::Repository &repo, MainWindow *parent) // Forward indexer stderr. Read from stdout. mIndexer.setProcessChannelMode(QProcess::ForwardedErrorChannel); - connect(&mIndexer, &QProcess::readyReadStandardOutput, [this] { + connect(&mIndexer, &QProcess::readyReadStandardOutput, this, [this] { mIndexer.readAllStandardOutput(); mIndex->reset(); }); @@ -245,7 +243,7 @@ RepoView::RepoView(const git::Repository &repo, MainWindow *parent) menuBar, &MenuBar::updateBranch); // Select HEAD branch when it changes. - connect(notifier, &git::RepositoryNotifier::referenceUpdated, + connect(notifier, &git::RepositoryNotifier::referenceUpdated, this, [this](const git::Reference &ref) { if (ref.isValid() && ref.isHead()) { mRefs->select(ref); @@ -273,7 +271,7 @@ RepoView::RepoView(const git::Repository &repo, MainWindow *parent) this, &RepoView::statusChanged); // Respond to pathspec change. - connect(mPathspec, &PathspecWidget::pathspecChanged, + connect(mPathspec, &PathspecWidget::pathspecChanged, this, [this](const QString &pathspec) { git::Config config = mRepo.appConfig(); mCommits->setPathspec(pathspec, config.value("index.enable", true)); @@ -282,14 +280,14 @@ RepoView::RepoView(const git::Repository &repo, MainWindow *parent) // Respond to search query change. connect(searchField, &SearchField::textChanged, mCommits, &CommitList::setFilter); - connect(mIndex, &Index::indexReset, [this, searchField] { + connect(mIndex, &Index::indexReset, this, [this, searchField] { mCommits->setFilter(searchField->text()); }); mDetails = new DetailView(repo, this); // Respond to diff/tree mode change. - connect(mDetails, &DetailView::viewModeChanged, + connect(mDetails, &DetailView::viewModeChanged, this, [this](ViewMode mode, bool spontaneous) { Q_UNUSED(mode) @@ -308,7 +306,7 @@ RepoView::RepoView(const git::Repository &repo, MainWindow *parent) // FIXME: This is a workaround. connect(notifier, &git::RepositoryNotifier::directoryStaged, this, &RepoView::refresh, Qt::QueuedConnection); - connect(notifier, &git::RepositoryNotifier::directoryAboutToBeStaged, + connect(notifier, &git::RepositoryNotifier::directoryAboutToBeStaged, this, [this](const QString &dir, int count, bool &allow) { if (!Settings::instance()->prompt(Settings::PromptDirectories)) return; @@ -334,7 +332,7 @@ RepoView::RepoView(const git::Repository &repo, MainWindow *parent) }); // large file size warning - connect(notifier, &git::RepositoryNotifier::largeFileAboutToBeStaged, + connect(notifier, &git::RepositoryNotifier::largeFileAboutToBeStaged, this, [this](const QString &file, int size, bool &allow) { if (!Settings::instance()->prompt(Settings::PromptLargeFiles)) return; @@ -381,7 +379,7 @@ RepoView::RepoView(const git::Repository &repo, MainWindow *parent) mDetailSplitter->addWidget(mDetails); mDetailSplitter->setStretchFactor(0, 1); mDetailSplitter->setStretchFactor(1, 3); - connect(mDetailSplitter, &QSplitter::splitterMoved, [this] { + connect(mDetailSplitter, &QSplitter::splitterMoved, this, [this] { QSettings().setValue(kSplitterKey, mDetailSplitter->saveState()); }); @@ -397,7 +395,7 @@ RepoView::RepoView(const git::Repository &repo, MainWindow *parent) this, &RepoView::cancelRemoteTransfer); mLogTimer.setSingleShot(true); - connect(&mLogTimer, &QTimer::timeout, [this] { + connect(&mLogTimer, &QTimer::timeout, this, [this] { setLogVisible(false); }); @@ -442,7 +440,7 @@ RepoView::RepoView(const git::Repository &repo, MainWindow *parent) mDetailSplitter->restoreState(QSettings().value(kSplitterKey).toByteArray()); // Connect automatic fetch timer. - connect(&mFetchTimer, &QTimer::timeout, [this] { + connect(&mFetchTimer, &QTimer::timeout, this, [this] { fetch(git::Remote(), false, false); }); } @@ -785,13 +783,13 @@ Repository *RepoView::remoteRepo() mRemoteRepoCached = true; if (mRemoteRepo) { - auto err = connect(mRemoteRepo->account(), &Account::pullRequestError, + auto err = connect(mRemoteRepo->account(), &Account::pullRequestError, this, [this](const QString &name, const QString &message) { LogEntry *parent = addLogEntry(tr("Pull Request"), tr("Create")); error(parent, tr("create pull request"), name, message); }); - connect(mRemoteRepo, &Repository::destroyed, [this, err] { + connect(mRemoteRepo, &Repository::destroyed, this, [this, err] { disconnect(err); mRemoteRepo = nullptr; mRemoteRepoCached = false; @@ -949,7 +947,7 @@ void RepoView::setLogVisible(bool visible) timeline->setCurveShape(QTimeLine::LinearCurve); timeline->setUpdateInterval(20); - connect(timeline, &QTimeLine::valueChanged, [this, pos](qreal value) { + connect(timeline, &QTimeLine::valueChanged, this, [this, pos](qreal value) { setSizes({1, static_cast(pos * value)}); }); @@ -1700,7 +1698,7 @@ void RepoView::promptToForcePush( QPushButton *accept = dialog->addButton(tr("Force Push"), QMessageBox::AcceptRole); - connect(accept, &QPushButton::clicked, [this, remote, src] { + connect(accept, &QPushButton::clicked, this, [this, remote, src] { push(remote, src, QString(), false, true); }); @@ -1888,7 +1886,7 @@ bool RepoView::commit( QPushButton *accept = dialog->addButton(tr("Commit"), QMessageBox::AcceptRole); - connect(accept, &QPushButton::clicked, [this, message, upstream, parent] { + connect(accept, &QPushButton::clicked, this, [this, message, upstream, parent] { this->commit(message, upstream, parent, true); }); @@ -1970,7 +1968,7 @@ void RepoView::promptToCheckout() { git::Reference ref = reference(); CheckoutDialog *dialog = new CheckoutDialog(mRepo, ref, this); - connect(dialog, &QDialog::accepted, [this, dialog] { + connect(dialog, &QDialog::accepted, this, [this, dialog] { checkout(dialog->reference(), dialog->detach()); }); @@ -2011,7 +2009,7 @@ void RepoView::checkout( QPushButton *checkoutButton = dialog->addButton(tr("Checkout Detached HEAD"), QMessageBox::DestructiveRole); - connect(checkoutButton, &QPushButton::clicked, [this, ref, detach] { + connect(checkoutButton, &QPushButton::clicked, this, [this, ref, detach] { checkout(ref.target(), ref, detach); }); @@ -2025,7 +2023,7 @@ void RepoView::checkout( QPushButton *resetButton = dialog->addButton(tr("Reset Local Branch"), QMessageBox::AcceptRole); - connect(resetButton, &QPushButton::clicked, [this, ref, local] { + connect(resetButton, &QPushButton::clicked, this, [this, ref, local] { createBranch(local, ref.target(), ref, true, true); }); } else { @@ -2040,7 +2038,7 @@ void RepoView::checkout( QPushButton *createButton = dialog->addButton(tr("Create Local Branch"), QMessageBox::AcceptRole); - connect(createButton, &QPushButton::clicked, [this, ref, local] { + connect(createButton, &QPushButton::clicked, this, [this, ref, local] { createBranch(local, ref.target(), ref, true); }); } @@ -2095,7 +2093,7 @@ void RepoView::checkout( void RepoView::promptToCreateBranch(const git::Commit &commit) { NewBranchDialog *dialog = new NewBranchDialog(mRepo, commit, this); - connect(dialog, &QDialog::accepted, [this, dialog] { + connect(dialog, &QDialog::accepted, this, [this, dialog] { createBranch( dialog->name(), dialog->target(), dialog->upstream(), dialog->checkout()); @@ -2303,7 +2301,7 @@ void RepoView::promptToReset( QString buttonText = commitToAmend ? tr("Amend") : tr("Reset"); QPushButton *accept = dialog->addButton(buttonText, QMessageBox::AcceptRole); - connect(accept, &QPushButton::clicked, [this, commit, type, commitToAmend] { + connect(accept, &QPushButton::clicked, this, [this, commit, type, commitToAmend] { reset(commit, type, commitToAmend); // Pre-populate the commit message editor. @@ -2630,7 +2628,7 @@ void RepoView::ignore(const QString &name) if (!file.open(QFile::Append | QFile::Text)) return; - QTextStream(&file) << name << endl; + QTextStream(&file) << name << "\n"; file.close(); refresh(); @@ -2667,14 +2665,14 @@ EditorWindow *RepoView::openEditor( } connect(widget, &BlameEditor::linkActivated, this, &RepoView::visitLink); - connect(widget, &BlameEditor::saved, [this] { + connect(widget, &BlameEditor::saved, this, [this] { // Notify window that the head branch is changed. emit mRepo.notifier()->referenceUpdated(mRepo.head()); }); // Track this window. mTrackedWindows.append(window); - connect(window, &QObject::destroyed, [this, window] { + connect(window, &QObject::destroyed, this, [this, window] { mTrackedWindows.removeAll(window); }); @@ -2869,65 +2867,66 @@ bool RepoView::checkForConflicts(LogEntry *parent, const QString &action) bool RepoView::match(QObject* search, QObject* parent) { - QObjectList children = parent->children(); - for (auto child : children) { - if (child == search) - return true; + QObjectList children = parent->children(); + for (auto child : children) { + if (child == search) + return true; - if (match(search, child)) - return true; - } - return false; + if (match(search, child)) + return true; + } + return false; } RepoView::DetailSplitterWidgets RepoView::detailSplitterMaximize(bool maximized, DetailSplitterWidgets maximizeWidget) { - QWidget* widget = mDetailSplitter->focusWidget(); + QWidget* widget = mDetailSplitter->focusWidget(); - DetailSplitterWidgets newMaximized = DetailSplitterWidgets::NotDefined; + DetailSplitterWidgets newMaximized = DetailSplitterWidgets::NotDefined; - if (maximizeWidget != DetailSplitterWidgets::NotDefined) - newMaximized = maximizeWidget; + if (maximizeWidget != DetailSplitterWidgets::NotDefined) + newMaximized = maximizeWidget; - mMaximized = maximized; + mMaximized = maximized; - if (mMaximized) { - bool found = false; - for (int i=0; i < mDetailSplitter->count(); i++) { - QWidget* w = mDetailSplitter->widget(i); - if (maximizeWidget == DetailSplitterWidgets::SideBar) { - if (w == mSideBar) { - mSideBar->setVisible(true); - found = true; - continue; - } - } else if(maximizeWidget == DetailSplitterWidgets::DetailView) { - if (w == mDetails) { - mDetails->setVisible(true); - found = true; - continue; - } - } else if (!widget) - return DetailSplitterWidgets::NotDefined; - else if (w == widget || match(widget, w)) { - w->setVisible(true); - found = true; - if (w == mSideBar) - newMaximized = DetailSplitterWidgets::SideBar; - else if (w == mDetails) - newMaximized = DetailSplitterWidgets::DetailView; - continue; - } - w->setVisible(false); + if (mMaximized) { + bool found = false; + for (int i=0; i < mDetailSplitter->count(); i++) { + QWidget* w = mDetailSplitter->widget(i); + if (maximizeWidget == DetailSplitterWidgets::SideBar) { + if (w == mSideBar) { + mSideBar->setVisible(true); + found = true; + continue; } - - assert(found); - } else { - for (int i=0; i < mDetailSplitter->count(); i++) - mDetailSplitter->widget(i)->setVisible(true); + } else if(maximizeWidget == DetailSplitterWidgets::DetailView) { + if (w == mDetails) { + mDetails->setVisible(true); + found = true; + continue; + } + } else if (!widget) + return DetailSplitterWidgets::NotDefined; + else if (w == widget || match(widget, w)) { + w->setVisible(true); + found = true; + if (w == mSideBar) + newMaximized = DetailSplitterWidgets::SideBar; + else if (w == mDetails) + newMaximized = DetailSplitterWidgets::DetailView; + continue; + } + w->setVisible(false); } - return newMaximized; + assert(found); + Q_UNUSED(found) + } else { + for (int i=0; i < mDetailSplitter->count(); i++) + mDetailSplitter->widget(i)->setVisible(true); + } + + return newMaximized; } #include "RepoView.moc"