summaryrefslogtreecommitdiffstats
path: root/yakuake/src/general_settings.cpp
blob: 7b90b1dfa2283fa2b93bd7dd1d1ddfa7baf955cf (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
/*
    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.
*/

/*
  Copyright (C) 2007 Eike Hein <hein@kde.org>
*/


#include "general_settings.h"
#include "general_settings.moc"

#include <tqapplication.h>
#include <tqslider.h>
#include <tqspinbox.h>
#include <tqcombobox.h>
#include <tqlabel.h>

#include <knuminput.h>
#include <tdelocale.h>


GeneralSettings::GeneralSettings(TQWidget* parent, const char* name)
 : GeneralSettingsUI(parent, name)
{
    kcfg_width->setSuffix("%");
    kcfg_height->setSuffix("%");
    steps_spinbox->setPrefix("~");
    steps_spinbox->setSuffix("ms");

    for (int i = 2; i <= TQApplication::desktop()->numScreens(); i++)
        kcfg_screen->insertItem(i18n("Screen %1").arg(TQString::number(i)));

    if (TQApplication::desktop()->numScreens() > 1)
    {
        screen_label->setEnabled(true);
        kcfg_screen->setEnabled(true);
    }

    connect(kcfg_width, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(updateWidthSlider(int)));
    connect(width_slider, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(updateWidthSpinbox(int)));

    connect(kcfg_height, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(updateHeightSlider(int)));
    connect(height_slider, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(updateHeightSpinbox(int)));

    connect(kcfg_steps, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(updateStepsSpinbox(int)));
    connect(steps_spinbox, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(updateStepsSlider(int)));

    connect(kcfg_location, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(updateLocation(int)));
}

GeneralSettings::~GeneralSettings()
{
}

void GeneralSettings::updateWidthSlider(int width)
{
    width_slider->setValue(width/10);

    emit updateSize(width, kcfg_height->value(), kcfg_location->value());
}

void GeneralSettings::updateWidthSpinbox(int width)
{
    kcfg_width->setValue(width*10);
}

void GeneralSettings::updateHeightSlider(int height)
{
    height_slider->setValue(height/10);

    emit updateSize(kcfg_width->value(), height, kcfg_location->value());
}

void GeneralSettings::updateHeightSpinbox(int height)
{
    kcfg_height->setValue(height*10);
}

void GeneralSettings::updateStepsSlider(int speed)
{
    kcfg_steps->setValue(speed/10);
}

void GeneralSettings::updateStepsSpinbox(int speed)
{
    steps_spinbox->setValue(speed*10);
}

void GeneralSettings::updateLocation(int location)
{
    emit updateSize(kcfg_width->value(), kcfg_height->value(), location);
}