Commit 1ed88f7c authored by Michael Reeves's avatar Michael Reeves

Fix Options Dialog connections preferences save now

*use default preference name.
*header cleanup
parent 99002817
......@@ -24,8 +24,8 @@
#include "options.h"
#include "progress.h"
#include <kmessagebox.h>
#include <klocalizedstring.h>
#include <KMessageBox>
#include <KLocalizedString>
#include <QFileInfo>
#include <QDir>
......@@ -1926,6 +1926,7 @@ void calcDiff3LineListTrim(
(*i3A).lineA = (*i3).lineA;
(*i3A).bAEqB = true;
(*i3A).bAEqC = true;
(*i3).lineA = -1;
(*i3).bAEqB = false;
(*i3).bAEqC = false;
......
......@@ -37,13 +37,13 @@
#include <QRunnable>
#include <QThreadPool>
#include <QMimeData>
#include <QFileDialog>
#include <klocalizedstring.h>
#include <KLocalizedString>
#include <cmath>
#include <cstdlib>
#include <assert.h>
#include <QFileDialog>
static QAtomicInt s_runnableCount = 0;
......@@ -2026,7 +2026,7 @@ void DiffTextWindowFrame::slotBrowseButtonClicked()
{
QString current = d->m_pFileSelection->text();
QUrl newURL = QFileDialog::getOpenFileUrl(this, QString(), QUrl::fromUserInput(current, QString(), QUrl::AssumeLocalFile), 0);
QUrl newURL = QFileDialog::getOpenFileUrl(this, i18n("Open File"), QUrl::fromUserInput(current, QString(), QUrl::AssumeLocalFile));
if ( !newURL.isEmpty() )
{
DiffTextWindow* pDTW = d->m_pDiffTextWindow;
......@@ -2115,7 +2115,7 @@ void EncodingLabel::insertCodec( const QString& visibleCodecName, QTextCodec* pC
if (currentTextCodecEnum==CodecMIBEnum)
pAction->setChecked(true);
pMenu->addAction(pAction);
connect(pAction, &QAction::triggered, this, &EncodingLabel::slotEncodingChanged);
connect(pAction, SIGNAL(triggered()), this, SLOT(slotEncodingChanged()));
codecEnumList.append(CodecMIBEnum);
}
}
......
......@@ -165,7 +165,7 @@ KDiff3App::KDiff3App( QWidget* pParent, const char* /*name*/, KDiff3Part* pKDiff
// This is just a convenience variable to make code that accesses options more readable
m_pOptions = &m_pOptionDialog->m_options;
m_pOptionDialog->readOptions( isPart() ? KSharedConfig::openConfig(QStringLiteral("kdiff3_part.rc")) : KSharedConfig::openConfig(QStringLiteral("kdiff3_shell.rc")) );
m_pOptionDialog->readOptions( KSharedConfig::openConfig() );
// Option handling: Only when pParent==0 (no parent)
int argCount = KDiff3Shell::getParser()->optionNames().count() + KDiff3Shell::getParser()->positionalArguments().count();
......@@ -684,7 +684,7 @@ void KDiff3App::saveOptions( KSharedConfigPtr config )
bool KDiff3App::queryClose()
{
saveOptions( isPart() ? KSharedConfig::openConfig(QStringLiteral("kdiff3_part.rc")) : KSharedConfig::openConfig(QStringLiteral("kdiff3_shell.rc")) );
saveOptions( KSharedConfig::openConfig() );
if(m_bOutputModified)
{
......
......@@ -17,9 +17,10 @@
* Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include <QApplication>
#include <QCheckBox>
#include <QComboBox>
#include <QDialogButtonBox>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
......@@ -34,16 +35,15 @@
#include <QGridLayout>
#include <QPixmap>
#include <QFrame>
#include <QVBoxLayout>
#include <QFontDatabase>
#include <QFontDialog>
#include <QPushButton>
#include <QApplication>
#include <QFontDatabase>
#include <KConfigGroup>
#include <KColorButton>
#include <KFontChooser>
#include <KIconLoader>
#include <KSharedConfig>
#include <KMessageBox>
#include <KMainWindow> //For ktoolbar.h
#include <KToolBar>
#include <KHelpClient>
#include <KLocalizedString>
......@@ -52,12 +52,6 @@
#include "optiondialog.h"
#include "diff.h"
#include "smalldialogs.h"
//FIXME: Verifiy which includes are needed only for kde and why.
#ifndef KREPLACEMENTS_H
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QPushButton>
#endif
#define KDIFF3_CONFIG_GROUP "KDiff3 Options"
......@@ -555,21 +549,12 @@ OptionDialog::OptionDialog( bool bShowDirMergeSettings, QWidget *parent, char *n
{
setFaceType( List );
setWindowTitle( i18n("Configure") );
mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::RestoreDefaults|QDialogButtonBox::Apply);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
QPushButton *okButton = mButtonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
//WARNING mainLayout->addWidget(buttonBox) must be last item in layout.
mainLayout->addWidget(mButtonBox);
okButton->setDefault(true);
setStandardButtons( QDialogButtonBox::Help | QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Apply | QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
// TODO KF5 necessary? setDefaultButton( Ok );
setObjectName( name );
setModal( true );
//showButtonSeparator( true );
//showButtonSeparator( true );01bc7c9af262353e7623bc02e5277fd59180183b
//setHelp( "kdiff3/index.html", QString::null );
setupFontPage();
......@@ -589,29 +574,16 @@ OptionDialog::OptionDialog( bool bShowDirMergeSettings, QWidget *parent, char *n
// Initialize all values in the dialog
resetToDefaults();
slotApply();
//connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(mButtonBox, &QDialogButtonBox::clicked, this, &OptionDialog::buttonClicked);
connect(mButtonBox, &QDialogButtonBox::helpRequested, this, &OptionDialog::helpRequested);
connect(button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &OptionDialog::slotApply);
connect(button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &OptionDialog::slotOk);
connect(button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, &OptionDialog::slotDefault);
connect(button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &QDialog::reject);
connect(button(QDialogButtonBox::Help), &QPushButton::clicked, this, &OptionDialog::helpRequested);
//connect(this, &OptionDialog::applyClicked, this, &OptionDialog::slotApply);
connect(mButtonBox, &QDialogButtonBox::accepted, this, &OptionDialog::slotOk);
//helpClicked() is connected in KDiff3App::KDiff3App -- Really where?
//connect(this, &OptionDialog::defaultClicked, this, &OptionDialog::slotDefault);
}
void OptionDialog::buttonClicked(QAbstractButton *button){
//for reasons beyond my comprehension QDialogButtonBox::standardButton() is non-static
switch(mButtonBox->standardButton(button)){
case QDialogButtonBox::Apply:
slotApply();
break;
case QDialogButtonBox::RestoreDefaults:
slotDefault();
break;
default:
break;
}
}
void OptionDialog::helpRequested() {
KHelpClient::invokeHelp( QStringLiteral( "kdiff3/index.html" ), QString());
......@@ -655,24 +627,28 @@ void OptionDialog::setupFontPage( void )
{
QFrame* page = new QFrame();
KPageWidgetItem *pageItem = new KPageWidgetItem( page, i18n("Font") );
QFont defaultFont;
pageItem->setHeader( i18n("Editor & Diff Output Font") );
pageItem->setIcon( QIcon::fromTheme(QStringLiteral("preferences-desktop-font")) );
pageItem->setIcon( QIcon::fromTheme(QStringLiteral("font-select-symbolic")) );
addPage( pageItem );
QVBoxLayout *topLayout = new QVBoxLayout( page );
topLayout->setMargin( 5 );
//requires QT 5.2 or later.
defaultFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
static const QFont defaultFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);;
static QFont defaultAppFont = QApplication::font();
OptionFontChooser* pAppFontChooser = new OptionFontChooser( defaultAppFont, "ApplicationFont", &m_options.m_appFont, page, this );
topLayout->addWidget( pAppFontChooser );
OptionFontChooser* pFontChooser = new OptionFontChooser( defaultFont, "Font", &m_options.m_font, page, this );
topLayout->addWidget( pFontChooser );
pFontChooser->setTitle(i18n("File view font"));
QGridLayout *gbox = new QGridLayout();
topLayout->addLayout( gbox );
QGridLayout *gbox = new QGridLayout();
topLayout->addLayout( gbox );
//int line=0;
// This currently does not work (see rendering in class DiffTextWindow)
......@@ -690,7 +666,7 @@ void OptionDialog::setupColorPage( void )
QFrame* page = new QFrame();
KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n("Color") );
pageItem->setHeader( i18n("Colors Settings") );
pageItem->setIcon( QIcon::fromTheme(QStringLiteral("preferences-desktop-color")) );
pageItem->setIcon( QIcon::fromTheme(QStringLiteral("colormanagement")) );
addPage( pageItem );
QVBoxLayout *topLayout = new QVBoxLayout( page );
......@@ -903,7 +879,7 @@ void OptionDialog::setupDiffPage( void )
QFrame* page = new QFrame();
KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n( "Diff" ) );
pageItem->setHeader( i18n( "Diff Settings" ) );
pageItem->setIcon( QIcon::fromTheme( QStringLiteral( "preferences-other" ) ) );
pageItem->setIcon( QIcon::fromTheme( QStringLiteral( "text-x-patch" ) ) );
addPage( pageItem );
......@@ -989,7 +965,7 @@ void OptionDialog::setupMergePage( void )
QFrame* page = new QFrame();
KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n( "Merge" ) );
pageItem->setHeader( i18n( "Merge Settings" ) );
pageItem->setIcon( QIcon::fromTheme( QStringLiteral( "plasmagik" ) ) );
pageItem->setIcon( QIcon::fromTheme( QStringLiteral( "merge" ) ) );
addPage( pageItem );
QVBoxLayout *topLayout = new QVBoxLayout( page );
......@@ -1178,7 +1154,7 @@ void OptionDialog::setupDirectoryMergePage( void )
QFrame* page = new QFrame();
KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n( "Directory" ) );
pageItem->setHeader( i18n( "Directory" ) );
pageItem->setIcon( QIcon::fromTheme( QStringLiteral( "folder" ) ) );
pageItem->setIcon( QIcon::fromTheme( QStringLiteral( "inode-directory" ) ) );
addPage( pageItem );
QVBoxLayout *topLayout = new QVBoxLayout( page );
......@@ -1432,7 +1408,7 @@ void OptionDialog::setupRegionalPage( void )
QFrame* page = new QFrame();
KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n("Regional Settings") );
pageItem->setHeader( i18n("Regional Settings") );
pageItem->setIcon( QIcon::fromTheme(QStringLiteral("locale")) );
pageItem->setIcon( QIcon::fromTheme(QStringLiteral("preferences-desktop-locale")) );
addPage( pageItem );
QVBoxLayout *topLayout = new QVBoxLayout( page );
......@@ -1681,7 +1657,7 @@ void OptionDialog::setupIntegrationPage( void )
QFrame* page = new QFrame();
KPageWidgetItem* pageItem = new KPageWidgetItem( page, i18n( "Integration" ) );
pageItem->setHeader( i18n( "Integration Settings" ) );
pageItem->setIcon( QIcon::fromTheme( QStringLiteral( "preferences-desktop-launch-feedback" ) ) );
pageItem->setIcon( QIcon::fromTheme( QStringLiteral( "utilities-terminal" ) ) );
addPage( pageItem );
QVBoxLayout *topLayout = new QVBoxLayout( page );
......@@ -1790,7 +1766,7 @@ void OptionDialog::setupKeysPage( void )
//QVBox *page = addVBoxPage( i18n("Keys"), i18n("KeyDialog" ),
// BarIcon("fonts", KIconLoader::SizeMedium ) );
//QVBoxLayout *topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() );
//QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
// new KFontChooser( page,"font",false/*onlyFixed*/,QStringList(),false,6 );
//m_pKeyDialog=new KKeyDialog( false, 0 );
//topLayout->addWidget( m_pKeyDialog );
......
......@@ -63,7 +63,7 @@ protected Q_SLOTS:
virtual void slotDefault( void );
virtual void slotOk( void );
virtual void slotApply( void );
virtual void buttonClicked( QAbstractButton* );
//virtual void buttonClicked( QAbstractButton* );
virtual void helpRequested();
void slotEncodingChanged();
......@@ -77,7 +77,7 @@ private:
std::list<OptionItem*> m_optionItemList;
QDialogButtonBox *mButtonBox;
//QDialogButtonBox *mButtonBox;
OptionCheckBox* m_pSameEncoding;
OptionEncodingComboBox* m_pEncodingAComboBox;
OptionCheckBox* m_pAutoDetectUnicodeA;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment