30 #include "kauthicon.h"
33 static const char *
const lock_xpm[] = {
64 static const char *
const openlock_xpm[] = {
95 : TQWidget(parent, name),
96 lockPM( const_cast< const char** >( lock_xpm)),
97 openLockPM( const_cast< const char** >(openlock_xpm))
99 lockText = i18n(
"Editing disabled");
100 openLockText = i18n(
"Editing enabled");
102 lockBox =
new TQLabel(
this);
103 lockBox->setFrameStyle(TQFrame::WinPanel|TQFrame::Raised);
104 lockBox->setPixmap(lockPM);
105 lockBox->setFixedSize(lockBox->sizeHint());
107 lockLabel =
new TQLabel(
this);
108 lockLabel->setFrameStyle(TQFrame::NoFrame);
111 if (lockLabel->fontMetrics().boundingRect(lockText).width() >
112 lockLabel->fontMetrics().boundingRect(openLockText).width())
113 lockLabel->setText(lockText);
115 lockLabel->setText(openLockText);
116 lockLabel->setAlignment(AlignCenter);
117 lockLabel->setMinimumSize(lockLabel->sizeHint());
118 lockLabel->setText(lockText);
120 layout =
new TQHBoxLayout(
this);
122 layout->addWidget(lockBox, 0, AlignLeft|AlignVCenter);
123 layout->addSpacing(5);
124 layout->addWidget(lockLabel, 0, AlignRight|AlignVCenter);
130 KAuthIcon::~KAuthIcon()
135 TQSize KAuthIcon::sizeHint()
const
137 return layout->minimumSize();
143 KRootPermsIcon::KRootPermsIcon(TQWidget *parent,
const char *name)
150 KRootPermsIcon::~KRootPermsIcon()
154 void KRootPermsIcon::updateStatus()
156 const bool newRoot = (geteuid() == 0);
157 lockBox->setPixmap(newRoot ? openLockPM : lockPM);
158 lockLabel->setText(newRoot ? openLockText : lockText);
160 if (root != newRoot) {
168 KWritePermsIcon::KWritePermsIcon(
const TQString & fileName,
169 TQWidget *parent,
const char *name)
172 fi.setFile(fileName);
177 KWritePermsIcon::~KWritePermsIcon()
181 void KWritePermsIcon::updateStatus()
184 newwrite = fi.isWritable();
185 lockBox->setPixmap(newwrite ? openLockPM : lockPM);
186 lockLabel->setText(newwrite ? openLockText : lockText);
188 if (writable != newwrite) {
194 void KAuthIcon::virtual_hook(
int,
void* )
197 void KRootPermsIcon::virtual_hook(
int id,
void* data )
198 { KAuthIcon::virtual_hook(
id, data ); }
200 void KWritePermsIcon::virtual_hook(
int id,
void* data )
201 { KAuthIcon::virtual_hook(
id, data ); }
203 #include "kauthicon.moc"
A base class for authorization icon widgets.
void authChanged(bool authorized)
this signal is emitted when authorization has changed from its previous state.
KAuthIcon(TQWidget *parent=0, const char *name=0)
Constructor.
virtual void updateStatus()=0
Re-implement this method if you want the icon to update itself when something external has changed (i...
TQString name(StdAccel id)