File: configinputwindow.cpp

package info (click to toggle)
skim 1.4.5-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,904 kB
  • ctags: 1,257
  • sloc: cpp: 9,423; python: 1,608; sh: 329; makefile: 71
file content (123 lines) | stat: -rw-r--r-- 3,628 bytes parent folder | download
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
/***************************************************************************
 *   Copyright (C) 2003-2006 by liuspider                                  *
 *   liuspider@users.sourceforge.net                                       *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/
#define USE_SCIM_KDE_SETTINGS
#include "src/skimpluginmanager.h"
#include "configinputwindow.h"

#include <kdebug.h>
#include <klocale.h>
#include <kfontrequester.h>
#include <kapplication.h>
#include <kconfigdialogmanager.h>
#include <qcheckbox.h>

#define MODULE_UUID "a1d34730-6d08-4f59-a418-e63334a46538"
class ConfigInputWindowPrivate
{
  public:
//     KConfigDialogManager * mgr;
    bool changed;
    QFont oldCustomFont;
};

ConfigInputWindow::ConfigInputWindow(QWidget *parent, const char */*name*/)
 : ConfigInputWindowBase(parent), d(new ConfigInputWindowPrivate())
{
    load();
    d->changed = false;

    connect(defaultFontRequester, SIGNAL(fontSelected (const QFont &)), SLOT(fontChanged (const QFont &)));
}

ConfigInputWindow::~ConfigInputWindow () {}

void ConfigInputWindow::load()
{
//     kdDebug(18010) << k_lineinfo << " IWKCMLoader::load()\n";
    if(!ScimKdeSettings::iW_Font().isEmpty())
    {
      d->oldCustomFont.fromString(ScimKdeSettings::iW_Font());
      defaultFontRequester->setFont(d->oldCustomFont);
    }
    else
    {
      d->oldCustomFont = font();
      defaultFontRequester->setFont(font());
    }
}

bool ConfigInputWindow::hasChanged()
{
    return d->changed;
}

void ConfigInputWindow::save()
{
    if(!hasChanged())
      return;

    d->oldCustomFont = defaultFontRequester->font();
    if(kapp->font() != d->oldCustomFont)
      ScimKdeSettings::setIW_Font(d->oldCustomFont.toString());
    else
      ScimKdeSettings::setIW_Font("");

    d->changed = false;
}

void ConfigInputWindow::fontChanged (const QFont &f)
{
    if(f == d->oldCustomFont)
      d->changed = false;
    else
      d->changed = true;

    emit changed(d->changed);
}

void ConfigInputWindow::defaults()
{
    if(kapp->font() == defaultFontRequester->font())
      return;
      
    defaultFontRequester->setFont(kapp->font());
    fontChanged(kapp->font()); 
}

#include <kgenericfactory.h>

typedef KGenericFactory<IWKCMLoader> KCMLoaderFactory;

K_EXPORT_COMPONENT_FACTORY( kcm_skimplugin_inputwindow, KCMLoaderFactory( "kcm_skimplugin_inputwindow" ) )

IWKCMLoader::IWKCMLoader( QWidget *parent, const char * /* name */, const QStringList &args )
 : KAutoCModule( KCMLoaderFactory::instance(), parent, args )
{
//   kdDebug(18010) << k_lineinfo << " " << KCMLoaderFactory::instance()->instanceName() << "\n";
  d = new ConfigInputWindow(this);
  setMainWidget(d);
  d->kcfg_LookupTable_MinimumWidth->setEnabled(d->kcfg_LookupTable_IsVertical->isChecked());
  connect(d, SIGNAL(changed(bool)), SLOT(slotWidgetModified()));
}

void IWKCMLoader::save(){  d->save(); KAutoCModule::save();}

void IWKCMLoader::load() { d->load(); KAutoCModule::load();}

void IWKCMLoader::defaults() {d->defaults(); KAutoCModule::defaults(); }

void IWKCMLoader::slotWidgetModified()
{
    emit changed(d->hasChanged() || configDialgoMgr()->hasChanged());
}

IWKCMLoader::~IWKCMLoader(){}

#include "configinputwindow.moc"