KiCad PCB EDA Suite
KIDIALOG Class Reference

Helper class to create more flexible dialogs, including 'do not show again' checkbox handling. More...

#include <confirm.h>

Inheritance diagram for KIDIALOG:

Public Types

enum  KD_TYPE {
  KD_NONE, KD_INFO, KD_QUESTION, KD_WARNING,
  KD_ERROR
}
 

Dialog type. Selects appropriate icon and default dialog title

More...
 

Public Member Functions

 KIDIALOG (wxWindow *aParent, const wxString &aMessage, const wxString &aCaption, long aStyle=wxOK)
 
 KIDIALOG (wxWindow *aParent, const wxString &aMessage, KD_TYPE aType, const wxString &aCaption="")
 
void DoNotShowCheckbox (wxString file, int line)
 

Shows the 'do not show again' checkbox

More...
 
bool DoNotShowAgain () const
 

Checks the 'do not show again' setting for the dialog

More...
 
void ForceShowAgain ()
 
bool Show (bool aShow=true) override
 
int ShowModal () override
 

Static Protected Member Functions

static wxString getCaption (KD_TYPE aType, const wxString &aCaption)
 
static long getStyle (KD_TYPE aType)
 

Protected Attributes

unsigned long m_hash
 

Unique identifier of the dialog

More...
 

Detailed Description

Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.

Definition at line 44 of file confirm.h.

Member Enumeration Documentation

◆ KD_TYPE

Dialog type. Selects appropriate icon and default dialog title

Enumerator
KD_NONE 
KD_INFO 
KD_QUESTION 
KD_WARNING 
KD_ERROR 

Definition at line 48 of file confirm.h.

Constructor & Destructor Documentation

◆ KIDIALOG() [1/2]

KIDIALOG::KIDIALOG ( wxWindow *  aParent,
const wxString &  aMessage,
const wxString &  aCaption,
long  aStyle = wxOK 
)

Definition at line 37 of file confirm.cpp.

39  : wxRichMessageDialog( aParent, aMessage, aCaption, aStyle | wxCENTRE | wxSTAY_ON_TOP ),
40  m_hash( 0 )
41 {
42 }
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:67

◆ KIDIALOG() [2/2]

KIDIALOG::KIDIALOG ( wxWindow *  aParent,
const wxString &  aMessage,
KD_TYPE  aType,
const wxString &  aCaption = "" 
)

Definition at line 45 of file confirm.cpp.

47  : wxRichMessageDialog( aParent, aMessage, getCaption( aType, aCaption ), getStyle( aType ) ),
48  m_hash( 0 )
49 {
50 }
static wxString getCaption(KD_TYPE aType, const wxString &aCaption)
Definition: confirm.cpp:113
static long getStyle(KD_TYPE aType)
Definition: confirm.cpp:131
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:67

Member Function Documentation

◆ DoNotShowAgain()

bool KIDIALOG::DoNotShowAgain ( ) const

Checks the 'do not show again' setting for the dialog

Definition at line 61 of file confirm.cpp.

62 {
63  return doNotShowAgainDlgs.count( m_hash ) > 0;
64 }
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:34
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:67

References doNotShowAgainDlgs, and m_hash.

◆ DoNotShowCheckbox()

◆ ForceShowAgain()

void KIDIALOG::ForceShowAgain ( )

Definition at line 67 of file confirm.cpp.

68 {
69  doNotShowAgainDlgs.erase( m_hash );
70 }
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:34
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:67

References doNotShowAgainDlgs, and m_hash.

◆ getCaption()

wxString KIDIALOG::getCaption ( KD_TYPE  aType,
const wxString &  aCaption 
)
staticprotected

Definition at line 113 of file confirm.cpp.

114 {
115  if( !aCaption.IsEmpty() )
116  return aCaption;
117 
118  switch( aType )
119  {
120  case KD_NONE: /* fall through */
121  case KD_INFO: return _( "Message" );
122  case KD_QUESTION: return _( "Question" );
123  case KD_WARNING: return _( "Warning" );
124  case KD_ERROR: return _( "Error" );
125  }
126 
127  return wxEmptyString;
128 }
#define _(s)

References _, KD_ERROR, KD_INFO, KD_NONE, KD_QUESTION, and KD_WARNING.

◆ getStyle()

long KIDIALOG::getStyle ( KD_TYPE  aType)
staticprotected

Definition at line 131 of file confirm.cpp.

132 {
133  long style = wxOK | wxCENTRE | wxSTAY_ON_TOP;
134 
135  switch( aType )
136  {
137  case KD_NONE: break;
138  case KD_INFO: style |= wxICON_INFORMATION; break;
139  case KD_QUESTION: style |= wxICON_QUESTION; break;
140  case KD_WARNING: style |= wxICON_WARNING; break;
141  case KD_ERROR: style |= wxICON_ERROR; break;
142  }
143 
144  return style;
145 }

References KD_ERROR, KD_INFO, KD_NONE, KD_QUESTION, and KD_WARNING.

◆ Show()

bool KIDIALOG::Show ( bool  aShow = true)
override

Definition at line 73 of file confirm.cpp.

74 {
75  // We should check the do-not-show-again setting only when the dialog is displayed
76  if( aShow )
77  {
78  // Check if this dialog should be shown to the user
79  auto it = doNotShowAgainDlgs.find( m_hash );
80 
81  if( it != doNotShowAgainDlgs.end() )
82  return it->second;
83  }
84 
85  bool ret = wxRichMessageDialog::Show( aShow );
86 
87  // Has the user asked not to show the dialog again
88  if( IsCheckBoxChecked() )
90 
91  return ret;
92 }
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:34
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:67

References doNotShowAgainDlgs, and m_hash.

◆ ShowModal()

int KIDIALOG::ShowModal ( )
override

Definition at line 95 of file confirm.cpp.

96 {
97  // Check if this dialog should be shown to the user
98  auto it = doNotShowAgainDlgs.find( m_hash );
99 
100  if( it != doNotShowAgainDlgs.end() )
101  return it->second;
102 
103  int ret = wxRichMessageDialog::ShowModal();
104 
105  // Has the user asked not to show the dialog again
106  if( IsCheckBoxChecked() )
107  doNotShowAgainDlgs[m_hash] = ret;
108 
109  return ret;
110 }
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:34
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:67

References doNotShowAgainDlgs, and m_hash.

Referenced by DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), LIB_EDIT_FRAME::ExportPart(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), LEGACY_PLUGIN::loadZONE_CONTAINER(), KICAD_MANAGER_CONTROL::NewFromTemplate(), DIALOG_ANNOTATE::OnApplyClick(), DIALOG_ANNOTATE::OnClearAnnotationCmpClick(), DIALOG_CONFIGURE_PATHS::OnGridCellChanging(), KICAD_MANAGER_FRAME::OnImportEagleFiles(), PCB_PARSER::parseZONE_CONTAINER(), ROUTER_TOOL::performDragging(), LIB_PIN_TOOL::PlacePin(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), PNS_KICAD_IFACE::syncZone(), and DIALOG_GENCAD_EXPORT_OPTIONS::TransferDataFromWindow().

Member Data Documentation

◆ m_hash

unsigned long KIDIALOG::m_hash
protected

Unique identifier of the dialog

Definition at line 67 of file confirm.h.

Referenced by DoNotShowAgain(), DoNotShowCheckbox(), ForceShowAgain(), Show(), and ShowModal().


The documentation for this class was generated from the following files: