summaryrefslogtreecommitdiff
path: root/src/plugins/debugger/shared/symbolpathsdialog.cpp
blob: f0e07ff4d90a561a4d7f86ae2c2da267e750130a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "symbolpathsdialog.h"

#include "../debuggertr.h"

#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QMessageBox>
#include <QVBoxLayout>

using namespace Utils;

namespace Debugger::Internal {

SymbolPathsDialog::SymbolPathsDialog(QWidget *parent) :
    QDialog(parent)
{
    setWindowTitle(Tr::tr("Set up Symbol Paths", nullptr));

    m_pixmapLabel = new QLabel(this);
    m_pixmapLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    m_pixmapLabel->setAlignment(Qt::AlignHCenter|Qt::AlignTop);
    m_pixmapLabel->setMargin(5);
    m_pixmapLabel->setPixmap(QMessageBox::standardIcon(QMessageBox::Question));

    m_msgLabel = new QLabel(Tr::tr("<html><head/><body><p>The debugger is not configured to use the "
        "public Microsoft Symbol Server.<br/>This is recommended for retrieval of the symbols "
        "of the operating system libraries.</p>"
        "<p><span style=\" font-style:italic;\">Note:</span> It is recommended, that if you use "
        "the Microsoft Symbol Server, to also use a local symbol cache.<br/>"
        "A fast internet connection is required for this to work smoothly,<br/>"
        "and a delay might occur when connecting for the first time and caching the symbols.</p>"
        "<p>What would you like to set up?</p></body></html>"));
    m_msgLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    m_msgLabel->setTextFormat(Qt::RichText);
    m_msgLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);

    m_useLocalSymbolCache = new QCheckBox(Tr::tr("Use Local Symbol Cache"));

    m_useSymbolServer = new QCheckBox(Tr::tr("Use Microsoft Symbol Server"));

    m_pathChooser = new PathChooser;

    auto buttonBox = new QDialogButtonBox;
    buttonBox->setOrientation(Qt::Horizontal);
    buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);

    connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
    connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);

    auto horizontalLayout = new QHBoxLayout();
    horizontalLayout->addWidget(m_pixmapLabel);
    horizontalLayout->addWidget(m_msgLabel);

    auto verticalLayout = new QVBoxLayout(this);
    verticalLayout->addLayout(horizontalLayout);
    verticalLayout->addWidget(m_useLocalSymbolCache);
    verticalLayout->addWidget(m_useSymbolServer);
    verticalLayout->addWidget(m_pathChooser);
    verticalLayout->addWidget(buttonBox);
}

SymbolPathsDialog::~SymbolPathsDialog() = default;

bool SymbolPathsDialog::useSymbolCache() const
{
    return m_useLocalSymbolCache->isChecked();
}

bool SymbolPathsDialog::useSymbolServer() const
{
    return m_useSymbolServer->isChecked();
}

FilePath SymbolPathsDialog::path() const
{
    return m_pathChooser->filePath();
}

void SymbolPathsDialog::setUseSymbolCache(bool useSymbolCache)
{
    m_useLocalSymbolCache->setChecked(useSymbolCache);
}

void SymbolPathsDialog::setUseSymbolServer(bool useSymbolServer)
{
    m_useSymbolServer->setChecked(useSymbolServer);
}

void SymbolPathsDialog::setPath(const FilePath &path)
{
    m_pathChooser->setFilePath(path);
}

bool SymbolPathsDialog::useCommonSymbolPaths(bool &useSymbolCache,
                                             bool &useSymbolServer,
                                             FilePath &path)
{
    SymbolPathsDialog dialog;
    dialog.setUseSymbolCache(useSymbolCache);
    dialog.setUseSymbolServer(useSymbolServer);
    dialog.setPath(path);
    int ret = dialog.exec();
    useSymbolCache = dialog.useSymbolCache();
    useSymbolServer = dialog.useSymbolServer();
    path = dialog.path();
    return ret == QDialog::Accepted;
}

} // Debugger::Internal