49 #include <sys/types.h>
60 #include <tqpushbutton.h>
61 #include <tqcheckbox.h>
62 #include <tqstrlist.h>
63 #include <tqstringlist.h>
64 #include <tqtextstream.h>
65 #include <tqpainter.h>
67 #include <tqcombobox.h>
68 #include <tqgroupbox.h>
69 #include <tqwhatsthis.h>
70 #include <tqtooltip.h>
72 #include <tqprogressbar.h>
74 #include <tqvaluevector.h>
78 #include <sys/param.h>
79 #ifdef HAVE_SYS_MOUNT_H
80 #include <sys/mount.h>
82 #ifdef HAVE_SYS_XATTR_H
83 #include <sys/xattr.h>
88 #include <tdeapplication.h>
91 #include <kdirwatch.h>
92 #include <kdirnotify_stub.h>
93 #include <kdiskfreesp.h>
95 #include <kdesktopfile.h>
96 #include <kicondialog.h>
98 #include <kurlrequester.h>
99 #include <tdelocale.h>
100 #include <tdeglobal.h>
101 #include <tdeglobalsettings.h>
102 #include <kstandarddirs.h>
103 #include <tdeio/job.h>
104 #include <tdeio/chmodjob.h>
105 #include <tdeio/renamedlg.h>
106 #include <tdeio/netaccess.h>
107 #include <tdeio/kservicetypefactory.h>
108 #include <tdefiledialog.h>
109 #include <kmimetype.h>
110 #include <kmountpoint.h>
111 #include <kiconloader.h>
112 #include <tdemessagebox.h>
113 #include <kservice.h>
114 #include <kcompletion.h>
115 #include <klineedit.h>
116 #include <kseparator.h>
117 #include <ksqueezedtextlabel.h>
118 #include <klibloader.h>
120 #include <tdeparts/componentfactory.h>
121 #include <kmetaprops.h>
122 #include <kpreviewprops.h>
123 #include <tdeprocess.h>
125 #include <tdelistview.h>
127 #include "tdefilesharedlg.h"
129 #include "kpropertiesdesktopbase.h"
130 #include "kpropertiesdesktopadvbase.h"
131 #include "kpropertiesmimetypebase.h"
133 #include "kacleditwidget.h"
136 #include "kpropertiesdialog.h"
139 # include <win32_utils.h>
142 static TQString nameFromFileName(TQString nameStr)
144 if ( nameStr.endsWith(
".desktop") )
145 nameStr.truncate( nameStr.length() - 8 );
146 if ( nameStr.endsWith(
".kdelnk") )
147 nameStr.truncate( nameStr.length() - 7 );
149 nameStr = TDEIO::decodeFileName( nameStr );
153 mode_t KFilePermissionsPropsPlugin::fperm[3][4] = {
154 {S_IRUSR, S_IWUSR, S_IXUSR, S_ISUID},
155 {S_IRGRP, S_IWGRP, S_IXGRP, S_ISGID},
156 {S_IROTH, S_IWOTH, S_IXOTH, S_ISVTX}
159 class KPropertiesDialog::KPropertiesDialogPrivate
162 KPropertiesDialogPrivate()
167 ~KPropertiesDialogPrivate()
171 TQWidget* fileSharePage;
175 TQWidget* parent,
const char* name,
176 bool modal,
bool autoShow)
177 : KDialogBase (KDialogBase::Tabbed, i18n(
"Properties for %1" ).arg(TDEIO::decodeFileName(item->url().fileName())),
178 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
181 d =
new KPropertiesDialogPrivate;
183 m_items.append(
new KFileItem(*
item) );
185 m_singleUrl =
item->url();
186 assert(!m_singleUrl.isEmpty());
188 init (modal, autoShow);
192 TQWidget* parent,
const char* name,
bool modal)
193 : KDialogBase (KDialogBase::Tabbed, i18n (
"Properties for %1").arg(title),
194 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
197 d =
new KPropertiesDialogPrivate;
203 TQWidget* parent,
const char* name,
204 bool modal,
bool autoShow)
205 : KDialogBase (KDialogBase::Tabbed,
208 _items.count()>1 ? i18n(
"<never used>",
"Properties for %n Selected Items",_items.count()) :
209 i18n(
"Properties for %1" ).arg(TDEIO::decodeFileName(_items.first()->url().fileName())),
210 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
213 d =
new KPropertiesDialogPrivate;
215 assert( !_items.isEmpty() );
216 m_singleUrl = _items.first()->url();
217 assert(!m_singleUrl.isEmpty());
219 KFileItemListIterator it ( _items );
221 for ( ; it.current(); ++it )
222 m_items.append(
new KFileItem( **it ) );
224 init (modal, autoShow);
227 #ifndef KDE_NO_COMPAT
229 TQWidget* parent,
const char* name,
230 bool modal,
bool autoShow)
231 : KDialogBase (KDialogBase::Tabbed,
232 i18n(
"Properties for %1" ).arg(TDEIO::decodeFileName(_url.fileName())),
233 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
234 parent, name, modal),
237 d =
new KPropertiesDialogPrivate;
239 TDEIO::UDSEntry entry;
241 TDEIO::NetAccess::stat(_url, entry, parent);
243 m_items.append(
new KFileItem( entry, _url ) );
244 init (modal, autoShow);
249 TQWidget* parent,
const char* name,
250 bool modal,
bool autoShow)
251 : KDialogBase (KDialogBase::Tabbed,
252 i18n(
"Properties for %1" ).arg(TDEIO::decodeFileName(_url.fileName())),
253 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
254 parent, name, modal),
257 d =
new KPropertiesDialogPrivate;
259 TDEIO::UDSEntry entry;
261 TDEIO::NetAccess::stat(_url, entry, parent);
263 m_items.append(
new KFileItem( entry, _url ) );
264 init (modal, autoShow);
268 const TQString& _defaultName,
269 TQWidget* parent,
const char* name,
270 bool modal,
bool autoShow)
271 : KDialogBase (KDialogBase::Tabbed,
272 i18n(
"Properties for %1" ).arg(TDEIO::decodeFileName(_tempUrl.fileName())),
273 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
274 parent, name, modal),
276 m_singleUrl( _tempUrl ),
277 m_defaultName( _defaultName ),
278 m_currentDir( _currentDir )
280 d =
new KPropertiesDialogPrivate;
282 assert(!m_singleUrl.isEmpty());
285 m_items.append(
new KFileItem( KFileItem::Unknown, KFileItem::Unknown, m_singleUrl ) );
286 init (modal, autoShow);
290 const char* name,
bool modal)
293 TQString localPath =
item->localPath();
294 if (!localPath.isEmpty())
295 return showWin32FilePropertyDialog(localPath);
302 const char* name,
bool modal)
305 if (_url.isLocalFile())
306 return showWin32FilePropertyDialog( _url.path() );
313 const char* name,
bool modal)
315 if (_items.count()==1)
321 void KPropertiesDialog::init (
bool modal,
bool autoShow)
323 m_pageList.setAutoDelete(
true );
324 m_items.setAutoDelete(
true );
339 if (d->fileSharePage) {
340 showPage( pageIndex( d->fileSharePage));
345 d->fileSharePage = page;
353 for ( it=m_pageList.first(); it != 0L; it=m_pageList.next() )
357 plugin->setFileNameReadOnly( ro );
363 void KPropertiesDialog::slotStatResult( TDEIO::Job * )
375 connect (plugin, TQ_SIGNAL (changed ()),
376 plugin, TQ_SLOT (setDirty ()));
378 m_pageList.append (plugin);
386 KDesktopPropsPlugin::supports( _items ) ||
387 KBindingPropsPlugin::supports( _items ) ||
388 KURLPropsPlugin::supports( _items ) ||
389 KDevicePropsPlugin::supports( _items ) ||
397 d->m_aborted =
false;
400 if ( m_pageList.first()->isA(
"KFilePropsPlugin") )
406 for ( page = m_pageList.first(); page != 0L; page = m_pageList.next() )
407 if ( page->isDirty() && filePropsPlugin )
409 filePropsPlugin->setDirty();
417 for ( page = m_pageList.first(); page != 0L && !d->m_aborted; page = m_pageList.next() )
418 if ( page->isDirty() )
420 kdDebug( 250 ) <<
"applying changes for " << page->className() << endl;
425 kdDebug( 250 ) <<
"skipping page " << page->className() << endl;
427 if ( !d->m_aborted && filePropsPlugin )
448 void KPropertiesDialog::insertPages()
450 if (m_items.isEmpty())
465 if ( KDesktopPropsPlugin::supports( m_items ) )
471 if ( KBindingPropsPlugin::supports( m_items ) )
477 if ( KURLPropsPlugin::supports( m_items ) )
483 if ( KDevicePropsPlugin::supports( m_items ) )
501 if ( kapp->authorizeTDEAction(
"sharefile") &&
502 KFileSharePropsPlugin::supports( m_items ) )
510 if ( m_items.count() != 1 )
513 KFileItem *
item = m_items.first();
514 TQString mimetype =
item->mimetype();
516 if ( mimetype.isEmpty() )
519 TQString query = TQString::fromLatin1(
520 "('KPropsDlg/Plugin' in ServiceTypes) and "
521 "((not exist [X-TDE-Protocol]) or "
522 " ([X-TDE-Protocol] == '%1' ) )" ).arg(
item->url().protocol());
524 kdDebug( 250 ) <<
"trader query: " << query << endl;
525 TDETrader::OfferList offers = TDETrader::self()->query( mimetype, query );
526 TDETrader::OfferList::ConstIterator it = offers.begin();
527 TDETrader::OfferList::ConstIterator end = offers.end();
528 for (; it != end; ++it )
531 ::createInstanceFromLibrary<KPropsDlgPlugin>( (*it)->library().local8Bit().data(),
533 (*it)->name().latin1() );
543 Q_ASSERT( m_items.count() == 1 );
544 kdDebug(250) <<
"KPropertiesDialog::updateUrl (pre)" << _newUrl.url() << endl;
545 KURL newUrl = _newUrl;
546 emit
saveAs(m_singleUrl, newUrl);
547 kdDebug(250) <<
"KPropertiesDialog::updateUrl (post)" << newUrl.url() << endl;
549 m_singleUrl = newUrl;
550 m_items.first()->setURL( newUrl );
551 assert(!m_singleUrl.isEmpty());
554 for ( TQPtrListIterator<KPropsDlgPlugin> it(m_pageList); it.current(); ++it )
555 if ( it.current()->isA(
"KExecPropsPlugin") ||
556 it.current()->isA(
"KURLPropsPlugin") ||
557 it.current()->isA(
"KDesktopPropsPlugin"))
560 it.current()->setDirty();
567 Q_ASSERT( m_items.count() == 1 );
568 kdDebug(250) <<
"KPropertiesDialog::rename " << _name << endl;
571 if ( !m_currentDir.isEmpty() )
573 newUrl = m_currentDir;
574 newUrl.addPath( _name );
578 TQString tmpurl = m_singleUrl.url();
579 if ( tmpurl.at(tmpurl.length() - 1) ==
'/')
581 tmpurl.truncate( tmpurl.length() - 1);
583 newUrl.setFileName( _name );
593 class KPropsDlgPlugin::KPropsDlgPluginPrivate
596 KPropsDlgPluginPrivate()
599 ~KPropsDlgPluginPrivate()
607 : TQObject( _props, 0L )
609 d =
new KPropsDlgPluginPrivate;
611 fontHeight = 2*
properties->fontMetrics().height();
615 KPropsDlgPlugin::~KPropsDlgPlugin()
624 KURL url = _item->mostLocalURL( isLocal );
629 if ( !S_ISREG( _item->mode() ) )
632 TQString t( url.path() );
635 FILE *f = fopen( TQFile::encodeName(t),
"r" );
641 return ( (_item->mimetype() ==
"application/x-desktop")
642 || (_item->mimetype() ==
"media/builtin-mydocuments")
643 || (_item->mimetype() ==
"media/builtin-mycomputer")
644 || (_item->mimetype() ==
"media/builtin-mynetworkplaces")
645 || (_item->mimetype() ==
"media/builtin-printers")
646 || (_item->mimetype() ==
"media/builtin-trash")
647 || (_item->mimetype() ==
"media/builtin-webbrowser") );
650 void KPropsDlgPlugin::setDirty(
bool b )
655 void KPropsDlgPlugin::setDirty()
660 bool KPropsDlgPlugin::isDirty()
const
667 kdWarning(250) <<
"applyChanges() not implemented in page !" << endl;
672 class KFilePropsPlugin::KFilePropsPluginPrivate
675 KFilePropsPluginPrivate()
678 dirSizeUpdateTimer = 0L;
680 m_freeSpaceLabel = 0;
682 ~KFilePropsPluginPrivate()
689 TQTimer *dirSizeUpdateTimer;
695 TQLabel *m_freeSpaceLabel;
697 TQString oldFileName;
704 d =
new KFilePropsPluginPrivate;
706 d->bIconChanged =
false;
707 d->bKDesktopMode = (TQCString(tqApp->name()) ==
"kdesktop");
709 kdDebug(250) <<
"KFilePropsPlugin::KFilePropsPlugin bMultiple=" << d->bMultiple << endl;
715 KURL url = item->mostLocalURL( isLocal );
716 bool isReallyLocal = item->url().isLocalFile();
718 kdDebug() <<
"url=" << url <<
" bDesktopFile=" << bDesktopFile <<
" isLocal=" << isLocal <<
" isReallyLocal=" << isReallyLocal << endl;
719 mode_t mode = item->mode();
720 bool hasDirs = item->isDir() && !item->isLink();
721 bool hasRoot = url.path() == TQString::fromLatin1(
"/");
722 TQString iconStr = KMimeType::iconForURL(url, mode);
725 TQString mimeComment = item->mimeComment();
726 d->mimeType = item->mimetype();
728 TDEIO::filesize_t totalSize = item->size(hasTotalSize);
729 TQString magicMimeComment;
731 KMimeType::Ptr magicMimeType = KMimeType::findByFileContent( url.path() );
732 if ( magicMimeType->name() != KMimeType::defaultMimeType() ) {
733 magicMimeComment = magicMimeType->comment();
738 TQString filename = TQString::null;
739 bool isTrash =
false;
740 bool isDevice =
false;
741 bool isMediaNode =
false;
742 m_bFromTemplate =
false;
745 uint iDirCount = hasDirs ? 1 : 0;
746 uint iFileCount = 1-iDirCount;
748 d->m_frame =
properties->addPage (i18n(
"&General"));
750 TQVBoxLayout *vbl =
new TQVBoxLayout( d->m_frame, 0,
751 KDialog::spacingHint(),
"vbl");
752 TQGridLayout *grid =
new TQGridLayout(0, 3);
753 grid->setColStretch(0, 0);
754 grid->setColStretch(1, 0);
755 grid->setColStretch(2, 1);
756 grid->addColSpacing(1, KDialog::spacingHint());
757 vbl->addLayout(grid);
763 if ( !m_bFromTemplate ) {
764 isTrash = (
properties->
kurl().protocol().find(
"trash", 0,
false)==0 );
768 if (d->mimeType.startsWith(
"media/")) {
772 if ( isReallyLocal ) {
786 determineRelativePath( path );
791 if ( filename.isEmpty() ) {
792 filename = item->name();
794 m_bFromTemplate =
true;
797 d->oldFileName = filename;
800 filename = nameFromFileName( filename );
802 if ( d->bKDesktopMode && d->bDesktopFile ) {
803 KDesktopFile config( url.path(),
true );
804 if ( config.hasKey(
"Name" ) ) {
805 filename = config.readName();
815 KFileItemListIterator it( items );
816 for ( ++it ; it.current(); ++it )
818 KURL url = (*it)->url();
819 kdDebug(250) <<
"KFilePropsPlugin::KFilePropsPlugin " << url.prettyURL() << endl;
822 if ( url.isLocalFile() != isLocal )
825 bDesktopFile =
false;
826 if ( (*it)->mode() != mode )
828 if ( KMimeType::iconForURL(url, mode) != iconStr )
829 iconStr =
"application-vnd.tde.tdemultiple";
830 if ( url.directory() != directory )
831 directory = TQString::null;
832 if ( url.protocol() != protocol )
833 protocol = TQString::null;
834 if ( !mimeComment.isNull() && (*it)->mimeComment() != mimeComment )
835 mimeComment = TQString::null;
836 if ( isLocal && !magicMimeComment.isNull() ) {
837 KMimeType::Ptr magicMimeType = KMimeType::findByFileContent( url.path() );
838 if ( magicMimeType->comment() != magicMimeComment )
839 magicMimeComment = TQString::null;
842 if ( url.path() == TQString::fromLatin1(
"/") )
844 if ( (*it)->isDir() && !(*it)->isLink() )
853 totalSize += (*it)->size(hasSize);
854 hasTotalSize = hasTotalSize || hasSize;
859 if (!isReallyLocal && !protocol.isEmpty())
863 directory += protocol;
867 if ( !isDevice && !isMediaNode && !isTrash && (bDesktopFile || S_ISDIR(mode)) && !d->bMultiple )
870 int bsize = 66 + 2 * iconButton->style().pixelMetric(TQStyle::PM_ButtonMargin);
871 iconButton->setFixedSize(bsize, bsize);
876 TQString iconStr = KMimeType::findByURL( url, mode )->icon( url, isLocal );
877 if ( bDesktopFile && isLocal ) {
878 KDesktopFile config( url.path(),
true );
879 config.setDesktopGroup();
880 iconStr = config.readEntry(
"Icon" );
881 if ( config.hasDeviceType() ) {
882 iconButton->
setIconType( TDEIcon::Desktop, TDEIcon::Device );
885 iconButton->
setIconType( TDEIcon::Desktop, TDEIcon::Application );
889 iconButton->
setIconType( TDEIcon::Desktop, TDEIcon::Place );
892 iconArea = iconButton;
893 connect( iconButton, TQ_SIGNAL( iconChanged(TQString) ),
894 this, TQ_SLOT( slotIconChanged() ) );
896 TQLabel *iconLabel =
new TQLabel( d->m_frame );
897 int bsize = 66 + 2 * iconLabel->style().pixelMetric(TQStyle::PM_ButtonMargin);
898 iconLabel->setFixedSize(bsize, bsize);
901 iconLabel->setPixmap( TDEGlobal::iconLoader()->loadIcon( item->iconName(), TDEIcon::Desktop, 48) );
905 iconLabel->setPixmap( TDEGlobal::iconLoader()->loadIcon( iconStr, TDEIcon::Desktop, 48) );
907 iconArea = iconLabel;
909 grid->addWidget(iconArea, curRow, 0, TQt::AlignLeft);
911 if (d->bMultiple || isTrash || isDevice || isMediaNode || hasRoot)
913 TQLabel *lab =
new TQLabel(d->m_frame );
915 lab->setText( TDEIO::itemsSummaryString( iFileCount + iDirCount, iFileCount, iDirCount, 0,
false ) );
917 lab->setText( filename );
921 d->m_lined =
new KLineEdit( d->m_frame );
922 d->m_lined->setText(filename);
923 nameArea = d->m_lined;
924 d->m_lined->setFocus();
928 KServiceTypeFactory::self()->findFromPattern( filename, &pattern );
929 if (!pattern.isEmpty() && pattern.at(0)==
'*' && pattern.find(
'*',1)==-1)
930 d->m_lined->setSelection(0, filename.length()-pattern.stripWhiteSpace().length()+1);
933 int lastDot = filename.findRev(
'.');
935 d->m_lined->setSelection(0, lastDot);
938 connect( d->m_lined, TQ_SIGNAL( textChanged(
const TQString & ) ),
939 this, TQ_SLOT( nameFileChanged(
const TQString & ) ) );
942 grid->addWidget(nameArea, curRow++, 2);
944 KSeparator* sep =
new KSeparator( KSeparator::HLine, d->m_frame);
945 grid->addMultiCellWidget(sep, curRow, curRow, 0, 2);
949 if ( !mimeComment.isEmpty() && !isDevice && !isMediaNode && !isTrash)
951 l =
new TQLabel(i18n(
"Type:"), d->m_frame );
953 grid->addWidget(l, curRow, 0);
955 TQHBox *box =
new TQHBox(d->m_frame);
957 l =
new TQLabel(mimeComment, box );
961 TQPushButton *button =
new TQPushButton(box);
963 TQIconSet iconSet = SmallIconSet(TQString::fromLatin1(
"configure"));
964 TQPixmap pixMap = iconSet.pixmap( TQIconSet::Small, TQIconSet::Normal );
965 button->setIconSet( iconSet );
966 button->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
967 if ( d->mimeType == KMimeType::defaultMimeType() )
968 TQToolTip::add(button, i18n(
"Create new file type"));
970 TQToolTip::add(button, i18n(
"Edit file type"));
972 connect( button, TQ_SIGNAL( clicked() ), TQ_SLOT( slotEditFileType() ));
974 if (!kapp->authorizeTDEAction(
"editfiletype"))
978 grid->addWidget(box, curRow++, 2);
981 if ( !magicMimeComment.isEmpty() && magicMimeComment != mimeComment )
983 l =
new TQLabel(i18n(
"Contents:"), d->m_frame );
984 grid->addWidget(l, curRow, 0);
986 l =
new TQLabel(magicMimeComment, d->m_frame );
987 grid->addWidget(l, curRow++, 2);
990 if ( !directory.isEmpty() )
992 l =
new TQLabel( i18n(
"Location:"), d->m_frame );
993 grid->addWidget(l, curRow, 0);
995 l =
new KSqueezedTextLabel( d->m_frame );
996 l->setText( directory );
997 grid->addWidget(l, curRow++, 2);
1000 if( hasDirs || hasTotalSize ) {
1001 l =
new TQLabel(i18n(
"Size:"), d->m_frame );
1002 grid->addWidget(l, curRow, 0);
1004 m_sizeLabel =
new TQLabel( d->m_frame );
1005 grid->addWidget( m_sizeLabel, curRow++, 2 );
1013 m_sizeLabel->setText(TDEIO::convertSizeWithBytes(totalSize));
1016 m_sizeDetermineButton = 0L;
1017 m_sizeStopButton = 0L;
1021 TQHBoxLayout * sizelay =
new TQHBoxLayout(KDialog::spacingHint());
1022 grid->addLayout( sizelay, curRow++, 2 );
1025 m_sizeDetermineButton =
new TQPushButton( i18n(
"Calculate"), d->m_frame );
1026 m_sizeStopButton =
new TQPushButton( i18n(
"Stop"), d->m_frame );
1027 connect( m_sizeDetermineButton, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotSizeDetermine() ) );
1028 connect( m_sizeStopButton, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotSizeStop() ) );
1029 sizelay->addWidget(m_sizeDetermineButton, 0);
1030 sizelay->addWidget(m_sizeStopButton, 0);
1031 sizelay->addStretch(10);
1034 if ( isReallyLocal && !hasRoot )
1036 m_sizeDetermineButton->setText( i18n(
"Refresh") );
1037 slotSizeDetermine();
1040 m_sizeStopButton->setEnabled(
false );
1043 if (!d->bMultiple && item->isLink()) {
1044 l =
new TQLabel(i18n(
"Points to:"), d->m_frame );
1045 grid->addWidget(l, curRow, 0);
1047 l =
new KSqueezedTextLabel(item->linkDest(), d->m_frame );
1048 grid->addWidget(l, curRow++, 2);
1055 time_t tim = item->time(TDEIO::UDS_CREATION_TIME, hasTime);
1058 l =
new TQLabel(i18n(
"Created:"), d->m_frame );
1059 grid->addWidget(l, curRow, 0);
1061 dt.setTime_t( tim );
1062 l =
new TQLabel(TDEGlobal::locale()->formatDateTime(dt), d->m_frame );
1063 grid->addWidget(l, curRow++, 2);
1066 tim = item->time(TDEIO::UDS_MODIFICATION_TIME, hasTime);
1069 l =
new TQLabel(i18n(
"Modified:"), d->m_frame );
1070 grid->addWidget(l, curRow, 0);
1072 dt.setTime_t( tim );
1073 l =
new TQLabel(TDEGlobal::locale()->formatDateTime(dt), d->m_frame );
1074 grid->addWidget(l, curRow++, 2);
1077 tim = item->time(TDEIO::UDS_ACCESS_TIME, hasTime);
1080 l =
new TQLabel(i18n(
"Accessed:"), d->m_frame );
1081 grid->addWidget(l, curRow, 0);
1083 dt.setTime_t( tim );
1084 l =
new TQLabel(TDEGlobal::locale()->formatDateTime(dt), d->m_frame );
1085 grid->addWidget(l, curRow++, 2);
1089 if ( isLocal && hasDirs )
1091 sep =
new KSeparator( KSeparator::HLine, d->m_frame);
1092 grid->addMultiCellWidget(sep, curRow, curRow, 0, 2);
1095 TQString mountPoint = TDEIO::findPathMountPoint( url.path() );
1097 if (mountPoint !=
"/")
1099 l =
new TQLabel(i18n(
"Mounted on:"), d->m_frame );
1100 grid->addWidget(l, curRow, 0);
1102 l =
new KSqueezedTextLabel( mountPoint, d->m_frame );
1103 grid->addWidget( l, curRow++, 2 );
1106 l =
new TQLabel(i18n(
"Free disk space:"), d->m_frame );
1107 grid->addWidget(l, curRow, 0);
1109 d->m_freeSpaceLabel =
new TQLabel( d->m_frame );
1110 grid->addWidget( d->m_freeSpaceLabel, curRow++, 2 );
1113 connect( job, TQ_SIGNAL( foundMountPoint(
const unsigned long&,
const unsigned long&,
1114 const unsigned long&,
const TQString& ) ),
1115 this, TQ_SLOT( slotFoundMountPoint(
const unsigned long&,
const unsigned long&,
1116 const unsigned long&,
const TQString& ) ) );
1117 job->
readDF( mountPoint );
1128 void KFilePropsPlugin::setFileNameReadOnly(
bool ro )
1132 d->m_lined->setReadOnly( ro );
1136 TQPushButton *button =
properties->actionButton(KDialogBase::Ok);
1143 void KFilePropsPlugin::slotEditFileType()
1147 if ( d->mimeType == KMimeType::defaultMimeType() ) {
1148 int pos = d->oldFileName.findRev(
'.' );
1150 mime =
"*" + d->oldFileName.mid(pos);
1157 TQString keditfiletype = TQString::fromLatin1(
"keditfiletype");
1158 KRun::runCommand( keditfiletype
1159 +
" --parent " + TQString::number( (ulong)
properties->topLevelWidget()->winId())
1160 +
" " + TDEProcess::quote(mime),
1161 keditfiletype, keditfiletype );
1165 void KFilePropsPlugin::slotIconChanged()
1167 d->bIconChanged =
true;
1171 void KFilePropsPlugin::nameFileChanged(
const TQString &text )
1177 void KFilePropsPlugin::determineRelativePath(
const TQString & path )
1183 m_sRelativePath =TDEGlobal::dirs()->relativeLocation(
"mime", path);
1184 if (m_sRelativePath.startsWith(
"/"))
1185 m_sRelativePath = TQString::null;
1189 m_sRelativePath =TDEGlobal::dirs()->relativeLocation(
"apps", path);
1190 if (m_sRelativePath.startsWith(
"/"))
1192 m_sRelativePath =TDEGlobal::dirs()->relativeLocation(
"xdgdata-apps", path);
1193 if (m_sRelativePath.startsWith(
"/"))
1194 m_sRelativePath = TQString::null;
1196 m_sRelativePath = path;
1199 if ( m_sRelativePath.isEmpty() )
1202 kdWarning(250) <<
"Warning : editing a mimetype file out of the mimetype dirs!" << endl;
1206 void KFilePropsPlugin::slotFoundMountPoint(
const TQString&,
1207 unsigned long kBSize,
1209 unsigned long kBAvail )
1211 d->m_freeSpaceLabel->setText(
1213 i18n(
"Available space out of total partition size (percent used)",
"%1 out of %2 (%3% used)")
1214 .arg(TDEIO::convertSizeFromKB(kBAvail))
1215 .arg(TDEIO::convertSizeFromKB(kBSize))
1216 .arg( 100 - (
int)(100.0 * kBAvail / kBSize) ));
1221 void KFilePropsPlugin::slotFoundMountPoint(
const unsigned long& kBSize,
1222 const unsigned long& ,
1223 const unsigned long& kBAvail,
1226 d->m_freeSpaceLabel->setText(
1228 i18n(
"Available space out of total partition size (percent used)",
"%1 out of %2 (%3% used)")
1229 .arg(TDEIO::convertSizeFromKB(kBAvail))
1230 .arg(TDEIO::convertSizeFromKB(kBSize))
1231 .arg( 100 - (
int)(100.0 * kBAvail / kBSize) ));
1234 void KFilePropsPlugin::slotDirSizeUpdate()
1236 TDEIO::filesize_t totalSize = d->dirSizeJob->totalSize();
1237 TDEIO::filesize_t totalFiles = d->dirSizeJob->totalFiles();
1238 TDEIO::filesize_t totalSubdirs = d->dirSizeJob->totalSubdirs();
1239 m_sizeLabel->setText( i18n(
"Calculating... %1 (%2)\n%3, %4")
1240 .arg(TDEIO::convertSize(totalSize))
1241 .arg(TDEGlobal::locale()->formatNumber(totalSize, 0))
1242 .arg(i18n(
"1 file",
"%n files",totalFiles))
1243 .arg(i18n(
"1 sub-folder",
"%n sub-folders",totalSubdirs)));
1246 void KFilePropsPlugin::slotDirSizeFinished( TDEIO::Job * job )
1249 m_sizeLabel->setText( job->errorString() );
1252 TDEIO::filesize_t totalSize =
static_cast<KDirSize*
>(job)->totalSize();
1253 TDEIO::filesize_t totalFiles =
static_cast<KDirSize*
>(job)->totalFiles();
1254 TDEIO::filesize_t totalSubdirs =
static_cast<KDirSize*
>(job)->totalSubdirs();
1255 m_sizeLabel->setText( TQString::fromLatin1(
"%1 (%2)\n%3, %4")
1256 .arg(TDEIO::convertSize(totalSize))
1257 .arg(TDEGlobal::locale()->formatNumber(totalSize, 0))
1258 .arg(i18n(
"1 file",
"%n files",totalFiles))
1259 .arg(i18n(
"1 sub-folder",
"%n sub-folders",totalSubdirs)));
1261 m_sizeStopButton->setEnabled(
false);
1263 m_sizeDetermineButton->setText( i18n(
"Refresh") );
1264 m_sizeDetermineButton->setEnabled(
true);
1266 delete d->dirSizeUpdateTimer;
1267 d->dirSizeUpdateTimer = 0L;
1270 void KFilePropsPlugin::slotSizeDetermine()
1272 m_sizeLabel->setText( i18n(
"Calculating...") );
1273 kdDebug(250) <<
" KFilePropsPlugin::slotSizeDetermine() properties->item()=" <<
properties->
item() << endl;
1274 kdDebug(250) <<
" URL=" <<
properties->
item()->url().url() << endl;
1276 d->dirSizeUpdateTimer =
new TQTimer(
this);
1277 connect( d->dirSizeUpdateTimer, TQ_SIGNAL( timeout() ),
1278 TQ_SLOT( slotDirSizeUpdate() ) );
1279 d->dirSizeUpdateTimer->start(500);
1280 connect( d->dirSizeJob, TQ_SIGNAL( result( TDEIO::Job * ) ),
1281 TQ_SLOT( slotDirSizeFinished( TDEIO::Job * ) ) );
1282 m_sizeStopButton->setEnabled(
true);
1283 m_sizeDetermineButton->setEnabled(
false);
1286 if ( d->m_freeSpaceLabel )
1290 KURL url = item->mostLocalURL( isLocal );
1291 TQString mountPoint = TDEIO::findPathMountPoint( url.path() );
1294 connect( job, TQ_SIGNAL( foundMountPoint(
const unsigned long&,
const unsigned long&,
1295 const unsigned long&,
const TQString& ) ),
1296 this, TQ_SLOT( slotFoundMountPoint(
const unsigned long&,
const unsigned long&,
1297 const unsigned long&,
const TQString& ) ) );
1298 job->
readDF( mountPoint );
1302 void KFilePropsPlugin::slotSizeStop()
1304 if ( d->dirSizeJob )
1306 m_sizeLabel->setText( i18n(
"Stopped") );
1307 d->dirSizeJob->kill();
1310 if ( d->dirSizeUpdateTimer )
1311 d->dirSizeUpdateTimer->stop();
1313 m_sizeStopButton->setEnabled(
false);
1314 m_sizeDetermineButton->setEnabled(
true);
1317 KFilePropsPlugin::~KFilePropsPlugin()
1328 void tqt_enter_modal( TQWidget *widget );
1329 void tqt_leave_modal( TQWidget *widget );
1333 if ( d->dirSizeJob ) {
1337 kdDebug(250) <<
"KFilePropsPlugin::applyChanges" << endl;
1339 if (nameArea->inherits(
"TQLineEdit"))
1341 TQString n = ((TQLineEdit *) nameArea)->text();
1343 while ( n[n.length()-1].isSpace() )
1344 n.truncate( n.length() - 1 );
1347 KMessageBox::sorry(
properties, i18n(
"The new file name is empty."));
1353 kdDebug(250) <<
"oldname = " << oldName << endl;
1354 kdDebug(250) <<
"newname = " << n << endl;
1355 if ( oldName != n || m_bFromTemplate ) {
1356 TDEIO::Job * job = 0L;
1359 TQString newFileName = TDEIO::encodeFileName(n);
1360 if (d->bDesktopFile && !newFileName.endsWith(
".desktop") && !newFileName.endsWith(
".kdelnk"))
1361 newFileName +=
".desktop";
1367 if ( !m_sRelativePath.isEmpty() ) {
1371 kdDebug(250) <<
"New URL = " <<
properties->
kurl().url() << endl;
1372 kdDebug(250) <<
"old = " << oldurl.url() << endl;
1375 if ( !m_bFromTemplate ) {
1382 connect( job, TQ_SIGNAL( result( TDEIO::Job * ) ),
1383 TQ_SLOT( slotCopyFinished( TDEIO::Job * ) ) );
1384 connect( job, TQ_SIGNAL( renamed( TDEIO::Job *,
const KURL &,
const KURL & ) ),
1385 TQ_SLOT( slotFileRenamed( TDEIO::Job *,
const KURL &,
const KURL & ) ) );
1387 TQWidget dummy(0,0,(WFlags)(WType_Dialog|WShowModal));
1388 tqt_enter_modal(&dummy);
1389 tqApp->enter_loop();
1390 tqt_leave_modal(&dummy);
1395 if ( !m_sRelativePath.isEmpty() ) {
1401 slotCopyFinished( 0L );
1404 void KFilePropsPlugin::slotCopyFinished( TDEIO::Job * job )
1406 kdDebug(250) <<
"KFilePropsPlugin::slotCopyFinished" << endl;
1413 job->showErrorDialog( d->m_frame );
1425 if (KBindingPropsPlugin::supports(
properties->
items()) && !m_sRelativePath.isEmpty())
1428 newURL.setPath( locateLocal(
"mime", m_sRelativePath) );
1431 else if (d->bDesktopFile && !m_sRelativePath.isEmpty())
1433 kdDebug(250) <<
"KFilePropsPlugin::slotCopyFinished " << m_sRelativePath << endl;
1435 newURL.setPath( KDesktopFile::locateLocal(m_sRelativePath) );
1436 kdDebug(250) <<
"KFilePropsPlugin::slotCopyFinished path=" << newURL.path() << endl;
1440 if ( d->bKDesktopMode && d->bDesktopFile ) {
1442 if ( d->oldFileName !=
properties->
kurl().fileName() || m_bFromTemplate ) {
1444 TQString nameStr = nameFromFileName(
properties->
kurl().fileName());
1445 config.writeEntry(
"Name", nameStr );
1446 config.writeEntry(
"Name", nameStr,
true,
false,
true );
1451 void KFilePropsPlugin::applyIconChanges()
1453 TDEIconButton *iconButton = ::tqt_cast<TDEIconButton *>( iconArea );
1454 if ( !iconButton || !d->bIconChanged )
1459 url = TDEIO::NetAccess::mostLocalURL( url,
properties );
1460 if (url.isLocalFile()) {
1465 path = url.path(1) + TQString::fromLatin1(
".directory");
1473 TQString str = KMimeType::findByURL( url,
1475 true )->KServiceType::icon();
1478 if ( str != iconButton->
icon() )
1479 sIcon = iconButton->
icon();
1482 kdDebug(250) <<
"**" << path <<
"**" << endl;
1486 if ( !sIcon.isEmpty() || f.exists() )
1488 if ( !f.open( IO_ReadWrite ) ) {
1489 KMessageBox::sorry( 0, i18n(
"<qt>Could not save properties. You do not "
1490 "have sufficient access to write to <b>%1</b>.</qt>").arg(path));
1495 KDesktopFile cfg(path);
1496 kdDebug(250) <<
"sIcon = " << (sIcon) << endl;
1497 kdDebug(250) <<
"str = " << (str) << endl;
1498 cfg.writeEntry(
"Icon", sIcon );
1504 void KFilePropsPlugin::slotFileRenamed( TDEIO::Job *,
const KURL &,
const KURL & newUrl )
1518 for ( KFileItemListIterator it( items ); it.current(); ++it )
1519 lst.append((*it)->url());
1520 KDirNotify_stub allDirNotify(
"*",
"KDirNotify*");
1521 allDirNotify.FilesChanged( lst );
1524 class KFilePermissionsPropsPlugin::KFilePermissionsPropsPluginPrivate
1527 KFilePermissionsPropsPluginPrivate()
1530 ~KFilePermissionsPropsPluginPrivate()
1535 TQCheckBox *cbRecursive;
1536 TQLabel *explanationLabel;
1537 TQComboBox *ownerPermCombo, *groupPermCombo, *othersPermCombo;
1538 TQCheckBox *extraCheckbox;
1539 mode_t partialPermissions;
1540 KFilePermissionsPropsPlugin::PermissionsMode pmode;
1541 bool canChangePermissions;
1543 bool hasExtendedACL;
1546 bool fileSystemSupportsACLs;
1549 #define UniOwner (S_IRUSR|S_IWUSR|S_IXUSR)
1550 #define UniGroup (S_IRGRP|S_IWGRP|S_IXGRP)
1551 #define UniOthers (S_IROTH|S_IWOTH|S_IXOTH)
1552 #define UniRead (S_IRUSR|S_IRGRP|S_IROTH)
1553 #define UniWrite (S_IWUSR|S_IWGRP|S_IWOTH)
1554 #define UniExec (S_IXUSR|S_IXGRP|S_IXOTH)
1555 #define UniSpecial (S_ISUID|S_ISGID|S_ISVTX)
1558 const mode_t KFilePermissionsPropsPlugin::permissionsMasks[3] = {UniOwner, UniGroup, UniOthers};
1559 const mode_t KFilePermissionsPropsPlugin::standardPermissions[4] = { 0, UniRead, UniRead|UniWrite, (mode_t)-1 };
1562 const char *KFilePermissionsPropsPlugin::permissionsTexts[4][4] = {
1563 { I18N_NOOP(
"Forbidden"),
1564 I18N_NOOP(
"Can Read"),
1565 I18N_NOOP(
"Can Read & Write"),
1567 { I18N_NOOP(
"Forbidden"),
1568 I18N_NOOP(
"Can View Content"),
1569 I18N_NOOP(
"Can View & Modify Content"),
1572 { I18N_NOOP(
"Forbidden"),
1573 I18N_NOOP(
"Can View Content & Read"),
1574 I18N_NOOP(
"Can View/Read & Modify/Write"),
1582 d =
new KFilePermissionsPropsPluginPrivate;
1583 d->cbRecursive = 0L;
1584 grpCombo = 0L; grpEdit = 0;
1589 bool isTrash = (
properties->
kurl().protocol().find(
"trash", 0,
false)==0 );
1590 bool IamRoot = (geteuid() == 0);
1593 bool isLink = item->isLink();
1594 bool isDir = item->isDir();
1595 bool hasDir = item->isDir();
1596 permissions = item->permissions();
1597 d->partialPermissions = permissions;
1598 d->isIrregular = isIrregular(permissions, isDir, isLink);
1599 strOwner = item->user();
1600 strGroup = item->group();
1601 d->hasExtendedACL = item->ACL().isExtended() || item->defaultACL().isValid();
1602 d->extendedACL = item->ACL();
1603 d->defaultACL = item->defaultACL();
1604 d->fileSystemSupportsACLs =
false;
1610 KFileItemListIterator it( items );
1611 for ( ++it ; it.current(); ++it )
1613 if (!d->isIrregular)
1614 d->isIrregular |= isIrregular((*it)->permissions(),
1615 (*it)->isDir() == isDir,
1616 (*it)->isLink() == isLink);
1617 d->hasExtendedACL = d->hasExtendedACL || (*it)->hasExtendedACL();
1618 if ( (*it)->isLink() != isLink )
1620 if ( (*it)->isDir() != isDir )
1622 hasDir |= (*it)->isDir();
1623 if ( (*it)->permissions() != permissions )
1625 permissions &= (*it)->permissions();
1626 d->partialPermissions |= (*it)->permissions();
1628 if ( (*it)->user() != strOwner )
1629 strOwner = TQString::null;
1630 if ( (*it)->group() != strGroup )
1631 strGroup = TQString::null;
1636 d->pmode = PermissionsOnlyLinks;
1638 d->pmode = PermissionsOnlyDirs;
1640 d->pmode = PermissionsMixed;
1642 d->pmode = PermissionsOnlyFiles;
1645 d->partialPermissions = d->partialPermissions & ~permissions;
1647 bool isMyFile =
false;
1649 if (isLocal && !strOwner.isEmpty()) {
1650 struct passwd *myself = getpwuid( geteuid() );
1653 isMyFile = (strOwner == TQString::fromLocal8Bit(myself->pw_name));
1655 kdWarning() <<
"I don't exist ?! geteuid=" << geteuid() << endl;
1663 d->canChangePermissions = (isMyFile || IamRoot) && (!isLink);
1668 d->m_frame =
properties->addPage(i18n(
"&Permissions"));
1670 TQBoxLayout *box =
new TQVBoxLayout( d->m_frame, 0, KDialog::spacingHint() );
1676 TQPushButton* pbAdvancedPerm = 0;
1679 gb =
new TQGroupBox ( 0, TQt::Vertical, i18n(
"Access Permissions"), d->m_frame );
1680 gb->layout()->setSpacing(KDialog::spacingHint());
1681 gb->layout()->setMargin(KDialog::marginHint());
1682 box->addWidget (gb);
1684 gl =
new TQGridLayout (gb->layout(), 7, 2);
1685 gl->setColStretch(1, 1);
1687 l = d->explanationLabel =
new TQLabel(
"", gb );
1689 d->explanationLabel->setText(i18n(
"This file is a link and does not have permissions.",
1690 "All files are links and do not have permissions.",
1692 else if (!d->canChangePermissions)
1693 d->explanationLabel->setText(i18n(
"Only the owner can change permissions."));
1694 gl->addMultiCellWidget(l, 0, 0, 0, 1);
1696 lbl =
new TQLabel( i18n(
"O&wner:"), gb);
1697 gl->addWidget(lbl, 1, 0);
1698 l = d->ownerPermCombo =
new TQComboBox(gb);
1700 gl->addWidget(l, 1, 1);
1701 connect(l, TQ_SIGNAL( highlighted(
int) ),
this, TQ_SIGNAL(
changed() ));
1702 TQWhatsThis::add(l, i18n(
"Specifies the actions that the owner is allowed to do."));
1704 lbl =
new TQLabel( i18n(
"Gro&up:"), gb);
1705 gl->addWidget(lbl, 2, 0);
1706 l = d->groupPermCombo =
new TQComboBox(gb);
1708 gl->addWidget(l, 2, 1);
1709 connect(l, TQ_SIGNAL( highlighted(
int) ),
this, TQ_SIGNAL(
changed() ));
1710 TQWhatsThis::add(l, i18n(
"Specifies the actions that the members of the group are allowed to do."));
1712 lbl =
new TQLabel( i18n(
"O&thers:"), gb);
1713 gl->addWidget(lbl, 3, 0);
1714 l = d->othersPermCombo =
new TQComboBox(gb);
1716 gl->addWidget(l, 3, 1);
1717 connect(l, TQ_SIGNAL( highlighted(
int) ),
this, TQ_SIGNAL(
changed() ));
1718 TQWhatsThis::add(l, i18n(
"Specifies the actions that all users, who are neither "
1719 "owner nor in the group, are allowed to do."));
1722 l = d->extraCheckbox =
new TQCheckBox(hasDir ?
1723 i18n(
"Only own&er can rename and delete folder content") :
1724 i18n(
"Is &executable"),
1726 connect( d->extraCheckbox, TQ_SIGNAL( clicked() ),
this, TQ_SIGNAL(
changed() ) );
1727 gl->addWidget(l, 4, 1);
1728 TQWhatsThis::add(l, hasDir ? i18n(
"Enable this option to allow only the folder's owner to "
1729 "delete or rename the contained files and folders. Other "
1730 "users can only add new files, which requires the 'Modify "
1731 "Content' permission.")
1732 : i18n(
"Enable this option to mark the file as executable. This only makes "
1733 "sense for programs and scripts. It is required when you want to "
1736 TQLayoutItem *spacer =
new TQSpacerItem(0, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding);
1737 gl->addMultiCell(spacer, 5, 5, 0, 1);
1739 pbAdvancedPerm =
new TQPushButton(i18n(
"A&dvanced Permissions"), gb);
1740 gl->addMultiCellWidget(pbAdvancedPerm, 6, 6, 0, 1, TQt::AlignRight);
1741 connect(pbAdvancedPerm, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotShowAdvancedPermissions() ));
1744 d->extraCheckbox = 0;
1748 gb =
new TQGroupBox ( 0, TQt::Vertical, i18n(
"Ownership"), d->m_frame );
1749 gb->layout()->setSpacing(KDialog::spacingHint());
1750 gb->layout()->setMargin(KDialog::marginHint());
1751 box->addWidget (gb);
1753 gl =
new TQGridLayout (gb->layout(), 4, 3);
1754 gl->addRowSpacing(0, 10);
1757 l =
new TQLabel( i18n(
"User:"), gb );
1758 gl->addWidget (l, 1, 0);
1765 int i, maxEntries = 1000;
1766 struct passwd *user;
1771 if (IamRoot && isLocal)
1773 usrEdit =
new KLineEdit( gb );
1774 TDECompletion *kcom = usrEdit->completionObject();
1775 kcom->setOrder(TDECompletion::Sorted);
1777 for (i=0; ((user = getpwent()) != 0L) && (i < maxEntries); i++)
1778 kcom->addItem(TQString::fromLatin1(user->pw_name));
1780 usrEdit->setCompletionMode((i < maxEntries) ? TDEGlobalSettings::CompletionAuto :
1781 TDEGlobalSettings::CompletionNone);
1782 usrEdit->setText(strOwner);
1783 gl->addWidget(usrEdit, 1, 1);
1784 connect( usrEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
1785 this, TQ_SIGNAL(
changed() ) );
1789 l =
new TQLabel(strOwner, gb);
1790 gl->addWidget(l, 1, 1);
1795 TQStringList groupList;
1797 user = getpwuid(geteuid());
1799 strUser = user->pw_name;
1802 gid_t *groups = NULL;
1804 struct group *mygroup;
1805 gid_t *newgroups = NULL;
1807 groups = (gid_t *) malloc(ng *
sizeof(gid_t));
1809 if (getgrouplist(strUser, user->pw_gid, groups, &ng) == -1) {
1810 newgroups = (gid_t *) malloc(ng *
sizeof(gid_t));
1811 if (newgroups != NULL) {
1814 getgrouplist(strUser, user->pw_gid, groups, &ng);
1818 for (i = 0; i < ng; i++) {
1819 mygroup = getgrgid(groups[i]);
1820 if (mygroup != NULL) groupList += TQString::fromLocal8Bit(mygroup->gr_name);
1829 ge = getgrgid (getegid());
1831 TQString name = TQString::fromLatin1(ge->gr_name);
1833 name.setNum(ge->gr_gid);
1834 if (groupList.find(name) == groupList.end())
1839 bool isMyGroup = groupList.contains(strGroup);
1845 groupList += strGroup;
1847 l =
new TQLabel( i18n(
"Group:"), gb );
1848 gl->addWidget (l, 2, 0);
1856 if (IamRoot && isLocal)
1858 grpEdit =
new KLineEdit(gb);
1859 TDECompletion *kcom =
new TDECompletion;
1860 kcom->setItems(groupList);
1861 grpEdit->setCompletionObject(kcom,
true);
1862 grpEdit->setAutoDeleteCompletionObject(
true );
1863 grpEdit->setCompletionMode(TDEGlobalSettings::CompletionAuto);
1864 grpEdit->setText(strGroup);
1865 gl->addWidget(grpEdit, 2, 1);
1866 connect( grpEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
1867 this, TQ_SIGNAL(
changed() ) );
1869 else if ((groupList.count() > 1) && isMyFile && isLocal)
1871 grpCombo =
new TQComboBox(gb,
"combogrouplist");
1872 grpCombo->insertStringList(groupList);
1873 grpCombo->setCurrentItem(groupList.findIndex(strGroup));
1874 gl->addWidget(grpCombo, 2, 1);
1875 connect( grpCombo, TQ_SIGNAL( activated(
int ) ),
1876 this, TQ_SIGNAL(
changed() ) );
1880 l =
new TQLabel(strGroup, gb);
1881 gl->addWidget(l, 2, 1);
1884 gl->setColStretch(2, 10);
1887 if ( hasDir && !isLink && !isTrash )
1889 d->cbRecursive =
new TQCheckBox( i18n(
"Apply changes to all subfolders and their contents"), d->m_frame );
1890 connect( d->cbRecursive, TQ_SIGNAL( clicked() ),
this, TQ_SIGNAL(
changed() ) );
1891 box->addWidget( d->cbRecursive );
1894 updateAccessControls();
1897 if ( isTrash || !d->canChangePermissions )
1900 enableAccessControls(
false);
1901 if ( pbAdvancedPerm && !d->hasExtendedACL )
1902 pbAdvancedPerm->setEnabled(
false);
1905 box->addStretch (10);
1908 #ifdef USE_POSIX_ACL
1909 static bool fileSystemSupportsACL(
const TQCString& pathCString )
1911 bool fileSystemSupportsACLs =
false;
1914 fileSystemSupportsACLs = ( statfs( pathCString.data(), &buf ) == 0 ) && ( buf.f_flags & MNT_ACLS );
1916 fileSystemSupportsACLs =
1917 getxattr( pathCString.data(),
"system.posix_acl_access", NULL, 0 ) >= 0
1919 || (errno == ENODATA)
1922 || (errno == ENOATTR)
1926 return fileSystemSupportsACLs;
1931 void KFilePermissionsPropsPlugin::slotShowAdvancedPermissions() {
1933 bool isDir = (d->pmode == PermissionsOnlyDirs) || (d->pmode == PermissionsMixed);
1934 KDialogBase dlg(
properties, 0,
true, i18n(
"Advanced Permissions"),
1935 KDialogBase::Ok|KDialogBase::Cancel);
1941 TQVBox *mainVBox = dlg.makeVBoxMainWidget();
1944 gb =
new TQGroupBox ( 0, TQt::Vertical, i18n(
"Access Permissions"), mainVBox );
1945 gb->layout()->setSpacing(KDialog::spacingHint());
1946 gb->layout()->setMargin(KDialog::marginHint());
1948 gl =
new TQGridLayout (gb->layout(), 6, 6);
1949 gl->addRowSpacing(0, 10);
1951 TQValueVector<TQWidget*> theNotSpecials;
1953 l =
new TQLabel(i18n(
"Class"), gb );
1954 gl->addWidget(l, 1, 0);
1955 theNotSpecials.append( l );
1958 l =
new TQLabel( i18n(
"Show\nEntries"), gb );
1960 l =
new TQLabel( i18n(
"Read"), gb );
1961 gl->addWidget (l, 1, 1);
1962 theNotSpecials.append( l );
1963 TQString readWhatsThis;
1965 readWhatsThis = i18n(
"This flag allows viewing the content of the folder.");
1967 readWhatsThis = i18n(
"The Read flag allows viewing the content of the file.");
1968 TQWhatsThis::add(l, readWhatsThis);
1971 l =
new TQLabel( i18n(
"Write\nEntries"), gb );
1973 l =
new TQLabel( i18n(
"Write"), gb );
1974 gl->addWidget (l, 1, 2);
1975 theNotSpecials.append( l );
1976 TQString writeWhatsThis;
1978 writeWhatsThis = i18n(
"This flag allows adding, renaming and deleting of files. "
1979 "Note that deleting and renaming can be limited using the Sticky flag.");
1981 writeWhatsThis = i18n(
"The Write flag allows modifying the content of the file.");
1982 TQWhatsThis::add(l, writeWhatsThis);
1984 TQString execWhatsThis;
1986 l =
new TQLabel( i18n(
"Enter folder",
"Enter"), gb );
1987 execWhatsThis = i18n(
"Enable this flag to allow entering the folder.");
1990 l =
new TQLabel( i18n(
"Exec"), gb );
1991 execWhatsThis = i18n(
"Enable this flag to allow executing the file as a program.");
1993 TQWhatsThis::add(l, execWhatsThis);
1994 theNotSpecials.append( l );
1996 TQSize size = l->sizeHint();
1997 size.setWidth(size.width() + 15);
1998 l->setFixedSize(size);
1999 gl->addWidget (l, 1, 3);
2001 l =
new TQLabel( i18n(
"Special"), gb );
2002 gl->addMultiCellWidget(l, 1, 1, 4, 5);
2003 TQString specialWhatsThis;
2005 specialWhatsThis = i18n(
"Special flag. Valid for the whole folder, the exact "
2006 "meaning of the flag can be seen in the right hand column.");
2008 specialWhatsThis = i18n(
"Special flag. The exact meaning of the flag can be seen "
2009 "in the right hand column.");
2010 TQWhatsThis::add(l, specialWhatsThis);
2012 cl[0] =
new TQLabel( i18n(
"User"), gb );
2013 gl->addWidget (cl[0], 2, 0);
2014 theNotSpecials.append( cl[0] );
2016 cl[1] =
new TQLabel( i18n(
"Group"), gb );
2017 gl->addWidget (cl[1], 3, 0);
2018 theNotSpecials.append( cl[1] );
2020 cl[2] =
new TQLabel( i18n(
"Others"), gb );
2021 gl->addWidget (cl[2], 4, 0);
2022 theNotSpecials.append( cl[2] );
2024 l =
new TQLabel(i18n(
"Set UID"), gb);
2025 gl->addWidget(l, 2, 5);
2026 TQString setUidWhatsThis;
2028 setUidWhatsThis = i18n(
"If this flag is set, the owner of this folder will be "
2029 "the owner of all new files.");
2031 setUidWhatsThis = i18n(
"If this file is an executable and the flag is set, it will "
2032 "be executed with the permissions of the owner.");
2033 TQWhatsThis::add(l, setUidWhatsThis);
2035 l =
new TQLabel(i18n(
"Set GID"), gb);
2036 gl->addWidget(l, 3, 5);
2037 TQString setGidWhatsThis;
2039 setGidWhatsThis = i18n(
"If this flag is set, the group of this folder will be "
2040 "set for all new files.");
2042 setGidWhatsThis = i18n(
"If this file is an executable and the flag is set, it will "
2043 "be executed with the permissions of the group.");
2044 TQWhatsThis::add(l, setGidWhatsThis);
2046 l =
new TQLabel(i18n(
"File permission",
"Sticky"), gb);
2047 gl->addWidget(l, 4, 5);
2048 TQString stickyWhatsThis;
2050 stickyWhatsThis = i18n(
"If the Sticky flag is set on a folder, only the owner "
2051 "and root can delete or rename files. Otherwise everybody "
2052 "with write permissions can do this.");
2054 stickyWhatsThis = i18n(
"The Sticky flag on a file is ignored on Linux, but may "
2055 "be used on some systems");
2056 TQWhatsThis::add(l, stickyWhatsThis);
2058 mode_t aPermissions, aPartialPermissions;
2059 mode_t dummy1, dummy2;
2061 if (!d->isIrregular) {
2063 case PermissionsOnlyFiles:
2064 getPermissionMasks(aPartialPermissions,
2069 case PermissionsOnlyDirs:
2070 case PermissionsMixed:
2071 getPermissionMasks(dummy1,
2072 aPartialPermissions,
2076 case PermissionsOnlyLinks:
2077 aPermissions = UniRead | UniWrite | UniExec | UniSpecial;
2078 aPartialPermissions = 0;
2083 aPermissions = permissions;
2084 aPartialPermissions = d->partialPermissions;
2088 bool allDisable =
true;
2089 TQCheckBox *cba[3][4];
2090 for (
int row = 0; row < 3 ; ++row) {
2091 for (
int col = 0; col < 4; ++col) {
2092 TQCheckBox *cb =
new TQCheckBox( gb );
2093 if ( col != 3 ) theNotSpecials.append( cb );
2095 cb->setChecked(aPermissions & fperm[row][col]);
2096 if ( d->canChangePermissions )
2100 if ( aPartialPermissions & fperm[row][col] )
2105 else if (d->cbRecursive && d->cbRecursive->isChecked())
2110 cb->setEnabled( d->canChangePermissions );
2111 gl->addWidget (cb, row+2, col+1);
2114 TQWhatsThis::add(cb, readWhatsThis);
2117 TQWhatsThis::add(cb, writeWhatsThis);
2120 TQWhatsThis::add(cb, execWhatsThis);
2125 TQWhatsThis::add(cb, setUidWhatsThis);
2128 TQWhatsThis::add(cb, setGidWhatsThis);
2131 TQWhatsThis::add(cb, stickyWhatsThis);
2138 gl->setColStretch(6, 10);
2140 #ifdef USE_POSIX_ACL
2141 KACLEditWidget *extendedACLs = 0;
2145 TQCString pathCString = TQFile::encodeName(
properties->
item()->url().path() );
2146 d->fileSystemSupportsACLs = fileSystemSupportsACL( pathCString );
2148 if ( d->fileSystemSupportsACLs ) {
2149 std::for_each( theNotSpecials.begin(), theNotSpecials.end(), std::mem_fn( &TQWidget::hide ) );
2150 extendedACLs =
new KACLEditWidget( mainVBox );
2151 if ( d->extendedACL.isValid() && d->extendedACL.isExtended() )
2152 extendedACLs->setACL( d->extendedACL );
2154 extendedACLs->setACL( KACL( aPermissions ) );
2156 if ( d->defaultACL.isValid() )
2157 extendedACLs->setDefaultACL( d->defaultACL );
2160 extendedACLs->setAllowDefaults(
true );
2161 if ( !d->canChangePermissions )
2162 extendedACLs->setReadOnly(
true );
2167 dlg.enableButtonOK(
false );
2170 if (dlg.exec() != KDialogBase::Accepted)
2173 mode_t andPermissions = mode_t(~0);
2174 mode_t orPermissions = 0;
2175 for (
int row = 0; row < 3; ++row)
2176 for (
int col = 0; col < 4; ++col) {
2177 switch (cba[row][col]->state())
2179 case TQCheckBox::On:
2180 orPermissions |= fperm[row][col];
2182 case TQCheckBox::Off:
2183 andPermissions &= ~fperm[row][col];
2190 d->isIrregular =
false;
2192 for (KFileItemListIterator it(items); it.current(); ++it) {
2193 if (isIrregular(((*it)->permissions() & andPermissions) | orPermissions,
2194 (*it)->isDir(), (*it)->isLink())) {
2195 d->isIrregular =
true;
2200 permissions = orPermissions;
2201 d->partialPermissions = andPermissions;
2203 #ifdef USE_POSIX_ACL
2205 if ( extendedACLs ) {
2206 d->extendedACL = extendedACLs->getACL();
2207 d->defaultACL = extendedACLs->getDefaultACL();
2208 d->hasExtendedACL = d->extendedACL.isExtended() || d->defaultACL.isValid();
2209 permissions = d->extendedACL.basePermissions();
2210 permissions |= ( andPermissions | orPermissions ) & ( S_ISUID|S_ISGID|S_ISVTX );
2214 updateAccessControls();
2223 KFilePermissionsPropsPlugin::~KFilePermissionsPropsPlugin()
2230 KFileItemList::const_iterator it = _items.constBegin();
2231 for ( ; it != _items.constEnd(); ++it ) {
2232 KFileItem *item = *it;
2233 if( !item->user().isEmpty() || !item->group().isEmpty() )
2240 void KFilePermissionsPropsPlugin::setComboContent(TQComboBox *combo, PermissionsTarget target,
2241 mode_t permissions, mode_t partial) {
2243 if (d->pmode == PermissionsOnlyLinks) {
2244 combo->insertItem(i18n(
"Link"));
2245 combo->setCurrentItem(0);
2249 mode_t tMask = permissionsMasks[target];
2251 for (textIndex = 0; standardPermissions[textIndex] != (mode_t)-1; textIndex++)
2252 if ((standardPermissions[textIndex]&tMask) == (permissions&tMask&(UniRead|UniWrite)))
2254 Q_ASSERT(standardPermissions[textIndex] != (mode_t)-1);
2256 for (
int i = 0; permissionsTexts[(int)d->pmode][i]; i++)
2257 combo->insertItem(i18n(permissionsTexts[(
int)d->pmode][i]));
2259 if (partial & tMask & ~UniExec) {
2260 combo->insertItem(i18n(
"Varying (No Change)"));
2261 combo->setCurrentItem(3);
2264 combo->setCurrentItem(textIndex);
2268 bool KFilePermissionsPropsPlugin::isIrregular(mode_t permissions,
bool isDir,
bool isLink) {
2272 mode_t p = permissions;
2273 if (p & (S_ISUID | S_ISGID))
2279 mode_t p0 = p & UniOwner;
2280 if ((p0 != 0) && (p0 != (S_IRUSR | S_IXUSR)) && (p0 != UniOwner))
2283 if ((p0 != 0) && (p0 != (S_IRGRP | S_IXGRP)) && (p0 != UniGroup))
2286 if ((p0 != 0) && (p0 != (S_IROTH | S_IXOTH)) && (p0 != UniOthers))
2294 mode_t p0 = p & UniOwner;
2295 bool usrXPossible = !p0;
2297 if ((p0 == S_IXUSR) || (p0 == (S_IWUSR | S_IXUSR)))
2299 usrXPossible =
true;
2301 else if (p0 == S_IWUSR)
2305 bool grpXPossible = !p0;
2307 if ((p0 == S_IXGRP) || (p0 == (S_IWGRP | S_IXGRP)))
2309 grpXPossible =
true;
2311 else if (p0 == S_IWGRP)
2314 grpXPossible =
true;
2317 bool othXPossible = !p0;
2319 if ((p0 == S_IXOTH) || (p0 == (S_IWOTH | S_IXOTH)))
2321 othXPossible =
true;
2323 else if (p0 == S_IWOTH)
2327 return (p & UniExec) && !(usrXPossible && grpXPossible && othXPossible);
2331 void KFilePermissionsPropsPlugin::enableAccessControls(
bool enable) {
2332 d->ownerPermCombo->setEnabled(enable);
2333 d->groupPermCombo->setEnabled(enable);
2334 d->othersPermCombo->setEnabled(enable);
2335 if (d->extraCheckbox)
2336 d->extraCheckbox->setEnabled(enable);
2337 if ( d->cbRecursive )
2338 d->cbRecursive->setEnabled(enable);
2342 void KFilePermissionsPropsPlugin::updateAccessControls() {
2343 setComboContent(d->ownerPermCombo, PermissionsOwner,
2344 permissions, d->partialPermissions);
2345 setComboContent(d->groupPermCombo, PermissionsGroup,
2346 permissions, d->partialPermissions);
2347 setComboContent(d->othersPermCombo, PermissionsOthers,
2348 permissions, d->partialPermissions);
2351 case PermissionsOnlyLinks:
2352 enableAccessControls(
false);
2354 case PermissionsOnlyFiles:
2355 enableAccessControls(d->canChangePermissions && !d->isIrregular && !d->hasExtendedACL);
2356 if (d->canChangePermissions)
2357 d->explanationLabel->setText(d->isIrregular || d->hasExtendedACL ?
2358 i18n(
"This file uses advanced permissions",
2359 "These files use advanced permissions.",
2361 if (d->partialPermissions & UniExec) {
2362 d->extraCheckbox->setTristate();
2363 d->extraCheckbox->setNoChange();
2366 d->extraCheckbox->setTristate(
false);
2367 d->extraCheckbox->setChecked(permissions & UniExec);
2370 case PermissionsOnlyDirs:
2371 enableAccessControls(d->canChangePermissions && !d->isIrregular && !d->hasExtendedACL);
2374 if ( d->cbRecursive )
2375 d->cbRecursive->setEnabled( d->canChangePermissions && !d->isIrregular );
2377 if (d->canChangePermissions)
2378 d->explanationLabel->setText(d->isIrregular || d->hasExtendedACL ?
2379 i18n(
"This folder uses advanced permissions.",
2380 "These folders use advanced permissions.",
2382 if (d->partialPermissions & S_ISVTX) {
2383 d->extraCheckbox->setTristate();
2384 d->extraCheckbox->setNoChange();
2387 d->extraCheckbox->setTristate(
false);
2388 d->extraCheckbox->setChecked(permissions & S_ISVTX);
2391 case PermissionsMixed:
2392 enableAccessControls(d->canChangePermissions && !d->isIrregular && !d->hasExtendedACL);
2393 if (d->canChangePermissions)
2394 d->explanationLabel->setText(d->isIrregular || d->hasExtendedACL ?
2395 i18n(
"These files use advanced permissions.") :
"");
2397 if (d->partialPermissions & S_ISVTX) {
2398 d->extraCheckbox->setTristate();
2399 d->extraCheckbox->setNoChange();
2402 d->extraCheckbox->setTristate(
false);
2403 d->extraCheckbox->setChecked(permissions & S_ISVTX);
2410 void KFilePermissionsPropsPlugin::getPermissionMasks(mode_t &andFilePermissions,
2411 mode_t &andDirPermissions,
2412 mode_t &orFilePermissions,
2413 mode_t &orDirPermissions) {
2414 andFilePermissions = mode_t(~UniSpecial);
2415 andDirPermissions = mode_t(~(S_ISUID|S_ISGID));
2416 orFilePermissions = 0;
2417 orDirPermissions = 0;
2421 mode_t m = standardPermissions[d->ownerPermCombo->currentItem()];
2422 if (m != (mode_t) -1) {
2423 orFilePermissions |= m & UniOwner;
2424 if ((m & UniOwner) &&
2425 ((d->pmode == PermissionsMixed) ||
2426 ((d->pmode == PermissionsOnlyFiles) && (d->extraCheckbox->state() == TQButton::NoChange))))
2427 andFilePermissions &= ~(S_IRUSR | S_IWUSR);
2429 andFilePermissions &= ~(S_IRUSR | S_IWUSR | S_IXUSR);
2430 if ((m & S_IRUSR) && (d->extraCheckbox->state() == TQButton::On))
2431 orFilePermissions |= S_IXUSR;
2434 orDirPermissions |= m & UniOwner;
2436 orDirPermissions |= S_IXUSR;
2437 andDirPermissions &= ~(S_IRUSR | S_IWUSR | S_IXUSR);
2440 m = standardPermissions[d->groupPermCombo->currentItem()];
2441 if (m != (mode_t) -1) {
2442 orFilePermissions |= m & UniGroup;
2443 if ((m & UniGroup) &&
2444 ((d->pmode == PermissionsMixed) ||
2445 ((d->pmode == PermissionsOnlyFiles) && (d->extraCheckbox->state() == TQButton::NoChange))))
2446 andFilePermissions &= ~(S_IRGRP | S_IWGRP);
2448 andFilePermissions &= ~(S_IRGRP | S_IWGRP | S_IXGRP);
2449 if ((m & S_IRGRP) && (d->extraCheckbox->state() == TQButton::On))
2450 orFilePermissions |= S_IXGRP;
2453 orDirPermissions |= m & UniGroup;
2455 orDirPermissions |= S_IXGRP;
2456 andDirPermissions &= ~(S_IRGRP | S_IWGRP | S_IXGRP);
2459 m = standardPermissions[d->othersPermCombo->currentItem()];
2460 if (m != (mode_t) -1) {
2461 orFilePermissions |= m & UniOthers;
2462 if ((m & UniOthers) &&
2463 ((d->pmode == PermissionsMixed) ||
2464 ((d->pmode == PermissionsOnlyFiles) && (d->extraCheckbox->state() == TQButton::NoChange))))
2465 andFilePermissions &= ~(S_IROTH | S_IWOTH);
2467 andFilePermissions &= ~(S_IROTH | S_IWOTH | S_IXOTH);
2468 if ((m & S_IROTH) && (d->extraCheckbox->state() == TQButton::On))
2469 orFilePermissions |= S_IXOTH;
2472 orDirPermissions |= m & UniOthers;
2474 orDirPermissions |= S_IXOTH;
2475 andDirPermissions &= ~(S_IROTH | S_IWOTH | S_IXOTH);
2478 if (((d->pmode == PermissionsMixed) || (d->pmode == PermissionsOnlyDirs)) &&
2479 (d->extraCheckbox->state() != TQButton::NoChange)) {
2480 andDirPermissions &= ~S_ISVTX;
2481 if (d->extraCheckbox->state() == TQButton::On)
2482 orDirPermissions |= S_ISVTX;
2488 mode_t orFilePermissions;
2489 mode_t orDirPermissions;
2490 mode_t andFilePermissions;
2491 mode_t andDirPermissions;
2493 if (!d->canChangePermissions)
2496 if (!d->isIrregular)
2497 getPermissionMasks(andFilePermissions,
2502 orFilePermissions = permissions;
2503 andFilePermissions = d->partialPermissions;
2504 orDirPermissions = permissions;
2505 andDirPermissions = d->partialPermissions;
2508 TQString owner, group;
2510 owner = usrEdit->text();
2512 group = grpEdit->text();
2514 group = grpCombo->currentText();
2516 if (owner == strOwner)
2517 owner = TQString::null;
2519 if (group == strGroup)
2520 group = TQString::null;
2522 bool recursive = d->cbRecursive && d->cbRecursive->isChecked();
2523 bool permissionChange =
false;
2525 KFileItemList files, dirs;
2527 for (KFileItemListIterator it(items); it.current(); ++it) {
2528 if ((*it)->isDir()) {
2530 if ((*it)->permissions() != (((*it)->permissions() & andDirPermissions) | orDirPermissions))
2531 permissionChange =
true;
2533 else if ((*it)->isFile()) {
2535 if ((*it)->permissions() != (((*it)->permissions() & andFilePermissions) | orFilePermissions))
2536 permissionChange =
true;
2540 const bool ACLChange = ( d->extendedACL !=
properties->
item()->ACL() );
2541 const bool defaultACLChange = ( d->defaultACL !=
properties->
item()->defaultACL() );
2543 if ( owner.isEmpty() && group.isEmpty() && !recursive
2544 && !permissionChange && !ACLChange && !defaultACLChange )
2548 if (files.count() > 0) {
2549 job = TDEIO::chmod( files, orFilePermissions, ~andFilePermissions,
2550 owner, group,
false );
2551 if ( ACLChange && d->fileSystemSupportsACLs )
2552 job->addMetaData(
"ACL_STRING", d->extendedACL.isValid()?d->extendedACL.asString():
"ACL_DELETE" );
2553 if ( defaultACLChange && d->fileSystemSupportsACLs )
2554 job->addMetaData(
"DEFAULT_ACL_STRING", d->defaultACL.isValid()?d->defaultACL.asString():
"ACL_DELETE" );
2556 connect( job, TQ_SIGNAL( result( TDEIO::Job * ) ),
2557 TQ_SLOT( slotChmodResult( TDEIO::Job * ) ) );
2559 TQWidget dummy(0,0,(WFlags)(WType_Dialog|WShowModal));
2560 tqt_enter_modal(&dummy);
2561 tqApp->enter_loop();
2562 tqt_leave_modal(&dummy);
2564 if (dirs.count() > 0) {
2565 job = TDEIO::chmod( dirs, orDirPermissions, ~andDirPermissions,
2566 owner, group, recursive );
2567 if ( ACLChange && d->fileSystemSupportsACLs )
2568 job->addMetaData(
"ACL_STRING", d->extendedACL.isValid()?d->extendedACL.asString():
"ACL_DELETE" );
2569 if ( defaultACLChange && d->fileSystemSupportsACLs )
2570 job->addMetaData(
"DEFAULT_ACL_STRING", d->defaultACL.isValid()?d->defaultACL.asString():
"ACL_DELETE" );
2572 connect( job, TQ_SIGNAL( result( TDEIO::Job * ) ),
2573 TQ_SLOT( slotChmodResult( TDEIO::Job * ) ) );
2575 TQWidget dummy(0,0,(WFlags)(WType_Dialog|WShowModal));
2576 tqt_enter_modal(&dummy);
2577 tqApp->enter_loop();
2578 tqt_leave_modal(&dummy);
2582 void KFilePermissionsPropsPlugin::slotChmodResult( TDEIO::Job * job )
2584 kdDebug(250) <<
"KFilePermissionsPropsPlugin::slotChmodResult" << endl;
2586 job->showErrorDialog( d->m_frame );
2594 class KURLPropsPlugin::KURLPropsPluginPrivate
2597 KURLPropsPluginPrivate()
2600 ~KURLPropsPluginPrivate()
2610 d =
new KURLPropsPluginPrivate;
2611 d->m_frame =
properties->addPage(i18n(
"U&RL"));
2612 TQVBoxLayout *layout =
new TQVBoxLayout(d->m_frame, 0, KDialog::spacingHint());
2615 l =
new TQLabel( d->m_frame,
"Label_1" );
2616 l->setText( i18n(
"URL:") );
2617 layout->addWidget(l);
2620 layout->addWidget(URLEdit);
2625 if ( !f.open( IO_ReadOnly ) ) {
2630 KSimpleConfig config( path );
2631 config.setDesktopGroup();
2632 URLStr = config.readPathEntry(
"URL" );
2636 if (item && item->mimetype().startsWith(
"media/builtin-")) {
2637 URLEdit->setEnabled(
false);
2640 if ( !URLStr.isNull() ) {
2641 URLEdit->
setURL( URLStr );
2644 connect( URLEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
2645 this, TQ_SIGNAL(
changed() ) );
2647 layout->addStretch (1);
2650 KURLPropsPlugin::~KURLPropsPlugin()
2660 bool KURLPropsPlugin::supports( KFileItemList _items )
2662 if ( _items.count() != 1 )
2664 KFileItem * item = _items.first();
2670 KDesktopFile config( item->url().path(),
true );
2671 return config.hasLinkType();
2679 if (item && item->mimetype().startsWith(
"media/builtin-")) {
2684 if ( !f.open( IO_ReadWrite ) ) {
2685 KMessageBox::sorry( 0, i18n(
"<qt>Could not save properties. You do not have "
2686 "sufficient access to write to <b>%1</b>.</qt>").arg(path));
2691 KSimpleConfig config( path );
2692 config.setDesktopGroup();
2693 config.writeEntry(
"Type", TQString::fromLatin1(
"Link"));
2694 config.writePathEntry(
"URL", URLEdit->
url() );
2697 if ( config.hasKey(
"Name") )
2699 TQString nameStr = nameFromFileName(
properties->
kurl().fileName());
2700 config.writeEntry(
"Name", nameStr );
2701 config.writeEntry(
"Name", nameStr,
true,
false,
true );
2713 class KBindingPropsPlugin::KBindingPropsPluginPrivate
2716 KBindingPropsPluginPrivate()
2719 ~KBindingPropsPluginPrivate()
2728 d =
new KBindingPropsPluginPrivate;
2729 d->m_frame =
properties->addPage(i18n(
"A&ssociation"));
2730 patternEdit =
new KLineEdit( d->m_frame,
"LineEdit_1" );
2731 commentEdit =
new KLineEdit( d->m_frame,
"LineEdit_2" );
2732 mimeEdit =
new KLineEdit( d->m_frame,
"LineEdit_3" );
2734 TQBoxLayout *mainlayout =
new TQVBoxLayout(d->m_frame, 0, KDialog::spacingHint());
2737 tmpQLabel =
new TQLabel( d->m_frame,
"Label_1" );
2738 tmpQLabel->setText( i18n(
"Pattern ( example: *.html;*.htm )") );
2739 tmpQLabel->setMinimumSize(tmpQLabel->sizeHint());
2740 mainlayout->addWidget(tmpQLabel, 1);
2744 patternEdit->setMaxLength( 512 );
2745 patternEdit->setMinimumSize( patternEdit->sizeHint() );
2746 patternEdit->setFixedHeight( fontHeight );
2747 mainlayout->addWidget(patternEdit, 1);
2749 tmpQLabel =
new TQLabel( d->m_frame,
"Label_2" );
2750 tmpQLabel->setText( i18n(
"Mime Type") );
2751 tmpQLabel->setMinimumSize(tmpQLabel->sizeHint());
2752 mainlayout->addWidget(tmpQLabel, 1);
2755 mimeEdit->setMaxLength( 256 );
2756 mimeEdit->setMinimumSize( mimeEdit->sizeHint() );
2757 mimeEdit->setFixedHeight( fontHeight );
2758 mainlayout->addWidget(mimeEdit, 1);
2760 tmpQLabel =
new TQLabel( d->m_frame,
"Label_3" );
2761 tmpQLabel->setText( i18n(
"Comment") );
2762 tmpQLabel->setMinimumSize(tmpQLabel->sizeHint());
2763 mainlayout->addWidget(tmpQLabel, 1);
2766 commentEdit->setMaxLength( 256 );
2767 commentEdit->setMinimumSize( commentEdit->sizeHint() );
2768 commentEdit->setFixedHeight( fontHeight );
2769 mainlayout->addWidget(commentEdit, 1);
2771 cbAutoEmbed =
new TQCheckBox( i18n(
"Left click previews"), d->m_frame,
"cbAutoEmbed" );
2772 mainlayout->addWidget(cbAutoEmbed, 1);
2774 mainlayout->addStretch (10);
2775 mainlayout->activate();
2777 TQFile f( _props->
kurl().path() );
2778 if ( !f.open( IO_ReadOnly ) )
2782 KSimpleConfig config( _props->
kurl().path() );
2783 config.setDesktopGroup();
2784 TQString patternStr = config.readEntry(
"Patterns" );
2785 TQString iconStr = config.readEntry(
"Icon" );
2786 TQString commentStr = config.readEntry(
"Comment" );
2787 m_sMimeStr = config.readEntry(
"MimeType" );
2789 if ( !patternStr.isEmpty() )
2790 patternEdit->setText( patternStr );
2791 if ( !commentStr.isEmpty() )
2792 commentEdit->setText( commentStr );
2793 if ( !m_sMimeStr.isEmpty() )
2794 mimeEdit->setText( m_sMimeStr );
2795 cbAutoEmbed->setTristate();
2796 if ( config.hasKey(
"X-TDE-AutoEmbed" ) )
2797 cbAutoEmbed->setChecked( config.readBoolEntry(
"X-TDE-AutoEmbed" ) );
2799 cbAutoEmbed->setNoChange();
2801 connect( patternEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
2802 this, TQ_SIGNAL(
changed() ) );
2803 connect( commentEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
2804 this, TQ_SIGNAL(
changed() ) );
2805 connect( mimeEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
2806 this, TQ_SIGNAL(
changed() ) );
2807 connect( cbAutoEmbed, TQ_SIGNAL( toggled(
bool ) ),
2808 this, TQ_SIGNAL(
changed() ) );
2811 KBindingPropsPlugin::~KBindingPropsPlugin()
2821 bool KBindingPropsPlugin::supports( KFileItemList _items )
2823 if ( _items.count() != 1 )
2825 KFileItem * item = _items.first();
2831 KDesktopFile config( item->url().path(),
true );
2832 return config.hasMimeTypeType();
2840 if ( !f.open( IO_ReadWrite ) )
2842 KMessageBox::sorry( 0, i18n(
"<qt>Could not save properties. You do not have "
2843 "sufficient access to write to <b>%1</b>.</qt>").arg(path));
2848 KSimpleConfig config( path );
2849 config.setDesktopGroup();
2850 config.writeEntry(
"Type", TQString::fromLatin1(
"MimeType") );
2852 config.writeEntry(
"Patterns", patternEdit->text() );
2853 config.writeEntry(
"Comment", commentEdit->text() );
2854 config.writeEntry(
"Comment",
2855 commentEdit->text(),
true,
false,
true );
2856 config.writeEntry(
"MimeType", mimeEdit->text() );
2857 if ( cbAutoEmbed->state() == TQButton::NoChange )
2858 config.deleteEntry(
"X-TDE-AutoEmbed",
false );
2860 config.writeEntry(
"X-TDE-AutoEmbed", cbAutoEmbed->isChecked() );
2870 class KDevicePropsPlugin::KDevicePropsPluginPrivate
2873 KDevicePropsPluginPrivate()
2876 ~KDevicePropsPluginPrivate()
2881 TQStringList mountpointlist;
2882 TQLabel *m_freeSpaceText;
2883 TQLabel *m_freeSpaceLabel;
2884 TQProgressBar *m_freeSpaceBar;
2889 d =
new KDevicePropsPluginPrivate;
2890 d->m_frame =
properties->addPage(i18n(
"De&vice"));
2892 TQStringList devices;
2893 KMountPoint::List mountPoints = KMountPoint::possibleMountPoints();
2895 for(KMountPoint::List::ConstIterator it = mountPoints.begin();
2896 it != mountPoints.end(); ++it)
2898 KMountPoint *mp = *it;
2899 TQString mountPoint = mp->mountPoint();
2900 TQString device = mp->mountedFrom();
2901 kdDebug()<<
"mountPoint :"<<mountPoint<<
" device :"<<device<<
" mp->mountType() :"<<mp->mountType()<<endl;
2903 if ((mountPoint !=
"-") && (mountPoint !=
"none") && !mountPoint.isEmpty()
2904 && device !=
"none")
2906 devices.append( device + TQString::fromLatin1(
" (")
2907 + mountPoint + TQString::fromLatin1(
")") );
2908 m_devicelist.append(device);
2909 d->mountpointlist.append(mountPoint);
2913 TQGridLayout *layout =
new TQGridLayout( d->m_frame, 0, 2, 0,
2914 KDialog::spacingHint());
2915 layout->setColStretch(1, 1);
2918 label =
new TQLabel( d->m_frame );
2919 label->setText( devices.count() == 0 ?
2920 i18n(
"Device (/dev/fd0):") :
2922 layout->addWidget(label, 0, 0);
2924 device =
new TQComboBox(
true, d->m_frame,
"ComboBox_device" );
2925 device->insertStringList( devices );
2926 layout->addWidget(device, 0, 1);
2927 connect( device, TQ_SIGNAL( activated(
int ) ),
2928 this, TQ_SLOT( slotActivated(
int ) ) );
2930 readonly =
new TQCheckBox( d->m_frame,
"CheckBox_readonly" );
2931 readonly->setText( i18n(
"Read only") );
2932 layout->addWidget(readonly, 1, 1);
2934 label =
new TQLabel( d->m_frame );
2935 label->setText( i18n(
"File system:") );
2936 layout->addWidget(label, 2, 0);
2938 TQLabel *fileSystem =
new TQLabel( d->m_frame );
2939 layout->addWidget(fileSystem, 2, 1);
2941 label =
new TQLabel( d->m_frame );
2942 label->setText( devices.count()==0 ?
2943 i18n(
"Mount point (/mnt/floppy):") :
2944 i18n(
"Mount point:"));
2945 layout->addWidget(label, 3, 0);
2947 mountpoint =
new TQLabel( d->m_frame,
"LineEdit_mountpoint" );
2949 layout->addWidget(mountpoint, 3, 1);
2952 d->m_freeSpaceText =
new TQLabel(i18n(
"Free disk space:"), d->m_frame );
2953 layout->addWidget(d->m_freeSpaceText, 4, 0);
2955 d->m_freeSpaceLabel =
new TQLabel( d->m_frame );
2956 layout->addWidget( d->m_freeSpaceLabel, 4, 1 );
2958 d->m_freeSpaceBar =
new TQProgressBar( d->m_frame,
"freeSpaceBar" );
2959 layout->addMultiCellWidget(d->m_freeSpaceBar, 5, 5, 0, 1);
2962 d->m_freeSpaceText->hide();
2963 d->m_freeSpaceLabel->hide();
2964 d->m_freeSpaceBar->hide();
2966 KSeparator* sep =
new KSeparator( KSeparator::HLine, d->m_frame);
2967 layout->addMultiCellWidget(sep, 6, 6, 0, 1);
2970 int bsize = 66 + 2 * unmounted->style().pixelMetric(TQStyle::PM_ButtonMargin);
2971 unmounted->setFixedSize(bsize, bsize);
2972 unmounted->setIconType(TDEIcon::Desktop, TDEIcon::Device);
2973 layout->addWidget(unmounted, 7, 0);
2975 label =
new TQLabel( i18n(
"Unmounted Icon"), d->m_frame );
2976 layout->addWidget(label, 7, 1);
2978 layout->setRowStretch(8, 1);
2980 TQString path( _props->
kurl().path() );
2983 if ( !f.open( IO_ReadOnly ) )
2987 KSimpleConfig config( path );
2988 config.setDesktopGroup();
2989 TQString deviceStr = config.readEntry(
"Dev" );
2990 TQString mountPointStr = config.readEntry(
"MountPoint" );
2991 bool ro = config.readBoolEntry(
"ReadOnly",
false );
2992 TQString unmountedStr = config.readEntry(
"UnmountIcon" );
2994 TQString fsType = config.readEntry(
"FSType");
2995 fileSystem->setText( (fsType.stripWhiteSpace() !=
"") ? i18n(fsType.local8Bit()) :
"" );
2997 device->setEditText( deviceStr );
2998 if ( !deviceStr.isEmpty() ) {
3000 int index = m_devicelist.findIndex(deviceStr);
3004 slotActivated( index );
3008 if ( !mountPointStr.isEmpty() )
3010 mountpoint->setText( mountPointStr );
3014 readonly->setChecked( ro );
3016 if ( unmountedStr.isEmpty() )
3017 unmountedStr = KMimeType::defaultMimeTypePtr()->KServiceType::icon();
3019 unmounted->setIcon( unmountedStr );
3021 connect( device, TQ_SIGNAL( activated(
int ) ),
3022 this, TQ_SIGNAL(
changed() ) );
3023 connect( device, TQ_SIGNAL( textChanged(
const TQString & ) ),
3024 this, TQ_SIGNAL(
changed() ) );
3025 connect( readonly, TQ_SIGNAL( toggled(
bool ) ),
3026 this, TQ_SIGNAL(
changed() ) );
3027 connect( unmounted, TQ_SIGNAL( iconChanged( TQString ) ),
3028 this, TQ_SIGNAL(
changed() ) );
3030 connect( device, TQ_SIGNAL( textChanged(
const TQString & ) ),
3031 this, TQ_SLOT( slotDeviceChanged() ) );
3036 KDevicePropsPlugin::~KDevicePropsPlugin()
3046 void KDevicePropsPlugin::processLockouts()
3048 if (device->currentText().stripWhiteSpace() !=
"")
3058 void KDevicePropsPlugin::updateInfo()
3061 d->m_freeSpaceText->hide();
3062 d->m_freeSpaceLabel->hide();
3063 d->m_freeSpaceBar->hide();
3065 if ( !mountpoint->text().isEmpty() )
3068 connect( job, TQ_SIGNAL( foundMountPoint(
const unsigned long&,
const unsigned long&,
3069 const unsigned long&,
const TQString& ) ),
3070 this, TQ_SLOT( slotFoundMountPoint(
const unsigned long&,
const unsigned long&,
3071 const unsigned long&,
const TQString& ) ) );
3073 job->
readDF( mountpoint->text() );
3079 void KDevicePropsPlugin::slotActivated(
int index )
3082 device->setEditText( m_devicelist[index] );
3083 mountpoint->setText( d->mountpointlist[index] );
3088 void KDevicePropsPlugin::slotDeviceChanged()
3091 int index = m_devicelist.findIndex( device->currentText() );
3093 mountpoint->setText( d->mountpointlist[index] );
3095 mountpoint->setText( TQString::null );
3100 void KDevicePropsPlugin::slotFoundMountPoint(
const unsigned long& kBSize,
3101 const unsigned long& ,
3102 const unsigned long& kBAvail,
3105 d->m_freeSpaceText->show();
3106 d->m_freeSpaceLabel->show();
3108 int percUsed = 100 - (int)(100.0 * kBAvail / kBSize);
3110 d->m_freeSpaceLabel->setText(
3112 i18n(
"Available space out of total partition size (percent used)",
"%1 out of %2 (%3% used)")
3113 .arg(TDEIO::convertSizeFromKB(kBAvail))
3114 .arg(TDEIO::convertSizeFromKB(kBSize))
3115 .arg( 100 - (
int)(100.0 * kBAvail / kBSize) ));
3117 d->m_freeSpaceBar->setProgress(percUsed, 100);
3118 d->m_freeSpaceBar->show();
3121 bool KDevicePropsPlugin::supports( KFileItemList _items )
3123 if ( _items.count() != 1 )
3125 KFileItem * item = _items.first();
3130 KDesktopFile config( item->url().path(),
true );
3131 return config.hasDeviceType();
3138 if ( !f.open( IO_ReadWrite ) )
3140 KMessageBox::sorry( 0, i18n(
"<qt>Could not save properties. You do not have sufficient "
3141 "access to write to <b>%1</b>.</qt>").arg(path));
3146 KSimpleConfig config( path );
3147 config.setDesktopGroup();
3148 config.writeEntry(
"Type", TQString::fromLatin1(
"FSDevice") );
3150 config.writeEntry(
"Dev", device->currentText() );
3151 config.writeEntry(
"MountPoint", mountpoint->text() );
3153 config.writeEntry(
"UnmountIcon", unmounted->
icon() );
3154 kdDebug(250) <<
"unmounted->icon() = " << unmounted->
icon() << endl;
3156 config.writeEntry(
"ReadOnly", readonly->isChecked() );
3172 TQFrame *frame =
properties->addPage(i18n(
"&Application"));
3173 TQVBoxLayout *mainlayout =
new TQVBoxLayout( frame, 0, KDialog::spacingHint() );
3175 w =
new KPropertiesDesktopBase(frame);
3176 mainlayout->addWidget(w);
3178 bool bKDesktopMode = (TQCString(tqApp->name()) ==
"kdesktop");
3183 w->nameEdit->hide();
3184 w->nameLabel->hide();
3187 w->pathEdit->setMode(KFile::Directory | KFile::LocalOnly);
3188 w->pathEdit->lineEdit()->setAcceptDrops(
false);
3190 connect( w->nameEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
this, TQ_SIGNAL(
changed() ) );
3191 connect( w->genNameEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
this, TQ_SIGNAL(
changed() ) );
3192 connect( w->commentEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
this, TQ_SIGNAL(
changed() ) );
3193 connect( w->commandEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
this, TQ_SIGNAL(
changed() ) );
3194 connect( w->pathEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
this, TQ_SIGNAL(
changed() ) );
3196 connect( w->browseButton, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotBrowseExec() ) );
3197 connect( w->addFiletypeButton, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotAddFiletype() ) );
3198 connect( w->delFiletypeButton, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotDelFiletype() ) );
3199 connect( w->advancedButton, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotAdvanced() ) );
3202 TQString path = _props->
kurl().path();
3204 if ( !f.open( IO_ReadOnly ) )
3208 KDesktopFile config( path );
3209 TQString nameStr = config.readName();
3210 TQString genNameStr = config.readGenericName();
3211 TQString commentStr = config.readComment();
3212 TQString commandStr = config.readPathEntry(
"Exec" );
3213 if (commandStr.left(12) ==
"ksystraycmd ")
3215 commandStr.remove(0, 12);
3216 m_systrayBool =
true;
3219 m_systrayBool =
false;
3221 m_origCommandStr = commandStr;
3222 TQString pathStr = config.readPathEntry(
"Path" );
3223 m_terminalBool = config.readBoolEntry(
"Terminal" );
3224 m_terminalOptionStr = config.readEntry(
"TerminalOptions" );
3225 m_suidBool = config.readBoolEntry(
"X-TDE-SubstituteUID" ) || config.readBoolEntry(
"X-KDE-SubstituteUID" );
3226 if( config.hasKey(
"X-TDE-Username" ))
3227 m_suidUserStr = config.readEntry(
"X-TDE-Username" );
3229 m_suidUserStr = config.readEntry(
"X-KDE-Username" );
3230 if( config.hasKey(
"StartupNotify" ))
3231 m_startupBool = config.readBoolEntry(
"StartupNotify",
true );
3233 m_startupBool = config.readBoolEntry(
"X-TDE-StartupNotify",
true );
3234 m_dcopServiceType = config.readEntry(
"X-DCOP-ServiceType").lower();
3236 TQStringList mimeTypes = config.readListEntry(
"MimeType",
';' );
3238 if ( nameStr.isEmpty() || bKDesktopMode ) {
3244 if ( !bKDesktopMode )
3245 w->nameEdit->setText(nameStr);
3247 w->genNameEdit->setText( genNameStr );
3248 w->commentEdit->setText( commentStr );
3249 w->commandEdit->setText( commandStr );
3250 w->pathEdit->lineEdit()->setText( pathStr );
3251 w->filetypeList->setAllColumnsShowFocus(
true);
3253 KMimeType::Ptr defaultMimetype = KMimeType::defaultMimeTypePtr();
3254 for(TQStringList::ConstIterator it = mimeTypes.begin();
3255 it != mimeTypes.end(); )
3257 KMimeType::Ptr p = KMimeType::mimeType(*it);
3259 TQString preference;
3260 if (it != mimeTypes.end())
3263 (*it).toInt(&numeric);
3270 if (p && (p != defaultMimetype))
3272 new TQListViewItem(w->filetypeList, p->name(), p->comment(), preference);
3278 KDesktopPropsPlugin::~KDesktopPropsPlugin()
3282 void KDesktopPropsPlugin::slotSelectMimetype()
3284 TQListView *w = (TQListView*)sender();
3285 TQListViewItem *item = w->firstChild();
3288 if (item->isSelected())
3289 w->setSelected(item,
false);
3290 item = item->nextSibling();
3294 void KDesktopPropsPlugin::slotAddFiletype()
3296 KDialogBase dlg(w,
"KPropertiesMimetypes",
true,
3298 KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok);
3300 KGuiItem okItem(i18n(
"&Add"), TQString::null ,
3301 i18n(
"Add the selected file types to\nthe list of supported file types."),
3302 i18n(
"Add the selected file types to\nthe list of supported file types."));
3303 dlg.setButtonOK(okItem);
3305 KPropertiesMimetypeBase *mw =
new KPropertiesMimetypeBase(&dlg);
3307 dlg.setMainWidget(mw);
3310 mw->listView->setRootIsDecorated(
true);
3311 mw->listView->setSelectionMode(TQListView::Extended);
3312 mw->listView->setAllColumnsShowFocus(
true);
3313 mw->listView->setFullWidth(
true);
3314 mw->listView->setMinimumSize(500,400);
3316 connect(mw->listView, TQ_SIGNAL(selectionChanged()),
3317 this, TQ_SLOT(slotSelectMimetype()));
3318 connect(mw->listView, TQ_SIGNAL(doubleClicked( TQListViewItem *,
const TQPoint &,
int )),
3319 &dlg, TQ_SLOT( slotOk()));
3321 TQMap<TQString,TQListViewItem*> majorMap;
3322 TQListViewItem *majorGroup;
3323 KMimeType::List mimetypes = KMimeType::allMimeTypes();
3324 TQValueListIterator<KMimeType::Ptr> it(mimetypes.begin());
3325 for (; it != mimetypes.end(); ++it) {
3326 TQString mimetype = (*it)->name();
3327 if (mimetype == KMimeType::defaultMimeType())
3329 int index = mimetype.find(
"/");
3330 TQString maj = mimetype.left(index);
3331 TQString min = mimetype.mid(index+1);
3333 TQMapIterator<TQString,TQListViewItem*> mit = majorMap.find( maj );
3334 if ( mit == majorMap.end() ) {
3335 majorGroup =
new TQListViewItem( mw->listView, maj );
3336 majorGroup->setExpandable(
true);
3337 mw->listView->setOpen(majorGroup,
true);
3338 majorMap.insert( maj, majorGroup );
3342 majorGroup = mit.data();
3345 TQListViewItem *item =
new TQListViewItem(majorGroup, min, (*it)->comment());
3346 item->setPixmap(0, (*it)->pixmap(TDEIcon::Small, IconSize(TDEIcon::Small)));
3348 TQMapIterator<TQString,TQListViewItem*> mit = majorMap.find(
"all" );
3349 if ( mit != majorMap.end())
3351 mw->listView->setCurrentItem(mit.data());
3352 mw->listView->ensureItemVisible(mit.data());
3356 if (dlg.exec() == KDialogBase::Accepted)
3358 KMimeType::Ptr defaultMimetype = KMimeType::defaultMimeTypePtr();
3359 TQListViewItem *majorItem = mw->listView->firstChild();
3362 TQString major = majorItem->text(0);
3364 TQListViewItem *minorItem = majorItem->firstChild();
3367 if (minorItem->isSelected())
3369 TQString mimetype = major +
"/" + minorItem->text(0);
3370 KMimeType::Ptr p = KMimeType::mimeType(mimetype);
3371 if (p && (p != defaultMimetype))
3373 mimetype = p->name();
3375 TQListViewItem *item = w->filetypeList->firstChild();
3378 if (mimetype == item->text(0))
3383 item = item->nextSibling();
3386 new TQListViewItem(w->filetypeList, p->name(), p->comment());
3391 minorItem = minorItem->nextSibling();
3394 majorItem = majorItem->nextSibling();
3400 void KDesktopPropsPlugin::slotDelFiletype()
3402 delete w->filetypeList->currentItem();
3406 void KDesktopPropsPlugin::checkCommandChanged()
3408 if (KRun::binaryName(w->commandEdit->text(),
true) !=
3409 KRun::binaryName(m_origCommandStr,
true))
3411 TQString m_origCommandStr = w->commandEdit->text();
3412 m_dcopServiceType= TQString::null;
3418 kdDebug(250) <<
"KDesktopPropsPlugin::applyChanges" << endl;
3423 if ( !f.open( IO_ReadWrite ) ) {
3424 KMessageBox::sorry( 0, i18n(
"<qt>Could not save properties. You do not have "
3425 "sufficient access to write to <b>%1</b>.</qt>").arg(path));
3432 checkCommandChanged();
3434 KSimpleConfig config( path );
3435 config.setDesktopGroup();
3436 config.writeEntry(
"Type", TQString::fromLatin1(
"Application"));
3437 config.writeEntry(
"Comment", w->commentEdit->text() );
3438 config.writeEntry(
"Comment", w->commentEdit->text(),
true,
false,
true );
3439 config.writeEntry(
"GenericName", w->genNameEdit->text() );
3440 config.writeEntry(
"GenericName", w->genNameEdit->text(),
true,
false,
true );
3443 config.writePathEntry(
"Exec", w->commandEdit->text().prepend(
"ksystraycmd ") );
3445 config.writePathEntry(
"Exec", w->commandEdit->text() );
3446 config.writePathEntry(
"Path", w->pathEdit->lineEdit()->text() );
3449 TQStringList mimeTypes;
3450 for( TQListViewItem *item = w->filetypeList->firstChild();
3451 item; item = item->nextSibling() )
3453 TQString preference = item->text(2);
3454 mimeTypes.append(item->text(0));
3455 if (!preference.isEmpty())
3456 mimeTypes.append(preference);
3459 config.writeEntry(
"MimeType", mimeTypes,
';' );
3461 if ( !w->nameEdit->isHidden() ) {
3462 TQString nameStr = w->nameEdit->text();
3463 config.writeEntry(
"Name", nameStr );
3464 config.writeEntry(
"Name", nameStr,
true,
false,
true );
3467 config.writeEntry(
"Terminal", m_terminalBool);
3468 config.writeEntry(
"TerminalOptions", m_terminalOptionStr);
3469 config.writeEntry(
"X-TDE-SubstituteUID", m_suidBool);
3470 config.writeEntry(
"X-TDE-Username", m_suidUserStr);
3471 config.writeEntry(
"StartupNotify", m_startupBool);
3472 config.writeEntry(
"X-DCOP-ServiceType", m_dcopServiceType);
3476 TQString sycocaPath = TDEGlobal::dirs()->relativeLocation(
"apps", path);
3477 bool updateNeeded = !sycocaPath.startsWith(
"/");
3480 sycocaPath = TDEGlobal::dirs()->relativeLocation(
"xdgdata-apps", path);
3481 updateNeeded = !sycocaPath.startsWith(
"/");
3484 KService::rebuildKSycoca(w);
3488 void KDesktopPropsPlugin::slotBrowseExec()
3491 TQString::null, w );
3495 if ( !f.isLocalFile()) {
3496 KMessageBox::sorry(w, i18n(
"Only executables on local file systems are supported."));
3500 TQString path = f.path();
3501 KRun::shellQuote( path );
3502 w->commandEdit->setText( path );
3505 void KDesktopPropsPlugin::slotAdvanced()
3507 KDialogBase dlg(w,
"KPropertiesDesktopAdv",
true,
3508 i18n(
"Advanced Options for %1").arg(
properties->
kurl().fileName()),
3509 KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok);
3510 KPropertiesDesktopAdvBase *w =
new KPropertiesDesktopAdvBase(&dlg);
3512 dlg.setMainWidget(w);
3516 checkCommandChanged();
3520 TDEConfigGroup confGroup( TDEGlobal::config(), TQString::fromLatin1(
"General") );
3521 TQString preferredTerminal = confGroup.readPathEntry(
"TerminalApplication",
3522 TQString::fromLatin1(
"konsole"));
3524 bool terminalCloseBool =
false;
3526 if (preferredTerminal ==
"konsole")
3528 terminalCloseBool = (m_terminalOptionStr.contains(
"--noclose" ) > 0);
3529 w->terminalCloseCheck->setChecked(terminalCloseBool);
3530 m_terminalOptionStr.replace(
"--noclose",
"");
3534 w->terminalCloseCheck->hide();
3537 w->terminalCheck->setChecked(m_terminalBool);
3538 w->terminalEdit->setText(m_terminalOptionStr);
3539 w->terminalCloseCheck->setEnabled(m_terminalBool);
3540 w->terminalEdit->setEnabled(m_terminalBool);
3541 w->terminalEditLabel->setEnabled(m_terminalBool);
3543 w->suidCheck->setChecked(m_suidBool);
3544 w->suidEdit->setText(m_suidUserStr);
3545 w->suidEdit->setEnabled(m_suidBool);
3546 w->suidEditLabel->setEnabled(m_suidBool);
3548 w->startupInfoCheck->setChecked(m_startupBool);
3549 w->systrayCheck->setChecked(m_systrayBool);
3551 if (m_dcopServiceType ==
"unique")
3552 w->dcopCombo->setCurrentItem(2);
3553 else if (m_dcopServiceType ==
"multi")
3554 w->dcopCombo->setCurrentItem(1);
3555 else if (m_dcopServiceType ==
"wait")
3556 w->dcopCombo->setCurrentItem(3);
3558 w->dcopCombo->setCurrentItem(0);
3561 TDECompletion *kcom =
new TDECompletion;
3562 kcom->setOrder(TDECompletion::Sorted);
3564 int i, maxEntries = 1000;
3566 for (i=0; ((pw = getpwent()) != 0L) && (i < maxEntries); i++)
3567 kcom->addItem(TQString::fromLatin1(pw->pw_name));
3571 w->suidEdit->setCompletionObject(kcom,
true);
3572 w->suidEdit->setAutoDeleteCompletionObject(
true );
3573 w->suidEdit->setCompletionMode(TDEGlobalSettings::CompletionAuto);
3580 connect( w->terminalEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
3581 this, TQ_SIGNAL(
changed() ) );
3582 connect( w->terminalCloseCheck, TQ_SIGNAL( toggled(
bool ) ),
3583 this, TQ_SIGNAL(
changed() ) );
3584 connect( w->terminalCheck, TQ_SIGNAL( toggled(
bool ) ),
3585 this, TQ_SIGNAL(
changed() ) );
3586 connect( w->suidCheck, TQ_SIGNAL( toggled(
bool ) ),
3587 this, TQ_SIGNAL(
changed() ) );
3588 connect( w->suidEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
3589 this, TQ_SIGNAL(
changed() ) );
3590 connect( w->startupInfoCheck, TQ_SIGNAL( toggled(
bool ) ),
3591 this, TQ_SIGNAL(
changed() ) );
3592 connect( w->systrayCheck, TQ_SIGNAL( toggled(
bool ) ),
3593 this, TQ_SIGNAL(
changed() ) );
3594 connect( w->dcopCombo, TQ_SIGNAL( highlighted(
int ) ),
3595 this, TQ_SIGNAL(
changed() ) );
3597 if ( dlg.exec() == TQDialog::Accepted )
3599 m_terminalOptionStr = w->terminalEdit->text().stripWhiteSpace();
3600 m_terminalBool = w->terminalCheck->isChecked();
3601 m_suidBool = w->suidCheck->isChecked();
3602 m_suidUserStr = w->suidEdit->text().stripWhiteSpace();
3603 m_startupBool = w->startupInfoCheck->isChecked();
3604 m_systrayBool = w->systrayCheck->isChecked();
3606 if (w->terminalCloseCheck->isChecked())
3608 m_terminalOptionStr.append(
" --noclose");
3611 switch(w->dcopCombo->currentItem())
3613 case 1: m_dcopServiceType =
"multi";
break;
3614 case 2: m_dcopServiceType =
"unique";
break;
3615 case 3: m_dcopServiceType =
"wait";
break;
3616 default: m_dcopServiceType =
"none";
break;
3621 bool KDesktopPropsPlugin::supports( KFileItemList _items )
3623 if ( _items.count() != 1 )
3625 KFileItem * item = _items.first();
3630 KDesktopFile config( item->url().path(),
true );
3631 return config.hasApplicationType() && kapp->authorize(
"run_desktop_files") && kapp->authorize(
"shell_access");
3634 void KPropertiesDialog::virtual_hook(
int id,
void* data )
3635 { KDialogBase::virtual_hook(
id, data ); }
3637 void KPropsDlgPlugin::virtual_hook(
int,
void* )
3649 class KExecPropsPlugin::KExecPropsPluginPrivate
3652 KExecPropsPluginPrivate()
3655 ~KExecPropsPluginPrivate()
3660 TQCheckBox *nocloseonexitCheck;
3666 d =
new KExecPropsPluginPrivate;
3667 d->m_frame =
properties->addPage(i18n(
"E&xecute"));
3668 TQVBoxLayout * mainlayout =
new TQVBoxLayout( d->m_frame, 0,
3669 KDialog::spacingHint());
3674 l =
new TQLabel( i18n(
"Comman&d:" ), d->m_frame );
3675 mainlayout->addWidget(l);
3677 TQHBoxLayout * hlayout;
3678 hlayout =
new TQHBoxLayout(KDialog::spacingHint());
3679 mainlayout->addLayout(hlayout);
3681 execEdit =
new KLineEdit( d->m_frame );
3682 TQWhatsThis::add(execEdit,i18n(
3683 "Following the command, you can have several place holders which will be replaced "
3684 "with the actual values when the actual program is run:\n"
3685 "%f - a single file name\n"
3686 "%F - a list of files; use for applications that can open several local files at once\n"
3687 "%u - a single URL\n"
3688 "%U - a list of URLs\n"
3689 "%d - the folder of the file to open\n"
3690 "%D - a list of folders\n"
3692 "%m - the mini-icon\n"
3693 "%c - the caption"));
3694 hlayout->addWidget(execEdit, 1);
3696 l->setBuddy( execEdit );
3698 execBrowse =
new TQPushButton( d->m_frame );
3699 execBrowse->setText( i18n(
"&Browse...") );
3700 hlayout->addWidget(execBrowse);
3703 TQGroupBox* tmpQGroupBox;
3704 tmpQGroupBox =
new TQGroupBox( i18n(
"Panel Embedding"), d->m_frame );
3705 tmpQGroupBox->setColumnLayout( 0, TQt::Horizontal );
3707 mainlayout->addWidget(tmpQGroupBox);
3709 TQGridLayout *grid =
new TQGridLayout(tmpQGroupBox->layout(), 2, 2);
3710 grid->setSpacing( KDialog::spacingHint() );
3711 grid->setColStretch(1, 1);
3713 l =
new TQLabel( i18n(
"&Execute on click:" ), tmpQGroupBox );
3714 grid->addWidget(l, 0, 0);
3716 swallowExecEdit =
new KLineEdit( tmpQGroupBox );
3717 grid->addWidget(swallowExecEdit, 0, 1);
3719 l->setBuddy( swallowExecEdit );
3721 l =
new TQLabel( i18n(
"&Window title:" ), tmpQGroupBox );
3722 grid->addWidget(l, 1, 0);
3724 swallowTitleEdit =
new KLineEdit( tmpQGroupBox );
3725 grid->addWidget(swallowTitleEdit, 1, 1);
3727 l->setBuddy( swallowTitleEdit );
3731 tmpQGroupBox =
new TQGroupBox( d->m_frame );
3732 tmpQGroupBox->setColumnLayout( 0, TQt::Horizontal );
3734 mainlayout->addWidget(tmpQGroupBox);
3736 grid =
new TQGridLayout(tmpQGroupBox->layout(), 3, 2);
3737 grid->setSpacing( KDialog::spacingHint() );
3738 grid->setColStretch(1, 1);
3740 terminalCheck =
new TQCheckBox( tmpQGroupBox );
3741 terminalCheck->setText( i18n(
"&Run in terminal") );
3742 grid->addMultiCellWidget(terminalCheck, 0, 0, 0, 1);
3746 TDEConfigGroup confGroup( TDEGlobal::config(), TQString::fromLatin1(
"General") );
3747 TQString preferredTerminal = confGroup.readPathEntry(
"TerminalApplication",
3748 TQString::fromLatin1(
"konsole"));
3751 d->nocloseonexitCheck = 0L;
3752 if (preferredTerminal ==
"konsole")
3755 d->nocloseonexitCheck =
new TQCheckBox( tmpQGroupBox );
3756 d->nocloseonexitCheck->setText( i18n(
"Do not &close when command exits") );
3757 grid->addMultiCellWidget(d->nocloseonexitCheck, 1, 1, 0, 1);
3760 terminalLabel =
new TQLabel( i18n(
"&Terminal options:" ), tmpQGroupBox );
3761 grid->addWidget(terminalLabel, posOptions, 0);
3763 terminalEdit =
new KLineEdit( tmpQGroupBox );
3764 grid->addWidget(terminalEdit, posOptions, 1);
3766 terminalLabel->setBuddy( terminalEdit );
3770 tmpQGroupBox =
new TQGroupBox( d->m_frame );
3771 tmpQGroupBox->setColumnLayout( 0, TQt::Horizontal );
3773 mainlayout->addWidget(tmpQGroupBox);
3775 grid =
new TQGridLayout(tmpQGroupBox->layout(), 2, 2);
3776 grid->setSpacing(KDialog::spacingHint());
3777 grid->setColStretch(1, 1);
3779 suidCheck =
new TQCheckBox(tmpQGroupBox);
3780 suidCheck->setText(i18n(
"Ru&n as a different user"));
3781 grid->addMultiCellWidget(suidCheck, 0, 0, 0, 1);
3783 suidLabel =
new TQLabel(i18n(
"&Username:" ), tmpQGroupBox);
3784 grid->addWidget(suidLabel, 1, 0);
3786 suidEdit =
new KLineEdit(tmpQGroupBox);
3787 grid->addWidget(suidEdit, 1, 1);
3789 suidLabel->setBuddy( suidEdit );
3791 mainlayout->addStretch(1);
3794 TQString path = _props->
kurl().path();
3796 if ( !f.open( IO_ReadOnly ) )
3800 KSimpleConfig config( path );
3801 config.setDollarExpansion(
false );
3802 config.setDesktopGroup();
3803 execStr = config.readPathEntry(
"Exec" );
3804 swallowExecStr = config.readPathEntry(
"SwallowExec" );
3805 swallowTitleStr = config.readEntry(
"SwallowTitle" );
3806 termBool = config.readBoolEntry(
"Terminal" );
3807 termOptionsStr = config.readEntry(
"TerminalOptions" );
3808 suidBool = config.readBoolEntry(
"X-TDE-SubstituteUID" );
3809 suidUserStr = config.readEntry(
"X-TDE-Username" );
3811 if ( !swallowExecStr.isNull() )
3812 swallowExecEdit->setText( swallowExecStr );
3813 if ( !swallowTitleStr.isNull() )
3814 swallowTitleEdit->setText( swallowTitleStr );
3816 if ( !execStr.isNull() )
3817 execEdit->setText( execStr );
3819 if ( d->nocloseonexitCheck )
3821 d->nocloseonexitCheck->setChecked( (termOptionsStr.contains(
"--noclose" ) > 0) );
3822 termOptionsStr.replace(
"--noclose",
"");
3824 if ( !termOptionsStr.isNull() )
3825 terminalEdit->setText( termOptionsStr );
3827 terminalCheck->setChecked( termBool );
3828 enableCheckedEdit();
3830 suidCheck->setChecked( suidBool );
3831 suidEdit->setText( suidUserStr );
3835 TDECompletion *kcom =
new TDECompletion;
3836 kcom->setOrder(TDECompletion::Sorted);
3838 int i, maxEntries = 1000;
3840 for (i=0; ((pw = getpwent()) != 0L) && (i < maxEntries); i++)
3841 kcom->addItem(TQString::fromLatin1(pw->pw_name));
3845 suidEdit->setCompletionObject(kcom,
true);
3846 suidEdit->setAutoDeleteCompletionObject(
true );
3847 suidEdit->setCompletionMode(TDEGlobalSettings::CompletionAuto);
3854 connect( swallowExecEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
3855 this, TQ_SIGNAL(
changed() ) );
3856 connect( swallowTitleEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
3857 this, TQ_SIGNAL(
changed() ) );
3858 connect( execEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
3859 this, TQ_SIGNAL(
changed() ) );
3860 connect( terminalEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
3861 this, TQ_SIGNAL(
changed() ) );
3862 if (d->nocloseonexitCheck)
3863 connect( d->nocloseonexitCheck, TQ_SIGNAL( toggled(
bool ) ),
3864 this, TQ_SIGNAL(
changed() ) );
3865 connect( terminalCheck, TQ_SIGNAL( toggled(
bool ) ),
3866 this, TQ_SIGNAL(
changed() ) );
3867 connect( suidCheck, TQ_SIGNAL( toggled(
bool ) ),
3868 this, TQ_SIGNAL(
changed() ) );
3869 connect( suidEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
3870 this, TQ_SIGNAL(
changed() ) );
3872 connect( execBrowse, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotBrowseExec() ) );
3873 connect( terminalCheck, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( enableCheckedEdit() ) );
3874 connect( suidCheck, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( enableSuidEdit() ) );
3878 KExecPropsPlugin::~KExecPropsPlugin()
3883 void KExecPropsPlugin::enableCheckedEdit()
3885 bool checked = terminalCheck->isChecked();
3886 terminalLabel->setEnabled( checked );
3887 if (d->nocloseonexitCheck)
3888 d->nocloseonexitCheck->setEnabled( checked );
3889 terminalEdit->setEnabled( checked );
3892 void KExecPropsPlugin::enableSuidEdit()
3894 bool checked = suidCheck->isChecked();
3895 suidLabel->setEnabled( checked );
3896 suidEdit->setEnabled( checked );
3899 bool KExecPropsPlugin::supports( KFileItemList _items )
3901 if ( _items.count() != 1 )
3903 KFileItem * item = _items.first();
3908 KDesktopFile config( item->url().path(),
true );
3909 return config.hasApplicationType() && kapp->authorize(
"run_desktop_files") && kapp->authorize(
"shell_access");
3914 kdDebug(250) <<
"KExecPropsPlugin::applyChanges" << endl;
3919 if ( !f.open( IO_ReadWrite ) ) {
3920 KMessageBox::sorry( 0, i18n(
"<qt>Could not save properties. You do not have "
3921 "sufficient access to write to <b>%1</b>.</qt>").arg(path));
3926 KSimpleConfig config( path );
3927 config.setDesktopGroup();
3928 config.writeEntry(
"Type", TQString::fromLatin1(
"Application"));
3929 config.writePathEntry(
"Exec", execEdit->text() );
3930 config.writePathEntry(
"SwallowExec", swallowExecEdit->text() );
3931 config.writeEntry(
"SwallowTitle", swallowTitleEdit->text() );
3932 config.writeEntry(
"Terminal", terminalCheck->isChecked() );
3933 TQString temp = terminalEdit->text();
3934 if (d->nocloseonexitCheck )
3935 if ( d->nocloseonexitCheck->isChecked() )
3936 temp += TQString::fromLatin1(
"--noclose ");
3937 temp = temp.stripWhiteSpace();
3938 config.writeEntry(
"TerminalOptions", temp );
3939 config.writeEntry(
"X-TDE-SubstituteUID", suidCheck->isChecked() );
3940 config.writeEntry(
"X-TDE-Username", suidEdit->text() );
3944 void KExecPropsPlugin::slotBrowseExec()
3947 TQString::null, d->m_frame );
3951 if ( !f.isLocalFile()) {
3952 KMessageBox::sorry(d->m_frame, i18n(
"Only executables on local file systems are supported."));
3956 TQString path = f.path();
3957 KRun::shellQuote( path );
3958 execEdit->setText( path );
3961 class TDEApplicationPropsPlugin::TDEApplicationPropsPluginPrivate
3964 TDEApplicationPropsPluginPrivate()
3966 m_kdesktopMode = TQCString(tqApp->name()) ==
"kdesktop";
3968 ~TDEApplicationPropsPluginPrivate()
3973 bool m_kdesktopMode;
3979 d =
new TDEApplicationPropsPluginPrivate;
3980 d->m_frame =
properties->addPage(i18n(
"&Application"));
3981 TQVBoxLayout *toplayout =
new TQVBoxLayout( d->m_frame, 0, KDialog::spacingHint());
3986 addExtensionButton =
new TQPushButton( TQString::null, d->m_frame );
3987 iconSet = SmallIconSet(
"back" );
3988 addExtensionButton->setIconSet( iconSet );
3989 pixMap = iconSet.pixmap( TQIconSet::Small, TQIconSet::Normal );
3990 addExtensionButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
3991 connect( addExtensionButton, TQ_SIGNAL( clicked() ),
3992 TQ_SLOT( slotAddExtension() ) );
3994 delExtensionButton =
new TQPushButton( TQString::null, d->m_frame );
3995 iconSet = SmallIconSet(
"forward" );
3996 delExtensionButton->setIconSet( iconSet );
3997 delExtensionButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
3998 connect( delExtensionButton, TQ_SIGNAL( clicked() ),
3999 TQ_SLOT( slotDelExtension() ) );
4003 TQGridLayout *grid =
new TQGridLayout(2, 2);
4004 grid->setColStretch(1, 1);
4005 toplayout->addLayout(grid);
4007 if ( d->m_kdesktopMode )
4014 l =
new TQLabel(i18n(
"Name:"), d->m_frame,
"Label_4" );
4015 grid->addWidget(l, 0, 0);
4017 nameEdit =
new KLineEdit( d->m_frame,
"LineEdit_3" );
4018 grid->addWidget(nameEdit, 0, 1);
4021 l =
new TQLabel(i18n(
"Description:"), d->m_frame,
"Label_5" );
4022 grid->addWidget(l, 1, 0);
4024 genNameEdit =
new KLineEdit( d->m_frame,
"LineEdit_4" );
4025 grid->addWidget(genNameEdit, 1, 1);
4027 l =
new TQLabel(i18n(
"Comment:"), d->m_frame,
"Label_3" );
4028 grid->addWidget(l, 2, 0);
4030 commentEdit =
new KLineEdit( d->m_frame,
"LineEdit_2" );
4031 grid->addWidget(commentEdit, 2, 1);
4033 l =
new TQLabel(i18n(
"File types:"), d->m_frame);
4034 toplayout->addWidget(l, 0, AlignLeft);
4036 grid =
new TQGridLayout(4, 3);
4037 grid->setColStretch(0, 1);
4038 grid->setColStretch(2, 1);
4039 grid->setRowStretch( 0, 1 );
4040 grid->setRowStretch( 3, 1 );
4041 toplayout->addLayout(grid, 2);
4043 extensionsList =
new TQListBox( d->m_frame );
4044 extensionsList->setSelectionMode( TQListBox::Extended );
4045 grid->addMultiCellWidget(extensionsList, 0, 3, 0, 0);
4047 grid->addWidget(addExtensionButton, 1, 1);
4048 grid->addWidget(delExtensionButton, 2, 1);
4050 availableExtensionsList =
new TQListBox( d->m_frame );
4051 availableExtensionsList->setSelectionMode( TQListBox::Extended );
4052 grid->addMultiCellWidget(availableExtensionsList, 0, 3, 2, 2);
4056 if ( !f.open( IO_ReadOnly ) )
4060 KDesktopFile config( path );
4061 TQString commentStr = config.readComment();
4062 TQString genNameStr = config.readGenericName();
4064 TQStringList selectedTypes = config.readListEntry(
"X-TDE-ServiceTypes" );
4066 selectedTypes += config.readListEntry(
"MimeType",
';' );
4068 TQString nameStr = config.readName();
4069 if ( nameStr.isEmpty() || d->m_kdesktopMode ) {
4076 commentEdit->setText( commentStr );
4077 genNameEdit->setText( genNameStr );
4079 nameEdit->setText( nameStr );
4081 selectedTypes.sort();
4082 TQStringList::Iterator sit = selectedTypes.begin();
4083 for( ; sit != selectedTypes.end(); ++sit ) {
4084 if ( !((*sit).isEmpty()) )
4085 extensionsList->insertItem( *sit );
4088 KMimeType::List mimeTypes = KMimeType::allMimeTypes();
4089 TQValueListIterator<KMimeType::Ptr> it2 = mimeTypes.begin();
4090 for ( ; it2 != mimeTypes.end(); ++it2 )
4091 addMimeType ( (*it2)->name() );
4095 connect( extensionsList, TQ_SIGNAL( highlighted(
int ) ),
4096 this, TQ_SLOT( updateButton() ) );
4097 connect( availableExtensionsList, TQ_SIGNAL( highlighted(
int ) ),
4098 this, TQ_SLOT( updateButton() ) );
4100 connect( addExtensionButton, TQ_SIGNAL( clicked() ),
4101 this, TQ_SIGNAL(
changed() ) );
4102 connect( delExtensionButton, TQ_SIGNAL( clicked() ),
4103 this, TQ_SIGNAL(
changed() ) );
4105 connect( nameEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
4106 this, TQ_SIGNAL(
changed() ) );
4107 connect( commentEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
4108 this, TQ_SIGNAL(
changed() ) );
4109 connect( genNameEdit, TQ_SIGNAL( textChanged(
const TQString & ) ),
4110 this, TQ_SIGNAL(
changed() ) );
4111 connect( availableExtensionsList, TQ_SIGNAL( selected(
int ) ),
4112 this, TQ_SIGNAL(
changed() ) );
4113 connect( extensionsList, TQ_SIGNAL( selected(
int ) ),
4114 this, TQ_SIGNAL(
changed() ) );
4117 TDEApplicationPropsPlugin::~TDEApplicationPropsPlugin()
4127 void TDEApplicationPropsPlugin::updateButton()
4129 addExtensionButton->setEnabled(availableExtensionsList->currentItem()>-1);
4130 delExtensionButton->setEnabled(extensionsList->currentItem()>-1);
4133 void TDEApplicationPropsPlugin::addMimeType(
const TQString & name )
4139 for ( uint i = 0; i < extensionsList->count(); i++ )
4140 if ( extensionsList->text( i ) == name )
4145 availableExtensionsList->insertItem( name );
4146 availableExtensionsList->sort();
4150 bool TDEApplicationPropsPlugin::supports( KFileItemList _items )
4153 return KExecPropsPlugin::supports( _items );
4162 if ( !f.open( IO_ReadWrite ) ) {
4163 KMessageBox::sorry( 0, i18n(
"<qt>Could not save properties. You do not "
4164 "have sufficient access to write to <b>%1</b>.</qt>").arg(path));
4169 KSimpleConfig config( path );
4170 config.setDesktopGroup();
4171 config.writeEntry(
"Type", TQString::fromLatin1(
"Application"));
4172 config.writeEntry(
"Comment", commentEdit->text() );
4173 config.writeEntry(
"Comment", commentEdit->text(),
true,
false,
true );
4174 config.writeEntry(
"GenericName", genNameEdit->text() );
4175 config.writeEntry(
"GenericName", genNameEdit->text(),
true,
false,
true );
4177 TQStringList selectedTypes;
4178 for ( uint i = 0; i < extensionsList->count(); i++ )
4179 selectedTypes.append( extensionsList->text( i ) );
4181 config.writeEntry(
"MimeType", selectedTypes,
';' );
4182 config.writeEntry(
"X-TDE-ServiceTypes",
"" );
4185 TQString nameStr = nameEdit ? nameEdit->text() : TQString::null;
4186 if ( nameStr.isEmpty() )
4189 config.writeEntry(
"Name", nameStr );
4190 config.writeEntry(
"Name", nameStr,
true,
false,
true );
4195 void TDEApplicationPropsPlugin::slotAddExtension()
4197 TQListBoxItem *item = availableExtensionsList->firstItem();
4198 TQListBoxItem *nextItem;
4202 nextItem = item->next();
4204 if ( item->isSelected() )
4206 extensionsList->insertItem( item->text() );
4207 availableExtensionsList->removeItem( availableExtensionsList->index( item ) );
4213 extensionsList->sort();
4217 void TDEApplicationPropsPlugin::slotDelExtension()
4219 TQListBoxItem *item = extensionsList->firstItem();
4220 TQListBoxItem *nextItem;
4224 nextItem = item->next();
4226 if ( item->isSelected() )
4228 availableExtensionsList->insertItem( item->text() );
4229 extensionsList->removeItem( extensionsList->index( item ) );
4235 availableExtensionsList->sort();
4241 #include "kpropertiesdialog.moc"
Used to edit the files containing [Desktop Entry] Type=MimeType.
virtual void applyChanges()
Applies all changes to the file.
KBindingPropsPlugin(KPropertiesDialog *_props)
Constructor.
Used to edit the files containing [Desktop Entry] Type=Application.
KDesktopPropsPlugin(KPropertiesDialog *_props)
Constructor.
virtual void applyChanges()
Applies all changes to the file.
Properties plugin for device .desktop files.
virtual void applyChanges()
Applies all changes to the file.
Computes a directory size (similar to "du", but doesn't give the same results since we simply sum up ...
static KDirSize * dirSizeJob(const KURL &directory)
Asynchronous method.
This class parses the output of "df" to find the disk usage information for a given partition (mount ...
int readDF(const TQString &mountPoint)
Call this to fire a search on the disk usage information for mountPoint.
KExecPropsPlugin(KPropertiesDialog *_props)
Constructor.
virtual void applyChanges()
Applies all changes to the file.
static KURL getOpenURL(const TQString &startDir=TQString::null, const TQString &filter=TQString::null, TQWidget *parent=0, const TQString &caption=TQString::null)
Creates a modal file dialog and returns the selected URL or an empty string if none was chosen.
'Permissions' plugin In this plugin you can modify permissions and change the owner of a file.
KFilePermissionsPropsPlugin(KPropertiesDialog *_props)
Constructor.
static bool supports(KFileItemList _items)
Tests whether the file specified by _items needs a 'Permissions' plugin.
virtual void applyChanges()
Applies all changes to the file.
'General' plugin This plugin displays the name of the file, its size and access times.
static bool supports(KFileItemList _items)
Tests whether the files specified by _items need a 'General' plugin.
KFilePropsPlugin(KPropertiesDialog *_props)
Constructor.
virtual void applyChanges()
Applies all changes made.
void postApplyChanges()
Called after all plugins applied their changes.
This plugin provides a page to KPropsDlg, showing the "file sharing" options.
static bool supports(KFileItemList _items)
Tests whether a preview for the first item should be shown.
The main properties dialog class.
void applied()
This signal is emitted when the properties changes are applied (for example, with the OK button)
void insertPlugin(KPropsDlgPlugin *plugin)
Adds a "3rd party" properties plugin to the dialog.
void setFileNameReadOnly(bool ro)
Call this to make the filename lineedit readonly, to prevent the user from renaming the file.
virtual void slotCancel()
Called when the user presses 'Cancel'.
void updateUrl(const KURL &_newUrl)
Updates the item URL (either called by rename or because a global apps/mimelnk desktop file is being ...
void showFileSharingPage()
Shows the page that was previously set by setFileSharingPage(), or does nothing if no page was set ye...
KFileItemList items() const
KPropertiesDialog(KFileItem *item, TQWidget *parent=0L, const char *name=0L, bool modal=false, bool autoShow=true)
Brings up a Properties dialog, as shown above.
void abortApplying()
To abort applying changes.
const KURL & kurl() const
The URL of the file that has its properties being displayed.
void setFileSharingPage(TQWidget *page)
Sets the file sharing page.
const TQString & defaultName() const
If the dialog is being built from a template, this method returns the default name.
void propertiesClosed()
This signal is emitted when the Properties Dialog is closed (for example, with OK or Cancel buttons)
void rename(const TQString &_name)
Renames the item to the specified name.
virtual void slotOk()
Called when the user presses 'Ok'.
static bool showDialog(KFileItem *item, TQWidget *parent=0, const char *name=0, bool modal=false)
Immediately displays a Properties dialog using constructor with the same parameters.
const KURL & currentDir() const
If the dialog is being built from a template, this method returns the current directory.
virtual ~KPropertiesDialog()
Cleans up the properties dialog and frees any associated resources, including the dialog itself.
void saveAs(const KURL &oldUrl, KURL &newUrl)
Emitted before changes to oldUrl are saved as newUrl.
void canceled()
This signal is emitted when the properties changes are aborted (for example, with the Cancel button)
static bool canDisplay(KFileItemList _items)
Determine whether there are any property pages available for the given file items.
A Plugin in the Properties dialog This is an abstract class.
void changed()
Emit this signal when the user changed anything in the plugin's tabs.
KPropertiesDialog * properties
Pointer to the dialog.
KPropsDlgPlugin(KPropertiesDialog *_props)
Constructor To insert tabs into the properties dialog, use the add methods provided by KDialogBase (t...
virtual void applyChanges()
Applies all changes to the file.
static bool isDesktopFile(KFileItem *_item)
Convenience method for most ::supports methods.
Used to edit the files containing [Desktop Entry] URL=....
virtual void applyChanges()
Applies all changes to the file.
KURLPropsPlugin(KPropertiesDialog *_props)
Constructor.
This class is a widget showing a lineedit and a button, which invokes a filedialog.
void setURL(const TQString &url)
Sets the url in the lineedit to url.
TDEApplicationPropsPlugin(KPropertiesDialog *_props)
Constructor.
virtual void applyChanges()
Applies all changes to the file.