windows/searchwindow: localization
This commit is contained in:
parent
33622d1829
commit
60c30fa8f1
@ -1,6 +1,11 @@
|
||||
#pragma comment( linker, "\"/manifestdependency:type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
|
||||
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"" )
|
||||
#include "searchwindow.hpp"
|
||||
#include "../tv_rename.hpp"
|
||||
#include "gui_functions.hpp"
|
||||
#include "../resources_windows.h"
|
||||
#include "../tv_rename.hpp"
|
||||
#include "../functions.hpp"
|
||||
|
||||
#define ID_SHOW_STATIC 0x0001
|
||||
#define ID_LANG_STATIC 0x0002
|
||||
@ -19,19 +24,28 @@ SearchWindow::SearchWindow(
|
||||
const std::vector< std::pair< std::wstring, std::wstring > > &languages,
|
||||
const int lang_pos, const wchar_t *show, HWND parent_window )
|
||||
: parent( parent_window ), langs( languages ) {
|
||||
window = CreateWindowW( L"SearchWindow", L"Show Search",
|
||||
window = CreateWindowW( L"SearchWindow", _( GUI_WINDOW_SEARCH ),
|
||||
WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME | WS_VISIBLE,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, window_width,
|
||||
window_height, parent, NULL, hInstance, NULL );
|
||||
ShowWindow( window, SW_SHOW );
|
||||
auto hFont = ( HFONT )GetStockObject( DEFAULT_GUI_FONT );
|
||||
EnableWindow( parent, false );
|
||||
setIcons( hInstance, window );
|
||||
|
||||
createLabel( L"Show:", 5, 5, 30, 15, ID_SHOW_STATIC, window, hFont );
|
||||
createLabel( L"Language:", 170, 5, 55, 15, ID_LANG_STATIC, window, hFont );
|
||||
possible_label = createLabel( L"Possible shows:", 5, 60, 100, 15,
|
||||
ID_RES_STATIC, window, hFont );
|
||||
show_input = createEditBox( 5, 20, 160, 25, ID_SHOW_INPUT, window, hFont );
|
||||
std::wstring label = _( SHOW );
|
||||
label += L":";
|
||||
createLabel( label.c_str(), 5, 5, 30, 15, ID_SHOW_STATIC, window, hFont );
|
||||
|
||||
label = _( ID_LANGUAGE );
|
||||
label += L":";
|
||||
createLabel( label.c_str(), 170, 5, 55, 15, ID_LANG_STATIC, window, hFont );
|
||||
|
||||
label = _( POSSIBLE_SHOWS );
|
||||
label += L":";
|
||||
possible_label = createLabel( label.c_str(), 5, 60, 100, 15, ID_RES_STATIC,
|
||||
window, hFont );
|
||||
show_input = createEditBox( 5, 20, 160, 20, ID_SHOW_INPUT, window, hFont );
|
||||
SendMessage( show_input, WM_SETTEXT, NULL, ( LPARAM )show );
|
||||
lang_input = createCombo( 170, 20, 160, 250, ID_LANG_INPUT, window, hFont );
|
||||
for ( auto &x : languages ) {
|
||||
@ -39,13 +53,14 @@ SearchWindow::SearchWindow(
|
||||
}
|
||||
SendMessage( lang_input, CB_SETCURSEL, lang_pos, NULL );
|
||||
|
||||
createButton( L"Search", 340, 18, 80, 25, ID_SEARCH_BUTTON, window, hFont );
|
||||
createButton( _( SEARCH ), 340, 18, 80, 25, ID_SEARCH_BUTTON, window,
|
||||
hFont );
|
||||
possible_input = createCombo( 5, 80, window_width - 125, 250, ID_RES_INPUT,
|
||||
window, hFont );
|
||||
createButton( L"OK", window_width - 200, 110, 80, 25, ID_OK_BUTTON, window,
|
||||
hFont );
|
||||
createButton( L"Cancel", window_width - 105, 110, 80, 25, ID_CANCEL_BUTTON,
|
||||
createButton( _( OK ), window_width - 200, 110, 80, 25, ID_OK_BUTTON,
|
||||
window, hFont );
|
||||
createButton( _( CANCEL ), window_width - 105, 110, 80, 25,
|
||||
ID_CANCEL_BUTTON, window, hFont );
|
||||
|
||||
ShowWindow( possible_label, SW_HIDE );
|
||||
ShowWindow( possible_input, SW_HIDE );
|
||||
@ -96,23 +111,16 @@ void SearchWindow::process() {
|
||||
wchar_t show[256];
|
||||
SendMessage( show_input, WM_GETTEXT, ( WPARAM )255, ( LPARAM )show );
|
||||
if ( wcslen( show ) == 0 ) {
|
||||
MessageBox( window, L"Show field is empty", L"Error",
|
||||
MB_OK | MB_ICONERROR );
|
||||
MessageBox( window, _( SHOW_FIELD_EMPTY ), _( ERROR ), MB_OK | MB_ICONERROR );
|
||||
return;
|
||||
}
|
||||
|
||||
auto index = SendMessage( lang_input, CB_GETCURSEL, NULL, NULL );
|
||||
if ( index == CB_ERR ) {
|
||||
MessageBox( window, L"No language selected", L"Error",
|
||||
MB_OK | MB_ICONERROR );
|
||||
return;
|
||||
}
|
||||
auto lang_code = langs[index].first;
|
||||
|
||||
possible_shows = searchShow( show, lang_code );
|
||||
if ( possible_shows.size() == 0 ) {
|
||||
MessageBox( window, L"No results found for given show name", L"Error",
|
||||
MB_OK | MB_ICONERROR );
|
||||
MessageBox( window, _( NO_RESULTS ), _( ERROR ), MB_OK | MB_ICONERROR );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -130,11 +138,6 @@ void SearchWindow::process() {
|
||||
void SearchWindow::ok() {
|
||||
selected = SendMessage( possible_input, CB_GETCURSEL, NULL, NULL );
|
||||
lang_id = SendMessage( lang_input, CB_GETCURSEL, NULL, NULL );
|
||||
if ( selected == CB_ERR ) {
|
||||
MessageBox( window, L"No show selected", L"Error",
|
||||
MB_OK | MB_ICONERROR );
|
||||
selected = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void SearchWindow::cancel() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <windows.h>
|
||||
|
||||
class SearchWindow {
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user