[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Getting KDE's KAction working with my Perl-KDE app....
From: "Gary L. Greene, Jr." <greeneg () phoenuxos ! com>
Date: 2006-11-14 19:44:13
Message-ID: 200611141444.13745.greeneg () phoenuxos ! com
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
While, yes, this app is written in PerlKDE and I did post about this on the
kde-perl mailing list (and have yet to get a response....), I don't think
it's OT for the devel list so here I go.
I cannot seem to get XMLGUI working. The code is attached with the xml file to
be installed in the proper place so people can see what I'm getting. You need
PerlKDE which is in PerlQt 3.009b2. Please, I need to figure why this isn't
working, so any help would be useful. If there are some folks on the list
that are familiar with PerlKDE or PerlQt, please look it over. Thanks.
--
Gary L. Greene, Jr.
Sent from: uriel.tolharadys.net
09:18:57 up 3 days, 13:05, 9 users, load average: 0.24, 0.23, 0.20
=========================================================================
Volunteer Developer for the PhoeNUX OS open source project
See http://www.phoenuxos.com/ for more information
=========================================================================
Please avoid sending me Word or PowerPoint attachments.
["pxi" (application/x-perl)]
#!/usr/bin/perl -w
use strict;
use utf8;
package main;
use KDE;
use Qt;
use Pxpmgui;
# I18N support.
use Locale::gettext;
sub i18n{ return gettext($_[0]); }
textdomain( "pxi" );
my $opt = [];
my $about = KDE::AboutData("pxi", "PXI", "0.1", "A Perl-Qt APT RPM Manager.");
KDE::CmdLineArgs::init(\@ARGV, $about);
KDE::CmdLineArgs::addCmdLineOptions($opt);
my $args = KDE::CmdLineArgs::parsedArgs();
# regular app stuff
my $app = KDE::Application();
my $wdgt = Pxpmgui;
Qt::Object::connect( $app,
SIGNAL( "lastWindowClosed()" ),
$app,
SLOT( "quit()" ) );
$app->setTopWidget( $wdgt );
$wdgt->setCaption( i18n( "Package Installer" ) );
$wdgt->show();
exit $app->exec();
END {}
["Pxpmgui.pm" (application/x-perl-module)]
###############################################################################
# PXI, a PerlQt based APT-RPM package manager.
#
# Author: Gary Greene <greeneg@phoenuxos.com>
# Copyright (c) 2006
#
# LICENSE: GPLv2, see License file in the top of the source distribution for
# the full text of the license.
#
###############################################################################
use strict;
use utf8;
package Pxpmgui;
use Qt;
use Qt::debug;
use Qt::isa qw( KDE::MainWindow );
use Qt::slots
changeStackPage => [],
myQuit => [],
rmbAddAppsClickAction => [],
rmbRmAppsClickAction => [];
use Qt::attributes qw(
sideFrameWdgt
sideBttnGrp
removeBttn
installBttn
configBttn
wizardWdgtStk
installWdgtStkPg
titleLbl
titleLbl_font
sortingCBox
installSelectionBttn
addAppsSearch
addAppsListView
removeWdgtStkPg
rmAppsLbl
rmAppsLbl_font
rmAppsSortCmbBx
rmAppsListView
reinstallBttn
removeSelectionBttn
configWdgtStkPg
textLabel2
textLabel2_font
instSrcLstVw
typeLbl
hostLbl
pathLbl
sectionLbl
typeCBox
hostLEdt
pathLEdt
sectionLEdt
activateChkBx
removeEntryBttn
addEntryBttn
rmAppsSearch
installAction
);
sub NEW {
shift->SUPER::NEW( @_[ 0..3 ] );
if ( name() eq "unnamed" ) {
setName( "Pxpmgui" );
}
our $image0 = Qt::Pixmap( "pixmaps/package.png" );
our $image1 = Qt::Pixmap( "pixmaps/package_utilities.png" );
our $image2 = Qt::Pixmap( "pixmaps/kcmsystem.png" );
setMinimumSize(Qt::Size(1000, 740) );
setMaximumSize(Qt::Size(1000, 740) );
setBaseSize(Qt::Size(1000, 740) );
setIcon( $image0 );
#------------------------------------------------------------------------------
#
# Side bar
#
#------------------------------------------------------------------------------
my $centralWdgt = Qt::Widget( this );
sideFrameWdgt = Qt::Frame( $centralWdgt, "sideFrameWdgt" );
sideFrameWdgt->setSizePolicy( Qt::SizePolicy(0, 5, 0, 0, \
sideFrameWdgt->sizePolicy()->hasHeightForWidth()) ); sideFrameWdgt->setGeometry( \
0,0,196,720 ); sideFrameWdgt->setPaletteBackgroundColor( Qt::Color(165, 165, 165) );
sideFrameWdgt->setFrameShape( &Qt::Frame::WinPanel() );
sideFrameWdgt->setFrameShadow( &Qt::Frame::Sunken() );
my $sideFrameWdgtLayout = Qt::VBoxLayout(sideFrameWdgt, 11, 6, \
'$sideFrameWdgtLayout');
sideBttnGrp = Qt::ButtonGroup(sideFrameWdgt, "sideBttnGrp");
sideBttnGrp->setFrameShape( &Qt::ButtonGroup::NoFrame() );
sideBttnGrp->setFrameShadow( &Qt::ButtonGroup::Plain() );
sideBttnGrp->setFlat( 0 );
sideBttnGrp->setExclusive( 1 );
installBttn = Qt::ToolButton(sideBttnGrp, "installBttn");
installBttn->setGeometry( Qt::Rect(0, 0, 170, 80) );
installBttn->setPaletteBackgroundColor( Qt::Color(165, 165, 165) );
installBttn->setCursor( Qt::Cursor(13) );
installBttn->setToggleButton( 1 );
installBttn->setOn( 1 );
installBttn->setIconSet( Qt::IconSet($image0) );
installBttn->setUsesBigPixmap( 1 );
installBttn->setUsesTextLabel( 1 );
installBttn->setAutoRaise( 1 );
removeBttn = Qt::ToolButton(sideBttnGrp, "removeBttn");
removeBttn->setGeometry( Qt::Rect(0, 90, 170, 80) );
removeBttn->setPaletteBackgroundColor( Qt::Color(165, 165, 165) );
removeBttn->setCursor( Qt::Cursor(13) );
removeBttn->setMouseTracking( 0 );
removeBttn->setFocusPolicy( &Qt::ToolButton::NoFocus() );
removeBttn->setToggleButton( 1 );
removeBttn->setIconSet( Qt::IconSet($image1) );
removeBttn->setUsesBigPixmap( 1 );
removeBttn->setUsesTextLabel( 1 );
removeBttn->setAutoRaise( 1 );
configBttn = Qt::ToolButton(sideBttnGrp, "configBttn");
configBttn->setGeometry( Qt::Rect(0, 180, 170, 80) );
configBttn->setPaletteBackgroundColor( Qt::Color(165, 165, 165) );
configBttn->setCursor( Qt::Cursor(13) );
configBttn->setToggleButton( 1 );
configBttn->setOn( 0 );
configBttn->setIconSet( Qt::IconSet($image2) );
configBttn->setUsesBigPixmap( 1 );
configBttn->setUsesTextLabel( 1 );
configBttn->setAutoRaise( 1 );
$sideFrameWdgtLayout->addWidget(sideBttnGrp);
my $spacer = Qt::SpacerItem(20, 242, &Qt::SizePolicy::Minimum, \
&Qt::SizePolicy::Expanding); $sideFrameWdgtLayout->addItem($spacer);
wizardWdgtStk = Qt::WidgetStack( $centralWdgt, "wizardWdgtStk" );
wizardWdgtStk->setSizePolicy( Qt::SizePolicy(5, 5, 0, 0, \
wizardWdgtStk->sizePolicy()->hasHeightForWidth()) ); \
wizardWdgtStk->setGeometry(196,0,806,710);
#------------------------------------------------------------------------------
#
# Install page
#
#------------------------------------------------------------------------------
installWdgtStkPg = Qt::Widget( wizardWdgtStk, "installWdgtStkPg" );
my $LayoutWidget = Qt::Widget( installWdgtStkPg, '$LayoutWidget' );
$LayoutWidget->setGeometry( Qt::Rect( 0, 0, 800, 50 ) );
my $layout12 = Qt::HBoxLayout( $LayoutWidget, 11, 6, '$layout12');
titleLbl = Qt::Label( $LayoutWidget, "titleLbl" );
my $titleLbl_font = Qt::Font( titleLbl->font );
$titleLbl_font->setFamily( "Bitstream Vera Sans" );
$titleLbl_font->setBold( 1 );
titleLbl->setFont( $titleLbl_font );
titleLbl->setGeometry( 0, 0, 120, 40 );
$layout12->addWidget( titleLbl );
sortingCBox = Qt::ComboBox( 0, $LayoutWidget, "sortingCBox" );
sortingCBox->setGeometry( 0, 0, 120, 40 );
$layout12->addWidget(sortingCBox);
addAppsSearch = KDE::ListViewSearchLineWidget( addAppsListView, installWdgtStkPg, \
"kListViewSearchLineWidget1" ); addAppsSearch->setGeometry( Qt::Rect( 10, 50, 780, \
30 ) );
addAppsListView = KDE::ListView( installWdgtStkPg, "addAppsListView" );
addAppsListView->setGeometry( Qt::Rect( 11, 89, 784, 560 ) );
addAppsListView->setSizePolicy( Qt::SizePolicy( 3, 3, 0, 0, \
addAppsListView->sizePolicy()->hasHeightForWidth() ) ); \
addAppsListView->setProperty( "selectionMode", Qt::Variant( "Multi" ) ); \
addAppsListView->setAllColumnsShowFocus( 1 ); addAppsListView->setItemMargin( int( 1 \
) ); addAppsListView->addColumn( "", -1 );
addAppsListView->addColumn( "Name", -1 );
addAppsListView->addColumn( "Version", -1 );
addAppsListView->addColumn( "Size", -1 );
addAppsListView->addColumn( "Build Date", -1 );
my $addAppsFooterWidget = Qt::Widget( installWdgtStkPg, 'addAppsFooterWidget' );
$addAppsFooterWidget->setGeometry( Qt::Rect(0, 650, 800, 40) );
my $addAppsBttnLayout = Qt::HBoxLayout( $addAppsFooterWidget, 11, 6, \
'$addAppsBttnLayout' ); my $spacer2 = Qt::SpacerItem(40, 20, \
&Qt::SizePolicy::Expanding, &Qt::SizePolicy::Preferred); \
$addAppsBttnLayout->addItem($spacer2);
installSelectionBttn = Qt::PushButton( $addAppsFooterWidget, \
"installSelectionBttn"); installSelectionBttn->setSizePolicy( Qt::SizePolicy(1, 5, \
0, 0, installSelectionBttn->sizePolicy()->hasHeightForWidth()) ); \
installSelectionBttn->setMinimumSize( Qt::Size(120, 30) ); \
$addAppsBttnLayout->addWidget(installSelectionBttn);
wizardWdgtStk->addWidget( installWdgtStkPg, 0 );
#------------------------------------------------------------------------------
#
# Remove Page
#
#------------------------------------------------------------------------------
removeWdgtStkPg = Qt::Widget(wizardWdgtStk, "removeWdgtStkPg");
my $removeLayout = Qt::Widget(removeWdgtStkPg, '$removeLayout');
$removeLayout->setGeometry( Qt::Rect(0, 0, 800, 50) );
my $layout13 = Qt::HBoxLayout($removeLayout, 11, 6, '$layout13');
rmAppsLbl = Qt::Label( $removeLayout, "rmAppsLbl");
my $rmAppsLbl_font = Qt::Font(rmAppsLbl->font);
$rmAppsLbl_font->setFamily("Bitstream Vera Sans");
$rmAppsLbl_font->setBold(1);
rmAppsLbl->setFont($rmAppsLbl_font);
rmAppsLbl->setGeometry( 0, 0, 120, 40 );
$layout13->addWidget(rmAppsLbl);
rmAppsSortCmbBx = Qt::ComboBox(0, $removeLayout, "rmAppsSortCmbBx");
rmAppsSortCmbBx->setGeometry( 0, 0, 120, 40 );
$layout13->addWidget(rmAppsSortCmbBx);
rmAppsSearch = KDE::ListViewSearchLineWidget( rmAppsListView, removeWdgtStkPg, \
"rmAppsSearch" ); rmAppsSearch->setGeometry( Qt::Rect( 10, 50, 780, 30 ) );
rmAppsListView = KDE::ListView(removeWdgtStkPg, "rmAppsListView");
rmAppsListView->setGeometry( Qt::Rect(11, 89, 784, 560 ) );
rmAppsListView->setSizePolicy( Qt::SizePolicy(3, 3, 0, 0, \
addAppsListView->sizePolicy()->hasHeightForWidth()) ); rmAppsListView->setProperty( \
"selectionMode", Qt::Variant( "Multi" ) ); rmAppsListView->setAllColumnsShowFocus( 1 \
); rmAppsListView->setShowSortIndicator( 0 );
rmAppsListView->setItemMargin( int( 1 ) );
rmAppsListView->addColumn( "", -1 );
rmAppsListView->addColumn( "Name", -1 );
rmAppsListView->addColumn( "Version", -1 );
rmAppsListView->addColumn( "Size", -1 );
rmAppsListView->addColumn( "Install Date", -1 );
my $rmAppsFooterWidget = Qt::Widget( removeWdgtStkPg, 'rmAppsFooterWidget' );
$rmAppsFooterWidget->setGeometry( Qt::Rect( 0, 650, 800, 50 ) );
my $rmBttnLayout = Qt::HBoxLayout( $rmAppsFooterWidget, 11, 6, 'rmBttnLayout');
reinstallBttn = Qt::PushButton( $rmAppsFooterWidget, "reinstallBttn" );
$rmBttnLayout->addWidget( reinstallBttn );
removeSelectionBttn = Qt::PushButton( $rmAppsFooterWidget, "removeSelectionBttn" \
); $rmBttnLayout->addWidget( removeSelectionBttn );
wizardWdgtStk->addWidget( removeWdgtStkPg, 1 );
#------------------------------------------------------------------------------
#
# Config Page
#
#------------------------------------------------------------------------------
configWdgtStkPg = Qt::Widget(wizardWdgtStk, "configWdgtStkPg");
my $configWdgtStkPgLayout = Qt::VBoxLayout(configWdgtStkPg, 11, 6, \
'$configWdgtStkPgLayout');
textLabel2 = Qt::Label( configWdgtStkPg, "textLabel2" );
my $textLabel2_font = Qt::Font( textLabel2->font );
$textLabel2_font->setFamily( "Bitstream Vera Sans" );
$textLabel2_font->setBold( 1 );
textLabel2->setFont( $textLabel2_font );
textLabel2->setGeometry( 0,0,120,40 );
$configWdgtStkPgLayout->addWidget( textLabel2 );
instSrcLstVw = Qt::ListView( configWdgtStkPg, "instSrcLstVw" );
instSrcLstVw->setGeometry( 0,0,784,300 );
instSrcLstVw->addColumn( trUtf8( "Active" ) );
instSrcLstVw->addColumn( trUtf8( "Type" ) );
instSrcLstVw->addColumn( trUtf8( "Host" ) );
instSrcLstVw->addColumn( trUtf8( "Path" ) );
instSrcLstVw->addColumn( trUtf8( "Sections" ) );
instSrcLstVw->header()->setResizeEnabled( 0, instSrcLstVw->header()->count() - 1 \
); $configWdgtStkPgLayout->addWidget( instSrcLstVw );
my $configInputLayout = Qt::HBoxLayout( undef, 0, 6, '$configInputLayout' );
my $configLblsLayout = Qt::VBoxLayout( undef, 0, 6, '$configLblsLayout' );
typeLbl = Qt::Label( configWdgtStkPg, "typeLbl" );
$configLblsLayout->addWidget( typeLbl );
hostLbl = Qt::Label( configWdgtStkPg, "hostLbl" );
$configLblsLayout->addWidget( hostLbl );
pathLbl = Qt::Label( configWdgtStkPg, "pathLbl" );
$configLblsLayout->addWidget( pathLbl );
sectionLbl = Qt::Label( configWdgtStkPg, "sectionLbl" );
$configLblsLayout->addWidget( sectionLbl );
$configInputLayout->addLayout( $configLblsLayout );
my $configInputBxLayout = Qt::VBoxLayout( undef, 0, 6, '$configInputBxLayout' );
typeCBox = Qt::ComboBox( 0, configWdgtStkPg, "typeCBox" );
$configInputBxLayout->addWidget( typeCBox );
hostLEdt = Qt::LineEdit( configWdgtStkPg, "hostLEdt" );
$configInputBxLayout->addWidget( hostLEdt );
pathLEdt = Qt::LineEdit( configWdgtStkPg, "pathLEdt" );
$configInputBxLayout->addWidget( pathLEdt );
sectionLEdt = Qt::LineEdit( configWdgtStkPg, "sectionLEdt" );
$configInputBxLayout->addWidget( sectionLEdt );
$configInputLayout->addLayout( $configInputBxLayout );
$configWdgtStkPgLayout->addLayout( $configInputLayout );
activateChkBx = Qt::CheckBox( configWdgtStkPg, "activateChkBx" );
$configWdgtStkPgLayout->addWidget( activateChkBx );
my $configBttnLayout = Qt::HBoxLayout(undef, 0, 6, '$configBttnLayout');
removeEntryBttn = Qt::PushButton(configWdgtStkPg, "removeEntryBttn");
$configBttnLayout->addWidget(removeEntryBttn);
addEntryBttn = Qt::PushButton(configWdgtStkPg, "addEntryBttn");
$configBttnLayout->addWidget(addEntryBttn);
$configWdgtStkPgLayout->addLayout($configBttnLayout);
wizardWdgtStk->addWidget( configWdgtStkPg, 2 );
#------------------------------------------------------------------------------
#
# Post UI setup.
#
#------------------------------------------------------------------------------
# Create the KActions to go in the menus or toolbars
#- File Menu
#-- Install Individual Package
my $a = KDE::Action( "Install Local Package...", "package", KDE::Shortcut( \
"Ctrl+I" ),
this, SLOT "installLocalPkg()", actionCollection(), \
"install_local_pkg" ); #-- Open Cached Selections
KDE::StdAction::open( this, SLOT "open()", actionCollection() );
#-- Save Selections
#-- View installation Log
#-- Exit
KDE::StdAction::quit( this, SLOT "close()", actionCollection() );
#- Actions Menu
#-- Select all Upgrades
#-- Unselect all
#-- Install
#-- Remove
#-- Reinstall
#-- Find Package
#-- Clear Cache
#- View
#-- Add and Upgrade Packages
#-- Reinstall and Remove Packages
#-- Configure Repositories
#-- Advanced Configuration Editor
#-- Package Properties
setupGUI( "pxiui.rc" );
setCentralWidget($centralWdgt);
languageChange();
my $resize = Qt::Size(1000, 720);
$resize = $resize->expandedTo(minimumSizeHint());
resize( $resize );
Qt::Object::connect( installBttn, SIGNAL "released()", this, SLOT \
"changeStackPage()" ); Qt::Object::connect( removeBttn, SIGNAL "released()", this, \
SLOT "changeStackPage()" ); Qt::Object::connect( addAppsListView, SIGNAL \
"rightButtonClicked( QListViewItem*, const QPoint&, int )", this, SLOT \
"rmbAddAppsClickAction()" ); Qt::Object::connect( rmAppsListView, SIGNAL \
"rightButtonClicked( QListViewItem*, const QPoint&, int )", this, SLOT \
"rmbRmAppsClickAction()" ); Qt::Object::connect( configBttn, SIGNAL "released()", \
this, SLOT "changeStackPage()" ); }
# Sets the strings of the subwidgets using the current language.
sub languageChange {
setCaption( trUtf8( "Add and Remove Software") );
sideBttnGrp->setTitle( undef );
removeBttn->setText( undef );
removeBttn->setTextLabel( trUtf8( "Remove Software" ) );
installBttn->setText( undef );
installBttn->setTextLabel( trUtf8( "Install Software" ) );
configBttn->setText( undef );
configBttn->setTextLabel( trUtf8( "Configure Sources" ) );
titleLbl->setText( trUtf8( "Add Programs" ) );
sortingCBox->clear();
sortingCBox->insertItem( trUtf8( "Name" ) );
sortingCBox->insertItem( trUtf8( "Size" ) );
sortingCBox->insertItem( trUtf8( "Build Date" ) );
Qt::ToolTip::add( sortingCBox, trUtf8( "Sort package list by..." ) );
installSelectionBttn->setText( trUtf8( "&Install Selection" ) );
installSelectionBttn->setAccel( Qt::KeySequence( trUtf8( "Alt+I" ) ) );
rmAppsLbl->setText( trUtf8( "Remove or Reinstall Programs" ) );
rmAppsSortCmbBx->clear();
rmAppsSortCmbBx->insertItem( trUtf8( "Name" ) );
rmAppsSortCmbBx->insertItem( trUtf8( "Size" ) );
rmAppsSortCmbBx->insertItem( trUtf8( "Install Date" ) );
reinstallBttn->setText( trUtf8( "&Reinstall Selected" ) );
reinstallBttn->setAccel( Qt::KeySequence( trUtf8( "Alt+R" ) ) );
removeSelectionBttn->setText( trUtf8( "Remo&ve Selected" ) );
removeSelectionBttn->setAccel( Qt::KeySequence( trUtf8( "Alt+V" ) ) );
textLabel2->setText( trUtf8( "APT Configuration Editor" ) );
instSrcLstVw->header()->setLabel( 0, trUtf8( "Active" ) );
instSrcLstVw->header()->setLabel( 1, trUtf8( "Type" ) );
instSrcLstVw->header()->setLabel( 2, trUtf8( "Host" ) );
instSrcLstVw->header()->setLabel( 3, trUtf8( "Path" ) );
instSrcLstVw->header()->setLabel( 4, trUtf8( "Sections" ) );
typeLbl->setText( trUtf8( "Type" ) );
hostLbl->setText( trUtf8( "Host" ) );
pathLbl->setText( trUtf8( "Path" ) );
sectionLbl->setText( trUtf8( "Sections" ) );
typeCBox->clear();
typeCBox->insertItem( trUtf8( "RPMS" ) );
typeCBox->insertItem( trUtf8( "SRPMS" ) );
activateChkBx->setText( trUtf8( "&Activated" ) );
activateChkBx->setAccel( Qt::KeySequence( trUtf8( "Alt+A" ) ) );
removeEntryBttn->setText( trUtf8("&Remove Entry") );
removeEntryBttn->setAccel( Qt::KeySequence( trUtf8( "Alt+R" ) ) );
addEntryBttn->setText( trUtf8( "A&dd Entry" ) );
addEntryBttn->setAccel( Qt::KeySequence( trUtf8( "Alt+D" ) ) );
}
sub changeStackPage {
print "Pxpmgui->changeStackPage(): activated.\n";
if ( installBttn->isOn() ) {
wizardWdgtStk->raiseWidget( 0 );
} elsif ( removeBttn->isOn() ) {
wizardWdgtStk->raiseWidget( 1 );
} elsif ( configBttn->isOn() ) {
wizardWdgtStk->raiseWidget( 2 )
}
}
sub installLocalPkg(): SLOT() {
print "Pxpmgui->installLocalPkg(): Not implemented yet.\n";
}
sub open(): SLOT() {
print "Pxpmgui->open(): Not implemented yet.\n";
}
sub rmbAddAppsClickAction {
print "Pxpmgui->rmbAddAppsClickAction(): Not implemented yet.\n";
}
sub rmbRmAppsClickAction {
print "Pxpmgui->rmbRmAppsClickAction(): Not implemented yet.\n";
}
1;
["pxiui.rc" (text/html)]
<!DOCTYPE kpartgui>
<kpartgui name="pxi">
<MenuBar>
<Menu name="file"><text>&File</text>
<Action name="install_local_pkg"/>
<Merge/>
</Menu>
<Menu name="edit"><text>&Edit</text></Menu>
<Menu name="view"><text>&View</text></Menu>
<Menu name="package"><text>&Package</text></Menu>
</MenuBar>
<!-- <ToolBar fullWidth="true" name="mainToolBar">
<Action name="add_to_bookmarks"/>
<Action name="back"/>
<Separator/>
<Action name="file_quit"/>
</ToolBar> -->
</kpartgui>
[Attachment #10 (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic