summaryrefslogtreecommitdiffstats
path: root/src/configdialog.h
blob: 7d65578703d986939356be1432aab9e94e512c60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/****************************************************************************
    copyright            : (C) 2001-2006 by Robby Stephenson
    email                : [email protected]
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of version 2 of the GNU General Public License as  *
 *   published by the Free Software Foundation;                            *
 *                                                                         *
 ***************************************************************************/

#ifndef CONFIGDIALOG_H
#define CONFIGDIALOG_H

#include "fetch/fetcher.h"

#include <kdialogbase.h>
#include <tdelistview.h>

class TDEConfig;
class KLineEdit;
class KIntSpinBox;
class KPushButton;
class KIntNumInput;
class TDEFontCombo;
class KColorCombo;

class TQCheckBox;
class TQRadioButton;

namespace Tellico {
  class SourceListViewItem;
  namespace Fetch {
    class ConfigWidget;
  }
  namespace GUI {
    class ComboBox;
  }

/**
 * The configuration dialog class allows the user to change the global application
 * preferences.
 *
 * @author Robby Stephenson
 */
class ConfigDialog : public KDialogBase {
Q_OBJECT
  

public:
  /**
   * The constructor sets up the Tabbed dialog pages.
   *
   * @param parent A pointer to the parent widget
   * @param name The widget name
   */
  ConfigDialog(TQWidget* parent, const char* name=0);
  virtual ~ConfigDialog();

  /**
   * Reads the current configuration. Only the options which are not saved somewhere
   * else are read at this point.
   *
   * @param config A pointer to the TDEConfig object
   */
  void readConfiguration();
  /**
   * Saves the configuration. @ref TDEConfigBase::sync is called. This method is called
   * from the main Tellico object.
   *
   * @param config A pointer to the TDEConfig object
   */
  void saveConfiguration();

signals:
  /**
   * Emitted whenever the Ok or Apply button is clicked.
   */
  void signalConfigChanged();

private slots:
  /**
   * Called when anything gets changed
   */
  void slotModified();
  /**
   * Called when the Ok button is clicked.
   */
  void slotOk();
  /**
   * Called when the Apply button is clicked.
   */
  void slotApply();
  /**
   * Called when the Default button is clicked.
   */
  void slotDefault();
  /**
   * Update the help link for a page.
   *
  TQCheckBox* m_cbWriteImagesInFile; * @param w The page
   */
  void slotUpdateHelpLink(TQWidget* w);
  /**
   * Create a new Internet source
   */
  void slotNewSourceClicked();
  /**
   * Modify a Internet source
   */
  void slotModifySourceClicked();
  /**
   * Remove a Internet source
   */
  void slotRemoveSourceClicked();
  void slotSelectedSourceChanged(TQListViewItem* item);
  void slotMoveUpSourceClicked();
  void slotMoveDownSourceClicked();
  void slotNewStuffClicked();
  void slotShowTemplatePreview();
  void slotInstallTemplate();
  void slotDownloadTemplate();
  void slotDeleteTemplate();

private:
  /**
   * Sets-up the page for the general options.
   */
  void setupGeneralPage();
  void readGeneralConfig();
  /**
   * Sets-up the page for printing options.
   */
  void setupPrintingPage();
  void readPrintingConfig();
  /**
   * Sets-up the page for template options.
   */
  void setupTemplatePage();
  void readTemplateConfig();
  void setupFetchPage();
  /**
   * Load fetcher config
   */
  void readFetchConfig();

  SourceListViewItem* findItem(const TQString& path) const;
  void loadTemplateList();

  bool m_modifying;
  bool m_okClicked;

  TQRadioButton* m_rbImageInFile;
  TQRadioButton* m_rbImageInAppDir;
  TQRadioButton* m_rbImageInLocalDir;
  TQCheckBox* m_cbOpenLastFile;
  TQCheckBox* m_cbShowTipDay;
  TQCheckBox* m_cbCapitalize;
  TQCheckBox* m_cbFormat;
  KLineEdit* m_leCapitals;
  KLineEdit* m_leArticles;
  KLineEdit* m_leSuffixes;
  KLineEdit* m_lePrefixes;

  TQCheckBox* m_cbPrintHeaders;
  TQCheckBox* m_cbPrintFormatted;
  TQCheckBox* m_cbPrintGrouped;
  KIntSpinBox* m_imageWidthBox;
  KIntSpinBox* m_imageHeightBox;

  GUI::ComboBox* m_templateCombo;
  KPushButton* m_previewButton;
  TDEFontCombo* m_fontCombo;
  KIntNumInput* m_fontSizeInput;
  KColorCombo* m_baseColorCombo;
  KColorCombo* m_textColorCombo;
  KColorCombo* m_highBaseColorCombo;
  KColorCombo* m_highTextColorCombo;

  TDEListView* m_sourceListView;
  TQMap<SourceListViewItem*, Fetch::ConfigWidget*> m_configWidgets;
  TQPtrList<Fetch::ConfigWidget> m_newStuffConfigWidgets;
  TQPtrList<Fetch::ConfigWidget> m_removedConfigWidgets;
  KPushButton* m_modifySourceBtn;
  KPushButton* m_moveUpSourceBtn;
  KPushButton* m_moveDownSourceBtn;
  KPushButton* m_removeSourceBtn;
  KPushButton* m_newStuffBtn;
};

class GeneralFetcherInfo {
public:
  GeneralFetcherInfo(Fetch::Type t, const TQString& n, bool o) : type(t), name(n), updateOverwrite(o) {}
  Fetch::Type type;
  TQString name;
  bool updateOverwrite : 1;
};

class SourceListViewItem : public TDEListViewItem {
public:
  SourceListViewItem(TDEListView* parent, const GeneralFetcherInfo& info,
                     const TQString& groupName = TQString());

  SourceListViewItem(TDEListView* parent, TQListViewItem* after,
                     const GeneralFetcherInfo& info, const TQString& groupName = TQString());

  void setConfigGroup(const TQString& s) { m_configGroup = s; }
  const TQString& configGroup() const { return m_configGroup; }
  const Fetch::Type& fetchType() const { return m_info.type; }
  void setUpdateOverwrite(bool b) { m_info.updateOverwrite = b; }
  bool updateOverwrite() const { return m_info.updateOverwrite; }
  void setNewSource(bool b) { m_newSource = b; }
  bool isNewSource() const { return m_newSource; }
  void setFetcher(Fetch::Fetcher::Ptr fetcher);
  Fetch::Fetcher::Ptr fetcher() const { return m_fetcher; }

private:
  GeneralFetcherInfo m_info;
  TQString m_configGroup;
  bool m_newSource : 1;
  Fetch::Fetcher::Ptr m_fetcher;
};

} // end namespace
#endif