diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2016-03-21 20:35:05 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2016-03-21 20:35:05 +0100 |
commit | 066aaaeb73a8bb908b1c0d8c45f110b2f799f7ce (patch) | |
tree | 4cb26eb8ace976f7d0c8607dc2d3de2b5107670c /bab | |
download | tde-style-baghira-066aaaeb73a8bb908b1c0d8c45f110b2f799f7ce.tar.gz tde-style-baghira-066aaaeb73a8bb908b1c0d8c45f110b2f799f7ce.zip |
Initial import of baghira 0.8
Diffstat (limited to 'bab')
-rw-r--r-- | bab/Makefile.am | 22 | ||||
-rw-r--r-- | bab/Themes/Brushed | 15 | ||||
-rw-r--r-- | bab/Themes/Jaguar | 14 | ||||
-rw-r--r-- | bab/Themes/Makefile.am | 3 | ||||
-rw-r--r-- | bab/Themes/Milk | 15 | ||||
-rw-r--r-- | bab/Themes/Panther | 14 | ||||
-rw-r--r-- | bab/Themes/Tiger | 14 | ||||
-rw-r--r-- | bab/bab.desktop | 10 | ||||
-rw-r--r-- | bab/bab.h | 108 | ||||
-rw-r--r-- | bab/bab.lsm | 16 | ||||
-rw-r--r-- | bab/bab_iface.h | 41 | ||||
-rw-r--r-- | bab/main.cpp | 615 | ||||
-rw-r--r-- | bab/styleconfdialog.cpp | 63 | ||||
-rw-r--r-- | bab/styleconfdialog.h | 53 |
14 files changed, 1003 insertions, 0 deletions
diff --git a/bab/Makefile.am b/bab/Makefile.am new file mode 100644 index 0000000..bf7a71e --- /dev/null +++ b/bab/Makefile.am @@ -0,0 +1,22 @@ +## Makefile.am for bab + +# set the include path for X, qt and KDE +INCLUDES = $(all_includes) + +# these are the headers for your project +noinst_HEADERS = bab.h bab_iface.h styleconfdialog.h + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kdedcoptest.pot + +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +bin_PROGRAMS = bab + +# the application source, library search path, and link libraries +bab_SOURCES = main.cpp styleconfdialog.cpp bab_iface.skel +bab_LDFLAGS = $(KDE_RPATH) $(all_libraries) +bab_LDADD = $(LIB_KDEUI) diff --git a/bab/Themes/Brushed b/bab/Themes/Brushed new file mode 100644 index 0000000..0354f24 --- /dev/null +++ b/bab/Themes/Brushed @@ -0,0 +1,15 @@ +2 +2 +1 +2 +1 +1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +0 diff --git a/bab/Themes/Jaguar b/bab/Themes/Jaguar new file mode 100644 index 0000000..01bde8f --- /dev/null +++ b/bab/Themes/Jaguar @@ -0,0 +1,14 @@ +0 +0 +0 +0 +0 +1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 diff --git a/bab/Themes/Makefile.am b/bab/Themes/Makefile.am new file mode 100644 index 0000000..2ae716a --- /dev/null +++ b/bab/Themes/Makefile.am @@ -0,0 +1,3 @@ +lnkdir = $HOME/.baghira +lnk_DATA = Brushed Milk Jaguar Tiger Panther +EXTRA_DIST = $(lnk_DATA) diff --git a/bab/Themes/Milk b/bab/Themes/Milk new file mode 100644 index 0000000..83b9864 --- /dev/null +++ b/bab/Themes/Milk @@ -0,0 +1,15 @@ +4 +4 +4 +4 +1 +0 +-592138 +-4930834 +-1 +-16777216 +-13009982 +-1 +-16777216 +-1116417 +1 diff --git a/bab/Themes/Panther b/bab/Themes/Panther new file mode 100644 index 0000000..c313570 --- /dev/null +++ b/bab/Themes/Panther @@ -0,0 +1,14 @@ +1 +1 +1 +1 +1 +1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 diff --git a/bab/Themes/Tiger b/bab/Themes/Tiger new file mode 100644 index 0000000..825a5c1 --- /dev/null +++ b/bab/Themes/Tiger @@ -0,0 +1,14 @@ +3 +3 +1 +1 +1 +1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 diff --git a/bab/bab.desktop b/bab/bab.desktop new file mode 100644 index 0000000..534daa4 --- /dev/null +++ b/bab/bab.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=bab +Name[xx]=xxbabxx +Exec=bab %i %m -caption "%c" +Icon=baghira +Type=Application +DocPath= +Comment=Access to the big black cat +Terminal=0 diff --git a/bab/bab.h b/bab/bab.h new file mode 100644 index 0000000..cc28882 --- /dev/null +++ b/bab/bab.h @@ -0,0 +1,108 @@ +/*************************************************************************** + * Copyright (C) 2004 by Thomas Lübking * + * thomas@home * + * * + * 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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _BAB_H_ +#define _BAB_H_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +//#include <dcopclient.h> +#include "bab_iface.h" +#include <qwidget.h> +#include <qpixmap.h> +#include <qsettings.h> +#include <kmainwindow.h> +#include <ksystemtray.h> + +class bab; + +class BabSwitcher : public KSystemTray , public babInterface{ + Q_OBJECT +public: + + enum State {Jaguar = 0, Panther, iTunes, Tiger, Milk}; + + BabSwitcher(bab *parent=0, const char *name=0); + ~BabSwitcher(); + + void toggle(); + void setStyle(QString); + QString style(); + void setDeco(QString); + QString deco(); + void start(QString name, QString settings); + void emitStyleChanged(); + static QPoint *globalPos; + +protected: + void mousePressEvent(QMouseEvent *e); + void paintEvent(QPaintEvent *ev); + +private: + + int state_; + int decoState_; + QPixmap JaguarIcon; + QPixmap PantherIcon; + QPixmap iTunesIcon; + QPixmap TigerIcon; + QPixmap MilkIcon; +}; + + +class QComboBox; +class QCheckBox; +/** + * @short Application Main Window + * @author Thomas Lübking <baghira-style@gmx.net> + * @version 0.1 + */ +class bab : public KMainWindow +{ + Q_OBJECT +public: + + enum TabState {Tab = 0, Clever, Chooser}; + bab(); + void showEvent(QShowEvent *e); + QCheckBox *cornerCheck; + virtual ~bab(); +private: + BabSwitcher* bSwitcher; + QComboBox *DefStyle; + +private slots: + void saveSettings(); + void configureBaghira(); + +}; + +class Corner : public QWidget +{ + Q_OBJECT + public: + enum Side {left = 0, right}; + Corner(Side side); +public slots: + void toggle(bool); +}; + +#endif // _BAB_H_ diff --git a/bab/bab.lsm b/bab/bab.lsm new file mode 100644 index 0000000..842281c --- /dev/null +++ b/bab/bab.lsm @@ -0,0 +1,16 @@ +Begin3 +Title: bab -- Some description +Version: 0.1 +Entered-date: +Description: +Keywords: KDE Qt +Author: Thomas Lübking <thomas@home> +Maintained-by: Thomas Lübking <thomas@home> +Home-page: +Alternate-site: +Primary-site: ftp://ftp.kde.org/pub/kde/unstable/apps/utils + xxxxxx bab-0.1.tar.gz + xxx bab-0.1.lsm +Platform: Linux. Needs KDE +Copying-policy: GPL +End diff --git a/bab/bab_iface.h b/bab/bab_iface.h new file mode 100644 index 0000000..bf63d92 --- /dev/null +++ b/bab/bab_iface.h @@ -0,0 +1,41 @@ +/*************************************************************************** + * Copyright (C) 2004 by Thomas Lübking * + * thomas@home * + * * + * 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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _BAB_INTERFACE_H_ +#define _BAB_INTERFACE_H_ + +#include <dcopobject.h> + +class babInterface : virtual public DCOPObject +{ + K_DCOP + k_dcop: + + virtual void toggle() = 0; + virtual QString style() = 0; + virtual void setStyle(QString state) = 0; + virtual QString deco() = 0; + virtual void setDeco(QString state) = 0; + virtual void start(QString name, QString settings) = 0; + virtual void emitStyleChanged() = 0; + +}; + +#endif diff --git a/bab/main.cpp b/bab/main.cpp new file mode 100644 index 0000000..14b23d1 --- /dev/null +++ b/bab/main.cpp @@ -0,0 +1,615 @@ +/*************************************************************************** + * Copyright (C) 2004 by Thomas Lübking * + * thomas@home * + * * + * 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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "bab.h" +#include <qpushbutton.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qdir.h> +#include <qlayout.h> +#include <qsettings.h> +#include <qtabwidget.h> +#include <qtooltip.h> +#include <qtimer.h> +#include <qvbox.h> +#include <qpainter.h> +#include <dcopclient.h> +#include <kapplication.h> +// #include <kconfig.h> +#include <kiconloader.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <kipc.h> +#include <klibloader.h> +#include <klocale.h> +#include <kprocess.h> +#if KDE_IS_VERSION(3,4,0) +#include <kwin.h> +#endif +#include <stdio.h> +#include <X11/Xlib.h> +#include <X11/extensions/shape.h> + +#include "styleconfdialog.h" + +static const char description[] = + I18N_NOOP("Baghira Aqua/Brushed"); + +static const char version[] = "cvs"; + +static KCmdLineOptions options[] = +{ +// { "+[URL]", I18N_NOOP( "Document to open." ), 0 }, + KCmdLineLastOption +}; + +int main(int argc, char **argv) +{ + KAboutData about("bab", I18N_NOOP("BAB - Baghira Aqua/Brushed Switcher"), version, description, + KAboutData::License_GPL, "(C) 2004/2005 Thomas Lübking", 0, 0, "baghira-style@gmx.net"); + about.addAuthor( "Thomas Lübking", 0, "baghira-style@gmx.net" ); + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions( options ); + KApplication app; + DCOPClient* client = app.dcopClient(); + client->registerAs( "bab", false); + client->setDefaultObject( "babInterface" ); + bab* mainBAB = 0; + mainBAB = new bab; + app.setMainWidget(mainBAB); + Corner leftCorner(Corner::left); + Corner rightCorner(Corner::right); +#if KDE_IS_VERSION(3,4,0) + KWin::setShadowSize(leftCorner.winId(), 0); + KWin::setShadowSize(rightCorner.winId(), 0); +#endif + if (!mainBAB->cornerCheck->isChecked()) + { + leftCorner.hide(); + rightCorner.hide(); + } + leftCorner.connect( mainBAB->cornerCheck, SIGNAL(toggled(bool)), SLOT(toggle(bool)) ); + rightCorner.connect( mainBAB->cornerCheck, SIGNAL(toggled(bool)), SLOT(toggle(bool)) ); + + int ret = app.exec(); + if (mainBAB) delete mainBAB; + return ret; +} + + +bab::bab() : KMainWindow(0,"bab",Qt::WStyle_StaysOnTop | Qt::WX11BypassWM ){ + bSwitcher = new BabSwitcher(this,"switcher"); + QToolTip::add(bSwitcher, i18n("leftclick toggles state<br>rightclick toggles setupmenu")); + bSwitcher->show(); + + QDir d( QDir::homeDirPath() + "/.baghira"); + if (!d.exists()) + d.mkdir(QDir::homeDirPath() + "/.baghira"); + d = QDir( QDir::homeDirPath() + "/.baghira/.bab"); + if (!d.exists()) + d.mkdir(QDir::homeDirPath() + "/.baghira/.bab"); + FILE *file = NULL; + QString tmpString = QDir::homeDirPath() + "/.baghira/Jaguar"; + if (!QFile::exists(tmpString)) + { + if( (file = fopen(tmpString.latin1(), "w")) != NULL ) + { + fprintf(file,"0\n0\n0\n0\n0\n1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n1\n"); + fclose(file); + } + } + tmpString = QDir::homeDirPath() + "/.baghira/Panther"; + if (!QFile::exists(tmpString)) + { + if( (file = fopen(tmpString.latin1(), "w")) != NULL ) + { + fprintf(file,"1\n1\n1\n1\n1\n1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n1\n"); + fclose(file); + } + } + tmpString = QDir::homeDirPath() + "/.baghira/Brushed"; + if (!QFile::exists(tmpString)) + { + if( (file = fopen(tmpString.latin1(), "w")) != NULL ) + { + fprintf(file,"2\n2\n1\n2\n1\n1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n0\n"); + fclose(file); + } + } + tmpString = QDir::homeDirPath() + "/.baghira/Tiger"; + if (!QFile::exists(tmpString)) + { + if( (file = fopen(tmpString.latin1(), "w")) != NULL ) + { + fprintf(file,"3\n3\n1\n1\n0\n1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n1\n"); + fclose(file); + } + } + tmpString = QDir::homeDirPath() + "/.baghira/Milk"; + if (!QFile::exists(tmpString)) + { + if( (file = fopen(tmpString.latin1(), "w")) != NULL ) + { + fprintf(file,"4\n4\n4\n4\n1\n0\n-592138\n-4930834\n-1\n-16777216\n-13009982\n-1\n-16777216\n-1116417\n1\n"); + fclose(file); + } + } + + QVBox *vb = new QVBox(this); + vb->setLineWidth(2); + vb->setMargin(2); +// vb->setFrameStyle(QFrame::Panel | QFrame::Plain ); + + QLabel *DefStyleLabel = new QLabel("Default Style is", vb); + DefStyle = new QComboBox(vb); + DefStyle->insertItem ( "Jaguar" ); + DefStyle->insertItem ( "Panther" ); + DefStyle->insertItem ( "Brushed" ); + DefStyle->insertItem ( "Tiger" ); + DefStyle->insertItem ( "Milk" ); + cornerCheck = new QCheckBox("Round upper screen corners", vb); + QSettings config; + config.beginGroup("/baghira/BAB"); + DefStyle->setCurrentItem(config.readNumEntry("defaultState", BabSwitcher::Panther )); + cornerCheck->setChecked( config.readBoolEntry("roundCorners", true ) ); + config.endGroup(); + QPushButton *configBaghira = new QPushButton("Configure Baghira", vb); + QPushButton *Quit = new QPushButton("Quit BAB", vb); + QPushButton *Close = new QPushButton("Close Menu", vb); + vb->adjustSize(); + bSwitcher->setStyle(DefStyle->currentText()); + bSwitcher->setDeco(DefStyle->currentText()); + + connect(DefStyle, SIGNAL(activated(int)), this, SLOT(saveSettings())); + connect(cornerCheck, SIGNAL(toggled(bool)), this, SLOT(saveSettings())); + connect(configBaghira, SIGNAL(clicked()), this, SLOT(configureBaghira())); + connect(Close, SIGNAL(clicked()), this, SLOT(hide())); + connect(Quit, SIGNAL(clicked()), this, SLOT(close())); + + resize(vb->width(),vb->height()); + +// show(); +} + +bab::~ bab() +{ + bSwitcher->setStyle(DefStyle->currentText()); + bSwitcher->setDeco(DefStyle->currentText()); + if (bSwitcher) delete bSwitcher; +} + +/*Taken from kcontrol, kcmshell style*/ +void bab::configureBaghira() +{ + + + // Use KLibLoader to get the library, handling + // any errors that arise + KLibLoader* loader = KLibLoader::self(); + + KLibrary* library = loader->library( QFile::encodeName("kstyle_baghira_config") ); + if (!library) + { + qWarning("There was an error loading the configuration dialog for this style."); + return; + } + + void* allocPtr = library->symbol("allocate_kstyle_config"); + + if (!allocPtr) + { + qWarning("There was an error loading the configuration dialog for this style."); + return; + } + + //Create the container dialog + StyleConfigDialog* dial = new StyleConfigDialog(this, "Baghira Configuration"); + dial->enableButtonSeparator(true); + + typedef QWidget*(* factoryRoutine)( QWidget* parent ); + + //Get the factory, and make the widget. + factoryRoutine factory = (factoryRoutine)(allocPtr); + QWidget* styleConfig = factory( dial ); + + QTabWidget* tw = (QTabWidget*)styleConfig->child("tabWidget"); + + QWidget* decoConfig = 0; + QObject *decoObject = 0; + if (tw) + { + KLibrary* library2 = loader->library( QFile::encodeName("kwin_baghira_config") ); + if (!library2) + { + qWarning("There was an error loading the configuration dialog for the deco."); + return; + } + void* allocPtr2 = library2->symbol("allocate_config"); + if (!allocPtr2) + { + qWarning("There was an error loading the configuration dialog for this style."); + return; + } + typedef QObject*(* factoryRoutine2)( KConfig* conf, QWidget* parent ); + factoryRoutine2 factory2 = (factoryRoutine2)(allocPtr2); + decoObject = factory2( 0, tw ); + decoConfig = (QWidget*)tw->child("ConfigDialog"); + tw->addTab(decoConfig, "Decoration"); + } + + //Insert it in... + dial->setMainWidget( styleConfig ); + + QWidget *desktop = QApplication::desktop(); + QPoint nPos((desktop->width() - dial->width())/2, (desktop->height() - dial->height() - 100)/2); + dial->move(nPos); + //..and connect it to the wrapper + connect(styleConfig, SIGNAL(changed(bool)), dial, SLOT(setStyleDirty(bool))); + connect(decoObject, SIGNAL(changed()), dial, SLOT(setDecoDirty())); + connect(dial, SIGNAL(defaults()), styleConfig, SLOT(defaults())); + connect(dial, SIGNAL(save()), styleConfig, SLOT(save())); + connect(dial, SIGNAL(defaults()), decoObject, SLOT(defaults())); + connect(dial, SIGNAL(save(KConfig*)), decoObject, SLOT(save(KConfig*))); + + if (dial->exec() == QDialog::Accepted) + { + //For now, ask all KDE apps to recreate their styles to apply the setitngs + if (dial->isStyleDirty()) + { + KIPC::sendMessageAll(KIPC::StyleChanged); + KIPC::sendMessageAll(KIPC::ToolbarStyleChanged); + } + if (dial->isDecoDirty()) + kapp->dcopClient()->send("kwin", "KWinInterface", "reconfigure()", QByteArray()); + } + tw->removeChild( decoObject ); + dial->insertChild( decoObject ); + decoConfig->reparent(dial, QPoint(0,0)); + delete dial; +} + +/* overwrite the show event for repositioning the window on top + of the icon, adapted from kkeyled */ +void bab::showEvent(QShowEvent *e){ + if ( bSwitcher->globalPos->x() >= 0) { + QWidget *desktop = QApplication::desktop(); + int w = desktop->width(); + QPoint nPos; + if (bSwitcher->globalPos->y() - height() >= 0 ) + { // it's not on top + nPos.setY(bSwitcher->globalPos->y() -height()); + nPos.setX(bSwitcher->globalPos->x() - (width() / 2)); + } + else if ( bSwitcher->globalPos->y() >= 0 ) + { + nPos.setY(bSwitcher->globalPos->y() + bSwitcher->height() ); + nPos.setX(bSwitcher->globalPos->x() - (width() / 2)); + } + if ( nPos.x() < 0 ) + { + nPos.setX(bSwitcher->globalPos->x() + bSwitcher->width()); + } + else if ( bSwitcher->globalPos->x() + (width() / 2) > w ) + { + nPos.setX(bSwitcher->globalPos->x() - width()); + } + move(nPos); + } + + // If it was set by the normal sessionmanagement it needs + // to set the Flags again + setWFlags(Qt::WStyle_StaysOnTop | Qt::WX11BypassWM); + QWidget::showEvent(e); // execute the normal showevent + raise(); +} + +void bab::saveSettings(){ + QSettings *config = new QSettings(); +// KConfig *config = new KConfig("baghirarc"); + config->beginGroup("/baghira/BAB"); + config->writeEntry("defaultState", DefStyle->currentItem()); + config->writeEntry("roundCorners", cornerCheck->isChecked()); + config->endGroup(); + delete config; +} + +QPoint *BabSwitcher::globalPos = new QPoint::QPoint(0,0); + +BabSwitcher::BabSwitcher(bab *parent, const char *name) + : KSystemTray(parent,name), DCOPObject("babInterface") { + KIconLoader* iLoader = KGlobal::iconLoader(); + JaguarIcon = iLoader->loadIcon("bab_jaguar", KIcon::Small, 22); + PantherIcon = iLoader->loadIcon("bab_panther", KIcon::Small, 22); + iTunesIcon = iLoader->loadIcon("bab_itunes", KIcon::Small, 22); + TigerIcon = iLoader->loadIcon("bab_tiger", KIcon::Small, 22); + MilkIcon = iLoader->loadIcon("bab_milk", KIcon::Small, 22); + installEventFilter(this); +} + +BabSwitcher::~BabSwitcher(){ +} + +void BabSwitcher::toggle() +{ + if ( state_ < Milk ) + state_++; + else + state_ = Jaguar; + decoState_ = state_; + QString nameString; + switch (state_) + { + case Jaguar: + nameString = "Jaguar"; + break; + case Panther: + nameString = "Panther"; + break; + case iTunes: + nameString = "Brushed"; + break; + case Tiger: + nameString = "Tiger"; + break; + case Milk: + nameString = "Milk"; + } + QString tmpString = QDir::homeDirPath() + "/.baghira/" + nameString; + QString tmpString2 = QDir::homeDirPath() + "/.baghira/.bab/.style"; + remove(tmpString2.latin1()); + symlink (tmpString.latin1(), tmpString2.latin1()); + tmpString2 = QDir::homeDirPath() + "/.baghira/.bab/.deco"; + remove(tmpString2.latin1()); + symlink (tmpString.latin1(), tmpString2.latin1()); + repaint(); +} + +void BabSwitcher::setStyle(QString style) +{ + if (style == "Jaguar") + state_ = Jaguar; + else if (style == "Brushed") + state_ = iTunes; + else if (style == "Tiger") + state_ = Tiger; + else if (style == "Milk") + state_ = Milk; + else + { + if (style != "Panther") + style = "Panther"; + state_ = Panther; + } + QString tmpString = QDir::homeDirPath() + "/.baghira/" + style; + QString tmpString2 = QDir::homeDirPath() + "/.baghira/.bab/.style"; + remove(tmpString2.latin1()); + symlink (tmpString.latin1(), tmpString2.latin1()); + repaint(); +} + +void BabSwitcher::setDeco(QString deco) +{ + if (deco == "Jaguar") + decoState_ = Jaguar; + else if (deco == "Brushed") + decoState_ = iTunes; + else if (deco == "Tiger") + decoState_ = Tiger; + else if (deco == "Milk") + decoState_ = Milk; + else + { + if (deco != "Panther") + deco = "Panther"; + decoState_ = Panther; + } + QString tmpString = QDir::homeDirPath() + "/.baghira/" + deco; + QString tmpString2 = QDir::homeDirPath() + "/.baghira/.bab/.deco"; + remove(tmpString2.latin1()); + symlink (tmpString.latin1(), tmpString2.latin1()); +} + +QString BabSwitcher::style() +{ + switch (state_) + { + case Jaguar: + return "Jaguar"; + case Panther: + return "Panther"; + case iTunes: + return "Brushed"; + case Tiger: + return "Tiger"; + case Milk: + return "Milk"; + } +} + +QString BabSwitcher::deco() +{ + switch (decoState_) + { + case Jaguar: + return "Jaguar"; + case Panther: + return "Panther"; + case iTunes: + return "Brushed"; + case Tiger: + return "Tiger"; + case Milk: + return "Milk"; + } +} + +void BabSwitcher::start(QString name, QString settings) +{ + KProcess proc; + QString section; int i = 0; bool done = false; + if (name.contains(' ')) + { + while (!done) + { + section = name.section(' ',i,i); + if (i == 0) + { + QString tmpString = QDir::homeDirPath() + "/.baghira/" + settings; + QString tmpString2 = QDir::homeDirPath() + "/.baghira/.bab/" + section; + remove(tmpString2.latin1()); + symlink (tmpString.latin1(), tmpString2.latin1()); + } + if (!section.isEmpty()) + proc << section; + else + done = true; + i++; + } + } + else + { + QString tmpString = QDir::homeDirPath() + "/.baghira/" + settings; + QString tmpString2 = QDir::homeDirPath() + "/.baghira/.bab/" + name; + remove(tmpString2.latin1()); + symlink (tmpString.latin1(), tmpString2.latin1()); + proc << name; + } + proc.start(KProcess::DontCare); + proc.detach(); +} + +void BabSwitcher::emitStyleChanged() +{ + KIPC::sendMessageAll(KIPC::StyleChanged); + KIPC::sendMessageAll(KIPC::ToolbarStyleChanged); +} + +void BabSwitcher::mousePressEvent(QMouseEvent *e){ + + QWidget *daddy = parentWidget(); + + globalPos->setX(e->globalX() - e->x()); + globalPos->setY(e->globalY() - e->y()); + + switch ( e->button() ) + { + case LeftButton: + { + toggle(); + break; + } + case RightButton: + default: + { + if ( daddy->isVisible() ) + daddy->hide(); + else + daddy->show(); + } + } +} + +void BabSwitcher::paintEvent(QPaintEvent *ev){ + KSystemTray::paintEvent(ev); + QPainter icyApainter(this); + switch (state_) + { + case Jaguar: + JaguarIcon.isNull() ? icyApainter.fillRect(rect(), Qt::blue) : icyApainter.drawPixmap(0, 0, JaguarIcon); + break; + case Panther: + PantherIcon.isNull() ? icyApainter.fillRect(rect(), Qt::black) : icyApainter.drawPixmap(0, 0, PantherIcon); + break; + case iTunes: + iTunesIcon.isNull() ? icyApainter.fillRect(rect(), Qt::gray) : icyApainter.drawPixmap(0, 0, iTunesIcon); + break; + case Tiger: + TigerIcon.isNull() ? icyApainter.fillRect(rect(), Qt::yellow) : icyApainter.drawPixmap(0, 0, TigerIcon); + break; + case Milk: + MilkIcon.isNull() ? icyApainter.fillRect(rect(), Qt::white) : icyApainter.drawPixmap(0, 0, MilkIcon); + default: + break; + } + icyApainter.end(); +} + +Corner::Corner(Side side) : QWidget(0, (side == left)?"left_corner":"right_corner", Qt::WType_TopLevel | Qt::WStyle_NoBorder | Qt::WStyle_StaysOnTop | Qt::WX11BypassWM ) +{ + if (side == left) { + setFixedSize(5,4); + move(0,0); + show(); + setPaletteBackgroundColor(Qt::black); + XRectangle* xrects = new XRectangle[4]; + xrects[ 0 ].x = 0; + xrects[ 0 ].y = 0; + xrects[ 0 ].width = 5; + xrects[ 0 ].height = 1; + xrects[ 1 ].x = 0; + xrects[ 1 ].y = 1; + xrects[ 1 ].width = 3; + xrects[ 1 ].height = 1; + xrects[ 2 ].x = 0; + xrects[ 2 ].y = 2; + xrects[ 2 ].width = 2; + xrects[ 2 ].height = 1; + xrects[ 3 ].x = 0; + xrects[ 3 ].y = 3; + xrects[ 3 ].width = 1; + xrects[ 3 ].height = 2; + XShapeCombineRectangles( qt_xdisplay(), winId(), ShapeBounding, 0, 0, + xrects, 4, ShapeSet, 0 ); + delete[] xrects; + } + else { + setFixedSize(5,4); + move(QApplication::desktop()->width()-5,0); + show(); + setPaletteBackgroundColor(Qt::black); + XRectangle* xrects = new XRectangle[4]; + xrects[ 0 ].x = 0; + xrects[ 0 ].y = 0; + xrects[ 0 ].width = 5; + xrects[ 0 ].height = 1; + xrects[ 1 ].x = 2; + xrects[ 1 ].y = 1; + xrects[ 1 ].width = 3; + xrects[ 1 ].height = 1; + xrects[ 2 ].x = 3; + xrects[ 2 ].y = 2; + xrects[ 2 ].width = 2; + xrects[ 2 ].height = 1; + xrects[ 3 ].x = 4; + xrects[ 3 ].y = 3; + xrects[ 3 ].width = 1; + xrects[ 3 ].height = 2; + XShapeCombineRectangles( qt_xdisplay(), winId(), ShapeBounding, 0, 0, + xrects, 4, ShapeSet, 0 ); + delete[] xrects; + } +} + +void Corner::toggle(bool b) +{ + b?show():hide(); +} + +#include "bab.moc" diff --git a/bab/styleconfdialog.cpp b/bab/styleconfdialog.cpp new file mode 100644 index 0000000..245f5ab --- /dev/null +++ b/bab/styleconfdialog.cpp @@ -0,0 +1,63 @@ +/* + * KCMStyle's container dialog for custom style setup dialogs + * + * (c) 2003 Maksim Orlovich <maksim.orlovich@kdemail.net> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "styleconfdialog.h" +#include <klocale.h> + +StyleConfigDialog::StyleConfigDialog(QWidget* parent, QString styleName): + KDialogBase(parent, "StyleConfigDialog", + true, /*modal*/ + styleName, + KDialogBase::Default | KDialogBase::Ok | KDialogBase::Cancel, + KDialogBase::Cancel) +{ + m_styleDirty = false; + m_decoDirty = false; + connect( this, SIGNAL( defaultClicked() ), this, SIGNAL( defaults() )); + connect( this, SIGNAL( okClicked() ), this, SIGNAL( save() )); + connect( this, SIGNAL( okClicked() ), this, SLOT( saveDeco() )); +} + +void StyleConfigDialog::saveDeco() +{ + emit save(0); +} + +bool StyleConfigDialog::isStyleDirty() const +{ + return m_styleDirty; +} + +void StyleConfigDialog::setStyleDirty(bool dirty) +{ + m_styleDirty = dirty; +} + +bool StyleConfigDialog::isDecoDirty() const +{ + return m_decoDirty; +} + +void StyleConfigDialog::setDecoDirty() +{ + m_decoDirty = TRUE; +} + +#include <styleconfdialog.moc> diff --git a/bab/styleconfdialog.h b/bab/styleconfdialog.h new file mode 100644 index 0000000..9a125d7 --- /dev/null +++ b/bab/styleconfdialog.h @@ -0,0 +1,53 @@ +/* + * KCMStyle's container dialog for custom style setup dialogs + * + * (c) 2003 Maksim Orlovich <maksim.orlovich@kdemail.net> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef STYLE_CONF_DIALOG +#define STYLE_CONF_DIALOG + +#include <kdialogbase.h> + +class KConfig; +class StyleConfigDialog: public KDialogBase +{ + Q_OBJECT +public: + StyleConfigDialog(QWidget* parent, QString styleName); + + bool isStyleDirty() const; + bool isDecoDirty() const; + +public slots: + void setStyleDirty(bool dirty); + void setDecoDirty(); + +private slots: + void saveDeco(); + +signals: + void defaults(); + void save(); + void save(KConfig*); + +private: + bool m_styleDirty; + bool m_decoDirty; +}; + +#endif |