GUI: fix path issue with backslashes. hide non-premium setting in premium settings dialog.
This commit is contained in:
parent
6df8573e15
commit
5c10cfd59e
|
@ -72,6 +72,16 @@
|
||||||
static const QString OnlineHelpURL("https://cppcheck.sourceforge.io/manual.html");
|
static const QString OnlineHelpURL("https://cppcheck.sourceforge.io/manual.html");
|
||||||
static const QString compile_commands_json("compile_commands.json");
|
static const QString compile_commands_json("compile_commands.json");
|
||||||
|
|
||||||
|
static QString fromNativePath(const QString& p) {
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
QString ret(p);
|
||||||
|
ret.replace('\\', '/');
|
||||||
|
return ret;
|
||||||
|
#else
|
||||||
|
return p;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
|
MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
|
||||||
mSettings(settings),
|
mSettings(settings),
|
||||||
mApplications(new ApplicationList(this)),
|
mApplications(new ApplicationList(this)),
|
||||||
|
@ -913,7 +923,7 @@ Settings MainWindow::getCppcheckSettings()
|
||||||
if (!mProjectFile->getImportProject().isEmpty())
|
if (!mProjectFile->getImportProject().isEmpty())
|
||||||
result.checkAllConfigurations = false;
|
result.checkAllConfigurations = false;
|
||||||
|
|
||||||
const QString &buildDir = mProjectFile->getBuildDir();
|
const QString &buildDir = fromNativePath(mProjectFile->getBuildDir());
|
||||||
if (!buildDir.isEmpty()) {
|
if (!buildDir.isEmpty()) {
|
||||||
if (QDir(buildDir).isAbsolute()) {
|
if (QDir(buildDir).isAbsolute()) {
|
||||||
result.buildDir = buildDir.toStdString();
|
result.buildDir = buildDir.toStdString();
|
||||||
|
@ -949,7 +959,7 @@ Settings MainWindow::getCppcheckSettings()
|
||||||
result.checkUnknownFunctionReturn.insert(s.toStdString());
|
result.checkUnknownFunctionReturn.insert(s.toStdString());
|
||||||
|
|
||||||
QString filesDir(getDataDir());
|
QString filesDir(getDataDir());
|
||||||
const QString pythonCmd = mSettings->value(SETTINGS_PYTHON_PATH).toString();
|
const QString pythonCmd = fromNativePath(mSettings->value(SETTINGS_PYTHON_PATH).toString());
|
||||||
for (const QString& addon : mProjectFile->getAddons()) {
|
for (const QString& addon : mProjectFile->getAddons()) {
|
||||||
QString addonFilePath = ProjectFile::getAddonFilePath(filesDir, addon);
|
QString addonFilePath = ProjectFile::getAddonFilePath(filesDir, addon);
|
||||||
if (addonFilePath.isEmpty())
|
if (addonFilePath.isEmpty())
|
||||||
|
@ -961,7 +971,7 @@ Settings MainWindow::getCppcheckSettings()
|
||||||
json += "{ \"script\":\"" + addonFilePath + "\"";
|
json += "{ \"script\":\"" + addonFilePath + "\"";
|
||||||
if (!pythonCmd.isEmpty())
|
if (!pythonCmd.isEmpty())
|
||||||
json += ", \"python\":\"" + pythonCmd + "\"";
|
json += ", \"python\":\"" + pythonCmd + "\"";
|
||||||
QString misraFile = mSettings->value(SETTINGS_MISRA_FILE).toString();
|
QString misraFile = fromNativePath(mSettings->value(SETTINGS_MISRA_FILE).toString());
|
||||||
if (addon == "misra" && !misraFile.isEmpty()) {
|
if (addon == "misra" && !misraFile.isEmpty()) {
|
||||||
QString arg;
|
QString arg;
|
||||||
if (misraFile.endsWith(".pdf", Qt::CaseInsensitive))
|
if (misraFile.endsWith(".pdf", Qt::CaseInsensitive))
|
||||||
|
@ -1102,7 +1112,7 @@ void MainWindow::checkLockDownUI()
|
||||||
|
|
||||||
void MainWindow::programSettings()
|
void MainWindow::programSettings()
|
||||||
{
|
{
|
||||||
SettingsDialog dialog(mApplications, mTranslation, this);
|
SettingsDialog dialog(mApplications, mTranslation, isCppcheckPremium(), this);
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
dialog.saveSettingValues();
|
dialog.saveSettingValues();
|
||||||
mSettings->sync();
|
mSettings->sync();
|
||||||
|
|
|
@ -37,12 +37,14 @@
|
||||||
|
|
||||||
SettingsDialog::SettingsDialog(ApplicationList *list,
|
SettingsDialog::SettingsDialog(ApplicationList *list,
|
||||||
TranslationHandler *translator,
|
TranslationHandler *translator,
|
||||||
|
bool premium,
|
||||||
QWidget *parent) :
|
QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
mApplications(list),
|
mApplications(list),
|
||||||
mTempApplications(new ApplicationList(this)),
|
mTempApplications(new ApplicationList(this)),
|
||||||
mTranslator(translator),
|
mTranslator(translator),
|
||||||
mUI(new Ui::Settings)
|
mUI(new Ui::Settings),
|
||||||
|
mPremium(premium)
|
||||||
{
|
{
|
||||||
mUI->setupUi(this);
|
mUI->setupUi(this);
|
||||||
mUI->mPythonPathWarning->setStyleSheet("color: red");
|
mUI->mPythonPathWarning->setStyleSheet("color: red");
|
||||||
|
@ -63,6 +65,10 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
|
||||||
mUI->mCheckForUpdates->setCheckState(boolToCheckState(settings.value(SETTINGS_CHECK_FOR_UPDATES, false).toBool()));
|
mUI->mCheckForUpdates->setCheckState(boolToCheckState(settings.value(SETTINGS_CHECK_FOR_UPDATES, false).toBool()));
|
||||||
mUI->mEditPythonPath->setText(settings.value(SETTINGS_PYTHON_PATH, QString()).toString());
|
mUI->mEditPythonPath->setText(settings.value(SETTINGS_PYTHON_PATH, QString()).toString());
|
||||||
validateEditPythonPath();
|
validateEditPythonPath();
|
||||||
|
if (premium)
|
||||||
|
mUI->mEditMisraFile->setVisible(false);
|
||||||
|
else
|
||||||
|
mUI->mEditMisraFile->setText(settings.value(SETTINGS_MISRA_FILE, QString()).toString());
|
||||||
mUI->mEditMisraFile->setText(settings.value(SETTINGS_MISRA_FILE, QString()).toString());
|
mUI->mEditMisraFile->setText(settings.value(SETTINGS_MISRA_FILE, QString()).toString());
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
|
@ -45,6 +45,7 @@ class SettingsDialog : public QDialog {
|
||||||
public:
|
public:
|
||||||
SettingsDialog(ApplicationList *list,
|
SettingsDialog(ApplicationList *list,
|
||||||
TranslationHandler *translator,
|
TranslationHandler *translator,
|
||||||
|
bool premium,
|
||||||
QWidget *parent = nullptr);
|
QWidget *parent = nullptr);
|
||||||
SettingsDialog(const SettingsDialog &) = delete;
|
SettingsDialog(const SettingsDialog &) = delete;
|
||||||
~SettingsDialog() override;
|
~SettingsDialog() override;
|
||||||
|
@ -238,6 +239,8 @@ private:
|
||||||
void manageStyleControls();
|
void manageStyleControls();
|
||||||
|
|
||||||
static const int mLangCodeRole = Qt::UserRole;
|
static const int mLangCodeRole = Qt::UserRole;
|
||||||
|
|
||||||
|
bool mPremium;
|
||||||
};
|
};
|
||||||
/// @}
|
/// @}
|
||||||
#endif // SETTINGSDIALOG_H
|
#endif // SETTINGSDIALOG_H
|
||||||
|
|
Loading…
Reference in New Issue