summaryrefslogtreecommitdiff
path: root/examples/main-tab
authordrw <drw>2005-06-15 22:39:20 (UTC)
committer drw <drw>2005-06-15 22:39:20 (UTC)
commite0205bac48b9d23af9feb48004c24fcf7a5e8200 (patch) (side-by-side diff)
tree2faa077192fd0bfc4fc409f0513cc0e82113fa9e /examples/main-tab
parentd2474c8e654d223b85b6200ce09fabd3a40af8e3 (diff)
downloadopie-e0205bac48b9d23af9feb48004c24fcf7a5e8200.zip
opie-e0205bac48b9d23af9feb48004c24fcf7a5e8200.tar.gz
opie-e0205bac48b9d23af9feb48004c24fcf7a5e8200.tar.bz2
Resource -> OResource
Diffstat (limited to 'examples/main-tab') (more/less context) (show whitespace changes)
-rw-r--r--examples/main-tab/config.in2
-rw-r--r--examples/main-tab/main-tab.pro2
-rw-r--r--examples/main-tab/opie-simple.control2
-rw-r--r--examples/main-tab/simple.cpp11
4 files changed, 8 insertions, 9 deletions
diff --git a/examples/main-tab/config.in b/examples/main-tab/config.in
index a40df56..640679e 100644
--- a/examples/main-tab/config.in
+++ b/examples/main-tab/config.in
@@ -1,4 +1,4 @@
config MAIN_TAB_EXAMPLE
boolean "Mainwindow with OTabWidget example"
default "y"
- depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIE2UI
+ depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIE2CORE && LIBOPIE2UI
diff --git a/examples/main-tab/main-tab.pro b/examples/main-tab/main-tab.pro
index a0df875..033a028 100644
--- a/examples/main-tab/main-tab.pro
+++ b/examples/main-tab/main-tab.pro
@@ -1,17 +1,17 @@
CONFIG += qt warn_on quick-app
TARGET = main-tab
HEADERS = simple.h
SOURCES = simple.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
# we now also include opie
-LIBS += -lqpe -lopieui2
+LIBS += -lqpe -lopiecore2 -lopieui2
include( $(OPIEDIR)/include.pro )
diff --git a/examples/main-tab/opie-simple.control b/examples/main-tab/opie-simple.control
index 8525a94..2046281 100644
--- a/examples/main-tab/opie-simple.control
+++ b/examples/main-tab/opie-simple.control
@@ -1,9 +1,9 @@
Package: opie-main-tab-example
Files: bin/main-tab apps/Examples/main-tab.desktop
Priority: optional
Section: opie/examples
Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org>
Architecture: arm
-Depends: task-opie-minimal, opie-pics
+Depends: task-opie-minimal, libopiecore2, libopieui2, opie-pics
Description: A simple example
Version: $QPE_VERSION$EXTRAVERSION
diff --git a/examples/main-tab/simple.cpp b/examples/main-tab/simple.cpp
index 7edb557..1e2d028 100644
--- a/examples/main-tab/simple.cpp
+++ b/examples/main-tab/simple.cpp
@@ -1,213 +1,212 @@
#include <qaction.h> // action
#include <qmenubar.h> // menubar
#include <qtoolbar.h> // toolbar
#include <qlabel.h> // a label
#include <qpushbutton.h> // the header file for the QPushButton
#include <qlayout.h>
#include <qpe/qpeapplication.h> // the QPEApplication
-#include <qpe/resource.h>
#include <qpe/sound.h>
#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching
+#include <opie2/oresource.h>
#include <opie2/otabwidget.h>
#include "simple.h"
/*
* implementation of simple
*/
/*
* The factory is used for quicklaunching
* It needs a constructor ( c'tor ) with at least QWidget, const char* and WFlags as parameter and a static QString appName() matching the TARGET of the .pro
*
* Depending on the global quick launch setting this will create
* either a main method or one for our component plugin system
*/
/* The OApplicationFactory is in the Opie::Core namespace */
using namespace Opie::Core;
OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl )
: QMainWindow( parent, name, fl ) {
setCaption(tr("My MainWindow") );
initUI();
/*
* Tab widget as central
*/
Opie::Ui::OTabWidget *tab = new Opie::Ui::OTabWidget(this);
connect(tab, SIGNAL(currentChanged(QWidget*) ),
this, SLOT( slotCurrentChanged(QWidget*) ) );
setCentralWidget( tab );
Simple1 *simple1 = new Simple1( this );
tab->addTab( simple1, "new", tr("Simple1") );
tab->setCurrentTab( tr("Simple1") );
Simple2 *simple2 = new Simple2( this );
tab->addTab( simple2, "trash", tr("Simple2") );
m_oldCurrent = simple1;
connect(m_fire, SIGNAL(activated() ),
simple1, SLOT(slotFire() ) );
}
MainWindow::~MainWindow() {
// again nothing to delete because Qt takes care
}
void MainWindow::setDocument( const QString& /*str*/ ) {
}
void MainWindow::slotCurrentChanged( QWidget *wid) {
disconnect(m_fire, SIGNAL(activated() ),
m_oldCurrent, SLOT(slotFire() ) );
connect(m_fire, SIGNAL(activated() ),
wid, SLOT(slotFire() ) );
m_oldCurrent = wid;
}
void MainWindow::initUI() {
setToolBarsMovable( false );
QToolBar *menuBarHolder = new QToolBar( this );
menuBarHolder->setHorizontalStretchable( true );
QMenuBar *mb = new QMenuBar( menuBarHolder );
QToolBar *tb = new QToolBar( this );
QPopupMenu *fileMenu = new QPopupMenu( this );
- QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"),
+ QAction *a = new QAction( tr("Quit"), Opie::Core::OResource::loadPixmap("quit_icon", Opie::Core::OResource::SmallIcon),
QString::null, 0, this, "quit_action" );
/*
* Connect quit to the QApplication quit slot
*/
connect(a, SIGNAL(activated() ),
qApp, SLOT(quit() ) );
a->addTo( fileMenu );
- a = new QAction(tr("Fire"),
- Resource::loadIconSet("new"),
+ a = new QAction(tr("Fire"), Opie::Core::OResource::loadPixmap("new", Opie::Core::OResource::SmallIcon),
QString::null, 0, this, "fire_button");
/* see the power? */
a->addTo( fileMenu );
a->addTo( tb );
m_fire = a;
mb->insertItem(tr("File"), fileMenu );
}
Simple1::Simple1( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl ) {
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setSpacing( 8 );
layout->setMargin( 11 );
QLabel *lbl = new QLabel( this, "a name for the label" );
lbl->setText( tr("Click on the button or follow the white rabbit") );
layout->addWidget( lbl );
m_button = new QPushButton(this);
m_button->setText( tr("Fire", "translatable quit string" ) );
layout->addWidget( m_button );
connect( m_button, SIGNAL(clicked() ),
this, SLOT( slotFire() ) );
}
Simple1::~Simple1() {
}
void Simple1::slotFire() {
/*
* NOTE: Simple is now a child window of MainWindow
* close will hide() Simple and not delete it. But as
* the mainwindow is shown all children will be shown as well
*/
close();
}
Simple2::Simple2( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl ) {
/*
* sets the caption of this toplevel widget
* put all translatable string into tr()
*/
setCaption(tr("My Simple Application") );
/*
* A simple vertical layout
* either call layout->setAutoAdd( true )
* or use layout->addWidget( wid ) to add widgets
*/
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setSpacing( 8 );
layout->setMargin( 11 );
/*
* creates a label
* The first parameter is this widget so the Label is a child
* of us and will be deleted when we're deleted.
*/
QLabel *lbl = new QLabel( this, "a name for the label" );
/*
- * Resource will search hard for a Pixmap in $OPIEDIR/pics
+ * OResource will search hard for a Pixmap in $OPIEDIR/pics
* to find 'logo/opielogo' You need to pass the subdir
* but not the ending
*/
- lbl->setPixmap( Resource::loadPixmap("logo/opielogo") );
+ lbl->setPixmap( Opie::Core::OResource::loadPixmap("logo/opielogo", Opie::Core::OResource::SmallIcon) );
layout->addWidget( lbl );
/* creates a button as child of this widget */
m_button = new QPushButton(this);
/*
* another way to call tr. The first parameter is the string
* to translate and the second a hint to the translator
*/
m_button->setText( tr("Fire", "translatable fire string" ) );
layout->addWidget( m_button );
connect( m_button, SIGNAL(clicked() ),
this, SLOT( slotQuit() ) );
}
Simple2::~Simple2() {
}
void Simple2::slotFire() {
/*
* We will fire up a sound
* Note that Sound will use Resource as well
* and we do not need to supply an ending
* sounds are found in $OPIEDIR/sounds
*/
Sound snd("hit_target01");
snd.play();
}