summaryrefslogtreecommitdiffstats
path: root/tderadio3/plugins/gui-docking-menu/docking-configuration.cpp
blob: dd1a18ca68dc034b29d4b31233aa7c8eb8d6cd96 (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
/***************************************************************************
                          docking-configuration.cpp  -  description
                             -------------------
    begin                : Son Aug 3 2003
    copyright            : (C) 2003 by Martin Witte
    email                : [email protected]
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#include "docking-configuration.h"

#include <tqcombobox.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqframe.h>

#include <tdelocale.h>

using namespace std;

DockingConfiguration::DockingConfiguration (RadioDocking *docking, TQWidget *parent)
    : StationSelector(parent),
      m_docking(docking),
      m_disableGUIUpdates(false)
{
    TQHBoxLayout *layout  = new TQHBoxLayout();
    TQHBoxLayout *layout2 = new TQHBoxLayout();

    m_labelClickMode = new TQLabel(this);
    layout->addWidget(m_labelClickMode);

    m_comboClickMode = new TQComboBox(this);
    layout->addWidget(m_comboClickMode);

    TQSpacerItem *spacer = new TQSpacerItem( 20, 2, TQSizePolicy::Expanding, TQSizePolicy::Minimum);
    layout->addItem(spacer);

    TQFrame *line = new TQFrame(this);
    line->setFrameShape ( TQFrame::HLine );
    line->setFrameShadow( TQFrame::Sunken );
    layout2->addWidget(line);

    StationSelectorUILayout->expand(2,0);
    StationSelectorUILayout->addMultiCellLayout(layout2, 2, 2, 0, 2);
    StationSelectorUILayout->addMultiCellLayout(layout,  3, 3, 0, 2);

    connect(m_comboClickMode, TQT_SIGNAL(activated( int )), this, TQT_SLOT(slotSetDirty()));

    languageChange();
    slotCancel();
}


DockingConfiguration::~DockingConfiguration ()
{
}


void DockingConfiguration::languageChange()
{
    StationSelector::languageChange();
    m_labelClickMode->setText( i18n( "Left Mouse Click on Tray" ) );

    m_comboClickMode->clear();
    m_comboClickMode->insertItem(i18n("Show/Hide all GUI Elements"));
    m_comboClickMode->insertItem(i18n("Power On/Off"));
}

void DockingConfiguration::slotOK()
{
    if (m_dirty) {
        StationSelector::slotOK();
        bool old = m_disableGUIUpdates;
        m_disableGUIUpdates = true;
        if (m_docking)
            m_docking->setLeftClickAction((LeftClickAction)m_comboClickMode->currentItem());
        m_disableGUIUpdates = old;
        m_dirty = false;
    }
}

void DockingConfiguration::slotCancel()
{
    if (m_dirty) {
        StationSelector::slotCancel();
        if (m_docking)
            m_comboClickMode->setCurrentItem(m_docking->getLeftClickAction());
        m_dirty = false;
    }
}

void DockingConfiguration::slotLeftClickActionChanged(LeftClickAction action)
{
    if (!m_disableGUIUpdates) {
        if (m_docking)
            m_comboClickMode->setCurrentItem(action);
    }
}

void DockingConfiguration::slotSetDirty()
{
    m_dirty = true;
}


#include "docking-configuration.moc"