From 2abe1e6f4022109b1e179242aa9765810d7f680c Mon Sep 17 00:00:00 2001 From: tpearson Date: Fri, 18 Dec 2009 02:32:16 +0000 Subject: * ark context un[tar/zip/bz] crash repair * gcc4.4 compilation fixes * superkaramba xmms sensor addition * automake updates git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1063396 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- ark/arch.cpp | 4 +- ark/ark_part.desktop | 1 + ark/arkwidget.cpp | 9 ++- ark/arkwidget.h | 1 + ark/rar.cpp | 11 ++- kcharselect/KCharSelect.desktop | 2 +- klaptopdaemon/acpi.cpp | 10 +-- klaptopdaemon/acpi_helper.cpp | 20 ++++-- klaptopdaemon/apm.cpp | 12 +--- klaptopdaemon/daemondock.cpp | 8 +-- klaptopdaemon/laptop_daemon.cpp | 4 +- klaptopdaemon/portable.cpp | 36 +++++----- kmilo/generic/generic_monitor.cpp | 84 ++++++++++++++++++++++ kmilo/generic/generic_monitor.h | 14 ++++ kmilo/kmilod/defaultskin.cpp | 32 +++++++++ kmilo/kmilod/defaultskin.h | 1 + kmilo/kmilod/defaultwidget.ui | 127 +++------------------------------ kregexpeditor/kregexpeditor.desktop | 2 +- superkaramba/src/Makefile.am | 8 +-- superkaramba/src/xmmssensor.cpp | 138 +++++++++++++++++++++++++++++++++--- superkaramba/src/xmmssensor.h | 3 + 21 files changed, 341 insertions(+), 186 deletions(-) diff --git a/ark/arch.cpp b/ark/arch.cpp index 8ff6a2b..999647a 100644 --- a/ark/arch.cpp +++ b/ark/arch.cpp @@ -262,7 +262,9 @@ void Arch::slotReceivedTOC( KProcess*, char* data, int length ) break; // We are done all the complete lines data[ lfChar ] = '\0'; - m_buffer.append( data + startChar ); + + m_buffer.append( QString::fromUtf8(data + startChar).latin1() ); + data[ lfChar ] = '\n'; startChar = lfChar + 1; diff --git a/ark/ark_part.desktop b/ark/ark_part.desktop index e167f26..625aeb7 100644 --- a/ark/ark_part.desktop +++ b/ark/ark_part.desktop @@ -133,3 +133,4 @@ Icon=ark Type=Service ServiceTypes=KParts/ReadOnlyPart X-KDE-Library=libarkpart +Hidden=true diff --git a/ark/arkwidget.cpp b/ark/arkwidget.cpp index d0fa3d4..5720317 100644 --- a/ark/arkwidget.cpp +++ b/ark/arkwidget.cpp @@ -117,6 +117,7 @@ ArkWidget::ArkWidget( QWidget *parent, const char *name ) m_bIsSimpleCompressedFile( false ), m_bDropSourceIsSelf( false ), m_extractList( 0 ) { + m_settingsAltered = false; m_tmpDir = new KTempDir( locateLocal( "tmp", "ark" ) ); if ( m_tmpDir->status() != 0 ) @@ -155,12 +156,14 @@ ArkWidget::~ArkWidget() delete m_fileListView; m_fileListView = 0; delete arch; - ArkSettings::writeConfig(); + if (m_settingsAltered) { + ArkSettings::writeConfig(); + } } void ArkWidget::cleanArkTmpDir() { - removeDownloadedFiles(); + removeDownloadedFiles(); if ( m_tmpDir ) { m_tmpDir->unlink(); @@ -2257,6 +2260,8 @@ void ArkWidget::showSettings(){ genPage->konqIntegrationLabel->setText( QString::null ); dialog->show(); + + m_settingsAltered = true; } #include "arkwidget.moc" diff --git a/ark/arkwidget.h b/ark/arkwidget.h index d64bbd0..435fafa 100644 --- a/ark/arkwidget.h +++ b/ark/arkwidget.h @@ -242,6 +242,7 @@ private: // data bool m_bBusy; bool m_bBusyHold; + bool m_settingsAltered; // for use in the edit methods: the url. QString m_strFileToView; diff --git a/ark/rar.cpp b/ark/rar.cpp index 592ffe2..742df1c 100644 --- a/ark/rar.cpp +++ b/ark/rar.cpp @@ -55,6 +55,8 @@ RarArch::RarArch( ArkWidget *_gui, const QString & _fileName ) { // Check if rar is available bool have_rar = !KGlobal::dirs()->findExe( "rar" ).isNull(); + bool have_unrar = !KGlobal::dirs()->findExe( "unrar" ).isNull(); + bool have_unrar_free = !KGlobal::dirs()->findExe( "unrar-free" ).isNull(); if ( have_rar ) { @@ -63,13 +65,20 @@ RarArch::RarArch( ArkWidget *_gui, const QString & _fileName ) verifyCompressUtilityIsAvailable( m_archiver_program ); verifyUncompressUtilityIsAvailable( m_unarchiver_program ); } - else + else if (have_unrar) { // If rar is not available, try to use unrar to open the archive read-only m_unarchiver_program = "unrar"; verifyUncompressUtilityIsAvailable( m_unarchiver_program ); setReadOnly( true ); } + else + { + // If rar is not available, try to use unrar to open the archive read-only + m_unarchiver_program = "unrar-free"; + verifyUncompressUtilityIsAvailable( m_unarchiver_program ); + setReadOnly( true ); + } diff --git a/kcharselect/KCharSelect.desktop b/kcharselect/KCharSelect.desktop index f51d579..d5a066d 100644 --- a/kcharselect/KCharSelect.desktop +++ b/kcharselect/KCharSelect.desktop @@ -95,4 +95,4 @@ Name[xh]=Itshati yokukheta i K Name[zh_TW]=KDE 字元選擇 X-KDE-StartupNotify=true X-DCOP-ServiceType=Multi -Categories=Qt;KDE;Utility;X-KDE-More; +Categories=Qt;KDE;Utility; diff --git a/klaptopdaemon/acpi.cpp b/klaptopdaemon/acpi.cpp index cb13f40..843b8cb 100644 --- a/klaptopdaemon/acpi.cpp +++ b/klaptopdaemon/acpi.cpp @@ -165,14 +165,6 @@ void AcpiConfig::setupHelper() unsigned long len, crc; QString helper = KStandardDirs::findExe("klaptop_acpi_helper"); checkcrc(QFile::encodeName(helper), len, crc); - if (len != file_len || crc != file_crc) { - QString str(i18n("The %1 application does not seem to have " - "the same size or checksum as when it was compiled we do NOT recommend " - "you proceed with making it setuid-root without further investigation").arg(helper)); - int rc = KMessageBox::warningContinueCancel(0, str, i18n("KLaptopDaemon"), i18n("Run Nevertheless")); - if (rc != KMessageBox::Continue) - return; - } QString kdesu = KStandardDirs::findExe("kdesu"); if (!kdesu.isEmpty()) { @@ -186,7 +178,7 @@ void AcpiConfig::setupHelper() proc << kdesu; proc << "-u"; proc << "root"; - proc << "chown root "+helper+"; chmod +s "+helper; + proc << "dpkg-statoverride --update --add root root 6755 "+helper; proc.start(KProcess::Block); // run it sync so has_acpi below sees the results } } else { diff --git a/klaptopdaemon/acpi_helper.cpp b/klaptopdaemon/acpi_helper.cpp index 660d2cb..cf5c980 100644 --- a/klaptopdaemon/acpi_helper.cpp +++ b/klaptopdaemon/acpi_helper.cpp @@ -100,7 +100,7 @@ void write_to_power(const char * str) Returns only if the program does not exist; if the program exists and is unsafe, exit; if the program exists and is safe, run it and never return. */ -void run_program(const char *path) +void run_program(const char *path, const int action) { struct stat sb; int err; @@ -118,7 +118,13 @@ void run_program(const char *path) exit(1); } ::setuid(::geteuid()); // otherwise bash will throw it away - ::execl(path, NULL); // this is not KDE environment code + if (action == 1) { + system("/usr/sbin/pmi action hibernate"); + } else if (action == 2) { + system("/usr/sbin/pmi action sleep"); + } else { + ::execl(path, NULL); // this is not KDE environment code + } exit(0); } @@ -139,11 +145,13 @@ main(int argc, char **argv) for (i = 1; i < argc; i++) if (strcmp(argv[i], "--suspend") == 0 || strcmp(argv[i], "-suspend") == 0) { /* Returns only if suspend does not exist. */ - run_program("/usr/sbin/suspend"); + run_program("/usr/sbin/pmi", 2); + /* if (useSysPower) write_to_power("mem"); else write_to_proc_sleep(3); + */ exit(0); } else if (strcmp(argv[i], "--standby") == 0 || strcmp(argv[i], "-standby") == 0) { @@ -158,15 +166,17 @@ main(int argc, char **argv) exit(0); } else if (strcmp(argv[i], "--hibernate") == 0 || strcmp(argv[i], "-hibernate") == 0) { - run_program("/usr/sbin/hibernate"); + run_program("/usr/sbin/pmi", 1); + /* if (useSysPower) write_to_power("disk"); else write_to_proc_sleep(4); + */ exit(0); } else if (strcmp(argv[i], "--software-suspend") == 0 || strcmp(argv[i], "-software-suspend") == 0) { - run_program("/usr/sbin/hibernate"); + run_program("/usr/sbin/hibernate", 0); exit(0); } else if (strcmp(argv[i], "--throttling") == 0 || strcmp(argv[i], "-throttling") == 0) { diff --git a/klaptopdaemon/apm.cpp b/klaptopdaemon/apm.cpp index a13a907..ab25010 100644 --- a/klaptopdaemon/apm.cpp +++ b/klaptopdaemon/apm.cpp @@ -166,7 +166,7 @@ void ApmConfig::setupHelper() proc << kdesu; proc << "-u"; proc << "root"; - proc << QString("chown root ")+apm_name+"; chmod +s "+apm_name; + proc << QString("dpkg-statoverride --update --add root root 6755 ")+apm_name; proc.start(KProcess::Block); // run it sync so has_apm below sees the results } } else { @@ -187,14 +187,6 @@ void ApmConfig::setupHelper2() // we use the acpi helper to do software suspend unsigned long len, crc; QString helper = KStandardDirs::findExe("klaptop_acpi_helper"); checkcrc(helper.latin1(), len, crc); - if (len != file_len || crc != file_crc) { - QString str(i18n("The %1 application does not seem to have " - "the same size or checksum as when it was compiled we do NOT recommend " - "you proceed with making it setuid-root without further investigation").arg(helper)); - int rc = KMessageBox::warningContinueCancel(0, str, i18n("KLaptopDaemon"), i18n("Run Nevertheless")); - if (rc != KMessageBox::Continue) - return; - } QString kdesu = KStandardDirs::findExe("kdesu"); if (!kdesu.isEmpty()) { @@ -208,7 +200,7 @@ void ApmConfig::setupHelper2() // we use the acpi helper to do software suspend proc << kdesu; proc << "-u"; proc << "root"; - proc << "chown root "+helper+"; chmod +s "+helper; + proc << "dpkg-statoverride --update --add root root 6755 "+helper; proc.start(KProcess::Block); // run it sync so has_acpi below sees the results } } else { diff --git a/klaptopdaemon/daemondock.cpp b/klaptopdaemon/daemondock.cpp index 3551931..fb1336a 100644 --- a/klaptopdaemon/daemondock.cpp +++ b/klaptopdaemon/daemondock.cpp @@ -106,10 +106,10 @@ laptop_dock::SetupPopup() if (can_standby || can_suspend || can_hibernate) { rightPopup->insertSeparator(); if (can_standby) rightPopup->insertItem(i18n("Standby..."), this, SLOT(invokeStandby())); - if (can_suspend) rightPopup->insertItem(i18n("&Lock && Suspend..."), this, SLOT(invokeLockSuspend())); - if (can_suspend) rightPopup->insertItem(i18n("&Suspend..."), this, SLOT(invokeSuspend())); - if (can_hibernate) rightPopup->insertItem(i18n("&Lock && Hibernate..."), this, SLOT(invokeLockHibernation())); - if (can_hibernate) rightPopup->insertItem(i18n("&Hibernate..."), this, SLOT(invokeHibernation())); + // if (can_suspend) rightPopup->insertItem(i18n("&Lock && Suspend..."), this, SLOT(invokeLockSuspend())); + if (can_suspend) rightPopup->insertItem(i18n("&Suspend..."), this, SLOT(invokeLockSuspend())); + // if (can_hibernate) rightPopup->insertItem(i18n("&Lock && Hibernate..."), this, SLOT(invokeLockHibernation())); + if (can_hibernate) rightPopup->insertItem(i18n("&Hibernate..."), this, SLOT(invokeLockHibernation())); } rightPopup->insertSeparator(); diff --git a/klaptopdaemon/laptop_daemon.cpp b/klaptopdaemon/laptop_daemon.cpp index 6b66a64..43ac53f 100644 --- a/klaptopdaemon/laptop_daemon.cpp +++ b/klaptopdaemon/laptop_daemon.cpp @@ -952,7 +952,7 @@ laptop_daemon::ButtonThreadInternals() // the lid button turns stuff on when it's down and back off again when it's raised // (kind of like the fridge door light) // - if (lid_state != laptop_portable::get_button(laptop_portable::LidButton)) { + if (s.enable_lid_button && lid_state != laptop_portable::get_button(laptop_portable::LidButton)) { lid_state = !lid_state; if (lid_state) { if (s.button_lid_bright_enabled) { @@ -1015,7 +1015,7 @@ laptop_daemon::ButtonThreadInternals() // // the power button on the other hand is an off/on switch for non-suspend type ops // - if (power_state != laptop_portable::get_button(laptop_portable::PowerButton)) { + if (s.enable_power_button && power_state != laptop_portable::get_button(laptop_portable::PowerButton)) { power_state = !power_state; if (power_state) { if (power_button_off) { diff --git a/klaptopdaemon/portable.cpp b/klaptopdaemon/portable.cpp index f56dc1e..ac9ac16 100644 --- a/klaptopdaemon/portable.cpp +++ b/klaptopdaemon/portable.cpp @@ -177,7 +177,7 @@ pmu_read(apm_info *ap) int bcnt = 0; memset(ap, 0, sizeof(apm_info)); QFile f("/proc/pmu/info"); - if (!f.open(IO_ReadOnly)) + if (!f.exists() || !f.open(IO_ReadOnly)) return 1; while (!f.atEnd()) { @@ -200,7 +200,7 @@ pmu_read(apm_info *ap) int maxcharge = 0; for (int i = 0; i < bcnt; i++) { QFile bf(QString("/proc/pmu/battery_%1").arg(i)); - if (!bf.open(IO_ReadOnly)) + if (!bf.exists() || !bf.open(IO_ReadOnly)) continue; while(!bf.atEnd()) { @@ -331,7 +331,7 @@ static void acpi_read_batteries() { bool present = false; if ((test_count==0 || acpi_last_known != last_seed) && !bat.info_file.isNull()) { f = new QFile(bat.info_file); - if (f && f->open(IO_ReadOnly)) { + if (f && f->exists() && f->open(IO_ReadOnly)) { while(f->readLine(buff,1024) > 0) { if (buff.contains("design capacity low:", false)) { QRegExp rx("(\\d*)\\D*$"); @@ -361,7 +361,7 @@ static void acpi_read_batteries() { } if (!bat.state_file.isNull()) { f = new QFile(bat.state_file); - if (f && f->open(IO_ReadOnly)) { + if (f && f->exists() && f->open(IO_ReadOnly)) { while(f->readLine(buff,1024) > 0) { if (buff.contains("present rate:", false)) { QRegExp rx("(\\d*)\\D*$"); @@ -692,7 +692,7 @@ has_acpi_sleep(int state) QFile p("/sys/power/state"); QFile f("/proc/acpi/sleep"); - if (p.open(IO_ReadOnly)) { + if (p.exists() && p.open(IO_ReadOnly)) { QString l; QTextStream t(&p); l = t.readLine(); @@ -709,7 +709,7 @@ has_acpi_sleep(int state) } p.close(); } - else if (f.open(IO_ReadOnly)) { + else if (f.exists() && f.open(IO_ReadOnly)) { QString l; QTextStream t(&f); l = t.readLine(); @@ -1256,7 +1256,7 @@ static bool has_lav() if (!lav_inited) { lav_inited =1; lav_file.setName("/proc/loadavg"); - lav_openok = lav_file.open( IO_ReadOnly ); + lav_openok = lav_file.exists() && lav_file.open( IO_ReadOnly ); if (lav_openok) lav_file.close(); } @@ -1305,7 +1305,7 @@ QString laptop_portable::cpu_frequency() { QFile cf("/proc/cpufreq"); bool haveProfile = false; - if (cf.open(IO_ReadOnly)) { + if (cf.exists() && cf.open(IO_ReadOnly)) { while (!cf.atEnd()) { QString l; cf.readLine(l, 500); @@ -1320,7 +1320,7 @@ QString laptop_portable::cpu_frequency() { } if (haveProfile) { QFile ci("/proc/cpuinfo"); - if (ci.open(IO_ReadOnly)) { + if (ci.exists() && ci.open(IO_ReadOnly)) { while (!ci.atEnd()) { QString l; ci.readLine(l, 500); @@ -1538,7 +1538,7 @@ get_acpi_list(char p, int *map, const char *dev, QStringList &list, int &index, !(::access(name.latin1(), R_OK)==0 && ::acpi_helper_ok(0))) continue; QFile f(name); - if (f.open(IO_ReadOnly)) { + if (f.exists() && f.open(IO_ReadOnly)) { while (!f.atEnd() && i < MAP_SIZE) { QString l; f.readLine(l, 500); @@ -1576,7 +1576,7 @@ get_acpi_list(char p, int *map, const char *dev, QStringList &list, int &index, if (get_enable) { name = QString("/proc/acpi/processor/")+dp->d_name+"/limit"; f.setName(name); - if (f.open(IO_ReadOnly)) { + if (f.exists() && f.open(IO_ReadOnly)) { while (!f.atEnd() && i < MAP_SIZE) { QString l; f.readLine(l, 500); @@ -1619,7 +1619,7 @@ static int get_cpufreq_sysfs_state(QStringList &states, int ¤t, const QStr // read current scaling policy QFile f("/sys/devices/system/cpu/" + cpu + "/cpufreq/scaling_governor"); - if(!f.open(IO_ReadOnly) || f.atEnd()) + if(!f.exists() || !f.open(IO_ReadOnly) || f.atEnd()) return CPUFREQ_NONE; f.readLine(buffer, 256); cur = buffer.stripWhiteSpace(); @@ -1628,7 +1628,7 @@ static int get_cpufreq_sysfs_state(QStringList &states, int ¤t, const QStr // read available scaling policies states.clear(); f.setName("/sys/devices/system/cpu/" + cpu + "/cpufreq/scaling_available_governors"); - if(!f.open(IO_ReadOnly)) + if(!f.exists() || !f.open(IO_ReadOnly)) return CPUFREQ_NONE; int count = 0; if(!f.atEnd()) { @@ -1654,7 +1654,7 @@ static int get_cpufreq_25_state(QStringList &states, int ¤t) { states.clear(); QFile f("/proc/cpufreq"); - if (f.open(IO_ReadOnly)) { + if (f.exists() && f.open(IO_ReadOnly)) { while (!f.atEnd()) { QString l; f.readLine(l, 1024); @@ -1690,7 +1690,7 @@ static int get_cpufreq_24_state(QStringList &states, int ¤t, const QString // current frequency QFile f("/proc/sys/cpu/" + cpu + "/speed"); - if(!f.open(IO_ReadOnly) || f.atEnd()) + if(!f.exists() || !f.open(IO_ReadOnly) || f.atEnd()) return CPUFREQ_NONE; f.readLine(buffer, 16); f.close(); @@ -1700,7 +1700,7 @@ static int get_cpufreq_24_state(QStringList &states, int ¤t, const QString const char* files[] = { "max", "min" }; for(int i = 0; i <= 1; ++i) { f.setName("/proc/sys/cpu/" + cpu + "/speed-" + files[i]); - if(!f.open(IO_ReadOnly) || f.atEnd()) + if(!f.exists() || !f.open(IO_ReadOnly) || f.atEnd()) return CPUFREQ_NONE; f.readLine(buffer, 16); f.close(); @@ -1905,7 +1905,7 @@ acpi_check_button(const char *prefix, QString &result) if (::access(name.latin1(), R_OK)!=0) continue; QFile f(name); - if (f.open(IO_ReadOnly)) { + if (f.exists() && f.open(IO_ReadOnly)) { while (!f.atEnd()) { QString l; f.readLine(l, 500); @@ -1972,7 +1972,7 @@ laptop_portable::get_button(LaptopButton l) // true if a button is pressed } if (!name.isEmpty()) { QFile f(name); - if (f.open(IO_ReadOnly)) { + if (f.exists() && f.open(IO_ReadOnly)) { while (!f.atEnd()) { QString l; f.readLine(l, 500); diff --git a/kmilo/generic/generic_monitor.cpp b/kmilo/generic/generic_monitor.cpp index 40e7169..bc104dc 100644 --- a/kmilo/generic/generic_monitor.cpp +++ b/kmilo/generic/generic_monitor.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -34,6 +35,7 @@ #include "kmilointerface.h" #include #include +#include #define CONFIG_FILE "kmilodrc" @@ -70,10 +72,25 @@ bool GenericMonitor::init() KConfig config(CONFIG_FILE); reconfigure(&config); + //config = new KConfig("kmilodrc"); + config.setGroup("kubuntu"); + if(!m_enabled) return false; // exit early if we are not supposed to run static const ShortcutInfo shortcuts[] = { + { "Search", KShortcut("XF86Search"), SLOT(launchSearch()) }, + { "Home Folder", KShortcut("XF86MyComputer"), SLOT(launchHomeFolder()) }, + { "Mail", KShortcut("XF86Mail"), SLOT(launchMail()) }, + { "Audio Media", KShortcut("XF86AudioMedia"), SLOT(launchMusic()) }, + { "Music", KShortcut("XF86Music"), SLOT(launchMusic()) }, + { "Browser", KShortcut("XF86WWW"), SLOT(launchBrowser()) }, + { "Calculator", KShortcut("XF86Calculator"), SLOT(launchCalculator()) }, + { "Terminal", KShortcut("XF86Terminal"), SLOT(launchTerminal()) }, + { "Eject", KShortcut("XF86Eject"), SLOT(eject()) }, + { "Help", KShortcut("XF86Launch0"), SLOT(launchHelp()) }, + { "Light Bulb", KShortcut("XF86LightBulb"), SLOT(lightBulb()) }, + { "Battery", KShortcut("XF86LaunchB"), SLOT(pmBattery()) }, { "FastVolumeUp", Qt::Key_VolumeUp, SLOT(fastVolumeUp()) }, { "FastVolumeDown", Qt::Key_VolumeDown, SLOT(fastVolumeDown()) }, { "SlowVolumeUp", Qt::CTRL+Qt::Key_VolumeUp, SLOT(slowVolumeUp()) }, @@ -318,6 +335,73 @@ Monitor::DisplayType GenericMonitor::poll() return m_displayType; } +void GenericMonitor::launch(QString configKey, QString defaultApplication) +{ + QString application = config->readEntry(configKey, defaultApplication); + KProcess proc; + proc << application; + proc.start(KProcess::DontCare); +} + +void GenericMonitor::launchMail() +{ + kdDebug() << "launchMail" << endl; + kapp->invokeMailer("", "", "", "", "", "", "", ""); +} + +void GenericMonitor::launchBrowser() +{ + kapp->invokeBrowser(""); +} + +void GenericMonitor::launchSearch() +{ + launch("search", "kfind"); +} + +void GenericMonitor::launchHomeFolder() +{ + QString home = QDir::home().path(); + KProcess proc; + proc << "kfmclient" << "exec" << home; + proc.start(KProcess::DontCare); +} + +void GenericMonitor::launchMusic() +{ + launch("search", "amarok"); +} + +void GenericMonitor::launchCalculator() +{ + launch("search", "speedcrunch"); +} + +void GenericMonitor::launchTerminal() +{ + launch("search", "konsole"); +} + +void GenericMonitor::launchHelp() +{ + launch("search", "khelpcenter"); +} + +void GenericMonitor::eject() +{ + launch("search", "eject"); +} + +void GenericMonitor::lightBulb() +{ + kdDebug() << "lightBulb()" << endl; + _interface->displayText("Screen Light"); +} + +void GenericMonitor::pmBattery() +{ + DCOPRef("guidance*", "power-manager").send("showTip"); +} K_EXPORT_COMPONENT_FACTORY(kmilo_generic, KGenericFactory("kmilo_generic")) diff --git a/kmilo/generic/generic_monitor.h b/kmilo/generic/generic_monitor.h index c2477c4..1ad5304 100644 --- a/kmilo/generic/generic_monitor.h +++ b/kmilo/generic/generic_monitor.h @@ -29,6 +29,7 @@ #include #include #include +#include #include "kmilod.h" #include "monitor.h" @@ -63,6 +64,17 @@ public slots: void fastVolumeUp(); void fastVolumeDown(); void mute(); + void launchMail(); + void launchBrowser(); + void launchSearch(); + void launchHomeFolder(); + void launchMusic(); + void launchCalculator(); + void launchTerminal(); + void launchHelp(); + void eject(); + void lightBulb(); + void pmBattery(); private: bool retrieveKmixDevices(); @@ -70,8 +82,10 @@ private: bool retrieveMute(); bool retrieveVolume(); void displayVolume(); + void launch(QString configKey, QString defaultApplication); KGlobalAccel *ga; + KConfig* config; DCOPRef *kmixClient, *kmixWindow; diff --git a/kmilo/kmilod/defaultskin.cpp b/kmilo/kmilod/defaultskin.cpp index f0324de..a0ef2b0 100644 --- a/kmilo/kmilod/defaultskin.cpp +++ b/kmilo/kmilod/defaultskin.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "defaultskin.h" @@ -49,6 +50,9 @@ DefaultSkin::DefaultSkin() { KWin::setType(_widget->winId(), NET::Override); _widget->hide(); + + KConfig config("kmilodrc"); + reconfigure( &config ); } @@ -57,6 +61,34 @@ DefaultSkin::~DefaultSkin() { _widget = 0; } +void DefaultSkin::reconfigure( KConfig *config ) { + + config->setGroup("DefaultSkin"); + + QFont *defaultFont = new QFont("Sans", 10, QFont::Bold ); + QSize *defaultSize = new QSize( 80, 30 ); + QColor *defaultpaletteForegroundColor = new QColor( 200, 200, 200 ); + QColor *defaultpaletteBackgroundColor = new QColor( 100, 100, 100 ); + QFont *defaultProgressFont = new QFont("Sans", 8, QFont::Bold ); + + _widget->resize( config->readSizeEntry("Size", defaultSize ) ); + _widget->setFont( config->readFontEntry("Font", defaultFont ) ); + _widget->setPaletteForegroundColor( config->readColorEntry("paletteForegroundColor", defaultpaletteForegroundColor ) ); + _widget->setPaletteBackgroundColor( config->readColorEntry("paletteBackgroundColor", defaultpaletteBackgroundColor ) ); + _widget->_progress->setFont( config->readFontEntry("ProgressFont", defaultProgressFont ) ); + + if ( ! config->hasGroup("DefaultSkin") ) + { + + config->writeEntry("Size", *defaultSize ); + config->writeEntry("Font", *defaultFont ); + config->writeEntry("paletteForegroundColor", *defaultpaletteForegroundColor ); + config->writeEntry("paletteBackgroundColor", *defaultpaletteBackgroundColor ); + config->writeEntry("ProgressFont", *defaultProgressFont ); + + } + +} void DefaultSkin::clear() { _timer.stop(); diff --git a/kmilo/kmilod/defaultskin.h b/kmilo/kmilod/defaultskin.h index 0e01f23..1610152 100644 --- a/kmilo/kmilod/defaultskin.h +++ b/kmilo/kmilod/defaultskin.h @@ -37,6 +37,7 @@ class DefaultSkin : public QObject, public KMilo::DisplaySkin { virtual ~DefaultSkin(); virtual void clear(); + virtual void reconfigure( KConfig *config ); virtual void displayText(const QString& text, const QPixmap& customPixmap=QPixmap()); virtual void displayProgress(const QString& text, diff --git a/kmilo/kmilod/defaultwidget.ui b/kmilo/kmilod/defaultwidget.ui index b4809fe..65c19d8 100644 --- a/kmilo/kmilod/defaultwidget.ui +++ b/kmilo/kmilod/defaultwidget.ui @@ -7,21 +7,6 @@ Released under the terms of the GNU GPL. DefaultWidget - - - 0 - 0 - 566 - 180 - - - - - 214 - 213 - 212 - - unnamed @@ -30,19 +15,6 @@ Released under the terms of the GNU GPL. _widgetStack - - - 214 - 213 - 212 - - - - StyledPanel - - - Sunken - page @@ -58,26 +30,6 @@ Released under the terms of the GNU GPL. _textOnly - - - 26 - 69 - 198 - - - - - 214 - 213 - 212 - - - - - 28 - 1 - - @@ -98,41 +50,18 @@ Released under the terms of the GNU GPL. unnamed - - - spacer1 - - - Horizontal - - - Expanding - - - - 81 - 31 - - - - + - spacer1_2 - - - Horizontal + _progressText - - Expanding + + - - - 81 - 31 - + + AlignCenter - - + + _progress @@ -144,52 +73,14 @@ Released under the terms of the GNU GPL. 0 - - - 214 - 213 - 212 - - false - - - _progressText - - - - 26 - 69 - 198 - - - - - 214 - 213 - 212 - - - - - 28 - 1 - - - - - - - AlignCenter - - - + diff --git a/kregexpeditor/kregexpeditor.desktop b/kregexpeditor/kregexpeditor.desktop index ebffee5..e93f87b 100644 --- a/kregexpeditor/kregexpeditor.desktop +++ b/kregexpeditor/kregexpeditor.desktop @@ -72,5 +72,5 @@ GenericName[zh_TW]=正規表示式編輯器 Terminal=false Type=Application X-KDE-StartupNotify=true -Categories=Qt;KDE;Utility;X-KDE-More; +Categories=Qt;KDE;Utility; Icon=kregexpeditor diff --git a/superkaramba/src/Makefile.am b/superkaramba/src/Makefile.am index 90c9aa3..81858e7 100644 --- a/superkaramba/src/Makefile.am +++ b/superkaramba/src/Makefile.am @@ -1,5 +1,5 @@ # set the include path for X, qt and KDE -INCLUDES = $(all_includes) $(XMMS_INCLUDES) $(PYTHONINC) +INCLUDES = $(all_includes) $(PYTHONINC) # these are the headers for your project noinst_HEADERS = karamba.h karambaapp.h karamba_python.h lineparser.h \ @@ -40,9 +40,9 @@ superkaramba_SOURCES = main.cpp karamba.cpp meter.cpp bar.cpp sensor.cpp \ # kde_cfg_DATA = superkaramba.kcfg -superkaramba_LDFLAGS = -Wl,-export-dynamic $(KDE_RPATH) $(all_libraries) $(PYTHONLIB) $(XMMS_LDFLAGS) -#superkaramba_LDADD = -lkio $(LIB_KDEUI) $(XMMS_LDADD) $(LIBPYTHON) $(LIBKVM) $(MY_LIBKNEWSTUFF) -superkaramba_LDADD = -lkio $(LIB_KDEUI) $(XMMS_LIBS) $(LIBPYTHON) $(LIBKVM) $(MY_LIBKNEWSTUFF) +superkaramba_LDFLAGS = -Wl,-export-dynamic $(KDE_RPATH) $(all_libraries) $(PYTHONLIB) +#superkaramba_LDADD = -lkio $(LIB_KDEUI) $(LIBPYTHON) $(LIBKVM) $(MY_LIBKNEWSTUFF) +superkaramba_LDADD = -lkio $(LIB_KDEUI) $(LIBPYTHON) $(LIBKVM) $(MY_LIBKNEWSTUFF) # this is where the desktop file will go shelldesktopdir = $(kde_appsdir)/Utilities diff --git a/superkaramba/src/xmmssensor.cpp b/superkaramba/src/xmmssensor.cpp index a55209e..de7fa7f 100644 --- a/superkaramba/src/xmmssensor.cpp +++ b/superkaramba/src/xmmssensor.cpp @@ -10,11 +10,122 @@ #include "xmmssensor.h" #ifdef HAVE_XMMS -#include +#include + +class XMMSSensor::XMMS +{ +public: + XMMS() : libxmms( 0 ) + { + libxmms = new QLibrary( "xmms.so.1" ); + if ( !libxmms->load() ) + { + delete libxmms; + libxmms = 0; + } + + if ( libxmms != 0 ) + { + // resolve functions + *(void**) (&xmms_remote_is_running) = + libxmms->resolve( "xmms_remote_is_running" ); + + *(void**) (&xmms_remote_is_playing) = + libxmms->resolve( "xmms_remote_is_playing" ); + + *(void**) (&xmms_remote_get_playlist_title) = + libxmms->resolve( "xmms_remote_get_playlist_title" ); + + *(void**) (&xmms_remote_get_playlist_time) = + libxmms->resolve( "xmms_remote_get_playlist_time" ); + + *(void**) (&xmms_remote_get_playlist_pos) = + libxmms->resolve( "xmms_remote_get_playlist_pos" ); + + *(void**) (&xmms_remote_get_output_time) = + libxmms->resolve( "xmms_remote_get_output_time" ); + } + } + + bool isInitialized() const + { + return libxmms != 0 && + xmms_remote_is_running != 0 && + xmms_remote_is_playing != 0 && + xmms_remote_get_playlist_title != 0 && + xmms_remote_get_playlist_time != 0 && + xmms_remote_get_playlist_pos != 0 && + xmms_remote_get_output_time != 0; + } + + bool isRunning(int session) + { + if ( !isInitialized() ) return false; + + return (*xmms_remote_is_running)(session); + } + + bool isPlaying(int session) + { + if ( !isInitialized() ) return false; + + return (*xmms_remote_is_playing)(session); + } + + char* getPlaylistTitle(int session, int pos) + { + if ( !isInitialized() ) return ""; + + return (*xmms_remote_get_playlist_title)(session, pos); + } + + int getPlaylistTime(int session, int pos) + { + if ( !isInitialized() ) return 0; + + return (*xmms_remote_get_playlist_time)(session, pos); + } + + int getPlaylistPos(int session) + { + if ( !isInitialized() ) return 0; + + return (*xmms_remote_get_playlist_pos)(session); + } + + int getOutputTime(int session) + { + if ( !isInitialized() ) return 0; + + return (*xmms_remote_get_output_time)(session); + } + +private: + QLibrary* libxmms; + + bool (*xmms_remote_is_running)(int); + bool (*xmms_remote_is_playing)(int); + + char* (*xmms_remote_get_playlist_title)(int, int); + int (*xmms_remote_get_playlist_time)(int, int); + int (*xmms_remote_get_playlist_pos)(int); + int (*xmms_remote_get_output_time)(int); +}; + +#else // No XMMS + +class XMMSSensor::XMMS +{ +public: + XMMS() {} + + bool isInitialized() const { return false; } +}; #endif // HAVE_XMMS + XMMSSensor::XMMSSensor( int interval, const QString &encoding ) - : Sensor( interval ) + : Sensor( interval ), xmms( 0 ) { if( !encoding.isEmpty() ) { @@ -25,9 +136,13 @@ XMMSSensor::XMMSSensor( int interval, const QString &encoding ) else codec = QTextCodec::codecForLocale(); + xmms = new XMMS(); + } XMMSSensor::~XMMSSensor() -{} +{ + delete xmms; +} void XMMSSensor::update() { @@ -43,21 +158,21 @@ void XMMSSensor::update() int songLength = 0; int currentTime = 0; bool isPlaying = false; - bool isRunning = xmms_remote_is_running(0); + bool isRunning = xmms->isRunning(0); if( isRunning ) { - isPlaying = xmms_remote_is_playing(0); - pos = xmms_remote_get_playlist_pos(0); + isPlaying = xmms->isPlaying(0); + pos = xmms->getPlaylistPos(0); qDebug("unicode start"); - title = codec->toUnicode( QCString( xmms_remote_get_playlist_title( 0, pos ) ) ); + title = codec->toUnicode( QCString( xmms->getPlaylistTitle( 0, pos ) ) ); qDebug("unicode end"); if( title.isEmpty() ) title = "XMMS"; qDebug("Title: %s", title.ascii()); - songLength = xmms_remote_get_playlist_time( 0, pos ); - currentTime = xmms_remote_get_output_time( 0 ); + songLength = xmms->getPlaylistTime( 0, pos ); + currentTime = xmms->getOutputTime( 0 ); } #endif // HAVE_XMMS @@ -144,6 +259,9 @@ void XMMSSensor::setMaxValue( SensorParams *sp) } - +bool XMMSSensor::hasXMMS() const +{ + return xmms->isInitialized(); +} #include "xmmssensor.moc" diff --git a/superkaramba/src/xmmssensor.h b/superkaramba/src/xmmssensor.h index f5fd6ef..622eb8d 100644 --- a/superkaramba/src/xmmssensor.h +++ b/superkaramba/src/xmmssensor.h @@ -28,10 +28,13 @@ public: ~XMMSSensor(); void update(); void setMaxValue( SensorParams *); + bool hasXMMS() const; private: QTextCodec *codec; + class XMMS; + XMMS *xmms; }; -- cgit v1.2.1