diff --git a/src/option/k3bmiscoptiontab.cpp b/src/option/k3bmiscoptiontab.cpp index 507395382..c76d52502 100644 --- a/src/option/k3bmiscoptiontab.cpp +++ b/src/option/k3bmiscoptiontab.cpp @@ -1,152 +1,154 @@ /* * * Copyright (C) 2003-2008 Sebastian Trueg * * This file is part of the K3b project. * Copyright (C) 1998-2008 Sebastian Trueg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * See the file "COPYING" for the exact licensing terms. */ #include "k3bmiscoptiontab.h" #include "k3bpluginmanager.h" #include "k3bcore.h" #include "k3bglobalsettings.h" #include "k3binteractiondialog.h" #include "k3bintmapcombobox.h" #include #include #include #include #include #include #include #include #include #include #include K3b::MiscOptionTab::MiscOptionTab(QWidget *parent ) : QWidget(parent) { setupUi( this ); m_editTempDir->setMode( KFile::Directory ); m_comboActionDialogSettings->insertItem( K3b::InteractionDialog::LOAD_K3B_DEFAULTS, i18n("Default Settings"), i18n("Load the K3b Defaults at dialog startup.") ); m_comboActionDialogSettings->insertItem( K3b::InteractionDialog::LOAD_SAVED_SETTINGS, i18n("Saved Settings"), i18n("Load the settings saved by the user at dialog startup.") ); m_comboActionDialogSettings->insertItem( K3b::InteractionDialog::LOAD_LAST_SETTINGS, i18n("Last Used Settings"), i18n("Load the last used settings at dialog startup.") ); m_comboActionDialogSettings->addGlobalWhatsThisText( i18n("K3b handles three sets of settings in action dialogs " "(action dialogs include the CD Copy dialog or the Audio CD " "project dialog):"), i18n("One of these sets is loaded once an action dialog is opened. " "This setting defines which set it will be.") ); + + connect(m_checkSaveOnExit, &QCheckBox::stateChanged, [this]{ Q_EMIT changed(); }); } K3b::MiscOptionTab::~MiscOptionTab() { } void K3b::MiscOptionTab::readSettings() { KConfigGroup c = KSharedConfig::openConfig()->group( "General Options" ); m_checkSaveOnExit->setChecked( c.readEntry( "ask_for_saving_changes_on_exit", true ) ); m_checkShowSplash->setChecked( c.readEntry("Show splash", true) ); m_checkShowProgressOSD->setChecked(c.readEntry("Show progress OSD", false)); m_checkHideMainWindowWhileWriting->setChecked( c.readEntry( "hide main window while writing", false ) ); m_checkKeepDialogsOpen->setChecked( c.readEntry( "keep action dialogs open", false ) ); m_comboActionDialogSettings->setSelectedValue( c.readEntry( "action dialog startup settings", ( int )K3b::InteractionDialog::LOAD_SAVED_SETTINGS ) ); m_checkSystemConfig->setChecked( c.readEntry( "check system config", true ) ); m_editTempDir->setUrl( QUrl::fromLocalFile( k3bcore->globalSettings()->defaultTempPath() ) ); // if( c.readEntry( "Multiple Instances", "smart" ) == "smart" ) // m_radioMultipleInstancesSmart->setChecked(true); // else // m_radioMultipleInstancesNew->setChecked(true); } bool K3b::MiscOptionTab::saveSettings() { KConfigGroup c = KSharedConfig::openConfig()->group( "General Options" ); c.writeEntry( "ask_for_saving_changes_on_exit", m_checkSaveOnExit->isChecked() ); c.writeEntry( "Show splash", m_checkShowSplash->isChecked() ); c.writeEntry( "Show progress OSD", m_checkShowProgressOSD->isChecked() ); c.writeEntry( "hide main window while writing", m_checkHideMainWindowWhileWriting->isChecked() ); c.writeEntry( "keep action dialogs open", m_checkKeepDialogsOpen->isChecked() ); c.writeEntry( "check system config", m_checkSystemConfig->isChecked() ); c.writeEntry( "action dialog startup settings", m_comboActionDialogSettings->selectedValue() ); QString tempDir = m_editTempDir->url().toLocalFile(); QFileInfo fi( tempDir ); if( fi.isRelative() ) { fi.setFile( fi.absoluteFilePath() ); } if( !fi.exists() ) { if( KMessageBox::questionYesNo( this, i18n("Folder (%1) does not exist. Create?",tempDir), i18n("Create Folder"), KGuiItem( i18n("Create") ), KStandardGuiItem::cancel() ) == KMessageBox::Yes ) { if( !QDir().mkpath( fi.absoluteFilePath() ) ) { KMessageBox::error( this, i18n("Unable to create folder %1",tempDir) ); return false; } } else { // the dir does not exist and the user doesn't want to create it return false; } } if( fi.isFile() ) { KMessageBox::information( this, i18n("You specified a file for the temporary folder. " "K3b will use its base path as the temporary folder."), i18n("Warning"), "temp file only using base path" ); fi.setFile( fi.path() ); } // check for writing permission if( !fi.isWritable() ) { KMessageBox::error( this, i18n("You do not have permission to write to %1.",fi.absoluteFilePath()) ); return false; } m_editTempDir->setUrl( QUrl::fromLocalFile( fi.absoluteFilePath() ) ); k3bcore->globalSettings()->setDefaultTempPath( m_editTempDir->url().toLocalFile() ); // if( m_radioMultipleInstancesSmart->isChecked() ) // c.writeEntry( "Multiple Instances", "smart" ); // else // c.writeEntry( "Multiple Instances", "always_new" ); return true; } diff --git a/src/option/k3bmiscoptiontab.h b/src/option/k3bmiscoptiontab.h index c823b93a5..a4e4564eb 100644 --- a/src/option/k3bmiscoptiontab.h +++ b/src/option/k3bmiscoptiontab.h @@ -1,36 +1,39 @@ /* * * Copyright (C) 2003-2008 Sebastian Trueg * * This file is part of the K3b project. * Copyright (C) 1998-2008 Sebastian Trueg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * See the file "COPYING" for the exact licensing terms. */ #ifndef K3BMISCOPTIONTAB_H #define K3BMISCOPTIONTAB_H #include "ui_base_k3bmiscoptiontab.h" namespace K3b { class MiscOptionTab : public QWidget, public Ui::base_K3bMiscOptionTab { Q_OBJECT public: MiscOptionTab(QWidget *parent=0); ~MiscOptionTab(); void readSettings(); bool saveSettings(); + +Q_SIGNALS: + void changed(); }; } #endif diff --git a/src/option/k3boptiondialog.cpp b/src/option/k3boptiondialog.cpp index 928280d6c..31caef387 100644 --- a/src/option/k3boptiondialog.cpp +++ b/src/option/k3boptiondialog.cpp @@ -1,218 +1,222 @@ /* * * $Id$ * Copyright (C) 2003-2008 Sebastian Trueg * * This file is part of the K3b project. * Copyright (C) 1998-2008 Sebastian Trueg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * See the file "COPYING" for the exact licensing terms. */ #include "k3boptiondialog.h" #include "k3bcore.h" #include "k3bdeviceoptiontab.h" #include "k3badvancedoptiontab.h" #include "k3bexternalbinoptiontab.h" #include "k3bmiscoptiontab.h" #include "k3bthemeoptiontab.h" #include "k3bpluginoptiontab.h" #include "k3bcddboptiontab.h" #include "k3bsystemproblemdialog.h" #include "k3bnotifyoptiontab.h" #include #include #include #include #include #include #include #include #include #include #include #include // TODO: handle the default-settings K3b::OptionDialog::OptionDialog(QWidget *parent ) : KPageDialog( parent ) { setFaceType( List ); setWindowTitle( i18n("Settings") ); this->setStandardButtons( QDialogButtonBox::Ok | QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Apply ); setupMiscPage(); setupDevicePage(); setupProgramsPage(); setupNotifyPage(); setupPluginPage(); setupThemePage(); setupCddbPage(); setupAdvancedPage(); m_miscOptionTab->readSettings(); m_deviceOptionTab->readDevices(); m_externalBinOptionTab->readSettings(); m_notifyOptionTab->readSettings(); m_themeOptionTab->readSettings(); m_advancedOptionTab->readSettings(); // if we don't do this the dialog start really huge // because of the label in the device-tab setFixedSize(700, 582); + buttonBox()->button(QDialogButtonBox::Apply)->setDefault(false); connect( this->buttonBox()->button( QDialogButtonBox::Ok ), SIGNAL(clicked()), SLOT(slotOk()) ); connect( this->buttonBox()->button( QDialogButtonBox::RestoreDefaults ), SIGNAL(clicked()), SLOT(slotDefault()) ); connect( this->buttonBox()->button( QDialogButtonBox::Apply ), SIGNAL(clicked()), SLOT(slotApply()) ); } K3b::OptionDialog::~OptionDialog() { } void K3b::OptionDialog::setCurrentPage( ConfigPage page ) { Pages::const_iterator pageIt = m_pages.constFind( page ); if( pageIt != m_pages.constEnd() ) { KPageDialog::setCurrentPage( *pageIt ); } } void K3b::OptionDialog::slotOk() { if( saveSettings() ) { accept(); KConfigGroup grp( KSharedConfig::openConfig(), "General Options" ); if( grp.readEntry( "check system config", true ) ) K3b::SystemProblemDialog::checkSystem(); } } void K3b::OptionDialog::slotApply() { saveSettings(); } bool K3b::OptionDialog::saveSettings() { m_deviceOptionTab->saveDevices(); m_externalBinOptionTab->saveSettings(); m_notifyOptionTab->saveSettings(); m_themeOptionTab->saveSettings(); m_cddbOptionTab->apply(); m_advancedOptionTab->saveSettings(); if( !m_miscOptionTab->saveSettings() ) return false; return true; } void K3b::OptionDialog::slotDefault() { } void K3b::OptionDialog::setupMiscPage() { m_miscOptionTab = new K3b::MiscOptionTab; + connect(m_miscOptionTab, &K3b::MiscOptionTab::changed, [this](){ + buttonBox()->button(QDialogButtonBox::Apply)->setDefault(true); + }); m_miscPage = addPage( m_miscOptionTab, i18n("Misc") ); m_miscPage->setHeader( i18n("Miscellaneous Settings") ); m_miscPage->setIcon( QIcon::fromTheme( "preferences-other" ) ); m_pages.insert( Misc, m_miscPage ); } void K3b::OptionDialog::setupDevicePage() { m_deviceOptionTab = new K3b::DeviceOptionTab; m_devicePage = addPage( m_deviceOptionTab, i18n("Devices") ); m_devicePage->setHeader( i18n("Optical Devices") ); QIcon icon = QIcon::fromTheme("drive-optical"); if (icon.isNull()) { icon = QIcon::fromTheme("media-optical"); } m_devicePage->setIcon(icon); m_pages.insert( Devices, m_devicePage ); } void K3b::OptionDialog::setupProgramsPage() { m_externalBinOptionTab = new K3b::ExternalBinOptionTab( k3bcore->externalBinManager() ); m_programsPage = addPage( m_externalBinOptionTab, i18n("Programs") ); m_programsPage->setHeader( i18n("Setup External Programs") ); m_programsPage->setIcon( QIcon::fromTheme( "system-run" ) ); m_pages.insert( Programs, m_programsPage ); } void K3b::OptionDialog::setupNotifyPage() { m_notifyOptionTab = new K3b::NotifyOptionTab; m_notifyPage = addPage( m_notifyOptionTab, i18n("Notifications") ); m_notifyPage->setHeader( i18n("System Notifications") ); m_notifyPage->setIcon( QIcon::fromTheme( "preferences-desktop-notification" ) ); m_pages.insert( Notifications, m_notifyPage ); } void K3b::OptionDialog::setupPluginPage() { m_pluginOptionTab = new K3b::PluginOptionTab; m_pluginPage = addPage( m_pluginOptionTab, i18n("Plugins") ); m_pluginPage->setHeader( i18n("K3b Plugin Configuration") ); QIcon icon = QIcon::fromTheme("preferences-plugin"); if (icon.isNull()) { icon = QIcon::fromTheme("application-x-addon"); } m_pluginPage->setIcon(icon); m_pages.insert( Plugins, m_pluginPage ); } void K3b::OptionDialog::setupThemePage() { m_themeOptionTab = new K3b::ThemeOptionTab; m_themePage = addPage( m_themeOptionTab, i18n("Themes") ); m_themePage->setHeader( i18n("K3b GUI Themes") ); m_themePage->setIcon( QIcon::fromTheme( "preferences-desktop-theme" ) ); m_pages.insert( Themes, m_themePage ); } void K3b::OptionDialog::setupCddbPage() { m_cddbOptionTab = new K3b::CddbOptionTab; m_cddbPage = addPage( m_cddbOptionTab, i18n("CDDB") ); m_cddbPage->setHeader( i18n("CDDB Audio CD Info Retrieval") ); m_cddbPage->setIcon( QIcon::fromTheme( "media-optical-audio" ) ); m_pages.insert( Cddb, m_cddbPage ); } void K3b::OptionDialog::setupAdvancedPage() { m_advancedOptionTab = new K3b::AdvancedOptionTab; m_advancedPage = addPage( m_advancedOptionTab, i18n("Advanced") ); m_advancedPage->setHeader( i18n("Advanced Settings") ); m_advancedPage->setIcon( QIcon::fromTheme( "media-optical-recordable" ) ); m_pages.insert( Advanced, m_advancedPage ); }