Auto-start on logon feature added

(closes #8)
This commit is contained in:
Simon Rozman 2016-04-29 09:51:40 +02:00
parent c7df06ba1e
commit 38bf070a4a
7 changed files with 144 additions and 54 deletions

View File

@ -137,6 +137,25 @@
<property name="label">&amp;Program</property> <property name="label">&amp;Program</property>
<property name="name">m_menuProgram</property> <property name="name">m_menuProgram</property>
<property name="permission">protected</property> <property name="permission">protected</property>
<object class="wxMenuItem" expanded="0">
<property name="bitmap"></property>
<property name="checked">0</property>
<property name="enabled">1</property>
<property name="help">Start this program automatically on logon</property>
<property name="id">wxID_AUTOSTART</property>
<property name="kind">wxITEM_CHECK</property>
<property name="label">&amp;Start on Logon</property>
<property name="name">m_menuItemAutoStart</property>
<property name="permission">none</property>
<property name="shortcut"></property>
<property name="unchecked_bitmap"></property>
<event name="OnMenuSelection"></event>
<event name="OnUpdateUI"></event>
</object>
<object class="separator" expanded="0">
<property name="name">m_separatorProgram1</property>
<property name="permission">none</property>
</object>
<object class="wxMenuItem" expanded="0"> <object class="wxMenuItem" expanded="0">
<property name="bitmap"></property> <property name="bitmap"></property>
<property name="checked">0</property> <property name="checked">0</property>

View File

@ -1,8 +1,8 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: ZRCola\n" "Project-Id-Version: ZRCola\n"
"POT-Creation-Date: 2016-04-23 22:20+0200\n" "POT-Creation-Date: 2016-04-29 09:43+0200\n"
"PO-Revision-Date: 2016-04-23 22:22+0200\n" "PO-Revision-Date: 2016-04-29 09:44+0200\n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n" "Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n" "Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n"
"Language: sl_SI\n" "Language: sl_SI\n"
@ -17,12 +17,12 @@ msgstr ""
"X-Poedit-KeywordsList: _\n" "X-Poedit-KeywordsList: _\n"
"X-Poedit-SearchPath-0: .\n" "X-Poedit-SearchPath-0: .\n"
#: zrcolafrm.cpp:70 #: zrcolafrm.cpp:73
#, c-format #, c-format
msgid "Select %s language for decomposition" msgid "Select %s language for decomposition"
msgstr "Izberi jezik %s za razstavljanje" msgstr "Izberi jezik %s za razstavljanje"
#: zrcolafrm.cpp:81 #: zrcolafrm.cpp:84
msgid "" msgid ""
"ZRCola keyboard shortcut Win+F5 could not be registered. Some functionality " "ZRCola keyboard shortcut Win+F5 could not be registered. Some functionality "
"will not be available." "will not be available."
@ -30,11 +30,11 @@ msgstr ""
"ZRColine bližnjice na tipkovnici Win+F5 ni mogoče registrirati. Nekaj " "ZRColine bližnjice na tipkovnici Win+F5 ni mogoče registrirati. Nekaj "
"funkcionalnosti ne bo na voljo." "funkcionalnosti ne bo na voljo."
#: zrcolafrm.cpp:81 zrcolafrm.cpp:83 #: zrcolafrm.cpp:84 zrcolafrm.cpp:86
msgid "Warning" msgid "Warning"
msgstr "Opozorilo" msgstr "Opozorilo"
#: zrcolafrm.cpp:83 #: zrcolafrm.cpp:86
msgid "" msgid ""
"ZRCola keyboard shortcut Win+F6 could not be registered. Some functionality " "ZRCola keyboard shortcut Win+F6 could not be registered. Some functionality "
"will not be available." "will not be available."
@ -42,7 +42,11 @@ msgstr ""
"ZRColine bližnjice na tipkovnici Win+F6 ni mogoče registrirati. Nekaj " "ZRColine bližnjice na tipkovnici Win+F6 ni mogoče registrirati. Nekaj "
"funkcionalnosti ne bo na voljo." "funkcionalnosti ne bo na voljo."
#: zrcolafrm.cpp:205 #: zrcolafrm.cpp:123
msgid "Start ZRCola automatically on logon"
msgstr "Samodejno zaženi ZRColo ob prijavi"
#: zrcolafrm.cpp:253
#, c-format #, c-format
msgid "" msgid ""
"ZRCola v%s\n" "ZRCola v%s\n"
@ -51,119 +55,127 @@ msgstr ""
"ZRCola v%s\n" "ZRCola v%s\n"
"Vse pravice pridržane 2015-%s Amebis" "Vse pravice pridržane 2015-%s Amebis"
#: zrcolafrm.cpp:205 #: zrcolafrm.cpp:253
msgid "About ZRCola" msgid "About ZRCola"
msgstr "O ZRColi" msgstr "O ZRColi"
#: zrcolagui.cpp:32 #: zrcolagui.cpp:32
msgid "&Start on Logon"
msgstr "Z&aženi ob prijavi"
#: zrcolagui.cpp:32
msgid "Start this program automatically on logon"
msgstr "Samodejno zaženi ta program ob prijavi"
#: zrcolagui.cpp:38
msgid "E&xit" msgid "E&xit"
msgstr "I&zhod" msgstr "I&zhod"
#: zrcolagui.cpp:32 #: zrcolagui.cpp:38
msgid "Quit this program" msgid "Quit this program"
msgstr "Zapri ta program" msgstr "Zapri ta program"
#: zrcolagui.cpp:35 #: zrcolagui.cpp:41
msgid "&Program" msgid "&Program"
msgstr "&Program" msgstr "&Program"
#: zrcolagui.cpp:68 #: zrcolagui.cpp:74
msgid "Select &All" msgid "Select &All"
msgstr "Izberi &vse" msgstr "Izberi &vse"
#: zrcolagui.cpp:68 #: zrcolagui.cpp:74
msgid "Select all text" msgid "Select all text"
msgstr "Izberi celotno besedilo" msgstr "Izberi celotno besedilo"
#: zrcolagui.cpp:74 #: zrcolagui.cpp:80
msgid "&Send Composed" msgid "&Send Composed"
msgstr "Pošlji &sestavljeno" msgstr "Pošlji &sestavljeno"
#: zrcolagui.cpp:74 zrcolagui.cpp:125 #: zrcolagui.cpp:80 zrcolagui.cpp:131
msgid "Send composed text to source window" msgid "Send composed text to source window"
msgstr "Pošlji sestavljeno besedilo izvornemu oknu" msgstr "Pošlji sestavljeno besedilo izvornemu oknu"
#: zrcolagui.cpp:83 #: zrcolagui.cpp:89
msgid "Send &Decomposed" msgid "Send &Decomposed"
msgstr "Pošlji &razstavljeno" msgstr "Pošlji &razstavljeno"
#: zrcolagui.cpp:83 zrcolagui.cpp:127 #: zrcolagui.cpp:89 zrcolagui.cpp:133
msgid "Send decomposed text to source window" msgid "Send decomposed text to source window"
msgstr "Pošlji razstavljeno besedilo izvornemu oknu" msgstr "Pošlji razstavljeno besedilo izvornemu oknu"
#: zrcolagui.cpp:92 #: zrcolagui.cpp:98
msgid "Abort (De)composition" msgid "Abort (De)composition"
msgstr "Prekini raz/sestavljanje" msgstr "Prekini raz/sestavljanje"
#: zrcolagui.cpp:92 #: zrcolagui.cpp:98
msgid "Abort composition and return focus to source window" msgid "Abort composition and return focus to source window"
msgstr "Prekini sestavljanje in vrni fokus nazaj izvornemu oknu" msgstr "Prekini sestavljanje in vrni fokus nazaj izvornemu oknu"
#: zrcolagui.cpp:101 #: zrcolagui.cpp:107
msgid "&Language" msgid "&Language"
msgstr "&Jezik" msgstr "&Jezik"
#: zrcolagui.cpp:104 #: zrcolagui.cpp:110
msgid "&Edit" msgid "&Edit"
msgstr "Ur&edi" msgstr "Ur&edi"
#: zrcolagui.cpp:111 #: zrcolagui.cpp:117
msgid "&Help" msgid "&Help"
msgstr "&Pomoč" msgstr "&Pomoč"
#: zrcolagui.cpp:117 #: zrcolagui.cpp:123
msgid "Cut" msgid "Cut"
msgstr "Izreži" msgstr "Izreži"
#: zrcolagui.cpp:117 #: zrcolagui.cpp:123
msgid "Cut selection" msgid "Cut selection"
msgstr "Izreži izbor" msgstr "Izreži izbor"
#: zrcolagui.cpp:119 #: zrcolagui.cpp:125
msgid "Copy" msgid "Copy"
msgstr "Kopiraj" msgstr "Kopiraj"
#: zrcolagui.cpp:119 #: zrcolagui.cpp:125
msgid "Copy selection" msgid "Copy selection"
msgstr "Kopiraj izbor" msgstr "Kopiraj izbor"
#: zrcolagui.cpp:121 #: zrcolagui.cpp:127
msgid "Paste" msgid "Paste"
msgstr "Prilepi" msgstr "Prilepi"
#: zrcolagui.cpp:121 #: zrcolagui.cpp:127
msgid "Paste selection" msgid "Paste selection"
msgstr "Prilepi izbor" msgstr "Prilepi izbor"
#: zrcolagui.cpp:125 #: zrcolagui.cpp:131
msgid "Send Composed" msgid "Send Composed"
msgstr "Pošlji sestavljeno" msgstr "Pošlji sestavljeno"
#: zrcolagui.cpp:127 #: zrcolagui.cpp:133
msgid "Send Decomposed" msgid "Send Decomposed"
msgstr "Pošlji razstavljeno" msgstr "Pošlji razstavljeno"
#: zrcolagui.cpp:129 #: zrcolagui.cpp:135
msgid "Language:" msgid "Language:"
msgstr "Jezik:" msgstr "Jezik:"
#: zrcolagui.cpp:178 #: zrcolagui.cpp:184
msgid "Decomposed Text" msgid "Decomposed Text"
msgstr "Razstavljeno besedilo" msgstr "Razstavljeno besedilo"
#: zrcolagui.cpp:198 #: zrcolagui.cpp:204
msgid "Decomposed Unicode Dump" msgid "Decomposed Unicode Dump"
msgstr "Unicode razstavljenega" msgstr "Unicode razstavljenega"
#: zrcolagui.cpp:225 #: zrcolagui.cpp:231
msgid "Composed Text" msgid "Composed Text"
msgstr "Sestavljeno besedilo" msgstr "Sestavljeno besedilo"
#: zrcolagui.cpp:245 #: zrcolagui.cpp:251
msgid "Composed Unicode Dump" msgid "Composed Unicode Dump"
msgstr "Unicode sestavljenega" msgstr "Unicode sestavljenega"
#: zrcolagui.h:75 MSIBuild/En.Win32.Release.Feature-2.idtx:4 #: zrcolagui.h:76 MSIBuild/En.Win32.Release.Feature-2.idtx:4
#: MSIBuild/En.Win32.Release.Shortcut-2.idtx:4 #: MSIBuild/En.Win32.Release.Shortcut-2.idtx:4
#: MSIBuild/En.x64.Release.Feature-2.idtx:4 #: MSIBuild/En.x64.Release.Feature-2.idtx:4
#: MSIBuild/En.x64.Release.Shortcut-2.idtx:4 #: MSIBuild/En.x64.Release.Shortcut-2.idtx:4

View File

@ -39,4 +39,6 @@
#if defined(__WXMSW__) #if defined(__WXMSW__)
#include <Msi.h> #include <Msi.h>
#include <ShObjIdl.h>
#include <ShlGuid.h>
#endif #endif

View File

@ -25,6 +25,10 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase) wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase)
EVT_UPDATE_UI (wxID_AUTOSTART , wxZRColaFrame::OnAutostartUpdate )
EVT_MENU (wxID_AUTOSTART , wxZRColaFrame::OnAutostart )
EVT_MENU (wxID_EXIT , wxZRColaFrame::OnExit )
EVT_UPDATE_UI_RANGE(wxID_CUT, wxID_CLEAR , wxZRColaFrame::OnForwardEventUpdate ) EVT_UPDATE_UI_RANGE(wxID_CUT, wxID_CLEAR , wxZRColaFrame::OnForwardEventUpdate )
EVT_MENU_RANGE (wxID_CUT, wxID_CLEAR , wxZRColaFrame::OnForwardEvent ) EVT_MENU_RANGE (wxID_CUT, wxID_CLEAR , wxZRColaFrame::OnForwardEvent )
EVT_UPDATE_UI (wxID_SELECTALL , wxZRColaFrame::OnForwardEventUpdate ) EVT_UPDATE_UI (wxID_SELECTALL , wxZRColaFrame::OnForwardEventUpdate )
@ -38,7 +42,6 @@ wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase)
EVT_UPDATE_UI_RANGE(wxID_DECOMP_LANGUAGE_START, wxID_DECOMP_LANGUAGE_END, wxZRColaFrame::OnDecomposedLanguageUpdate) EVT_UPDATE_UI_RANGE(wxID_DECOMP_LANGUAGE_START, wxID_DECOMP_LANGUAGE_END, wxZRColaFrame::OnDecomposedLanguageUpdate)
EVT_MENU_RANGE (wxID_DECOMP_LANGUAGE_START, wxID_DECOMP_LANGUAGE_END, wxZRColaFrame::OnDecomposedLanguage ) EVT_MENU_RANGE (wxID_DECOMP_LANGUAGE_START, wxID_DECOMP_LANGUAGE_END, wxZRColaFrame::OnDecomposedLanguage )
EVT_MENU(wxID_EXIT , wxZRColaFrame::OnExit )
EVT_MENU (wxID_ABOUT , wxZRColaFrame::OnAbout ) EVT_MENU (wxID_ABOUT , wxZRColaFrame::OnAbout )
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
@ -92,6 +95,57 @@ wxZRColaFrame::~wxZRColaFrame()
} }
void wxZRColaFrame::OnAutostartUpdate(wxUpdateUIEvent& event)
{
#if defined(__WXMSW__)
wxString linkName(wxExpandEnvVars("%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\ZRCola.lnk"));
event.Check(wxFileExists(linkName));
#else
event.Enable(false);
#endif
}
void wxZRColaFrame::OnAutostart(wxCommandEvent& event)
{
#if defined(__WXMSW__)
wxString linkName(wxExpandEnvVars("%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\ZRCola.lnk"));
if (wxFileExists(linkName)) {
// The shortcut already exists. Remove it.
wxRemoveFile(linkName);
} else {
// Create the shortcut.
IShellLink *sl;
HRESULT hr = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&sl);
if (SUCCEEDED(hr)) {
// Setup ZRCola shortcut.
sl->SetPath(wxTheApp->argv[0]);
sl->SetDescription(_("Start ZRCola automatically on logon"));
sl->SetShowCmd(SW_SHOWMINNOACTIVE);
// Query IShellLink for the IPersistFile interface, used for saving the
// shortcut in persistent storage.
IPersistFile *pf;
hr = sl->QueryInterface(IID_IPersistFile, (LPVOID*)&pf);
if (SUCCEEDED(hr)) {
// Save the link by calling IPersistFile::Save.
hr = pf->Save(linkName, TRUE);
pf->Release();
}
sl->Release();
}
}
#endif
}
void wxZRColaFrame::OnExit(wxCommandEvent& event)
{
Close();
}
void wxZRColaFrame::OnForwardEventUpdate(wxUpdateUIEvent& event) void wxZRColaFrame::OnForwardEventUpdate(wxUpdateUIEvent& event)
{ {
wxControl *focusWnd = wxDynamicCast(FindFocus(), wxControl); wxControl *focusWnd = wxDynamicCast(FindFocus(), wxControl);
@ -194,12 +248,6 @@ void wxZRColaFrame::OnDecompLanguageChoice(wxCommandEvent& event)
} }
void wxZRColaFrame::OnExit(wxCommandEvent& event)
{
Close();
}
void wxZRColaFrame::OnAbout(wxCommandEvent& event) void wxZRColaFrame::OnAbout(wxCommandEvent& event)
{ {
wxMessageBox(wxString::Format(_("ZRCola v%s\nCopyright 2015-%s Amebis"), wxT(ZRCOLA_VERSION_STR), wxT(ZRCOLA_BUILD_YEAR_STR)), _("About ZRCola"), wxOK | wxICON_INFORMATION); wxMessageBox(wxString::Format(_("ZRCola v%s\nCopyright 2015-%s Amebis"), wxT(ZRCOLA_VERSION_STR), wxT(ZRCOLA_BUILD_YEAR_STR)), _("About ZRCola"), wxOK | wxICON_INFORMATION);

View File

@ -54,6 +54,9 @@ public:
virtual ~wxZRColaFrame(); virtual ~wxZRColaFrame();
protected: protected:
void OnAutostartUpdate(wxUpdateUIEvent& event);
void OnAutostart(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
void OnForwardEventUpdate(wxUpdateUIEvent& event); void OnForwardEventUpdate(wxUpdateUIEvent& event);
void OnForwardEvent(wxCommandEvent& event); void OnForwardEvent(wxCommandEvent& event);
void OnSendUpdate(wxUpdateUIEvent& event); void OnSendUpdate(wxUpdateUIEvent& event);
@ -63,7 +66,6 @@ protected:
void OnDecomposedLanguageUpdate(wxUpdateUIEvent& event); void OnDecomposedLanguageUpdate(wxUpdateUIEvent& event);
void OnDecomposedLanguage(wxCommandEvent& event); void OnDecomposedLanguage(wxCommandEvent& event);
virtual void OnDecompLanguageChoice(wxCommandEvent& event); virtual void OnDecompLanguageChoice(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event); void OnAbout(wxCommandEvent& event);
wxDECLARE_EVENT_TABLE(); wxDECLARE_EVENT_TABLE();

View File

@ -28,6 +28,12 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
m_menubar = new wxMenuBar( 0 ); m_menubar = new wxMenuBar( 0 );
m_menuProgram = new wxMenu(); m_menuProgram = new wxMenu();
wxMenuItem* m_menuItemAutoStart;
m_menuItemAutoStart = new wxMenuItem( m_menuProgram, wxID_AUTOSTART, wxString( _("&Start on Logon") ) , _("Start this program automatically on logon"), wxITEM_CHECK );
m_menuProgram->Append( m_menuItemAutoStart );
m_menuProgram->AppendSeparator();
wxMenuItem* m_menuItemExit; wxMenuItem* m_menuItemExit;
m_menuItemExit = new wxMenuItem( m_menuProgram, wxID_EXIT, wxString( _("E&xit") ) + wxT('\t') + wxT("Alt+F4"), _("Quit this program"), wxITEM_NORMAL ); m_menuItemExit = new wxMenuItem( m_menuProgram, wxID_EXIT, wxString( _("E&xit") ) + wxT('\t') + wxT("Alt+F4"), _("Quit this program"), wxITEM_NORMAL );
m_menuProgram->Append( m_menuItemExit ); m_menuProgram->Append( m_menuItemExit );

View File

@ -45,7 +45,8 @@ class wxZRColaFrameBase : public wxFrame
protected: protected:
enum enum
{ {
wxID_SEND_COMPOSED = 1000, wxID_AUTOSTART = 1000,
wxID_SEND_COMPOSED,
wxID_SEND_DECOMPOSED, wxID_SEND_DECOMPOSED,
wxID_SEND_ABORT wxID_SEND_ABORT
}; };