1 /***************************************************************************
2  *   Copyright (C) 2003 by Sébastien Laoût                                 *
3  *   slaout@linux62.org                                                    *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 
21 #include "settings.h"
22 
23 #include <QCheckBox>
24 #include <QGroupBox>
25 #include <QLabel>
26 #include <QPushButton>
27 #include <QHBoxLayout>
28 #include <QGridLayout>
29 #include <QVBoxLayout>
30 #include <QDate>
31 #include <QGuiApplication>
32 #include <QSpinBox>
33 #include <QUrl>
34 #include <QLineEdit>
35 #include <QLocale>
36 #include <QMimeType>
37 #include <QMimeDatabase>
38 #include <QTabWidget>
39 
40 #include <KConfig>
41 #include <KConfigGroup>
42 #include <KLocalizedString>
43 #include <KIO/Global>
44 
45 #include "kgpgme.h"
46 #include "basketscene.h"
47 #include "linklabel.h"
48 #include "variouswidgets.h"
49 #include "aboutdata.h"
50 
51 /** Settings */
52 
53 // General:                                      // TODO: Use this grouping everywhere!
54 bool    Settings::s_useSystray           = true;
55 bool    Settings::s_usePassivePopup      = true;
56 bool    Settings::s_playAnimations       = true;
57 bool    Settings::s_showNotesToolTip     = true; // TODO: RENAME: useBasketTooltips
58 bool    Settings::s_confirmNoteDeletion  = true;
59 bool    Settings::s_bigNotes             = false;
60 bool    Settings::s_autoBullet           = true;
61 bool    Settings::s_pasteAsPlainText     = false;
62 bool    Settings::s_exportTextTags       = true;
63 bool    Settings::s_useGnuPGAgent        = false;
64 bool    Settings::s_treeOnLeft           = true;
65 bool    Settings::s_filterOnTop          = false;
66 int     Settings::s_defImageX            = 300;
67 int     Settings::s_defImageY            = 200;
68 bool    Settings::s_enableReLockTimeout  = true;
69 int     Settings::s_reLockTimeoutMinutes = 0;
70 int     Settings::s_newNotesPlace        = 1;
71 int     Settings::s_viewTextFileContent  = false;
72 int     Settings::s_viewHtmlFileContent  = false;
73 int     Settings::s_viewImageFileContent = false;
74 int     Settings::s_viewSoundFileContent = false;
75 // Applications:
76 bool    Settings::s_htmlUseProg          = false; // TODO: RENAME: s_*App (with KService!)
77 bool    Settings::s_imageUseProg         = true;
78 bool    Settings::s_animationUseProg     = true;
79 bool    Settings::s_soundUseProg         = false;
80 QString Settings::s_htmlProg             = "quanta";
81 QString Settings::s_imageProg            = "kolourpaint";
82 QString Settings::s_animationProg        = "gimp";
83 QString Settings::s_soundProg            = "";
84 // Addictive Features:
85 bool    Settings::s_groupOnInsertionLine = false;
86 int     Settings::s_middleAction         = 0;
87 bool    Settings::s_showIconInSystray    = false; // TODO: RENAME: basketIconInSystray
88 bool    Settings::s_hideOnMouseOut       = false;
89 int     Settings::s_timeToHideOnMouseOut = 0;
90 bool    Settings::s_showOnMouseIn        = false;
91 int     Settings::s_timeToShowOnMouseIn  = 1;
92 // Rememberings:
93 int     Settings::s_defIconSize          = 32; // TODO: RENAME: importIconSize
94 bool    Settings::s_blinkedFilter        = false;
95 bool    Settings::s_startDocked          = false;
96 int     Settings::s_basketTreeWidth      = -1;
97 bool    Settings::s_welcomeBasketsAdded  = false;
98 QString Settings::s_dataFolder           = "";
99 QDate   Settings::s_lastBackup           = QDate();
100 QPoint  Settings::s_mainWindowPosition   = QPoint();
101 QSize   Settings::s_mainWindowSize       = QSize();
102 bool    Settings::s_showEmptyBasketInfo  = true;
103 bool    Settings::s_spellCheckTextNotes  = true;
104 // Version Sync
105 bool    Settings::s_versionSyncEnabled   = false;
106 
loadConfig()107 void Settings::loadConfig()
108 {
109     LinkLook defaultSoundLook;
110     LinkLook defaultFileLook;
111     LinkLook defaultLocalLinkLook;
112     LinkLook defaultNetworkLinkLook;
113     LinkLook defaultLauncherLook; /* italic  bold    underlining                color      hoverColor  iconSize  preview */
114     LinkLook defaultCrossReferenceLook;
115 
116     defaultSoundLook.setLook(false,  false,  LinkLook::Never,           QColor(),  QColor(),   32,       LinkLook::None);
117     defaultFileLook.setLook(false,  false,  LinkLook::Never,           QColor(),  QColor(),   32,       LinkLook::TwiceIconSize);
118     defaultLocalLinkLook.setLook(true,   false,  LinkLook::OnMouseHover,    QColor(),  QColor(),   22,       LinkLook::TwiceIconSize);
119     defaultNetworkLinkLook.setLook(false,  false,  LinkLook::OnMouseOutside,  QColor(),  QColor(),   16,       LinkLook::None);
120     defaultLauncherLook.setLook(false,  true,   LinkLook::Never,           QColor(),  QColor(),   48,       LinkLook::None);
121     defaultCrossReferenceLook.setLook(false, false, LinkLook::OnMouseHover, QColor(), QColor(), 16, LinkLook::None);
122 
123     loadLinkLook(LinkLook::soundLook,       "Sound Look",        defaultSoundLook);
124     loadLinkLook(LinkLook::fileLook,        "File Look",         defaultFileLook);
125     loadLinkLook(LinkLook::localLinkLook,   "Local Link Look",   defaultLocalLinkLook);
126     loadLinkLook(LinkLook::networkLinkLook, "Network Link Look", defaultNetworkLinkLook);
127     loadLinkLook(LinkLook::launcherLook,    "Launcher Look",     defaultLauncherLook);
128     loadLinkLook(LinkLook::crossReferenceLook, "Cross Reference Look", defaultCrossReferenceLook);
129 
130     KConfigGroup config = Global::config()->group("Main window");    // TODO: Split with a "System tray icon" group !
131     setTreeOnLeft(config.readEntry("treeOnLeft",           true));
132     setFilterOnTop(config.readEntry("filterOnTop",          false));
133     setPlayAnimations(config.readEntry("playAnimations",       true));
134     setShowNotesToolTip(config.readEntry("showNotesToolTip",     true));
135     setBigNotes(config.readEntry("bigNotes",             false));
136     setConfirmNoteDeletion(config.readEntry("confirmNoteDeletion",  true));
137     setPasteAsPlainText(config.readEntry("pasteAsPlainText",  false));
138     setAutoBullet(config.readEntry("autoBullet",           true));
139     setExportTextTags(config.readEntry("exportTextTags",       true));
140     setUseGnuPGAgent(config.readEntry("useGnuPGAgent",        false));
141     setBlinkedFilter(config.readEntry("blinkedFilter",        false));
142     setEnableReLockTimeout(config.readEntry("enableReLockTimeout",  true));
143     setReLockTimeoutMinutes(config.readEntry("reLockTimeoutMinutes", 0));
144     setUseSystray(config.readEntry("useSystray",           true));
145     setShowIconInSystray(config.readEntry("showIconInSystray",    false));
146     setStartDocked(config.readEntry("startDocked",          false));
147     setMiddleAction(config.readEntry("middleAction",         0));
148     setGroupOnInsertionLine(config.readEntry("groupOnInsertionLine", false));
149     setSpellCheckTextNotes(config.readEntry("spellCheckTextNotes",  true));
150     setHideOnMouseOut(config.readEntry("hideOnMouseOut",       false));
151     setTimeToHideOnMouseOut(config.readEntry("timeToHideOnMouseOut", 0));
152     setShowOnMouseIn(config.readEntry("showOnMouseIn",        false));
153     setTimeToShowOnMouseIn(config.readEntry("timeToShowOnMouseIn",  1));
154     setBasketTreeWidth(config.readEntry("basketTreeWidth",      -1));
155     setUsePassivePopup(config.readEntry("usePassivePopup",      true));
156     setWelcomeBasketsAdded(config.readEntry("welcomeBasketsAdded",  false));
157     setDataFolder(config.readEntry("dataFolder",           ""));
158     setLastBackup(config.readEntry("lastBackup", QDate()));
159     setMainWindowPosition(config.readEntry("position", QPoint()));
160     setMainWindowSize(config.readEntry("size",     QSize()));
161 
162     config = Global::config()->group("Notification Messages");
163     setShowEmptyBasketInfo(config.readEntry("emptyBasketInfo",      true));
164 
165     config = Global::config()->group("Programs");
166     setIsHtmlUseProg(config.readEntry("htmlUseProg",          false));
167     setIsImageUseProg(config.readEntry("imageUseProg",         true));
168     setIsAnimationUseProg(config.readEntry("animationUseProg",     true));
169     setIsSoundUseProg(config.readEntry("soundUseProg",         false));
170     setHtmlProg(config.readEntry("htmlProg",             "quanta"));
171     setImageProg(config.readEntry("imageProg",            "kolourpaint"));
172     setAnimationProg(config.readEntry("animationProg",        "gimp"));
173     setSoundProg(config.readEntry("soundProg",            ""));
174 
175     config = Global::config()->group("Note Addition");
176     setNewNotesPlace(config.readEntry("newNotesPlace",        1));
177     setViewTextFileContent(config.readEntry("viewTextFileContent",  false));
178     setViewHtmlFileContent(config.readEntry("viewHtmlFileContent",  false));
179     setViewImageFileContent(config.readEntry("viewImageFileContent", true));
180     setViewSoundFileContent(config.readEntry("viewSoundFileContent", true));
181 
182     config = Global::config()->group("Insert Note Default Values");
183     setDefImageX(config.readEntry("defImageX",   300));
184     setDefImageY(config.readEntry("defImageY",   200));
185     setDefIconSize(config.readEntry("defIconSize", 32));
186 
187     config = Global::config()->group("MainWindow Toolbar mainToolBar");
188     // The first time we start, we define "Text Alongside Icons" for the main toolbar.
189     // After that, the user is free to hide the text from the icons or customize as he/she want.
190     // But it is a good default (Fitt's Laws, better looking, less "empty"-feeling), especially for this application.
191 //  if (!config->readEntry("alreadySetIconTextRight", false)) {
192 //      config->writeEntry( "IconText",                "IconTextRight" );
193 //      config->writeEntry( "alreadySetIconTextRight", true            );
194 //  }
195     if (!config.readEntry("alreadySetToolbarSettings", false)) {
196         config.writeEntry("IconText", "IconOnly"); // In 0.6.0 Alpha versions, it was made "IconTextRight". We're back to IconOnly
197         config.writeEntry("Index",    "0");        // Make sure the main toolbar is the first...
198         config = Global::config()->group("MainWindow Toolbar richTextEditToolBar");
199         config.writeEntry("Position", "Top");      // In 0.6.0 Alpha versions, it was made "Bottom"
200         config.writeEntry("Index",    "1");        // ... and the rich text toolbar is on the right of the main toolbar
201         config = Global::config()->group("MainWindow Toolbar mainToolBar");
202         config.writeEntry("alreadySetToolbarSettings", true);
203     }
204 
205     config = Global::config()->group("Version Sync");
206     setVersionSyncEnabled(config.readEntry("enabled", false));
207 }
208 
saveConfig()209 void Settings::saveConfig()
210 {
211     saveLinkLook(LinkLook::soundLook,       "Sound Look");
212     saveLinkLook(LinkLook::fileLook,        "File Look");
213     saveLinkLook(LinkLook::localLinkLook,   "Local Link Look");
214     saveLinkLook(LinkLook::networkLinkLook, "Network Link Look");
215     saveLinkLook(LinkLook::launcherLook,    "Launcher Look");
216     saveLinkLook(LinkLook::crossReferenceLook,"Cross Reference Look");
217 
218     KConfigGroup config = Global::config()->group("Main window");
219     config.writeEntry("treeOnLeft",           treeOnLeft());
220     config.writeEntry("filterOnTop",          filterOnTop());
221     config.writeEntry("playAnimations",       playAnimations());
222     config.writeEntry("showNotesToolTip",     showNotesToolTip());
223     config.writeEntry("confirmNoteDeletion",  confirmNoteDeletion());
224     config.writeEntry("pasteAsPlainText",     pasteAsPlainText());
225     config.writeEntry("bigNotes",             bigNotes());
226     config.writeEntry("autoBullet",           autoBullet());
227     config.writeEntry("exportTextTags",       exportTextTags());
228 #ifdef HAVE_LIBGPGME
229     if (KGpgMe::isGnuPGAgentAvailable())
230         config.writeEntry("useGnuPGAgent",    useGnuPGAgent());
231 #endif
232     config.writeEntry("blinkedFilter",        blinkedFilter());
233     config.writeEntry("enableReLockTimeout",  enableReLockTimeout());
234     config.writeEntry("reLockTimeoutMinutes", reLockTimeoutMinutes());
235     config.writeEntry("useSystray",           useSystray());
236     config.writeEntry("showIconInSystray",    showIconInSystray());
237     config.writeEntry("startDocked",          startDocked());
238     config.writeEntry("middleAction",         middleAction());
239     config.writeEntry("groupOnInsertionLine", groupOnInsertionLine());
240     config.writeEntry("spellCheckTextNotes",  spellCheckTextNotes());
241     config.writeEntry("hideOnMouseOut",       hideOnMouseOut());
242     config.writeEntry("timeToHideOnMouseOut", timeToHideOnMouseOut());
243     config.writeEntry("showOnMouseIn",        showOnMouseIn());
244     config.writeEntry("timeToShowOnMouseIn",  timeToShowOnMouseIn());
245     config.writeEntry("basketTreeWidth",      basketTreeWidth());
246     config.writeEntry("usePassivePopup",      usePassivePopup());
247     config.writeEntry("welcomeBasketsAdded",  welcomeBasketsAdded());
248     config.writePathEntry("dataFolder",        dataFolder());
249     config.writeEntry("lastBackup",           QDate(lastBackup()));
250     config.writeEntry("position",             mainWindowPosition());
251     config.writeEntry("size",                 mainWindowSize());
252 
253     config = Global::config()->group("Notification Messages");
254     config.writeEntry("emptyBasketInfo",      showEmptyBasketInfo());
255 
256     config = Global::config()->group("Programs");
257     config.writeEntry("htmlUseProg",          isHtmlUseProg());
258     config.writeEntry("imageUseProg",         isImageUseProg());
259     config.writeEntry("animationUseProg",     isAnimationUseProg());
260     config.writeEntry("soundUseProg",         isSoundUseProg());
261     config.writeEntry("htmlProg",             htmlProg());
262     config.writeEntry("imageProg",            imageProg());
263     config.writeEntry("animationProg",        animationProg());
264     config.writeEntry("soundProg",            soundProg());
265 
266     config = Global::config()->group("Note Addition");
267     config.writeEntry("newNotesPlace",        newNotesPlace());
268     config.writeEntry("viewTextFileContent",  viewTextFileContent());
269     config.writeEntry("viewHtmlFileContent",  viewHtmlFileContent());
270     config.writeEntry("viewImageFileContent", viewImageFileContent());
271     config.writeEntry("viewSoundFileContent", viewSoundFileContent());
272 
273     config = Global::config()->group("Insert Note Default Values");
274     config.writeEntry("defImageX",         defImageX());
275     config.writeEntry("defImageY",         defImageY());
276     config.writeEntry("defIconSize",       defIconSize());
277 
278     config = Global::config()->group("Version Sync");
279     config.writeEntry("enabled", versionSyncEnabled());
280 
281     config.sync();
282 }
283 
loadLinkLook(LinkLook * look,const QString & name,const LinkLook & defaultLook)284 void Settings::loadLinkLook(LinkLook *look, const QString &name, const LinkLook &defaultLook)
285 {
286     KConfigGroup config = Global::config()->group(name);
287 
288     QString underliningStrings[] = { "Always", "Never", "OnMouseHover", "OnMouseOutside" };
289     QString defaultUnderliningString = underliningStrings[defaultLook.underlining()];
290 
291     QString previewStrings[] = { "None", "IconSize", "TwiceIconSize", "ThreeIconSize" };
292     QString defaultPreviewString = previewStrings[defaultLook.preview()];
293 
294     bool    italic            = config.readEntry("italic",      defaultLook.italic());
295     bool    bold              = config.readEntry("bold",        defaultLook.bold());
296     QString underliningString = config.readEntry("underlining", defaultUnderliningString);
297     QColor  color             = config.readEntry("color",       defaultLook.color());
298     QColor  hoverColor        = config.readEntry("hoverColor",  defaultLook.hoverColor());
299     int     iconSize          = config.readEntry("iconSize",    defaultLook.iconSize());
300     QString previewString     = config.readEntry("preview",     defaultPreviewString);
301 
302     int underlining = 0;
303     if (underliningString == underliningStrings[1]) underlining = 1;
304     else if (underliningString == underliningStrings[2]) underlining = 2;
305     else if (underliningString == underliningStrings[3]) underlining = 3;
306 
307     int preview = 0;
308     if (previewString == previewStrings[1]) preview = 1;
309     else if (previewString == previewStrings[2]) preview = 2;
310     else if (previewString == previewStrings[3]) preview = 3;
311 
312     look->setLook(italic, bold, underlining, color, hoverColor, iconSize, preview);
313 }
314 
saveLinkLook(LinkLook * look,const QString & name)315 void Settings::saveLinkLook(LinkLook *look, const QString &name)
316 {
317     KConfigGroup config = Global::config()->group(name);
318 
319     QString underliningStrings[] = { "Always", "Never", "OnMouseHover", "OnMouseOutside" };
320     QString underliningString = underliningStrings[look->underlining()];
321 
322     QString previewStrings[] = { "None", "IconSize", "TwiceIconSize", "ThreeIconSize" };
323     QString previewString = previewStrings[look->preview()];
324 
325     config.writeEntry("italic",      look->italic());
326     config.writeEntry("bold",        look->bold());
327     config.writeEntry("underlining", underliningString);
328     config.writeEntry("color",       look->color());
329     config.writeEntry("hoverColor",  look->hoverColor());
330     config.writeEntry("iconSize",    look->iconSize());
331     config.writeEntry("preview",     previewString);
332 }
333 
setBigNotes(bool big)334 void Settings::setBigNotes(bool big)
335 {
336     if (big == s_bigNotes)
337         return;
338 
339     s_bigNotes = big;
340     // Big notes for accessibility reasons OR Standard small notes:
341     Note::NOTE_MARGIN      = (big ? 4 : 2);
342     Note::INSERTION_HEIGHT = (big ? 5 : 3);
343     Note::EXPANDER_WIDTH   = 9;
344     Note::EXPANDER_HEIGHT  = 9;
345     Note::GROUP_WIDTH      = 2 * Note::NOTE_MARGIN + Note::EXPANDER_WIDTH;
346     Note::HANDLE_WIDTH     = Note::GROUP_WIDTH;
347     Note::RESIZER_WIDTH    = Note::GROUP_WIDTH;
348     Note::TAG_ARROW_WIDTH  = 5 + (big ? 4 : 0);
349     Note::EMBLEM_SIZE      = 16;
350     Note::MIN_HEIGHT       = 2 * Note::NOTE_MARGIN + Note::EMBLEM_SIZE;
351 
352     if (Global::bnpView)
353         Global::bnpView->relayoutAllBaskets();
354 }
355 
setAutoBullet(bool yes)356 void Settings::setAutoBullet(bool yes)
357 {
358     s_autoBullet = yes;
359     if (Global::bnpView && Global::bnpView->currentBasket()) {
360         Global::bnpView->currentBasket()->editorPropertiesChanged();
361     }
362 }
363 
364 /** GeneralPage */
365 
GeneralPage(QWidget * parent,const char * name)366 GeneralPage::GeneralPage(QWidget * parent, const char * name)
367         : KCModule(parent)
368 {
369     KAboutData* about = new AboutData();
370     about->setComponentName(name);
371     setAboutData(about);
372 
373     QVBoxLayout *layout = new QVBoxLayout(this);
374     QHBoxLayout *hLay;
375     QLabel      *label;
376     HelpLabel   *hLabel;
377 
378     QGridLayout *gl = new QGridLayout;
379     layout->addLayout(gl);
380     gl->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding), 0, 2);
381 
382     // Basket Tree Position:
383     m_treeOnLeft = new KComboBox(this);
384     m_treeOnLeft->addItem(i18n("On left"));
385     m_treeOnLeft->addItem(i18n("On right"));
386 
387     label = new QLabel(this);
388     label->setText(i18n("&Basket tree position:"));
389     label->setBuddy(m_treeOnLeft);
390 
391     gl->addWidget(label, 0, 0);
392     gl->addWidget(m_treeOnLeft, 0, 1);
393     connect(m_treeOnLeft, SIGNAL(activated(int)), this, SLOT(changed()));
394 
395     // Filter Bar Position:
396     m_filterOnTop = new KComboBox(this);
397     m_filterOnTop->addItem(i18n("On top"));
398     m_filterOnTop->addItem(i18n("On bottom"));
399 
400     label = new QLabel(this);
401     label->setText(i18n("&Filter bar position:"));
402     label->setBuddy(m_filterOnTop);
403 
404     gl->addWidget(label,         1, 0);
405     gl->addWidget(m_filterOnTop, 1, 1);
406     connect(m_filterOnTop, SIGNAL(activated(int)), this, SLOT(changed()));
407 
408     // Use balloons to Report Results of Global Actions:
409     hLay = new QHBoxLayout(0);
410     m_usePassivePopup = new QCheckBox(i18n("&Use balloons to report results of global actions"), this);
411     connect(m_usePassivePopup, SIGNAL(stateChanged(int)), this, SLOT(changed()));
412     hLabel = new HelpLabel(
413         i18n("What are global actions?"),
414         ("<p>" + i18n("You can configure global shortcuts to do some actions without having to show the main window. For instance, you can paste the clipboard content, take a color from "
415                       "a point of the screen, etc. You can also use the mouse scroll wheel over the system tray icon to change the current basket. Or use the middle mouse button "
416                       "on that icon to paste the current selection.") + "</p>" +
417          "<p>" + i18n("When doing so, %1 pops up a little balloon message to inform you the action has been successfully done. You can disable that balloon.", QGuiApplication::applicationDisplayName()) + "</p>" +
418          "<p>" + i18n("Note that those messages are smart enough to not appear if the main window is visible. This is because you already see the result of your actions in the main window.") + "</p>"),
419         this);
420     hLay->addWidget(m_usePassivePopup);
421     hLay->addWidget(hLabel);
422     hLay->addStretch();
423     layout->addLayout(hLay);
424 
425     // System Tray Icon:
426     QGroupBox *gbSys = new QGroupBox(i18n("System Tray Icon"), this);
427     layout->addWidget(gbSys);
428     QVBoxLayout *sysLay = new QVBoxLayout(gbSys);
429 
430     // Dock in System Tray:
431     m_useSystray = new QCheckBox(i18n("&Dock in system tray"), gbSys);
432     sysLay->addWidget(m_useSystray);
433     connect(m_useSystray, SIGNAL(stateChanged(int)), this, SLOT(changed()));
434 
435     m_systray = new QWidget(gbSys);
436     QVBoxLayout *subSysLay = new QVBoxLayout(m_systray);
437     sysLay->addWidget(m_systray);
438 
439     // Show Current Basket Icon in System Tray Icon:
440     m_showIconInSystray = new QCheckBox(i18n("&Show current basket icon in system tray icon"), m_systray);
441     subSysLay->addWidget(m_showIconInSystray);
442     connect(m_showIconInSystray, SIGNAL(stateChanged(int)), this, SLOT(changed()));
443 
444     QGridLayout *gs = new QGridLayout;
445     subSysLay->addLayout(gs);
446     gs->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding), 0, 2);
447 
448     // Hide Main Window when Mouse Goes out of it for Some Time:
449     m_timeToHideOnMouseOut = new QSpinBox();
450     m_hideOnMouseOut = new QCheckBox(i18n("&Hide main window when mouse leaves it for"), m_systray);
451     m_timeToHideOnMouseOut->setRange(0, 600);
452     m_timeToHideOnMouseOut->setSuffix(i18n(" tenths of seconds"));
453     gs->addWidget(m_hideOnMouseOut,       0, 0);
454     gs->addWidget(m_timeToHideOnMouseOut, 0, 1);
455     connect(m_hideOnMouseOut, SIGNAL(stateChanged(int)), this, SLOT(changed()));
456     connect(m_timeToHideOnMouseOut, SIGNAL(valueChanged(int)), this, SLOT(changed()));
457 //  subSysLay->addWidget(
458 
459     // Show Main Window when Mouse Hovers over the System Tray Icon for Some Time:
460     m_timeToShowOnMouseIn = new QSpinBox();
461     m_showOnMouseIn  = new QCheckBox(i18n("Show &main window when mouse hovers over the system tray icon for"), m_systray);
462     m_timeToShowOnMouseIn->setRange(0, 600);
463     m_timeToShowOnMouseIn->setSuffix(i18n(" tenths of seconds"));
464     gs->addWidget(m_showOnMouseIn,       1, 0);
465     gs->addWidget(m_timeToShowOnMouseIn, 1, 1);
466     connect(m_showOnMouseIn, SIGNAL(stateChanged(int)), this, SLOT(changed()));
467     connect(m_timeToShowOnMouseIn, SIGNAL(valueChanged(int)), this, SLOT(changed()));
468 
469     connect(m_hideOnMouseOut, SIGNAL(toggled(bool)), m_timeToHideOnMouseOut, SLOT(setEnabled(bool)));
470     connect(m_showOnMouseIn,  SIGNAL(toggled(bool)), m_timeToShowOnMouseIn,  SLOT(setEnabled(bool)));
471 
472     connect(m_useSystray,     SIGNAL(toggled(bool)), m_systray,              SLOT(setEnabled(bool)));
473 
474     layout->insertStretch(-1);
475     load();
476 }
477 
load()478 void GeneralPage::load()
479 {
480     m_treeOnLeft->setCurrentIndex((int)!Settings::treeOnLeft());
481     m_filterOnTop->setCurrentIndex((int)!Settings::filterOnTop());
482 
483     m_usePassivePopup->setChecked(Settings::usePassivePopup());
484 
485     m_useSystray->setChecked(Settings::useSystray());
486     m_systray->setEnabled(Settings::useSystray());
487 
488     m_showIconInSystray->setChecked(Settings::showIconInSystray());
489 
490     m_hideOnMouseOut->setChecked(Settings::hideOnMouseOut());
491     m_timeToHideOnMouseOut->setValue(Settings::timeToHideOnMouseOut());
492     m_timeToHideOnMouseOut->setEnabled(Settings::hideOnMouseOut());
493 
494     m_showOnMouseIn->setChecked(Settings::showOnMouseIn());
495     m_timeToShowOnMouseIn->setValue(Settings::timeToShowOnMouseIn());
496     m_timeToShowOnMouseIn->setEnabled(Settings::showOnMouseIn());
497 
498 
499 }
500 
save()501 void GeneralPage::save()
502 {
503     Settings::setTreeOnLeft(! m_treeOnLeft->currentIndex());
504     Settings::setFilterOnTop(! m_filterOnTop->currentIndex());
505 
506     Settings::setUsePassivePopup(m_usePassivePopup->isChecked());
507 
508     Settings::setUseSystray(m_useSystray->isChecked());
509     Settings::setShowIconInSystray(m_showIconInSystray->isChecked());
510     Settings::setShowOnMouseIn(m_showOnMouseIn->isChecked());
511     Settings::setTimeToShowOnMouseIn(m_timeToShowOnMouseIn->value());
512     Settings::setHideOnMouseOut(m_hideOnMouseOut->isChecked());
513     Settings::setTimeToHideOnMouseOut(m_timeToHideOnMouseOut->value());
514 }
515 
defaults()516 void GeneralPage::defaults()
517 {
518     // TODO
519 }
520 
521 /** BasketsPage */
522 
BasketsPage(QWidget * parent,const char * name)523 BasketsPage::BasketsPage(QWidget * parent, const char * name)
524         : KCModule(parent)
525 {
526     KAboutData* about = new AboutData();
527     about->setComponentName(name);
528     setAboutData(about);
529 
530     QVBoxLayout *layout = new QVBoxLayout(this);
531     QHBoxLayout *hLay;
532     HelpLabel   *hLabel;
533 
534     // Appearance:
535 
536     QGroupBox *appearanceBox = new QGroupBox(i18n("Appearance"), this);
537     QVBoxLayout* appearanceLayout = new QVBoxLayout;
538     appearanceBox->setLayout(appearanceLayout);
539     layout->addWidget(appearanceBox);
540 
541     m_playAnimations = new QCheckBox(i18n("Ani&mate changes in baskets"), appearanceBox);
542     appearanceLayout->addWidget(m_playAnimations);
543     connect(m_playAnimations, SIGNAL(stateChanged(int)), this, SLOT(changed()));
544 
545     m_showNotesToolTip = new QCheckBox(i18n("&Show tooltips in baskets"), appearanceBox);
546     appearanceLayout->addWidget(m_showNotesToolTip);
547     connect(m_showNotesToolTip, SIGNAL(stateChanged(int)), this, SLOT(changed()));
548 
549     m_bigNotes = new QCheckBox(i18n("&Big notes"), appearanceBox);
550     appearanceLayout->addWidget(m_bigNotes);
551     connect(m_bigNotes, SIGNAL(stateChanged(int)), this, SLOT(changed()));
552 
553     // Behavior:
554 
555     QGroupBox *behaviorBox = new QGroupBox(i18n("Behavior"), this);
556     QVBoxLayout* behaviorLayout = new QVBoxLayout;
557     behaviorBox->setLayout(behaviorLayout);
558     layout->addWidget(behaviorBox);
559 
560     m_autoBullet = new QCheckBox(i18n("&Transform lines starting with * or - to lists in text editors"), behaviorBox);
561     behaviorLayout->addWidget(m_autoBullet);
562     connect(m_autoBullet, SIGNAL(stateChanged(int)), this, SLOT(changed()));
563 
564     m_confirmNoteDeletion = new QCheckBox(i18n("Ask confirmation before &deleting notes"), behaviorBox);
565     behaviorLayout->addWidget(m_confirmNoteDeletion);
566     connect(m_confirmNoteDeletion, SIGNAL(stateChanged(int)), this, SLOT(changed()));
567 
568     m_pasteAsPlainText = new QCheckBox(i18n("Do not keep text formatting when pasting"), behaviorBox);
569     behaviorLayout->addWidget(m_pasteAsPlainText);
570     connect(m_pasteAsPlainText, SIGNAL(stateChanged(int)), this, SLOT(changed()));
571 
572     QWidget *widget = new QWidget(behaviorBox);
573     behaviorLayout->addWidget(widget);
574     hLay = new QHBoxLayout(widget);
575     m_exportTextTags = new QCheckBox(i18n("&Export tags in texts"), widget);
576     connect(m_exportTextTags, SIGNAL(stateChanged(int)), this, SLOT(changed()));
577 
578     hLabel = new HelpLabel(
579         i18n("When does this apply?"),
580         "<p>" + i18n("It does apply when you copy and paste, or drag and drop notes to a text editor.") + "</p>" +
581         "<p>" + i18n("If enabled, this property lets you paste the tags as textual equivalents.") + "<br>" +
582         i18n("For instance, a list of notes with the <b>To Do</b> and <b>Done</b> tags are exported as lines preceded by <b>[ ]</b> or <b>[x]</b>, "
583              "representing an empty checkbox and a checked box.") + "</p>" +
584         "<p align='center'><img src=\":/images/tag_export_help.png\"></p>",
585         widget);
586     hLay->addWidget(m_exportTextTags);
587     hLay->addWidget(hLabel);
588     hLay->addStretch();
589 
590     m_groupOnInsertionLineWidget = new QWidget(behaviorBox);
591     behaviorLayout->addWidget(m_groupOnInsertionLineWidget);
592     QHBoxLayout *hLayV = new QHBoxLayout(m_groupOnInsertionLineWidget);
593     m_groupOnInsertionLine = new QCheckBox(i18n("&Group a new note when clicking on the right of the insertion line"), m_groupOnInsertionLineWidget);
594     HelpLabel *helpV = new HelpLabel(
595         i18n("How to group a new note?"),
596         i18n("<p>When this option is enabled, the insertion-line not only allows you to insert notes at the cursor position, but also allows you to group a new note with the one under the cursor:</p>") +
597         "<p align='center'><img src=\":/images/insertion_help.png\"></p>" +
598         i18n("<p>Place your mouse between notes, where you want to add a new one.<br>"
599              "Click on the <b>left</b> of the insertion-line middle-mark to <b>insert</b> a note.<br>"
600              "Click on the <b>right</b> to <b>group</b> a note, with the one <b>below or above</b>, depending on where your mouse is.</p>"),
601         m_groupOnInsertionLineWidget);
602     hLayV->addWidget(m_groupOnInsertionLine);
603     hLayV->addWidget(helpV);
604     hLayV->insertStretch(-1);
605     layout->addWidget(m_groupOnInsertionLineWidget);
606     connect(m_groupOnInsertionLine, SIGNAL(stateChanged(int)), this, SLOT(changed()));
607 
608     widget = new QWidget(behaviorBox);
609     behaviorLayout->addWidget(widget);
610     QGridLayout *ga = new QGridLayout(widget);
611     ga->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding), 0, 3);
612 
613     m_middleAction = new KComboBox(widget);
614     m_middleAction->addItem(i18n("Do nothing"));
615     m_middleAction->addItem(i18n("Paste clipboard"));
616     m_middleAction->addItem(i18n("Insert image note"));
617     m_middleAction->addItem(i18n("Insert link note"));
618     m_middleAction->addItem(i18n("Insert cross reference"));
619     m_middleAction->addItem(i18n("Insert launcher note"));
620     m_middleAction->addItem(i18n("Insert color note"));
621     m_middleAction->addItem(i18n("Grab screen zone"));
622     m_middleAction->addItem(i18n("Insert color from screen"));
623     m_middleAction->addItem(i18n("Load note from file"));
624     m_middleAction->addItem(i18n("Import Launcher for desktop application"));
625     m_middleAction->addItem(i18n("Import icon"));
626 
627     QLabel *labelM = new QLabel(widget);
628     labelM->setText(i18n("&Shift+middle-click anywhere:"));
629     labelM->setBuddy(m_middleAction);
630 
631     ga->addWidget(labelM,                                          0, 0);
632     ga->addWidget(m_middleAction,                                  0, 1);
633     ga->addWidget(new QLabel(i18n("at cursor position"), widget),  0, 2);
634     connect(m_middleAction, SIGNAL(activated(int)), this, SLOT(changed()));
635 
636     // Protection:
637 
638     QGroupBox *protectionBox = new QGroupBox(i18n("Password Protection"), this);
639     QVBoxLayout* protectionLayout = new QVBoxLayout;
640     layout->addWidget(protectionBox);
641     protectionBox->setLayout(protectionLayout);
642     widget = new QWidget(protectionBox);
643     protectionLayout->addWidget(widget);
644 
645     // Re-Lock timeout configuration
646     hLay = new QHBoxLayout(widget);
647     m_enableReLockTimeoutMinutes = new QCheckBox(i18n("A&utomatically lock protected baskets when closed for"), widget);
648     hLay->addWidget(m_enableReLockTimeoutMinutes);
649     m_reLockTimeoutMinutes = new QSpinBox(widget);
650     m_reLockTimeoutMinutes->setMinimum(0);
651     m_reLockTimeoutMinutes->setSuffix(i18n(" minutes"));
652     hLay->addWidget(m_reLockTimeoutMinutes);
653     //label = new QLabel(i18n("minutes"), this);
654     //hLay->addWidget(label);
655     hLay->addStretch();
656 //  layout->addLayout(hLay);
657     connect(m_enableReLockTimeoutMinutes, SIGNAL(stateChanged(int)), this,                   SLOT(changed()));
658     connect(m_reLockTimeoutMinutes,       SIGNAL(valueChanged(int)), this,                   SLOT(changed()));
659     connect(m_enableReLockTimeoutMinutes, SIGNAL(toggled(bool)),     m_reLockTimeoutMinutes, SLOT(setEnabled(bool)));
660 
661 #ifdef HAVE_LIBGPGME
662     m_useGnuPGAgent = new QCheckBox(i18n("Use GnuPG agent for &private/public key protected baskets"), protectionBox);
663     protectionLayout->addWidget(m_useGnuPGAgent);
664 //  hLay->addWidget(m_useGnuPGAgent);
665     connect(m_useGnuPGAgent, SIGNAL(stateChanged(int)), this, SLOT(changed()));
666 #endif
667 
668     layout->insertStretch(-1);
669     load();
670 }
671 
load()672 void BasketsPage::load()
673 {
674     m_playAnimations->setChecked(Settings::playAnimations());
675     m_showNotesToolTip->setChecked(Settings::showNotesToolTip());
676     m_bigNotes->setChecked(Settings::bigNotes());
677 
678     m_autoBullet->setChecked(Settings::autoBullet());
679     m_confirmNoteDeletion->setChecked(Settings::confirmNoteDeletion());
680     m_pasteAsPlainText->setChecked(Settings::pasteAsPlainText());
681     m_exportTextTags->setChecked(Settings::exportTextTags());
682 
683     m_groupOnInsertionLine->setChecked(Settings::groupOnInsertionLine());
684     m_middleAction->setCurrentIndex(Settings::middleAction());
685 
686     // The correctness of this code depends on the default of enableReLockTimeout
687     // being true - otherwise, the reLockTimeoutMinutes widget is not disabled properly.
688     m_enableReLockTimeoutMinutes->setChecked(Settings::enableReLockTimeout());
689     m_reLockTimeoutMinutes->setValue(Settings::reLockTimeoutMinutes());
690 #ifdef HAVE_LIBGPGME
691     m_useGnuPGAgent->setChecked(Settings::useGnuPGAgent());
692 
693     if (KGpgMe::isGnuPGAgentAvailable()) {
694         m_useGnuPGAgent->setChecked(Settings::useGnuPGAgent());
695     } else {
696         m_useGnuPGAgent->setChecked(false);
697         m_useGnuPGAgent->setEnabled(false);
698     }
699 #endif
700 }
701 
save()702 void BasketsPage::save()
703 {
704     Settings::setPlayAnimations(m_playAnimations->isChecked());
705     Settings::setShowNotesToolTip(m_showNotesToolTip->isChecked());
706     Settings::setBigNotes(m_bigNotes->isChecked());
707 
708     Settings::setAutoBullet(m_autoBullet->isChecked());
709     Settings::setConfirmNoteDeletion(m_confirmNoteDeletion->isChecked());
710     Settings::setPasteAsPlainText(m_pasteAsPlainText->isChecked());
711     Settings::setExportTextTags(m_exportTextTags->isChecked());
712 
713     Settings::setGroupOnInsertionLine(m_groupOnInsertionLine->isChecked());
714     Settings::setMiddleAction(m_middleAction->currentIndex());
715 
716     Settings::setEnableReLockTimeout(m_enableReLockTimeoutMinutes->isChecked());
717     Settings::setReLockTimeoutMinutes(m_reLockTimeoutMinutes->value());
718 #ifdef HAVE_LIBGPGME
719     Settings::setUseGnuPGAgent(m_useGnuPGAgent->isChecked());
720 #endif
721 }
722 
defaults()723 void BasketsPage::defaults()
724 {
725     // TODO
726 }
727 
728 /** class NewNotesPage: */
729 
NewNotesPage(QWidget * parent,const char * name)730 NewNotesPage::NewNotesPage(QWidget * parent, const char * name)
731         : KCModule(parent)
732 {
733     KAboutData* about = new AboutData();
734     about->setComponentName(name);
735     setAboutData(about);
736 
737     QVBoxLayout *layout = new QVBoxLayout(this);
738     QHBoxLayout *hLay;
739     QLabel      *label;
740 
741     // Place of New Notes:
742 
743     hLay = new QHBoxLayout;
744     m_newNotesPlace = new KComboBox(this);
745 
746     label = new QLabel(this);
747     label->setText(i18n("&Place of new notes:"));
748     label->setBuddy(m_newNotesPlace);
749 
750     m_newNotesPlace->addItem(i18n("On top"));
751     m_newNotesPlace->addItem(i18n("On bottom"));
752     m_newNotesPlace->addItem(i18n("At current note"));
753     hLay->addWidget(label);
754     hLay->addWidget(m_newNotesPlace);
755     hLay->addStretch();
756     //layout->addLayout(hLay);
757     label->hide();
758     m_newNotesPlace->hide();
759     connect(m_newNotesPlace, SIGNAL(editTextChanged(const QString &)), this, SLOT(changed()));
760 
761     // New Images Size:
762 
763     hLay = new QHBoxLayout;
764     m_imgSizeX = new QSpinBox(this);
765     m_imgSizeX->setMinimum(1);
766     m_imgSizeX->setMaximum(4096);
767     //m_imgSizeX->setReferencePoint(100); //from KIntNumInput
768     connect(m_imgSizeX, SIGNAL(valueChanged(int)), this, SLOT(changed()));
769 
770     label = new QLabel(this);
771     label->setText(i18n("&New images size:"));
772     label->setBuddy(m_imgSizeX);
773 
774     hLay->addWidget(label);
775     hLay->addWidget(m_imgSizeX);
776 
777     m_imgSizeY = new QSpinBox(this);
778     m_imgSizeY->setMinimum(1);
779     m_imgSizeY->setMaximum(4096);
780     //m_imgSizeY->setReferencePoint(100);
781     connect(m_imgSizeY, SIGNAL(valueChanged(int)), this, SLOT(changed()));
782 
783     label = new QLabel(this);
784     label->setText(i18n("&by"));
785     label->setBuddy(m_imgSizeY);
786 
787     hLay->addWidget(label);
788     hLay->addWidget(m_imgSizeY);
789     label = new QLabel(i18n("pixels"), this);
790     hLay->addWidget(label);
791     m_pushVisualize = new QPushButton(i18n("&Visualize..."), this);
792     hLay->addWidget(m_pushVisualize);
793     hLay->addStretch();
794     layout->addLayout(hLay);
795     connect(m_pushVisualize, SIGNAL(clicked()), this, SLOT(visualize()));
796 
797     // View File Content:
798 
799     QGroupBox* buttonGroup = new QGroupBox(i18n("View Content of Added Files for the Following Types"), this);
800     QVBoxLayout* buttonLayout = new QVBoxLayout;
801     m_viewTextFileContent  = new QCheckBox(i18n("&Plain text"),         buttonGroup);
802     m_viewHtmlFileContent  = new QCheckBox(i18n("&HTML page"),          buttonGroup);
803     m_viewImageFileContent = new QCheckBox(i18n("&Image or animation"), buttonGroup);
804     m_viewSoundFileContent = new QCheckBox(i18n("&Sound"),              buttonGroup);
805 
806     buttonLayout->addWidget(m_viewTextFileContent);
807     buttonLayout->addWidget(m_viewHtmlFileContent);
808     buttonLayout->addWidget(m_viewImageFileContent);
809     buttonLayout->addWidget(m_viewSoundFileContent);
810     buttonGroup->setLayout(buttonLayout);
811 
812     layout->addWidget(buttonGroup);
813     connect(m_viewTextFileContent,  SIGNAL(stateChanged(int)), this, SLOT(changed()));
814     connect(m_viewHtmlFileContent,  SIGNAL(stateChanged(int)), this, SLOT(changed()));
815     connect(m_viewImageFileContent, SIGNAL(stateChanged(int)), this, SLOT(changed()));
816     connect(m_viewSoundFileContent, SIGNAL(stateChanged(int)), this, SLOT(changed()));
817 
818     layout->insertStretch(-1);
819     load();
820 }
821 
load()822 void NewNotesPage::load()
823 {
824     m_newNotesPlace->setCurrentIndex(Settings::newNotesPlace());
825 
826     m_imgSizeX->setValue(Settings::defImageX());
827     m_imgSizeY->setValue(Settings::defImageY());
828 
829     m_viewTextFileContent->setChecked(Settings::viewTextFileContent());
830     m_viewHtmlFileContent->setChecked(Settings::viewHtmlFileContent());
831     m_viewImageFileContent->setChecked(Settings::viewImageFileContent());
832     m_viewSoundFileContent->setChecked(Settings::viewSoundFileContent());
833 }
834 
save()835 void NewNotesPage::save()
836 {
837     Settings::setNewNotesPlace(m_newNotesPlace->currentIndex());
838 
839     Settings::setDefImageX(m_imgSizeX->value());
840     Settings::setDefImageY(m_imgSizeY->value());
841 
842     Settings::setViewTextFileContent(m_viewTextFileContent->isChecked());
843     Settings::setViewHtmlFileContent(m_viewHtmlFileContent->isChecked());
844     Settings::setViewImageFileContent(m_viewImageFileContent->isChecked());
845     Settings::setViewSoundFileContent(m_viewSoundFileContent->isChecked());
846 }
847 
defaults()848 void NewNotesPage::defaults()
849 {
850     // TODO
851 }
852 
visualize()853 void NewNotesPage::visualize()
854 {
855     QPointer<ViewSizeDialog> size = new ViewSizeDialog(this, m_imgSizeX->value(), m_imgSizeY->value());
856     size->exec();
857     m_imgSizeX->setValue(size->width());
858     m_imgSizeY->setValue(size->height());
859 }
860 
861 /** class NotesAppearancePage: */
862 
NotesAppearancePage(QWidget * parent,const char * name)863 NotesAppearancePage::NotesAppearancePage(QWidget * parent, const char * name)
864         : KCModule(parent)
865 {
866     KAboutData* about = new AboutData();
867     about->setComponentName(name);
868     setAboutData(about);
869 
870     QVBoxLayout *layout = new QVBoxLayout(this);
871     QTabWidget *tabs = new QTabWidget(this);
872     layout->addWidget(tabs);
873 
874     m_soundLook       = new LinkLookEditWidget(this, i18n("Conference audio record"),                         "folder-sound",       tabs);
875     m_fileLook        = new LinkLookEditWidget(this, i18n("Annual report"),                                   "folder-documents",    tabs);
876     m_localLinkLook   = new LinkLookEditWidget(this, i18n("Home folder"),                                     "user-home", tabs);
877     m_networkLinkLook = new LinkLookEditWidget(this, "www.kde.org",             KIO::iconNameForUrl(QUrl("http://www.kde.org")), tabs);
878     m_launcherLook    = new LinkLookEditWidget(this, i18n("Launch %1", QGuiApplication::applicationDisplayName()), "basket",      tabs);
879     m_crossReferenceLook=new LinkLookEditWidget(this, i18n("Another basket"), "basket", tabs);
880 
881     tabs->addTab(m_soundLook,       i18n("&Sounds"));
882     tabs->addTab(m_fileLook,        i18n("&Files"));
883     tabs->addTab(m_localLinkLook,   i18n("&Local Links"));
884     tabs->addTab(m_networkLinkLook, i18n("&Network Links"));
885     tabs->addTab(m_launcherLook,    i18n("Launc&hers"));
886     tabs->addTab(m_crossReferenceLook, i18n("&Cross References"));
887 
888     load();
889 }
890 
load()891 void NotesAppearancePage::load()
892 {
893     m_soundLook->set(LinkLook::soundLook);
894     m_fileLook->set(LinkLook::fileLook);
895     m_localLinkLook->set(LinkLook::localLinkLook);
896     m_networkLinkLook->set(LinkLook::networkLinkLook);
897     m_launcherLook->set(LinkLook::launcherLook);
898     m_crossReferenceLook->set(LinkLook::crossReferenceLook);
899 }
900 
save()901 void NotesAppearancePage::save()
902 {
903     m_soundLook->saveChanges();
904     m_fileLook->saveChanges();
905     m_localLinkLook->saveChanges();
906     m_networkLinkLook->saveChanges();
907     m_launcherLook->saveChanges();
908     m_crossReferenceLook->saveChanges();
909     Global::bnpView->linkLookChanged();
910 }
911 
defaults()912 void NotesAppearancePage::defaults()
913 {
914     // TODO
915 }
916 
917 /** class ApplicationsPage: */
918 
ApplicationsPage(QWidget * parent,const char * name)919 ApplicationsPage::ApplicationsPage(QWidget * parent, const char * name)
920         : KCModule(parent)
921 {
922     KAboutData* about = new AboutData();
923     about->setComponentName(name);
924     setAboutData(about);
925 
926     /* Applications page */
927     QVBoxLayout *layout = new QVBoxLayout(this);
928 
929     m_htmlUseProg  = new QCheckBox(i18n("Open &text notes with a custom application:"), this);
930     m_htmlProg     = new RunCommandRequester("", i18n("Open text notes with:"), this);
931     QHBoxLayout *hLayH = new QHBoxLayout;
932     hLayH->insertSpacing(-1, 20);
933     hLayH->addWidget(m_htmlProg);
934     connect(m_htmlUseProg, SIGNAL(stateChanged(int)), this, SLOT(changed()));
935     connect(m_htmlProg->lineEdit(), SIGNAL(textChanged(const QString &)), this, SLOT(changed()));
936 
937     m_imageUseProg = new QCheckBox(i18n("Open &image notes with a custom application:"), this);
938     m_imageProg    = new RunCommandRequester("", i18n("Open image notes with:"), this);
939     QHBoxLayout *hLayI = new QHBoxLayout;
940     hLayI->insertSpacing(-1, 20);
941     hLayI->addWidget(m_imageProg);
942     connect(m_imageUseProg, SIGNAL(stateChanged(int)), this, SLOT(changed()));
943     connect(m_imageProg->lineEdit(), SIGNAL(textChanged(const QString &)), this, SLOT(changed()));
944 
945     m_animationUseProg = new QCheckBox(i18n("Open a&nimation notes with a custom application:"), this);
946     m_animationProg    = new RunCommandRequester("", i18n("Open animation notes with:"), this);
947     QHBoxLayout *hLayA = new QHBoxLayout;
948     hLayA->insertSpacing(-1, 20);
949     hLayA->addWidget(m_animationProg);
950     connect(m_animationUseProg, SIGNAL(stateChanged(int)), this, SLOT(changed()));
951     connect(m_animationProg->lineEdit(), SIGNAL(textChanged(const QString &)), this, SLOT(changed()));
952 
953     m_soundUseProg = new QCheckBox(i18n("Open so&und notes with a custom application:"), this);
954     m_soundProg    = new RunCommandRequester("", i18n("Open sound notes with:"), this);
955     QHBoxLayout *hLayS = new QHBoxLayout;
956     hLayS->insertSpacing(-1, 20);
957     hLayS->addWidget(m_soundProg);
958     connect(m_soundUseProg, SIGNAL(stateChanged(int)), this, SLOT(changed()));
959     connect(m_soundProg->lineEdit(), SIGNAL(textChanged(const QString &)), this, SLOT(changed()));
960 
961     QString whatsthis = i18n(
962                             "<p>If checked, the application defined below will be used when opening that type of note.</p>"
963                             "<p>Otherwise, the application you've configured in Konqueror will be used.</p>");
964 
965     m_htmlUseProg->setWhatsThis(whatsthis);
966     m_imageUseProg->setWhatsThis(whatsthis);
967     m_animationUseProg->setWhatsThis(whatsthis);
968     m_soundUseProg->setWhatsThis(whatsthis);
969 
970     whatsthis = i18n(
971                     "<p>Define the application to use for opening that type of note instead of the "
972                     "application configured in Konqueror.</p>");
973 
974     m_htmlProg->setWhatsThis(whatsthis);
975     m_imageProg->setWhatsThis(whatsthis);
976     m_animationProg->setWhatsThis(whatsthis);
977     m_soundProg->setWhatsThis(whatsthis);
978 
979     layout->addWidget(m_htmlUseProg);
980     layout->addItem(hLayH);
981     layout->addWidget(m_imageUseProg);
982     layout->addItem(hLayI);
983     layout->addWidget(m_animationUseProg);
984     layout->addItem(hLayA);
985     layout->addWidget(m_soundUseProg);
986     layout->addItem(hLayS);
987 
988     QHBoxLayout *hLay = new QHBoxLayout;
989     HelpLabel *hl1 = new HelpLabel(
990         i18n("How to change the application used to open Web links?"),
991         i18n("<p>When opening Web links, they are opened in different applications, depending on the content of the link "
992              "(a Web page, an image, a PDF document...), such as if they were files on your computer.</p>"
993              "<p>Here is how to do if you want every Web addresses to be opened in your Web browser. "
994              "It is useful if you are not using Plasma (if you are using eg. GNOME, XFCE...).</p>"
995              "<ul>"
996              "<li>Open the KDE System Settings (if it is not available, try to type \"systemsettings\" in a command line terminal);</li>"
997              "<li>Go to the \"Applications\" and then \"Default Applications\" section;</li>"
998              "<li>Choose \"Web Browser\", check \"with the following command:\" and enter the name of your Web browser (like \"firefox\" or \"epiphany\").</li>"
999              "</ul>"
1000              "<p>Now, when you click <i>any</i> link that start with \"http://...\", it will be opened in your Web browser (eg. Mozilla Firefox or Epiphany or...).</p>"
1001              "<p>For more fine-grained configuration (like opening only Web pages in your Web browser), read the second help link.</p>"),
1002         this);
1003     hLay->addWidget(hl1);
1004     hLay->addStretch();
1005     layout->addLayout(hLay);
1006 
1007     hLay = new QHBoxLayout;
1008     HelpLabel *hl2 = new HelpLabel(
1009         i18n("How to change the applications used to open files and links?"),
1010         i18n("<p>Here is how to set the application to be used for each type of file. "
1011              "This also applies to Web links if you choose not to open them systematically in a Web browser (see the first help link). "
1012              "The default settings should be good enough for you, but this tip is useful if you are using GNOME, XFCE, or another environment than Plasma.</p>"
1013              "<p>This is an example of how to open HTML pages in your Web browser (and keep using the other applications for other addresses or files). "
1014              "Repeat these steps for each type of file you want to open in a specific application.</p>"
1015              "<ul>"
1016              "<li>Open the KDE System Settings (if it is not available, try to type \"systemsettings\" in a command line terminal);</li>"
1017              "<li>Go to the \"Applications\" and then \"File Associations\" section;</li>"
1018              "<li>In the tree, expand \"text\" and click \"html\";</li>"
1019              "<li>In the applications list, add your Web browser as the first entry;</li>"
1020              "<li>Do the same for the type \"application -> xhtml+xml\".</li>"
1021              "</ul>"),
1022         this);
1023     hLay->addWidget(hl2);
1024     hLay->addStretch();
1025     layout->addLayout(hLay);
1026 
1027     connect(m_htmlUseProg,      SIGNAL(toggled(bool)), m_htmlProg,      SLOT(setEnabled(bool)));
1028     connect(m_imageUseProg,     SIGNAL(toggled(bool)), m_imageProg,     SLOT(setEnabled(bool)));
1029     connect(m_animationUseProg, SIGNAL(toggled(bool)), m_animationProg, SLOT(setEnabled(bool)));
1030     connect(m_soundUseProg,     SIGNAL(toggled(bool)), m_soundProg,     SLOT(setEnabled(bool)));
1031 
1032     layout->insertStretch(-1);
1033     load();
1034 }
1035 
load()1036 void ApplicationsPage::load()
1037 {
1038     m_htmlProg->setRunCommand(Settings::htmlProg());
1039     m_htmlUseProg->setChecked(Settings::isHtmlUseProg());
1040     m_htmlProg->setEnabled(Settings::isHtmlUseProg());
1041 
1042     m_imageProg->setRunCommand(Settings::imageProg());
1043     m_imageUseProg->setChecked(Settings::isImageUseProg());
1044     m_imageProg->setEnabled(Settings::isImageUseProg());
1045 
1046     m_animationProg->setRunCommand(Settings::animationProg());
1047     m_animationUseProg->setChecked(Settings::isAnimationUseProg());
1048     m_animationProg->setEnabled(Settings::isAnimationUseProg());
1049 
1050     m_soundProg->setRunCommand(Settings::soundProg());
1051     m_soundUseProg->setChecked(Settings::isSoundUseProg());
1052     m_soundProg->setEnabled(Settings::isSoundUseProg());
1053 }
1054 
save()1055 void ApplicationsPage::save()
1056 {
1057     Settings::setIsHtmlUseProg(m_htmlUseProg->isChecked());
1058     Settings::setHtmlProg(m_htmlProg->runCommand());
1059 
1060     Settings::setIsImageUseProg(m_imageUseProg->isChecked());
1061     Settings::setImageProg(m_imageProg->runCommand());
1062 
1063     Settings::setIsAnimationUseProg(m_animationUseProg->isChecked());
1064     Settings::setAnimationProg(m_animationProg->runCommand());
1065 
1066     Settings::setIsSoundUseProg(m_soundUseProg->isChecked());
1067     Settings::setSoundProg(m_soundProg->runCommand());
1068 }
1069 
defaults()1070 void ApplicationsPage::defaults()
1071 {
1072     // TODO
1073 }
1074 
1075