void EditTOC::ReadSettings() { SettingsStore settings; settings.beginGroup(SETTINGS_GROUP); // The size of the window and it's full screen status QByteArray geometry = settings.value("geometry").toByteArray(); if (!geometry.isNull()) { restoreGeometry(geometry); } // Column widths int size = settings.beginReadArray("column_data"); for (int column = 0; column < size && column < ui.TOCTree->header()->count(); column++) { settings.setArrayIndex(column); int column_width = settings.value("width").toInt(); if (column_width) { ui.TOCTree->setColumnWidth(column, column_width); } } settings.endArray(); settings.endGroup(); }
void PreviewWindow::LoadSettings() { SettingsStore settings; settings.beginGroup(SETTINGS_GROUP); m_Splitter->restoreState(settings.value("splitter").toByteArray()); settings.endGroup(); }
void MetaEditor::WriteSettings() { SettingsStore settings; settings.beginGroup(SETTINGS_GROUP); // The size of the window and it's full screen status settings.setValue("geometry", saveGeometry()); settings.endGroup(); }
void FindReplace::WriteSettingsVisible(bool visible) { SettingsStore *settings = new SettingsStore(); settings->beginGroup( SETTINGS_GROUP ); settings->setValue( "visible", visible); settings->endGroup(); }
void PreviewWindow::SplitterMoved(int pos, int index) { Q_UNUSED(pos); Q_UNUSED(index); SettingsStore settings; settings.beginGroup(SETTINGS_GROUP); settings.setValue("splitter", m_Splitter->saveState()); settings.endGroup(); }
void MetaEditor::ReadSettings() { SettingsStore settings; settings.beginGroup(SETTINGS_GROUP); // The size of the window and it's full screen status QByteArray geometry = settings.value("geometry").toByteArray(); if (!geometry.isNull()) { restoreGeometry(geometry); } settings.endGroup(); }
void FindReplace::WriteSettings() { SettingsStore settings; settings.beginGroup( SETTINGS_GROUP ); settings.setValue( "find_strings", GetPreviousFindStrings() ); settings.setValue( "replace_strings", GetPreviousReplaceStrings() ); settings.setValue( "search_mode", GetSearchMode() ); settings.setValue( "look_where", GetLookWhere() ); settings.setValue( "search_direction", GetSearchDirection() ); settings.endGroup(); }
const QString OpenExternally::editorForResourceType(const Resource::ResourceType type) { if (mayOpen(type)) { SettingsStore settings; settings.beginGroup(SETTINGS_GROUP); const QString &editorKey = QString("editor_") + RESOURCE_TYPE_NAME(type); if (settings.contains(editorKey)) { const QString &editorPath = settings.value(editorKey).toString(); return QFile::exists(editorPath) ? editorPath : EMPTY; } } return EMPTY; }
void FindReplace::ShowHide() { SettingsStore settings; settings.beginGroup( SETTINGS_GROUP ); QVariant show_find_replace = settings.value( "visible" ); settings.endGroup(); // Hide the window by default if (show_find_replace.isNull() ? false : show_find_replace.toBool()) { show(); } else { hide(); } }
void EditTOC::WriteSettings() { SettingsStore settings; settings.beginGroup(SETTINGS_GROUP); // The size of the window and it's full screen status settings.setValue("geometry", saveGeometry()); // Column widths settings.beginWriteArray("column_data"); for (int column = 0; column < ui.TOCTree->header()->count(); column++) { settings.setArrayIndex(column); settings.setValue("width", ui.TOCTree->columnWidth(column)); } settings.endArray(); settings.endGroup(); }
void UpdateChecker::ReplyRecieved( QNetworkReply* reply ) { Q_ASSERT( reply ); SettingsStore settings; settings.beginGroup( SETTINGS_GROUP ); QString last_online_version = settings.value( LAST_ONLINE_VERSION_KEY, QString() ).toString(); QString current_online_version = ReadOnlineVersion( TextInReply( reply ) ); bool is_newer = IsOnlineVersionNewer( SIGIL_VERSION, current_online_version ); // The message box is displayed only if the online version is newer // and only if the user hasn't been informed about this release before if ( is_newer && ( current_online_version != last_online_version ) ) { QMessageBox::StandardButton button_clicked; button_clicked = QMessageBox::question( 0, QObject::tr( "Sigil" ), QObject::tr( "<p>A newer version of Sigil is available, version <b>%1</b>.<br/>" "The ChangeLog can be seen <a href='http://sigil.googlecode.com/git/ChangeLog.txt'>here</a>.</p>" "<p>Would you like to go to the download page?</p>" ) .arg( current_online_version ), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes ); if ( button_clicked == QMessageBox::Yes ) QDesktopServices::openUrl( QUrl( DOWNLOAD_PAGE_LOCATION ) ); } // Store the current online version as the last one checked settings.setValue( LAST_ONLINE_VERSION_KEY, current_online_version ); settings.endGroup(); // Schedule this object for deletion. // There is no point for its existence // after it has received and processed the net reply. deleteLater(); }
void UpdateChecker::CheckForUpdate() { SettingsStore settings; settings.beginGroup( SETTINGS_GROUP ); // The default time is one always longer than the check interval QDateTime default_time = QDateTime::currentDateTime().addSecs( - SECONDS_BETWEEN_CHECKS - 1 ); QDateTime last_check_time = settings.value( LAST_CHECK_TIME_KEY, default_time ).toDateTime(); // We want to check for a new version // no sooner than every six hours if ( last_check_time.secsTo( QDateTime::currentDateTime() ) > SECONDS_BETWEEN_CHECKS ) { settings.setValue( LAST_CHECK_TIME_KEY, QDateTime::currentDateTime() ); m_NetworkManager->get( QNetworkRequest( QUrl( UPDATE_XML_LOCATION ) ) ); } settings.endGroup(); }
const QString OpenExternally::editorDescriptionForResourceType(const Resource::ResourceType type) { QString editorDescription; if (mayOpen(type)) { SettingsStore settings; settings.beginGroup(SETTINGS_GROUP); const QString &editorDescriptionKey = QString("editor_description_") + RESOURCE_TYPE_NAME(type); const QString &editorKey = QString("editor_") + RESOURCE_TYPE_NAME(type); if (settings.contains(editorDescriptionKey)) { editorDescription = settings.value(editorDescriptionKey).toString(); } if (editorDescription.isEmpty()) { editorDescription = prettyApplicationName(settings.value(editorKey).toString()); } } return editorDescription; }
// Reads all the stored settings void FindReplace::ReadSettings() { SettingsStore settings; settings.beginGroup( SETTINGS_GROUP ); // Find and Replace history QStringList find_strings = settings.value( "find_strings" ).toStringList(); find_strings.removeDuplicates(); ui.cbFind->clear(); ui.cbFind->addItems( find_strings ); QStringList replace_strings = settings.value( "replace_strings" ).toStringList(); replace_strings.removeDuplicates(); ui.cbReplace->clear(); ui.cbReplace->addItems( replace_strings ); SetSearchMode( settings.value( "search_mode", 0 ).toInt() ); SetLookWhere( settings.value( "look_where", 0 ).toInt() ); SetSearchDirection( settings.value( "search_direction", 0 ).toInt() ); settings.endGroup(); }
const QString OpenExternally::selectEditorForResourceType(const Resource::ResourceType type) { if (!mayOpen(type)) { return EMPTY; } const QString &editorKey = QString("editor_") + RESOURCE_TYPE_NAME(type); const QString &editorDescriptionKey = QString("editor_description_") + RESOURCE_TYPE_NAME(type); SettingsStore settings; settings.beginGroup(SETTINGS_GROUP); #if defined(Q_OS_WIN32) // Windows barks about getenv or _wgetenv. This elicits no warnings and works with unicode paths static QString LAST_LOCATION = QProcessEnvironment::systemEnvironment().value("PROGRAMFILES", "").trimmed(); #else static QString LAST_LOCATION = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation); #endif QString lastEditor = settings.value(editorKey).toString(); if (!QFile::exists(lastEditor)) { lastEditor = LAST_LOCATION; if (!QFile::exists(lastEditor)) { lastEditor = LAST_LOCATION = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); } } static const QString NAME_FILTER = QObject::tr("Applications") #if defined(Q_OS_WIN32) + " (*.exe *.com *.bat *.cmd)" #elif defined(Q_OS_MAC) + " (*.app)" #else + " (*)" #endif ; const QString selectedFile = QFileDialog::getOpenFileName(0, QObject::tr("Open With"), lastEditor, NAME_FILTER, 0, QFileDialog::ReadOnly | QFileDialog::HideNameFilterDetails); if (!selectedFile.isEmpty()) { settings.setValue(editorKey, selectedFile); LAST_LOCATION = selectedFile; // Let the user choose a friendly menu name for the application QString editorDescription; QString prettyName = prettyApplicationName(selectedFile); OpenWithName name(prettyName, QApplication::activeWindow()); name.exec(); editorDescription = name.GetName(); if (editorDescription.isEmpty()) { editorDescription = prettyName; } settings.setValue(editorDescriptionKey, editorDescription); } return selectedFile; }