📄 ksmoothdock.cpp~
字号:
if (id == winId()) return; if (!m_showTaskbar) return; bool iconChanged = (properties & NET::WMIcon); bool nameChanged = (properties & NET::WMName); bool deskChanged = (properties & NET::WMDesktop); bool stateChanged = (properties & NET::WMState); KWin::WindowInfo info(id, 0, 0); if (!m_showWindowsAllDesktops && !info.onAllDesktops() && info.desktop() != KWin::currentDesktop() && !deskChanged) return; if (deskChanged && !m_showWindowsAllDesktops) { if (info.desktop() == KWin::currentDesktop()) { // a window has been moved to the current desktop, add it windowAdded(id); } else { // a window may have been moved to a different desktop, remove it windowRemoved(id); } } Task task; for (unsigned int i = 0; i < m_items.size(); i++) { // if the item is a task, check its id Task task; if (typeid(*m_items[i]) == typeid(task)) { Task* t = dynamic_cast<Task*>(m_items[i]); if (t->getWinId() == id) { if (nameChanged) { // Window title changed. t->setDescription(info.name()); } if (iconChanged) { // Window icon changed. QPixmap pix = KWin::icon(id, m_baseIconSize, m_baseIconSize); t->setIcon(pix); m_state->updateItem(i); } if (stateChanged) { if (info.state() & NET::DemandsAttention) { // demand attention t->setDemandsAttention(true); } else if (t->getDemandsAttention()) { t->setDemandsAttention(false); } } break; } } }}/** * Update the dock when the active window has been changed */void KSmoothDock::activeWindowChanged(WId id) { m_state->activeWindowChanged(id);}/** * Update the dock when the current desktop has been changed */void KSmoothDock::currentDesktopChanged(int desktop) { if (!m_showWindowsAllDesktops) { loadLaunchers(); initPager(); loadTasks(); initClock(); updateLayout(false); }}/** * Update a specific item */void KSmoothDock::updateItem(int itemId) { for (unsigned int i = 0; i < m_items.size(); i++) { if (m_items[i]->getItemId() == itemId) { m_state->updateItem(i); break; } }}/** * Config the launchers */void KSmoothDock::configLaunchers() { m_launcherConfigDialog->update(); m_launcherConfigDialog->show();}/** * Config the dock */void KSmoothDock::config() { m_configDialog->updateValues(); m_configDialog->show();}/** * Switch the zoom mode */void KSmoothDock::switchZoomMode() { if (m_zoomMode == NORMAL_ZOOM) { m_zoomMode = PARABOLIC_ZOOM; if (m_parabolicZoomState == NULL) m_parabolicZoomState = new ParabolicZoomState(this); m_state = m_parabolicZoomState; } else { // Parabolic zoom m_zoomMode = NORMAL_ZOOM; if (m_normalZoomState == NULL) m_normalZoomState = new NormalZoomState(this); m_state = m_normalZoomState; } // init icon sizes if (m_zoomMode == NORMAL_ZOOM) { m_baseIconSize = m_NzBaseIconSize; m_smallIconSize = m_NzSmallIconSize; m_bigIconSize = m_NzBigIconSize; } else { m_baseIconSize = m_PzBaseIconSize; m_smallIconSize = m_PzSmallIconSize; m_bigIconSize = m_PzBigIconSize; } loadLaunchers(); initPager(); loadTasks(); initClock(); updateLayout(); updateLayout(); saveConfig();}/** * Hide the dock (to a buttonised state) */void KSmoothDock::buttonise() { if (m_buttonisedState == NULL) m_buttonisedState = new ButtonisedState(this); m_state = m_buttonisedState; updateLayout();}/** * Show the about dialog */void KSmoothDock::about() { m_aboutDialog->show();}/** * Update the launchers */void KSmoothDock::updateLaunchers() { // load quick launchers loadLaunchers(); // initiate the pager initPager(); // load the running tasks loadTasks(); // init clock initClock(); // update layout updateLayout();}/** * Set position to the top of the screen */void KSmoothDock::setPositionTop() { setPosition(TOP);}/** * Set position to the bottom of the screen */void KSmoothDock::setPositionBottom() { setPosition(BOTTOM);}/** * Set position to the left of the screen */void KSmoothDock::setPositionLeft() { setPosition(LEFT);}/** * Set position to the right of the screen */void KSmoothDock::setPositionRight() { setPosition(RIGHT);}/** * Set position of the dock * @param position the new position */void KSmoothDock::setPosition(PanelPosition position) { if (m_position == position) return; m_position = position; m_orientation = ((position == TOP) || (position == BOTTOM)) ? Qt::Horizontal : Qt::Vertical; loadLaunchers(); initPager(); loadTasks(); initClock(); updateLayout(); updateLayout(); saveConfig();}/** * Switch autohide mode on/off */void KSmoothDock::switchAutohideMode() { m_isAutohide = 1 - m_isAutohide; m_state->updateAutohideMode(); saveConfig();}/// PROTECTED ////** * Paint event handler * * @param e the paint event */void KSmoothDock::paintEvent(QPaintEvent* e) { //std::cout << "Paint event" << std::endl; m_state->paintEvent(e);}// Mouse pressed event handlervoid KSmoothDock::mousePressEvent(QMouseEvent* e) { m_state->mousePressEvent(e);}// Mouse moved event handlervoid KSmoothDock::mouseMoveEvent(QMouseEvent* e) { m_state->mouseMoveEvent(e);}// Enter event handlervoid KSmoothDock::enterEvent(QEvent* e) { m_state->enterEvent(e);}// Leave event handlervoid KSmoothDock::leaveEvent(QEvent* e) { m_state->leaveEvent(e);}/// PRIVATE ////** * Init the dock */void KSmoothDock::init() { KWin::setOnAllDesktops(winId(), true); KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager); KWin::setType(winId(), NET::Dock); setBackgroundMode(NoBackground); setMouseTracking(TRUE);}/** * Load configuration data */void KSmoothDock::loadConfig(bool reset) { KConfig* config = KGlobal::config(); config->setGroup("ksmoothdock"); QDir home_dir = QDir::home(); QString conf_file = locateLocal("config", "ksmoothdockrc"); bool first_run; if (reset) { first_run = true; } else { first_run = !home_dir.exists(conf_file); } if (first_run) { // first run of KSmoothDock, or in case of reset WelcomeDialog welcome(this, "Welcome to KSmoothDock", TRUE); welcome.exec(); m_zoomMode = welcome.getZoomMode(); m_showPager = welcome.isShowingPager(); m_showTaskbar = welcome.isShowingTaskbar(); m_showWindowsAllDesktops = welcome.isShowingWindowsAllDesktops(); m_showClock = welcome.isShowingClock(); m_isAutohide = welcome.isAutohide(); m_position = welcome.getPosition(); } else { m_zoomMode = static_cast<ZoomMode> (config->readNumEntry("ZoomMode", NORMAL_ZOOM)); m_showPager = config->readNumEntry("ShowPager", 1); m_showTaskbar = config->readNumEntry("ShowTaskbar", 1); m_showWindowsAllDesktops = config->readNumEntry("ShowWindowsFromAllDesktops", 1); m_showClock = config->readNumEntry("ShowClock", 1); m_isAutohide = config->readNumEntry("Autohide", 0); m_position = static_cast<PanelPosition> (config->readNumEntry("PanelPosition", RIGHT)); } m_NzZoomSpeed = config->readNumEntry("NormalZoomSpeed", 16); m_PzZoomSpeed = config->readNumEntry("ParabolicZoomSpeed", 16); m_showNotification = config->readNumEntry("ShowNotification", 0); m_showBorders = config->readNumEntry("ShowBorders", 1); m_borderColor = QColor(config->readEntry("BorderColor", "#b1c4de")); m_NzSmallIconSize = config->readNumEntry("SmallIconSizeNormalZoom", NZ_DEFAULT_SMALL_SIZE); m_NzBigIconSize = config->readNumEntry("BigIconSizeNormalZoom", NZ_DEFAULT_BIG_SIZE); m_NzBaseIconSize = config->readNumEntry("BaseIconSizeNormalZoom", NZ_DEFAULT_BASE_SIZE); m_PzSmallIconSize = config->readNumEntry("SmallIconSizeParabolicZoom", PZ_DEFAULT_SMALL_SIZE); m_PzBigIconSize = config->readNumEntry("BigIconSizeParabolicZoom", PZ_DEFAULT_BIG_SIZE); m_PzBaseIconSize = config->readNumEntry("BaseIconSizeParabolicZoom", PZ_DEFAULT_BASE_SIZE); m_dockOpacity = config->readNumEntry("DockOpacity", DEFAULT_DOCK_OPACITY); m_backgroundColor = QColor(config->readEntry("BackgroundColor", "#638abd")); m_separatorColor = QColor(config->readEntry("SeparatorColor", "#b1c4de")); m_screenWidth = config->readNumEntry("ScreenWidth", 0); m_activeDesktopColor = QColor(config->readEntry("ActiveDesktopColor", "yellow")); m_inactiveDesktopColor = QColor(config->readEntry("InactiveDesktopColor", "white")); m_showTooltip = config->readNumEntry("ShowTooltip", 1); m_tooltipFontFace = config->readEntry("TooltipFontFace", "Sans Serif"); m_tooltipFontSize = config->readNumEntry("TooltipFontSize", 18); m_tooltipFontIsItalic = config->readNumEntry("TooltipFontItalic", 1); m_tooltipFontIsBold = config->readNumEntry("TooltipFontBold", 1); m_tooltipFontColor = QColor(config->readEntry("TooltipFontColor", "white")); m_tooltipBackgroundColor = QColor(config->readEntry("TooltipFontBgColor", "black")); m_use24HourClock = config->readNumEntry("Use24HourClock", 1); m_clockFontColor = QColor(config->readEntry("ClockFontColor", "white")); m_clockFontFace = config->readEntry("ClockFontFace", "Sans Serif"); int def_size = (m_zoomMode == NORMAL_ZOOM) ? m_NzSmallIconSize/2 : m_PzSmallIconSize/2; m_clockFontSize = config->readNumEntry("ClockFontSize", def_size); m_clockFontIsItalic = config->readNumEntry("ClockFontItalic", 0); m_clockFontIsBold = config->readNumEntry("ClockFontBold", 0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -