mirror of
https://github.com/Murmele/Gittyup.git
synced 2024-09-11 10:45:39 +03:00
Add usage reporting setting to the 'General' preferences panel
Addresses #281.
This commit is contained in:
parent
7d4b14dd5d
commit
bc3b47e1b2
3
conf/tracking.lua
Normal file
3
conf/tracking.lua
Normal file
@ -0,0 +1,3 @@
|
||||
return {
|
||||
enabled = true
|
||||
}
|
@ -48,7 +48,7 @@ public:
|
||||
bool isWhitespaceIgnored() const;
|
||||
void setWhitespaceIgnored(bool ignored);
|
||||
|
||||
// Last repository path
|
||||
// last repository path
|
||||
QString lastPath() const;
|
||||
void setLastPath(const QString &lastPath);
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QPointer>
|
||||
#include <QSettings>
|
||||
#include <QTabBar>
|
||||
#include <QTextBrowser>
|
||||
#include <QVBoxLayout>
|
||||
@ -40,7 +39,7 @@ const QString kSubtitleFmt =
|
||||
|
||||
const QString kTextFmt =
|
||||
"<p style='white-space: nowrap'><b style='font-size: large'>%1 v%2</b> - %3 - %4<br>"
|
||||
"Copyright © 2016-2018 Scientific Toolworks, Inc. All rights reserved.</p>"
|
||||
"Copyright © 2016-2019 Scientific Toolworks, Inc. All rights reserved.</p>"
|
||||
"<p> If you have a question that might benefit the community, consider "
|
||||
"asking it on <a href='%5'>Stack Overflow</a> by including 'gitahead' in the "
|
||||
"tags. Otherwise, contact us at <a href='mailto:%6'>%6</a>";
|
||||
@ -92,10 +91,10 @@ AboutDialog::AboutDialog(QWidget *parent)
|
||||
label->setTextInteractionFlags(kTextFlags);
|
||||
connect(label, &QLabel::linkActivated, QDesktopServices::openUrl);
|
||||
|
||||
QTabBar *tabs = new QTabBar(this);
|
||||
tabs->setTabData(tabs->addTab(tr("Changelog")), "changelog.html");
|
||||
tabs->setTabData(tabs->addTab(tr("Acknowledgments")), "acknowledgments.html");
|
||||
tabs->setTabData(tabs->addTab(tr("Privacy")), "privacy.html");
|
||||
mTabs = new QTabBar(this);
|
||||
mTabs->setTabData(mTabs->addTab(tr("Changelog")), "changelog.html");
|
||||
mTabs->setTabData(mTabs->addTab(tr("Acknowledgments")), "acknowledgments.html");
|
||||
mTabs->setTabData(mTabs->addTab(tr("Privacy")), "privacy.html");
|
||||
|
||||
QTextBrowser *browser = new QTextBrowser(this);
|
||||
browser->setOpenLinks(false);
|
||||
@ -104,30 +103,30 @@ AboutDialog::AboutDialog(QWidget *parent)
|
||||
connect(browser, &QTextBrowser::anchorClicked, [this](const QUrl &url) {
|
||||
if (url.isLocalFile() &&
|
||||
QFileInfo(url.toLocalFile()).fileName() == "opt-out") {
|
||||
QSettings().setValue("tracking/enabled", false);
|
||||
Settings::instance()->setValue("tracking/enabled", false);
|
||||
QString text =
|
||||
tr("Usage tracking has been disabled. Restart "
|
||||
"the app for changes to take effect.");
|
||||
QMessageBox::information(this, tr("Usage Tracking Disabled"), 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(tabs, &QTabBar::currentChanged, [tabs, browser](int index) {
|
||||
QString url = Settings::docDir().filePath(tabs->tabData(index).toString());
|
||||
connect(mTabs, &QTabBar::currentChanged, [this, browser](int index) {
|
||||
QString url = Settings::docDir().filePath(mTabs->tabData(index).toString());
|
||||
browser->setSource(QUrl::fromLocalFile(url));
|
||||
});
|
||||
|
||||
// Load the initial content.
|
||||
emit tabs->currentChanged(tabs->currentIndex());
|
||||
emit mTabs->currentChanged(mTabs->currentIndex());
|
||||
|
||||
QVBoxLayout *right = new QVBoxLayout;
|
||||
right->setSpacing(0);
|
||||
right->addWidget(label);
|
||||
right->addSpacing(12);
|
||||
right->addWidget(tabs, 0, TAB_BAR_ALIGNMENT);
|
||||
right->addWidget(mTabs, 0, TAB_BAR_ALIGNMENT);
|
||||
right->addWidget(browser);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
@ -136,16 +135,22 @@ AboutDialog::AboutDialog(QWidget *parent)
|
||||
layout->addLayout(right);
|
||||
}
|
||||
|
||||
void AboutDialog::openSharedInstance()
|
||||
void AboutDialog::openSharedInstance(Index index)
|
||||
{
|
||||
static QPointer<AboutDialog> dialog;
|
||||
if (dialog) {
|
||||
dialog->show();
|
||||
dialog->raise();
|
||||
dialog->activateWindow();
|
||||
return;
|
||||
} else {
|
||||
dialog = new AboutDialog;
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
dialog = new AboutDialog;
|
||||
dialog->show();
|
||||
dialog->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void AboutDialog::setCurrentIndex(Index index)
|
||||
{
|
||||
mTabs->setCurrentIndex(index);
|
||||
}
|
||||
|
@ -12,12 +12,26 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QTabBar;
|
||||
|
||||
class AboutDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
enum Index
|
||||
{
|
||||
Changelog,
|
||||
Acknowledgments,
|
||||
Privacy
|
||||
};
|
||||
|
||||
AboutDialog(QWidget *parent = nullptr);
|
||||
|
||||
static void openSharedInstance();
|
||||
static void openSharedInstance(Index index = Changelog);
|
||||
|
||||
private:
|
||||
void setCurrentIndex(Index index);
|
||||
|
||||
QTabBar *mTabs;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -8,6 +8,7 @@
|
||||
//
|
||||
|
||||
#include "SettingsDialog.h"
|
||||
#include "AboutDialog.h"
|
||||
#include "DiffPanel.h"
|
||||
#include "ExternalToolsDialog.h"
|
||||
#include "PluginsPanel.h"
|
||||
@ -115,6 +116,13 @@ 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("<a href='view'>View privacy policy</a>"));
|
||||
connect(privacy, &QLabel::linkActivated, [] {
|
||||
AboutDialog::openSharedInstance(AboutDialog::Privacy);
|
||||
});
|
||||
|
||||
QFormLayout *form = new QFormLayout;
|
||||
form->addRow(tr("User name:"), mName);
|
||||
form->addRow(tr("User email:"), mEmail);
|
||||
@ -122,6 +130,8 @@ public:
|
||||
form->addRow(QString(), mPushCommit);
|
||||
form->addRow(QString(), mPullUpdate);
|
||||
form->addRow(tr("Credentials:"), mStoreCredentials);
|
||||
form->addRow(tr("Usage reporting:"), mUsageReporting);
|
||||
form->addRow(QString(), privacy);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(16,12,16,12);
|
||||
@ -163,6 +173,10 @@ public:
|
||||
Settings::instance()->setValue("credential/store", checked);
|
||||
delete CredentialHelper::instance();
|
||||
});
|
||||
|
||||
connect(mUsageReporting, &QCheckBox::toggled, [](bool checked) {
|
||||
Settings::instance()->setValue("tracking/enabled", checked);
|
||||
});
|
||||
}
|
||||
|
||||
void init()
|
||||
@ -183,6 +197,7 @@ public:
|
||||
settings->endGroup();
|
||||
|
||||
mStoreCredentials->setChecked(settings->value("credential/store").toBool());
|
||||
mUsageReporting->setChecked(settings->value("tracking/enabled").toBool());
|
||||
}
|
||||
|
||||
private:
|
||||
@ -194,6 +209,7 @@ private:
|
||||
QCheckBox *mPushCommit;
|
||||
QCheckBox *mPullUpdate;
|
||||
QCheckBox *mStoreCredentials;
|
||||
QCheckBox *mUsageReporting;
|
||||
};
|
||||
|
||||
class ToolsPanel : public QWidget
|
||||
|
@ -633,7 +633,9 @@ MenuBar::MenuBar(QWidget *parent)
|
||||
QString name = QCoreApplication::applicationName();
|
||||
QAction *about = help->addAction(tr("About %1").arg(name));
|
||||
about->setMenuRole(QAction::AboutRole);
|
||||
connect(about, &QAction::triggered, &AboutDialog::openSharedInstance);
|
||||
connect(about, &QAction::triggered, [] {
|
||||
AboutDialog::openSharedInstance();
|
||||
});
|
||||
|
||||
QAction *update = help->addAction(tr("Check For Updates..."));
|
||||
update->setMenuRole(QAction::ApplicationSpecificRole);
|
||||
|
Loading…
Reference in New Issue
Block a user