void IconOptions::setIconFromField(const QLineEdit * edit, const QString & sid) { QDir themeDirectory = getLexicon()->themeDirectory(); QDir imagedirectory; /// if the image directory is absolute then just use it /// otherwise it is a subdirectory of the theme root QFileInfo im(m_directory->text()); if (im.isRelative()) { if (themeDirectory.cd(m_directory->text())) { /// good to go imagedirectory = themeDirectory; } else { } } else { imagedirectory = im.dir(); } QString name = edit->text(); QFileInfo f(name); if (f.isRelative()) { QFileInfo fi(imagedirectory,name); name = fi.absoluteFilePath(); } onSetIcon(sid,name); }
void IconOptions::onSetFile() { QPushButton * btn = qobject_cast<QPushButton *>(sender()); QString sid = btn->property("SID").toString(); QLineEdit * edit = this->findChild<QLineEdit *>(sid); if (! edit ) { return; } QString d = m_directory->text(); QString p = getLexicon()->getResourceFilePath(Lexicon::Image); QString imagedirectory = p; if (! d.isEmpty()) { QFileInfo fi(p,d); if (fi.isDir()) { imagedirectory = fi.absoluteFilePath(); } } QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"),imagedirectory , tr("Image Files (*.*)")); QDir id(imagedirectory); if (! fileName.isEmpty()) { edit->setText(id.relativeFilePath(fileName)); } setIconFromField(edit,sid); }
DeleteThemeDialog::DeleteThemeDialog(QWidget * parent) : QDialog(parent) { QVBoxLayout * layout = new QVBoxLayout; setWindowTitle(tr("Delete Theme")); m_themes = new QComboBox; QStringList themes = getLexicon()->getThemes(); themes.sort(); m_themes->addItems(themes); m_currentTheme = getLexicon()->currentTheme(); m_themes->setCurrentText(m_currentTheme); m_switch = new QComboBox; m_switch->addItems(themes); m_currentTheme = getLexicon()->currentTheme(); connect(m_themes,SIGNAL(currentIndexChanged(int)),this,SLOT(onChangeTheme(int))); m_themes->setCurrentText(m_currentTheme); m_themes->removeItem(m_themes->findText(m_currentTheme)); // m_switch->removeItem(m_themes->findText(m_currentTheme)); QFormLayout * form = new QFormLayout; form->addRow(tr("Delete theme"),m_themes); form->addRow(tr("New theme"),m_switch); m_deleteButton = new QPushButton(tr("Delete")); QDialogButtonBox * btns = new QDialogButtonBox(QDialogButtonBox::Cancel); btns->addButton(m_deleteButton,QDialogButtonBox::AcceptRole); connect(btns,SIGNAL(accepted()),this,SLOT(accept())); connect(btns,SIGNAL(rejected()),this,SLOT(reject())); layout->addWidget(new QLabel(QString(tr("The current theme is \"%1\" and cannot be deleted.")).arg(m_currentTheme))); layout->addLayout(form); layout->addWidget(btns); // layout->addStretch(); setLayout(layout); if (themes.size() == 1) { m_deleteButton->setEnabled(false); } };
void SystemOptions::onSetCss() { QString cssDirectory = getLexicon()->getResourceFilePath(Lexicon::Stylesheet); QString fileName = QFileDialog::getOpenFileName(this, tr("Select application stylesheet"), cssDirectory, tr("CSS (*.css)")); if (fileName.isEmpty()) { return; } QDir d(cssDirectory); m_css->setText(d.relativeFilePath(fileName)); }
void IconOptions::onSetDirectory() { QString d = m_directory->text(); QString p = getLexicon()->getResourceFilePath(Lexicon::Image); QString imagedirectory = p; if (! d.isEmpty()) { QFileInfo fi(p,d); if (fi.isDir()) { imagedirectory = fi.absoluteFilePath(); } } QString fileName = QFileDialog::getExistingDirectory(this, tr("Open Image Directory"),imagedirectory); }
void SystemOptions::onShowSplash() { getLexicon()->showPath(Lexicon::Splash); }
/** * * * * @return */ bool SystemOptions::isModified() { m_dirty = false; m_changes.clear(); QSettings settings(m_settingsFileName,QSettings::IniFormat); settings.setIniCodec("UTF-8"); settings.beginGroup(m_section); if (compare(&settings,SID_SYSTEM_MESSAGE_TIMEOUT,m_interval)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_CONTENTS_LINKED,m_contentsLinked)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_DATABASE,m_lexicon)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_DOCKED,m_docked)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_APPEND_NEW_TABS,m_appendNewTab)) { m_dirty = true; } // else { // setButtons(false); // } if (compare(&settings,SID_SYSTEM_IMPORTLINKS_IGNORE,m_importCheck)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_IMPORTLINKS_SHOW_WARNING,m_importShow)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_MINIMAL,m_minimalInterface)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_RESTORE_BOOKMARKS,m_restoreBookmarks)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_RESTORE_TABS,m_restoreTabs)) { m_dirty = true; } /* if (compare(&settings,SID_SYSTEM_SAVE_SETTINGS,m_saveSettings)) { m_dirty = true; } */ if (compare(&settings,SID_SYSTEM_SAVE_TABS,m_saveTabs)) { m_dirty = true; } if (m_allowNavMode) { if (compare(&settings,SID_SYSTEM_BY_ROOT,m_rootNavigation)) { m_dirty = true; } } // if (compare(&settings,SID_SYSTEM_RUN_DATE,m_runDate)) { // m_dirty = true; // } if (compare(&settings,SID_SYSTEM_INTERFACE_WARNING,m_showInterfaceWarning)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_ALLOW_DUPLICATES,m_allowDuplicates)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_STYLESHEET,m_css)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_TITLE,m_title)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_TOOLBAR_TEXT,m_toolbarText)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_OPTIONS_CLOSE,m_optionsWarning)) { m_dirty = true; } if (compare(&settings,SID_SYSTEM_QT_STYLE,m_qtStyle)) { m_dirty = true; } settings.endGroup(); /* settings.beginGroup("Notes"); if (compare(&settings,SID_NOTES_ENABLED,m_useNotes)) { m_dirty = true; } if (compare(&settings,SID_NOTES_DATABASE,m_notesDb)) { m_dirty = true; } settings.endGroup(); */ if (m_keyboard->currentText() != getLexicon()->getDefaultKeyboard()) { m_dirty = true; } if (m_theme->currentText() != getLexicon()->currentTheme()) { m_dirty = true; } settings.beginGroup("Splash"); if (compare(&settings,SID_SPLASH_ENABLED,m_splashScreen)) { m_dirty = true; } if (compare(&settings,SID_SPLASH_DELAY,m_splashDuration)) { m_dirty = true; } settings.endGroup(); settings.beginGroup("History"); if (compare(&settings,SID_HISTORY_DATABASE,m_historyDb)) { m_dirty = true; } settings.endGroup(); settings.beginGroup("Help"); if (compare(&settings,SID_HELP_ONLINE_PREFIX,m_onlineUrl)) { m_dirty = true; } /// check this if (compare(&settings,SID_HELP_ONLINE_URL,m_onlineCurrentPage)) { m_dirty = true; } if (compare(&settings,SID_HELP_LOCAL_LOCATION,m_offlineLocation)) { m_dirty = true; } /* QDir dd(m_offlineLocation->text()); QUrl u = settings.value(SID_HELP_LOCAL_URL,QUrl()).toUrl(); QString str = dd.relativeFilePath(u.fileName()); if (str != m_offlineCurrentPage->text()) { m_dirty = true; if (m_debug) { // QLOG_DEBUG() << "Is Modified" << SID_HELP_LOCAL_URL << str << m_offlineCurrentPage->text(); } } */ if (compare(&settings,SID_HELP_LOCAL_URL,m_offlineCurrentPage)) { m_dirty = true; } if (compare(&settings,SID_HELP_LOCAL,m_localDocs)) { m_dirty = true; } return m_dirty; }
void SystemOptions::writeSettings(const QString & fileName) { QString f = m_settingsFileName; if (!fileName.isEmpty()) { f = fileName; } #ifdef LANE getLexicon()->setTheme(m_theme->currentText()); getLexicon()->setDefaultKeyboard(m_keyboard->currentText()); #else #endif QSettings settings(f,QSettings::IniFormat); settings.setIniCodec("UTF-8"); settings.beginGroup(m_section); settings.setValue(SID_SYSTEM_CONTENTS_LINKED, m_contentsLinked->isChecked()); settings.setValue(SID_SYSTEM_DATABASE,m_lexicon->text()); settings.setValue(SID_SYSTEM_MESSAGE_TIMEOUT,m_interval->text()); settings.setValue(SID_SYSTEM_DOCKED,m_docked->isChecked()); settings.setValue(SID_SYSTEM_IMPORTLINKS_IGNORE,m_importCheck->isChecked()); settings.setValue(SID_SYSTEM_IMPORTLINKS_SHOW_WARNING,m_importShow->isChecked()); settings.setValue(SID_SYSTEM_MINIMAL,m_minimalInterface->isChecked()); settings.setValue(SID_SYSTEM_RESTORE_BOOKMARKS,m_restoreBookmarks->isChecked()); settings.setValue(SID_SYSTEM_RESTORE_TABS,m_restoreTabs->isChecked()); // settings.setValue(SID_SYSTEM_SAVE_SETTINGS,m_saveSettings->isChecked()); settings.setValue(SID_SYSTEM_SAVE_TABS,m_saveTabs->isChecked()); settings.setValue(SID_SYSTEM_BY_ROOT,m_rootNavigation->isChecked()); // settings.setValue(SID_SYSTEM_RUN_DATE,m_runDate->dateTime().toString(Qt::ISODate)); settings.setValue(SID_SYSTEM_INTERFACE_WARNING,m_showInterfaceWarning->isChecked()); settings.setValue(SID_SYSTEM_STYLESHEET,m_css->text()); settings.setValue(SID_SYSTEM_TITLE,m_title->text()); settings.setValue(SID_SYSTEM_TOOLBAR_TEXT,m_toolbarText->isChecked()); settings.setValue(SID_SYSTEM_APPEND_NEW_TABS,m_appendNewTab->isChecked()); settings.setValue(SID_SYSTEM_ALLOW_DUPLICATES,m_allowDuplicates->isChecked()); settings.setValue(SID_SYSTEM_OPTIONS_CLOSE,m_optionsWarning->isChecked()); QString oldStyle = settings.value(SID_SYSTEM_QT_STYLE).toString(); QString newStyle = m_qtStyle->currentText(); settings.setValue(SID_SYSTEM_QT_STYLE,m_qtStyle->currentText()); if (oldStyle != newStyle) { QApplication::setStyle(QStyleFactory::create(newStyle)); } settings.endGroup(); settings.beginGroup("Notes"); settings.setValue(SID_NOTES_DATABASE,m_notesDb->text()); /* This was originally here and caused corruption to any arabic text in the ini file. getLexicon()->setDefaultKeyboard(m_keyboard->currentText()); */ settings.endGroup(); settings.beginGroup("Splash"); settings.setValue(SID_SPLASH_ENABLED,m_splashScreen->isChecked()); settings.setValue(SID_SPLASH_DELAY,m_splashDuration->text()); settings.endGroup(); settings.beginGroup("History"); settings.setValue(SID_HISTORY_DATABASE,m_historyDb->text()); settings.endGroup(); settings.beginGroup("Help"); settings.setValue(SID_HELP_ONLINE_PREFIX,m_onlineUrl->text()); settings.setValue(SID_HELP_ONLINE_URL,QUrl(m_onlineCurrentPage->text())); settings.setValue(SID_HELP_LOCAL_LOCATION,m_offlineLocation->text()); // QFileInfo fi(QDir(m_offlineLocation->text()),m_offlineCurrentPage->text()); // settings.setValue(SID_HELP_LOCAL_URL,QUrl::fromLocalFile(fi.absoluteFilePath())); settings.setValue(SID_HELP_LOCAL_URL,m_offlineCurrentPage->text()); settings.setValue(SID_HELP_LOCAL,m_localDocs->isChecked()); settings.sync(); m_dirty = false; emit(modified(false)); }
void SystemOptions::readSettings(bool reload) { QSettings settings(m_settingsFileName,QSettings::IniFormat); settings.setIniCodec("UTF-8"); settings.beginGroup(m_section); m_contentsLinked->setChecked(settings.value(SID_SYSTEM_CONTENTS_LINKED,true).toBool()); m_lexicon->setText(settings.value(SID_SYSTEM_DATABASE,"lexicon.sqlite").toString()); m_docked->setChecked(settings.value(SID_SYSTEM_DOCKED,true).toBool()); m_importCheck->setChecked(settings.value(SID_SYSTEM_IMPORTLINKS_IGNORE,false).toBool()); m_importShow->setChecked(settings.value(SID_SYSTEM_IMPORTLINKS_SHOW_WARNING,false).toBool()); m_minimalInterface->setChecked(settings.value(SID_SYSTEM_MINIMAL,true).toBool()); m_restoreBookmarks->setChecked(settings.value(SID_SYSTEM_RESTORE_BOOKMARKS,true).toBool()); m_restoreTabs->setChecked(settings.value(SID_SYSTEM_RESTORE_TABS,true).toBool()); // m_saveSettings->setChecked(settings.value(SID_SYSTEM_SAVE_SETTINGS,true).toBool()); m_saveTabs->setChecked(settings.value(SID_SYSTEM_SAVE_TABS,true).toBool()); m_rootNavigation->setChecked(settings.value(SID_SYSTEM_BY_ROOT,true).toBool()); m_interval->setText(settings.value(SID_SYSTEM_MESSAGE_TIMEOUT,2).toString()); m_appendNewTab->setChecked(settings.value(SID_SYSTEM_APPEND_NEW_TABS,true).toBool()); m_insertNewTab->setChecked(! m_appendNewTab->isChecked()); QString newStyle = m_qtStyle->currentText(); m_qtStyle->setCurrentText(settings.value(SID_SYSTEM_QT_STYLE).toString()); if (reload) { QString oldStyle = m_qtStyle->currentText(); if (oldStyle != newStyle) { QApplication::setStyle(QStyleFactory::create(oldStyle)); } } #ifndef STANDALONE m_keyboard->addItems(getLexicon()->getKeyboards()); m_keyboard->setCurrentText(getLexicon()->getDefaultKeyboard()); QStringList themes = getLexicon()->getThemes(); themes.sort(); m_theme->addItems(themes); m_theme->setCurrentText(getLexicon()->currentTheme()); #endif // QString d = settings.value(SID_SYSTEM_RUN_DATE,QString()).toString(); // m_runDate->setDateTime(QDateTime::fromString(d,Qt::ISODate)); m_allowDuplicates->setChecked(settings.value(SID_SYSTEM_ALLOW_DUPLICATES,false).toBool()); m_showInterfaceWarning->setChecked(settings.value(SID_SYSTEM_INTERFACE_WARNING,true).toBool()); m_css->setText(settings.value(SID_SYSTEM_STYLESHEET,"app.css").toString()); m_title->setText(settings.value(SID_SYSTEM_TITLE,"Lane's Lexicon").toString()); m_toolbarText->setChecked(settings.value(SID_SYSTEM_TOOLBAR_TEXT,true).toBool()); m_optionsWarning->setChecked(settings.value(SID_SYSTEM_OPTIONS_CLOSE,true).toBool()); settings.endGroup(); settings.beginGroup("Notes"); // m_useNotes->setChecked(settings.value(SID_NOTES_ENABLED,false).toBool()); m_notesDb->setText(settings.value(SID_NOTES_DATABASE,"notes.sqlite").toString()); settings.endGroup(); settings.beginGroup("Splash"); m_splashScreen->setChecked(settings.value(SID_SPLASH_ENABLED,true).toBool()); m_splashDuration->setText(settings.value(SID_SPLASH_DELAY,3).toString()); settings.endGroup(); settings.beginGroup("History"); m_historyDb->setText(settings.value(SID_HISTORY_DATABASE,"history.sqlite").toString()); settings.endGroup(); settings.beginGroup("Help"); m_onlineUrl->setText(settings.value(SID_HELP_ONLINE_PREFIX).toString()); m_onlineCurrentPage->setText(settings.value(SID_HELP_ONLINE_URL,QUrl()).toUrl().toString()); m_offlineLocation->setText(settings.value(SID_HELP_LOCAL_LOCATION,"site").toString()); QDir dd(m_offlineLocation->text()); // QUrl u = settings.value(SID_HELP_LOCAL_URL,QUrl()).toUrl(); // m_offlineCurrentPage->setText(dd.relativeFilePath(u.fileName())); m_offlineCurrentPage->setText(settings.value(SID_HELP_LOCAL_URL,"index.html").toString()); //u.tom_offlineLocation->text(); m_localDocs->setChecked(settings.value(SID_HELP_LOCAL,true).toBool()); m_dirty = false; }
/** * Switch to using the new lexicon 'n' to search for keywords in, and return * a flag to indicate the lexicon that we were previously using. */ lexicon Lexer::setLexicon(lexicon n) { lexicon o = getLexicon(); // Remember old value _isKeyword = n==AQL ? isAQLKeyword : isAFLKeyword; // Assign new lexicon return o; // Return saved value }