1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
package GeneralTab;
use strict;
use warnings;
use QtCore4;
use QtGui4;
use QtCore4::isa qw( Qt::Widget );
sub NEW {
my ( $class, $fileInfo, $parent ) = @_;
$class->SUPER::NEW( $parent );
my $fileNameLabel = Qt::Label(this->tr('File Name:'));
my $fileNameEdit = Qt::LineEdit($fileInfo->fileName());
my $pathLabel = Qt::Label(this->tr('Path:'));
my $pathValueLabel = Qt::Label($fileInfo->absoluteFilePath());
$pathValueLabel->setFrameStyle(Qt::Frame::Panel() | Qt::Frame::Sunken());
my $sizeLabel = Qt::Label(this->tr('Size:'));
my $size = $fileInfo->size()/1024;
my $sizeValueLabel = Qt::Label(this->tr(sprintf '%d K', $size));
$sizeValueLabel->setFrameStyle(Qt::Frame::Panel() | Qt::Frame::Sunken());
my $lastReadLabel = Qt::Label(this->tr('Last Read:'));
my $lastReadValueLabel = Qt::Label($fileInfo->lastRead()->toString());
$lastReadValueLabel->setFrameStyle(Qt::Frame::Panel() | Qt::Frame::Sunken());
my $lastModLabel = Qt::Label(this->tr('Last Modified:'));
my $lastModValueLabel = Qt::Label($fileInfo->lastModified()->toString());
$lastModValueLabel->setFrameStyle(Qt::Frame::Panel() | Qt::Frame::Sunken());
my $mainLayout = Qt::VBoxLayout;
$mainLayout->addWidget($fileNameLabel);
$mainLayout->addWidget($fileNameEdit);
$mainLayout->addWidget($pathLabel);
$mainLayout->addWidget($pathValueLabel);
$mainLayout->addWidget($sizeLabel);
$mainLayout->addWidget($sizeValueLabel);
$mainLayout->addWidget($lastReadLabel);
$mainLayout->addWidget($lastReadValueLabel);
$mainLayout->addWidget($lastModLabel);
$mainLayout->addWidget($lastModValueLabel);
$mainLayout->addStretch(1);
this->setLayout($mainLayout);
}
package PermissionsTab;
use strict;
use warnings;
use QtCore4;
use QtGui4;
use QtCore4::isa qw( Qt::Widget );
sub NEW {
my ( $class, $fileInfo, $parent ) = @_;
$class->SUPER::NEW( $parent );
my $permissionsGroup = Qt::GroupBox(this->tr('Permissions'));
my $readable = Qt::CheckBox(this->tr('Readable'));
$readable->setChecked(1) if ($fileInfo->isReadable());
my $writable = Qt::CheckBox(this->tr('Writable'));
$writable->setChecked(1) if ( $fileInfo->isWritable() );
my $executable = Qt::CheckBox(this->tr('Executable'));
$executable->setChecked(1) if ( $fileInfo->isExecutable() );
my $ownerGroup = Qt::GroupBox(this->tr('Ownership'));
my $ownerLabel = Qt::Label(this->tr('Owner'));
my $ownerValueLabel = Qt::Label($fileInfo->owner());
$ownerValueLabel->setFrameStyle(Qt::Frame::Panel() | Qt::Frame::Sunken());
my $groupLabel = Qt::Label(this->tr('Group'));
my $groupValueLabel = Qt::Label($fileInfo->group());
$groupValueLabel->setFrameStyle(Qt::Frame::Panel() | Qt::Frame::Sunken());
my $permissionsLayout = Qt::VBoxLayout();
$permissionsLayout->addWidget($readable);
$permissionsLayout->addWidget($writable);
$permissionsLayout->addWidget($executable);
$permissionsGroup->setLayout($permissionsLayout);
my $ownerLayout = Qt::VBoxLayout();
$ownerLayout->addWidget($ownerLabel);
$ownerLayout->addWidget($ownerValueLabel);
$ownerLayout->addWidget($groupLabel);
$ownerLayout->addWidget($groupValueLabel);
$ownerGroup->setLayout($ownerLayout);
my $mainLayout = Qt::VBoxLayout();
$mainLayout->addWidget($permissionsGroup);
$mainLayout->addWidget($ownerGroup);
$mainLayout->addStretch(1);
this->setLayout($mainLayout);
}
package ApplicationsTab;
use strict;
use warnings;
use QtCore4;
use QtGui4;
use QtCore4::isa qw( Qt::Widget );
sub NEW {
my ( $class, $fileInfo, $parent ) = @_;
$class->SUPER::NEW( $parent );
my $topLabel = Qt::Label(this->tr('Open with:'));
my $applicationsListBox = Qt::ListWidget();
my @applications = map{ "Application $_" } ( 0..30 );
$applicationsListBox->insertItems(0, \@applications);
my $alwaysCheckBox;
if (!$fileInfo->suffix()) {
$alwaysCheckBox = Qt::CheckBox(this->tr('Always use this application to ' .
'open this type of file'));
}
else {
$alwaysCheckBox = Qt::CheckBox(this->tr('Always use this application to ' .
'open files with the extension \'' . $fileInfo->suffix() . '\''));
}
my $layout = Qt::VBoxLayout();
$layout->addWidget($topLabel);
$layout->addWidget($applicationsListBox);
$layout->addWidget($alwaysCheckBox);
this->setLayout($layout);
}
package TabDialog;
use strict;
use warnings;
use QtCore4;
use QtGui4;
use QtCore4::isa qw( Qt::Dialog );
use GeneralTab;
use PermissionsTab;
use ApplicationsTab;
sub NEW {
my ( $class, $fileName, $parent ) = @_;
$class->SUPER::NEW( $parent );
my $fileInfo = Qt::FileInfo($fileName);
my $tabWidget = Qt::TabWidget();
this->{tabWidget} = $tabWidget;
$tabWidget->addTab(GeneralTab($fileInfo), this->tr('General'));
$tabWidget->addTab(PermissionsTab($fileInfo), this->tr('Permissions'));
$tabWidget->addTab(ApplicationsTab($fileInfo), this->tr('Applications'));
my $buttonBox = Qt::DialogButtonBox(Qt::DialogButtonBox::Ok()
| Qt::DialogButtonBox::Cancel());
this->{buttonBox} = $buttonBox;
this->connect($buttonBox, SIGNAL 'accepted()', this, SLOT 'accept()');
this->connect($buttonBox, SIGNAL 'rejected()', this, SLOT 'reject()');
my $mainLayout = Qt::VBoxLayout();
$mainLayout->addWidget($tabWidget);
$mainLayout->addWidget($buttonBox);
this->setLayout($mainLayout);
this->setWindowTitle(this->tr('Tab Dialog'));
}
1;
|