~neon/kompare/master

« back to all changes in this revision

Viewing changes to komparepart/kompareprefdlg.cpp

  • Committer: Friedrich W. H. Kossebau
  • Date: 2020-11-13 21:43:33 UTC
  • Revision ID: git-v1:79fce0df862602a8e2790d7d14f4037744a006f6
Reorganize sources into src/ subfolder

NO_CHANGELOG

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
                                kompareprefdlg.cpp
3
 
                                ------------------
4
 
        begin                   : Sun Mar 4 2001
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
 
****************************************************************************/
9
 
 
10
 
/***************************************************************************
11
 
**
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.
16
 
**
17
 
***************************************************************************/
18
 
 
19
 
#include "kompareprefdlg.h"
20
 
 
21
 
#include <QTabWidget>
22
 
#include <QPushButton>
23
 
 
24
 
#include <KLocalizedString>
25
 
#include <KHelpClient>
26
 
#include <KStandardGuiItem>
27
 
 
28
 
#include "diffpage.h"
29
 
#include "viewpage.h"
30
 
 
31
 
// implementation
32
 
 
33
 
KomparePrefDlg::KomparePrefDlg(ViewSettings* viewSets, DiffSettings* diffSets) : KPageDialog(nullptr)
34
 
{
35
 
    setFaceType(KPageDialog::List);
36
 
    setWindowTitle(i18nc("@title:window", "Preferences"));
37
 
    setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Reset | QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel);
38
 
    setModal(true);
39
 
 
40
 
    KGuiItem::assign(button(QDialogButtonBox::Reset), KStandardGuiItem::defaults());
41
 
 
42
 
    // ok i need some stuff in that pref dlg...
43
 
    //setIconListAllVisible(true);
44
 
 
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);
50
 
 
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);
56
 
 
57
 
//     frame = addVBoxPage(i18n(""), i18n(""), UserIcon(""));
58
 
 
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);
64
 
 
65
 
    adjustSize();
66
 
}
67
 
 
68
 
KomparePrefDlg::~KomparePrefDlg()
69
 
{
70
 
 
71
 
}
72
 
 
73
 
/** No descriptions */
74
 
void KomparePrefDlg::slotDefault()
75
 
{
76
 
    // restore all defaults in the options...
77
 
    m_viewPage->setDefaults();
78
 
    m_diffPage->setDefaults();
79
 
}
80
 
 
81
 
/** No descriptions */
82
 
void KomparePrefDlg::slotHelp()
83
 
{
84
 
    // figure out the current active page
85
 
    QWidget* currentpage = currentPage()->widget();
86
 
    if (dynamic_cast<ViewPage*>(currentpage))
87
 
    {
88
 
        // figure out the active tab
89
 
        int currentTab = static_cast<ViewPage*>(currentpage)->m_tabWidget->currentIndex();
90
 
        switch (currentTab)
91
 
        {
92
 
        case 0:
93
 
            KHelpClient::invokeHelp(QStringLiteral("appearance"));
94
 
            break;
95
 
        case 1:
96
 
            KHelpClient::invokeHelp(QStringLiteral("fonts"));
97
 
            break;
98
 
        default:
99
 
            KHelpClient::invokeHelp(QStringLiteral("view-settings"));
100
 
        }
101
 
    }
102
 
    else if (dynamic_cast<DiffPage*>(currentpage))
103
 
    {
104
 
        // figure out the active tab
105
 
        int currentTab = static_cast<DiffPage*>(currentpage)->m_tabWidget->currentIndex();
106
 
        switch (currentTab)
107
 
        {
108
 
        case 0:
109
 
            KHelpClient::invokeHelp(QStringLiteral("diff"));
110
 
            break;
111
 
        case 1:
112
 
            KHelpClient::invokeHelp(QStringLiteral("diff-format"));
113
 
            break;
114
 
        case 2:
115
 
            KHelpClient::invokeHelp(QStringLiteral("options"));
116
 
            break;
117
 
        case 3:
118
 
            KHelpClient::invokeHelp(QStringLiteral("exclude"));
119
 
            break;
120
 
        default:
121
 
            KHelpClient::invokeHelp(QStringLiteral("diff-settings"));
122
 
        }
123
 
    }
124
 
    else // Fallback since we had not added the code for the page/tab or forgotten about it
125
 
        KHelpClient::invokeHelp(QStringLiteral("configure-preferences"));
126
 
}
127
 
 
128
 
/** No descriptions */
129
 
void KomparePrefDlg::slotApply()
130
 
{
131
 
    // well apply the settings that are currently selected
132
 
    m_viewPage->apply();
133
 
    m_diffPage->apply();
134
 
 
135
 
    Q_EMIT configChanged();
136
 
}
137
 
 
138
 
/** No descriptions */
139
 
void KomparePrefDlg::slotOk()
140
 
{
141
 
    // Apply the settings that are currently selected
142
 
    m_viewPage->apply();
143
 
    m_diffPage->apply();
144
 
 
145
 
    //accept();
146
 
}
147
 
 
148
 
/** No descriptions */
149
 
void KomparePrefDlg::slotCancel()
150
 
{
151
 
    // discard the current settings and use the present ones
152
 
    m_viewPage->restore();
153
 
    m_diffPage->restore();
154
 
 
155
 
    //reject();
156
 
}