1
/***************************************************************************
5
Copyright 2001-2009 Otto Bruggeman <bruggie@gmail.com>
6
Copyright 2001-2003 John Firebaugh <jfirebaugh@kde.org>
7
Copyright 2007 Kevin Kofler <kevin.kofler@chello.at>
8
****************************************************************************/
10
/***************************************************************************
12
** This program is free software; you can redistribute it and/or modify
13
** it under the terms of the GNU General Public License as published by
14
** the Free Software Foundation; either version 2 of the License, or
15
** (at your option) any later version.
17
***************************************************************************/
19
#include "kompareprefdlg.h"
22
#include <QPushButton>
24
#include <KLocalizedString>
25
#include <KHelpClient>
26
#include <KStandardGuiItem>
33
KomparePrefDlg::KomparePrefDlg(ViewSettings* viewSets, DiffSettings* diffSets) : KPageDialog(nullptr)
35
setFaceType(KPageDialog::List);
36
setWindowTitle(i18nc("@title:window", "Preferences"));
37
setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Reset | QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel);
40
KGuiItem::assign(button(QDialogButtonBox::Reset), KStandardGuiItem::defaults());
42
// ok i need some stuff in that pref dlg...
43
//setIconListAllVisible(true);
45
m_viewPage = new ViewPage();
46
KPageWidgetItem* item = addPage(m_viewPage, i18nc("@title:tab", "View"));
47
item->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-theme")));
48
item->setHeader(i18nc("@title", "View Settings"));
49
m_viewPage->setSettings(viewSets);
51
m_diffPage = new DiffPage();
52
item = addPage(m_diffPage, i18nc("@title:tab", "Diff"));
53
item->setIcon(QIcon::fromTheme(QStringLiteral("text-x-patch")));
54
item->setHeader(i18nc("@title", "Diff Settings"));
55
m_diffPage->setSettings(diffSets);
57
// frame = addVBoxPage(i18n(""), i18n(""), UserIcon(""));
59
connect(button(QDialogButtonBox::Reset), &QPushButton::clicked, this, &KomparePrefDlg::slotDefault);
60
connect(button(QDialogButtonBox::Help), &QPushButton::clicked, this, &KomparePrefDlg::slotHelp);
61
connect(button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &KomparePrefDlg::slotApply);
62
connect(button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &KomparePrefDlg::slotOk);
63
connect(button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &KomparePrefDlg::slotCancel);
68
KomparePrefDlg::~KomparePrefDlg()
73
/** No descriptions */
74
void KomparePrefDlg::slotDefault()
76
// restore all defaults in the options...
77
m_viewPage->setDefaults();
78
m_diffPage->setDefaults();
81
/** No descriptions */
82
void KomparePrefDlg::slotHelp()
84
// figure out the current active page
85
QWidget* currentpage = currentPage()->widget();
86
if (dynamic_cast<ViewPage*>(currentpage))
88
// figure out the active tab
89
int currentTab = static_cast<ViewPage*>(currentpage)->m_tabWidget->currentIndex();
93
KHelpClient::invokeHelp(QStringLiteral("appearance"));
96
KHelpClient::invokeHelp(QStringLiteral("fonts"));
99
KHelpClient::invokeHelp(QStringLiteral("view-settings"));
102
else if (dynamic_cast<DiffPage*>(currentpage))
104
// figure out the active tab
105
int currentTab = static_cast<DiffPage*>(currentpage)->m_tabWidget->currentIndex();
109
KHelpClient::invokeHelp(QStringLiteral("diff"));
112
KHelpClient::invokeHelp(QStringLiteral("diff-format"));
115
KHelpClient::invokeHelp(QStringLiteral("options"));
118
KHelpClient::invokeHelp(QStringLiteral("exclude"));
121
KHelpClient::invokeHelp(QStringLiteral("diff-settings"));
124
else // Fallback since we had not added the code for the page/tab or forgotten about it
125
KHelpClient::invokeHelp(QStringLiteral("configure-preferences"));
128
/** No descriptions */
129
void KomparePrefDlg::slotApply()
131
// well apply the settings that are currently selected
135
Q_EMIT configChanged();
138
/** No descriptions */
139
void KomparePrefDlg::slotOk()
141
// Apply the settings that are currently selected
148
/** No descriptions */
149
void KomparePrefDlg::slotCancel()
151
// discard the current settings and use the present ones
152
m_viewPage->restore();
153
m_diffPage->restore();