void Installer::initInstall() { // load languages QString langCode; QString curLang; curLang = "en_US"; bool foundLang = false; comboLanguage->clear(); languages = Scripts::Backend::languages(); if ( QFile::exists("/var/.wizardlang") ) { QFile lFile("/var/.wizardlang"); if ( lFile.open(QIODevice::ReadOnly | QIODevice::Text) ) { curLang = lFile.readLine().simplified(); lFile.close(); } } qDebug() << curLang; // Now set languages for (int i=0; i < languages.count(); ++i) { QString languageStr = languages.at(i); QString language = languageStr.split("-").at(0); comboLanguage->addItem(language.trimmed()); // Grab the language code langCode = languageStr; langCode.truncate(langCode.lastIndexOf(")")); langCode.remove(0, langCode.lastIndexOf("(") + 1); if ( curLang == langCode ) { comboLanguage->setCurrentIndex(i); foundLang = true; } } // If we found a language to default to if ( foundLang ) slotChangeLanguage(); connect(comboLanguage, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotChangeLanguage())); }
void Installer::initInstall() { // load languages comboLanguage->clear(); languages = Scripts::Backend::languages(); for (int i=0; i < languages.count(); ++i) { QString languageStr = languages.at(i); QString language = languageStr.split("-").at(0); comboLanguage->addItem(language.trimmed()); } connect(comboLanguage, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotChangeLanguage())); }
Thesaurus::Thesaurus() { m_standAlone = false; m_thesProc = new KProcess; m_wnProc = new KProcess; m_dialog = new KDialog(0); m_dialog->setButtons(KDialog::Help | KDialog::Ok | KDialog::Cancel); m_dialog->setDefaultButton(KDialog::Ok); m_dialog->setHelp(QString(), "thesaurus"); m_dialog->resize(600, 400); KConfigGroup cfg = KGlobal::config()->group(""); m_dataFile = cfg.readEntry("datafile"); if (m_dataFile.isEmpty()) m_dataFile = KGlobal::dirs()->findResource("data", "koffice/thesaurus/thesaurus.txt"); setCaption(); m_noMatch = i18n("(No match)"); m_historyPos = 1; QWidget *page = new QWidget(); m_dialog->setMainWidget(page); QVBoxLayout *topLayout = new QVBoxLayout(page); topLayout->setMargin(KDialog::marginHint()); topLayout->setSpacing(KDialog::spacingHint()); QHBoxLayout *row1 = new QHBoxLayout; topLayout->addLayout(row1); m_edit = new KHistoryComboBox(page); QLabel editLabel(i18n("&Search for:"), page); editLabel.setBuddy(m_edit); m_search = new KPushButton(i18n("S&earch"), page); connect(m_search, SIGNAL(clicked()), this, SLOT(slotFindTerm())); row1->addWidget(&editLabel, 0); row1->addWidget(m_edit, 1); row1->addWidget(m_search, 0); m_back = new QToolButton(page); m_back->setIcon(KIcon(QString::fromLatin1("go-previous"))); m_back->setToolTip(i18nc("@action:button Go back to the previous word in history", "Back")); row1->addWidget(m_back, 0); m_forward = new QToolButton(page); m_forward->setIcon(KIcon(QString::fromLatin1("go-next"))); m_forward->setToolTip(i18nc("@action:button Go forward to the next word in history", "Forward")); row1->addWidget(m_forward, 0); KPushButton *lang = new KPushButton(i18n("Change Language..."), page); connect(lang, SIGNAL(clicked()), this, SLOT(slotChangeLanguage())); row1->addWidget(lang, 0); connect(m_back, SIGNAL(clicked()), this, SLOT(slotBack())); connect(m_forward, SIGNAL(clicked()), this, SLOT(slotForward())); m_tabWidget = new KTabWidget(page); topLayout->addWidget(m_tabWidget); // // Thesaurus Tab // QWidget *thesWidget = new QWidget(m_tabWidget); m_tabWidget->addTab(thesWidget, i18n("&Thesaurus")); QHBoxLayout *thesLayout = new QHBoxLayout; thesLayout->setSpacing(KDialog::spacingHint()); thesWidget->setLayout(thesLayout); QGroupBox *synGroupBox = new QGroupBox(i18n("Synonyms"), thesWidget); QHBoxLayout *synLayout = new QHBoxLayout(); synGroupBox->setLayout(synLayout); m_synListWidget = new QListWidget(synGroupBox); synLayout->addWidget(m_synListWidget); thesLayout->addWidget(synGroupBox); QGroupBox *hyperGroupBox = new QGroupBox(i18n("More General Words"), thesWidget); QHBoxLayout *hyperLayout = new QHBoxLayout(); hyperGroupBox->setLayout(hyperLayout); m_hyperListWidget = new QListWidget(hyperGroupBox); hyperLayout->addWidget(m_hyperListWidget); thesLayout->addWidget(hyperGroupBox); QGroupBox *hypoGroupBox = new QGroupBox(i18n("More Specific Words"), thesWidget); QHBoxLayout *hypoLayout = new QHBoxLayout(); hypoGroupBox->setLayout(hypoLayout); m_hypoListWidget = new QListWidget(hypoGroupBox); hypoLayout->addWidget(m_hypoListWidget); thesLayout->addWidget(hypoGroupBox); // single click -- keep display unambiguous by removing other selections: connect(m_synListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(slotSetReplaceTermSyn(QListWidgetItem *))); connect(m_hyperListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(slotSetReplaceTermHyper(QListWidgetItem *))); connect(m_hypoListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(slotSetReplaceTermHypo(QListWidgetItem *))); // double click -- set the double clicked item as the new search term connect(m_synListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotFindTermFromList(QListWidgetItem *))); connect(m_hyperListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotFindTermFromList(QListWidgetItem *))); connect(m_hypoListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotFindTermFromList(QListWidgetItem *))); // // WordNet Tab // QWidget *wnWidget = new QWidget(m_tabWidget); m_tabWidget->addTab(wnWidget, i18n("&Wordnet")); QVBoxLayout *wnLayout = new QVBoxLayout; wnLayout->setSpacing(KDialog::spacingHint()); wnLayout->setMargin(KDialog::marginHint()); wnWidget->setLayout(wnLayout); m_wnComboBox = new KComboBox(wnWidget); m_wnComboBox->setEditable(false); wnLayout->addWidget(m_wnComboBox); connect(m_wnComboBox, SIGNAL(activated(int)), this, SLOT(slotFindTerm())); m_resultTextBrowser = new KTextBrowser(wnWidget); m_resultTextBrowser->setReadOnly(true); connect(m_resultTextBrowser, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(slotFindTermFromUrl(const QUrl &))); wnLayout->addWidget(m_resultTextBrowser); // Connect for the history box m_edit->setTrapReturnKey(true); // Do not use Return as default key... connect(m_edit, SIGNAL(returnPressed()), this, SLOT(slotFindTerm())); connect(m_edit, SIGNAL(activated(int)), this, SLOT(slotGotoHistory(int))); QHBoxLayout *row2 = new QHBoxLayout( /*m_top_layout*/ ); topLayout->addLayout(row2); m_replaceLineEdit = new KLineEdit(page); m_replaceLabel = new QLabel(i18n("&Replace with:"), page); m_replaceLabel->setBuddy(m_replaceLineEdit); row2->addWidget(m_replaceLabel, 0); row2->addWidget(m_replaceLineEdit, 1); // Set focus m_edit->setFocus(); updateNavButtons(); connect(m_dialog, SIGNAL(accepted()), this, SLOT(process())); connect(m_dialog, SIGNAL(rejected()), this, SLOT(dialogClosed())); }