File: uisettingsdlg.cpp

package info (click to toggle)
codelite 14.0+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 112,816 kB
  • sloc: cpp: 483,662; ansic: 150,144; php: 9,569; lex: 4,186; python: 3,417; yacc: 2,820; sh: 1,147; makefile: 52; xml: 13
file content (139 lines) | stat: -rw-r--r-- 5,358 bytes parent folder | download | duplicates (3)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright            : (C) 2014 Eran Ifrah
// file name            : uisettingsdlg.cpp
//
// -------------------------------------------------------------------------
// A
//              _____           _      _     _ _
//             /  __ \         | |    | |   (_) |
//             | /  \/ ___   __| | ___| |    _| |_ ___
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
//              \____/\___/ \__,_|\___\_____/_|\__\___|
//
//                                                  F i l e
//
//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 of the License, or
//    (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

#include "imanager.h"
#include "callgraph.h"
#include "uisettingsdlg.h"
#include <wx/filedlg.h>
#include "windowattrmanager.h"

uisettingsdlg::uisettingsdlg(wxWindow* parent, IManager* mgr) //, CallGraph *plugin )
    : uisettings(parent),
      m_mgr(mgr)
{
    // ConfCallGraph confData;
    // read last stored value for paths gprof and dot
    m_mgr->GetConfigTool()->ReadObject(wxT("CallGraph"), &confData);
    m_textCtrl_path_gprof->SetValue(confData.GetGprofPath());
    m_textCtrl_path_dot->SetValue(confData.GetDotPath());
    m_spinCtrl_treshold_edge->SetValue(confData.GetTresholdEdge());
    m_spinCtrl_treshold_node->SetValue(confData.GetTresholdNode());
    m_spinCtrl_colors_node->SetValue(confData.GetColorsNode());
    m_spinCtrl_colors_edge->SetValue(confData.GetColorsEdge());
    m_checkBox_Names->SetValue(confData.GetHideParams());
    m_checkBox_Parameters->SetValue(confData.GetStripParams());
    m_checkBox_Namespaces->SetValue(confData.GetHideNamespaces());
    //
    if(m_checkBox_Names->IsChecked()) m_checkBox_Parameters->Disable();
    if(m_checkBox_Parameters->IsChecked()) m_checkBox_Names->Disable();
    //

    GetSizer()->Fit(this);
    SetName("uisettingsdlg");
    WindowAttrManager::Load(this);
}

uisettingsdlg::~uisettingsdlg() {}

void uisettingsdlg::OnButton_click_select_gprof(wxCommandEvent& event)
{
    wxUnusedVar(event);
    wxString new_gprof_path = wxFileSelector(_("Select gprof..."),
                                             m_textCtrl_path_gprof->GetValue().c_str(),
                                             wxT(""),
                                             wxT(""),
                                             wxFileSelectorDefaultWildcardStr,
                                             0,
                                             this);
    if(!new_gprof_path.IsEmpty()) {
        m_textCtrl_path_gprof->SetValue(new_gprof_path);
    }
}

void uisettingsdlg::OnButton_click_select_dot(wxCommandEvent& event)
{
    wxUnusedVar(event);
    wxString new_dot_path = wxFileSelector(_("Select dot..."),
                                           m_textCtrl_path_dot->GetValue().c_str(),
                                           wxT(""),
                                           wxT(""),
                                           wxFileSelectorDefaultWildcardStr,
                                           0,
                                           this);
    if(!new_dot_path.IsEmpty()) {
        m_textCtrl_path_dot->SetValue(new_dot_path);
    }
}

void uisettingsdlg::OnButton_click_ok(wxCommandEvent& event)
{
    wxUnusedVar(event);
    // store values
    // ConfCallGraph confData;
    confData.SetGprofPath(m_textCtrl_path_gprof->GetValue());
    confData.SetDotPath(m_textCtrl_path_dot->GetValue());
    confData.SetTresholdNode(m_spinCtrl_treshold_node->GetValue());
    confData.SetTresholdEdge(m_spinCtrl_treshold_edge->GetValue());
    confData.SetColorsEdge(m_spinCtrl_colors_edge->GetValue());
    confData.SetColorsNode(m_spinCtrl_colors_node->GetValue());
    confData.SetHideParams(m_checkBox_Names->GetValue());
    confData.SetHideNamespaces(m_checkBox_Namespaces->GetValue());
    confData.SetStripParams(m_checkBox_Parameters->GetValue());

    m_mgr->GetConfigTool()->WriteObject(wxT("CallGraph"), &confData);

    if((wxFileExists(m_textCtrl_path_gprof->GetValue())) && (wxFileExists(m_textCtrl_path_dot->GetValue()))) {
        EndModal(wxID_OK);
    } else {
        wxMessageBox(_("Please check the external tools' paths settings."),
                     wxT("CallGraph"),
                     wxOK | wxICON_ERROR,
                     m_mgr->GetTheApp()->GetTopWindow());
    }

    // event.Skip();
}

void uisettingsdlg::OnButton_click_cancel(wxCommandEvent& event)
{
    wxUnusedVar(event);
    EndModal(wxID_CANCEL);
}

void uisettingsdlg::OnCheckName(wxCommandEvent& event)
{
    if(m_checkBox_Names->IsChecked())
        m_checkBox_Parameters->Disable();
    else
        m_checkBox_Parameters->Enable();
}

void uisettingsdlg::OnCheckParam(wxCommandEvent& event)
{
    if(m_checkBox_Parameters->IsChecked())
        m_checkBox_Names->Disable();
    else
        m_checkBox_Names->Enable();
}