EditFontDialog::EditFontDialog(const String & editFontPresetName, QDialog *parent) : QDialog(parent), ui(new Ui::EditFontDialog) { ui->setupUi(this); ui->buttonBox->button( QDialogButtonBox::Ok )->setEnabled(false); dialogResult.fontPresetOriginalName = editFontPresetName; dialogResult.fontPresetName = editFontPresetName; Font* font = EditorFontManager::Instance()->GetLocalizedFont(editFontPresetName, "default"); dialogResult.font = font ? font->Clone() : EditorFontManager::Instance()->GetDefaultFont()->Clone(); const Vector<String> &locales = EditorFontManager::Instance()->GetLocales(); int32 localesCount = locales.size(); for(int32 i = 0; i < localesCount; ++i) { Font* localizedFont = EditorFontManager::Instance()->GetLocalizedFont(editFontPresetName, locales[i]); dialogResult.localizedFonts[locales[i]] = localizedFont ? localizedFont->Clone() : dialogResult.font->Clone(); Logger::FrameworkDebug("EditFontDialog::EditFontDialog dialogResult.localizedFonts[%s] = %p", locales[i].c_str(), dialogResult.localizedFonts[locales[i]]); ui->selectLocaleComboBox->addItem(QString::fromStdString(locales[i])); } if(0 < localesCount) { currentLocale = locales[0]; } // Initialize dialog ConnectToSignals(); }
void FontManagerDialog::OkButtonClicked() { Font *returnFont = NULL; QItemSelectionModel *selectionModel = ui->fontsTableView->selectionModel(); if (selectionModel->hasSelection()) { returnFont = GetSelectedFont(selectionModel); if (returnFont) { //Set dialog resulting font - it corresponds to selected font by user dialogResultFont = returnFont->Clone(); SafeRelease(returnFont); //Set dialog result as QDialog::Accepted and close it accept(); } } }