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 45 of file confirm.cpp.

47  : wxRichMessageDialog( aParent, aMessage, aCaption, aStyle | wxCENTRE | wxSTAY_ON_TOP ),
48  m_hash( 0 )
49 {
50 }
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:65

◆ KIDIALOG() [2/2]

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

Definition at line 53 of file confirm.cpp.

55  : wxRichMessageDialog( aParent, aMessage, getCaption( aType, aCaption ), getStyle( aType ) ),
56  m_hash( 0 )
57 {
58 }
static wxString getCaption(KD_TYPE aType, const wxString &aCaption)
Definition: confirm.cpp:121
static long getStyle(KD_TYPE aType)
Definition: confirm.cpp:139
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:65

Member Function Documentation

◆ DoNotShowAgain()

bool KIDIALOG::DoNotShowAgain ( ) const

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

Definition at line 69 of file confirm.cpp.

70 {
71  return doNotShowAgainDlgs.count( m_hash ) > 0;
72 }
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:42
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:65

References doNotShowAgainDlgs, and m_hash.

◆ DoNotShowCheckbox()

◆ ForceShowAgain()

void KIDIALOG::ForceShowAgain ( )

Definition at line 75 of file confirm.cpp.

76 {
77  doNotShowAgainDlgs.erase( m_hash );
78 }
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:42
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:65

References doNotShowAgainDlgs, and m_hash.

◆ getCaption()

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

Definition at line 121 of file confirm.cpp.

122 {
123  if( !aCaption.IsEmpty() )
124  return aCaption;
125 
126  switch( aType )
127  {
128  case KD_NONE: /* fall through */
129  case KD_INFO: return _( "Message" );
130  case KD_QUESTION: return _( "Question" );
131  case KD_WARNING: return _( "Warning" );
132  case KD_ERROR: return _( "Error" );
133  }
134 
135  return wxEmptyString;
136 }

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

◆ getStyle()

long KIDIALOG::getStyle ( KD_TYPE  aType)
staticprotected

Definition at line 139 of file confirm.cpp.

140 {
141  long style = wxOK | wxCENTRE | wxSTAY_ON_TOP;
142 
143  switch( aType )
144  {
145  case KD_NONE: break;
146  case KD_INFO: style |= wxICON_INFORMATION; break;
147  case KD_QUESTION: style |= wxICON_QUESTION; break;
148  case KD_WARNING: style |= wxICON_WARNING; break;
149  case KD_ERROR: style |= wxICON_ERROR; break;
150  }
151 
152  return style;
153 }

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

◆ Show()

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

Definition at line 81 of file confirm.cpp.

82 {
83  // We should check the do-not-show-again setting only when the dialog is displayed
84  if( aShow )
85  {
86  // Check if this dialog should be shown to the user
87  auto it = doNotShowAgainDlgs.find( m_hash );
88 
89  if( it != doNotShowAgainDlgs.end() )
90  return it->second;
91  }
92 
93  bool ret = wxRichMessageDialog::Show( aShow );
94 
95  // Has the user asked not to show the dialog again
96  if( IsCheckBoxChecked() )
98 
99  return ret;
100 }
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:42
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:65

References doNotShowAgainDlgs, and m_hash.

◆ ShowModal()

int KIDIALOG::ShowModal ( )
override

Definition at line 103 of file confirm.cpp.

104 {
105  // Check if this dialog should be shown to the user
106  auto it = doNotShowAgainDlgs.find( m_hash );
107 
108  if( it != doNotShowAgainDlgs.end() )
109  return it->second;
110 
111  int ret = wxRichMessageDialog::ShowModal();
112 
113  // Has the user asked not to show the dialog again
114  if( IsCheckBoxChecked() )
115  doNotShowAgainDlgs[m_hash] = ret;
116 
117  return ret;
118 }
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
Definition: confirm.cpp:42
unsigned long m_hash
Unique identifier of the dialog
Definition: confirm.h:65

References doNotShowAgainDlgs, and m_hash.

Referenced by DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), LEGACY_PLUGIN::loadZONE_CONTAINER(), DIALOG_ANNOTATE::OnApplyClick(), DIALOG_ANNOTATE::OnClearAnnotationCmpClick(), KICAD_MANAGER_FRAME::OnCreateProjectFromTemplate(), LIB_EDIT_FRAME::OnExportPart(), 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 65 of file confirm.h.

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


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