diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2015-10-01 17:05:29 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2015-10-01 17:05:29 +0200 |
commit | 39f2c6a84cd715b11fb3ffa82a86abf2fb9bcd70 (patch) | |
tree | d6bc97f38d36892b14703c788cef782f13ee2a4d /src | |
download | kooldock-39f2c6a84cd715b11fb3ffa82a86abf2fb9bcd70.tar.gz kooldock-39f2c6a84cd715b11fb3ffa82a86abf2fb9bcd70.zip |
Initial import of kooldock 0.4.7
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 64 | ||||
-rw-r--r-- | src/appProp.ui | 264 | ||||
-rw-r--r-- | src/apppropprg.cpp | 159 | ||||
-rw-r--r-- | src/apppropprg.h | 45 | ||||
-rw-r--r-- | src/clip.cpp | 47 | ||||
-rw-r--r-- | src/clip.h | 29 | ||||
-rw-r--r-- | src/dinfo.cpp | 56 | ||||
-rw-r--r-- | src/dinfo.h | 42 | ||||
-rw-r--r-- | src/item.cpp | 274 | ||||
-rw-r--r-- | src/item.h | 84 | ||||
-rw-r--r-- | src/kooldock.cpp | 3848 | ||||
-rw-r--r-- | src/kooldock.h | 364 | ||||
-rw-r--r-- | src/main.cpp | 114 | ||||
-rw-r--r-- | src/setupdialog.ui | 1990 | ||||
-rw-r--r-- | src/setupdialogprg.cpp | 702 | ||||
-rw-r--r-- | src/setupdialogprg.h | 102 | ||||
-rw-r--r-- | src/xosd.cpp | 226 | ||||
-rw-r--r-- | src/xosd.h | 58 |
18 files changed, 8468 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..703b7bf --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,64 @@ +####### kdevelop will overwrite this part!!! (begin)########## +bin_PROGRAMS = kooldock + +## INCLUDES were found outside kdevelop specific part + +kooldock_SOURCES = appProp.ui apppropprg.cpp clip.cpp dinfo.cpp item.cpp \ + kooldock.cpp main.cpp setupdialog.ui setupdialogprg.cpp xosd.cpp +kooldock_LDADD = $(LIB_KIO) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET) + + +EXTRA_DIST = main.cpp kooldock.cpp kooldock.h item.cpp item.h + +####### kdevelop will overwrite this part!!! (end)############ +# These paths are KDE specific. Use them: +# kde_appsdir Where your application's menu entry (.desktop) should go to. +# kde_icondir Where your icon should go to - better use KDE_ICON. +# kde_sounddir Where your sounds should go to. +# kde_htmldir Where your docs should go to. (contains lang subdirs) +# kde_datadir Where you install application data. (Use a subdir) +# kde_locale Where translation files should go to. (contains lang subdirs) +# kde_cgidir Where cgi-bin executables should go to. +# kde_confdir Where config files should go to (system-wide ones with default values). +# kde_mimedir Where mimetypes .desktop files should go to. +# kde_servicesdir Where services .desktop files should go to. +# kde_servicetypesdir Where servicetypes .desktop files should go to. +# kde_toolbardir Where general toolbar icons should go to (deprecated, use KDE_ICON). +# kde_wallpaperdir Where general wallpapers should go to. +# kde_templatesdir Where templates for the "New" menu (Konqueror/KDesktop) should go to. +# kde_bindir Where executables should go to. Use bin_PROGRAMS or bin_SCRIPTS. +# kde_libdir Where shared libraries should go to. Use lib_LTLIBRARIES. +# kde_moduledir Where modules (e.g. parts) should go to. Use kde_module_LTLIBRARIES. +# kde_styledir Where Qt/KDE widget styles should go to (new in KDE 3). +# kde_designerdir Where Qt Designer plugins should go to (new in KDE 3). + +# set the include path for X, qt and KDE +INCLUDES= $(all_includes) + +METASOURCES = AUTO + +# the library search path. +kooldock_LDFLAGS = $(all_libraries) $(KDE_RPATH) + +# Uncomment the following two lines if you add a ui.rc file for your application to make use of +# KDE?s XML GUI builing +#rcdir = $(kde_datadir)/kooldock +#rc_DATA = kooldockui.rc + +#WARNING: if you use a ui.rc file above, use: + +# messages: rc.cpp + +# instead of + +# messages: + +messages: + LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \ + if test -n "$$LIST"; then \ + $(XGETTEXT) $$LIST -o $(podir)/kooldock.pot; \ + fi + + +noinst_HEADERS = apppropprg.h clip.h dinfo.h setupdialogprg.h xosd.h + diff --git a/src/appProp.ui b/src/appProp.ui new file mode 100644 index 0000000..38e732f --- /dev/null +++ b/src/appProp.ui @@ -0,0 +1,264 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>appProp</class> +<widget class="QDialog"> + <property name="name"> + <cstring>appProp</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>421</width> + <height>259</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32767</width> + <height>32767</height> + </size> + </property> + <property name="caption"> + <string>Launcher Properties</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <property name="modal"> + <bool>true</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton" row="2" column="2"> + <property name="name"> + <cstring>buttonCancel</cstring> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + <widget class="QPushButton" row="2" column="1"> + <property name="name"> + <cstring>buttonOk</cstring> + </property> + <property name="text"> + <string>&Add</string> + </property> + <property name="accel"> + <string>Alt+A</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <spacer row="2" column="0"> + <property name="name"> + <cstring>Horizontal Spacing2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>250</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QGroupBox" row="1" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>groupBox1</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>3</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Advanced Options</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox" row="0" column="0"> + <property name="name"> + <cstring>terminal</cstring> + </property> + <property name="text"> + <string>Run From Terminal</string> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0"> + <property name="name"> + <cstring>cuser</cstring> + </property> + <property name="text"> + <string>Run as different User</string> + </property> + </widget> + <widget class="QCheckBox" row="0" column="1"> + <property name="name"> + <cstring>tclose</cstring> + </property> + <property name="text"> + <string>Keep terminal open after exit</string> + </property> + </widget> + <widget class="QLineEdit" row="1" column="1"> + <property name="name"> + <cstring>user</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="0" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>groupBox2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>3</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Minimal Options</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Don't forget to chose an icon.</string> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string><b>Command</b></string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string><b>Name</b></string> + </property> + </widget> + <widget class="QPushButton" row="2" column="2"> + <property name="name"> + <cstring>cmdfile</cstring> + </property> + <property name="text"> + <string>&Browse</string> + </property> + <property name="accel"> + <string>Alt+B</string> + </property> + </widget> + <widget class="KIconButton" row="0" column="2" rowspan="2" colspan="1"> + <property name="name"> + <cstring>iconbutton</cstring> + </property> + <property name="text"> + <string>Icon</string> + </property> + </widget> + <widget class="QLineEdit" row="1" column="1"> + <property name="name"> + <cstring>cmdname</cstring> + </property> + </widget> + <widget class="QLineEdit" row="2" column="1"> + <property name="name"> + <cstring>cmdpath</cstring> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>appProp</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>appProp</receiver> + <slot>reject()</slot> + </connection> + <connection> + <sender>cuser</sender> + <signal>toggled(bool)</signal> + <receiver>appProp</receiver> + <slot>cuserchk()</slot> + </connection> + <connection> + <sender>terminal</sender> + <signal>toggled(bool)</signal> + <receiver>appProp</receiver> + <slot>terminalchk()</slot> + </connection> + <connection> + <sender>cmdfile</sender> + <signal>clicked()</signal> + <receiver>appProp</receiver> + <slot>cmdfile_clicked()</slot> + </connection> +</connections> +<slots> + <slot>cuserchk(bool)</slot> + <slot>cuserchk()</slot> + <slot>terminalchk()</slot> + <slot>cmdfile_clicked()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>kicondialog.h</includehint> +</includehints> +</UI> diff --git a/src/apppropprg.cpp b/src/apppropprg.cpp new file mode 100644 index 0000000..b806b67 --- /dev/null +++ b/src/apppropprg.cpp @@ -0,0 +1,159 @@ +// +// C++ Implementation: apppropprg +// +// Description: +// +// +// Author: KoolDock team <radix@kde.cl>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include <kicondialog.h> +#include <kfiledialog.h> +#include <kmessagebox.h> +#include <kstandarddirs.h> +#include <klocale.h> + +#include "apppropprg.h" +#include "appProp.h" +#include "kooldock.h" + +appPropPrg::appPropPrg(QWidget *parent, const char *name) +: appProp(parent, name) +{ + +} + + +appPropPrg::~appPropPrg() +{ +} + +void appPropPrg::accept() +{ + QString icon; + QString desktop; + QString path; + QString puser; + + icon=iconbutton->icon(); + desktop=cmdname->text(); + path=cmdpath->text(); + puser=user->text(); + + if(icon.length() == 0) + { + KMessageBox::sorry(0, i18n("You must select an icon!"), i18n("Error"), 1); + return; + } + if(desktop.length() == 0) + { + KMessageBox::sorry(0, i18n("You must enter a name!"), i18n("Error"), 1); + return; + } + if(path.length() == 0) + { + KMessageBox::sorry(0, i18n("You must enter a command or path!"), i18n("Error"), 1); + return; + } + if((cuser->isChecked()==true) && (puser.length()==0)) + { + KMessageBox::sorry(0, i18n("You must provide a username!"), i18n("Error"), 1); + return; + } + + + // Now we modify desktop (lowercase, no spaces) + desktop.remove(" ", TRUE); + desktop=desktop.lower(); + desktop.append(".desktop"); + + //To handle position + QString progPath = locateLocal("data", "kooldock"); + QDir dir(progPath + QString("/menu/")); + QString preffix; + QStringList fileList = dir.entryList("*.desktop"); + + int pos=fileList.count(); + if(pos<10) preffix=QString("0%1_").arg(pos); + if(pos>=10) preffix=QString("%1_").arg(pos); + + desktop.prepend(preffix); + //End handling position + + /* Here we add the .desktop file to the menuPath */ + KoolDock::addFile(desktop, icon, cmdpath->text(), cmdname->text(), true, terminal->isChecked(), tclose->isChecked(), cuser->isChecked(), user->text()); + user->setEnabled(false); + cuser->setChecked(false); + terminal->setChecked(false); + tclose->setChecked(false); + tclose->setEnabled(false); + this->hide(); + emit apply(); +} + +void appPropPrg::reject() +{ + user->setEnabled(false); + cuser->setChecked(false); + terminal->setChecked(false); + tclose->setChecked(false); + tclose->setEnabled(false); + this->hide(); +} + +void appPropPrg::closeEvent( QCloseEvent *e ) +{ + e->ignore(); + reject(); +} + +void appPropPrg::cmdfile_clicked() +{ + QString tmp; + + QString fileToOpen=KFileDialog::getOpenFileName(QDir::currentDirPath(), "*.*", this, i18n("Open File")); + if (!fileToOpen.isEmpty()) + { + cmdpath->setText(fileToOpen); + + //Lets set a default icon based on the program name + tmp=fileToOpen; + int pos=tmp.findRev("/", -1); + if(pos!=-1) + { + tmp.remove(1, pos); + tmp.remove("/", TRUE); + } + iconbutton->setIcon(tmp); + cmdname->setText(tmp); + } +} + +void appPropPrg::cuserchk() +{ + if(cuser->isChecked()==true) + { + user->setEnabled(true); + } + else + { + user->setEnabled(false); + } +} + +void appPropPrg::terminalchk() +{ + if(terminal->isChecked()==true) + { + tclose->setEnabled(true); + } + else + { + tclose->setChecked(false); + tclose->setEnabled(false); + } +} + +#include "apppropprg.moc" diff --git a/src/apppropprg.h b/src/apppropprg.h new file mode 100644 index 0000000..cc8124f --- /dev/null +++ b/src/apppropprg.h @@ -0,0 +1,45 @@ +// +// C++ Interface: apppropprg +// +// Description: +// +// +// Author: KoolDock team <radix@kde.cl>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef APPPROPPRG_H +#define APPPROPPRG_H + +#include <qwidget.h> +#include "appProp.h" + +/** +@author KoolDock team +*/ + +class appPropPrg : public appProp +{ +Q_OBJECT + + public: + appPropPrg(QWidget *parent = 0, const char *name = 0); + ~appPropPrg(); + + void addFile(QString filename, QString iconname, QString execname, QString name, bool notify); + + public slots: + void accept(); + void reject(); + void cmdfile_clicked(); + void cuserchk(); + void terminalchk(); + signals: + void apply(); + + protected: + void closeEvent( QCloseEvent* ); +}; + +#endif diff --git a/src/clip.cpp b/src/clip.cpp new file mode 100644 index 0000000..de71d2b --- /dev/null +++ b/src/clip.cpp @@ -0,0 +1,47 @@ +#include "clip.h" + +#include <qwidget.h> +#include <qbitmap.h> +#include <qpainter.h> +#include <netwm.h> +#include <netwm_def.h> +#include <kwin.h> + +#include <kdebug.h> + +clip::clip(QWidget *parent, const char *name) : QWidget(parent, name, WStyle_Customize | WStyle_NoBorder | WNoAutoErase | WDestructiveClose | WMouseNoMask | WStyle_StaysOnTop) +{ + info = new NETWinInfo( qt_xdisplay(), winId(), qt_xrootwin(), NET::WMState); + info->setDesktop( NETWinInfo::OnAllDesktops ); + + info->setState(NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager, NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager); + hide(); + setBackgroundMode(NoBackground); + + KWin::setOnAllDesktops(winId(), true); + KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager); + KWin::setType(winId(), NET::Dock); + + setCaption("kooldock clipping window"); +} + +clip::~clip() +{ +} + +void clip::clipDesktop(int p1,int p2,int p3,int p4,int p5,int p6,int p7,int p8,int p9,int p10,int p11,int p12) +{ +KWin::setExtendedStrut(winId(), p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); +} + +void clip::paintEvent(QPaintEvent *) +{ + QBitmap bm(size()); + QPainter mp; + + mp.begin(&bm, this); + mp.fillRect(rect(), Qt::black); + mp.end(); + + setMask(bm); +} diff --git a/src/clip.h b/src/clip.h new file mode 100644 index 0000000..c14af10 --- /dev/null +++ b/src/clip.h @@ -0,0 +1,29 @@ +#ifndef clip_H_ +#define clip_H_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <qwidget.h> + +#include <netwm.h> +#include <kwin.h> + +class clip : public QWidget +{ +Q_OBJECT + public: + clip(QWidget* parent=0, const char *name=0); + + virtual ~clip(); + void clipDesktop(int,int,int,int,int,int,int,int,int,int,int,int); + + private: + NETWinInfo *info; + + protected: + void paintEvent(QPaintEvent *); + +}; +#endif // CLIP_H_ diff --git a/src/dinfo.cpp b/src/dinfo.cpp new file mode 100644 index 0000000..f6cf476 --- /dev/null +++ b/src/dinfo.cpp @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (C) 2007 by bisiek * + * bisiek9@gmail.com * + * * + * 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 "dinfo.h" + +dInfo::dInfo() +{ + mBool=false; + mInt=0; +} + + +dInfo::~dInfo() +{ +} + +bool dInfo::gBool() +{ + return mBool; +} + +void dInfo::sBool(bool nVal) +{ + mBool=nVal; +} + +int dInfo::gInt() +{ + return mInt; +} + +void dInfo::sInt(int nVal) +{ + mInt=nVal; +} + +void dInfo::inc(int val) +{ + mInt+=val; +} diff --git a/src/dinfo.h b/src/dinfo.h new file mode 100644 index 0000000..681f04d --- /dev/null +++ b/src/dinfo.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (C) 2007 by bisiek * + * bisiek9@gmail.com * + * * + * 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 DINFO_H +#define DINFO_H + +#include <kpopupmenu.h> +/** + @author bisiek <bisiek9@gmail.com> +*/ +class dInfo{ +public: + dInfo(); + ~dInfo(); + bool gBool(); + void sBool(bool nVal); + int gInt(); + void sInt(int nVal); + void inc(int val); +private: + bool mBool; + int mInt; + +}; + +#endif diff --git a/src/item.cpp b/src/item.cpp new file mode 100644 index 0000000..1de9cf7 --- /dev/null +++ b/src/item.cpp @@ -0,0 +1,274 @@ +/*************************************************************************** + item.cpp - description + ------------------- + begin : Fri May 23 2003 + copyright : (C) 2003 by KoolDock team + email : + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 <kglobal.h> +#include <kicontheme.h> + +#include <qfile.h> +#include <qimage.h> +#include <qtextstream.h> + +#include "item.h" + +Item::Item(QString iconName, QString cmd, QString name, int minSize, int maxSize) { + iLoader = KGlobal::iconLoader(); + command = cmd; + this->name = name; + mCount=0; + mIndex=0; + mMIndex=0; + mClass=""; + this->minSize = minSize; + this->maxSize = maxSize; + this->iconName = iconName; + + QImage icon(iLoader->loadIcon(iconName, KIcon::NoGroup, 64).convertToImage()); + if (minSize <= maxSize) + { + int count = maxSize - minSize + 1; + + icons.setAutoDelete(TRUE); + + for(int i=0; i<count; i++) + { + if (i % SIZE_INC == 0) + { + icons.append(new QPixmap(icon.smoothScale(minSize + i, minSize + i))); + } + } + } + + id = 0; + animed = FALSE; +} + + +Item::Item(QString fileName, int minSize, int maxSize) +{ + QString line; + QFile in(fileName); + in.open(IO_ReadOnly); + mCount=0; + mIndex=0; + mMIndex=0; + mClass=""; + if(in.readLine(line, MAX_LEN) != -1) + { + if(line.contains("[Desktop Entry]", FALSE) > 0) + { + while (in.readLine(line, MAX_LEN) != -1) + { + if(line.startsWith("Exec=")) + { + command = line.mid(5).stripWhiteSpace(); + } + else if(line.startsWith("Icon=")) + { + iconName = line.mid(5).stripWhiteSpace(); + } + else if(line.startsWith("Name=")) + { + name = line.mid(5).stripWhiteSpace(); + } + } + } + } + + in.close(); + + iLoader = KGlobal::iconLoader(); + this->minSize = minSize; + this->maxSize = maxSize; + this->filename = fileName; + mCount=0; + mIndex=0; + mMIndex=0; + mClass=""; + QImage icon(iLoader->loadIcon(iconName, KIcon::NoGroup, 64).convertToImage()); + if (minSize <= maxSize) + { + int count = maxSize - minSize + 1; + + icons.setAutoDelete(TRUE); + + for(int i=0; i<count; i++) + { + if (i % SIZE_INC == 0) + { + icons.append(new QPixmap(icon.smoothScale(minSize + i, minSize + i))); + } + } + } + + id = 0; + animed = FALSE; +} + +Item::Item(QPixmap iconBig, WId id, QString name, int minSize, int maxSize, bool wi) +{ + setId(id); + this->name = name; + mCount=0; + mIndex=0; + mMIndex=0; + mClass=""; + this->minSize = minSize; + this->maxSize = maxSize; + command = ""; + wIcon=wi; + QImage icon(iconBig.convertToImage()); + if(minSize <= maxSize) + { + int count = maxSize - minSize + 1; + + icons.setAutoDelete(TRUE); + + for(int i=0; i<count; i++) + { + if (i % SIZE_INC == 0) + { + if (wi) + {icons.append(new QPixmap(icon));} + else + { + icons.append(new QPixmap(icon.scale(minSize + i, minSize + i))); + } +//moothS + } + } + } + animed = FALSE; +} + +Item::~Item() +{ +} + +QPixmap* Item::getIcon(int size) +{ + if ((size >= minSize) && (size <= maxSize)) + { + int d = size - minSize; + return(icons.at(d / SIZE_INC)); + + //return(new QPixmap (icons.at(maxSize-minSize)->convertToImage().scale(size,size))); + } + else + { + return(0); + } +} + +QString Item::getCommand() +{ + return(command); +} + +QString Item::getName() +{ + return(name); +} + +QCString Item::getClass() +{ + return(mClass); +} + +int Item::getCount() +{ + return(mCount); +} + +int Item::getIndex() +{ + return(mIndex); +} + +int Item::getMIndex() +{ + return(mMIndex); +} + +QString Item::getFilename() +{ + return(filename); +} + +WId Item::getId() +{ + return(id); +} + +void Item::setId(WId newId) +{ + + info = KWin::windowInfo(newId, 0, NET::WM2AllowedActions); + id=newId; +} + +void Item::setIcon(QPixmap iconBig) +{ + icons.clear(); + QImage icon(iconBig.convertToImage()); + + int count = maxSize - minSize + 1; + + icons.setAutoDelete(TRUE); + + for (int i = 0; i < count; i++) + { + if (i % SIZE_INC == 0) + { + icons.append(new QPixmap(icon.smoothScale(minSize + i, minSize + i))); + } + } +} + +void Item::setName(QString newName) +{ + name = newName; +} + +void Item::setClass(QCString newClass) +{ + mClass = newClass; +} + +void Item::setCount(int newCount) +{ + mCount = newCount; +} + +void Item::setIndex(int newIndex) +{ + mIndex = newIndex; +} + +void Item::setMIndex(int newIndex) +{ + mMIndex = newIndex; +} + +bool Item::isAnimed() +{ + return(this->animed); +} + +void Item::anim(bool param) +{ + this->animed=param; +} diff --git a/src/item.h b/src/item.h new file mode 100644 index 0000000..27b22b9 --- /dev/null +++ b/src/item.h @@ -0,0 +1,84 @@ +/*************************************************************************** + item.h - description + ------------------- + begin : Fri May 23 2003 + copyright : (C) 2003 by KoolDock team + email : + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 ITEM_H +#define ITEM_H + +#include <kiconloader.h> +#include <kwin.h> + +#include <qstring.h> +#include <qpixmap.h> +#include <qptrlist.h> + +#include <vector> +#include <qevent.h> +#include <qnamespace.h> + +const int MAX_LEN = 256; +const int SIZE_INC = 1; + +class Item +{ + public: + Item(QString iconName, QString cmd, QString name, int minSize, int maxSize); + Item(QString fileName, int minSize, int maxSize); + Item(QPixmap iconBig, WId id, QString name, int minSize, int maxSize, bool wi =FALSE); + ~Item(); + + void setIcon(QPixmap iconBig); + + QPixmap* getIcon(int size); + QString getCommand(); + QString getName(); + QCString getClass(); + int getCount(); + int getIndex(); + int getMIndex(); + WId getId(); + KWin::WindowInfo info; + void setId(WId newId); + QString getFilename(); + + void setName(QString newName); + void setClass(QCString newClass); + void setCount(int newCount); + void setIndex(int newIndex); + void setMIndex(int newIndex); + bool animed; + bool isAnimed(); + void anim(bool param); + QPtrList<QPixmap> icons; + bool wIcon; + + private: + KIconLoader *iLoader; + + int minSize; + int maxSize; + QString command; + QString name; + QCString mClass; + int mCount; + int mIndex; + int mMIndex; + QString iconName; + QString filename; + WId id; +}; + +#endif diff --git a/src/kooldock.cpp b/src/kooldock.cpp new file mode 100644 index 0000000..58a0831 --- /dev/null +++ b/src/kooldock.cpp @@ -0,0 +1,3848 @@ +/************************************************************************** + kooldock.cpp - description + ------------------- + begin : Tue Jun 10 22:18:34 BST 2003 + copyright : (C) 2003 by KoolDock team + email : +***************************************************************************/ + +/*************************************************************************** + * * + * 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 <stdlib.h> +#include <math.h> + +#include <qpixmap.h> +#include <qimage.h> +#include <qpainter.h> +#include <qcursor.h> +#include <qdir.h> +#include <qstringlist.h> +#include <qvaluelist.h> +#include <qtooltip.h> +#include <qrect.h> +#include <qfile.h> +#include <qtextstream.h> +#include <qbrush.h> +#include <qpoint.h> +#include <qfont.h> +#include <qdatetime.h> + +#include <kwin.h> +#include <kprocess.h> +#include <netwm_def.h> +#include <kmessagebox.h> +#include <klocale.h> +#include <kcmdlineargs.h> +#include <krun.h> +#include <kurifilter.h> +#include <kpixmapio.h> +#include <kstandarddirs.h> +#include <kaboutapplication.h> +#include <qlistbox.h> +#include <keditlistbox.h> + +// for "renicing" the bar +#include <sys/time.h> +#include <sys/resource.h> + + +#include "kooldock.h" + +#include <kconfig.h> +#include <kdebug.h> +#include "setupdialogprg.h" + +// macros + +#define min(a, b) (a < b) ? (a) : (b) +#define max(a, b) (a > b) ? (a) : (b) + +// compiler issues +#if __GNUC__ == 2 && __GNUC_MINOR__ <= 95 +# define _GCC295 +#endif +#include <dcopclient.h> +#include <iostream> +#include <qdatastream.h> + +KoolDock::KoolDock(QWidget *parent, const char *name) : QWidget(parent, name, WStyle_Customize | WStyle_NoBorder | WNoAutoErase | WDestructiveClose | WStyle_StaysOnTop )//| WX11BypassWM) +{ + // Default configuration paths + progPath = locateLocal("data", "kooldock"); + menuPath = progPath + QString("/menu/"); + confFile = locateLocal("config", "kooldockrc"); + + noSet=false; + firstInit=true; + setupdlg = new SetupDialogPrg(); // create the setup dialog object. + + connect (setupdlg, SIGNAL(apply()), SLOT(chkRestart())); + perf = new QTime(); + + reloadIcons=TRUE; + + //Menu definitions + deskpopup=new KPopupMenu(); + appMenu=new KPopupMenu(); + godesk=new KPopupMenu; + tasklist=new KPopupMenu; + popup=new KPopupMenu; + advMenu=new KPopupMenu; + + connect(popup, SIGNAL(aboutToShow()), SLOT(aboutToShow())); + connect(popup, SIGNAL(aboutToHide()), SLOT(aboutToHide())); + connect(appMenu, SIGNAL(aboutToShow()), SLOT(aboutToShow())); + connect(appMenu, SIGNAL(aboutToHide()), SLOT(aboutToHide())); + connect(deskpopup, SIGNAL(aboutToShow()), SLOT(menuShow())); + connect(appMenu, SIGNAL(highlighted(int)), this, SLOT(menuX(int))); + connect(godesk, SIGNAL(activated(int)), this, SLOT(goToDesktop(int))); + connect(tasklist, SIGNAL(activated(int)), this, SLOT(goToWindow(int))); + connect(deskpopup, SIGNAL(activated(int)), this, SLOT(sendToDesktop(int))); + menuCount=0; + + init1(); + + QString welcomeMsg; + if (fFirstRun) + { + // Show welcome dialog. + welcomeMsg = QString("<center><B>Welcome</B></center>It appears to be the first time you run KoolDock.<br>" + "By default the dock is hidden at the botton of the screen, move your mouse" + " to the bottom edge of the screen and the dock will appear.<br>" + "Right click on the dock for a menu that allows you to configure it<br>" + "or run with <I>-o</I> parameter to have preferences window at start.<br>" + "We hope this software is usefull for you<br>-- The KoolDock Team"); + KMessageBox::information(0L, i18n(welcomeMsg)); + saveConf(); // create initial configuration. + } + + init2(); + firstInit=false; +} +KoolDock::~KoolDock() +{ + if (xosdw) delete(xosdw); + if (clipw) delete(clipw); + if (info) delete(info); + if (wm) delete(wm); + if (setupdlg) delete(setupdlg); + if (rootpix) delete(rootpix); + if (trackTimer) delete(trackTimer); + if (mTimer) delete(mTimer); + if (mkbigTimer) delete(mkbigTimer); + if (mksmallTimer) delete(mksmallTimer); + if (onChangeTimer) delete(onChangeTimer); + if (_filterData) delete(_filterData); +} + +void KoolDock::mTimerEnd() +{ + if (menuCount>0) return; + QPoint pointer; + pointer = QCursor::pos(); + lastXPos=pointer.x()-rx; + lastYPos=pointer.y()-ry; + int px,py,pw,ph,pt; + int mpx, mpy; + mpx=pointer.x(); + mpy=pointer.y(); + + if (fExpanded && !mksmallTimer->isActive()) {px=x1;} else {px=x0;} + if ((fOrientation & 2)==2) py=0; else py=dh-h; + pw=w; + ph=h; + if ((fOrientation & 1)==1) + { + pt=px;px=py;py=pt; + pt=pw;pw=ph;ph=pt; + pt=mpx;mpx=mpy;mpy=pt; + } + if (xinerama==1) px+=XinPreviousWidth; + + if (fHidden==1) + { + if (pointer.y() >= py && pointer.y() <= (py + ph) && pointer.x() >= px && pointer.x() <= (px + pw)) + { + mMoveEvent(pointer.x()-rx,pointer.y()-ry); + } + else + { + debug(QString("mTimer1Leave: %1 %2 %3 %4 %5 %6").arg(pointer.x()).arg(pointer.y()).arg(dh-h).arg(ry).arg(rx).arg(x+w)); + onleaveEvent(NULL); + } + } + else + { + if (pointer.y() >= py && pointer.y() <= (py + ph) && pointer.x() >= px && pointer.x() <= (px + pw)) + { + if (fExpanded && !mksmallTimer->isActive()) + { + mMoveEvent(pointer.x()-rx,pointer.y()-ry); + } + else + { + debug(QString("mTimer2EnterEv: %1 %2").arg(pointer.x()-rx).arg(pointer.y()-ry)); + if (mpx>=firstX && mpx<=firstX+tmpw) + { + enterEvent(NULL); + } + } + } + else + { + if (fExpanded) + { + debug(QString("mTimer2Leave")); + onleaveEvent(NULL); + } + } + } + if (fSteppy==1) if (!mkbigTimer->isActive() || !mksmallTimer->isActive()) mMoveEvent(pointer.x()-rx, pointer.y()-ry); +} + + +void KoolDock::trackTimerEnd() +{ + + QPoint pointer; + pointer = QCursor::pos(); + int px, py; + if ((fOrientation & 1) == 1) + { + px = pointer.y(); + py = pointer.x(); + } + else + { + py = pointer.y(); + px = pointer.x(); + } + if ((fOrientation & 2) == 2) py = dh-py; + if (py+2 >= dh && px > x0 && px < x0+w0) + { + if(track2active==FALSE) QTimer::singleShot( hideTimer, this, SLOT(trackTimer2End()) ); + track2active=true; + } +} + +void KoolDock::trackTimer2End() +{ + QPoint pointer; + pointer = QCursor::pos(); + int px, py; + if ((fOrientation & 1) == 1) + { + px = pointer.y(); + py = pointer.x(); + } + else + { + py = pointer.y(); + px = pointer.x(); + } + if ((fOrientation & 2) == 2) py = dh-py; + if (py+2 >= dh && px > x0 && px < x0+w0) + { + if(mksmallTimer->isActive()==TRUE) mksmallTimerstop(); + move( 0, rdh); + raise(); + trackTimer->stop(); + getBottomBG(); + if(h1 > h0) getTopBG(); + debug(QString("tracktimer: grabWindow(%1, %2, %3, %4)").arg(x1).arg(dh - h1).arg(w1).arg(h1)); + move2( x, dh - h); + resize2(w, h); + Ybase = iwBig2; + enterEvent(NULL); + } + track2active=FALSE; +} + +void KoolDock::paintEvent(QPaintEvent *) +{ + // Draw backgound, icons, and all that stuff over the widget. + QPainter p; + if (initialization && ptPart==5) return; + p.begin (&offscr,this); + + int i; + int ii; + + debug(QString("painting")); + + // draw background (new engine) + int bgY; + QImage TempBG; + QPixmap TempScaledLeft; + //QPixmap TempScaledCenter; + QPixmap TempScaledRight; + int p1,p2,p3,p4=0,p5=0,p6,p7,p8,p9,p10,pt; + if (w<dw) Offset=0; + if (fExpanded==FALSE) + { + bgY = 0; + } + else + { + bgY = h1 - h0 + Ybase; + } + lastX = cur_cx[items.count()-1] - iSize[items.count()-1]/2 + adjust; + lastX += iSize[items.count()-1]; + if (ii_first == 0) + { + firstX = cur_cx[0] - iSize[0]/2 - iSpace/2 + adjust+soffset-eoffset+x; + } + else + { + firstX = cur_cx[0] - iSize[0]/2 - iSpace/2 + SPACE_W+x; + } + lastX +=soffset; + tmpw=lastX+x-firstX+iSpace/2; + if (ii_last < (int)items.count()-1) + { + tmpw+=eoffset; + } + if (ii_first==ii_last && ii_first>0) tmpw-=adjust; + + p1=0; + p2=0; + KPixmapIO pixio; + if (!fLeftImg.isEmpty()) + { + TempBG = pixio.convertToImage(LeftImg); + if ((fOrientation & 1)==1) {p1=LeftImg.height();} else {p1=LeftImg.width();} + p2=h0; + if ((fOrientation & 1)==1) {pt=p1; p1=p2; p2=pt;} + if (scaleMax) + {TempScaledLeft = QPixmap(TempBG.scale(p1, p2, QImage::ScaleMin));} + else + {TempScaledLeft = QPixmap(TempBG.scale(p1, p2));} + p2=0; + if ((fOrientation & 1)==1) {p1=TempScaledLeft.height();} else {p1=TempScaledLeft.width();} + } + if (!fRightImg.isEmpty()) + { + TempBG = pixio.convertToImage(RightImg); + if ((fOrientation & 1)==1) {p2=RightImg.height();} else {p2=RightImg.width();} + p3=h0; + if ((fOrientation & 1)==1) {pt=p2; p2=p3; p3=pt;} + if (scaleMax) + {TempScaledRight = QPixmap(TempBG.scale(p2, p3, QImage::ScaleMin));} + else + {TempScaledRight = QPixmap(TempBG.scale(p2, p3));} + if ((fOrientation & 1)==1) {p2=TempScaledRight.height();} else {p2=TempScaledRight.width();} + } + if (oldtmpw<tmpw) + { + p10=oldfirstX-Offset-p1; + p8=oldtmpw+p1+p2; + } + else + { + p10=firstX-Offset-p1; + p8=tmpw+p1+p2; + } + + oldfirstX=firstX; + oldtmpw=tmpw; + + if (p10<0) p10=0; + if (p8+p10>dw) p8=dw-p10; + + p1=p10; + p2=0; + p3=p8; + p4=h1 - h0; + p5=p10; + p6=h1 - h0; + p7=p8; + p8=h0; + p9=p10; + p10=0; + if ((fOrientation & 2)==2) + { + p6=0; + p2=h0; + } + if ((fOrientation & 1)==1) + { + pt=p1; p1=p2; p2=pt; + pt=p3; p3=p4; p4=pt; + pt=p5; p5=p6; p6=pt; + pt=p7; p7=p8; p8=pt; + pt=p9; p9=p10; p10=pt; + } + if((h1 - h0)>0) bitBlt(&offscr, p1, p2, &topBg, p9, p10, p3, p4); // put the top background + bitBlt(&offscr, p5, p6, &bottomBg, p5, p6, p7, p8); //put the rest of the background + if (dockOpacity>0) + { + p1=firstX-Offset; + if ((fOrientation & 2)==2) {p2=0;} else {p2=h1 - h0+Ybase;} + p3=tmpw; + p4=h0-Ybase; + if (p4>0) + { + if ((fOrientation & 1)==1) + { + pt=p1; p1=p2; p2=pt; + pt=p3; p3=p4; p4=pt; + } + bitBlt(&offscr, p1, p2, &bottomBgf, p1, p2, p3, p4); + } + } + // end drawing background + +// Left side image + p1=0; + p5=0; + p6=0; + if (!fLeftImg.isEmpty()) + { + if ((fOrientation & 1)==1) {p1=TempScaledLeft.height();} else {p1=TempScaledLeft.width();} + + p4=firstX-Offset-p1; + if (fNWideBg) if (p4<0) p4=0; + p5=p4+p1; + if ((fOrientation & 2)==2) + {if (fExpanded==1) { + p2=-Ybase; + } else {p2=0;}} + else + if (fExpanded==1) {p2=bgY;} else {p2=h1-h0;} + if ((fOrientation & 1)==1) {pt=p4; p4=p2; p2=pt;} + bitBlt(&offscr, p4, p2, &TempScaledLeft); + } +// Right side image + if (!fRightImg.isEmpty()) + { + if ((fOrientation & 1)==1) {p1=TempScaledRight.height();} else {p1=TempScaledRight.width();} + + p2=firstX - Offset+tmpw; + if (fNWideBg) if (p2>dw-p1) p2=dw-p1; + p6=p2; + if ((fOrientation & 2)==2) + { + if (fExpanded==1) {p3=-Ybase;} else {p3=0;} + } + else + if (fExpanded==1) {p3=bgY;} else {p3=h1-h0;} + if ((fOrientation & 1)==1) {pt=p2; p2=p3; p3=pt;} + bitBlt(&offscr, p2, p3, &TempScaledRight); + } + + //Center image + if (!fCenterImg.isEmpty()) + { + TempBG = pixio.convertToImage(CenterImg); + // hack!! to optimize drawing speed, now it scales the background image only when it's + // necessary, I'd prefeer to use a bit more of memory instead of loosing speed. + // -- Matias + if ((fOrientation & 1)==1) {p1=TempScaledCenter.height();} else {p1=TempScaledCenter.width();} + if (p1 != (p6-p5)) + { + p2=p6-p5; + p3=h0; + if ((fOrientation & 1)==1) {pt=p2; p2=p3; p3=pt;} + TempScaledCenter = QPixmap(TempBG.scale( p2, p3)); + } + p1=p5; + if ((fOrientation & 2)==2) + {if (fExpanded) {p2=-Ybase;} else {p2=0;}} + else + {if (fExpanded==1) {p2=bgY;} else {p2=h1-h0;}} + if ((fOrientation & 1)==1) {pt=p1; p1=p2; p2=pt;} + bitBlt(&offscr, p1, p2, &TempScaledCenter); + } + +// End drawing the backgound + + + // draw borders + if (fShowBorders) + { + p1=firstX-Offset; + p3=SPACE_W; + p4=h0; + p5=tmpw; + p6=SPACE_W; + p7=tmpw - SPACE_W+firstX-Offset; + p2=h1 - h0+Ybase; + p8=p2; + p9=p1; + p10=p2; + if ((fOrientation & 2)==2) + { + p2=-Ybase; + p8=-Ybase; + p10=p4-Ybase-1; + } + if ((fOrientation & 1)==1) + { + pt=p1; p1=p2; p2=pt; + pt=p3; p3=p4; p4=pt; + pt=p5; p5=p6; p6=pt; + pt=p7; p7=p8; p8=pt; + pt=p9; p9=p10; p10=pt; + } + p.fillRect (QRect(p1, p2, p3, p4), QBrush(borderColor)); + p.fillRect (QRect(p9, p10, p5, p6), QBrush(borderColor)); + p.fillRect (QRect(p7, p8, p3, p4), QBrush(borderColor)); + } + // end drawing borders + + Item *item; + // new icon drawing engine + int Ypos; // Y position + int Xpos; // X position + KPixmap *currentIcon; // current icon pixmap + i=0; + for (i = 0; i < (int)items.count(); i++) + { + item = items.at(i); + // start setting the icon position + if(i < ii_first) + { + // left side icons + Xpos = cur_cx[i] - iwSmall/2 + SPACE_W-Offset; + } + else if(i >= ii_first && i <= ii_last) + { + // zoomed icons (center) + Xpos = cur_cx[i] - iSize[i]/2 + adjust - Offset+soffset-eoffset; + if (i==ii_first && i==(int)items.count()-1 && i>0) Xpos=cur_cx[i-1] + iwSmall/2 + SPACE_W-Offset + iSpace; + } + else if(i > ii_last) + { + // right side icons + Xpos = cur_cx[i] - iwSmall/2 + adjust + SPACE_W - 2 - Offset; + } // end getting icon positions + if ((fOrientation & 2)==2) + {Ypos = iy-Ybase;} + else + {Ypos = h1 - iy - iSize[i]+Ybase;} + + // now, get the icon image + if (Xpos<dw && Xpos+iwBig2>0) + { + currentIcon = new KPixmap(*item->getIcon(iSize[i])); + if (items.at(i)->wIcon==TRUE) + { + for (ii=0;ii<(int)witems.count();ii++) + { + if (items.at(i)->getId()==witems.at(ii)->getId()) + { + currentIcon = new KPixmap(*witems.at(ii)->getIcon(iSize[i])); + } + } + } + + // misc icon effects and animations + if (iOnClick == i) + { + // highlight the clicked icon + KPixmapEffect::fade(*currentIcon, ((float)50)*0.01, QColor("#FFFFFF")); + QTimer::singleShot( 10*60, this, SLOT( unhighlight() ) ); // unhighlight the icon in 1 second + } + + // notify animation + if (fShowNotification && item->isAnimed()) + { + KPixmapEffect::fade(*currentIcon, ((float) animValue )*0.01, QColor("#FFFFFF")); + } + + //Lets apply an effect to the active window in TaskBar + if(item->getId()==wm->activeWindow() && item->getId()!=0) + { + KPixmapEffect::fade(*currentIcon, ((float)60)*0.01, QColor("#FFFFFF")); + } + + // End drawing icon effects + Xpos+=x; + if ((fOrientation & 1)==1) {ii=Xpos;Xpos=Ypos;Ypos=ii;} + // Draw the icon on the widget in its respective position + bitBlt(&offscr, Xpos, Ypos, currentIcon); + // Destroy the unused currentIcon pixmap. + delete currentIcon; + } + } // End drawing icons + + // Draw the seperator between launcher and taskbar + if(fShowTaskbar && ((numLaunchers>0 && (int)items.count()>numLaunchers) || (fShowKMenu==1 && items.count()>1))) + { + i=numLaunchers-1; + if (i>=0 && i<(int)items.count()-1) + { + Xpos=xFromIndex(i)+xFromIndex(i+1)+iSize[i]; + p1=Xpos/2 - Offset+x; + p3=SPACE_W; + p4=h0; + if (fExpanded==0) + { + p2=h1-h0; + if ((fOrientation & 2)==2) p2=0; + } + else if ( (signed)items.count() > numLaunchers) + { + p2=h1 - h0 + Ybase; + if ((fOrientation & 2)==2) p2=-Ybase; + } + if ((fOrientation & 1)==1) + {p.fillRect (QRect(p2, p1, p4, p3), QBrush(sepColor));} + else + {p.fillRect (QRect(p1, p2, p3, p4), QBrush(sepColor));} + } + } + if((fSystray==1) && (numSystray>0)) + { + i=items.count()-numSystray-1; + if (i>=0 && i<(int)items.count()-1) + { + Xpos=xFromIndex(i)+xFromIndex(i+1)+iSize[i]; + p1=Xpos/2 - Offset+x; + p3=SPACE_W; + p4=h0; + if(h == h0) + { + p2=h; + if ((fOrientation & 2)==2) p2=0; + } + else + { + p2=h1 - h0 + Ybase; + if ((fOrientation & 2)==2) p2=-Ybase; + } + if ((fOrientation &1)==1) + {p.fillRect (QRect(p2, p1, p4, p3), QBrush(sepColor));} + else + {p.fillRect (QRect(p1, p2, p3, p4), QBrush(sepColor));} + } + } + p.end(); + + // Finally update the widget + if ((fOrientation & 1)==1) + {bitBlt(this, 0, 0, &offscr, 0, 0, h1, dh, Qt::CopyROP);} + else + {bitBlt(this, 0, 0, &offscr, 0, 0, dw, h1, Qt::CopyROP);} + + //return; + //Preparing mask + QBitmap bm(size(),true); + QPainter mp; + + mp.begin(&bm, this); + mp.setPen( Qt::black ); + mp.fillRect(rect(), Qt::black); + mp.fillRect(QRect(0, 0, 1, 1), Qt::white); + p1=0; + p2=0; + if (!fLeftImg.isEmpty()) + if ((fOrientation & 1)==1) {p1=TempScaledLeft.height();} else {p1=TempScaledLeft.width();} + if (!fRightImg.isEmpty()) + if ((fOrientation & 1)==1) {p2=TempScaledRight.height();} else {p2=TempScaledRight.width();} + p3=firstX-Offset-p1; + if ((fOrientation & 2)==2) {p4=0;} else {if (fExpanded) p4=0; else p4 = h1-h0;} + p5=tmpw+p1+p2; + if (fExpanded) p6=h1; else p6=h0; + if (p3<0) p3=0; + if (p5+p3>dw) p5=dw-p3; + if ((fOrientation & 1)==1) + {p6++;mp.fillRect(QRect(p4, p3, p6, p5), Qt::white);} + else + {mp.fillRect(QRect(p3, p4, p5, p6), Qt::white);} + if ((fOrientation & 2)==2) + {mp.fillRect(QRect(rw-1, rh-1, 1, 1), Qt::black);} + else + { + if ((fOrientation & 1)==1) + {mp.fillRect(QRect(0, rh-1, 1, 1), Qt::black);} + else + {mp.fillRect(QRect(rw-1, 0, 1, 1), Qt::black);} + } + if (initialization) + { + mp.fillRect(rect(), Qt::black); + mp.fillRect(QRect(0, 0, 1, 1), Qt::white); + } + mp.end(); + setMask(bm); + +} + + +void KoolDock::unhighlight() +{ + iOnClick = -1; + paintEvent(NULL);; +} + +void KoolDock::mousePressEvent( QMouseEvent *e) +{ + mPress (e->x(), e->y(), e->button()); +} + +void KoolDock::mPress(int mx, int my, ButtonState srcButton) +{ + int i, j; + int iClicked; + Item *item; + + if ((fOrientation & 1)==1) + { + i=mx; + mx=my; + my=i; + } + if ((fOrientation & 2)==2) + {my=h1-my;} + mx=mx-x1; + + mx = mx+Offset; + iClicked=itemFromPoint(mx); + + if (srcButton == Qt::LeftButton) + { + i=iClicked; + + if ((my >= h1 - iy - iSize[i]) && (my <= h1 - iy)) + { + if ((i >= 0) && (i < (int)items.count())) + { + items.at(i)->anim(FALSE); + WId id = items.at(i)->getId(); + if (id == 0) + { + // if user clicked on a quick launcher, launch the app + // acknowledge on click + iOnClick = i; + paintEvent(NULL); + + // run the app + debug(QString("clicked: %1").arg(items.at(i)->getName())); + if (items.at(i)->getName() == "KMenu") + { + // show K Menu + run(items.at(i)->getCommand()); + } + else + { + // run the application with KDE feedback (loading icon) + // we need to run the .desktop file, since the command + // may be a url or another KIO stuff like 'system:/' + if (items.at(i)->getFilename()!="") + { + run(items.at(i)->getFilename()); + } + else + { + run(items.at(i)->getCommand()); + } + } + } + else + { + KWin::WindowInfo info; + KWin::WindowInfo winfo; + info = KWin::windowInfo(id,0,NET::WM2WindowClass); + QString name = info.visibleName(); + QCString cls = info.windowClassClass(); + + if(i>=((int)items.count()-numSystray)) + { + //KWin::forceActiveWindow(id); + + KWin::deIconifyWindow(id); + kdDebug(0) << "Systray: " << id << " Name: " << name << " Estado: " << info.state() << endl; + //QMouseEvent me(e->type(), mapTo( topLevelWidget(), e->pos() ), e->globalPos(), e->button(), e->state() ); + + //QApplication::sendEvent(, &me); + } + else + { + // if user clicked on a running task's icon, activate it + cId = id; + + if (fGrouping) //switches between windows when clicking on window group icon + { + //find currently focused window in witems list + int jl=-1,il; + bool getNext=false; + for (j=0, item = witems.at(0); item; j++, item = witems.next()) + if (item->getId()==CurrentFocus) {jl=j;break;} + + if (jl>=0) + {if(witems.at(jl)->getClass()==cls) getNext=true;} + else + {getNext=true;} + + jl=-1; + if (getNext) + { + il=witems.count(); + for (j=0, item = witems.at(0); item; j++, item = witems.next()) + { + if (item->getIndex()<il) + { + if (item->getClass()==cls) + { + winfo = item->info; + if ((fMinimizedOnly==0 || winfo.isMinimized()) && (fCurrent==0 || winfo.isOnDesktop(KWin::currentDesktop()))) + {jl=j;il=item->getIndex();} + } + } + } + } + else + { + il=-1; + for (j=0, item = witems.at(0); item; j++, item = witems.next()) + { + if (item->getIndex()>il) + { + if (item->getClass()==cls) + { + winfo = item->info; + if ((fMinimizedOnly==0 || winfo.isMinimized()) && (fCurrent==0 || winfo.isOnDesktop(KWin::currentDesktop()))) + {jl=j;il=item->getIndex();} + } + } + } + } + if (jl>=0) cId=witems.at(jl)->getId(); + } + + if (cId!=CurrentFocus) + { + //KWin::activateWindow(id); + activateApp(); + } + else + { + minApp(); + //KWin::iconifyWindow(id, true); + CurrentFocus = winId(); + } + } + } + } + if(fHidden == 1 && fHideOnClick == 1) onleaveEvent(NULL); // it's configurable + } + } + else if(srcButton == Qt::RightButton) + { + // Right button. + i = iClicked; + advMenu->clear(); + advMenu->insertItem(SmallIconSet("up"), i18n("Keep &Above Others"), this, SLOT(toggleAlwaysOnTop()),0,1); + advMenu->insertItem(SmallIconSet("down"), i18n("Keep &Below Others"), this, SLOT(toggleKeptBelowOthers()),0,2); + advMenu->insertItem(SmallIconSet("window_fullscreen"), i18n("&Fullscreen"), this, SLOT(toggleFullScreen()),0,3); + + // Main KoolDock popup menu + popup->clear(); + popup->insertTitle(i18n("Main Menu")); + popup->insertItem(SmallIcon("configure"), i18n("Edit Quick Launch &Menu"), this, SLOT(edit())); + popup->insertItem(SmallIcon("pencil"), i18n("Edit &Preferences"), this, SLOT(editPref())); + popup->insertItem(SmallIcon("redo"), i18n("&Reload configuration"), this, SLOT(restart())); + popup->insertSeparator(); + popup->insertItem(SmallIcon("about_kde"), i18n("&About"), this, SLOT(about())); + popup->insertSeparator(); + popup->insertItem(SmallIcon("exit"), i18n("E&xit"), this, SLOT(endProg())); + // End Main KoolDock Menu + + if(fShowNav==1) + { + //Menu to be appended to MainMenu + godesk->clear(); + for(int index=0; index<KWin::numberOfDesktops(); index++) + { + QString tmp=i18n("Desktop &%1").arg(index+1); + int menustate=godesk->insertItem(SmallIcon("forward"), tmp, index+1); + if(KWin::currentDesktop()==(index+1)) godesk->setItemEnabled(menustate, false); + } + //End godesk Menu + + //Append Navigation Menu (godesk+Time) + QDateTime timeEntry=QDateTime::currentDateTime(); + QString tmp=i18n("Navigation: Desktop %1").arg(KWin::currentDesktop()); + popup->insertTitle(tmp); + popup->insertItem(SmallIcon("forward"), i18n("&Go to Desktop"), godesk); + popup->insertItem(SmallIcon("forward"), i18n("&Task List"), tasklist); + popup->insertSeparator(); + popup->insertItem(SmallIcon("clock"), timeEntry.toString()); + //End append Navigation Menu + } + + if ((my >= h1 - iy - iSize[i]) && (my <= h1 - iy)) + { + if ((i >= 0) && (i < (int)items.count())) + { + WId id = items.at(i)->getId(); + if (id == 0) + { + // if user right clicked on a quick launch icon. + if (items.at(i)->getCommand() != "") + { + // Edit the .desktop file + if (i==0 && fShowKMenu) + { + // if user right clicked on the K menu, show the configuration menu. + popup->exec(QCursor::pos()); + } + else + { + iGroup=false; + appMenu->clear(); + appMenu->insertTitle(i18n("Item menu")); + iFilename = items.at(i)->getFilename(); + appMenu->insertItem(SmallIcon("configure"), i18n("&Edit item"), this, SLOT(editItem())); + appMenu->insertItem(SmallIcon("fileclose"), i18n("&Delete item"), this, SLOT(removeItem())); + appMenu->insertSeparator(); + appMenu->insertItem(SmallIcon("forward"), "&KoolDock", popup); + appMenu->exec(QCursor::pos()); + } + } + } + else + { + // If user clicked on a running task icon, show the app menu. + // Pop-up menu for right-clicking on a taskbar icon. + cId = id; + KWin::WindowInfo winfo; + winfo = KWin::windowInfo(cId,0, NET::WM2WindowClass | NET::WM2AllowedActions); + int menustate; + //winfo.desktop() = -1 1 2 3 ... + + //Begin Move to Desktop Menu + deskpopup->clear(); + QString tmp=i18n("All desktops"); + menustate=deskpopup->insertItem(SmallIcon("forward"), tmp, 0); + tmp=i18n("Current Desktop &%1").arg(KWin::currentDesktop()); + menustate=deskpopup->insertItem(SmallIcon("forward"), tmp, KWin::currentDesktop()); + + deskpopup->insertSeparator(); + for(int i=0; i<KWin::numberOfDesktops(); i++) + { + if(winfo.isOnDesktop(KWin::currentDesktop()) && (i+1)==KWin::currentDesktop()) + { + continue; + } + else + { + if((i+1)!=KWin::currentDesktop()) + { + QString tmpd=i18n("Desktop &%1").arg(i+1); + menustate=deskpopup->insertItem(SmallIcon("forward"), tmpd, i+1); + } + } + } + dIndex=winfo.desktop(); + if(dIndex==-1) dIndex=0; + deskpopup->setItemChecked(dIndex, true); + + //End Move to Desktop Menu + + advMenu->setItemChecked(1,winfo.state() & NET::KeepAbove); + advMenu->setItemChecked(2,winfo.state() & NET::KeepBelow); + advMenu->setItemChecked(3,winfo.state() & NET::FullScreen); + advMenu->setItemEnabled(3,winfo.actionSupported(NET::ActionFullScreen)); + + appMenu->clear(); + if (fGrouping && items.at(iClicked)->getCount()>0) + { + iGroup=true; + QCString cls = winfo.windowClassClass(); + popups.clear(); + for (j=0, item = witems.at(0); item; j++, item = witems.next()) + { + if (item->getClass()==cls) + { + winfo = item->info; + if ((fMinimizedOnly==0 || winfo.isMinimized()) && (fCurrent==0 || winfo.isOnDesktop(KWin::currentDesktop()))) + { + KPopupMenu *tmpMenu = new KPopupMenu; + createMenu(item->getId(), tmpMenu, &winfo); + connect(tmpMenu, SIGNAL(aboutToShow()), SLOT(menuShow())); + popups.append (tmpMenu); + appMenu->setItemParameter(appMenu->insertItem(*item->getIcon(iwBig2), item->getName(), tmpMenu), item->getId()); + } + } + } + appMenu->insertSeparator(); + appMenu->insertItem(SmallIcon("forward"), "&Move to Desktop", deskpopup); + appMenu->insertItem(i18n("Mi&nimize all"), this, SLOT(minAllApps())); + appMenu->insertItem(i18n("Ma&ximize all"), this, SLOT(maxAllApps())); + appMenu->insertItem(i18n("&Restore all"), this, SLOT(restAllApps())); + appMenu->insertItem(SmallIcon("fileclose"), i18n("&Close all"), this, SLOT(closeAllApps())); + } + else + { + iGroup=false; + createMenu(cId, appMenu, &winfo); + } + appMenu->insertSeparator(); + appMenu->insertItem(SmallIcon("forward"), "KoolDock", popup); + appMenu->exec(QCursor::pos()); + iGroup=false; + } + } + } + else + { + // Show the configuration popup menu if the user clicked on another place. + popup->exec(QCursor::pos()); + } + deskpopup->clear(); + godesk->clear(); + //tasklist->clear(); + popup->clear(); + popups.clear(); + appMenu->clear(); + } + +} + +void KoolDock::mMoveEvent( int ex, int ey) +{ + if (!fExpanded) return; + unsigned int i; + int mx, my, dmx; + int dx; + unsigned int k; + int cur_cx_desk; + int p1=0,p2=0; + + if ((fOrientation & 1)==1) + { + mx=ex; + ex=ey; + ey=mx; + } + if ((fOrientation & 2)==2) + {ey=h1-ey;} + + if (w0>dw) + { + mx=w0*ex/dw; + } + else + { + mx = ex-x0; + } + dmx=abs(mx - last_mx); + last_mx = mx; + if (w1>dw) + { + Offset=(w1-dw)*mx/w0; + ex=ex+Offset; + } + else + { + Offset=0; + } + + if (fSteppy==1) last_ncx=mx=(int)(last_ncx*0.7+cx[(ex - x0 - iSpace)/iDist]*0.3); + + if (!mkbigTimer->isActive() && !mksmallTimer->isActive()) + { + Ybase=0; + } + if (dmx >= UPDATE_DIST && fExpanded || mkbigTimer->isActive() || mksmallTimer->isActive()) + { + ii_first = 0; + ii_last = items.count() - 1; + for (i = 0; i < items.count(); i++) + { + dx = abs(cx[i] - mx); + if (dx < funcW) + { + iSize[i] = func(dx); + } + else + { + iSize[i] = iwSmall; + if (cx[i] < mx) + { + ii_first = min(i + 1, items.count() - 1); + } + else if (ii_last == (int)items.count() - 1) + { + ii_last = max(i - 1, 0); + } + } + } + + cur_cx[0] = iSpace + iSize[0]/2; + + for(i=1; i < items.count() + 1; i++) + { + cur_cx[i] = cur_cx[i-1] + (iSize[i] + iSize[i-1])/2 + iSpace; + } + for(k=0; (k < items.count()-1) && (mx > cx[k]); k++); + + cur_cx_desk = ((int)((iwBig2 - iwSmall)*0.6*fAmount) + iSpace*2)/2 + cx[k] + (int)((cx[k] - mx)*(func(0) + func(iDist) - 2*iwSmall)/(2*iDist)); + adjust = cur_cx_desk - cur_cx[k]; + + if (w1<dw && (!mkbigTimer->isActive() || (zoomTicksB>1 && mkbigTimer->isActive()))) + { + if (!initialization && menuCount==0) + { + if (mx < 0) onleaveEvent(NULL); + if (lastX>0) if (mx > tmpw+firstX-x1-(w1-w0)/2) onleaveEvent(NULL); + } + } + if (ii_last < (int)items.count() - 1) + { + cur_cx[items.count() - 1] = w1*zoomVal/fzoomSpeed + (eoffset-soffset+(w1+w0)/2)*(fzoomSpeed-zoomVal)/(fzoomSpeed) - iwSmall/2 - iSpace - adjust; + for (i = items.count() - 2; (int)i >= ii_last + 1; i--) + { + cur_cx[i] = cur_cx[i+1] - iDist; + } + if (ii_last == 0) cur_cx[0] = cur_cx[1] - iDist - (iSize[0] - iSize[1])/2; + } + + for (i = 0; (int)i < ii_first; i++) + { + cur_cx[i]+=(int)((soffset-eoffset+(w1-w0)/2)*(fzoomSpeed-zoomVal)/fzoomSpeed); + } + paintEvent(NULL); + } + + /*if (mx<0) + { + ii_first = 0; + ii_last = items.count() - 1; +}*/ + my = ey; + mx = ex-x1; + + i=itemFromPoint(mx); + if ((int)i < numLaunchers) + { + mouseOnLauncher=true; + } + else + { + mouseOnLauncher=false; + } + + if(showNames == 1 && iwBig == iwBig2 && dmx<10 ) + { + // get the name of the item at the mouse position + if (!mksmallTimer->isActive() && !mkbigTimer->isActive()) + { + QPoint pointer; + pointer = QCursor::pos(); + if (i < MAX_ICONS+1) + { + if (((int)i >= 0) && (i < items.count())) + { + nom = items.at(i)->getName(); + } + else + {nom = "";} + } + + if(nom!=aux) + { + xosd_st=0; + } + if(xosd_st==0) + { + xosdw->setText(nom); + xosd_st=1; + } + aux = nom; + mx=mx-Offset; + if (fOrientation==0) + { + p1=mx+x1 - (xosdw->w/2); + p2=dh - h - xosdw->h; + } + if (fOrientation==1) + { + p1=dh-h1-xosdw->w; + p2=mx- xosdw->h/2+x1; + } + if (fOrientation==2) + { + p1=mx+x1 - (xosdw->w/2); + p2=h1; + } + if (fOrientation==3) + { + p1=h1; + p2=mx- xosdw->h/2+x1; + } + if ((fOrientation & 1)==0) + { + if (p1<0) p1=0; + if (p1+xosdw->w>dw) p1=dw-xosdw->w; + } + if (xinerama==1) p1+=XinPreviousWidth; + if (!initialization && (xosdw->pos().x()!=p1 || xosdw->pos().y()!=p2)) xosdw->move2(p1, p2); + } + } + if (dmx>=10) + { + xosdw->move2(0,rdh); + } + +} + +//Mouse Wheel now switches desktops (away from user desktop+1, towards user desktop-1) +//-Francisco +void KoolDock::wheelEvent(QWheelEvent *e) +{ + if(e->delta()==120 && (KWin::currentDesktop()<KWin::numberOfDesktops())) + { + KWin::setCurrentDesktop(KWin::currentDesktop()+1); + } + if((e->delta()==-120) && (KWin::currentDesktop()>0)) + { + KWin::setCurrentDesktop(KWin::currentDesktop()-1); + } +} + + +void KoolDock::mkbigTimerDo() +{ + int timing; + + zoomTicksB++; + iwBig = iwBig2*zoomVal/fzoomSpeed+iwSmall*(fzoomSpeed-zoomVal)/fzoomSpeed; // frames to grow up the dockbar + if (iwBig<iwSmall) iwBig=iwSmall; + zoomVal=zoomVal+zoomStepB; + + if (fzoomSpeed<=zoomVal) + { + zoomVal=fzoomSpeed; + iwBig = iwBig2; + mkbigTimer->stop(); + last_mx=-1; + debug(QString("Stopped mkbigTimer")); + if (zoomTicksB>=neededTicksB && fSpeed) + { + //performace check + timing =perf->elapsed(); + zoomStepB=zoomStepB*timing/fzoomSpeed; + if (zoomStepB<=0) zoomStepB=1; + if (zoomStepB>200) zoomStepB=200; + neededTicksB=(int)((fzoomSpeed/zoomStep)-1)*zoomStep/zoomStepB; + } + zoomTicksB=0; + zoomTicksS=0; + if (initialization) + { + pTest(); + } + else + { + if (fHidden==1) + {mTimer->start(fMouseTimer, FALSE);} + else + {mTimer->changeInterval(fMouseTimer);} + } + } + iy = (iDist - iwSmall) / 2; + funcH = iwBig - iwSmall; + if (fHidden == 1) Ybase = iwBig2*(fzoomSpeed-zoomVal)/fzoomSpeed; + mMoveEvent(QWidget::mapFromGlobal ( QCursor::pos() ).x(), QWidget::mapFromGlobal ( QCursor::pos() ).y()); + paintEvent(NULL); +} + +void KoolDock::mksmallTimerDo() +{ + zoomTicksS++; + iwBig = iwBig2*zoomVal/fzoomSpeed+iwSmall*(fzoomSpeed-zoomVal)/fzoomSpeed; + if (iwBig<iwSmall) iwBig=iwSmall; + if (0>zoomVal) + { + zoomVal=0; + mksmallTimerstop(); + } + else + { + if (fHidden == 1) Ybase = iwBig2*(fzoomSpeed-zoomVal)/fzoomSpeed; + funcH = iwBig - iwSmall; + iy = (iDist - iwSmall) / 2; + mMoveEvent(lastXPos,lastYPos); + paintEvent(NULL); + } + zoomVal=zoomVal-zoomStepS; +} + +void KoolDock::mksmallTimerstop() +{ + zoomVal=0; + if (fStayBelow==1 && fHidden==0) setDockBelow(); + int i; + mksmallTimer->stop(); + xosdw->move2(0,rdh); + fExpanded=FALSE; + debug(QString("Stopped mksmallTimer")); + if (!initialization) + {if (fHidden==0) {mTimer->changeInterval(250);} else {mTimer->stop();}} + + w = w0; + x = x0; + h = h0; + + // normalize the dock + for (i = 0; i < (int)items.count() + 1; i++) + { + iSize[i] = iwSmall; + cur_cx[i] = cx[i]; + } + + ii_first = 0; + ii_last = items.count() - 1; + ii_first = 0; + ii_last = items.count() - 1; + adjust = 0; + iwBig = iwBig2; + if (fHidden == 0) + { + move2( x, dh - h ); + resize2(w, h); + } + else + { + move( 0, rdh); + resize2(w, h); + } + oldfirstX=x; + oldtmpw=w; + paintEvent(NULL); + if (zoomTicksS>=neededTicksS && fSpeed) + { + //performace check + int timing =perf->elapsed(); + zoomStepS=zoomStepS*timing/fzoomSpeed; + if (zoomStepS<=0) zoomStepS=1; + if (zoomStepS>200) zoomStepS=200; + neededTicksS=(int)((fzoomSpeed/zoomStep)-1)*zoomStep/zoomStepS; + } + zoomTicksB=0; + zoomTicksS=0; + if (initialization) pTest(); +} + +void KoolDock::enterEvent(QEvent *) +{ + if (fExpanded==TRUE && !mksmallTimer->isActive() || mkbigTimer->isActive()) return; + if (fStayBelow==1 && fHidden==0) setDockAbove(); + if (mksmallTimer->isActive()==TRUE) mksmallTimer->stop(); + + w=w1; + x=x1; + h=h1; + + if (!fExpanded) + { + getTopBG(); + if (dockOpacity > 0) {bitBlt(&bottomBgf,0,0,&bottomBg);KPixmapEffect::fade(bottomBgf, ((float)dockOpacity)*0.01, bgColor);} + + adjust=x0-x1; + iwBig = iwSmall; + } + + resize2(w,h); + move2(x,dh-h); + + funcH = iwBig - iwSmall; + iy = (iDist - iwSmall) / 2; + + fExpanded=TRUE; + oldfirstX=x; + oldtmpw=w; + paintEvent(NULL); + debug("enterEvent"); + zoomTicksB=0; + zoomTicksS=0; + + perf->start(); + mkbigTimer->start(zoomStep, FALSE); +} + +void KoolDock::onleaveEvent(QEvent *) +{ + if (menuCount>0) return; + if (mksmallTimer->isActive()==TRUE) return; + zoomTicksB=0; + zoomTicksS=0; + perf->start(); + debug("onleaveEvent"); + lastXPos = QWidget::mapFromGlobal ( QCursor::pos() ).x(); + lastYPos = QWidget::mapFromGlobal ( QCursor::pos() ).y(); + if (mkbigTimer->isActive()) + { + mkbigTimer->stop(); + } + mksmallTimer->start(zoomStep, FALSE); + + if(showNames==1) + { + xosdw->move2(0,rdh); + xosd_st=0; + } + if(fHidden==1) + { + trackTimer->start(250, FALSE); + } +} + + +void KoolDock::edit() +{ + editPref(); + setupdlg->tabWidget->setCurrentPage(3); +} + + +void KoolDock::run(QString command) +{ + + QString exec; + + kapp->propagateSessionManager(); + + _filterData->setData( command.stripWhiteSpace() ); + QStringList filters; + filters << "kurisearchfilter" << "kshorturifilter"; + KURIFilter::self()->filterURI( *(_filterData), filters ); + + QString cmd = (_filterData->uri().isLocalFile() ? _filterData->uri().path():_filterData->uri().url()); + // Nothing interesting. Quit! + if(cmd.isEmpty()) + { + KMessageBox::sorry(0L, i18n("You have to enter a command to execute or a URL to be opened first.")); + return; + } + else + { + switch( _filterData->uriType() ) + { + case KURIFilterData::LOCAL_FILE: + case KURIFilterData::LOCAL_DIR: + case KURIFilterData::NET_PROTOCOL: + case KURIFilterData::HELP: + { + if (useList) + { + KApplication::startServiceByDesktopPath (command, lstDrop, &QString(0) ,&QCString(0) ,0 , "" ,true); + } + else + { + (void) new KRun( _filterData->uri() ); + } + return; + } + case KURIFilterData::EXECUTABLE: + case KURIFilterData::SHELL: + { + exec = cmd; + if( _filterData->hasArgsAndOptions() ) cmd += _filterData->argsAndOptions(); + break; + } + case KURIFilterData::UNKNOWN: + case KURIFilterData::ERROR: + default: + KMessageBox::sorry( 0, i18n("<qt>The program name or command <b>%1</b>\n" + "cannot be found. Please correct the command\n" + "or URL and try again</qt>").arg( cmd ) ); + return; + } + } + if(KRun::runCommand( cmd, exec, "" )) + { + return; + } + else + { + KMessageBox::sorry( 0, i18n("<qt>Could not run <b>%1</b>.\nPlease correct" + " the command or URL and try again.</qt>").arg( cmd ) ); + return; + } +} + + +// Parabolic function +int KoolDock::func(int x) +{ + int res = iwBig - (int)((x*x*funcH)/(funcW*funcW)); + return res; +} +int KoolDock::func2(int x) +{ + int res; + if (x<funcW) + {res = iwBig - (int)((x*x*funcH)/(funcW*funcW));} + else + {res=iwSmall;} + return res; +} + +//Here we add windows to the taskbar +void KoolDock::addWindows() +{ + // Show task bar + int index; + if(fShowTaskbar) + { + KWin::WindowInfo info; + QValueList<WId>::ConstIterator it; + int i; + Item *item; + + //First we removed every taskbar item + int count=items.count()-numSystray; + + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + item->setCount(0); + } + for(i=count; i>=numLaunchers; i--) + { + items.remove(i); + } + + //Lets go through all the windows + if(firstTime) + { + for (it=wm->windows().begin(); it != wm->windows().end(); ++it) + { + addwTask(*it); + } + firstTime=false; + } + + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + item->setId(item->getId()); + info=item->info; + index=info.desktop(); + //If it belongs to the current desktop, lets add it + if (info.valid()) + { + if(fCurrent==0 || index==KWin::currentDesktop() || index==-1) + { + addTask(item->getId(), i); + } + } + } + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + if (!item->info.valid()) witems.remove(i); + doUpdateGeometry(); + } + CurrentFocus=wm->activeWindow(); + + updTaskList(); +} + +void KoolDock::workAreaChanged() +{ + int mdw,mdh,mdt; + if (xinerama==0) + { + mdw=QApplication::desktop()->width(); + mdh = QApplication::desktop()->height(); + } + else + { + mdw=leftRes; + mdh=XinDesiredHeight; + } + if ((fOrientation & 1)==1) + { + mdt=mdw;mdw=mdh;mdh=mdt; + } + if (dw!=mdw || dh!=mdh) reload(); +} + +//What happens when we change desktops +void KoolDock::currentDesktopChanged(int) +{ + if (initialization) return; + funcH = iwBig2 - iwSmall; + iwBig = iwBig2; + addWindows(); + doUpdateGeometry(); + move(0,rdh); + getTopBG(); + if (fExpanded) move2(x1,dh-h1); + if (fHidden==0 && !fExpanded) move2(x0,dh-h0); + xosdw->move2(0,rdh); + oldDesktop=KWin::currentDesktop(); +} + +void KoolDock::windowAdded(WId id) +{ + if (initialization) return; + if (fShowNav) + { + addToTaskList(id); + } + if (!fShowTaskbar) return; + KWin::WindowInfo info; + info = KWin::windowInfo(id); + QString name = info.name(); + if (name == "kooldock xosd window") + { + debug("Not adding OSD window to taskbar."); + return; + } + if (name == "kooldock") + { + debug("Not adding ourselves."); + return; + } + + debug(QString("windowAdded(%1)").arg(name)); + + if (addwTask(id)) addToTaskList(id); + addTask(id); + doUpdateGeometry(); + +} + +void KoolDock::windowRemoved(WId id) +{ + if (initialization) return; + if (fShowNav) + { + rmFromTaskList(id); + } + if (!fShowTaskbar) return; + unsigned int i; + Item *item; + debug(QString("windowRemoved(%1)").arg(id)); + + KWin::WindowInfo info; + info = KWin::windowInfo(id); + QString name = info.name(); + + if (name == "kooldock xosd window") + { + debug("Not removing OSD window from taskbar."); + return; + } + for (i=0; i < witems.count(); i++ ) + { + item = witems.at(i); + if(item->getId() == id) + { + rmTask(id,i); + rmwTask(i); + rmFromTaskList(id); + break; + } + } + doUpdateGeometry(); +} + +void KoolDock::windowChanged(WId id, unsigned int properties) +{ + if (initialization) return; + if (fShowNav) + { + rmFromTaskList(id); + addToTaskList(id); + } + if (!fShowTaskbar) return; + Item *item; + bool iconChanged, nameChanged; + int i; + bool toRepaint = FALSE; + bool hasfound=FALSE; + int iFound; + + KWin::WindowInfo winfo; + winfo = KWin::windowInfo(id); + + iconChanged = (properties & NET::WMIcon); + nameChanged = ((properties & NET::WMName) | (properties & NET::WMVisibleName)); + + properties = 0; + + if (id != winId() ) //not add kooldock window + { + if (ignored(winfo.name()) == false) + { + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + //find item in witem (window item) list + if (item->getId()==id) + { + hasfound=true; //remember whether item was found, and its index + iFound=i; + + //Handle icon/name changes + if (iconChanged) {item->setIcon(KWin::icon(id, iwBig2, iwBig2, TRUE));toRepaint=true;} + // FIXME: on gcc2.95 item->setName() falls on a loop and gets a segfault. (?) +#ifndef _GCC295 + if (nameChanged) item->setName(winfo.name()); +#endif + if ((fShowNotification) && (id != wm->activeWindow())) + { + debug(QString("windowChanged (inactive window changed)")); + // An inactive window's title changed + // notify user + item->anim(TRUE); + if(onChangeTimer == NULL) + { + onChangeTimer = new QTimer(this); + connect( onChangeTimer, SIGNAL(timeout()), this, SLOT(onChangeTimerTicked())); + onChangeTimer->start( ON_CHANGE_ANIM_INTERVAL, FALSE ); + } + } + item->setId(id); + break; + } + } + //If window is on window list, and user haven't changed desktop recently... + if (hasfound && oldDesktop==KWin::currentDesktop()) + { + if (witems.at(iFound)->getCount()==0) //window icon is not visible on kooldock + { + //... check whether it can be added + if ((fCurrent==0 || winfo.isOnDesktop(KWin::currentDesktop())) && (fMinimizedOnly==0 || winfo.isMinimized())) {toRepaint|=addTask(id);} + } + else + { + //... check whether it can be removed + if ((fCurrent==1 && !winfo.isOnDesktop(KWin::currentDesktop())) || (fMinimizedOnly==1 && !winfo.isMinimized())) {toRepaint|=rmTask(id, iFound);} + } + rmFromTaskList(id); + addToTaskList(id); + } + if(toRepaint) {doUpdateGeometry();paintEvent(NULL);} + } + } +} + +void KoolDock::systemTrayWindowAdded(WId id) +{ + if (initialization) return; + if(fSystray==1) + { + KWin::WindowInfo info; + info = KWin::windowInfo(id); + QString name = info.visibleName(); + + if (ignored(info.name()) == false) + { + QPixmap pix = KWin::icon(id, iwBig2, iwBig2, TRUE); + numSystray++; + items.append(new Item(pix, id, name, iwSmall, iwBig2)); + debug(QString("addSystem Tray(%1)").arg(info.visibleName())); + doUpdateGeometry(); + } + } +} + +void KoolDock::systemTrayWindowRemoved(WId id) +{ + if (initialization) return; + if(fSystray==1) + { + numSystray--; + if(numSystray<0) numSystray=0; + windowRemoved(id); + } +} + +void KoolDock::activeWindowChanged(WId id) +{ + if (initialization) return; + if (id != winId()) CurrentFocus = id; + + // end notify animation + unsigned int i; + for (i=0; i<=items.count()-1; i++) + { + if (items.at(i)->getId() == id) + { + items.at(i)->anim(FALSE); + } + } + + bool toDelete = TRUE; + for (i=0; i<=items.count()-1; i++) + { + if (items.at(i)->isAnimed()) toDelete = FALSE; + } + + if (toDelete && onChangeTimer != NULL) + { + delete(onChangeTimer); + onChangeTimer = NULL; + debug("Deleted onChangeTimer"); + } + if (fGrouping) movetoback(id); + paintEvent(NULL); +} + +void KoolDock::doUpdateGeometry() +{ + int dw1, dw0; + unsigned int i; + iwBig=iwBig2; + for (i=0;i<items.count();i++) + { + cx[i] = iSpace + i*iDist + iwSmall/2; + iSize[i]=iwSmall; + if (!fExpanded) cur_cx[i]=cx[i]; + } + w0 = 2*iSpace + (items.count()-1)*iDist +iwSmall+soffset*2-eoffset*2; + w = w0; + w1 = w0 + (int)((iwBig - iwSmall)*0.6*fAmount) + iSpace*2; + x1 = (dw - w1) * fpercentPos / 100; + if (w1>dw) {x1=0;} + if (w1>dw) {dw1=dw;} else {dw1=w1;} + if (w0>dw) {dw0=dw;} else {dw0=w0;} + x0 = (dw1 - dw0)/2 + x1; + //x0 = (dw - w0) * fpercentPos / 100; + //if(xinerama==1) {if (fOrientation && 1)==0) {x0=x0+XinPreviousWidth; x1=x1+XinPreviousWidth;}} + x = x0; + h0 = 2*iy + iwSmall; + h = h0; + h1 = 2*iy + iwBig; + + adjust = 0; + + if(fHidden == 0) + { + resize2(w, h); + move2( x, dh - h ); + } + + //if ((fOrientation & 1)==1) {offscr = QPixmap(h1, w1);} else {offscr = QPixmap(w1, h1);} + + ii_first = 0; + ii_last = items.count() - 1; + ii_first = 0; + ii_last = ii_last; + + if (fExpanded==TRUE) + { + w=w1; + h=h1; + x=x1; + funcH = iwBig2 - iwSmall; + iy = (iDist - iwSmall) / 2; + if(fHidden==1) + { + move(0,rdh); + getBottomBG(); + getTopBG(); + //move(rx,ry); + } + resize2(w, h); + move2( x, dh - h ); + } + else if (fHidden==1) + { + move(0,rdh); + } + debug(QString("w1: %1").arg(w1)); + debug(QString("x1: %1").arg(x1)); + if (fExpanded) {last_mx=-10; mMoveEvent(lastXPos,lastYPos);} + oldfirstX=x; + oldtmpw=w; + paintEvent(NULL); + xosdw->move2(0,rdh); + +} + +bool KoolDock::rmTask(WId id, int iFound) +{ + Item *item, *witem, *fitem; + int i, j; + int miFound; + bool hasfound; + hasfound=false; + miFound=iFound; + QCString cls; + + if (miFound==-1) + { + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if (item->getId()==id) + {hasfound=true;miFound=i;break;} + } + } + else + { + hasfound=true; + } + if (hasfound) + { + fitem=witems.at(miFound); + if (fitem->getId()==id) + { + if (fitem->getCount()==1) + { + cls=fitem->getClass(); + //Removing item + for (i=numLaunchers, item = items.at(numLaunchers); item; i++, item = items.next()) + { + if (fGrouping) + { + if (cls==item->getClass()) + { + int cnt=item->getCount(); + //KMessageBox::information(0,QString("%1").arg(cnt)); + fitem->setCount(0); + if (cnt==0) + { + items.remove(i); + return true; + } + else + { + int ir, il=-1, im=-1; + int jl=-1,jm=-1; + ir=fitem->getIndex(); + for (j=0, witem = witems.at(0); witem; j++, witem = witems.next()) + { + if (witem->getClass()==cls) + { + if (witem->getIndex()<ir && witem->getIndex()>il) + {il=witem->getIndex(); jl=witem->getId();} + if (witem->getIndex()>im) + {im=witem->getIndex(); jm=witem->getId();} + } + } + item->setCount(cnt-1); + if (jl>=0) {item->setId(jl);return true;} + if (jm>=0) {item->setId(jm);} + return true; + } + } + } + else + { + if (item->getId()==id) + { + items.remove(i); + witems.at(miFound)->setCount(0); + return true; + } + } + } + } + } + } + return false; +} + +void KoolDock::rmwTask(int iFound) +{ + int i, ind; + Item *item; + + ind=witems.at(iFound)->getIndex(); + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if (item->getIndex()>ind) item->setIndex(item->getIndex()-1); + } + witems.remove(iFound); +} + +bool KoolDock::addTask(WId id, int iFound) +{ + Item *item; + int i ; + int miFound; + bool hasfound; + hasfound=false; + miFound=iFound; + + KWin::WindowInfo info; + info = KWin::windowInfo(id,0,NET::WM2WindowClass); + const int SUPPORTED_WINDOW_TYPES = NET::NormalMask | NET::DesktopMask | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask; + QString name = info.visibleName(); + QCString cls = info.windowClassClass(); + if (info.windowType(SUPPORTED_WINDOW_TYPES) == NET::Normal || info.windowType(SUPPORTED_WINDOW_TYPES) == NET::Override || info.windowType(SUPPORTED_WINDOW_TYPES) == NET::Dialog || info.windowType(SUPPORTED_WINDOW_TYPES) == NET::Unknown) + { + if (info.isMinimized() || fMinimizedOnly==0) + if (fCurrent==0 || info.isOnDesktop(KWin::currentDesktop())) + if ((info.state() & NET::SkipTaskbar) == 0) + if (ignored(info.name()) == false) + { + if (miFound==-1) + { + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if (item->getId()==id) + {hasfound=true;miFound=i;break;} + } + } + else + { + hasfound=true; + } + + if (hasfound) + { + if (witems.at(miFound)->getId()==id) + { + if (witems.at(miFound)->getCount()==0) + { + witems.at(miFound)->setCount(1); + if (fGrouping) + { + hasfound=false; + for (i=numLaunchers, item = items.at(numLaunchers); item; i++, item = items.next()) + { + if (item->getClass()==cls) + { + item->setCount(item->getCount()+1); + return true; + } + } + } + QPixmap pix; + items.insert(items.count()-numSystray, new Item(pix, id, name, iwSmall, iwBig2, TRUE)); + items.at(items.count()-1)->setClass(cls); + debug(QString("addTask(%1)").arg(info.visibleName())); + return true; + } + } + } + } + } + return false; +} + +bool KoolDock::addwTask(WId id) +{ + KWin::WindowInfo info; + info = KWin::windowInfo(id,0,NET::WM2WindowClass); + const int SUPPORTED_WINDOW_TYPES = NET::NormalMask | NET::DesktopMask | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask; + QString name = info.visibleName(); + QCString cls = info.windowClassClass(); + + if (info.windowType(SUPPORTED_WINDOW_TYPES) == NET::Normal || info.windowType(SUPPORTED_WINDOW_TYPES) == NET::Override || info.windowType(SUPPORTED_WINDOW_TYPES) == NET::Dialog || info.windowType(SUPPORTED_WINDOW_TYPES) == NET::Unknown) + { + if ((info.state() & NET::SkipTaskbar) == 0) + { + if (ignored(info.name()) == false) + { + QPixmap pix = KWin::icon(id, iwBig2, iwBig2, TRUE); + witems.append(new Item(pix, id, name, iwSmall, iwBig2)); + witems.at(witems.count()-1)->setClass(cls); + witems.at(witems.count()-1)->setIndex(witems.count()-1); + return true; + } + } + } + return false; +} + +void KoolDock::loadConf() +{ + KConfig *config = KGlobal::config(); + + config->setGroup("kooldock"); + fShowTaskbar = config->readNumEntry("ShowTaskbar", 0); + fMinimizedOnly = config->readNumEntry("MinimizedOnly", 0); + fShowNotification = config->readNumEntry("ShowNotification", 0); + showNames = config->readNumEntry("showNames", 1); + fCleaner = config->readNumEntry("Cleaner", 0); + xosdFont = config->readEntry("xosdFont", "Tahoma"); + xosdColor = config->readEntry("xosdColor", "#f1f1f1"); + xosdShadowColor = config->readEntry("xosdShadowColor", "#000000"); + xosdSize = config->readNumEntry("xosdSize", 17); + xosdShadowOffset = config->readNumEntry("xosdShadowOffset", 2); + fShowBorders = config->readNumEntry("ShowBorders", 0); + borderColor = QColor(config->readEntry("BorderColor", "#b1c4de")); + iwSmall = config->readNumEntry("SmallIconSize", 32); + iwBig = config->readNumEntry("BigIconSize", 90); + fAmount = config->readNumEntry("BigIconAmount", 5); + if (fAmount>10) fAmount=10; + if (fAmount<4) fAmount=4; + fShowKMenu = config->readNumEntry("ShowKMenu", 0); + fUseKBFX = config->readNumEntry("KBFX", 0); + dockOpacity = config->readNumEntry("DockOpacity", 0); + iSpace = config->readNumEntry("iSpace", 10); + if (dockOpacity < 0) + { + dockOpacity = 0; + } + else if (dockOpacity > 100) + { + dockOpacity = 100; + } + bgColor = QColor(config->readEntry("BackgroundColor", "#ccccff")); + sepColor = QColor(config->readEntry("SeparatorColor", "#000000")); + fPriority = config->readNumEntry("Priority", 3); + fMouseTimer = config->readNumEntry("MouseTimer", 25); + fClipping = config->readNumEntry("Clipping", 0); + fClipIcons = config->readNumEntry("ClipIconArea", 0); + fpercentPos = config->readNumEntry("percentPos", 50); + fOrientation = config->readNumEntry("fOrientation", 0); + if (fOrientation<0 || fOrientation>3) fOrientation=0; + fzoomSpeed = config->readNumEntry("zoomSpeed", 20); + fSpeed = config->readNumEntry("speedControl", 0)==1; + //fSpeed=true; + if (fzoomSpeed>10) + { + if (fzoomSpeed>100) + {zoomStep=10;} + else + {zoomStep=fzoomSpeed/10;} + } + else + {zoomStep=1;} + if (fSpeed) + { + zoomStepB=200; + zoomStepS=200; + neededTicksB=1; + neededTicksS=1; + } + else + { + zoomStepB=zoomStep; + zoomStepS=zoomStep; + neededTicksB=(int)(fzoomSpeed/zoomStep)-1; + neededTicksS=(int)(fzoomSpeed/zoomStep)-1; + } + + if (neededTicksB==0) neededTicksB=1; + if (neededTicksS==0) neededTicksS=1; + + if (fpercentPos<0) fpercentPos=0; + if (fpercentPos>100) fpercentPos=100; + fHidden = config->readNumEntry("Hidden", 1); + fHighLightTime = config->readNumEntry("HighLightTime", 2); + fHideOnClick = config->readNumEntry("HideOnClick", 0); + fStayBelow = config->readNumEntry("StayBelow", 0); + fSteppy = config->readNumEntry("fSteppy", 0); + fLeftImg = config->readEntry("LeftImg"); + fRightImg = config->readEntry("RightImg"); + fCenterImg = config->readEntry("CenterImg"); + fNWideBg = config->readBoolEntry("nWideBg", TRUE); + scaleMax = config->readBoolEntry("scaleMax", FALSE); + fFirstRun = config->readBoolEntry("FirstRun", TRUE); + xinerama = config->readNumEntry("Xinerama", 0); + leftRes=config->readNumEntry("leftRes", QApplication::desktop()->width()); + XinDesiredHeight=config->readNumEntry("XinDesiredHeight", QApplication::desktop()->height()); + XinPreviousWidth=config->readNumEntry("XinPreviousWidth", 0); + hideTimer = config->readNumEntry("hideTimer", 125); + Solid = config->readNumEntry("Solid", 1); + fShowShot = config->readBoolEntry("ShowSShot", false); + fGrouping = config->readBoolEntry("iconGrouping", false); + fShowNav=config->readNumEntry("Navigator", 1); + fSystray=0;//config->readNumEntry("Systray", 0); + fCurrent=config->readNumEntry("currentDesktop", 0); + curTheme=config->readEntry("Theme"); + + if(config->readNumEntry("xosdBold", 1) == 0) + { + xosdBold = false; + } + else + { + xosdBold = true; + } + + if(config->readNumEntry("xosdItalic", 1) == 0) + { + xosdItalic = false; + } + else + { + xosdItalic = true; + } + + if (iwSmall > iwBig) + { + iwSmall = 32; + iwBig = 90; + } + if (!fShowTaskbar) + { + fShowNotification = 0; + } + if (fHidden!=1 && fHidden!=0) fHidden = 1; + if (fStayBelow!=1 && fStayBelow!=0) fStayBelow = 0; +} + + +void KoolDock::loadIgnore() +{ + QString line; + + // read the ignorelist into 'ignoreList' + QFile in(QString(progPath + "/ignorelist.conf")); + + //clear de ignoreList and the KEditListBox (ignoreBox) + ignoreList.clear(); + setupdlg->ignoreBox->clear(); + if (in.open(IO_ReadOnly)) + { + while (in.readLine(line, MAX_LEN) != -1) + { + //append the item and strip the last char (new line) + ignoreList.append(line.mid(0, line.length()-1)); + } + in.close(); + if(!ignoreList.isEmpty()) setupdlg->ignoreBox->insertStringList(ignoreList); + } +} + + +void KoolDock::saveConf() +{ + KConfig *config = KGlobal::config(); + + config->setGroup("kooldock"); + config->writeEntry("ShowTaskbar", fShowTaskbar); + config->writeEntry("MinimizedOnly", fMinimizedOnly); + config->writeEntry("ShowNotification", fShowNotification); + config->writeEntry("ShowBorders", fShowBorders); + config->writeEntry("BorderColor", borderColor.name()); + config->writeEntry("SmallIconSize", iwSmall); + config->writeEntry("BigIconSize", iwBig2); + config->writeEntry("BigIconAmount", fAmount); + config->writeEntry("DockOpacity", dockOpacity); + config->writeEntry("BackgroundColor", bgColor.name()); + config->writeEntry("SeparatorColor", sepColor.name()); + config->writeEntry("ShowKMenu", fShowKMenu); + config->writeEntry("KBFX", fUseKBFX); + config->writeEntry("Priority", fPriority); + config->writeEntry("MouseTimer", fMouseTimer); + config->writeEntry("Clipping", fClipping); + config->writeEntry("ClipIconArea", fClipIcons); + config->writeEntry("percentPos", fpercentPos); + config->writeEntry("zoomSpeed", fzoomSpeed); + config->writeEntry("speedControl", fSpeed); + config->writeEntry("Hidden", fHidden); + config->writeEntry("StayBelow", fStayBelow); + config->writeEntry("fOrientation", fOrientation); + config->writeEntry("showNames", showNames); + config->writeEntry("Cleaner", fCleaner); + config->writeEntry("xosdFont", xosdFont); + config->writeEntry("xosdColor", xosdColor); + config->writeEntry("xosdShadowColor", xosdShadowColor); + config->writeEntry("xosdSize", xosdSize); + config->writeEntry("HideOnClick", fHideOnClick); + config->writeEntry("fSteppy", fSteppy); + config->writeEntry("HighLightTime", fHighLightTime); + config->writeEntry("iSpace", iSpace); + config->writeEntry("FirstRun", FALSE); + config->writeEntry("Xinerama", xinerama); + config->writeEntry("hideTimer", hideTimer); + config->writeEntry("Solid", Solid); + config->writeEntry("ShowSShot", fShowShot); + config->writeEntry("iconGrouping", fGrouping); + config->writeEntry("Navigator", fShowNav); + config->writeEntry("Systray", fSystray); + config->writeEntry("currentDesktop", fCurrent); + + if (xosdBold == true) + { + config->writeEntry("xosdBold", 1); + } + else + { + config->writeEntry("xosdBold", 0); + } + + if (xosdItalic == true) + { + config->writeEntry("xosdItalic", 1); + } + else + { + config->writeEntry("xosdItalic", 0); + } + + config->sync(); +} + + +void KoolDock::editPref() +{ + bool tmp; //to save some code + + // open up the configuration dialog + + // Fill dialog with values from configuration + tmp=fHidden==1; + + setupdlg->chk1->setChecked(tmp); + setupdlg->hideTimer->setEnabled(tmp); + setupdlg->hideOnClick->setEnabled(tmp); + setupdlg->cbStayBelow->setEnabled(!tmp); + setupdlg->cbStayBelow->setChecked(fStayBelow==1); + + tmp=fShowTaskbar==1; + + setupdlg->chk6->setEnabled(tmp); + setupdlg->cbMinimizedOnly->setEnabled(tmp); + setupdlg->chkSshot->setEnabled(tmp); + setupdlg->chkGrouping->setEnabled(tmp); + setupdlg->currentDesk->setEnabled(tmp); + + setupdlg->systray->setChecked(fSystray==1); + + setupdlg->currentDesk->setChecked(fCurrent==1); + + //Even if start Hidden is disabled we load the stored value + setupdlg->hideTimer->setValue(hideTimer); + setupdlg->hideOnClick->setChecked(fHideOnClick == 1); + setupdlg->Steppy->setChecked(fSteppy == 1); + setupdlg->cbCleaner->setChecked(fCleaner == 1); + + tmp=showNames==1; + + setupdlg->chk2->setChecked(tmp); + setupdlg->xosdBold->setEnabled(tmp); + setupdlg->xosdItalic->setEnabled(tmp); + setupdlg->xosdSize->setEnabled(tmp); + setupdlg->spinBox2->setEnabled(tmp); + setupdlg->kColorCombo1->setEnabled(tmp); + setupdlg->kColorCombo_shadow->setEnabled(tmp); + setupdlg->xosdFont->setEnabled(tmp); + setupdlg->cbCleaner->setEnabled(tmp); + + if(Solid==1) + { + setupdlg->chkSolid->setChecked(true); + setupdlg->chkSolidSlot(); + } + else + { + if(!curTheme.isEmpty()) setupdlg->theme->setCurrentText(curTheme); + setupdlg->chkImg->setChecked(true); + setupdlg->chkSolidSlot(); + } + setupdlg->chk4->setChecked(fShowBorders == 1); + setupdlg->kColorCombo1->setColor(xosdColor); + setupdlg->kColorCombo_shadow->setColor(xosdShadowColor); + setupdlg->xosdFont->setCurrentFont(xosdFont); + setupdlg->kColorCombo2->setColor(bgColor.name()); + setupdlg->kColorCombo3->setColor(borderColor.name()); + setupdlg->kColorCombo4->setColor(sepColor.name()); + setupdlg->spinBox1->setValue(dockOpacity); + setupdlg->xosdSize->setValue(xosdSize); + setupdlg->spinBox2->setValue(xosdShadowOffset); + setupdlg->chk5->setChecked(fShowTaskbar == 1); + setupdlg->cbMinimizedOnly->setChecked(fMinimizedOnly == 1); + setupdlg->chk6->setChecked(fShowNotification == 1); + setupdlg->chk7->setChecked(fShowKMenu == 1); + setupdlg->chkUseKBFX->setChecked(fUseKBFX == 1); + setupdlg->iwSmall->setValue(iwSmall); + setupdlg->iwBig->setValue(iwBig2); + setupdlg->fAmount->setValue(fAmount); + setupdlg->sbSpace->setValue(iSpace); + setupdlg->nWideBg->setChecked(fNWideBg); + if (scaleMax) {setupdlg->opScale2->setChecked(true);} else {setupdlg->opScale1->setChecked(true);} + setupdlg->xosdBold->setChecked(xosdBold); + setupdlg->xosdItalic->setChecked(xosdItalic); + if (xinerama==1) + { + setupdlg->xrma->setChecked(true); + setupdlg->SleftRes->setEnabled(true); + setupdlg->SHeight->setEnabled(true); + setupdlg->PWidth->setEnabled(true); + setupdlg->SleftRes->setValue(leftRes); + setupdlg->SHeight->setValue(XinDesiredHeight); + setupdlg->PWidth->setValue(XinPreviousWidth); + } + else + { + setupdlg->SleftRes->setEnabled(false); + setupdlg->SHeight->setEnabled(false); + setupdlg->PWidth->setEnabled(false); + setupdlg->xrma->setChecked(false); + setupdlg->SleftRes->setValue(QApplication::desktop()->width()); + setupdlg->SHeight->setValue(QApplication::desktop()->height()); + } + setupdlg->nav->setChecked(fShowNav==1); + setupdlg->chkSshot->setChecked(fShowShot); + setupdlg->chkGrouping->setChecked(fGrouping); + setupdlg->Priority->setValue(fPriority); + //setupdlg->cbMouseTimer->setValue(fMouseTimer); + setupdlg->chClipping->setChecked(fClipping==1); + setupdlg->chClipIcons->setChecked(fClipIcons==1); + setupdlg->zoomSpeed->setValue(fzoomSpeed); + setupdlg->chkSpeed->setChecked(fSpeed); + setupdlg->percentPos->setValue(fpercentPos); + if (fOrientation==0) setupdlg->op0->setChecked(true); + if (fOrientation==1) setupdlg->op1->setChecked(true); + if (fOrientation==2) setupdlg->op2->setChecked(true); + if (fOrientation==3) setupdlg->op3->setChecked(true); + loadIgnore(); //Load Ignore List + + if (!setupdlg->isVisible()) if (!noSet) setupdlg->tabWidget->setCurrentPage(0); + setupdlg->toReloadIcons->setChecked(FALSE); + + setupdlg->show(); + KWin::WindowInfo winfo; + winfo = KWin::windowInfo(setupdlg->winId()); + + if (winfo.desktop()!=-1) KWin::setOnDesktop(setupdlg->winId(), KWin::currentDesktop()); + KWin::activateWindow(setupdlg->winId()); + +} + +void KoolDock::loadMenu() +{ + QDir homeDir = QDir::home(); + if (homeDir.exists(menuPath)) + { + QDir dir(menuPath); + //First we make sure every index is correct! + //Lets update the launchers index + QString preffix; + QStringList fileListRemove=dir.entryList("*.desktop"); + QStringList fileListRemove2=fileListRemove; + + //Not really sure why I couldn't do this within the other for, something like fileListRemove[i].remove(0,2).prepend(preffix), but hell it works + for(unsigned int i=0; i<fileListRemove2.count(); i++) + { + fileListRemove2[i].remove(0,2); + } + + //Rename the files so they reflect their new position + for(unsigned int i=0; i<fileListRemove.count(); i++) + { + if(i<10) preffix=QString("0%1").arg(i); + if(i>=10) preffix=QString("%1").arg(i); + + dir.rename(fileListRemove[i], QString("%1%2").arg(preffix).arg(fileListRemove2[i])); + } + //End updating launchers index + + QStringList fileList = dir.entryList( "*.desktop"); + if(!fileList.isEmpty()) + { + for ( QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it ) + { + if ( ((*it) != ".") && ((*it) != "..") ) + { + items.append(new Item(menuPath + (*it), iwSmall, iwBig2)); + } + } + } + } + else + { + debug("Config directory doesn't exits"); + QDir progPathDir(progPath); + progPathDir.mkdir(progPath); + QDir menuPathDir(menuPath); + menuPathDir.mkdir(menuPath); + debug("Created item directory"); + + // create initial entries. + addFile(QString("00_konqueror.desktop"), QString("konqueror"), QString("kfmclient openProfile webbrowsing"), QString("Konqueror Web Browser"), true, false, false, false, QString("na")); + addFile(QString("01_home.desktop"), QString("kfm_home"), QString("kfmclient openProfile filemanagement"), QString("Home directory"), true, false, false, false, QString("na")); + addFile(QString("02_kmail.desktop"), QString("kmail"), QString("kmail"), QString("KMail"), true, false, false, false, QString("na")); + addFile(QString("03_kate.desktop"), QString("kate"), QString("kate"), QString("Kate"), true, false, false, false, QString("na")); + addFile(QString("04_konsole.desktop"), QString("konsole"), QString("konsole"), QString("Konsole"), true, false, false, false, QString("na")); + addFile(QString("05_kcontrol.desktop"), QString("kcontrol"), QString("kcontrol"), QString("Control Center"), true, false, false, false, QString("na")); + + loadMenu(); + } + numLaunchers = items.count(); +} + + +void KoolDock::about() +{ + KAboutApplication about(this, 0, false); + about.exec(); +} + + +void KoolDock::onChangeTimerTicked() +{ + if (animValue > 70) animState = FALSE; + if (animValue < 5) animState = TRUE; + + if (animState == TRUE) + { + animValue = animValue + 5; + } + else + { + animValue = animValue - 5; + } + paintEvent(NULL); +} + + +void KoolDock::updateBackground(const QPixmap& pix) +{ + if (pix.width()==1 && pix.height()==1) + { + if (fHidden == 0) + { + if ((fOrientation & 1)==1) {bottomBg = QPixmap(h1, dw);} else {bottomBg = QPixmap(dw, h1);} + bottomBg.fill (pix.convertToImage().pixel(0,0)); + } + if (dockOpacity > 0) {bitBlt(&bottomBgf,0,0,&bottomBg);KPixmapEffect::fade(bottomBgf, ((float)dockOpacity)*0.01, bgColor);} + } + else + { + if (fHidden == 0) bottomBg = QPixmap(pix); + if (dockOpacity > 0) {bitBlt(&bottomBgf,0,0,&bottomBg);KPixmapEffect::fade(bottomBgf, ((float)dockOpacity)*0.01, bgColor);} + } + uw=w; + paintEvent(NULL); + +} + +void KoolDock::toggleAlwaysOnTop() +{ + KWin::WindowInfo info=KWin::windowInfo(cId); + + if (info.state() & NET::KeepAbove) + { + KWin::clearState(cId,NET::KeepAbove); + } + else + { + KWin::setState(cId,NET::KeepAbove); + KWin::raiseWindow(cId); + } +} + +void KoolDock::toggleKeptBelowOthers() +{ + KWin::WindowInfo info=KWin::windowInfo(cId); + + if (info.state() & NET::KeepBelow) + { + KWin::clearState(cId,NET::KeepBelow); + } + else + { + KWin::setState(cId,NET::KeepBelow); + KWin::lowerWindow(cId); + } +} + +void KoolDock::toggleFullScreen() +{ + KWin::WindowInfo info=KWin::windowInfo(cId); + + if (info.state() & NET::FullScreen) + { + KWin::clearState(cId,NET::FullScreen); + } + else + { + KWin::setState(cId,NET::FullScreen); + } +} + +void KoolDock::moveApp() +{ + KWin::WindowInfo info=KWin::windowInfo(cId); + activateApp(); + + QCursor::setPos(info.geometry().center()); + + NETRootInfo ri(qt_xdisplay(), NET::WMMoveResize); + ri.moveResizeRequest(cId, info.geometry().center().x(), info.geometry().center().y(), NET::Move); +} + +void KoolDock::resizeApp() +{ + KWin::WindowInfo info=KWin::windowInfo(cId); + activateApp(); + + QCursor::setPos(info.geometry().bottomRight()); + + NETRootInfo ri(qt_xdisplay(), NET::WMMoveResize); + ri.moveResizeRequest(cId, info.geometry().bottomRight().x(), + info.geometry().bottomRight().y(), NET::BottomRight); +} + +void KoolDock::minApp() +{ + Item *item; + int i; + QPixmap shot; + QImage tmpImg; + KWin::WindowInfo info=KWin::windowInfo(cId); + + if (info.isMinimized()) + { + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if(item->getId() == cId) + { + // set default's item icon + item->setIcon(KWin::icon(cId, iwBig2, iwBig2, TRUE)); + } + } + KWin::deIconifyWindow(cId, true); + KWin::activateWindow(cId); + } + else + { + if (fShowShot == TRUE) + { + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if(item->getId() == cId) + { + // take the screenshot + shot = QPixmap::grabWindow(cId); + // scale the screenshot + tmpImg = shot.convertToImage(); + tmpImg.scale(iwBig2, iwBig2); + shot.convertFromImage(tmpImg); + // set the new item's icon + item->setIcon(shot); + } + } + paintEvent(NULL); + } + KWin::iconifyWindow(cId, true); + } + hide(); + QTimer::singleShot( 100, this, SLOT(refreshBackground()) ); +} + + +void KoolDock::maxApp() +{ + Item *item; + int i; + KWin::WindowInfo info=KWin::windowInfo(cId); + + if (fShowShot == TRUE) + { + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if(item->getId() == cId) + { + // set default's item icon + item->setIcon(KWin::icon(cId, iwBig2, iwBig2, TRUE)); + } + } + } + if (info.isMinimized()) + { + KWin::deIconifyWindow(cId, true); + } + else + { + if (info.state() & NET::Max) + { + KWin::clearState(cId, NET::Max); + } + else + { + KWin::setState(cId, NET::Max); + } + } + KWin::activateWindow(cId); + hide(); + QTimer::singleShot( 100, this, SLOT(refreshBackground()) ); +} + +void KoolDock::restApp() +{ + Item *item; + int i; + KWin::WindowInfo info=KWin::windowInfo(cId); + + if (fShowShot == TRUE) + { + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if(item->getId() == cId) + { + // set default's item icon + item->setIcon(KWin::icon(cId, iwBig2, iwBig2, TRUE)); + } + } + } + + KWin::clearState(cId, NET::MaxVert + NET::MaxHoriz); + KWin::deIconifyWindow(cId, true); + KWin::activateWindow(cId); + hide(); + QTimer::singleShot( 100, this, SLOT(refreshBackground()) ); +} + +void KoolDock::minAllApps() +{ + int i; + Item *item; + KWin::WindowInfo info=KWin::windowInfo(cId,0,NET::WM2WindowClass); + QCString cls=info.windowClassClass(); + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if (!item->info.isMinimized()) + { + if ((fMinimizedOnly==0 || item->info.isMinimized()) || (fCurrent==0 || item->info.isOnDesktop(info.desktop()))) + { + if (cls==item->getClass()) + { + KWin::iconifyWindow(item->getId(), true); + } + } + } + } + +} + +void KoolDock::maxAllApps() +{ + int i; + Item *item; + KWin::WindowInfo info=KWin::windowInfo(cId,0,NET::WM2WindowClass); + QCString cls=info.windowClassClass(); + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if (!(item->info.state() & NET::Max) || item->info.isMinimized()) + { + if ((fMinimizedOnly==0 || item->info.isMinimized()) || (fCurrent==0 || item->info.isOnDesktop(info.desktop()))) + { + if (cls==item->getClass()) + { + if (item->info.isMinimized()) KWin::deIconifyWindow(item->getId(),true); + KWin::setState(item->getId(), NET::Max); + } + } + } + } +} + +void KoolDock::restAllApps() +{ + int i; + Item *item; + KWin::WindowInfo info=KWin::windowInfo(cId,0,NET::WM2WindowClass); + QCString cls=info.windowClassClass(); + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if (item->info.state() & NET::Max || item->info.isMinimized()) + { + if ((fMinimizedOnly==0 || item->info.isMinimized()) || (fCurrent==0 || item->info.isOnDesktop(info.desktop()))) + { + if (cls==item->getClass()) + { + if (item->info.isMinimized()) + { + KWin::deIconifyWindow(item->getId(),true); + } + else + { + KWin::clearState(item->getId(), NET::Max); + } + } + } + } + } +} + +void KoolDock::closeAllApps() +{ + int i; + Item *item; + KWin::WindowInfo info=KWin::windowInfo(cId,0,NET::WM2WindowClass); + QCString cls=info.windowClassClass(); + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if ((fMinimizedOnly==0 || item->info.isMinimized()) || (fCurrent==0 || item->info.isOnDesktop(info.desktop()))) + { + if (cls==item->getClass()) + { + NETRootInfo app(qt_xdisplay(), NET::CloseWindow); + app.closeWindowRequest(item->getId()); + } + } + } +} + +void KoolDock::shadeApp() +{ + KWin::WindowInfo info=KWin::windowInfo(cId); + + if (info.state() & NET::Shaded) + { + KWin::clearState(cId, NET::Shaded); + } + else + { + KWin::setState(cId, NET::Shaded); + } + + hide(); + QTimer::singleShot( 100, this, SLOT(refreshBackground()) ); +} + +void KoolDock::activateApp() +{ + Item *item; + int i; + KWin::WindowInfo info = KWin::windowInfo(cId); + + if (fShowShot == TRUE) + { + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if(item->getId() == cId) + { + // set default's item icon + item->setIcon(KWin::icon(cId, iwBig2, iwBig2, TRUE)); + } + } + } + + if (info.desktop()!=-1 && info.desktop()!=KWin::currentDesktop()) + { + goToDesktop(info.desktop()); + } + if (info.isMinimized()) KWin::deIconifyWindow(cId, true); + KWin::activateWindow(cId); + hide(); + QTimer::singleShot( 100, this, SLOT(refreshBackground()) ); +} + +void KoolDock::closeApp() +{ + NETRootInfo app(qt_xdisplay(), NET::CloseWindow); + app.closeWindowRequest(cId); + debug(QString("Closed: %1").arg(cId)); +} + + +void KoolDock::editItem() +{ + run(QString("kfmclient openProperties ") + iFilename); +} + + +void KoolDock::sendToDesktop(int desktop) +{ + if (desktop==0) desktop=-1; + if (iGroup && allApps) + { + int i; + Item *item; + KWin::WindowInfo info=KWin::windowInfo(cId,0,NET::WM2WindowClass); + QCString cls=info.windowClassClass(); + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if ((fMinimizedOnly==0 || item->info.isMinimized()) || (fCurrent==0 || item->info.isOnDesktop(info.desktop()))) + { + if (cls==item->getClass()) + { + KWin::setOnDesktop(item->getId(), desktop); + } + } + } + return; + } + KWin::setOnDesktop(cId, desktop); +} + + +void KoolDock::goToDesktop(int desktop) +{ + KWin::setCurrentDesktop(desktop); +} + + +void KoolDock::goToWindow(int win) +{ + cId=(WId)win; + activateApp(); +} + + +void KoolDock::removeItem() +{ + QFile::remove(iFilename); + restart(); +} + + +void KoolDock::addFile(QString filename, QString iconname, QString execname, QString name, bool notify, bool terminal, bool tclose, bool cuser, QString puser) +{ + QString progPath = locateLocal("data", "kooldock"); + QString menuPath = progPath + QString("/menu/"); + QString confFile = locateLocal("config", "kooldockrc"); + + QFile out(QString(menuPath + filename)); + if (out.open(IO_WriteOnly)) + { + QTextStream out_s(&out); + out_s << "[Desktop Entry]" << endl; + out_s << "Comment=" << endl; + out_s << "Encoding=UTF-8" << endl; + out_s << "Exec=" << execname << endl; + out_s << "GenericName=" << endl; + out_s << "Icon=" << iconname << endl; + out_s << "MimeType=" << endl; + out_s << "Name=" << name << endl; + out_s << "Path=" << endl; + out_s << "ServiceTypes=" << endl; + out_s << "SwallowExec=" << endl; + out_s << "SwallowTitle=" << endl; + out_s << "Terminal=false" << endl; + out_s << "TerminalOptions=" << endl; + out_s << "Type=Application" << endl; + if(notify == true) + { + out_s << "X-KDE-StartupNotify=true" << endl; + } + else + { + out_s << "X-KDE-StartupNotify=false" << endl; + } + if(cuser==true) + { + out_s << "X-KDE-SubstituteUID=true" << endl; + out_s << "X-KDE-Username=" << puser << endl; + } + else + { + out_s << "X-KDE-SubstituteUID=false" << endl; + out_s << "X-KDE-Username=" << endl; + } + if(terminal==true) + { + out_s << "Terminal=true" << endl; + } + else + { + out_s << "Terminal=false" << endl; + } + if(tclose==true) + { + out_s << "TerminalOptions=\\s--noclose" << endl; + } + else + { + out_s << "TerminalOptions=" << endl; + } + out.close(); + } +} + + +bool KoolDock::ignored(QString appname) +{ + if(ignoreList.count()>0) + { + for(unsigned int i=0; i<ignoreList.count(); i++) + { + if(ignoreList[i]==appname) + return(true); + + } + } + return(false); +} + + +#ifdef _ENABLE_DEBUG +void KoolDock::debug(QString message) +{ + // debugging function (show messages to stdout) + kdDebug(0) << "DEBUG: " << message << endl; +} +#endif +#ifndef _ENABLE_DEBUG +void KoolDock::debug(QString) +{ +} +#endif + +void KoolDock::endProg() +{ + if (fHidden==0 && fClipping==1) + { + if ((fOrientation & 1)==1) + { + setDesktopIconsArea(0,0,dh,dw); + } + else + { + setDesktopIconsArea(0,0,dw,dh); + } + } + debug("Clean exit."); + exit(0); +} + +void KoolDock::restart() +{ + QString cmd; + cmd = mainPath + " &"; + kdDebug(0) << "mainPath: " << mainPath << endl; + debug("Restarting..."); + system(cmd.latin1()); + endProg(); +} + +void KoolDock::reload() +{ + setupdlg->setEnabled(FALSE); + + hide(); + if (wm) delete(wm); + trackTimer->stop(); + mkbigTimer->stop(); + mksmallTimer->stop(); + mTimer->stop(); + if (onChangeTimer != NULL) onChangeTimer->stop(); + + if (trackTimer) delete(trackTimer); + if (mTimer) delete(mTimer); + if (mkbigTimer) delete(mkbigTimer); + if (mksmallTimer) delete(mksmallTimer); + if (onChangeTimer != NULL) delete(onChangeTimer); + if (_filterData) delete(_filterData); + + if (rootpix) delete(rootpix); + if (xosdw) delete(xosdw); + if (clipw) delete(clipw); + if (info) delete(info); + + if (reloadIcons) + { + items.clear(); + witems.clear(); + } + init1(); + init2(); + if (setupdlg->isVisible()) + { + noSet=true; + editPref(); + if (reloadIcons) + { + setupdlg->appClear(); + setupdlg->appFill(); + } + noSet=false; + } +} + +void KoolDock::chkRestart() +{ + if (initialization) return; + if (!setupdlg ) return; + // this function is called by a timer to check if the dock should be restarted + // or not, depending on what was done in the configuration dialog. + reloadIcons=setupdlg->toReloadIcons->isChecked(); + reload(); + reloadIcons=false; + setupdlg->toReloadIcons->setChecked(FALSE); +} + + +void KoolDock::setMainPath(QString path) +{ + mainPath = path; +} + +void KoolDock::setArgs(QString params) +{ + args = params; + if (args=="-options" || args=="-o") editPref(); + +} + +void KoolDock::move2(int nx, int ny) +{ + int cx, cy, tmp, xn=0; + if (xinerama==1) {xn=XinPreviousWidth;} + + cx=0; + if ((fOrientation & 2) == 2) {ny=0; cy=0;} else {ny=dh-h1; cy=dh-h0;} + if ((fOrientation & 1) == 1) + {rx=ny; ry=nx; + tmp=cx;cx=cy;cy=tmp;} + else + {rx=nx; ry=ny;} + //if (fHidden==0) clipw->move(cx,cy); + if (rx==x0 && ry==dh-h0 && fExpanded==FALSE && w1>dw) + { + if (w0>dw) + { + Offset=(w1-dw)*lastXPos/dw - rx; + if ((fOrientation & 1) == 1) ry=0; + move(xn,ry); + } + else + { + Offset=0; + if ((fOrientation & 1) == 1) {ry=0;} else {rx=0;} + move(rx+xn,ry); + } + } + else + { + if ((fOrientation & 1) == 1) {ry=0;} else {rx=0;} + move(rx+xn,ry); + } + rx+=xn; + //clipw->lower(); +} + +void KoolDock::resize2(int nw, int nh) +{ + int mw, mh; + //if (w1>dw && nw>w1) + nw=dw; + nh=h1; + if ((fOrientation & 1) == 1) {rw=nh; rh=nw;} else {rw=nw; rh=nh;} + if (w1<dw) Offset=0; + resize(rw,rh); + nw=dw; + nh=h0; + if ((fOrientation & 1) == 1) {mw=nh; mh=nw;} else {mw=nw; mh=nh;} + //clipw->resize(200, 200); + //clipw->lower(); +} +void KoolDock::getBottomBG() +{ + if (fHidden==0) return; + int p1,p2,p3,p4,pt; + p1=0; + if ((fOrientation & 2)==2) {p2=0;} else {p2=dh - h1;} + p3=dw; + p4=h1; + if ((fOrientation & 1)==1) + { + pt=p1; p1=p2; p2=pt; + pt=p3; p3=p4; p4=pt; + } + if (xinerama==1) p1+=XinPreviousWidth; + bottomBg = QPixmap::grabWindow(qt_xrootwin(), p1, p2, p3, p4); + //bottomBg = QPixmap::grabWindow(qt_xrootwin(), x1, dh - h1, w1, h1); +} + +void KoolDock::getTopBG() +{ + int p1,p2,p3,p4,pt; + p1=0; + if ((fOrientation & 2)==2) {p2=h0;} else {p2=dh - h1;} + p3=dw; + p4=h1 - h0; + if ((fOrientation & 1)==1) + { + pt=p1; p1=p2; p2=pt; + pt=p3; p3=p4; p4=pt; + } + if (xinerama==1) p1+=XinPreviousWidth; + topBg = QPixmap::grabWindow(qt_xrootwin(), p1, p2, p3, p4); + //topBg = QPixmap::grabWindow(qt_xrootwin(), x1, dh - h1, w1, h1 - h0); +} + +void KoolDock::setDesktopIconsArea(int left, int top, int width, int height) +{ + if (fClipIcons==0) return; + DCOPClient* client = KApplication::dcopClient(); + if (!client->isAttached()) { + client->attach(); + client->registerAs("KoolDock"); + } + + for (int i = 0; i < KWin::numberOfDesktops(); i++) { + QByteArray data; + QDataStream args(data, IO_WriteOnly); + args << left << top << width << height << i; + client->send("kdesktop", "KDesktopIface", "desktopIconsAreaChanged(QRect, int)", data); + } +} + +void KoolDock::setDockAbove() { + KWin::setState(winId(), NET::KeepAbove); + raise(); +} + +void KoolDock::setDockBelow() { + KWin::setState(winId(), NET::KeepBelow); + lower(); +} + +void KoolDock::menuShow() +{ + allApps=false; + int tcId; + if (iGroup && menuCount!=0) + { + tcId=appMenu->itemParameter(currMenu); + + if (tcId==currMenu && menuCount==1) + { + allApps=true; + deskpopup->setItemChecked(dIndex,false); + return; + } + cId=tcId; + KWin::WindowInfo info=KWin::windowInfo(cId,0,NET::WM2AllowedActions); + deskpopup->setItemChecked(dIndex,false); + dIndex=info.desktop(); + if (dIndex==-1) dIndex=0; + deskpopup->setItemChecked(dIndex,true); + advMenu->setItemChecked(1,info.state() & NET::KeepAbove); + advMenu->setItemChecked(2,info.state() & NET::KeepBelow); + advMenu->setItemChecked(3,info.state() & NET::FullScreen); + advMenu->setItemEnabled(3,info.actionSupported(NET::ActionFullScreen)); + } +} + +void KoolDock::menuX(int num) +{ + if (iGroup && menuCount!=0) + { + currMenu=num; + } +} + +void KoolDock::init1() +{ + initialization=true; + ptPart=5; + // Load the configuration + loadConf(); + + if (fStayBelow==0 || fHidden==1) + { + reparent (0, getWFlags() | WX11BypassWM, pos(),FALSE); + } + else + { + reparent (0, getWFlags() & !WX11BypassWM, pos(),FALSE); + } + hide(); + + // Lets initialize the systray counter + if (reloadIcons) numSystray=0; + + // first, we set our "nice" priority + if (fPriority > 19) fPriority = DEF_PRIORITY; + if (fPriority < 0) fPriority = DEF_PRIORITY; + setpriority(0, 0, fPriority); + debug(QString("Priority: %1").arg(fPriority)); + + iwBig2 = iwBig; + + lastX=0; + + iDist = iwSmall + iSpace; + funcW = (int)(iDist*fAmount/2); + funcH = iwBig - iwSmall; + iy = iSpace/ 2; + + + KWin::setOnAllDesktops(winId(), true); + KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager); + KWin::setType(winId(), NET::Dock); + + items.setAutoDelete(TRUE); + popups.setAutoDelete(TRUE); + desks.setAutoDelete(TRUE); + + if(fShowKMenu==1) + { + if (fUseKBFX==1) + { + if (reloadIcons) items.append(new Item("kmenu", "dcop kicker KBFXInterface showMenu", "KMenu", iwSmall, iwBig2)); + } + else + { + if (reloadIcons) items.append(new Item("kmenu", "dcop kicker kicker popupKMenu 0", "KMenu", iwSmall, iwBig2)); + } + } + + + //Lets load the menu entries + if (reloadIcons) loadMenu(); + if (items.count()==0) + { + items.append(new Item("kooldock", "kooldock -k; kooldock -o" , "K", iwSmall, iwBig2)); + } + // Create the "xosd" widget + xosdw = new xosd(); + rdh=QApplication::desktop()->height(); + xosdw->move(0,rdh); + + wm = new KWinModule(); + + info = new NETWinInfo( qt_xdisplay(), winId(), qt_xrootwin(), NET::WMState); + info->setDesktop( NETWinInfo::OnAllDesktops ); + info->setState(NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager, NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager); + setBackgroundMode(NoBackground); + + // Load the ignore List + loadIgnore(); + + xosd_st = 0; + xosdw->setFont(xosdFont); + if (xosdItalic == true) xosdw->setItalic(); + if (xosdBold == true) xosdw->setBold(); + xosdw->setSize(xosdSize); + xosdw->setShadowOffset(xosdShadowOffset); + xosdw->setColor(xosdColor); + xosdw->setShadowColor(xosdShadowColor); + + // Show task bar + if (fShowTaskbar) + { + //Lets add the necesary windows + if (reloadIcons) {firstTime=true;addWindows();} + connect(wm, SIGNAL(activeWindowChanged(WId)), SLOT(activeWindowChanged(WId))); + + } + connect(wm, SIGNAL(windowAdded(WId)), SLOT(windowAdded(WId))); + connect(wm, SIGNAL(windowRemoved(WId)), SLOT(windowRemoved(WId))); + connect(wm, SIGNAL(windowChanged(WId, unsigned int)), SLOT(windowChanged(WId, unsigned int))); + if (fSystray) + { + /* System Tray implementation (hope this works - Francisco) */ + connect(wm, SIGNAL(systemTrayWindowAdded(WId)), SLOT(systemTrayWindowAdded(WId))); + connect(wm, SIGNAL(systemTrayWindowRemoved(WId)), SLOT(systemTrayWindowRemoved(WId))); + + QCString screenstr; + screenstr.setNum(qt_xscreen()); + QCString trayatom = "_NET_SYSTEM_TRAY_S" + screenstr; + + Display *display = qt_xdisplay(); + + net_system_tray_selection = XInternAtom(display, trayatom, false); + net_system_tray_opcode = XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", false); + + // Acquire system tray + XSetSelectionOwner(display, net_system_tray_selection, winId(), CurrentTime); + + //WId root = qt_xrootwin(); + + if (XGetSelectionOwner (display, net_system_tray_selection) == winId()) + { + XClientMessageEvent xev; + + xev.type = ClientMessage; + //xev.window = root; + + xev.message_type = XInternAtom (display, "MANAGER", False); + xev.format = 32; + xev.data.l[0] = CurrentTime; + xev.data.l[1] = net_system_tray_selection; + xev.data.l[2] = winId(); + xev.data.l[3] = 0; + xev.data.l[4] = 0; + + //XSendEvent (display, root, False, StructureNotifyMask, (XEvent *)&xev); + } + } + connect(wm, SIGNAL(currentDesktopChanged(int)), SLOT(currentDesktopChanged(int))); + connect(wm, SIGNAL(workAreaChanged()), SLOT(workAreaChanged())); + + // Pseudo-Transparency code + rootpix = new KRootPixmap(this); + rootpix->setCustomPainting(TRUE); + connect(rootpix, SIGNAL(backgroundUpdated (const QPixmap &)), SLOT(updateBackground(const QPixmap &))); + rootpix->start(); + + debug(QString("Items loaded: %1").arg(items.count())); + + //Simple work around to support xinerama (user defined) + if(xinerama==0) + { + dw=QApplication::desktop()->width(); + dh = QApplication::desktop()->height(); + } + else + { + dw=leftRes; + dh=XinDesiredHeight; + } + + xosdw->setClear(fCleaner); + xosdw->setOrientation(fOrientation & 1, dw, rdh); + + // All icons to small size + unsigned int i; + for (i=0; i < items.count() + 1; i++) + { + iSize[i] = iwSmall; + } + for (i=0; i < items.count() + 1; i++) + { + cx[i] = iSpace + i*iDist + iwSmall/2; + cur_cx[i] = cx[i]; + } + if ((fOrientation & 1)==1) + { + int tmpdw; + tmpdw=dw; + dw=dh; + dh=tmpdw; + } + if (fOrientation==2 || fOrientation==1) + { + QString tmpstr; + tmpstr=fLeftImg; + fLeftImg=fRightImg; + fRightImg=tmpstr; + } + + Offset=0; + + xosdw->move2(0,rdh); + xosdw->show(); + //setMouseTracking(TRUE); + fExpanded=FALSE; + // Timer to track the mouse position + // When the mouse pointer reaches the bottom of the screen, the bar should popup in a userdefined time (int hideTimer) + + track2active=FALSE; + trackTimer = new QTimer(this); + connect(trackTimer, SIGNAL(timeout()), this, SLOT(trackTimerEnd())); + + ii_first = 0; + ii_last = items.count() - 1; + + iOnClick = -1; + onChangeTimer = NULL; + Ybase = 0; + soffset=0; + eoffset=0; + last_ncx=0; + + /* For the the onscreen text (icon names) */ + nom = ""; + aux = ""; + + mTimer = new QTimer(this); + connect(mTimer, SIGNAL(timeout()), this, SLOT(mTimerEnd())); + + _filterData = new KURIFilterData(); + + mkbigTimer = new QTimer(this); + connect(mkbigTimer, SIGNAL(timeout()), this, SLOT(mkbigTimerDo())); + + mksmallTimer = new QTimer(this); + connect(mksmallTimer, SIGNAL(timeout()), this, SLOT(mksmallTimerDo())); + + QWMatrix m; + m.rotate( -90*fOrientation ); + if (!fLeftImg.isEmpty()) + { + LeftImg.load(fLeftImg); + LeftImg = LeftImg.xForm( m ); + } + if (!fRightImg.isEmpty()) + { + RightImg.load(fRightImg); + RightImg = RightImg.xForm( m ); + } + if (!fCenterImg.isEmpty()) + { + CenterImg.load(fCenterImg); + CenterImg = CenterImg.xForm( m ); + } + + if (fHidden==1) + { + move (0,rdh); + } + debug("Kooldock has started"); + + doUpdateGeometry(); + if ((fOrientation & 1)==1) {offscr = QPixmap(h1, dw); bottomBgf = QPixmap(h1, dw);} else {offscr = QPixmap(dw, h1); bottomBgf = QPixmap(dw, h1);} + + soffset = iwSmall/2 + func2(abs(1-funcW)) + func2(abs(iDist+1-funcW)) + func2(abs(2*iDist+1-funcW)) + func2(abs(3*iDist +1-funcW))/2 - ((int)((iwBig - iwSmall)*0.6*fAmount) + iSpace*2)/2 - 4*iwSmall - (int)((3*iDist+1-funcW)*(func(0) + func(iDist) - 2*iwSmall)/(2*iDist))+1; + eoffset=(int)((iwBig2-iwSmall)*fAmount/100); + doUpdateGeometry(); + +} + +void KoolDock::init2() +{ + clipw = new clip(); + + if (fHidden==1) + { + clipw->resize(0,0); + clipw->move(-10,-10); + } + else + { + int cx, cy; + cx=0; + if ((fOrientation & 2) == 2) {cy=0;} else {cy=dh-h0;} + if ((fOrientation & 1) == 1) + {clipw->move(cy,cx);clipw->resize(h0,dw);} + else + {clipw->move(cx,cy);clipw->resize(dw,h0);} + } + KWin::setOnAllDesktops(clipw->winId(), true); + KWin::setState(clipw->winId(), NET::KeepBelow); + clipw->lower(); + clipw->show(); + + animValue = 0; + animState = TRUE; + + if (fHidden==0) + { + resize2(w0,h0); + rootpix->repaint(true); + } + //Create desktop clipper widget + + if (fHidden==0 && fClipping==1) + { + //clipping desktop + if (fOrientation==0) {clipw->clipDesktop(0, 0, 0, 0, 0, 0, 0, 0, 0, h0, 0, dh);setDesktopIconsArea(0,0,dw,dh-h0);} + if (fOrientation==1) {clipw->clipDesktop(0, 0, 0, h0, 0, dh, 0, 0, 0, 0, 0, 0);setDesktopIconsArea(0,0,dh-h0,dw);} + if (fOrientation==2) {clipw->clipDesktop(0, 0, 0, 0, 0, 0, h0, 0, dh, 0, 0, 0);setDesktopIconsArea(0,h0,dw,dh);} + if (fOrientation==3) {clipw->clipDesktop(h0, 0, dh, 0, 0, 0, 0, 0, 0, 0, 0, 0);setDesktopIconsArea(h0,0,dh,dw);} + } + if (fStayBelow==1 && fHidden==0) setDockBelow(); + setAcceptDrops(TRUE); + useList=false; + if (fSpeed) ptPart=0; else ptPart=1; + if (fHidden==0) paintEvent(NULL); + if (ptPart==0) + enterEvent(NULL); + else + pTest(); +} + +void KoolDock::pTest() +{ + + if (ptPart==0) + { + onleaveEvent(NULL); ptPart=1; + return; + } + + //Finalize initialization + if(fHidden==1) + { + trackTimer->start(250, FALSE); + } + else + { + mTimer->start(250, FALSE); + } + oldDesktop=KWin::currentDesktop(); + initialization=false; + if (fShowTaskbar) addWindows(); + show(); + if (fHidden==0) paintEvent(NULL); + setupdlg->setEnabled(TRUE); + if (fFirstRun) editPref(); + updTaskList(); +} + +void KoolDock::refreshBackground() +{ + getBottomBG(); + getTopBG(); + if (dockOpacity > 0) {bitBlt(&bottomBgf,0,0,&bottomBg);KPixmapEffect::fade(bottomBgf, ((float)dockOpacity)*0.01, bgColor);} + show(); + paintEvent(NULL); +} + +void KoolDock::dragMoveEvent(QDragMoveEvent* event) +{ + if (mouseOnLauncher && QTextDrag::canDecode(event)) + { + event->accept(); + } + else + { + event->ignore(); + } +} + +void KoolDock::dropEvent(QDropEvent* event) +{ + QString strDrop; + QPoint pointer; + pointer = QCursor::pos(); + int px, py; + + px = pointer.x()-pos().x(); + py = pointer.y()-pos().y(); + + QTextDrag::decode(event, strDrop); + lstDrop=QStringList::split(QString("\n"),strDrop,false); + + useList=true; + mPress (px, py, Qt::LeftButton); + useList=false; +} + +void KoolDock::movetoback(WId id) +{ + int i; + Item *item; + int ic=-1,jc; + QCString cls; + + //find clicked item in witems list + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + if (item->getId()==id) {ic=i;break;} + + if (ic>=0) + { + jc=witems.at(ic)->getIndex(); //get item stack index + for (i=0, item = witems.at(0); item; i++, item = witems.next()) + { + if (item->getIndex()>jc) item->setIndex(item->getIndex()-1); + } + //move clicked item to last position in the stack + witems.at(ic)->setIndex(witems.count()-1); + cls = witems.at(ic)->getClass(); + for (i=numLaunchers, item = items.at(numLaunchers); item; i++, item = items.next()) + { + if (item->getClass()==cls) + { + item->setId(witems.at(ic)->getId()); + item->setName(witems.at(ic)->getName()); + break; + } + } + } +} + +int KoolDock::itemFromPoint(int x) +{ + int i, Xpos=-1; + for (i=0; i<(int)items.count(); i++) + { + Xpos=xFromIndex(i); + if ((x+iSpace/2)>Xpos && (x-iSpace)<(Xpos+iSize[i])) break; + } + currXPos=Xpos; + return i; +} + +int KoolDock::xFromIndex(int i) +{ + int Xpos; + if(i < ii_first){Xpos = cur_cx[i] - iwSmall/2 + SPACE_W;} + else if(i >= ii_first && i <= ii_last){Xpos = cur_cx[i] - iSize[i]/2 + adjust+soffset;} + else if(i > ii_last){Xpos = cur_cx[i] - iwSmall/2 + adjust + SPACE_W - 3+soffset*0;} + return Xpos; +} + +void KoolDock::aboutToShow() +{ + menuCount++; +} + +void KoolDock::aboutToHide() +{ + menuCount--; +} + +void KoolDock::createMenu(WId id, KPopupMenu* tmpMenu, KWin::WindowInfo * info) +{ + QString appTitle; + int menustate; + appTitle = info->visibleName(); + appTitle.truncate(30); + + tmpMenu->insertTitle(appTitle); + + tmpMenu->insertItem(i18n("Ad&vanced"), advMenu); + + menustate = tmpMenu->insertItem(SmallIcon("move"), i18n("&Move"), this, SLOT(moveApp())); + tmpMenu->setItemEnabled(menustate, info->actionSupported(NET::ActionMove)); + + menustate = tmpMenu->insertItem(i18n("Re&size"), this, SLOT(resizeApp())); + tmpMenu->setItemEnabled(menustate, info->actionSupported(NET::ActionMove)); + + menustate = tmpMenu->insertItem(i18n("Mi&nimize"), this, SLOT(minApp())); + if (info->isMinimized()) tmpMenu->setItemChecked(menustate, true); + tmpMenu->setItemEnabled(menustate, info->actionSupported(NET::ActionMinimize)); + + menustate = tmpMenu->insertItem(i18n("Ma&ximize"), this, SLOT(maxApp())); + if ((info->state() & NET::Max) && !info->isMinimized()) tmpMenu->setItemChecked(menustate, true); + tmpMenu->setItemEnabled(menustate, info->actionSupported(NET::ActionMax)); + + menustate = tmpMenu->insertItem(i18n("&Shade"), this, SLOT(shadeApp())); + if (info->state() & NET::Shaded) tmpMenu->setItemChecked(menustate, true); + tmpMenu->setItemEnabled(menustate, info->actionSupported(NET::ActionShade)); + + //menustate = tmpMenu->insertItem(i18n("&Restore"), this, SLOT(restApp())); + //if (!info->isMinimized() && info->state() != NET::Max) tmpMenu->setItemEnabled(menustate, false); + + tmpMenu->insertItem(SmallIcon("forward"), i18n("&Move to Desktop"), deskpopup); + tmpMenu->insertSeparator(); + tmpMenu->insertItem(SmallIcon("fileclose"), i18n("&Close"), this, SLOT(closeApp())); +} + +void KoolDock::updTaskList() +{ + + if (!fShowNav) return; + + desks.setAutoDelete (true); + + //tasklist; menu to access every window throught navigation menu + int j, index, incr, nDesks; + KWin::WindowInfo tmpinfo; + + nDesks=KWin::numberOfDesktops(); + + tasklist->clear(); + desks.clear(); + + for(index=0; index<=nDesks; index++) + { + desks.append (new dInfo); + } + + KWin::WindowInfo info; + QValueList<WId>::ConstIterator it; + for (it=wm->windows().begin(); it != wm->windows().end(); ++it) + { + tmpinfo=KWin::windowInfo(*it); + + const int SUPPORTED_WINDOW_TYPES = NET::NormalMask | NET::DesktopMask | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask; + QString name = tmpinfo.visibleName(); + + if (tmpinfo.windowType(SUPPORTED_WINDOW_TYPES) == NET::Normal || tmpinfo.windowType(SUPPORTED_WINDOW_TYPES) == NET::Override || tmpinfo.windowType(SUPPORTED_WINDOW_TYPES) == NET::Dialog || tmpinfo.windowType(SUPPORTED_WINDOW_TYPES) == NET::Unknown) + { + if ((tmpinfo.state() & NET::SkipTaskbar) == 0) + { + if (ignored(tmpinfo.name()) == false) + { + index=tmpinfo.desktop(); + if (index==-1) index=0; + + incr=0; + + if (!desks.at(index)->gBool()) + { + desks.current()->sBool(true); + if (index==0) + {tasklist->insertTitle(i18n("All desktops"),-1,desks.current()->gInt());} + else + {tasklist->insertTitle(i18n("Desktop %1").arg(index),-1,desks.current()->gInt());} + incr++; + } + tasklist->insertItem(KWin::icon(*it), tmpinfo.visibleName(), *it, desks.current()->gInt()+incr); + incr++; + for(j=index; j<=nDesks; j++) + { + desks.at(j)->inc(incr); + } + } + } + } + } +} + +void KoolDock::addToTaskList(WId id) +{ + int i; + Item *item; + int index, rIndex, j, incr=0, decr=0; + KWin::WindowInfo tmpinfo; + tmpinfo=KWin::windowInfo(id); + nDesks=KWin::numberOfDesktops(); + rIndex = tmpinfo.desktop(); + + const int SUPPORTED_WINDOW_TYPES = NET::NormalMask | NET::DesktopMask | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask | NET::OverrideMask | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask; + QString name = tmpinfo.visibleName(); + + if (tmpinfo.windowType(SUPPORTED_WINDOW_TYPES) == NET::Normal || tmpinfo.windowType(SUPPORTED_WINDOW_TYPES) == NET::Override || tmpinfo.windowType(SUPPORTED_WINDOW_TYPES) == NET::Dialog || tmpinfo.windowType(SUPPORTED_WINDOW_TYPES) == NET::Unknown) + { + if ((tmpinfo.state() & NET::SkipTaskbar) == 0) + { + if (ignored(tmpinfo.name()) == false) + { + + if (rIndex==0) return; + index=rIndex; + if (index==-1) index=0; + + if (!desks.at(index)->gBool()) + { + desks.at(index)->sBool(true); + if (index==0) + {tasklist->insertTitle(i18n("All desktops"),-1,desks.at(index)->gInt());} + else + {tasklist->insertTitle(i18n("Desktop %1").arg(index),-1,desks.at(index)->gInt());} + incr++; + } + else + { + if (fShowTaskbar) + { + for (i=witems.count(), item = witems.at(i); item; i--, item = witems.prev()) + { + if (item->getId()==id) break; + if (item->info.desktop()==rIndex) decr++; + } + } + } + tasklist->insertItem(KWin::icon(id), tmpinfo.visibleName(), id, desks.at(index)->gInt()+incr-decr); + incr++; + for(j=index; j<=nDesks; j++) + { + desks.at(j)->inc(incr); + } + } + } + } +} + +void KoolDock::rmFromTaskList(WId id) +{ + nDesks=KWin::numberOfDesktops(); + int i, j, k, dec=0; + int index=0; + i=tasklist->indexOf(id); + index=tasklist->idAt(i); + if (index==id) + { + tasklist->removeItem(id); + dec--; + for(j=0; j<=nDesks; j++) + { + if (desks.at(j)->gBool() && desks.at(j)->gInt()>=i+1) + { + if (desks.at(j)->gInt()==i+1) + { + if (tasklist->text(tasklist->idAt(i-1)).isNull() && tasklist->text(tasklist->idAt(i)).isNull()) + { + dec--; + desks.at(j)->sBool(false); + tasklist->removeItemAt(i-1); + } + } + for(k=j; k<=nDesks; k++) + { + desks.at(k)->inc(dec); + } + break; + } + } + } +} + diff --git a/src/kooldock.h b/src/kooldock.h new file mode 100644 index 0000000..af196bd --- /dev/null +++ b/src/kooldock.h @@ -0,0 +1,364 @@ +/*************************************************************************** + kooldock.h - description + ------------------- + begin : Tue Jun 10 22:18:34 BST 2003 + copyright : (C) 2003 by KoolDock team + email : + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 KOOLDOCK_H +#define KOOLDOCK_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <kapp.h> +#include <kpopupmenu.h> +#include <kwinmodule.h> +#include <kaboutdialog.h> +#include <krootpixmap.h> +#include <kpixmap.h> +#include <kurifilter.h> + +#include <qwidget.h> +#include <qptrlist.h> +#include <qtimer.h> +#include <qcolor.h> + +#include <netwm.h> + +#include <qdatetime.h> + +#include "item.h" +#include "xosd.h" +#include "clip.h" +#include "setupdialogprg.h" +#include "dinfo.h" + +const int MAX_ICONS = 150; // max number of icons +const int UPDATE_DIST = 1; // update when x - last_x <= UPDATE_DIST +const int DEF_SMALL_SIZE = 32; // default small icon size +const int DEF_BIG_SIZE = 90; // default big icon size +const int DEF_DOCK_OPACITY = 50; // default dock opacity +const int DEF_PRIORITY = 5; +const int DEF_HIDDEN = 1; // default hidden priority +const int ANIM_TOTAL_STEP = 6; // not in use yet + +const int SPACE_W = 1; // space between quick launchers and tasks (the seperator) + +const int ON_CHANGE_ANIM_INTERVAL = 50; // animation's interval + +/** KoolDock is the base class of the project */ +class KoolDock : public QWidget +{ + Q_OBJECT + public: + /** construtor */ + KoolDock(QWidget* parent=0, const char *name=0); + /** destructor */ + ~KoolDock(); + + //static bool writeIgnoreList(QString text); + void setMainPath(QString path); + void setArgs(QString param); + clip *clipw; + + private: + QTime *perf; + // configuration variables + int fShowTaskbar; // show-taskbar flag + int fMinimizedOnly; // show only minimized icons flag + int fShowNotification; // show-notification flag + int fShowBorders; // show-borders flag + int fShowKMenu; // show the K menu + int fUseKBFX; + int fPriority; // "nice" priority + int fMouseTimer; // Mouse timer interval + int fClipping; //window area clippig + int fClipIcons; //icon area clipping + long int fzoomSpeed, zoomStep, zoomStepB, zoomStepS, zoomVal; //speed of show/hide animation + int zoomTicksB, zoomTicksS; //counts timer ticks + int neededTicksB,neededTicksS; //sets how many ticks is necessary to calculate new speed + bool fSpeed; + QColor borderColor; + int fHidden; // hidden dockbar + int fStayBelow; + int fOrientation; //bottom/left/top/right + int fHideOnClick; + int fSteppy; + int fShowFrames; // frames to show the dock "growing from bottom" + int fGrowFrames; // frames to grow the icon when the mouse is over it. + int fHighLightTime; + bool fFirstRun; + bool fShowShot; + bool fGrouping; + int fRepaintInterval; + int xinerama; //whether we want xinerama + int hideTimer; //user define time to show dock + int Solid; //whether using backgroung Image or not (for preference controls) + int fShowNav; //whether we want the navigation menu (clock + desktop chooser) in kooldocks main menu + int numSystray; //for systray control + int fSystray; //whether we want the systray or not + int fCurrent; //whether to only show windows on current desktop + int oldDesktop; //number of previous desktop + bool firstTime; //to control certain things + QString curTheme; //for the background theme (to preserve changes) + int leftRes; //Left monitor resolution + int XinDesiredHeight; + int XinPreviousWidth; + int fpercentPos; + + bool noSet; + bool firstInit; + bool reloadIcons; + bool initialization; + int ptPart; + + bool mouseOnLauncher; + QStringList lstDrop; + bool useList; + + Atom net_system_tray_selection; + Atom net_system_tray_opcode; + + QString fLeftImg; + QString fRightImg; + QString fCenterImg; + bool fNWideBg; + bool scaleMax; + + QPixmap LeftImg; + QPixmap RightImg; + QPixmap CenterImg; + QPixmap TempScaledCenter; + QPixmap TestPix; + QImage TestIm; + + unsigned int oLeft, oRight; + + int iwSmall; + int iwBig; + int iwBig2; + + int firstX, tmpw; + int oldfirstX, oldtmpw; + int lastX; + + int dockOpacity; + QColor bgColor; + + QColor sepColor; // separator bar's color + + int Ybase; + + // normal variables + + QString progPath; + QString menuPath; + QString confFile; + QString iFilename; // right clicked item filename + QString mainPath; + QString args; + + QStringList ignoreList; + + + NETWinInfo *info; + KWinModule *wm; + SetupDialog *setupdlg; + + int Offset; + int numLaunchers; // number of quick launcher items + int x, y, w, h, h0, h1, w0, x0, w1, x1; + int rx, ry, rw, rh, uw; //current position + int ix, iy, iDist, iSpace; + int dw, dh, rdh; + int funcW, funcH; + int ii_first, ii_last; + int soffset, eoffset; //used in icon positioning + int sx, sw; + int adjust; + int fAmount; + int last_mx; + int last_ncx; + + QPtrList<Item> items;//currently visible items + QPtrList<Item> witems;//all windows on all desktops + int iSize[MAX_ICONS + 1];//icon sizes + int cx[MAX_ICONS + 1];//positions of small icons + int cur_cx[MAX_ICONS + 1];//positions of visible icons + QPixmap offscr;//drawing buffer + + KRootPixmap *rootpix; + KPixmap bottomBg; + KPixmap bottomBgf; + QPixmap topBg; + + KAboutDialog *aboutDlg; + QTimer *mkbigTimer; //zoom animation timers + QTimer *mksmallTimer; + QTimer *mTimer; //mouse move emulator (can't use normal event instead) + QTimer *onChangeTimer; // used when a window has changed and we need to notify user + QTimer *trackTimer; //checks whether mouse touches screen edge + + int animStep; // animation step, not in use yet + int iOnClick; // index of the quick launcher being clicked + WId cId; // id of the application (used in the right click menu over the taskbar) + QString cClass; + WId CurrentFocus; + int onChangeAnimStep; + KPopupMenu *deskpopup; + KPopupMenu *appMenu; + KPopupMenu *godesk; + KPopupMenu *tasklist; + KPopupMenu *popup; + KPopupMenu *advMenu; + int menuCount, currMenu; + bool allApps; + QPtrList<KPopupMenu> popups; + bool iGroup; + int dIndex, nDesks; + QPtrList<dInfo> desks; + + bool fExpanded; + bool track2active; + /*Xosd Section */ + QString nom; + QString aux; + //xosd *osd; + int xosd_st; + int showNames; + int fCleaner; + int xosdShadowOffset; + QString xosdFont; + QString xosdColor; + QString xosdShadowColor; + bool xosdBold; + bool xosdItalic; + int xosdSize; + KURIFilterData *_filterData; + xosd *xosdw; + int animValue; + int animState; + + void run(QString cmd); + int func(int x); + int func2(int x); + void doUpdateGeometry(); + bool addTask(WId id, int iFound=-1); + bool rmTask(WId id, int iFound=-1); + void rmwTask(int iFound); + bool addwTask(WId id); + void movetoback(WId id); + void loadConf(); + void loadIgnore(); + void saveConf(); + void loadMenu(); + void addWindows(); + int itemFromPoint(int x); + int xFromIndex(int i); + void createMenu(WId id, KPopupMenu* tmpMenu, KWin::WindowInfo* info); + void updTaskList(); + void addToTaskList(WId id); + void rmFromTaskList(WId id); + bool doRepaint; + int currXPos; + int lastXPos; + int lastYPos; + void init1(); + void init2(); + + protected: + void paintEvent(QPaintEvent *); + void mousePressEvent( QMouseEvent * ); + void mMoveEvent( int ex, int ey); + void mPress( int mx, int my, ButtonState srcButton); + void wheelEvent(QWheelEvent *); + void enterEvent(QEvent*); + void onleaveEvent(QEvent*); + void mksmallTimerstop(); + void dragMoveEvent(QDragMoveEvent* event); + void dropEvent(QDropEvent* event); + + public slots: + void edit(); + void editPref(); + void about(); + void windowAdded(WId id); + void windowRemoved(WId id); + void windowChanged(WId id, unsigned int properties); + void activeWindowChanged(WId id); + void workAreaChanged(); + void currentDesktopChanged(int); + void onChangeTimerTicked(); + void updateBackground(const QPixmap&); + void moveApp(); + void resizeApp(); + void minApp(); + void maxApp(); + void restApp(); + void minAllApps(); + void maxAllApps(); + void restAllApps(); + void closeAllApps(); + void shadeApp(); + void activateApp(); + void closeApp(); + void editItem(); + void removeItem(); + void sendToDesktop(int); + void goToDesktop(int); + void goToWindow(int); + /* Systray support */ + void systemTrayWindowAdded(WId id); + void systemTrayWindowRemoved(WId id); + void aboutToShow(); + void aboutToHide(); + + void toggleAlwaysOnTop(); + void toggleKeptBelowOthers(); + void toggleFullScreen(); + + static void addFile(QString filename, QString iconname, QString execname, QString name, bool notify, bool terminal, bool tclose, bool, QString); + bool ignored(QString appname); + + #ifdef _ENABLE_DEBUG + static void debug(QString message); + #endif + #ifndef _ENABLE_DEBUG + static void debug(QString); + #endif + void mkbigTimerDo(); + void mksmallTimerDo(); + void endProg(); + void mTimerEnd(); + void trackTimerEnd(); + void trackTimer2End(); + void restart(); + void reload(); + void chkRestart(); + void refreshBackground(); + void unhighlight(); + void move2(int nx, int ny); + void resize2(int nw, int nh); + void getBottomBG(); + void getTopBG(); + void setDesktopIconsArea(int, int, int, int); + void setDockAbove(); + void setDockBelow(); + void menuX(int num); + void menuShow(); + void pTest(); +}; + +#endif diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..411fad6 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,114 @@ +/*************************************************************************** + main.cpp - description + ------------------- + begin : Thu Jun 19 14:43:55 BST 2003 + copyright : (C) 2003 by KoolDock team + email : + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 <kcmdlineargs.h> +#include <kaboutdata.h> +#include <klocale.h> +#include <kcrash.h> +#include <kdebug.h> +#include <kuniqueapplication.h> + +#include <stdio.h> +#include <stdlib.h> +#include <kmessagebox.h> + +#include "kooldock.h" + +#define KOOLDOCK_VERSION "0.4.7" +QString argv0; + +#ifndef _ENABLE_DEBUG +extern "C" +{ + static void crashHandler(int /*signal*/) + { + char cmd[1024]; + fprintf(stderr, "kooldock: crashHandler called\n"); + snprintf(cmd, 1025, "%s &", argv0.ascii()); + system(cmd); // try to restart according to argv[0] + } +} +#endif + +static const char *description = I18N_NOOP("<center><b>KoolDock</b></center>A Kool Dock for KDE<br><br>KoolDock is based upon the original work of Dang Viet Dung, Ksmoothdock 2.1<br><br>"); + +static KCmdLineOptions options[] = +{ + { "o", 0, 0 }, + { "options", I18N_NOOP("Show configuration window on start"), 0 }, + { "k", 0, 0 }, + { "kill", I18N_NOOP("Kills all processes called Kooldock"), 0 }, + {0, 0, 0} +}; + +int main(int argc, char *argv[]) +{ + argv0=QString("%1").arg(argv[0]); + + KAboutData aboutData( "kooldock", I18N_NOOP("KoolDock"), + KOOLDOCK_VERSION, description, KAboutData::License_GPL, + "(c) 2003, 2006 - KoolDock team", 0, "http://ktown.kde.cl/kooldock", "kooldock-devel@lists.kde.cl"); + aboutData.addAuthor("Matias Fernandez",0, "radix@kde.cl"); + aboutData.addAuthor("Francisco Guidi",0, "francisco@guidi.com", "http://francisco.guidi.com"); + aboutData.addAuthor("Blase Stanek", 0, "bisiek@op.pl"); + aboutData.addCredit("Mauricio Bahamonde", I18N_NOOP("Project Webmaster"), "elkrammer@kde.cl", "http://ktown.kde.cl/~elkrammer/"); + aboutData.addCredit("Sebastian Sariego Benitez", I18N_NOOP("Icon and artwork"), "segfault@powers.cl", "http://segfault.kde.cl"); + aboutData.setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS\nYour names"), I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails")); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. + + #ifdef _ENABLE_DEBUG + KApplication::addCmdLineOptions(); + #endif + #ifndef _ENABLE_DEBUG + KUniqueApplication::addCmdLineOptions(); + #endif + if (QString("%1").arg(argv[1])=="-kill" || QString("%1").arg(argv[1])=="-k") + { + system("killall kooldock"); + exit(0); + } + + #ifndef _ENABLE_DEBUG + if (!KUniqueApplication::start()) + { + fprintf(stderr, "Kooldock is already running!\n"); + exit(0); + } + #endif + + #ifndef _ENABLE_DEBUG + KUniqueApplication a; + #endif + #ifdef _ENABLE_DEBUG + KApplication a; + #endif + KoolDock *kooldock = new KoolDock(); + a.setMainWidget(kooldock); + + #ifndef _ENABLE_DEBUG + if(KCrash::crashHandler()!=0) + { + kdDebug(0) << "Installing crash handler" << endl; + KCrash::setEmergencySaveFunction(crashHandler); // Try to restart on crash + } + #endif + + kooldock->setMainPath(argv0); + kooldock->setArgs(QString("%1").arg(argv[1])); + return a.exec(); +} diff --git a/src/setupdialog.ui b/src/setupdialog.ui new file mode 100644 index 0000000..f23cbaf --- /dev/null +++ b/src/setupdialog.ui @@ -0,0 +1,1990 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>SetupDialog</class> +<widget class="QDialog"> + <property name="name"> + <cstring>SetupDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>545</width> + <height>475</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>1024</width> + <height>768</height> + </size> + </property> + <property name="baseSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="caption"> + <string>KoolDock Configuration</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <property name="modal"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string></string> + </property> + <property name="whatsThis" stdset="0"> + <string></string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton" row="1" column="3"> + <property name="name"> + <cstring>buttonCancel</cstring> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + <widget class="QPushButton" row="1" column="2"> + <property name="name"> + <cstring>buttonOk</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0"> + <property name="name"> + <cstring>toReloadIcons</cstring> + </property> + <property name="maximumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>checkBox11</string> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0"> + <property name="name"> + <cstring>systray</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Enable System Tray (Experimental!)</string> + </property> + <property name="toolTip" stdset="0"> + <string>Enables KoolDock System Tray Support; it can be used instead of kicker's systray applet (its VERY experimental; do not use it unless you intend to help me get this working :P )</string> + </property> + </widget> + <widget class="QTabWidget" row="0" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>tabWidget</cstring> + </property> + <widget class="QWidget"> + <property name="name"> + <cstring>Widget2</cstring> + </property> + <attribute name="title"> + <string>General</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBox3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>General options:</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="Line" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>line15</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="Line" row="6" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>line1_3</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="Line" row="8" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>line1_3_2</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0"> + <property name="name"> + <cstring>chk1</cstring> + </property> + <property name="text"> + <string>Autohide</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Start KoolDock hidden; if the mouse is not over KoolDock it will hide</string> + </property> + </widget> + <widget class="QCheckBox" row="3" column="0"> + <property name="name"> + <cstring>chk5</cstring> + </property> + <property name="text"> + <string>Enable Taskbar</string> + </property> + <property name="toolTip" stdset="0"> + <string>Enables KoolDock taskbar; it can be used instead of Kicker's taskbar</string> + </property> + </widget> + <widget class="QCheckBox" row="4" column="0"> + <property name="name"> + <cstring>chk6</cstring> + </property> + <property name="text"> + <string>Enable Taskbar notification</string> + </property> + <property name="toolTip" stdset="0"> + <string>Window icon in KoolDock's taskbar will blink when something happens on the given application</string> + </property> + </widget> + <widget class="QCheckBox" row="5" column="0"> + <property name="name"> + <cstring>chkGrouping</cstring> + </property> + <property name="text"> + <string>Similar windows grouping</string> + </property> + <property name="toolTip" stdset="0"> + <string>Enables grouping similar task icons into one icon.</string> + </property> + </widget> + <widget class="QCheckBox" row="7" column="0"> + <property name="name"> + <cstring>chk7</cstring> + </property> + <property name="text"> + <string>Show K Menu</string> + </property> + <property name="toolTip" stdset="0"> + <string>Shows the KDE Menu in KoolDock's launcher.</string> + </property> + </widget> + <widget class="QCheckBox" row="9" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>Steppy</cstring> + </property> + <property name="text"> + <string>Don't scroll while mouse is on the same icon</string> + </property> + <property name="toolTip" stdset="0"> + <string>Makes the scrolling not smooth, but automatically centered on current icon.</string> + </property> + </widget> + <widget class="QCheckBox" row="10" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>nav</cstring> + </property> + <property name="text"> + <string>Navigation Menu</string> + </property> + <property name="toolTip" stdset="0"> + <string>Adds a clock into the Main Menu and a virtual desktop navigator.</string> + </property> + </widget> + <widget class="QCheckBox" row="7" column="1"> + <property name="name"> + <cstring>chkUseKBFX</cstring> + </property> + <property name="text"> + <string>Use KBFX</string> + </property> + <property name="toolTip" stdset="0"> + <string>Makes that KoolDock don't use KMenu, but uses alternative KBFX menu (widget is necessary).</string> + </property> + </widget> + <widget class="QCheckBox" row="5" column="1"> + <property name="name"> + <cstring>cbMinimizedOnly</cstring> + </property> + <property name="text"> + <string>Show only minimized</string> + </property> + <property name="toolTip" stdset="0"> + <string>That makes kooldock shows only the minimized application icons, and hides the other.</string> + </property> + </widget> + <widget class="QCheckBox" row="4" column="1"> + <property name="name"> + <cstring>chkSshot</cstring> + </property> + <property name="text"> + <string>Screenshot of minimized windows</string> + </property> + <property name="toolTip" stdset="0"> + <string>When a window is minimized a screenshot of the application will be use as an icon in KoolDock's Taskbar.</string> + </property> + </widget> + <widget class="QCheckBox" row="3" column="1"> + <property name="name"> + <cstring>currentDesk</cstring> + </property> + <property name="text"> + <string>Only Manage Current Desktop</string> + </property> + <property name="toolTip" stdset="0"> + <string>Only show in KoolDock's taskbar windows in the current desktop</string> + </property> + </widget> + <widget class="QCheckBox" row="0" column="1"> + <property name="name"> + <cstring>hideOnClick</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Hide on click</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Hide KoolDock after clicking on a Launcher or Window icon.</string> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>cbStayBelow</cstring> + </property> + <property name="text"> + <string>Stay below windows when not used</string> + </property> + <property name="toolTip" stdset="0"> + <string>Sends KoolDock before other windows, when it's collapsed.</string> + </property> + </widget> + </grid> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>Icon text</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBox10</cstring> + </property> + <property name="title"> + <string>Icon text</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel1_4</cstring> + </property> + <property name="text"> + <string>Text font:</string> + </property> + </widget> + <widget class="KFontCombo" row="2" column="1"> + <property name="name"> + <cstring>xosdFont</cstring> + </property> + </widget> + <widget class="QLabel" row="5" column="0"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="text"> + <string>Shadow offset:</string> + </property> + </widget> + <widget class="QSpinBox" row="5" column="1"> + <property name="name"> + <cstring>spinBox2</cstring> + </property> + <property name="maxValue"> + <number>4</number> + </property> + <property name="minValue"> + <number>0</number> + </property> + </widget> + <widget class="QLabel" row="4" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Text color:</string> + </property> + </widget> + <widget class="KColorCombo" row="4" column="1"> + <property name="name"> + <cstring>kColorCombo1</cstring> + </property> + </widget> + <widget class="QSpinBox" row="3" column="1"> + <property name="name"> + <cstring>xosdSize</cstring> + </property> + <property name="maxValue"> + <number>99</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel1_2_2</cstring> + </property> + <property name="text"> + <string>Font size:</string> + </property> + </widget> + <widget class="KColorCombo" row="6" column="1"> + <property name="name"> + <cstring>kColorCombo_shadow</cstring> + </property> + </widget> + <widget class="QLabel" row="6" column="0"> + <property name="name"> + <cstring>textLabel1_8</cstring> + </property> + <property name="text"> + <string>Shadow color:</string> + </property> + </widget> + <widget class="Line" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>line9</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QCheckBox" row="7" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>cbCleaner</cstring> + </property> + <property name="text"> + <string>Cleaner text (bigger memory and CPU usage)</string> + </property> + </widget> + <widget class="QFrame" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>frame3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <property name="lineWidth"> + <number>0</number> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox" row="0" column="2"> + <property name="name"> + <cstring>xosdBold</cstring> + </property> + <property name="text"> + <string>Bold</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + <spacer row="0" column="1"> + <property name="name"> + <cstring>spacer10</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>16</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="QCheckBox" row="0" column="0"> + <property name="name"> + <cstring>chk2</cstring> + </property> + <property name="text"> + <string>Show text over icons</string> + </property> + <property name="toolTip" stdset="0"> + <string>Moving the mouse over KoolDock's launcher or TaskBar will show the window/launcher name on the screen</string> + </property> + </widget> + <spacer row="0" column="3"> + <property name="name"> + <cstring>spacer11</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>16</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QCheckBox" row="0" column="4"> + <property name="name"> + <cstring>xosdItalic</cstring> + </property> + <property name="text"> + <string>Italic</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + <spacer row="0" column="5"> + <property name="name"> + <cstring>spacer12</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>81</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + </grid> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>Sizes</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBox9</cstring> + </property> + <property name="title"> + <string>Sizes</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Small icon size:</string> + </property> + </widget> + <widget class="QSpinBox" row="0" column="1"> + <property name="name"> + <cstring>iwSmall</cstring> + </property> + </widget> + <widget class="QLabel" row="0" column="2"> + <property name="name"> + <cstring>textLabel2_2</cstring> + </property> + <property name="text"> + <string>Big icon size:</string> + </property> + </widget> + <widget class="QSpinBox" row="0" column="3"> + <property name="name"> + <cstring>iwBig</cstring> + </property> + <property name="maxValue"> + <number>160</number> + </property> + </widget> + <widget class="QLabel" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel1_13</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Amount of big icons:</string> + </property> + </widget> + <widget class="QSpinBox" row="1" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>fAmount</cstring> + </property> + <property name="maxValue"> + <number>10</number> + </property> + <property name="minValue"> + <number>4</number> + </property> + <property name="toolTip" stdset="0"> + <string>This box determines amout of zoomed icons.</string> + </property> + </widget> + <widget class="QLabel" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel1_6</cstring> + </property> + <property name="text"> + <string>Space between icons</string> + </property> + </widget> + <widget class="QSpinBox" row="2" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>sbSpace</cstring> + </property> + </widget> + </grid> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>Application List</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel1_3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Drag an application to add it or</string> + </property> + </widget> + <widget class="QPushButton" row="0" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>buttonadd</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Manually &add Application</string> + </property> + <property name="accel"> + <string>Alt+A</string> + </property> + <property name="toolTip" stdset="0"> + <string>Click here to manually add an application to the Launcher</string> + </property> + </widget> + <widget class="KIconView" row="1" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>applist</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="mode"> + <enum>Select</enum> + </property> + <property name="toolTip" stdset="0"> + <string>Drag and Drop here any executable or desktop file for which you want an entry in KoolDock's Launcher</string> + </property> + </widget> + <widget class="QPushButton" row="2" column="0"> + <property name="name"> + <cstring>mLeft</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Move Left</string> + </property> + <property name="toolTip" stdset="0"> + <string>Moves selected item left</string> + </property> + </widget> + <widget class="QPushButton" row="2" column="3"> + <property name="name"> + <cstring>mRight</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Move Right</string> + </property> + <property name="toolTip" stdset="0"> + <string>Moves selected item right</string> + </property> + </widget> + <spacer row="2" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>spacer7</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>181</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="QLabel" row="3" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>textLabel1_5</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Right click opens the icon menu.</string> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>Ignore list</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton" row="0" column="0"> + <property name="name"> + <cstring>grabWin</cstring> + </property> + <property name="text"> + <string>Grab Window</string> + </property> + <property name="toolTip" stdset="0"> + <string>Click here to start grabbing windows names; click Add for each window you click on</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1_7</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Click "Grab Window" and click over a Window, then click "Add" to append it to +the ignore list; you may also manually type or edit the window's name in the +box below. To stop grabbing just click "Grabbing...", "Ok" or "Cancel".</string> + </property> + </widget> + <widget class="KEditListBox" row="2" column="0"> + <property name="name"> + <cstring>ignoreBox</cstring> + </property> + <property name="title"> + <string></string> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string></string> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>Background</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="1" column="0"> + <property name="name"> + <cstring>chkSolid</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Solid Background:</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel1_3_2_2</cstring> + </property> + <property name="text"> + <string>Border color:</string> + </property> + </widget> + <widget class="KColorCombo" row="3" column="1"> + <property name="name"> + <cstring>kColorCombo3</cstring> + </property> + </widget> + <widget class="QLabel" row="4" column="0"> + <property name="name"> + <cstring>textLabel1_3_3</cstring> + </property> + <property name="text"> + <string>Dock opacity:</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1_3_2</cstring> + </property> + <property name="text"> + <string>Background color:</string> + </property> + </widget> + <widget class="KColorCombo" row="1" column="1"> + <property name="name"> + <cstring>kColorCombo2</cstring> + </property> + </widget> + <widget class="QCheckBox" row="2" column="0"> + <property name="name"> + <cstring>chk4</cstring> + </property> + <property name="text"> + <string>Show borders</string> + </property> + <property name="toolTip" stdset="0"> + <string>When using a Solid Background you may tell KoolDock to draw its borders (rectangle)</string> + </property> + </widget> + <widget class="QSpinBox" row="4" column="1"> + <property name="name"> + <cstring>spinBox1</cstring> + </property> + <property name="specialValueText"> + <string></string> + </property> + <property name="maxValue"> + <number>100</number> + </property> + <property name="toolTip" stdset="0"> + <string>Solid background level of transparency (0 means fully transparent)</string> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBox6</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="lineWidth"> + <number>1</number> + </property> + <property name="midLineWidth"> + <number>0</number> + </property> + <property name="title"> + <string>TaskBar Separator</string> + </property> + <property name="flat"> + <bool>false</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KColorCombo" row="0" column="1"> + <property name="name"> + <cstring>kColorCombo4</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip" stdset="0"> + <string>The separator is a line drawed between KoolDock's Launcher and Taskbar</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1_3_2_2_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Separator color:</string> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="2" column="0"> + <property name="name"> + <cstring>chkImg</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Background Theme:</string> + </property> + <property name="flat"> + <bool>false</bool> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>nWideBg</cstring> + </property> + <property name="text"> + <string>Don't allow wider background than screen</string> + </property> + <property name="toolTip" stdset="0"> + <string>Mkaes that the background ends don't go over the screen edges.</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1_9</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Background Theme:</string> + </property> + </widget> + <widget class="QComboBox" row="1" column="1"> + <property name="name"> + <cstring>theme</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + <widget class="QButtonGroup" row="3" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>buttonGroup2_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <property name="lineWidth"> + <number>0</number> + </property> + <property name="title"> + <string></string> + </property> + <property name="flat"> + <bool>false</bool> + </property> + <property name="checkable"> + <bool>false</bool> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <property name="exclusive"> + <bool>false</bool> + </property> + <property name="radioButtonExclusive"> + <bool>true</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton" row="0" column="0"> + <property name="name"> + <cstring>opScale1</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Corner scale: free</string> + </property> + </widget> + <spacer row="0" column="1"> + <property name="name"> + <cstring>spacer8</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>146</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QRadioButton" row="0" column="2"> + <property name="name"> + <cstring>opScale2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Corner scale: min</string> + </property> + </widget> + <spacer row="0" column="3"> + <property name="name"> + <cstring>spacer9</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>21</height> + </size> + </property> + </spacer> + </grid> + </widget> + </grid> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>Placement</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBox5</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>3</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Window placement</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1_11</cstring> + </property> + <property name="text"> + <string>Window position on edge (%):</string> + </property> + </widget> + <widget class="QSpinBox" row="0" column="1"> + <property name="name"> + <cstring>percentPos</cstring> + </property> + <property name="maxValue"> + <number>100</number> + </property> + <property name="lineStep"> + <number>5</number> + </property> + <property name="value"> + <number>50</number> + </property> + <property name="toolTip" stdset="0"> + <string>Determines the position of expanded KoolDock's window on the selected screen edge.</string> + </property> + </widget> + <widget class="QCheckBox" row="2" column="0"> + <property name="name"> + <cstring>xrma</cstring> + </property> + <property name="text"> + <string>Xinerama Support</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>If you are using xinerama you should enable this option for proper behaviour.</string> + </property> + </widget> + <widget class="Line" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>line4</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel1_10</cstring> + </property> + <property name="text"> + <string>Desired Monitor Width</string> + </property> + </widget> + <widget class="QLabel" row="4" column="0"> + <property name="name"> + <cstring>textLabel1_12</cstring> + </property> + <property name="text"> + <string>Desired Monitor Height</string> + </property> + </widget> + <widget class="QSpinBox" row="3" column="1"> + <property name="name"> + <cstring>SleftRes</cstring> + </property> + <property name="maxValue"> + <number>32768</number> + </property> + <property name="minValue"> + <number>0</number> + </property> + <property name="value"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>Width of monitor on which KoolDock should be shown.</string> + </property> + </widget> + <widget class="QSpinBox" row="4" column="1"> + <property name="name"> + <cstring>SHeight</cstring> + </property> + <property name="maxValue"> + <number>32767</number> + </property> + <property name="minValue"> + <number>200</number> + </property> + <property name="toolTip" stdset="0"> + <string>Height of monitor on which kooldock should be shown.</string> + </property> + </widget> + <widget class="QSpinBox" row="5" column="1"> + <property name="name"> + <cstring>PWidth</cstring> + </property> + <property name="maxValue"> + <number>32768</number> + </property> + <property name="toolTip" stdset="0"> + <string>Sum of widths of monitors before the desired one.</string> + </property> + </widget> + <widget class="QLabel" row="5" column="0"> + <property name="name"> + <cstring>textLabel2_4</cstring> + </property> + <property name="text"> + <string>Previous Monitors Width</string> + </property> + </widget> + <widget class="QLabel" row="6" column="0"> + <property name="name"> + <cstring>textLabel2_5</cstring> + </property> + <property name="text"> + <string>Window position:</string> + </property> + </widget> + <widget class="QButtonGroup" row="6" column="1"> + <property name="name"> + <cstring>buttonGroup2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>GroupBoxPanel</enum> + </property> + <property name="title"> + <string></string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer row="0" column="2"> + <property name="name"> + <cstring>spacer3</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>31</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="QRadioButton" row="1" column="0"> + <property name="name"> + <cstring>op3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="autoMask"> + <bool>false</bool> + </property> + <property name="text"> + <string>Left</string> + </property> + <property name="toolTip" stdset="0"> + <string>Makes that KoolDock's window will appear on left screen edge.</string> + </property> + </widget> + <widget class="QRadioButton" row="1" column="2"> + <property name="name"> + <cstring>op1</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="autoMask"> + <bool>false</bool> + </property> + <property name="text"> + <string>Right</string> + </property> + <property name="toolTip" stdset="0"> + <string>Makes that KoolDock's window will appear on right screen edge.</string> + </property> + </widget> + <spacer row="1" column="1"> + <property name="name"> + <cstring>spacer6</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>41</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="2" column="2"> + <property name="name"> + <cstring>spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>21</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="QRadioButton" row="0" column="1"> + <property name="name"> + <cstring>op2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="autoMask"> + <bool>false</bool> + </property> + <property name="text"> + <string>Top</string> + </property> + <property name="toolTip" stdset="0"> + <string>Makes that KoolDock's window will appear on top screen edge.</string> + </property> + </widget> + <widget class="QRadioButton" row="2" column="1"> + <property name="name"> + <cstring>op0</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="autoMask"> + <bool>false</bool> + </property> + <property name="text"> + <string>Bottom</string> + </property> + <property name="toolTip" stdset="0"> + <string>Makes that KoolDock's window will appear on bottom screen edge.</string> + </property> + </widget> + <spacer row="0" column="0"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>31</width> + <height>21</height> + </size> + </property> + </spacer> + <spacer row="2" column="0"> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>21</width> + <height>21</height> + </size> + </property> + </spacer> + </grid> + </widget> + </grid> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>Other</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBox7</cstring> + </property> + <property name="title"> + <string>CPU</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel2_3</cstring> + </property> + <property name="text"> + <string>Priority (0=max, 19=min)</string> + </property> + </widget> + <widget class="QSpinBox" row="0" column="1"> + <property name="name"> + <cstring>Priority</cstring> + </property> + <property name="maxValue"> + <number>19</number> + </property> + <property name="minValue"> + <number>0</number> + </property> + <property name="value"> + <number>5</number> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="1" column="0"> + <property name="name"> + <cstring>groupBox8</cstring> + </property> + <property name="title"> + <string>Desktop clipping</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox" row="0" column="0"> + <property name="name"> + <cstring>chClipping</cstring> + </property> + <property name="text"> + <string>Clip desktop workspace</string> + </property> + <property name="toolTip" stdset="0"> + <string>Makes desktop smaller that maximized windows don't cover KoolDock's window.</string> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0"> + <property name="name"> + <cstring>chClipIcons</cstring> + </property> + <property name="text"> + <string>Clip icon area (DCOP)</string> + </property> + <property name="toolTip" stdset="0"> + <string>Makes KDE desktop smaller, that KoolDock's window don't cover the icons.</string> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="2" column="0"> + <property name="name"> + <cstring>groupBox6_2</cstring> + </property> + <property name="title"> + <string>Speed</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>sejtanwodbycie</cstring> + </property> + <property name="text"> + <string>Zooming speed (ms)</string> + </property> + </widget> + <widget class="QSpinBox" row="0" column="1"> + <property name="name"> + <cstring>zoomSpeed</cstring> + </property> + <property name="prefix"> + <string></string> + </property> + <property name="suffix"> + <string></string> + </property> + <property name="specialValueText"> + <string></string> + </property> + <property name="wrapping"> + <bool>false</bool> + </property> + <property name="buttonSymbols"> + <enum>UpDownArrows</enum> + </property> + <property name="maxValue"> + <number>1000</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="value"> + <number>100</number> + </property> + <property name="toolTip" stdset="0"> + <string>Determines the speen of zooming animation</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1_6_2</cstring> + </property> + <property name="text"> + <string>Show after</string> + </property> + </widget> + <widget class="QSpinBox" row="1" column="1"> + <property name="name"> + <cstring>hideTimer</cstring> + </property> + <property name="suffix"> + <string>msec</string> + </property> + <property name="maxValue"> + <number>5000</number> + </property> + <property name="toolTip" stdset="0"> + <string>Time before showing KoolDock if mouse reaches bottom of the screen</string> + </property> + </widget> + <widget class="QCheckBox" row="2" column="0"> + <property name="name"> + <cstring>chkSpeed</cstring> + </property> + <property name="text"> + <string>Speed control</string> + </property> + <property name="toolTip" stdset="0"> + <string></string> + </property> + </widget> + </grid> + </widget> + </grid> + </widget> + </widget> + <spacer row="1" column="1"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>300</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="QPushButton" row="1" column="0"> + <property name="name"> + <cstring>btnApply</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Apply</string> + </property> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>applist</sender> + <signal>dropped(QDropEvent*,const QValueList<QIconDragItem>&)</signal> + <receiver>SetupDialog</receiver> + <slot>applist_dropped(QDropEvent*,const QValueList<QIconDragItem>&)</slot> + </connection> + <connection> + <sender>buttonadd</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>buttonadd_clicked()</slot> + </connection> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>configOK()</slot> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>configCancel()</slot> + </connection> + <connection> + <sender>grabWin</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>grabWin_clicked()</slot> + </connection> + <connection> + <sender>applist</sender> + <signal>contextMenuRequested(QIconViewItem*,const QPoint&)</signal> + <receiver>SetupDialog</receiver> + <slot>applist_contextMenuRequested(QIconViewItem*,const QPoint&)</slot> + </connection> + <connection> + <sender>mLeft</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>left()</slot> + </connection> + <connection> + <sender>mRight</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>right()</slot> + </connection> + <connection> + <sender>applist</sender> + <signal>clicked(QIconViewItem*,const QPoint&)</signal> + <receiver>SetupDialog</receiver> + <slot>applist_clicked(QIconViewItem*,const QPoint&)</slot> + </connection> + <connection> + <sender>xrma</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>xrma_clicked()</slot> + </connection> + <connection> + <sender>chk1</sender> + <signal>toggled(bool)</signal> + <receiver>SetupDialog</receiver> + <slot>chkHidden()</slot> + </connection> + <connection> + <sender>chk5</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>chkTask()</slot> + </connection> + <connection> + <sender>btnApply</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>configApply()</slot> + </connection> + <connection> + <sender>cbMinimizedOnly</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>iconsChanged()</slot> + </connection> + <connection> + <sender>currentDesk</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>iconsChanged()</slot> + </connection> + <connection> + <sender>chk6</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>iconsChanged()</slot> + </connection> + <connection> + <sender>chk7</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>iconsChanged()</slot> + </connection> + <connection> + <sender>iwSmall</sender> + <signal>valueChanged(int)</signal> + <receiver>SetupDialog</receiver> + <slot>iconsChanged()</slot> + </connection> + <connection> + <sender>iwBig</sender> + <signal>valueChanged(int)</signal> + <receiver>SetupDialog</receiver> + <slot>iconsChanged()</slot> + </connection> + <connection> + <sender>ignoreBox</sender> + <signal>changed()</signal> + <receiver>SetupDialog</receiver> + <slot>iconsChanged()</slot> + </connection> + <connection> + <sender>chkUseKBFX</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>iconsChanged()</slot> + </connection> + <connection> + <sender>chkGrouping</sender> + <signal>clicked()</signal> + <receiver>SetupDialog</receiver> + <slot>iconsChanged()</slot> + </connection> + <connection> + <sender>chkImg</sender> + <signal>toggled(bool)</signal> + <receiver>SetupDialog</receiver> + <slot>chkImgSlot()</slot> + </connection> + <connection> + <sender>chkSolid</sender> + <signal>toggled(bool)</signal> + <receiver>SetupDialog</receiver> + <slot>chkSolidSlot()</slot> + </connection> +</connections> +<includes> + <include location="global" impldecl="in declaration">kiconview.h</include> +</includes> +<slots> + <slot>configOK()</slot> + <slot>configCancel()</slot> + <slot>chooseFont()</slot> + <slot>SelectLeftClicked()</slot> + <slot>SelectCenterClicked()</slot> + <slot>SelectRightClicked()</slot> + <slot>applist_dropped( QDropEvent *, const QValueList<QIconDragItem> & )</slot> + <slot>applist_clicked( QIconViewItem *, const QPoint & )</slot> + <slot>buttonadd_clicked()</slot> + <slot>chk1_toggled( bool )</slot> + <slot>chkHidden( bool )</slot> + <slot>chkHidden()</slot> + <slot>buttonDefault_clicked()</slot> + <slot>configDefault()</slot> + <slot>chkFont()</slot> + <slot>chkTask()</slot> + <slot>grabWin_clicked()</slot> + <slot>applist_contextMenuRequested( QIconViewItem *, const QPoint & )</slot> + <slot>xrma_clicked()</slot> + <slot>groupBox7_destroyed( QObject * )</slot> + <slot>left()</slot> + <slot>right()</slot> + <slot>configApply()</slot> + <slot>iconsChanged()</slot> + <slot>appClear()</slot> + <slot>appFill()</slot> + <slot>chkImgSlot()</slot> + <slot>chkSolidSlot()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>kfontcombo.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>kcolorcombo.h</includehint> + <includehint>kcolorcombo.h</includehint> + <includehint>kiconview.h</includehint> + <includehint>keditlistbox.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>kcolorcombo.h</includehint> + <includehint>kcolorcombo.h</includehint> + <includehint>kcolorcombo.h</includehint> +</includehints> +</UI> diff --git a/src/setupdialogprg.cpp b/src/setupdialogprg.cpp new file mode 100644 index 0000000..e2b9c39 --- /dev/null +++ b/src/setupdialogprg.cpp @@ -0,0 +1,702 @@ +// +// C++ Implementation: setupdialogprg +// +// Description: +// +// +// Author: KoolDock team <radix@kde.cl>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include <kfiledialog.h> +#include <kimageio.h> +#include <kicondialog.h> +#include <klocale.h> +#include <ksimpleconfig.h> +#include <kmessagebox.h> +#include <kstandarddirs.h> +#include <kpushbutton.h> +#include <keditlistbox.h> +#include <klineedit.h> +#include <qlistbox.h> +#include <krun.h> + +#include <qiconview.h> +#include <qdir.h> +#include <qstringlist.h> +#include <qtabwidget.h> + +#include "setupdialog.h" +#include "setupdialogprg.h" +#include "apppropprg.h" +#include "appProp.h" +#include "kooldock.h" + +SetupDialogPrg::SetupDialogPrg(QWidget *parent, const char *name) + : SetupDialog(parent, name) +{ + //Ignore list handlers + grabbing=0; + gwm=new KWinModule(); + connect(gwm, SIGNAL(activeWindowChanged(WId)), SLOT(activeWindowChanged(WId))); + gwm->blockSignals(true); + in=ignoreBox->lineEdit(); + //Remove useless buttons from widget + up=ignoreBox->upButton(); + down=ignoreBox->downButton(); + up->hide(); + down->hide(); + //End ignore list handlers + + // some configuration variables + progPath = locateLocal("data", "kooldock"); + menuPath = progPath + QString("/menu/"); + + KConfig *config = KGlobal::config(); + config->setGroup("kooldock"); + + appdlg=new appPropPrg(); + appdlg->user->setEnabled(false); + appdlg->cuser->setChecked(false); + appdlg->terminal->setChecked(false); + appdlg->tclose->setChecked(false); + appdlg->tclose->setEnabled(false); + connect(appdlg, SIGNAL(apply()), SLOT(appRestart())); + + //Lets load the theme List + KStandardDirs sys; + QStringList bgPath = sys.findDirs("data", "kooldock/backgrounds"); + for(unsigned int i=0; i<bgPath.count();i++) + { + QDir tmpdir(bgPath[i]); + QStringList theme_tmp(tmpdir.entryList(QDir::Dirs, QDir::Name)); + //We do it like this to avoid showing "." and ".." instead of copying QDir::entryList directly into "theme" + for(unsigned int j=2; j<theme_tmp.count(); j++) theme->insertItem(theme_tmp[j]); + } +} + + +void SetupDialogPrg::appRestart() +{ + if(!appdlg) return; + iconsChanged(); + kdDebug(0) << "Refresh applist" << endl; + appClear(); + appFill(); +} + + +SetupDialogPrg::~SetupDialogPrg() +{ + if(appdlg) delete(appdlg); + if(in) delete(in); + kdDebug(0) << "Destroying..." << endl; +} + + +// Setup dialog implementation +void SetupDialogPrg::iconsChanged() +{ + toReloadIcons->setChecked(TRUE); +} +void SetupDialogPrg::configOK() +{ + this->hide(); + configApply(); +} + +void SetupDialogPrg::configApply() +{ + int fShowTaskbar=0; + int fMinimizedOnly=0; + int fShowNotification=0; + int fShowBorders=0; + int fShowKMenu=0; + int fUseKBFX=0; + int fHidden=0; + int showNames=0; + int fCleaner=0; + int fHideOnClick=0; + int fStayBelow = 0; + int fSteppy=0; + int xinerama=0; + int fhideTimer=5; + int fShowNav=0; + int fSystray=0; + int fCurrent=0; + int fPriority=0; + int fpercentPos=0; + int fOrientation=0; + int fClipping=0; + int fClipIcons=0; + int fSpeed=0; + + //Stop grabbing window + gwm->blockSignals(true); + grabbing=0; + grabWin->setText(i18n("Grab Window")); + + if (chk5->isChecked() == true) fShowTaskbar = 1; + if (cbMinimizedOnly->isChecked() == true) fMinimizedOnly = 1; + if (chk6->isChecked() == true) fShowNotification = 1; + if (chk4->isChecked() == true) fShowBorders = 1; + if (chk7->isChecked() == true) fShowKMenu = 1; + if (chkUseKBFX->isChecked() == true) fUseKBFX = 1; + if (chk1->isChecked() == true) + { + fHidden = 1; + } + fhideTimer = hideTimer->value(); + if (chk2->isChecked() == true) showNames = 1; + if (cbCleaner->isChecked() == true) fCleaner = 1; + if (hideOnClick->isChecked() == true) fHideOnClick = 1; + if (cbStayBelow->isChecked() == true) fStayBelow = 1; + if (Steppy->isChecked() == true) fSteppy = 1; + if (xrma->isChecked() == true) xinerama=1; + if (nav->isChecked()==true) fShowNav=1; + if (systray->isChecked()==true) fSystray=1; + if (currentDesk->isChecked()==true) fCurrent=1; + if (chClipping->isChecked()==true) fClipping=1; + if (chClipIcons->isChecked()==true) fClipIcons=1; + if (chkSpeed->isChecked()==true) fSpeed=1; + fPriority=Priority->value(); + fpercentPos=percentPos->value(); + + kdDebug(0) << "Saving preferences..." << endl; + KConfig *config = KGlobal::config(); + config->setGroup("kooldock"); + config->writeEntry("ShowTaskbar", fShowTaskbar); + config->writeEntry("MinimizedOnly", fMinimizedOnly); + config->writeEntry("ShowNotification", fShowNotification); + config->writeEntry("BorderColor", kColorCombo3->color().name()); + config->writeEntry("SmallIconSize", iwSmall->value()); + config->writeEntry("BigIconSize", iwBig->value()); + config->writeEntry("BigIconAmount", fAmount->value()); + config->writeEntry("iSpace", sbSpace->value()); + config->writeEntry("BackgroundColor", kColorCombo2->color().name()); + config->writeEntry("SeparatorColor", kColorCombo4->color().name()); + config->writeEntry("ShowKMenu", fShowKMenu); + config->writeEntry("KBFX", fUseKBFX); + config->writeEntry("Hidden", fHidden); + config->writeEntry("HideOnClick", fHideOnClick); + config->writeEntry("StayBelow", fStayBelow); + config->writeEntry("fSteppy", fSteppy); + config->writeEntry("Xinerama", xinerama); + config->writeEntry("nWideBg", nWideBg->isChecked()); + config->writeEntry("scaleMax", opScale2->isChecked()); + if(xinerama==1) {config->writeEntry("leftRes", SleftRes->value()); config->writeEntry("XinDesiredHeight", SHeight->value()); config->writeEntry("XinPreviousWidth", PWidth->value());} + config->writeEntry("hideTimer", fhideTimer); + config->writeEntry("Navigator", fShowNav); + config->writeEntry("Systray", fSystray); + config->writeEntry("currentDesktop", fCurrent); + + config->writeEntry("Priority", fPriority); + config->writeEntry("Clipping", fClipping); + config->writeEntry("ClipIconArea", fClipIcons); + config->writeEntry("percentPos", fpercentPos); + if (op1->isChecked()) fOrientation=1; + if (op2->isChecked()) fOrientation=2; + if (op3->isChecked()) fOrientation=3; + config->writeEntry("fOrientation", fOrientation); + config->writeEntry("zoomSpeed", zoomSpeed->value()); + config->writeEntry("speedControl", fSpeed); + + // kosd config + config->writeEntry("showNames", showNames); + config->writeEntry("Cleaner", fCleaner); + config->writeEntry("xosdFont", xosdFont->currentText()); + config->writeEntry("xosdColor", kColorCombo1->color().name()); + config->writeEntry("xosdShadowColor", kColorCombo_shadow->color().name()); + config->writeEntry("xosdShadowOffset", spinBox2->value()); + config->writeEntry("xosdSize", xosdSize->value()); + if (xosdBold->isChecked()) + { + config->writeEntry("xosdBold", 1); + } + else + { + config->writeEntry("xosdBold", 0); + } + if (xosdItalic->isChecked()) + { + config->writeEntry("xosdItalic", 1); + } + else + { + config->writeEntry("xosdItalic", 0); + } + + config->writeEntry("ShowSShot", chkSshot->isChecked()); + config->writeEntry("iconGrouping", chkGrouping->isChecked()); + + // save background configurations + if (chkImg->isChecked()) + { + //Lets find exactly where the selected theme is + KStandardDirs sys; + QString theme_dir="kooldock/backgrounds/"+theme->currentText(); + QStringList bgPath = sys.findDirs("data", theme_dir); + + //Lets set the images and write the config + QString LeftImg=(QString)bgPath[0]+"background-left.png"; + QString CenterImg=(QString)bgPath[0]+"background-center.png"; + QString RightImg=(QString)bgPath[0]+"background-right.png"; + + // background image enabled + config->writeEntry("Solid", 0); + config->writeEntry("Theme", theme->currentText()); + config->writeEntry("LeftImg", LeftImg); + config->writeEntry("RightImg", RightImg); + config->writeEntry("CenterImg", CenterImg); + config->writeEntry("ShowBorders", 0); + config->writeEntry("DockOpacity", 0); + } + else + { + // background image disabled + config->writeEntry("Solid", 1); + config->writeEntry("Theme", ""); + config->writeEntry("LeftImg", ""); + config->writeEntry("RightImg", ""); + config->writeEntry("CenterImg", ""); + config->writeEntry("ShowBorders", fShowBorders); + config->writeEntry("DockOpacity", spinBox1->value()); + } + + config->sync(); + + // write ignore list to file + QString progPath = locateLocal("data", "kooldock"); + QString menuPath = progPath + QString("/menu/"); + filepath = QString(progPath + "/ignorelist.conf"); + if(ignoreBox->count()>0) + { + QFile out(filepath); + if (out.open(IO_WriteOnly)) + { + QTextStream out_s(&out); + for(int i=0; i<ignoreBox->count(); i++) + { + out_s << ignoreBox->text(i) << "\n"; + } + out.close(); + } + } + else + { + QFile::remove(filepath); + } + emit apply(); +} + +void SetupDialogPrg::configCancel() +{ + //Stop grabbing Windows + gwm->blockSignals(true); + grabWin->setText(i18n("Grab Window")); + grabbing=0; + this->hide(); +} + +void SetupDialogPrg::closeEvent( QCloseEvent *e ) +{ + e->ignore(); + configCancel(); +} + +void SetupDialogPrg::chkFont() +{ + bool tmp; //just to save some code + + if(chk2->isChecked()) + { + tmp=true; + } + else + { + tmp=false; + } + xosdBold->setEnabled(tmp); + xosdItalic->setEnabled(tmp); + xosdSize->setEnabled(tmp); + spinBox2->setEnabled(tmp); + kColorCombo1->setEnabled(tmp); + kColorCombo_shadow->setEnabled(tmp); + xosdFont->setEnabled(tmp); + cbCleaner->setEnabled(tmp); +} + + +void SetupDialogPrg::xrma_clicked() +{ + if(xrma->isChecked()==true) {SleftRes->setEnabled(true); SHeight->setEnabled(true); PWidth->setEnabled(true);} + if(xrma->isChecked()==false) {SleftRes->setEnabled(false); SHeight->setEnabled(false); PWidth->setEnabled(false);} +} + +void SetupDialogPrg::chkTask() +{ + iconsChanged(); + bool tmp; + + if(chk5->isChecked()) + { + tmp=true; + } + else + { + tmp=false; + } + chk6->setEnabled(tmp); + currentDesk->setEnabled(tmp); + chkSshot->setEnabled(tmp); + chkGrouping->setEnabled(tmp); + cbMinimizedOnly->setEnabled(tmp); +} + +void SetupDialogPrg::chkHidden() +{ + bool tmp; + + if(chk1->isChecked()) + { + tmp=true; + } + else + { + tmp=false; + } + hideTimer->setEnabled(tmp); + hideOnClick->setEnabled(tmp); + cbStayBelow->setEnabled(!tmp); +} + +void SetupDialogPrg::applist_dropped(QDropEvent*e,const QValueList<QIconDragItem>&) +{ + KIconLoader icon_obj; + QStringList lst; + QString name; + int pos; + + QUriDrag::decodeLocalFiles(e, lst); + name=lst[0]; + + //Lets see if it is a desktop file + pos=name.findRev(".desktop", -1); + if(pos!=-1) + { + KSimpleConfig *desktopfile; + kdDebug(0) << "Desktop file dropped!" << endl; + desktopfile = new KSimpleConfig(lst[0], TRUE); + desktopfile->setGroup("Desktop Entry"); + appdlg->cmdname->setText(desktopfile->readEntry("Name")); + appdlg->cmdpath->setText(desktopfile->readEntry("Exec")); + appdlg->iconbutton->setIcon(desktopfile->readEntry("Icon")); + delete(desktopfile); + } + else + { + //It was not a dekstop file, so lets create a new entry + //Lets set a default name based on the program name + pos=name.findRev("/", -1); + if(pos!=-1) + { + name.remove(1, pos); + name.remove("/", TRUE); + } + + //Now we create and show the appProp dialog + //appdlg=new appPropPrg(); + appdlg->cmdname->setText(name); + appdlg->cmdpath->setText(lst[0]); + + //Based on the program name, lets try to set an icon; if it does + //not exists, the system will set the "default" icon + appdlg->iconbutton->setIcon(name); + } + appdlg->show(); +} + +void SetupDialogPrg::removeLauncher() +{ + if(fileName!=NULL) + { + QString question=i18n("Do you want to remove ") + fileName + QString("?"); + int remove = KMessageBox::questionYesNo(0, question, i18n("Remove Launcher")); + if(remove!=KMessageBox::Yes) return; + KSimpleConfig *desktopfile; + QDir homeDir = QDir::home(); + + if (homeDir.exists(progPath)) + { + QDir dir(menuPath); + QStringList fileListRemove; + fileListRemove = dir.entryList("*.desktop"); + for ( QStringList::Iterator it = fileListRemove.begin(); it != fileListRemove.end(); ++it ) + { + if ( ((*it) != ".") && ((*it) != "..") ) + { + desktopfile = new KSimpleConfig( menuPath + (*it), TRUE); + desktopfile->setGroup("Desktop Entry"); + if(desktopfile->readEntry("Name")==fileName) + { + kdDebug(0) << "Removing " << menuPath + (*it) << endl; + delete(desktopfile); + if(QFile::remove(menuPath+(*it))==TRUE) + { + kdDebug(0) << "Item removed!" << endl; + + //Lets update the launchers index + QString preffix; + fileListRemove.clear(); + fileListRemove=dir.entryList("*.desktop"); + QStringList fileListRemove2=fileListRemove; + + //Not really sure why I couldn't do this within the other for, something like fileListRemove[i].remove(0,2).prepend(preffix), but hell it works + for(unsigned int i=0; i<fileListRemove2.count(); i++) + { + fileListRemove2[i].remove(0,2); + } + + //Rename the files so they reflect their new position + for(unsigned int i=0; i<fileListRemove.count(); i++) + { + if(i<10) preffix=QString("0%1").arg(i); + if(i>=10) preffix=QString("%1").arg(i); + + dir.rename(fileListRemove[i], QString("%1%2").arg(preffix).arg(fileListRemove2[i])); + } + //End updating + + appClear(); + appFill(); + iconsChanged(); + } + else + { + kdDebug(0) << "Unable to remove file!" << endl; + } + return; + } + delete(desktopfile); + } + } + } + } +} + + +void SetupDialogPrg::grabWin_clicked() +{ + if(grabbing==0) + { + grabbing=1; + grabWin->setText(i18n("Grabbing...")); + gwm->blockSignals(false); + } + else + { + grabbing=0; + grabWin->setText(i18n("Grab Window")); + gwm->blockSignals(true); + } +} + + +void SetupDialogPrg::activeWindowChanged(WId id) +{ + KWin::WindowInfo winfo; + winfo=KWin::windowInfo(id); + QString ninfo=winfo.visibleName(); + + if(ninfo!=caption()) + { + in->setText(ninfo); + } +} + +void SetupDialogPrg::buttonadd_clicked() +{ + appdlg->cmdpath->setText(""); + appdlg->cmdname->setText(""); + appdlg->iconbutton->setIcon("unknown"); + appdlg->show(); +} + +void SetupDialogPrg::showEvent(QShowEvent *) +{ + //Here we fill the applist + appFill(); +} + +void SetupDialogPrg::appFill() +{ + // fill the application list. + KSimpleConfig *desktopfile; + + QDir homeDir = QDir::home(); + KIconLoader icon_obj; + QPixmap pixm; + + if(homeDir.exists(progPath)) + { + QDir dir(menuPath); + + fileList.clear(); + fileList = dir.entryList("*.desktop"); + for ( QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it ) + { + if ( ((*it) != ".") && ((*it) != "..") ) + { + desktopfile = new KSimpleConfig( menuPath + (*it), TRUE); + desktopfile->setGroup("Desktop Entry"); + QPixmap pixm=icon_obj.loadIcon(desktopfile->readEntry("Icon") ,KIcon::Desktop,0,KIcon::DefaultState,0L,false); + new KIconViewItem(applist, desktopfile->readEntry("Name"), pixm); + delete(desktopfile); + } + } + } +} + +void SetupDialogPrg::hideEvent ( QHideEvent * ) +{ + // the application list is erased here. + appClear(); +} + +void SetupDialogPrg::appClear() +{ + applist->clear(); +} + +void SetupDialogPrg::left() +{ + if (oldPos>0) {setnewpos(oldPos-1); oldPos--;iconsChanged();} +} + +void SetupDialogPrg::right() +{ + if (oldPos!=-1 && oldPos < (int)fileList.count()-1) {setnewpos(oldPos+1); oldPos++;iconsChanged();} +} + +void SetupDialogPrg::applist_clicked(QIconViewItem *e, const QPoint&) +{ + if(e!=NULL) + {oldPos=e->index();} + else + {oldPos=-1;} +} +void SetupDialogPrg::applist_contextMenuRequested(QIconViewItem *e,const QPoint&) +{ + if(e!=NULL) + { + KPopupMenu *popup=new KPopupMenu(); + KPopupMenu *setpos=new KPopupMenu(); + + fileName=e->text(); + oldPos=e->index(); + connect(setpos, SIGNAL(activated(int)), this, SLOT(setnewpos(int))); + + //Load desktop data + KSimpleConfig *desktopfile; + + QDir dir(menuPath); + fileList.clear(); + fileList = dir.entryList("*.desktop"); + int i=0; + for ( QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it ) + { + if ( ((*it) != ".") && ((*it) != "..") ) + { + desktopfile = new KSimpleConfig( menuPath + (*it), TRUE); + desktopfile->setGroup("Desktop Entry"); + int menustate=setpos->insertItem(QString("%1").arg(desktopfile->readEntry("Name")),i); + if(i==oldPos) {setpos->setItemEnabled(menustate, false);filepath=menuPath + (*it);} + delete(desktopfile); + i++; + } + } + //End Load + + popup->insertTitle(e->text()); + popup->insertItem(i18n("Swap with"), setpos); + popup->insertItem(i18n("&Edit item"), this, SLOT(editItem())); + popup->insertItem(i18n("Remove"), this, SLOT(removeLauncher())); + popup->exec(QCursor::pos()); + if(popup) delete(popup); + if(setpos) delete(setpos); + } + else + { + oldPos=-1; + } +} + +void SetupDialogPrg::editItem() +{ + KRun::runCommand("kfmclient openProperties " + filepath, "kfmclient", ""); +} + +void SetupDialogPrg::setnewpos(int newpos) +{ + kdDebug(0) << "New pos " << QString("0%1").arg(newpos) << "requested for: " << fileName<< endl; + if(newpos==oldPos) return; //Nothing to be done + computeNewPos(newpos); +} + +void SetupDialogPrg::computeNewPos(int pos) +{ + QString preffix, preffix2; + QDir dir(menuPath); + + fileList.clear(); + fileList = dir.entryList("*.desktop"); + + //Lets remove the preffix of the files from fileList + for(unsigned int i=0; i<fileList.count(); i++) + { + fileList[i]=fileList[i].remove(0,2); + } + + //Preffix for old position + if(oldPos<10) preffix=QString("0%1").arg(oldPos); + if(oldPos>=10) preffix=QString("%1").arg(oldPos); + + //Preffix for new position + if(pos<10) preffix2=QString("0%1").arg(pos); + if(pos>=10) preffix2=QString("%1").arg(pos); + + kdDebug(0) << "Old Position: " << oldPos << endl; + kdDebug(0) << "New Position: " << pos << endl; + + dir.rename(QString("%1%2").arg(preffix).arg(fileList[oldPos]), QString("%1%2").arg(preffix2).arg(fileList[oldPos])); + dir.rename(QString("%1%2").arg(preffix2).arg(fileList[pos]), QString("%1%2").arg(preffix).arg(fileList[pos])); + + appClear(); + appFill(); +} + +void SetupDialogPrg::chkImgSlot() +{ + if (chkImg->isChecked()) + { + chkSolid->setChecked(false); + } + else + { + chkSolid->setChecked(true); + } +} + +void SetupDialogPrg::chkSolidSlot() +{ + if (chkSolid->isChecked()) + { + chkImg->setChecked(false); + } + else + { + chkImg->setChecked(true); + }} + +#include "setupdialogprg.moc" diff --git a/src/setupdialogprg.h b/src/setupdialogprg.h new file mode 100644 index 0000000..5539c5a --- /dev/null +++ b/src/setupdialogprg.h @@ -0,0 +1,102 @@ +// +// C++ Interface: setupdialogprg +// +// Description: +// +// +// Author: KoolDock team <radix@kde.cl>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef SETUPDIALOGPRG_H +#define SETUPDIALOGPRG_H + +#include "setupdialog.h" +#include "apppropprg.h" + +// QT includes +#include <qcolor.h> +#include <qstring.h> +#include <qcheckbox.h> +#include <qlineedit.h> +#include <qspinbox.h> +#include <qfont.h> +#include <qptrlist.h> +#include <qtabwidget.h> +#include <qpushbutton.h> +#include <qradiobutton.h> + +// KDE includes +#include <kfontcombo.h> +#include <kcolorcombo.h> +#include <ktextedit.h> +#include <kdebug.h> +#include <kconfig.h> +#include <kfontdialog.h> +#include <kwinmodule.h> +#include <netwm.h> +#include <klineedit.h> + +/** +@author KoolDock team +*/ + +class KoolDock; + +class SetupDialogPrg : public SetupDialog +{ +Q_OBJECT + public: + SetupDialogPrg(QWidget *parent = 0, const char *name = 0); + ~SetupDialogPrg(); + appProp *appdlg; + QString progPath; + QString menuPath; + KWinModule *gwm; + KLineEdit *in; + QPushButton *up; + QPushButton *down; + int grabbing; + int oldPos; + QString fileName; + QStringList fileList; + QString filepath; + + public slots: + void editItem(); + void iconsChanged(); + void configOK(); + void configApply(); + void configCancel(); + void chkHidden(); + void chkImgSlot(); + void chkSolidSlot(); + void chkFont(); + void chkTask(); + void applist_dropped(QDropEvent*,const QValueList<QIconDragItem>&); + void buttonadd_clicked(); + void applist_clicked(QIconViewItem *, const QPoint&); + void appRestart(); + void appFill(); + void appClear(); + void grabWin_clicked(); + void activeWindowChanged(WId id); + void applist_contextMenuRequested(QIconViewItem*,const QPoint&); + void removeLauncher(); + void setnewpos(int); + void xrma_clicked(); + void left(); + void right(); + signals: + void apply(); + + private: + void computeNewPos(int); + + protected: + void closeEvent( QCloseEvent* ); + void showEvent ( QShowEvent * ); + void hideEvent ( QHideEvent * ); +}; +#endif diff --git a/src/xosd.cpp b/src/xosd.cpp new file mode 100644 index 0000000..656be2d --- /dev/null +++ b/src/xosd.cpp @@ -0,0 +1,226 @@ +#include "xosd.h" + +#include <qpainter.h> +#include <qbitmap.h> +#include <qstring.h> +#include <qfont.h> +#include <qfontmetrics.h> + +#include <qwidget.h> +#include <klocale.h> +#include <netwm.h> +#include <netwm_def.h> +#include <kwin.h> + +#include <kdebug.h> + +xosd::xosd(QWidget *parent, const char *name) : QWidget(parent, name, WStyle_Customize | WRepaintNoErase | WStyle_NoBorder | WDestructiveClose | WResizeNoErase | WMouseNoMask | WStyle_StaysOnTop | WX11BypassWM) +{ + info = new NETWinInfo( qt_xdisplay(), winId(), qt_xrootwin(), NET::WMState); + info->setDesktop( NETWinInfo::OnAllDesktops ); + hide(); + KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager); + setCaption("kooldock xosd window"); +} + +xosd::~xosd() +{ +} + +void xosd::setColor(QString color) +{ + fontColor=color; +} + +void xosd::setShadowColor(QString color) +{ + shadowColor=color; +} + +void xosd::setOrientation(int orientation, int w, int mh) +{ + fOrientation=orientation; + dw=w; + rdh=mh; + if (fCleaner==1) + { + //font is set, so program can get its height to prepare background buffer + QFontMetrics *metrics = new QFontMetrics(f); + h = metrics->height(); + + bgBuffer = QPixmap(dw, h); + maskBuffer = QPixmap(dw, h, true); + bgBuffer = QPixmap::grabWindow(qt_xrootwin(), 0, 0, dw, h); + lastX=0; + lastY=0; + } + +} + +//Enables/disables dynamic background +void xosd::setClear(int nClean) +{ + fCleaner = nClean; +} + +void xosd::setShadowOffset(int off) +{ + shadowOffset=off; +} + +void xosd::setText(QString t) +{ + //setMask(QRegion(0,0,0,0)); + // NOTICE: it appears that with WX11BypassWM, resize() doesn't flick the widget anymore :) + // so, setMask() is no more needed. + // -- Matias + resize(0,0); + text = t; + QFontMetrics *metrics = new QFontMetrics(f); + w = metrics->width(text); + w = w + shadowOffset + 5; // 5 pixels more + h = metrics->height(); + yOffset = metrics->height()-metrics->descent(); + update(); +} + +void xosd::setFont(QString font) +{ + f.setFamily(font); +} + +void xosd::setItalic() +{ + f.setItalic(TRUE); +} + +void xosd::setBold() +{ + f.setBold(TRUE); +} + +void xosd::setSize(int size) +{ + f.setPointSize(size); + fontSize = size; +} + +/*int xosd::w() +{ + QFontMetrics *metrics = new QFontMetrics(f); + return (metrics->width(text) + shadowOffset + 5); + +} + +int xosd::h() +{ + QFontMetrics *metrics = new QFontMetrics(f); + return metrics->height(); +}*/ + +void xosd::paintEvent(QPaintEvent *) +{ + int i, j; + + resize(w,h); + + QPixmap pm(size()); + QBitmap bm(size()); + QPainter p; + + //Drawing text + p.begin(&pm, this); + if (fCleaner==1) + { + //Dynamic background - look cleaner + bitBlt(&pm, 0, 0, &bgBuffer, lastX, 0, w, h); + } + else + { + //One colour background - work faster + p.fillRect (rect(), QColor(shadowColor)); + } + + p.setPen( QColor(shadowColor) ); + p.setFont(f); + p.drawText(shadowOffset, yOffset + shadowOffset, text, AlignCenter); // draw shadow text + + // now, draw normal text + p.setPen( QColor(fontColor) ); + + p.drawText(1, yOffset, text, AlignCenter); // draw front text + + p.end(); + + //Drawing mask + p.begin(&bm, this); + // now we must draw the text with black color for making the mask + p.setPen( Qt::white ); + p.fillRect (rect(), Qt::black); + p.setFont(f); + for (i=-fCleaner;i<=fCleaner;i++) + { + for (j=-fCleaner;j<=fCleaner;j++) + { + p.drawText(shadowOffset+i, yOffset + shadowOffset+j, text, AlignCenter); // shadow + p.drawText(1+i, yOffset+j, text, AlignCenter); // front + } + } + p.end(); + bitBlt(this, 0, 0, &pm); // update the widget + if (fCleaner==1) bitBlt(&maskBuffer, 0, 0, &bm); + + info->setState(NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager, NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager); + setMask(bm); +} + +void xosd::move2(int x, int y) +{ + + //bit block transfer don't work propertly with too less cursor position changes + if (abs(lastY-y)>2 || abs(lastX-x)>2) + { + if (fCleaner==1) + { + QPixmap tmpBuffer; + //window is not hidden + if (y!=rdh) + { + tmpBuffer = QPixmap::grabWindow(qt_xrootwin(), 0, y, dw, h); + if (lastY!=rdh) + { + //fill background covered with the text with cached version + if (fOrientation==0 ) //horizontal + { + bitBlt(&tmpBuffer, lastX, 0, &maskBuffer, 0, 0, w, h, Qt::AndROP);//copying part, which hides only the text + bitBlt(&bgBuffer, lastX, 0, &maskBuffer, 0, 0, w, h, Qt::NotAndROP);//so the background won't be covered by + bitBlt(&tmpBuffer, lastX, 0, &bgBuffer, lastX, 0, w, h, Qt::OrROP);//currently visible text. + } + if (fOrientation==1) //vertical + { + if (y<lastY && (y+h)>lastY) + { + bitBlt(&tmpBuffer, lastX, lastY-y, &maskBuffer, 0, 0, w, h, Qt::AndROP); + bitBlt(&bgBuffer, lastX, 0, &maskBuffer, 0, 0, w, h, Qt::NotAndROP); + bitBlt(&tmpBuffer, lastX, lastY-y, &bgBuffer, lastX, 0, w, h, Qt::OrROP); + } + if (y>lastY && (y-lastY)<h) + { + bitBlt(&tmpBuffer, lastX, 0, &maskBuffer, 0, 0, w, h, Qt::AndROP); + bitBlt(&bgBuffer, lastX, y-lastY, &maskBuffer, 0, 0, w, h, Qt::NotAndROP); + bitBlt(&tmpBuffer, lastX, 0, &bgBuffer, lastX, y-lastY, w, h, Qt::OrROP); + } + } + } + + } + bitBlt(&bgBuffer,0,0,&tmpBuffer); + lastX=x; + paintEvent(NULL); + } + + move(x,y); + lastX=x; + lastY=y; + } +} diff --git a/src/xosd.h b/src/xosd.h new file mode 100644 index 0000000..b40d8ab --- /dev/null +++ b/src/xosd.h @@ -0,0 +1,58 @@ +#ifndef XOSD_H_ +#define XOSD_H_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <qstring.h> +#include <qwidget.h> +#include <qfont.h> +#include <qpixmap.h> +#include <qbitmap.h> + +#include <netwm.h> +#include <kwin.h> + +class xosd : public QWidget +{ +Q_OBJECT + public: + xosd(QWidget* parent=0, const char *name=0); + + virtual ~xosd(); + void setText(QString t); + void setFont(QString font); + void setItalic(); + void setBold(); + void setSize(int size); + void setColor(QString color); + void setShadowColor(QString color); + void setShadowOffset(int off); + void move2(int x, int y); + void setOrientation(int orientation, int w, int mh); + void setClear(int nClean); + int yOffset; + int w, h; + int fontSize; + int fontStyle; + QString fontFamily; + + private: + NETWinInfo *info; + QString text; + QFont f; + QString fontColor; + QString shadowColor; + int shadowOffset; + int fOrientation; + QPixmap bgBuffer; + int dw, rdh; + int lastX, lastY; + int fCleaner; + QPixmap maskBuffer; + + protected: + void paintEvent(QPaintEvent *); +}; +#endif // XOSD_H_ |