summaryrefslogtreecommitdiffstats
path: root/src/common/gui/misc_gui.h
blob: 5df73820107331b78bfcf5eb0b05124daba523de (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
/***************************************************************************
 *   Copyright (C) 2006-2007 Nicolas Hadacek <hadacek@kde.org>             *
 *                                                                         *
 *   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.                                   *
 ***************************************************************************/
#ifndef MISC_GUI_H
#define MISC_GUI_H

#include <tqlayout.h>
#include <tqsplitter.h>
#include <tqvaluevector.h>
#include <tqvalidator.h>
#include <tqcombobox.h>
#include <tqwidgetstack.h>

#include <tdelocale.h>
#include <kpushbutton.h>
#include <ktabwidget.h>
#include <ktabbar.h>
#include <kstdguiitem.h>
#include <klineedit.h>
class TDEAction;

#include "common/global/generic_config.h"
#include "common/global/log.h"
#include "common/common/number.h"

//-----------------------------------------------------------------------------
class PBusyCursor
{
public:
  PBusyCursor() { start(); }
  ~PBusyCursor() { stop(); }
  static void start();
  static void stop();
  static void pause();
  static void restore();

private:
  static bool _overridePaused;
};

//-----------------------------------------------------------------------------
namespace MessageBox
{
extern void information(const TQString &text, Log::ShowMode show, const TQString &dontShowAgainName = TQString());
extern void detailedSorry(const TQString &text, const TQString &details, Log::ShowMode show);
inline void sorry(const TQString &text, Log::ShowMode show) { detailedSorry(text, TQString(), show); }
extern bool askContinue(const TQString &text, const KGuiItem &continueButton = KStdGuiItem::cont(),
                        const TQString &caption = i18n("Warning"));
extern bool questionYesNo(const TQString &text, const KGuiItem &yesButton, const KGuiItem &noButton,
                          const TQString &caption = i18n("Warning"));
enum Result { Yes, No, Cancel };
extern Result questionYesNoCancel(const TQString &text, const KGuiItem &yesButton, const KGuiItem &noButton,
                                  const TQString &caption = i18n("Warning"));
extern void text(const TQString &text, Log::ShowMode show);
}

//----------------------------------------------------------------------------
class PopupButton : public KPushButton
{
Q_OBJECT
  
public:
  PopupButton(TQWidget *parent = 0, const char *name = 0);
  PopupButton(const TQString &text, TQWidget *parent = 0, const char *name = 0);
  void appendAction(TDEAction *action);
  void appendAction(const TQString &label, const TQString &icon = TQString(),
                    TQObject *receiver = 0, const char *slot = 0);
  int appendItem(const TQString &label, uint id) { return appendItem(label, TQPixmap(), id); }
  int appendItem(const TQString &label, const TQString &icon, int id = -1);
  int appendItem(const TQString &label, const TQPixmap &icon, int id = -1);
  void appendSeparator() { _separator = true; }

signals:
  void activated(int id);

private:
  bool _separator;

  void init();
};

//-----------------------------------------------------------------------------
class Splitter : public TQSplitter
{
Q_OBJECT
  
public:
  Splitter(const TQValueList<int> &defaultSizes, Qt::Orientation orientation,
           TQWidget *parent, const char *name);
  virtual ~Splitter();

private slots:
  void updateSizes();

private:
  TQValueList<int> _defaultSizes;
};

//-----------------------------------------------------------------------------
class GuiConfig : public GenericConfig
{
public:
  GuiConfig() : GenericConfig("gui") {}
};

//-----------------------------------------------------------------------------
class SeparatorWidget : public TQFrame
{
Q_OBJECT
  
public:
  SeparatorWidget(TQWidget *parent) : TQFrame(parent, "separator") {
    setFrameStyle(TQFrame::Panel | TQFrame::Sunken);
    setMargin(2);
    setFixedHeight(2*2);
  }
};

//-----------------------------------------------------------------------------
class TabBar : public KTabBar
{
Q_OBJECT
  
public:
  TabBar(TQWidget *parent = 0, const char *name = 0);

protected:
  virtual void wheelEvent(TQWheelEvent *e);

private:
  bool _ignoreWheelEvent;

  friend class TabWidget;
};

class TabWidget : public KTabWidget
{
Q_OBJECT
  
public:
  TabWidget(TQWidget *parent = 0, const char *name = 0);
  void setIgnoreWheelEvent(bool ignore);

protected:
  virtual void wheelEvent(TQWheelEvent *e);
  void setTabBar(TabBar *tabbar);
};

//-----------------------------------------------------------------------------
class ComboBox : public TQComboBox
{
Q_OBJECT
  
public:
  ComboBox(TQWidget *parent = 0, const char *name = 0);
  void setIgnoreWheelEvent(bool ignore) { _ignoreWheelEvent = ignore; }

protected:
  virtual void wheelEvent(TQWheelEvent *e);

private:
  bool _ignoreWheelEvent;
};

#endif