void
GeneralSettingsWidget::saveSettings()
{
    qDebug() << "has unsaved changes?" << hasUnsavedChanges();
    if ( hasUnsavedChanges() )
    {
        int currIndex = ui->languages->currentIndex();
        QString currLanguage = ui->languages->itemData( currIndex ).toString();

        if ( unicorn::AppSettings().value( "language", "" ) != currLanguage )
        {
            unicorn::AppSettings().setValue( "language", currLanguage );
            QMessageBoxBuilder( 0 )
                .setIcon( QMessageBox::Information )
                .setTitle( tr( "Restart needed" ) )
                .setText( tr( "You need to restart the application for the language change to take effect." ) )
                .exec();
        }

        unicorn::Settings().setValue( SETTING_SHOW_AS, ui->showAs->isChecked() );
        aApp->showAs( ui->showAs->isChecked() );

        // setting is for the 'Client' aplication for compatibility with old media player plugins
        unicorn::AppSettings( "Client" ).setValue( SETTING_LAUNCH_ITUNES, ui->launch->isChecked() );

        //
        unicorn::Settings().setValue( SETTING_NOTIFICATIONS, ui->notifications->isChecked() );
        unicorn::Settings().setValue( SETTING_LAST_RADIO, ui->lastRadio->isChecked() );
        unicorn::Settings().setValue( SETTING_SEND_CRASH_REPORTS, ui->sendCrashReports->isChecked() );
        unicorn::Settings().setValue( SETTING_CHECK_UPDATES, ui->updates->isChecked() );

        onSettingsSaved();
    }
}
Exemplo n.º 2
0
void GraphEditorTabs::handleExit(QCloseEvent *event)
{
    //save the currently selected editor tab
    getSettings().setValue("GraphEditorTabs/activeIndex", this->currentIndex());

    //exit logic -- save changes dialogs
    for (int i = 0; i < this->count(); i++)
    {
        auto editor = dynamic_cast<GraphEditor *>(this->widget(i));
        assert(editor != nullptr);
        if (not editor->hasUnsavedChanges()) continue;

        this->setCurrentIndex(i); //select this editor

        //yes/no dialog if we have unsaved changes
        const auto reply = QMessageBox::question(this,
            tr("Exit: unsaved changes!"),
            tr("Unsaved changes %1!\nWould you like to save changes?").arg(editor->getCurrentFilePath()),
            QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);

        if (reply == QMessageBox::Cancel)
        {
            event->ignore();
            return;
        }
        if (reply == QMessageBox::Yes) this->handleSave();
    }

    event->accept();
}
void
ScrobbleSettingsWidget::saveSettings()
{
    if ( hasUnsavedChanges() )
    {
        qDebug() << "Saving settings...";

        aApp->onScrobbleToggled( ui->scrobblingOn->isChecked() );

        unicorn::UserSettings userSettings;
        userSettings.setScrobblePoint( ui->scrobblePoint->value() );
        userSettings.setFingerprinting( ui->allowFingerprint->isChecked() );
        userSettings.setPodcasts( ui->podcasts->isChecked() );
        userSettings.setEnforceScrobbleTimeMax( ui->enfocreScrobbleTimeMax->isChecked() );

        QStringList exclusionDirs = ui->exclusionDirs->getExclusions();
        exclusionDirs.removeAll( "" );
        qDebug() << exclusionDirs;
        userSettings.setExclusionDirs( exclusionDirs );

        userSettings.sync();

        ScrobbleService::instance().scrobbleSettingsChanged();

        onSettingsSaved();
    }
}
Exemplo n.º 4
0
void Template::unloadTemplateFile()
{
	Q_ASSERT(template_state == Loaded);
	if (hasUnsavedChanges())
	{
		// The changes are lost
		setHasUnsavedChanges(false);
	}
	unloadTemplateFileImpl();
	template_state = Unloaded;
	emit templateStateChanged();
}
void
IpodSettingsWidget::saveSettings()
{
    if ( hasUnsavedChanges() )
    {
        // save settings
        qDebug() << "Saving settings...";

        unicorn::AppSettings().setAlwaysAsk( ui->alwaysAsk->isChecked() );

        // we need to restart iTunes for this setting to take affect
        bool currentlyEnabled = unicorn::OldeAppSettings().deviceScrobblingEnabled();

#ifndef Q_WS_X11
        if ( currentlyEnabled != ui->deviceScrobblingEnabled->isChecked() )
        {
#ifdef Q_OS_WIN
            QList<unicorn::IPluginInfo*> plugins;
            unicorn::ITunesPluginInfo* iTunesPluginInfo = new unicorn::ITunesPluginInfo;
            plugins << iTunesPluginInfo;
            unicorn::CloseAppsDialog* closeApps = new unicorn::CloseAppsDialog( plugins, this );
            closeApps->setOwnsPlugins( true );
#else
            unicorn::CloseAppsDialog* closeApps = new unicorn::CloseAppsDialog( this );
#endif
            if ( closeApps->result() != QDialog::Accepted )
                closeApps->exec();
            else
                closeApps->deleteLater();

            if ( closeApps->result() == QDialog::Accepted )
            {
                unicorn::OldeAppSettings().setDeviceScrobblingEnabled( ui->deviceScrobblingEnabled->isChecked() );
            }
            else
            {
                ui->deviceScrobblingEnabled->setChecked( currentlyEnabled );

                // The user didn't close their media players
                QMessageBoxBuilder( this ).setTitle( tr( "Setting not changed" ) )
                        .setIcon( QMessageBox::Warning )
                        .setText( tr( "You did not close iTunes for this setting to change" ) )
                        .setButtons( QMessageBox::Ok )
                        .exec();
            }
        }
#endif

        onSettingsSaved();
    }
}
void
ScrobbleSettingsWidget::saveSettings()
{
    if ( hasUnsavedChanges() )
    {
        qDebug() << "Saving settings...";

        aApp->onScrobbleToggled( ui->scrobblingOn->isChecked() );
        unicorn::UserSettings().setValue( SETTING_SCROBBLE_POINT, ui->scrobblePoint->value() );
        unicorn::UserSettings().setValue( SETTING_ALLOW_FINGERPRINTING, ui->allowFingerprint->isChecked() );
        unicorn::UserSettings().setValue( SETTING_PODCASTS, ui->podcasts->isChecked() );

        ScrobbleService::instance().scrobbleSettingsChanged();

        onSettingsSaved();
    }
}
Exemplo n.º 7
0
void Template::saveTemplateConfiguration(QXmlStreamWriter& xml, bool open)
{
	xml.writeStartElement("template");
	xml.writeAttribute("open", open ? "true" : "false");
	xml.writeAttribute("name", getTemplateFilename());
	xml.writeAttribute("path", getTemplatePath());
	xml.writeAttribute("relpath", getTemplateRelativePath());
	if (is_georeferenced)
		xml.writeAttribute("georef", "true");
	else
	{
		xml.writeAttribute("group", QString::number(template_group));
		
		xml.writeStartElement("transformations");
		if (adjusted)
			xml.writeAttribute("adjusted", "true");
		if (adjustment_dirty)
			xml.writeAttribute("adjustment_dirty", "true");
		int num_passpoints = (int)passpoints.size();
		xml.writeAttribute("passpoints", QString::number(num_passpoints));
		
		transform.save(xml, "active");
		other_transform.save(xml, "other");
		
		for (int i = 0; i < num_passpoints; ++i)
			passpoints[i].save(xml);
		
		map_to_template.save(xml, "map_to_template");
		template_to_map.save(xml, "template_to_map");
		template_to_map_other.save(xml, "template_to_map_other");
		
		xml.writeEndElement(/*transformations*/);
	}
	
	saveTypeSpecificTemplateConfiguration(xml);
	
	if (open && hasUnsavedChanges())
	{
		// Save the template itself (e.g. image, gpx file, etc.)
		saveTemplateFile();
		setHasUnsavedChanges(false); // TODO: Error handling?
	}
	xml.writeEndElement(/*template*/);
}
void
GeneralSettingsWidget::saveSettings()
{
    qDebug() << "has unsaved changes?" << hasUnsavedChanges();
    if ( hasUnsavedChanges() )
    {
        int currIndex = ui->languages->currentIndex();
        QString currLanguage = ui->languages->itemData( currIndex ).toString();

        if ( unicorn::AppSettings().value( "language", "" ) != currLanguage )
        {
            if ( currLanguage == ""  )
                QLocale::setDefault( QLocale::system() );
            else
                QLocale::setDefault( QLocale( currLanguage ) );

            unicorn::AppSettings().setValue( "language", currLanguage );
//            QMessageBoxBuilder( 0 )
//                .setIcon( QMessageBox::Information )
//                .setTitle( tr( "Restart needed" ) )
//                .setText( tr( "You need to restart the application for the language change to take effect." ) )
//                .exec();
        }

        // setting is for the 'Client' aplication for compatibility with old media player plugins
        unicorn::AppSettings( APP_LAUNCH ).setValue( SETTING_LAUNCH_ITUNES, ui->launch->isChecked() );

        unicorn::Settings().setValue( SETTING_NOTIFICATIONS, ui->notifications->isChecked() );
        unicorn::Settings().setValue( SETTING_LAST_RADIO, ui->lastRadio->isChecked() );
        unicorn::Settings().setValue( SETTING_SEND_CRASH_REPORTS, ui->sendCrashReports->isChecked() );
        unicorn::Settings().setValue( SETTING_CHECK_UPDATES, ui->updates->isChecked() );

#ifdef Q_OS_MAC
        int showWhereIndex = unicorn::Settings().value( SETTING_SHOW_WHERE, -1 ).toInt();
        bool showAs = ui->showWhere->currentIndex() != 1;

        unicorn::Settings().setValue( SETTING_SHOW_WHERE, ui->showWhere->currentIndex() );
        unicorn::Settings().setValue( SETTING_SHOW_AS, showAs );

        aApp->showAs( showAs );
        aApp->hideDockIcon( ui->showWhere->currentIndex() == 2 );

        if ( ( showWhereIndex != 2 && ui->showWhere->currentIndex() == 2 )
             || (showWhereIndex == 2 && ui->showWhere->currentIndex() != 2) )
        {
            int button = QMessageBoxBuilder( 0 )
                                .setIcon( QMessageBox::Question )
                                .setTitle( tr( "Restart now?" ) )
                                .setText( tr( "Would you like to restart now for the dock setting to take effect?" ) )
                                .setButtons( QMessageBox::Yes | QMessageBox::No )
                                .exec();

            if ( button == QMessageBox::Yes )
                aApp->restart();
        }
#else
        unicorn::Settings().setValue( SETTING_SHOW_AS, ui->showAs->isChecked() );
        aApp->showAs( ui->showAs->isChecked() );
#endif

        onSettingsSaved();
    }
}
void
GeneralSettingsWidget::saveSettings()
{
    qDebug() << "has unsaved changes?" << hasUnsavedChanges();
    if ( hasUnsavedChanges() )
    {
        bool restartNeeded = false;

        int currIndex = ui->languages->currentIndex();
        QString currLanguage = ui->languages->itemData( currIndex ).toString();

        if ( unicorn::AppSettings().value( "language", "" ) != currLanguage )
        {
            if ( currLanguage == ""  )
                QLocale::setDefault( QLocale::system() );
            else
                QLocale::setDefault( QLocale( currLanguage ) );

            unicorn::AppSettings().setValue( "language", currLanguage );

#ifdef Q_OS_MAC
            aApp->translate();
#endif

            restartNeeded = true;
        }

        // setting is for the 'Client' aplication for compatibility with old media player plugins
        unicorn::OldeAppSettings().setLaunchWithMediaPlayers( ui->launch->isChecked() );

        unicorn::Settings().setNotifications( ui->notifications->isChecked() );
        unicorn::Settings().setSendCrashReports( ui->sendCrashReports->isChecked() );
        unicorn::Settings().setCheckForUpdates( ui->updates->isChecked() );
        unicorn::Settings().setBetaUpdates( ui->beta->isChecked() );

        aApp->setBetaUpdates( ui->beta->isChecked() );

#ifdef Q_OS_MAC
        /// media keys
        unicorn::Settings().setValue( "mediaKeys", ui->mediaKeys->isChecked() );
        aApp->setMediaKeysEnabled( ui->mediaKeys->isChecked() );

        /// dock hiding
        bool showDockOld = unicorn::Settings().showDock();
        unicorn::Settings().setShowDock( ui->showDock->isChecked() );

        if ( showDockOld != ui->showDock->isChecked() )
        {
            // the setting has changed
            aApp->showDockIcon( ui->showDock->isChecked() );

            // Hiding the dock icon while the app is running is not supported on Snow Leopard
            if ( QSysInfo::MacintoshVersion <= QSysInfo::MV_10_6 && !ui->showDock->isChecked() )
                restartNeeded = true;
        }
#endif

        unicorn::Settings().setShowAS( ui->showAs->isChecked() );
        aApp->showAs( ui->showAs->isChecked() );

        onSettingsSaved();

        if ( restartNeeded )
        {
            int button = QMessageBoxBuilder( this )
                            .setIcon( QMessageBox::Question )
                            .setTitle( tr( "Restart now?" ) )
                            .setText( tr( "An application restart is required for the change to take effect. Would you like to restart now?" ) )
                            .setButtons( QMessageBox::Yes | QMessageBox::No )
                            .exec();

            if ( button == QMessageBox::Yes )
                aApp->restart();
        }
    }
}