⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ksmoothdock.cpp

📁 thes is veer good (ksmoutTool)
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/*************************************************************************** *   Copyright (C) 2007 by the KSmoothDock team   * *   dangvd@yahoo.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.             * ***************************************************************************//// KSmoothDock main class. VERSION: 4.5#include "ksmoothdock.h"#include <iostream>#include <iterator>#include <qdir.h>#include <kapplication.h>#include <kconfig.h>#include <kdialogbase.h>#include <kglobal.h>#include <klocale.h>#include <kmessagebox.h>#include <kstandarddirs.h>#include <kwin.h>#include <dcopclient.h>#include "aboutdialog.h"#include "buttonisedstate.h"#include "clock.h"#include "configdialog.h"#include "desktopselector.h"#include "dockstate.h"#include "launcher.h"#include "launcherconfigdialog.h"#include "normalzoomstate.h"#include "paraboliczoomstate.h"#include "separator.h"#include "task.h"#include "welcomedialog.h"/// PUBLIC ////**  * Constructor */KSmoothDock::KSmoothDock(bool resetConfig, bool resetLaunchers) : QWidget(0, "KSmoothDock", WStyle_Customize | WStyle_NoBorder | WNoAutoErase) {    // init the dock    init();    // load configuration    loadConfig(resetConfig);    // initiate variables    initVariables();        // load quick launchers    loadLaunchers(resetLaunchers);    // initiate the pager    initPager();    // load the running tasks    loadTasks();    // init clock    initClock();    // update layout    updateLayout();    // check kicker position    checkKickerPosition();}/**  * Destructor */KSmoothDock::~KSmoothDock() {    // free resources    for (unsigned int i = 0; i < m_items.size(); i++) {        delete m_items[i];    }    delete m_wallpaperManager;    if (m_normalZoomState != NULL)        delete m_normalZoomState;    if (m_parabolicZoomState != NULL)        delete m_parabolicZoomState;    if (m_buttonisedState != NULL)        delete m_buttonisedState;}/** * Get the current active window */WId KSmoothDock::activeWindow() {    return m_windowManager.activeWindow();}/** * Get the position of the dock */PanelPosition KSmoothDock::getPosition() {    return m_position;}/** * Get the zoom mode of the dock */ZoomMode KSmoothDock::getZoomMode() {    return m_zoomMode;}/** * Get active desktop color */QColor KSmoothDock::getActiveDesktopColor() {    return m_activeDesktopColor;}/** * Get inactive desktop color */QColor KSmoothDock::getInactiveDesktopColor() {    return m_inactiveDesktopColor;}/** * Get separator color */QColor KSmoothDock::getSeparatorColor() {    return m_separatorColor;}/** * Get clock font face */QString KSmoothDock::getClockFontFace() {    return m_clockFontFace;}/** * Get small icon size */int KSmoothDock::getSmallIconSize() {    return m_smallIconSize;}/** * Update tooltip */void KSmoothDock::updateTooltip() {    if (m_showTooltip) {        m_tooltip.setFontFace(m_tooltipFontFace);        m_tooltip.setFontSize(m_tooltipFontSize);        m_tooltip.setFontBold(m_tooltipFontIsBold);        m_tooltip.setFontItalic(m_tooltipFontIsItalic);        m_tooltip.setFontColor(m_tooltipFontColor);        m_tooltip.setBackgroundColor(m_tooltipBackgroundColor);    }}/** * Update clock */void KSmoothDock::updateClock() {    if (m_showClock) {        DockItem* item = m_items[m_items.size() - 1];        Clock c_test;        if (typeid(*item) == typeid(c_test)) {            Clock* c = dynamic_cast<Clock*>(item);            c->set24HourClock(m_use24HourClock);            c->setFontFace(m_clockFontFace);            c->setFontSize(m_clockFontSize);            c->setFontBold(m_clockFontIsBold);            c->setFontItalic(m_clockFontIsItalic);            c->setFontColor(m_clockFontColor);            repaint();        }    }}/** * Show the popup menu */void KSmoothDock::showPopupMenu(const QPoint& pos) {    KPopupMenu popup(this);    popup.insertItem(i18n("Edit Quick Launch &Menu"), this, SLOT(configLaunchers()));    popup.insertItem(i18n("Edit &Preferences"), this, SLOT(config()));    popup.insertSeparator();    if (m_zoomMode == NORMAL_ZOOM)        popup.insertItem(i18n("Switch to Parabolic &Zooming Mode"), this, SLOT(switchZoomMode()));    else        popup.insertItem(i18n("Switch to Normal &Zooming Mode"), this, SLOT(switchZoomMode()));    popup.insertSeparator();        KPopupMenu position(&popup);    position.insertItem(i18n("Top"), this, SLOT(setPositionTop()), 0, 0);    position.insertItem(i18n("Bottom"), this, SLOT(setPositionBottom()), 0, 1);    position.insertItem(i18n("Left"), this, SLOT(setPositionLeft()), 0, 2);    position.insertItem(i18n("Right"), this, SLOT(setPositionRight()), 0, 3);    switch(m_position) {    case LEFT:        position.setItemChecked(2, true);        break;    case RIGHT:        position.setItemChecked(3, true);        break;    case TOP:        position.setItemChecked(0, true);        break;    case BOTTOM:        position.setItemChecked(1, true);        break;    default:        break;    }    popup.insertItem("Position", &position);    popup.insertItem(i18n("&Hide"), this, SLOT(buttonise()), 0, 4);    if (m_isAutohide) {        popup.setItemEnabled(4, false);    }            popup.insertItem(i18n("H&ide Automatically"), this, SLOT(switchAutohideMode()), 0, 5);    if (m_isAutohide) {        popup.setItemChecked(5, true);    }    popup.insertSeparator();    popup.insertItem(i18n("&About"), this, SLOT(about()));    popup.insertSeparator();    popup.insertItem(i18n("E&xit"), this, SLOT(close()));    popup.exec(pos);}/** * Config the dock */void KSmoothDock::config(int tabIndex) {    if (tabIndex > -1)        m_configDialog->setCurrentPage(tabIndex);    config();}/** * Set the desktop icons area */void KSmoothDock::setDesktopIconsArea(int left, int top, int width, int height) {    DCOPClient* client = KApplication::dcopClient();    if (!client->isAttached()) {        client->attach();        client->registerAs("KSmoothDock");    }    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);    }}/** * Exit the dock */void KSmoothDock::exit() {    close();}/** * Update the dock when the background has been changed, reload the wallpaper if necessary */void KSmoothDock::updateBackground(const QPixmap& pix) {    if (m_wallpaperManager->wallpapersChanged())        m_wallpaperManager->loadWallpaper();    else        updateBackground();}/** * Update background, no wallpaper reload */void KSmoothDock::updateBackground() {    m_state->updateBackground();}/**  * Update the dock when a window has been added */void KSmoothDock::windowAdded(WId id) {    if (id == winId()) {        m_state->dockCreatedEvent();        return;    }    if (!m_showTaskbar)        return;    if (!m_showWindowsAllDesktops) {        KWin::WindowInfo info(id, 0, 0);        if (!info.onAllDesktops() && info.desktop() != KWin::currentDesktop())            return;    }    addTask(id, true);    updateLayout(false);}/** * Update the dock when a window has been removed */void KSmoothDock::windowRemoved(WId id) {    if (!m_showTaskbar)        return;    Task task;        std::vector<DockItem*>::iterator it = m_items.begin();    for (unsigned int i = 0; i < m_items.size(); i++, it++) {        // if the item is a task, check its id        if (typeid(*m_items[i]) == typeid(task)) {            Task* t = dynamic_cast<Task*>(m_items[i]);            if (t->getWinId() == id) {                // remove the task                m_items.erase(it);                // free memory                delete t;                // update layout                updateLayout(false);                break;            }        }    }    }/** * Update the dock when a window has been changed */void KSmoothDock::windowChanged(WId id, unsigned int properties) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -