summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/batteryapplet/battery.cpp15
-rw-r--r--core/applets/cardmon/cardmon.cpp13
-rw-r--r--core/applets/cardmon/cardmon.h2
-rw-r--r--core/applets/clipboardapplet/clipboard.cpp196
-rw-r--r--core/applets/volumeapplet/volume.cpp5
5 files changed, 26 insertions, 205 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp
index 3b329c6..f3a95ed 100644
--- a/core/applets/batteryapplet/battery.cpp
+++ b/core/applets/batteryapplet/battery.cpp
@@ -1,152 +1,153 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "battery.h"
#include "batterystatus.h"
#include <qpe/power.h>
+#include <qpe/applnk.h>
#include <qpainter.h>
#include <qtimer.h>
BatteryMeter::BatteryMeter( QWidget *parent )
: QWidget( parent ), charging(false)
{
ps = new PowerStatus;
startTimer( 10000 );
- setFixedHeight(12);
+ setFixedHeight( AppLnk::smallIconSize() );
chargeTimer = new QTimer( this );
connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) );
timerEvent(0);
}
BatteryMeter::~BatteryMeter()
{
delete ps;
}
QSize BatteryMeter::sizeHint() const
{
- return QSize(10,12);
+ return QSize(10, height() );
}
void BatteryMeter::mouseReleaseEvent( QMouseEvent *)
{
if ( batteryView && batteryView->isVisible() ) {
delete (QWidget *) batteryView;
} else {
if ( !batteryView )
batteryView = new BatteryStatus( ps );
batteryView->showMaximized();
batteryView->raise();
batteryView->show();
}
}
void BatteryMeter::timerEvent( QTimerEvent * )
{
PowerStatus prev = *ps;
*ps = PowerStatusManager::readStatus();
if ( prev != *ps ) {
percent = ps->batteryPercentRemaining();
if ( !charging && ps->batteryStatus() == PowerStatus::Charging && percent < 0 ) {
percent = 0;
charging = true;
chargeTimer->start( 500 );
} else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) {
charging = false;
chargeTimer->stop();
if ( batteryView )
batteryView->updatePercent( percent );
}
repaint(FALSE);
if ( batteryView )
batteryView->repaint();
}
}
void BatteryMeter::chargeTimeout()
{
percent += 20;
if ( percent > 100 )
percent = 0;
repaint(FALSE);
if ( batteryView )
batteryView->updatePercent( percent );
}
void BatteryMeter::paintEvent( QPaintEvent* )
{
QPainter p(this);
QColor c;
QColor darkc;
QColor lightc;
if ( ps->acStatus() == PowerStatus::Offline ) {
c = blue.light(120);
darkc = c.dark(120);
lightc = c.light(140);
} else if ( ps->acStatus() == PowerStatus::Online ) {
c = green.dark(130);
darkc = c.dark(120);
lightc = c.light(180);
} else {
c = red;
darkc = c.dark(120);
lightc = c.light(160);
}
- int w = 6;
- int h = height()-3;
+ int w = height() / 2 ;
+ int h = height() - 4;
int pix = (percent * h) / 100;
- int y2 = height() - 2;
+ int y2 = height() -2;
int y = y2 - pix;
- int x1 = (width() - w) / 2;
+ int x1 = (width() - w ) / 2;
p.setPen(QColor(80,80,80));
p.drawLine(x1+w/4,0,x1+w/4+w/2,0);
p.drawRect(x1,1,w,height()-1);
p.setBrush(c);
int extra = ((percent * h) % 100)/(100/4);
#define Y(i) ((i<=extra)?y-1:y)
#define DRAWUPPER(i) if ( Y(i) >= 2 ) p.drawLine(i+x1,2,i+x1,Y(i));
p.setPen( gray );
DRAWUPPER(1);
DRAWUPPER(3);
p.setPen( gray.light(130) );
DRAWUPPER(2);
p.setPen( gray.dark(120) );
DRAWUPPER(4);
-#define DRAW(i) { if ( Y(i) < y2 ) p.drawLine(i+x1,Y(i)+1,i+x1,y2); }
+#define DRAW(i) { if ( Y(i) < y2 ) p.drawLine(i+x1,Y(i)+1, i+x1,y2); }
p.setPen( c );
DRAW(1);
DRAW(3);
p.setPen( lightc );
DRAW(2);
p.setPen(darkc);
DRAW(4);
}
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp
index f3f9044..b8c4553 100644
--- a/core/applets/cardmon/cardmon.cpp
+++ b/core/applets/cardmon/cardmon.cpp
@@ -1,344 +1,349 @@
/*
* cardmon.cpp
*
* ---------------------
*
* copyright : (c) 2002 by Maximilian Reiss
* email : max.reiss@gmx.de
* based on two apps by Devin Butterfield
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "cardmon.h"
#include <qpe/resource.h>
#include <opie/odevice.h>
+#include <qpe/applnk.h>
+
#include <qcopchannel_qws.h>
#include <qpainter.h>
#include <qmessagebox.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qtimer.h>
#include <qapplication.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <qsound.h>
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
#include <sys/vfs.h>
#include <mntent.h>
#endif
using namespace Opie;
CardMonitor::CardMonitor(QWidget * parent):QWidget(parent),
-pm(Resource::
- loadPixmap("cardmon/pcmcia"))
+ pm( Resource::loadPixmap("cardmon/pcmcia") )
{
QCopChannel *pcmciaChannel = new QCopChannel("QPE/Card", this);
connect(pcmciaChannel,
SIGNAL(received(const QCString &, const QByteArray &)), this,
SLOT(cardMessage(const QCString &, const QByteArray &)));
QCopChannel *sdChannel = new QCopChannel("QPE/Card", this);
connect(sdChannel,
SIGNAL(received(const QCString &, const QByteArray &)), this,
SLOT(cardMessage(const QCString &, const QByteArray &)));
cardInPcmcia0 = FALSE;
cardInPcmcia1 = FALSE;
cardInSd = FALSE;
- setFixedSize(pm.size());
+ setFocusPolicy( NoFocus );
+
+ setFixedWidth ( AppLnk::smallIconSize() );
+ setFixedHeight ( AppLnk::smallIconSize() );
+
getStatusPcmcia(TRUE);
getStatusSd(TRUE);
repaint(FALSE);
popupMenu = 0;
}
CardMonitor::~CardMonitor()
{
if (popupMenu) {
delete popupMenu;
}
}
void CardMonitor::popUp(QString message, QString icon)
{
if (!popupMenu) {
popupMenu = new QPopupMenu(this);
}
popupMenu->clear();
if (icon.isEmpty()) {
popupMenu->insertItem(message, 0);
} else {
popupMenu->insertItem(QIconSet(Resource::loadPixmap(icon)),
message, 0);
}
QPoint p = mapToGlobal(QPoint(0, 0));
QSize s = popupMenu->sizeHint();
popupMenu->popup(QPoint(p.x() + (width() / 2) - (s.width() / 2),
p.y() - s.height()), 0);
QTimer::singleShot(2000, this, SLOT(popupTimeout()));
}
void CardMonitor::popupTimeout()
{
popupMenu->hide();
}
void CardMonitor::mousePressEvent(QMouseEvent *)
{
QPopupMenu *menu = new QPopupMenu(this);
QString cmd;
int err = 0;
if (cardInSd) {
menu->insertItem(QIconSet(Resource::loadPixmap("cardmon/ide")),
tr("Eject SD/MMC card"), 0);
}
if (cardInPcmcia0) {
menu->
insertItem(QIconSet
(Resource::loadPixmap("cardmon/" + cardInPcmcia0Type)),
tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1);
}
if (cardInPcmcia1) {
menu->
insertItem(QIconSet
(Resource::loadPixmap("cardmon/" + cardInPcmcia1Type)),
tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2);
}
QPoint p = mapToGlobal(QPoint(0, 0));
QSize s = menu->sizeHint();
int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2),
p.y() - s.height()), 0);
if (opt == 1) {
cmd = "/sbin/cardctl eject 0";
err = system((const char *) cmd);
if (err != 0) {
qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d",
err);
popUp(tr("CF/PCMCIA card eject failed!"));
}
} else if (opt == 0) {
if (ODevice::inst()->system() == System_Familiar) {
cmd = "umount /dev/mmc/part1";
} else {
cmd = "umount /dev/mmcda1";
}
err = system((const char *) cmd);
if (err != 0) {
popUp(tr("SD/MMC card eject failed!"));
}
} else if (opt == 2) {
cmd = "/sbin/cardctl eject 1";
err = system((const char *) cmd);
if (err != 0) {
qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d",
err);
popUp(tr("CF/PCMCIA card eject failed!"));
}
}
delete menu;
}
void CardMonitor::cardMessage(const QCString & msg, const QByteArray &)
{
if (msg == "stabChanged()") {
// qDebug("Pcmcia: stabchanged");
getStatusPcmcia();
} else if (msg == "mtabChanged()") {
// qDebug("CARDMONAPPLET: mtabchanged");
getStatusSd();
}
}
bool CardMonitor::getStatusPcmcia(int showPopUp)
{
bool cardWas0 = cardInPcmcia0; // remember last state
bool cardWas1 = cardInPcmcia1;
QString fileName;
// one of these 3 files should exist
if (QFile::exists("/var/run/stab")) {
fileName = "/var/run/stab";
} else if (QFile::exists("/var/state/pcmcia/stab")) {
fileName = "/var/state/pcmcia/stab";
} else {
fileName = "/var/lib/pcmcia/stab";
}
QFile f(fileName);
if (f.open(IO_ReadOnly)) {
QStringList list;
QTextStream stream(&f);
QString streamIn;
streamIn = stream.read();
list = QStringList::split("\n", streamIn);
for (QStringList::Iterator line = list.begin(); line != list.end();
line++) {
if ((*line).startsWith("Socket 0:")) {
if ((*line).startsWith("Socket 0: empty") && cardInPcmcia0) {
cardInPcmcia0 = FALSE;
} else if (!(*line).startsWith("Socket 0: empty")
&& !cardInPcmcia0) {
cardInPcmcia0Name =
(*line).mid(((*line).find(':') + 1),
(*line).length() - 9);
cardInPcmcia0Name.stripWhiteSpace();
cardInPcmcia0 = TRUE;
show();
line++;
int pos = (*line).find('\t') + 1;
cardInPcmcia0Type =
(*line).mid(pos, (*line).find("\t", pos) - pos);
}
} else if ((*line).startsWith("Socket 1:")) {
if ((*line).startsWith("Socket 1: empty") && cardInPcmcia1) {
cardInPcmcia1 = FALSE;
} else if (!(*line).startsWith("Socket 1: empty")
&& !cardInPcmcia1) {
cardInPcmcia1Name =
(*line).mid(((*line).find(':') + 1),
(*line).length() - 9);
cardInPcmcia1Name.stripWhiteSpace();
cardInPcmcia1 = TRUE;
show();
line++;
int pos = (*line).find('\t') + 1;
cardInPcmcia1Type =
(*line).mid(pos, (*line).find("\t", pos) - pos);
}
}
}
f.close();
if (!showPopUp
&& (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) {
QString text = QString::null;
QString what = QString::null;
if (cardWas0 != cardInPcmcia0) {
if (cardInPcmcia0) {
text += tr("New card: ");
what = "on";
} else {
text += tr("Ejected: ");
what = "off";
}
text += cardInPcmcia0Name;
popUp(text, "cardmon/" + cardInPcmcia0Type);
}
if (cardWas1 != cardInPcmcia1) {
if (cardInPcmcia1) {
text += tr("New card: ");
what = "on";
} else {
text += tr("Ejected: ");
what = "off";
}
text += cardInPcmcia1Name;
popUp(text, "cardmon/" + cardInPcmcia1Type);
}
QSound::play(Resource::findSound("cardmon/card" + what));
}
} else {
// no file found
qDebug("no file found");
cardInPcmcia0 = FALSE;
cardInPcmcia1 = FALSE;
}
repaint( FALSE );
return ((cardWas0 == cardInPcmcia0
&& cardWas1 == cardInPcmcia1) ? FALSE : TRUE);
}
bool CardMonitor::getStatusSd(int showPopUp)
{
bool cardWas = cardInSd; // remember last state
cardInSd = FALSE;
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
struct mntent *me;
FILE *mntfp = setmntent("/etc/mtab", "r");
if (mntfp) {
while ((me = getmntent(mntfp)) != 0) {
QString fs = me->mnt_fsname;
//qDebug( fs );
if (fs.left(14) == "/dev/mmc/part1" || fs.left(7) == "/dev/sd"
|| fs.left(9) == "/dev/mmcd") {
cardInSd = TRUE;
show();
}
// else {
// cardInSd = FALSE;
// }
}
endmntent(mntfp);
}
if (!showPopUp && cardWas != cardInSd) {
QString text = QString::null;
QString what = QString::null;
if (cardInSd) {
text += "New card: SD/MMC";
what = "on";
} else {
text += "Ejected: SD/MMC";
what = "off";
}
//qDebug("TEXT: " + text );
QSound::play(Resource::findSound("cardmon/card" + what));
popUp(text, "cardmon/ide"); // XX add SD pic
}
#else
#error "Not on Linux"
#endif
repaint( FALSE );
return ((cardWas == cardInSd) ? FALSE : TRUE);
}
void CardMonitor::paintEvent(QPaintEvent *)
{
QPainter p(this);
if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) {
- p.drawPixmap(0, 0, pm);
+ p.drawPixmap(0, 0, pm );
show();
} else {
//p.eraseRect(rect());
hide();
}
}
diff --git a/core/applets/cardmon/cardmon.h b/core/applets/cardmon/cardmon.h
index 49bcae8..4f00920 100644
--- a/core/applets/cardmon/cardmon.h
+++ b/core/applets/cardmon/cardmon.h
@@ -1,58 +1,58 @@
/*
* cardmon.h
*
* ---------------------
*
- * copyright : (c) 2002 by Maximilian Reiss
+ * copyright : (c) 2003 by Maximilian Reiss
* email : max.reiss@gmx.de
* based on two apps by Devin Butterfield
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef CARDMON_H
#define CARDMON_H
#include <qwidget.h>
#include <qpixmap.h>
#include <qpopupmenu.h>
class CardMonitor : public QWidget {
Q_OBJECT
public:
CardMonitor( QWidget *parent = 0 );
~CardMonitor();
bool getStatusPcmcia( int showPopUp = FALSE );
bool getStatusSd( int showPopUp = FALSE );
private slots:
void cardMessage( const QCString &msg, const QByteArray & );
void popupTimeout();
protected:
void paintEvent( QPaintEvent* );
void mousePressEvent( QMouseEvent * );
private:
QPixmap pm;
// pcmcia socket 0
bool cardInPcmcia0;
QString cardInPcmcia0Name;
QString cardInPcmcia0Type;
// pcmcia socket 1
bool cardInPcmcia1;
QString cardInPcmcia1Name;
QString cardInPcmcia1Type;
bool cardInSd;
void iconShow();
QPopupMenu *popupMenu;
void popUp(QString message, QString icon = QString::null );
};
#endif
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp
index b83e16e..21b68e3 100644
--- a/core/applets/clipboardapplet/clipboard.cpp
+++ b/core/applets/clipboardapplet/clipboard.cpp
@@ -1,358 +1,172 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "clipboard.h"
#include <qpe/resource.h>
+#include <qpe/applnk.h>
#include <qpainter.h>
#include <qpopupmenu.h>
#include <qwindowsystem_qws.h>
#include <qapplication.h>
#include <qclipboard.h>
#include <qtimer.h>
//===========================================================================
-/* XPM */
-static const char * paste_xpm[] = {
-"14 16 167 2",
-" c None",
-". c #96A0AC",
-"+ c #9BB0D4",
-"@ c #5E7095",
-"# c #F1CA79",
-"$ c #EFC56D",
-"% c #C9AF76",
-"& c #9FABBA",
-"* c #AEBFDD",
-"= c #8899BA",
-"- c #726E68",
-"; c #D19A33",
-"> c #DA9524",
-", c #EFC065",
-"' c #F3DDA6",
-") c #E9D192",
-"! c #ADA895",
-"~ c #9AA8BF",
-"{ c #B4C2D8",
-"] c #AEBED7",
-"^ c #797E8A",
-"/ c #B78534",
-"( c #DE8516",
-"_ c #8A4308",
-": c #F0C470",
-"< c #F5EFD3",
-"[ c #DFD7B4",
-"} c #8F9BA6",
-"| c #7C8BA3",
-"1 c #808A9A",
-"2 c #828892",
-"3 c #727582",
-"4 c #9A6435",
-"5 c #F37004",
-"6 c #A24104",
-"7 c #F0C36E",
-"8 c #F4EBCC",
-"9 c #ECDCAF",
-"0 c #CDC29B",
-"a c #C1B486",
-"b c #C3A86B",
-"c c #B8924A",
-"d c #B17B31",
-"e c #C66C1C",
-"f c #DE6610",
-"g c #944311",
-"h c #F3E8C6",
-"i c #F3E0AB",
-"j c #F2DB9B",
-"k c #F1D382",
-"l c #F0C056",
-"m c #CCA354",
-"n c #B7B09D",
-"o c #C2A898",
-"p c #BCA298",
-"q c #9A959F",
-"r c #526C8F",
-"s c #F3E4B9",
-"t c #F3DA99",
-"u c #F4D78A",
-"v c #F5CA6A",
-"w c #F4B032",
-"x c #C19A56",
-"y c #C2D7EA",
-"z c #C0D0E7",
-"A c #B0C6E8",
-"B c #A6C1EB",
-"C c #6AA1E3",
-"D c #F0C36D",
-"E c #F3E2B0",
-"F c #F3D891",
-"G c #F3CF7A",
-"H c #F4BC4C",
-"I c #F3A51C",
-"J c #BC9758",
-"K c #CAE4FE",
-"L c #C5DDFB",
-"M c #B5D3FB",
-"N c #A8CCFC",
-"O c #63A6F6",
-"P c #2180E3",
-"Q c #F3E1AE",
-"R c #F3D488",
-"S c #F3C664",
-"T c #F4B63C",
-"U c #F2A61C",
-"V c #BC9A5C",
-"W c #CCE6FE",
-"X c #C8DEFB",
-"Y c #B9D6FB",
-"Z c #B2D0FC",
-"` c #84B6FB",
-" . c #479DFB",
-".. c #F3DFAC",
-"+. c #F3CC76",
-"@. c #F3BE52",
-"#. c #F4B53A",
-"$. c #F2AB24",
-"%. c #BC9D61",
-"&. c #CBE5FE",
-"*. c #C3DBFB",
-"=. c #B0D0FB",
-"-. c #ACCBFC",
-";. c #A0C3FD",
-">. c #6EB1FF",
-",. c #F3DCA4",
-"'. c #F3C35F",
-"). c #F3BC4A",
-"!. c #F3AC26",
-"~. c #BC9E63",
-"{. c #CAE4FF",
-"]. c #BCD7FB",
-"^. c #A3C7FB",
-"/. c #94BCFB",
-"(. c #92BAFB",
-"_. c #74B4FE",
-":. c #F1C46D",
-"<. c #F4D99A",
-"[. c #F4BE52",
-"}. c #F4BB47",
-"|. c #F4B63D",
-"1. c #F4AD27",
-"2. c #BC9E64",
-"3. c #CAE5FF",
-"4. c #BAD6FB",
-"5. c #A1C5FB",
-"6. c #9AC1FB",
-"7. c #9DC1FC",
-"8. c #7CBAFE",
-"9. c #F5C870",
-"0. c #F8DC9B",
-"a. c #F8C65C",
-"b. c #F8C252",
-"c. c #F8BE49",
-"d. c #F7B534",
-"e. c #BFA46C",
-"f. c #CBE4FF",
-"g. c #B7D3FB",
-"h. c #A4C6FB",
-"i. c #A0C4FB",
-"j. c #A2C4FC",
-"k. c #80BDFF",
-"l. c #BC9250",
-"m. c #BF9461",
-"n. c #BD8944",
-"o. c #BD863D",
-"p. c #BD8438",
-"q. c #BC7C2C",
-"r. c #988269",
-"s. c #C5E7FF",
-"t. c #C0DDFE",
-"u. c #B2D4FE",
-"v. c #ACD1FE",
-"w. c #ACD0FE",
-"x. c #7DC0FF",
-"y. c #805835",
-"z. c #754D26",
-"A. c #754C22",
-"B. c #754B20",
-"C. c #75471A",
-"D. c #534D4F",
-"E. c #619BCE",
-"F. c #6295C8",
-"G. c #5C91C8",
-"H. c #598FC8",
-"I. c #588FC8",
-"J. c #3E87CD",
-" . + @ ",
-" # $ % & * = - ; > ",
-", ' ) ! ~ { ] ^ / ( _ ",
-": < [ } | 1 2 3 4 5 6 ",
-"7 8 9 0 a b c d e f g ",
-"7 h i j k l m n o p q r ",
-"7 s t u v w x y z A B C ",
-"D E F G H I J K L M N O P ",
-"D Q R S T U V W X Y Z ` . ",
-"D ..+.@.#.$.%.&.*.=.-.;.>. ",
-"7 ,.'.).T !.~.{.].^./.(._. ",
-":.<.[.}.|.1.2.3.4.5.6.7.8. ",
-"9.0.a.b.c.d.e.f.g.h.i.j.k. ",
-"l.m.n.o.p.q.r.s.t.u.v.w.x. ",
-" y.z.A.B.C.D.E.F.G.H.I.J. ",
-" "};
-
ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name )
{
- setFixedWidth ( 14 );
- setFixedHeight ( 18 );
- m_clipboardPixmap = QPixmap ( paste_xpm );
+ setFixedWidth ( AppLnk::smallIconSize() );
+ setFixedHeight ( AppLnk::smallIconSize() );
+ m_clipboardPixmap = QPixmap ( Resource::loadPixmap( "paste" ) );
m_timer = new QTimer ( this );
connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( )));
connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( )));
connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( )));
m_menu = 0;
m_dirty = true;
m_lasttext = QString::null;
m_timer-> start ( 0, true );
}
ClipboardApplet::~ClipboardApplet ( )
{
}
void ClipboardApplet::shutdown ( )
{
// the timer has to be stopped, or Qt/E will hang on quit()
// see launcher/desktop.cpp
m_timer-> stop ( );
}
void ClipboardApplet::mousePressEvent ( QMouseEvent *)
{
if ( m_dirty ) {
delete m_menu;
m_menu = new QPopupMenu ( this );
m_menu-> setCheckable ( true );
if ( m_history. count ( )) {
for ( unsigned int i = 0; i < m_history. count ( ); i++ ) {
QString str = m_history [i];
if ( str. length ( ) > 20 )
str = str. left ( 20 ) + "...";
m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i );
m_menu-> setItemChecked ( i, false );
}
m_menu-> setItemChecked ( m_history. count ( ) - 1, true );
m_menu-> insertSeparator ( );
}
m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 );
m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 );
m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 );
connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int )));
m_dirty = false;
}
QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
QSize s = m_menu-> sizeHint ( );
m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )));
}
void ClipboardApplet::action(int id)
{
ushort unicode = 0;
int scan = 0;
switch ( id ) {
case 100:
unicode = 'X' - '@';
scan = Key_X; // Cut
break;
case 101:
unicode = 'C' - '@';
scan = Key_C; // Copy
break;
case 102:
unicode = 'V' - '@';
scan = Key_V; // Paste
break;
default:
if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) {
QApplication::clipboard ( )-> setText ( m_history [id] );
for ( uint i = 0; i < m_history. count ( ); i++ )
m_menu-> setItemChecked ( i, i == uint( id ));
unicode = 'V' - '@';
scan = Key_V;
}
break;
}
if ( scan ) {
qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false );
qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false );
}
}
void ClipboardApplet::paintEvent ( QPaintEvent* )
{
QPainter p ( this );
- p. drawPixmap ( 0, 1, m_clipboardPixmap );
+ p. drawPixmap( 0, 1, m_clipboardPixmap );
}
void ClipboardApplet::newData ( )
{
static bool excllock = false;
if ( excllock )
return;
else
excllock = true;
m_timer-> stop ( );
QCString type = "plain";
QString txt = QApplication::clipboard ( )-> text ( type );
if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) {
m_history. append ( txt );
if ( m_history. count ( ) > 5 )
m_history. remove ( m_history. begin ( ));
m_dirty = true;
}
m_timer-> start ( 1500, true );
excllock = false;
}
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index ed07ec4..906bb77 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -1,218 +1,219 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <stdio.h>
#include "volume.h"
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
+#include <qpe/applnk.h>
#include <qpe/config.h>
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
#include <qpe/qcopenvelope_qws.h>
#endif
#include <qpainter.h>
#include <qcheckbox.h>
#include <qslider.h>
#include <qlayout.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qvbox.h>
#include <qlabel.h>
#include <qtoolbutton.h>
#include <qpushbutton.h>
#include <qtimer.h>
#include <opie/odevice.h>
#include "oledbox.h"
using namespace Opie;
#define RATE_TIMER_INTERVAL 100
// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time
// results in "hanging" buttons on the iPAQ due to quite high CPU consumption.
/* XPM */
static const char * vol_xpm[] = {
"20 20 3 1",
" c None",
". c #0000FF",
"+ c #000000",
" ",
" . ",
" . . . . ",
" . . . . . . ",
" . . . . . . . ",
" . . ..... . . ",
" . ... ..... ... ",
" ........... .... ",
" ................. ",
"++++++++++++++++++++",
" .................. ",
" . ............. . ",
" . ..... ....... ",
" . ... ..... . ",
" . ... ..... . ",
" . ... ..... ",
" . . . . . ",
" . . . ",
" . . . ",
" "};
/* XPM */
static const char * mic_xpm[] = {
"20 20 21 1",
" c None",
". c #000000",
"+ c #EEEEEE",
"@ c #B4B6B4",
"# c #8B8D8B",
"$ c #D5D6D5",
"% c #E6E6E6",
"& c #9C9D9C",
"* c #6A696A",
"= c #E6E2E6",
"- c #F6F2F6",
"; c #CDC6CD",
"> c #737573",
", c #4A484A",
"' c #DEDEDE",
") c #F6EEF6",
"! c #414041",
"~ c #202020",
"{ c #ACAEAC",
"] c #838583",
"^ c #6A656A",
" ",
" .... ",
" .+@+#. ",
" ..$%&%*. ",
" .=-.;=>=,. ",
" .'+).&+!+. ",
" .+;+;.~+~. ",
" ..%{%,.... ",
" ..&=>=~.. ",
" .+..]^,.. ",
" .+....... ",
" .%... ",
" .=... ",
" .+... ",
" .+... ",
" .... ",
" .... ",
" .. ",
" . ",
". "};
static const char * bass_xpm[] = {
"20 20 3 1",
" c None",
". c #000000",
"+ c #0000FF",
" ",
" ",
" ",
"..... +++ ......",
" +++++++ ",
" ++ ++ ",
"... ++ ... ++ ++ .",
" +++ ++ ++ ",
" ++++ ++ ",
"... ++++ .. ++ .....",
" ++ ++ ",
" ++ ++ ",
"..........++ ++ .",
" ++ ",
" ++ ",
"...... ++ .........",
" + ",
" ",
" ",
" "};
static const char * treble_xpm[] = {
"20 20 3 1",
" c None",
". c #0000FF",
"+ c #000000",
" .. ",
" . .. ",
" . .. ",
"++++++++ . .. ++++++",
" . . ",
" ... ",
"++++++++ . +++++++",
" .. ",
" .. . ",
"+++ .. ... +++++++",
" .. .. .. ",
" .. . . .. ",
"+++ .. . . + . +++++",
" .. . .. ",
" .. . .. ",
"++++ ...... +++++++",
" . ",
" .. . ",
" .. . ",
" .. "};
/* XPM */
static const char * alarm_xpm[] = {
"20 20 33 1",
" c None",
". c #080602",
"+ c #AAA602",
"@ c #252002",
"# c #434202",
"$ c #795602",
"% c #C3C20D",
"& c #DADAC2",
"* c #826002",
"= c #740502",
"- c #D6D602",
"; c #322E02",
"> c #826A02",
", c #F1F195",
"' c #959215",
") c #423602",
"! c #4B0302",
"~ c #844315",
"{ c #AAAA2A",
"] c #E2DE42",
"^ c #BA7E04",
"/ c #7F7502",
"( c #828276",
"_ c #FEFE4E",
": c #7D1902",
"< c #989656",
"[ c #260B02",
"} c #F7F7D8",
"| c #DCDA5A",
"1 c #823102",
"2 c #B1AC6B",
"3 c #F7F710",
@@ -536,247 +537,247 @@ void VolumeControl::readConfig ( bool force )
bool old_st = m_snd_touch;
bool old_sa = m_snd_alarm;
int old_ap = m_alarm_percent;
m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 );
m_mic_percent = cfg. readNumEntry ( "Mic", 50 );
m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 );
m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 );
m_vol_muted = cfg. readBoolEntry ( "Mute", 0 );
m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 );
m_snd_key = cfg. readBoolEntry ( "KeySound", 0 );
m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 );
m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 );
m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 );
if ( force || ( m_vol_percent != old_vp ))
volSlider-> setValue ( 100 - m_vol_percent );
if ( force || ( m_mic_percent != old_mp ))
micSlider-> setValue ( 100 - m_mic_percent );
if ( force || ( m_alarm_percent != old_ap ))
alarmSlider-> setValue ( 100 - m_alarm_percent );
if ( force || ( m_bass_percent != old_bass ))
bassSlider-> setValue ( 100 - m_bass_percent );
if ( force || ( m_treble_percent != old_treble ))
trebleSlider-> setValue ( 100 - m_treble_percent );
if ( force || ( m_vol_muted != old_vm ))
volLed-> setOn ( !m_vol_muted );
if ( force || ( m_mic_muted != old_mm ))
micLed-> setOn ( !m_mic_muted );
if ( force || ( m_snd_alarm != old_sa ))
alarmLed-> setOn ( m_snd_alarm );
if ( force || ( m_snd_key != old_sk ))
keyBox-> setChecked ( m_snd_key );
if ( force || ( m_snd_touch != old_st ))
tapBox-> setChecked ( m_snd_touch );
if ( force || ( m_snd_alarm != old_sa ))
alarmBox-> setChecked ( m_snd_alarm );
}
void VolumeControl::volumeChanged ( bool /*nowMuted*/ )
{
int prevVol = m_vol_percent;
bool prevMute = m_vol_muted;
readConfig ( );
// Handle case where muting it toggled
if ( m_vol_muted != prevMute )
m_icon-> redraw ( true );
else if ( prevVol != m_vol_percent ) // Avoid over repainting
m_icon-> redraw ( false );
}
void VolumeControl::micChanged ( bool nowMuted )
{
if ( !nowMuted )
readConfig ( );
m_mic_muted = nowMuted;
}
void VolumeControl::screenTapToggled ( bool b )
{
m_snd_touch = b;
writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol );
}
void VolumeControl::keyClickToggled ( bool b )
{
m_snd_key = b;
writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol );
}
void VolumeControl::alarmSoundToggled ( bool b )
{
m_snd_alarm = b;
writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
}
void VolumeControl::volMuteToggled ( bool b )
{
m_vol_muted = !b;
m_icon-> redraw ( true );
writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol );
}
void VolumeControl::micMuteToggled ( bool b )
{
m_mic_muted = !b;
writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
}
void VolumeControl::volMoved ( int percent )
{
m_vol_percent = 100 - percent;
// clamp volume percent to be between 0 and 100
m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent );
// repaint just the little volume rectangle
m_icon-> redraw ( false );
writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol );
}
void VolumeControl::micMoved ( int percent )
{
m_mic_percent = 100 - percent;
// clamp volume percent to be between 0 and 100
m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent );
writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic );
}
void VolumeControl::alarmMoved ( int percent )
{
m_alarm_percent = 100 - percent;
// clamp volume percent to be between 0 and 100
m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent );
writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
}
void VolumeControl::bassMoved ( int percent )
{
m_bass_percent = 100 - percent;
// clamp bass percent to be between 0 and 100
m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent );
writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass );
}
void VolumeControl::trebleMoved ( int percent )
{
m_treble_percent = 100 - percent;
// clamp treble percent to be between 0 and 100
m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent );
writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble );
}
void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd )
{
Config cfg ( "qpe" );
cfg. setGroup ( "Volume" );
cfg. writeEntry ( entry, val );
// cfg. write ( );
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
switch ( upd ) {
case UPD_Vol: {
QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted;
break;
}
case UPD_Mic: {
QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted;
break;
}
case UPD_Bass: {
QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true;
break;
}
case UPD_Treble: {
QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true;
break;
}
case UPD_None:
break;
}
#endif
}
//===========================================================================
VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
: QWidget( parent, name )
{
- setFixedHeight ( 18 );
- setFixedWidth ( 14 );
+ setFixedWidth ( AppLnk::smallIconSize() );
+ setFixedHeight ( AppLnk::smallIconSize() );
m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" ));
m_dialog = new VolumeControl ( this, true, this, "volumecontrol" );
connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool )));
connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool )));
}
VolumeApplet::~VolumeApplet()
{
delete m_pixmap;
}
void VolumeApplet::mousePressEvent ( QMouseEvent * )
{
if ( m_dialog-> isVisible ( ))
m_dialog-> hide ( );
else
m_dialog-> show ( true );
}
void VolumeApplet::redraw ( bool all )
{
if ( all )
repaint ( true );
else
repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false );
}
void VolumeApplet::paintEvent ( QPaintEvent * )
{
QPainter p ( this );
p. drawPixmap ( 0, 1, *m_pixmap );
p. setPen ( darkGray );
p. drawRect ( 1, height() - 4, width() - 2, 4 );
int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100;
p. fillRect ( 2, height() - 3, pixelsWide, 2, red );
p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray );
if ( m_dialog-> volMuted ( )) {
p. setPen ( red );
p. drawLine ( 1, 2, width() - 2, height() - 5 );
p. drawLine ( 1, 3, width() - 2, height() - 4 );
p. drawLine ( width() - 2, 2, 1, height() - 5 );
p. drawLine ( width() - 2, 3, 1, height() - 4 );
}
}